class RbPlusPlus::Builders::ExtensionNode

Extension node. There is only ever one of these in a project as this is the top level node for building a Ruby extension.

Extensions are effectively Modules with some slightly different symantics, in that they expose to Kernel and have slightly different function handling and code generation.

Attributes

additional_includes[R]

Public Class Methods

new(name, code, modules) click to toggle source
# File lib/rbplusplus/builders/extension.rb, line 15
def initialize(name, code, modules)
  self.name = name
  self.modules = modules

  @additional_includes = []

  super(code, nil)
end

Public Instance Methods

add_includes(includes) click to toggle source
# File lib/rbplusplus/builders/extension.rb, line 28
def add_includes(includes)
  @additional_includes << includes
  includes.each do |inc|
    add_child IncludeNode.new(self, inc)
  end
end
build() click to toggle source
# File lib/rbplusplus/builders/extension.rb, line 35
def build
  super
  self.rice_variable = nil
  self.rice_variable_type = nil
end
qualified_name() click to toggle source
# File lib/rbplusplus/builders/extension.rb, line 24
def qualified_name
  name
end
write() click to toggle source
# File lib/rbplusplus/builders/extension.rb, line 41
def write
  # Let nodes build their code, splitting up code blocks into
  # includes, declarations, and registrations,
  # then wrap it up in our own template
  registrations << "extern \"C\""
  registrations << "void Init_#{@name}() {"
  registrations << "RUBY_TRY {"
end