class RbPlusPlus::Builders::EnumerationNode

Expose an enumeration.

Public Instance Methods

build() click to toggle source
# File lib/rbplusplus/builders/enumeration.rb, line 7
def build
  add_child IncludeNode.new(self, "rice/Enum.hpp", :system)
  add_child IncludeNode.new(self, code.file)

  # See ClassNode
  add_global_child ConstConverterNode.new(self.code, self)

  self.rice_variable_type = "Rice::Enum<#{code.qualified_name}>"
  self.rice_variable = "rb_e#{code.name}"

  Logger.info "Wrapping enumeration #{code.qualified_name}"
end
write() click to toggle source
# File lib/rbplusplus/builders/enumeration.rb, line 20
def write
  second = parent.rice_variable ? ", #{parent.rice_variable}" : ""

  registrations << "\t#{rice_variable_type} #{rice_variable} = "            "Rice::define_enum<#{code.qualified_name}>(\"#{code.name}\"#{second});"

  code.values.each do |v|
    registrations << "\t#{rice_variable}.define_value(\"#{v.name}\", #{v.qualified_name});"
  end
end