Builds a class based on information found in the introspection repository.
Builds modules and classes based on information found in the introspection repository. Call its ::build_module and ::build_class methods to create the modules and classes used in your program.
TODO: Move elsewhere, perhaps to Builder::Function.
# File lib/gir_ffi/builder.rb, line 42 def self.attach_ffi_function lib, info sym = info.symbol return if lib.method_defined? sym argtypes = ffi_function_argument_types info rt = ffi_function_return_type info lib.attach_function sym, argtypes, rt end
# File lib/gir_ffi/builder.rb, line 17 def self.build_by_gtype gtype info = GObjectIntrospection::IRepository.default.find_by_gtype gtype if info.nil? Builder::Type::Unintrospectable.new(gtype).build_class else build_class info end end
# File lib/gir_ffi/builder.rb, line 34 def self.build_callback callable_info, &block rettype = ffi_callback_return_type callable_info argtypes = ffi_callback_argument_types callable_info FFI::Function.new rettype, argtypes, &block end
# File lib/gir_ffi/builder.rb, line 13 def self.build_class info Builder::Type.build(info) end
# File lib/gir_ffi/builder.rb, line 26 def self.build_module namespace, version=nil Builder::Module.new(namespace, version).generate end
# File lib/gir_ffi/builder.rb, line 30 def self.build_module_non_recursive namespace, version=nil Builder::Module.new(namespace, version).build_module_non_recursive end
# File lib/gir_ffi/builder.rb, line 62 def self.ffi_callback_argument_types info types = info.args.map do |arg| itypeinfo_to_callback_ffitype arg.argument_type end types.unshift(:pointer).push(:pointer) end
# File lib/gir_ffi/builder.rb, line 69 def self.ffi_callback_return_type info ffi_function_return_type info end
# File lib/gir_ffi/builder.rb, line 51 def self.ffi_function_argument_types info types = info.args.map { |arg| iarginfo_to_ffitype arg } if info.info_type == :function types.unshift :pointer if info.method? types << :pointer if info.throws? end types end
# File lib/gir_ffi/builder.rb, line 73 def self.ffi_function_return_type info itypeinfo_to_ffitype info.return_type end
# File lib/gir_ffi/builder.rb, line 106 def self.iarginfo_to_ffitype info return :pointer if info.direction != :in return itypeinfo_to_ffitype info.argument_type end
# File lib/gir_ffi/builder.rb, line 77 def self.itypeinfo_to_callback_ffitype info tag = info.tag return :string if tag == :utf8 return :pointer if info.pointer? if tag == :interface case info.interface.info_type when :enum, :flags :int32 else :pointer end else return TypeMap.map_basic_type tag end end
# File lib/gir_ffi/builder.rb, line 95 def self.itypeinfo_to_ffitype info return :pointer if info.pointer? tag = info.tag if tag == :interface return build_class info.interface else return TypeMap.map_basic_type tag end end