FFI::Generator::Type

Constants

ArraySizeRE
ArrayRE

Attributes

full_decl[R]

Public Class Methods

new(params = { }) click to toggle source
    # 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

Public Instance Methods

to_s() click to toggle source
    # File lib/generator/type.rb, line 52
52:       def to_s
53:         ffi_type_from(@full_decl)
54:       end

Private Instance Methods

array() click to toggle source
    # 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
callback() click to toggle source
     # 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
constant() click to toggle source
    # 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
decl() click to toggle source
    # File lib/generator/type.rb, line 59
59:       def decl
60:         get_attr('decl').to_s
61:       end
enum() click to toggle source
     # File lib/generator/type.rb, line 98
 98:       def enum
 99:         ffi_type_from(Generator::TYPES['int']) if @declaration.is_enum?
100:       end
ffi_type_from(full_decl) click to toggle source
     # 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
get_full_decl() click to toggle source
    # 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
inline_callback() click to toggle source
     # 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
native() click to toggle source
    # File lib/generator/type.rb, line 65
65:       def native
66:         ffi_type_from(Generator::TYPES[@full_decl]) if @declaration.is_native?
67:       end
pointer() click to toggle source
    # 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
struct() click to toggle source
    # 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
type() click to toggle source
    # File lib/generator/type.rb, line 62
62:       def type
63:         get_attr('type').to_s
64:       end
typedef() click to toggle source
     # 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
undefined(type) click to toggle source
     # File lib/generator/type.rb, line 110
110:       def undefined(type)
111:         "#{type}"
112:       end
union() click to toggle source
    # File lib/generator/type.rb, line 95
95:       def union
96:         Union.camelcase(@full_decl.scan(/^union\s(\w+)/).flatten[0]) if @declaration.is_union?
97:       end
volatile() click to toggle source
    # File lib/generator/type.rb, line 71
71:       def volatile
72:         ffi_type_from(@full_decl.scan(/^q\(volatile\)\.(.+)/).flatten[0]) if @declaration.is_volatile?
73:       end

Disabled; run with --debug to generate this.

[Validate]

Generated with the Darkfish Rdoc Generator 1.1.6.