class RbPlusPlus::Builders::AllocationStrategyNode
Handles code generation for telling Rice how to allocate / deallocate classes. See ClassNode#check_allocation_strategies
.
Public Class Methods
new(parent, code, has_public_constructor, has_public_destructor)
click to toggle source
Calls superclass method
# File lib/rbplusplus/builders/allocation_strategy.rb, line 8 def initialize(parent, code, has_public_constructor, has_public_destructor) super(code, parent) @public_constructor = has_public_constructor @public_destructor = has_public_destructor end
Public Instance Methods
build()
click to toggle source
# File lib/rbplusplus/builders/allocation_strategy.rb, line 19 def build end
qualified_name()
click to toggle source
Used by MultipleFileWriter to only wrap a given type once.
# File lib/rbplusplus/builders/allocation_strategy.rb, line 15 def qualified_name "#{self.code.qualified_name}_AllocStrat" end
write()
click to toggle source
# File lib/rbplusplus/builders/allocation_strategy.rb, line 22 def write includes << "#include <rice/Data_Object.hpp>" node_name = self.code.qualified_name code = <<-END namespace Rice { template<> struct Default_Free_Function< #{node_name} > { static void free(#{node_name} * obj); }; } END declarations << code pre = "Rice::Default_Free_Function< #{node_name} >::" tmp = "void #{pre}free(#{node_name} * obj) { " tmp += @public_destructor ? "delete obj;" : "" tmp += " }" registrations << tmp end