Class: Rbind::GeneratorRuby::RTypeHelper::OverloadedOperationHelper
- Inherits:
-
HelperBase
- Object
- HelperBase
- Rbind::GeneratorRuby::RTypeHelper::OverloadedOperationHelper
- Defined in:
- lib/rbind/generator_ruby.rb
Instance Attribute Summary
Attributes inherited from HelperBase
Attributes included from Logger
Instance Method Summary collapse
- #add_alias ⇒ Object
- #add_doc ⇒ Object
- #add_methods ⇒ Object
- #binding ⇒ Object
-
#initialize(root) ⇒ OverloadedOperationHelper
constructor
A new instance of OverloadedOperationHelper.
- #static? ⇒ Boolean
Methods inherited from HelperBase
Methods included from Logger
Constructor Details
#initialize(root) ⇒ OverloadedOperationHelper
Returns a new instance of OverloadedOperationHelper.
586 587 588 589 590 |
# File 'lib/rbind/generator_ruby.rb', line 586 def initialize(root) raise "expect an array of methods but got #{root}" if root.size < 1 super(GeneratorRuby.normalize_method_name(root.first.alias || root.first.name),root) @overload_wrapper = ERB.new(File.open(File.join(File.dirname(__FILE__),"templates","ruby","roverloaded_method_call.rb")).read,nil,"-") end |
Instance Method Details
#add_alias ⇒ Object
609 610 611 612 613 614 615 616 617 618 |
# File 'lib/rbind/generator_ruby.rb', line 609 def add_alias name = GeneratorRuby::normalize_alias_method_name(@root.first.alias || @root.first.name) if name == self.name || !@root.first.cplusplus_alias? nil elsif static? " class << self; alias :#{name} :#{self.name}; end\n" else " alias #{name} #{self.name}\n" end end |
#add_doc ⇒ Object
620 621 622 623 624 625 626 627 628 629 |
# File 'lib/rbind/generator_ruby.rb', line 620 def add_doc str = @root.map do |op| s = op.add_doc s ||= "" s = s.gsub(/( *#)/) do "#{$1} " end " # @overload #{op.name}(#{op.wrap_parameters_signature})\n#{s}" end.join(" #\n") end |
#add_methods ⇒ Object
596 597 598 599 600 601 602 603 604 605 606 607 |
# File 'lib/rbind/generator_ruby.rb', line 596 def add_methods str = @root.map do |method| next if method.ignore? raise "Cannot overload attributes" if method.attribute? op = if method.is_a? OperationHelper method else OperationHelper.new(method) end @overload_wrapper.result(op.binding) end.join("\n") end |
#binding ⇒ Object
631 632 633 |
# File 'lib/rbind/generator_ruby.rb', line 631 def binding Kernel.binding end |
#static? ⇒ Boolean
592 593 594 |
# File 'lib/rbind/generator_ruby.rb', line 592 def static? @root.first.static? end |