Class: Rbind::GeneratorRuby::RTypeHelper
- Inherits:
-
HelperBase
- Object
- HelperBase
- Rbind::GeneratorRuby::RTypeHelper
- Defined in:
- lib/rbind/generator_ruby.rb
Defined Under Namespace
Classes: OperationHelper
Instance Method Summary collapse
- #add_constructor ⇒ Object
- #add_consts ⇒ Object
- #add_methods ⇒ Object
- #add_specializing ⇒ Object
- #add_types ⇒ Object
- #cdelete_method ⇒ Object
- #cname ⇒ Object
- #full_name ⇒ Object
-
#initialize(name, root) ⇒ RTypeHelper
constructor
A new instance of RTypeHelper.
- #name ⇒ Object
- #result ⇒ Object
Methods inherited from HelperBase
Constructor Details
#initialize(name, root) ⇒ RTypeHelper
Returns a new instance of RTypeHelper.
244 245 246 247 248 249 250 251 |
# File 'lib/rbind/generator_ruby.rb', line 244 def initialize(name, root) @type_wrapper = ERB.new(File.open(File.join(File.dirname(__FILE__),"templates","ruby","rtype.rb")).read,nil,"-") @type_constructor_wrapper = ERB.new(File.open(File.join(File.dirname(__FILE__),"templates","ruby","rtype_constructor.rb")).read,nil,"-") @namespace_wrapper = ERB.new(File.open(File.join(File.dirname(__FILE__),"templates","ruby","rnamespace.rb")).read,nil,"-") @static_method_wrapper = ERB.new(File.open(File.join(File.dirname(__FILE__),"templates","ruby","rstatic_method.rb")).read) @method_wrapper = ERB.new(File.open(File.join(File.dirname(__FILE__),"templates","ruby","rmethod.rb")).read,nil,'-') super end |
Instance Method Details
#add_constructor ⇒ Object
273 274 275 276 277 278 279 280 281 |
# File 'lib/rbind/generator_ruby.rb', line 273 def add_constructor raise "there is no constructor for namespaces!" if self.is_a?(RNamespace) ops = Array(@root.operation(@root.name,false)) return until ops ops.map do |c| ch = OperationHelper.new(c) @type_constructor_wrapper.result(ch.binding) end.join("\n") end |
#add_consts ⇒ Object
283 284 285 286 287 |
# File 'lib/rbind/generator_ruby.rb', line 283 def add_consts @root.consts.map do |c| " #{c.name} = #{c.value}\n" end.join end |
#add_methods ⇒ Object
289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 |
# File 'lib/rbind/generator_ruby.rb', line 289 def add_methods str = "" @root.operations.each do |ops| ops.each do |op| next if op.constructor? oph = OperationHelper.new(op) str += if op.instance_method? @method_wrapper.result(oph.binding) else @static_method_wrapper.result(oph.binding) end end end str end |
#add_specializing ⇒ Object
265 266 267 268 269 270 271 |
# File 'lib/rbind/generator_ruby.rb', line 265 def add_specializing if @root.respond_to?(:specialize_ruby) @root.specialize_ruby else nil end end |
#add_types ⇒ Object
305 306 307 308 309 310 311 312 313 |
# File 'lib/rbind/generator_ruby.rb', line 305 def add_types str = "" @root.each_type(false) do |t| next if t.basic_type? && !t.is_a?(RNamespace) t = RTypeHelper.new(t.name,t) str += t.result end str end |
#cdelete_method ⇒ Object
261 262 263 |
# File 'lib/rbind/generator_ruby.rb', line 261 def cdelete_method GeneratorRuby.normalize_method_name(@root.cdelete_method) end |
#cname ⇒ Object
257 258 259 |
# File 'lib/rbind/generator_ruby.rb', line 257 def cname GeneratorRuby.normalize_type_name(@root.cname) end |
#full_name ⇒ Object
315 316 317 |
# File 'lib/rbind/generator_ruby.rb', line 315 def full_name @root.full_name end |
#name ⇒ Object
253 254 255 |
# File 'lib/rbind/generator_ruby.rb', line 253 def name GeneratorRuby.normalize_type_name(@name) end |
#result ⇒ Object
319 320 321 322 323 324 325 326 327 328 329 330 331 |
# File 'lib/rbind/generator_ruby.rb', line 319 def result str = if @root.is_a? RStruct @type_wrapper.result(self.binding) else @namespace_wrapper.result(self.binding) end if(@root.root?) str else str.gsub!("\n","\n ").gsub!(" \n","\n") " "+str[0,str.size-4] end end |