File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -159,6 +159,14 @@ def write_config(io)
159159 @fields . each { |field | io . puts field . to_config ( @name ) }
160160 end
161161
162+ def write_class ( io )
163+ layout = generate_layout . gsub ( /\n / , '' ) . squeeze ( ' ' )
164+ struct_name = @struct_name . split ( ' ' ) . last . capitalize + "_t"
165+ struct_class = "class #{ struct_name } < FFI::Struct; #{ layout } ; end"
166+
167+ io . puts "rbx.platform.#{ @name } .class = #{ struct_class } "
168+ end
169+
162170 def generate_layout
163171 buf = ""
164172
Original file line number Diff line number Diff line change @@ -62,7 +62,7 @@ file 'runtime/platform.conf' => deps do |task|
6262 s . name 'struct timeval'
6363 s . field :tv_sec , :time_t
6464 s . field :tv_usec , :suseconds_t
65- end . write_config ( f )
65+ end . tap { | struct | struct . write_config ( f ) ; struct . write_class ( f ) }
6666
6767 Rubinius ::FFI ::Generators ::Structures . new 'sockaddr_in' do |s |
6868 if BUILD_CONFIG [ :windows ]
You can’t perform that action at this time.
0 commit comments