Class: RbPlusPlus::Builders::MethodBase
- Defined in:
- lib/rbplusplus/builders/method_base.rb
Overview
Base class for any type of method or function handling
Direct Known Subclasses
GlobalFunctionNode, MethodNode, ModuleFunctionNode, StaticMethodNode
Instance Attribute Summary collapse
-
#prefix ⇒ Object
Returns the value of attribute prefix.
-
#rice_method ⇒ Object
Returns the value of attribute rice_method.
-
#suffix ⇒ Object
Returns the value of attribute suffix.
Attributes inherited from Base
#code, #declarations, #global_nodes, #includes, #nodes, #parent, #registrations, #rice_variable, #rice_variable_type
Instance Method Summary collapse
-
#code_path ⇒ Object
This method should return the full C++ path to the method you’re exposing.
-
#initialize(code, parent = nil) ⇒ MethodBase
constructor
A new instance of MethodBase.
-
#write ⇒ Object
Wrap up this method making sure that overloads are properly typedef’d to keep from compiler error from unresolvable types.
Methods inherited from Base
#build, #has_children?, #qualified_name, #sort
Constructor Details
#initialize(code, parent = nil) ⇒ MethodBase
Returns a new instance of MethodBase.
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/rbplusplus/builders/method_base.rb', line 9 def initialize(code, parent = nil) super # Overload checks: # - If we're the only one, no overload required # - If we're one of many w/ the same name: # - Find out which in the list we are # - Add the number to ruby_name, unless user has renamed # - Build typedef of the method and use it in the exposure found = [code.parent.methods(code.name)].flatten if found.length > 1 && !code.renamed? num = found.index(code) self.suffix = "_#{num}" end end |
Instance Attribute Details
#prefix ⇒ Object
Returns the value of attribute prefix.
7 8 9 |
# File 'lib/rbplusplus/builders/method_base.rb', line 7 def prefix @prefix end |
#rice_method ⇒ Object
Returns the value of attribute rice_method.
7 8 9 |
# File 'lib/rbplusplus/builders/method_base.rb', line 7 def rice_method @rice_method end |
#suffix ⇒ Object
Returns the value of attribute suffix.
7 8 9 |
# File 'lib/rbplusplus/builders/method_base.rb', line 7 def suffix @suffix end |
Instance Method Details
#code_path ⇒ Object
This method should return the full C++ path to the method you’re exposing
43 44 45 |
# File 'lib/rbplusplus/builders/method_base.rb', line 43 def code_path self.code.qualified_name end |
#write ⇒ Object
Wrap up this method making sure that overloads are properly typedef’d to keep from compiler error from unresolvable types
Thanks to Py++ for the appropriate C++ syntax for this.
29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/rbplusplus/builders/method_base.rb', line 29 def write @ruby_name = Inflector.underscore(code.name) self.prefix ||= "#{self.parent.rice_variable}." self.suffix ||= "" if self.code.arguments.size == 1 && (fp = self.code.arguments[0].cpp_type.base_type).is_a?(RbGCCXML::FunctionType) wrap_with_function_pointer(fp) else wrap_normal_method end end |