Sha256: 4cf48aa41efd867633760300d29329a99eaa601b3163c78b1ee7b7e66a40f667

Contents?: true

Size: 789 Bytes

Versions: 8

Compression:

Stored size: 789 Bytes

Contents

module RbPlusPlus
  module Builders

    # Expose a const value
    class ConstNode < Base

      def build
        add_child IncludeNode.new(self, code.file)
      end

      def write
        # If this constant is initialized in the header, we need to set the constant to the initialized value
        # If we just use the variable itself, Linux will fail to compile because the linker won't be able to
        # find the constant.
        set_to =
          if init = code.attributes["init"]
            init
          else
            code.qualified_name
          end

        prefix = parent.rice_variable ? "#{parent.rice_variable}." : "Rice::Module(rb_mKernel)."
        registrations << "\t#{prefix}const_set(\"#{code.name}\", to_ruby(#{set_to}));"
      end

    end

  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

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