Sha256: 363938cd735403baa16018b6fe761095fb5360a1fb3fa2a3b75d795c47b20907

Contents?: true

Size: 938 Bytes

Versions: 7

Compression:

Stored size: 938 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

7 entries across 7 versions & 1 rubygems

Version Path
rbplusplus-1.3.0 lib/rbplusplus/builders/enumeration.rb
rbplusplus-1.2.1 lib/rbplusplus/builders/enumeration.rb
rbplusplus-1.2.0 lib/rbplusplus/builders/enumeration.rb
rbplusplus-1.1.0 lib/rbplusplus/builders/enumeration.rb
rbplusplus-1.0.3 lib/rbplusplus/builders/enumeration.rb
rbplusplus-1.0.1 lib/rbplusplus/builders/enumeration.rb
rbplusplus-1.0 lib/rbplusplus/builders/enumeration.rb