Class: Ikra::Types::ArrayType

Inherits:
Object
  • Object
show all
Includes:
RubyType
Defined in:
lib/types/array_type.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods included from RubyType

#class_id, #is_primitive?, #is_union_type?, #to_ruby_type

Constructor Details

#initialize(inner_type) ⇒ ArrayType

Returns a new instance of ArrayType.



22
23
24
25
26
27
28
# File 'lib/types/array_type.rb', line 22

def initialize(inner_type)
    if not inner_type.is_union_type?
        raise "Union type expected"
    end

    @inner_type = inner_type
end

Class Method Details

.new(inner_type) ⇒ Object

Ensure singleton per class



10
11
12
13
14
15
16
17
18
19
# File 'lib/types/array_type.rb', line 10

def new(inner_type)
    if @cache == nil
        @cache = {}
        @cache.default_proc = Proc.new do |hash, key|
            hash[key] = super(key)
        end
    end

    @cache[inner_type]
end

Instance Method Details

#to_c_typeObject



30
31
32
# File 'lib/types/array_type.rb', line 30

def to_c_type
    "#{@inner_type.to_c_type} *"
end

#to_ffi_typeObject



34
35
36
# File 'lib/types/array_type.rb', line 34

def to_ffi_type
    :pointer
end