# File lib/generator/type.rb, line 44 44: def initialize(params = { }) 45: super 46: params = { :declaration => get_full_decl, :typedefs => { } }.merge(params) 47: @full_decl = params[:declaration] 48: @typedefs = params[:typedefs] || { } 49: @declaration = Declaration.new(@full_decl) 50: @is_pointer = 0 51: end
# File lib/generator/type.rb, line 86 86: def array 87: if @declaration.is_array? 88: num = @full_decl.scan(ArrayRE).flatten[0] 89: "[#{ffi_type_from(@full_decl.gsub!(/#{ArrayRE}\./, ''))}, #{num}]" 90: end 91: end
# File lib/generator/type.rb, line 101 101: def callback 102: ":#{@full_decl.scan(/^callback\s(\w+)/).flatten[0]}" if @declaration.is_callback? 103: end
# File lib/generator/type.rb, line 68 68: def constant 69: ffi_type_from(@full_decl.scan(/^q\(const\)\.(.+)/).flatten[0]) if @declaration.is_constant? 70: end
# File lib/generator/type.rb, line 59 59: def decl 60: get_attr('decl').to_s 61: end
# File lib/generator/type.rb, line 98 98: def enum 99: ffi_type_from(Generator::TYPES['int']) if @declaration.is_enum? 100: end
# File lib/generator/type.rb, line 113 113: def ffi_type_from(full_decl) 114: @full_decl = full_decl 115: @declaration = Declaration.new(full_decl) 116: constant || volatile || 117: typedef || 118: pointer || 119: enum || 120: native || 121: struct || 122: union || 123: array || 124: inline_callback || 125: callback || 126: undefined(full_decl) 127: end
# File lib/generator/type.rb, line 56 56: def get_full_decl 57: get_attr('decl').to_s + get_attr('type').to_s if @node 58: end
# File lib/generator/type.rb, line 104 104: def inline_callback 105: Callback.new(:node => @node, :inline => true, :typedefs => @typedefs).to_s if @declaration.is_inline_callback? 106: end
# File lib/generator/type.rb, line 65 65: def native 66: ffi_type_from(Generator::TYPES[@full_decl]) if @declaration.is_native? 67: end
# File lib/generator/type.rb, line 74 74: def pointer 75: if @declaration.is_pointer? or @is_pointer > 0 76: @is_pointer += 1 77: if @full_decl.scan(/^p\.(.+)/).flatten[0] 78: ffi_type_from(@full_decl.scan(/^p\.(.+)/).flatten[0]) 79: elsif @full_decl == 'char' and @is_pointer == 2 80: ':string' 81: else 82: ':pointer' 83: end 84: end 85: end
# File lib/generator/type.rb, line 92 92: def struct 93: Struct.camelcase(@full_decl.scan(/^struct\s(\w+)/).flatten[0]) if @declaration.is_struct? 94: end
# File lib/generator/type.rb, line 62 62: def type 63: get_attr('type').to_s 64: end
# File lib/generator/type.rb, line 107 107: def typedef 108: ffi_type_from(@typedefs[@full_decl]) if @typedefs.has_key?(@full_decl) 109: end
# File lib/generator/type.rb, line 110 110: def undefined(type) 111: "#{type}" 112: end
Disabled; run with --debug to generate this.
Generated with the Darkfish Rdoc Generator 1.1.6.