Sha256: fe78632e2ad8310740038b7f01606430f068bb00f0bd2f252b871694c1daee97

Contents?: true

Size: 1.22 KB

Versions: 5

Compression:

Stored size: 1.22 KB

Contents

module Mirah
  module JVM
    module Types
      class TypeDefinition < Type
        attr_accessor :node

        def initialize(name, node)
          raise ArgumentError, "Bad name #{name}" if name[0,1] == '.'
          raise ArgumentError, "Bad name #{name}" if name.include? ?/
          @name = name
          @node = node
          raise ArgumentError, "Bad type #{name}" if self.name =~ /Java::/
        end

        def name
          if @type
            @type.name.tr('/', '.')
          else
            @name
          end
        end

        def superclass
          (node && node.superclass) || Object
        end

        def interfaces
          if node
            node.interfaces
          else
            []
          end
        end

        def define(builder)
          class_name = @name.tr('.', '/')
          abstract = node && node.abstract
          @type ||= builder.define_class(
              class_name,
              :visibility => :public,
              :abstract => abstract,
              :superclass => superclass,
              :interfaces => interfaces)
        end

        def meta
          @meta ||= TypeDefMeta.new(self)
        end
      end

      class TypeDefMeta < MetaType
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
mirah-0.0.12-java lib/mirah/jvm/types/type_definition.rb
mirah-0.0.11-java lib/mirah/jvm/types/type_definition.rb
mirah-0.0.10-java lib/mirah/jvm/types/type_definition.rb
mirah-0.0.9-java lib/mirah/jvm/types/type_definition.rb
mirah-0.0.8-java lib/mirah/jvm/types/type_definition.rb