Class: FFI::Clang::Types::Type

Inherits:
Object
  • Object
show all
Defined in:
lib/ffi/clang/types/type.rb

Direct Known Subclasses

Array, Elaborated, Function, Pointer, Record, TypeDef, Vector

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(type, translation_unit) ⇒ Type

Returns a new instance of Type.



39
40
41
42
# File 'lib/ffi/clang/types/type.rb', line 39

def initialize(type, translation_unit)
	@type = type
	@translation_unit = translation_unit
end

Instance Attribute Details

#translation_unitObject (readonly)

Returns the value of attribute translation_unit.



15
16
17
# File 'lib/ffi/clang/types/type.rb', line 15

def translation_unit
  @translation_unit
end

#typeObject (readonly)

Returns the value of attribute type.



15
16
17
# File 'lib/ffi/clang/types/type.rb', line 15

def type
  @type
end

Class Method Details

.create(cxtype, translation_unit) ⇒ Object

Just hard code the types - they don’t likely to change



18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/ffi/clang/types/type.rb', line 18

def self.create(cxtype, translation_unit)
	case cxtype[:kind]
		when :type_pointer, :type_block_pointer, :type_obj_c_object_pointer, :type_member_pointer
			Pointer.new(cxtype, translation_unit)
		when :type_constant_array, :type_incomplete_array, :type_variable_array, :type_dependent_sized_array
			Array.new(cxtype, translation_unit)
		when :type_vector
			Vector.new(cxtype, translation_unit)
		when :type_function_no_proto, :type_function_proto
			Function.new(cxtype, translation_unit)
		when :type_elaborated
			Elaborated.new(cxtype, translation_unit)
		when :type_typedef
			TypeDef.new(cxtype, translation_unit)
		when :type_record
			Record.new(cxtype, translation_unit)
		else
			Type.new(cxtype, translation_unit)
	end
end

Instance Method Details

#==(other) ⇒ Object



88
89
90
# File 'lib/ffi/clang/types/type.rb', line 88

def ==(other)
	Lib.equal_types(@type, other.type) != 0
end

#alignofObject



72
73
74
# File 'lib/ffi/clang/types/type.rb', line 72

def alignof
	Lib.type_get_align_of(@type)
end

#const_qualified?Boolean

Returns:

  • (Boolean)


60
61
62
# File 'lib/ffi/clang/types/type.rb', line 60

def const_qualified?
	Lib.is_const_qualified_type(@type) != 0
end

#declarationObject



84
85
86
# File 'lib/ffi/clang/types/type.rb', line 84

def declaration
	Cursor.new Lib.get_type_declaration(@type), @translation_unit
end

#kindObject



44
45
46
# File 'lib/ffi/clang/types/type.rb', line 44

def kind
	@type[:kind]
end

#kind_spellingObject



48
49
50
# File 'lib/ffi/clang/types/type.rb', line 48

def kind_spelling
	Lib.extract_string Lib.get_type_kind_spelling @type[:kind]
end

#pod?Boolean

Returns:

  • (Boolean)


56
57
58
# File 'lib/ffi/clang/types/type.rb', line 56

def pod?
	Lib.is_pod_type(@type) != 0
end

#ref_qualifierObject



80
81
82
# File 'lib/ffi/clang/types/type.rb', line 80

def ref_qualifier
	Lib.type_get_cxx_ref_qualifier(@type)
end

#restrict_qualified?Boolean

Returns:

  • (Boolean)


68
69
70
# File 'lib/ffi/clang/types/type.rb', line 68

def restrict_qualified?
	Lib.is_restrict_qualified_type(@type) != 0
end

#sizeofObject



76
77
78
# File 'lib/ffi/clang/types/type.rb', line 76

def sizeof
	Lib.type_get_size_of(@type)
end

#spellingObject



52
53
54
# File 'lib/ffi/clang/types/type.rb', line 52

def spelling
	Lib.extract_string Lib.get_type_spelling(@type)
end

#to_sObject



92
93
94
# File 'lib/ffi/clang/types/type.rb', line 92

def to_s
	"#{self.class.name} <#{self.kind}: #{self.spelling}>"
end

#volatile_qualified?Boolean

Returns:

  • (Boolean)


64
65
66
# File 'lib/ffi/clang/types/type.rb', line 64

def volatile_qualified?
	Lib.is_volatile_qualified_type(@type) != 0
end