Sha256: 30f785c98ef1c6028ff379d5656306d9820dd7f18a72aeaf4819abb77baa6fce

Contents?: true

Size: 942 Bytes

Versions: 1

Compression:

Stored size: 942 Bytes

Contents

module RbPlusPlus
  module Builders

    # Expose an enumeration.
    class EnumerationNode < Base

      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

      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

    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
rbplusplus-1.4.0 lib/rbplusplus/builders/enumeration.rb