Class: Rbind::GeneratorRuby::RBindHelper

Inherits:
HelperBase
  • Object
show all
Defined in:
lib/rbind/generator_ruby.rb

Instance Attribute Summary collapse

Attributes inherited from HelperBase

#name

Instance Method Summary collapse

Methods inherited from HelperBase

#binding, #full_name

Constructor Details

#initialize(name, root) ⇒ RBindHelper

Returns a new instance of RBindHelper.



139
140
141
# File 'lib/rbind/generator_ruby.rb', line 139

def initialize(name, root)
    super
end

Instance Attribute Details

#library_nameObject

TODO



137
138
139
# File 'lib/rbind/generator_ruby.rb', line 137

def library_name
  @library_name
end

Instance Method Details

#add_accessorsObject



155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
# File 'lib/rbind/generator_ruby.rb', line 155

def add_accessors
    str = ""
    @root.each_type do |t|
        next if t.basic_type? && !t.is_a?(RNamespace)
        str += "\n#methods for #{t.full_name}\n"
        if t.cdelete_method
            str += "attach_function :#{normalize_m t.cdelete_method},"\
            ":#{t.cdelete_method},[#{normalize_t t.full_name}],:void\n"
            str += "attach_function :#{normalize_m t.cdelete_method}_struct,"\
            ":#{t.cdelete_method},[#{normalize_t t.full_name}Struct],:void\n"
        end
        str += t.operations.map do |ops|
            ops.map do |op|
                return_type = if op.constructor?
                                  "#{normalize_t op.owner.full_name}"
                              else
                                  if op.return_type.basic_type?
                                      ":#{normalize_bt op.return_type.csignature}"
                                  else
                                      "#{normalize_t op.return_type.full_name}"
                                  end
                              end
                args = op.cparameters.map do |p|
                    if p.type.basic_type?
                        ":#{normalize_bt p.type.csignature}"
                    else
                        "#{normalize_t p.type.full_name}"
                    end
                end
                fct_name = normalize_m op.cname
                "attach_function :#{fct_name},:#{op.cname},[#{args.join(",")}],#{return_type}\n"
            end.join
        end.join
        str+"\n"
    end
    str+"\n"
    str.gsub(/\n/,"\n        ")
end

#normalize_bt(name) ⇒ Object



147
148
149
# File 'lib/rbind/generator_ruby.rb', line 147

def normalize_bt(name)
    GeneratorRuby.normalize_basic_type_name name
end

#normalize_m(name) ⇒ Object



151
152
153
# File 'lib/rbind/generator_ruby.rb', line 151

def normalize_m(name)
    GeneratorRuby.normalize_method_name name
end

#normalize_t(name) ⇒ Object



143
144
145
# File 'lib/rbind/generator_ruby.rb', line 143

def normalize_t(name)
    GeneratorRuby.normalize_type_name name
end