ffi-clang 0.8.0 → 0.10.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,9 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  # Released under the MIT License.
4
- # Copyright, 2010, by Jari Bakken.
5
- # Copyright, 2012, by Hal Brodigan.
6
- # Copyright, 2013-2022, by Samuel Williams.
4
+ # Copyright, 2013-2024, by Samuel Williams.
7
5
 
8
6
  module FFI
9
7
  module Clang
@@ -1,10 +1,11 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  # Released under the MIT License.
4
- # Copyright, 2013-2022, by Samuel Williams.
4
+ # Copyright, 2013-2024, by Samuel Williams.
5
5
  # Copyright, 2014, by Masahiro Sano.
6
6
  # Copyright, 2019, by Hayden Purdy.
7
7
  # Copyright, 2022, by Motonori Iwamuro.
8
+ # Copyright, 2023, by Charlie Savage.
8
9
 
9
10
  require_relative 'index'
10
11
 
@@ -28,7 +29,9 @@ module FFI
28
29
  :single_file_parse, 0x400,
29
30
  :limit_skip_function_bodies_to_preamble, 0x800,
30
31
  :include_attributed_type, 0x1000,
31
- :visit_implicit_attributes, 0x2000
32
+ :visit_implicit_attributes, 0x2000,
33
+ :ignore_non_errors_from_included_files, 0x4000,
34
+ :retain_excluded_conditional_blocks, 0x8000,
32
35
  ]
33
36
 
34
37
  SaveTranslationUnitFlags = enum [
@@ -63,6 +66,14 @@ module FFI
63
66
  :preprocessor_header_search, 14,
64
67
  ]
65
68
 
69
+ ErrorCodes = enum [
70
+ :cx_error_success, 0,
71
+ :cx_error_failure, 1,
72
+ :cx_error_crashed, 2,
73
+ :cx_error_invalid_arguments, 3,
74
+ :cx_error_ast_read_error, 4,
75
+ ]
76
+
66
77
  class CXTUResourceUsage < FFI::Struct
67
78
  layout(
68
79
  :data, :pointer,
@@ -80,6 +91,7 @@ module FFI
80
91
 
81
92
  # Source code translation units:
82
93
  attach_function :parse_translation_unit, :clang_parseTranslationUnit, [:CXIndex, :string, :pointer, :int, :pointer, :uint, :uint], :CXTranslationUnit
94
+ attach_function :parse_translation_unit2, :clang_parseTranslationUnit2, [:CXIndex, :string, :pointer, :int, :pointer, :uint, :uint, :pointer], ErrorCodes
83
95
  attach_function :create_translation_unit, :clang_createTranslationUnit, [:CXIndex, :string], :CXTranslationUnit
84
96
  attach_function :dispose_translation_unit, :clang_disposeTranslationUnit, [:CXTranslationUnit], :void
85
97
  attach_function :get_translation_unit_spelling, :clang_getTranslationUnitSpelling, [:CXTranslationUnit], CXString.by_value
@@ -2,10 +2,11 @@
2
2
 
3
3
  # Released under the MIT License.
4
4
  # Copyright, 2013, by Carlos Martín Nieto.
5
- # Copyright, 2013-2022, by Samuel Williams.
5
+ # Copyright, 2013-2024, by Samuel Williams.
6
6
  # Copyright, 2013, by Takeshi Watanabe.
7
7
  # Copyright, 2013-2014, by Masahiro Sano.
8
8
  # Copyright, 2014, by Niklas Therning.
9
+ # Copyright, 2024, by Charlie Savage.
9
10
 
10
11
  module FFI
11
12
  module Clang
@@ -59,6 +60,71 @@ module FFI
59
60
  :type_variable_array, 115,
60
61
  :type_dependent_sized_array, 116,
61
62
  :type_member_pointer, 117,
63
+ :type_auto, 118,
64
+ :type_elaborated, 119,
65
+ :type_pipe, 120,
66
+ :type_ocl_image_1d_ro, 121,
67
+ :type_ocl_image_1d_array_ro, 122,
68
+ :type_ocl_image_1d_buffer_ro, 123,
69
+ :type_ocl_image_2d_ro, 124,
70
+ :type_ocl_image_2d_array_ro, 125,
71
+ :type_ocl_image_2d_depth_ro, 126,
72
+ :type_ocl_image_2d_array_depth_ro, 127,
73
+ :type_ocl_image_2d_msaa_ro, 128,
74
+ :type_ocl_image_2d_array_msaa_ro, 129,
75
+ :type_ocl_image_2d_msaa_depth_ro, 130,
76
+ :type_ocl_image_2d_array_msaa_depth_ro, 131,
77
+ :type_ocl_image_3d_ro, 132,
78
+ :type_ocl_image_1d_wo, 133,
79
+ :type_ocl_image_1d_array_wo, 134,
80
+ :type_ocl_image_1d_buffer_wo, 135,
81
+ :type_ocl_image_2d_wo, 136,
82
+ :type_ocl_image_2d_array_wo, 137,
83
+ :type_ocl_image_2d_depth_wo, 138,
84
+ :type_ocl_image_2d_arraydepth_wo, 139,
85
+ :type_ocl_image_2d_msaa_wo, 140,
86
+ :type_ocl_image_2d_array_msaa_wo, 141,
87
+ :type_ocl_image_2d_msaa_depth_wo, 142,
88
+ :type_ocl_image_2d_array_msaa_depth_wo, 143,
89
+ :type_ocl_image_3d_wo, 144,
90
+ :type_ocl_image_1d_rw, 145,
91
+ :type_ocl_image_1d_array_rw, 146,
92
+ :type_ocl_image_1d_buffer_rw, 147,
93
+ :type_ocl_image_2d_rw, 148,
94
+ :type_ocl_image_2d_array_rw, 149,
95
+ :type_ocl_image_2d_depth_rw, 150,
96
+ :type_ocl_image_2d_arraydepth_rw, 151,
97
+ :type_ocl_image_2d_msaa_rw, 152,
98
+ :type_ocl_image_2d_array_msaa_rw, 153,
99
+ :type_ocl_image_2d_msaa_depth_rw, 154,
100
+ :type_ocl_image_2d_array_msaa_depth_rw, 155,
101
+ :type_ocl_image_3d_rw, 156,
102
+ :type_ocl_sampler, 157,
103
+ :type_ocl_event, 158,
104
+ :type_ocl_queue, 159,
105
+ :type_ocl_reserve_id, 160,
106
+ :type_objc_object, 161,
107
+ :type_objc_type_param, 162,
108
+ :type_attributed, 163,
109
+ :type_ocl_intel_subgroup_avc_mce_payload, 164,
110
+ :type_ocl_intel_subgroup_avc_ime_payload, 165,
111
+ :type_ocl_intel_subgroup_avc_ref_payload, 166,
112
+ :type_ocl_intel_subgroup_avc_sic_payload, 167,
113
+ :type_ocl_intel_subgroup_avc_mce_result, 168,
114
+ :type_ocl_intel_subgroup_avc_ime_result, 169,
115
+ :type_ocl_intel_subgroup_avc_ref_result, 170,
116
+ :type_ocl_intel_subgroup_avc_sic_result, 171,
117
+ :type_ocl_intel_subgroup_avc_ime_result_single_reference_streamout, 172,
118
+ :type_ocl_intel_subgroup_avc_ime_result_dual_reference_streamout, 173,
119
+ :type_ocl_intel_subgroup_avc_ime_single_reference_streamin, 174,
120
+ :type_ocl_intel_subgroup_avc_ime_dual_reference_streamin, 175,
121
+ :type_ocl_intel_subgroup_avc_ime_result_single_ref_streamout, 172,
122
+ :type_ocl_intel_subgroup_avc_ime_result_dual_ref_streamout, 173,
123
+ :type_ocl_intel_subgroup_avc_ime_single_ref_streamin, 174,
124
+ :type_ocl_intel_subgroup_avc_ime_dual_ref_streamin, 175,
125
+ :type_ext_vector, 176,
126
+ :type_atomic, 177,
127
+ :type_btf_tag_attributed, 178
62
128
  ]
63
129
 
64
130
  enum :calling_conv, [
@@ -74,6 +140,16 @@ module FFI
74
140
  :calling_conv_intel_ocl_bicc, 9,
75
141
  :calling_conv_x86_64_win64, 10,
76
142
  :calling_conv_x86_64_sysv, 11,
143
+ :calling_conv_x86_vector_call, 12,
144
+ :calling_conv_swift, 13,
145
+ :calling_conv_preserve_most, 14,
146
+ :calling_conv_preserve_all, 15,
147
+ :calling_conv_aarch64_vector_call, 16,
148
+ :calling_conv_swift_async, 17,
149
+ :calling_conv_aarch64_sve_pcs, 18,
150
+ :calling_conv_m68k_rtd, 19,
151
+ :calling_conv_preserve_none, 20,
152
+ :calling_conv_riscv_vector_call, 21,
77
153
  :calling_conv_invalid, 100,
78
154
  :calling_conv_unexposed, 200
79
155
  ]
@@ -90,6 +166,7 @@ module FFI
90
166
  :layout_error_dependent, -3,
91
167
  :layout_error_not_constant_size, -4,
92
168
  :layout_error_invalid_field_name, -5,
169
+ :layout_error_undeduced, -6
93
170
  ]
94
171
 
95
172
  class CXType < FFI::Struct
@@ -108,7 +185,7 @@ module FFI
108
185
  attach_function :get_pointee_type, :clang_getPointeeType, [CXType.by_value], CXType.by_value
109
186
  attach_function :get_result_type, :clang_getResultType, [CXType.by_value], CXType.by_value
110
187
  attach_function :get_canonical_type, :clang_getCanonicalType, [CXType.by_value], CXType.by_value
111
-
188
+
112
189
  attach_function :type_get_class_type, :clang_Type_getClassType, [CXType.by_value], CXType.by_value
113
190
 
114
191
  attach_function :is_const_qualified_type, :clang_isConstQualifiedType, [CXType.by_value], :uint
@@ -127,7 +204,7 @@ module FFI
127
204
  attach_function :type_get_offset_of, :clang_Type_getOffsetOf, [CXType.by_value, :string], :long_long
128
205
 
129
206
  attach_function :type_get_cxx_ref_qualifier, :clang_Type_getCXXRefQualifier, [CXType.by_value], :ref_qualifier_kind
130
-
207
+
131
208
  attach_function :get_fuction_type_calling_conv, :clang_getFunctionTypeCallingConv, [CXType.by_value], :calling_conv
132
209
 
133
210
  attach_function :equal_types, :clang_equalTypes, [CXType.by_value, CXType.by_value], :uint
data/lib/ffi/clang/lib.rb CHANGED
@@ -3,7 +3,7 @@
3
3
  # Released under the MIT License.
4
4
  # Copyright, 2010-2012, by Jari Bakken.
5
5
  # Copyright, 2012, by Hal Brodigan.
6
- # Copyright, 2013-2022, by Samuel Williams.
6
+ # Copyright, 2013-2024, by Samuel Williams.
7
7
  # Copyright, 2013-2014, by Carlos Martín Nieto.
8
8
  # Copyright, 2013, by Takeshi Watanabe.
9
9
  # Copyright, 2014, by Masahiro Sano.
@@ -12,7 +12,8 @@
12
12
  # Copyright, 2016, by Mike Dalessio.
13
13
  # Copyright, 2019, by Hayden Purdy.
14
14
  # Copyright, 2019, by Dominic Sisnero.
15
- # Copyright, 2020, by Luikore.
15
+ # Copyright, 2020, by Zete Lui.
16
+ # Copyright, 2023, by Charlie Savage.
16
17
 
17
18
  require 'mkmf'
18
19
 
@@ -69,11 +70,11 @@ module FFI
69
70
  def self.bitmask_from(enum, opts)
70
71
  bitmask = 0
71
72
 
72
- opts.each do |key, value|
73
- if int = enum[key]
73
+ opts.each do |symbol|
74
+ if int = enum[symbol]
74
75
  bitmask |= int
75
76
  else
76
- raise Error, "unknown option: #{key.inspect}, expected one of #{enum.symbols}"
77
+ raise Error, "unknown option: #{symbol}, expected one of #{enum.symbols}"
77
78
  end
78
79
  end
79
80
 
@@ -82,19 +83,19 @@ module FFI
82
83
 
83
84
  def self.opts_from(enum, bitmask)
84
85
  bit = 1
85
- opts = {}
86
+ result = []
86
87
  while bitmask != 0
87
88
  if bitmask & 1
88
- if sym = enum[bit]
89
- opts[sym] = true
89
+ if symbol = enum[bit]
90
+ result << symbol
90
91
  else
91
- raise Error, "unknown values: #{bit}, expected one of #{enum.symbols}"
92
+ raise(Error, "unknown values: #{bit}, expected one of #{enum.symbols}")
92
93
  end
93
94
  end
94
95
  bitmask >>= 1
95
96
  bit <<= 1
96
97
  end
97
- opts
98
+ result
98
99
  end
99
100
  end
100
101
  end
@@ -0,0 +1,36 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Released under the MIT License.
4
+ # Copyright, 2024, by Charlie Savage.
5
+ # Copyright, 2024, by Samuel Williams.
6
+
7
+ require_relative 'lib/printing_policy'
8
+
9
+ module FFI
10
+ module Clang
11
+ class PrintingPolicy < AutoPointer
12
+ def initialize(cursor)
13
+ policy = Lib.get_printing_policy(cursor)
14
+ super(policy)
15
+ @cursor = cursor
16
+ end
17
+
18
+ def self.release(pointer)
19
+ Lib.dispose_printing_policy(pointer)
20
+ end
21
+
22
+ def get_property(property)
23
+ result = Lib.printing_policy_get_property(self, property)
24
+ result == 0 ? false : true
25
+ end
26
+
27
+ def set_property(property, value)
28
+ Lib.printing_policy_set_property(self, property, value ? 1 : 0)
29
+ end
30
+
31
+ def pretty_print
32
+ Lib.extract_string Lib.pretty_print(@cursor, self)
33
+ end
34
+ end
35
+ end
36
+ end
@@ -6,6 +6,7 @@
6
6
  # Copyright, 2013-2022, by Samuel Williams.
7
7
  # Copyright, 2013, by Garry Marshall.
8
8
  # Copyright, 2014, by Masahiro Sano.
9
+ # Copyright, 2024, by Charlie Savage.
9
10
 
10
11
  require_relative 'lib/source_location'
11
12
  require_relative 'lib/file'
@@ -30,22 +31,6 @@ module FFI
30
31
  Lib.location_is_from_main_file(@location) != 0
31
32
  end
32
33
 
33
- def expansion_location
34
- ExpansionLocation.new(@location)
35
- end
36
-
37
- def presumed_location
38
- PresumedLocation.new(@location)
39
- end
40
-
41
- def spelling_location
42
- SpellingLocation.new(@location)
43
- end
44
-
45
- def file_location
46
- FileLocation.new(@location)
47
- end
48
-
49
34
  def null?
50
35
  Lib.equal_locations(@location, Lib.get_null_location) != 0
51
36
  end
@@ -73,6 +58,14 @@ module FFI
73
58
  @column = column.get_uint(0)
74
59
  @offset = offset.get_uint(0)
75
60
  end
61
+
62
+ def as_string
63
+ "#{@file}:#{@line}:#{@column}:#{@offset}"
64
+ end
65
+
66
+ def to_s
67
+ "ExpansionLocation <#{self.as_string}>"
68
+ end
76
69
  end
77
70
 
78
71
  class PresumedLocation < SourceLocation
@@ -82,8 +75,8 @@ module FFI
82
75
  super(location)
83
76
 
84
77
  cxstring = MemoryPointer.new Lib::CXString
85
- line = MemoryPointer.new :uint
86
- column = MemoryPointer.new :uint
78
+ line = MemoryPointer.new :uint
79
+ column = MemoryPointer.new :uint
87
80
 
88
81
  Lib::get_presumed_location(@location, cxstring, line, column)
89
82
 
@@ -91,6 +84,14 @@ module FFI
91
84
  @line = line.get_uint(0)
92
85
  @column = column.get_uint(0)
93
86
  end
87
+
88
+ def as_string
89
+ "#{@filename}:#{@line}:#{@column}"
90
+ end
91
+
92
+ def to_s
93
+ "PresumedLocation <#{self.as_string}>"
94
+ end
94
95
  end
95
96
 
96
97
  class SpellingLocation < SourceLocation
@@ -111,6 +112,14 @@ module FFI
111
112
  @column = column.get_uint(0)
112
113
  @offset = offset.get_uint(0)
113
114
  end
115
+
116
+ def as_string
117
+ "#{@file}:#{@line}:#{@column}:#{@offset}"
118
+ end
119
+
120
+ def to_s
121
+ "SpellingLocation <#{self.as_string}>"
122
+ end
114
123
  end
115
124
 
116
125
  class FileLocation < SourceLocation
@@ -131,6 +140,14 @@ module FFI
131
140
  @column = column.get_uint(0)
132
141
  @offset = offset.get_uint(0)
133
142
  end
143
+
144
+ def as_string
145
+ "#{@file}:#{@line}:#{@column}:#{@offset}"
146
+ end
147
+
148
+ def to_s
149
+ "FileLocation <#{self.as_string}>"
150
+ end
134
151
  end
135
152
  end
136
153
  end
@@ -0,0 +1,15 @@
1
+ module FFI
2
+ module Clang
3
+ module Types
4
+ class Array < Type
5
+ def element_type
6
+ Type.create Lib.get_array_element_type(@type), @translation_unit
7
+ end
8
+
9
+ def size
10
+ Lib.get_array_size(@type)
11
+ end
12
+ end
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,26 @@
1
+ module FFI
2
+ module Clang
3
+ module Types
4
+ class Elaborated < Type
5
+ def canonical
6
+ Type.create Lib.get_canonical_type(@type), @translation_unit
7
+ end
8
+
9
+ # Example anonymous union where `u` is an elaborated type
10
+ #
11
+ # typedef struct {
12
+ # union {
13
+ # int idata;
14
+ # } u;
15
+ # } SomeStruct;
16
+ def anonymous?
17
+ self.declaration.anonymous?
18
+ end
19
+
20
+ def pointer?
21
+ self.canonical.is_a?(Pointer)
22
+ end
23
+ end
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,27 @@
1
+ module FFI
2
+ module Clang
3
+ module Types
4
+ class Function < Type
5
+ def variadic?
6
+ Lib.is_function_type_variadic(@type) != 0
7
+ end
8
+
9
+ def args_size
10
+ Lib.get_num_arg_types(@type)
11
+ end
12
+
13
+ def arg_type(i)
14
+ Type.create Lib.get_arg_type(@type, i), @translation_unit
15
+ end
16
+
17
+ def result_type
18
+ Type.create Lib.get_result_type(@type), @translation_unit
19
+ end
20
+
21
+ def calling_conv
22
+ Lib.get_fuction_type_calling_conv(@type)
23
+ end
24
+ end
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,42 @@
1
+ module FFI
2
+ module Clang
3
+ module Types
4
+ class Pointer < Type
5
+ def pointee
6
+ Type.create Lib.get_pointee_type(@type), @translation_unit
7
+ end
8
+
9
+ def function?
10
+ self.pointee.is_a?(Types::Function)
11
+ end
12
+
13
+ def class_type
14
+ if self.kind == :type_member_pointer
15
+ Type.create Lib.type_get_class_type(@type), @translation_unit
16
+ else
17
+ nil
18
+ end
19
+ end
20
+
21
+ def forward_declaration?
22
+ # Is this a pointer to a record (struct or union) that referenced
23
+ # a forward declaration at the point of its inclusion in the translation unit?
24
+ if !self.function? && self.pointee.is_a?(Types::Elaborated) &&
25
+ self.pointee.canonical.is_a?(Types::Record)
26
+
27
+ # Get the universal symbol reference
28
+ usr = self.pointee.canonical.declaration.usr
29
+
30
+ # Now does that same usr occur earlier in the file?
31
+ first_declaration, _ = self.translation_unit.cursor.find do |child, parent|
32
+ child.usr == usr
33
+ end
34
+ # NOTE - Maybe should also check that the line number of
35
+ # is less than the line number of the declaration this type references
36
+ first_declaration.forward_declaration?
37
+ end
38
+ end
39
+ end
40
+ end
41
+ end
42
+ end
@@ -0,0 +1,26 @@
1
+ module FFI
2
+ module Clang
3
+ module Types
4
+ class Record < Type
5
+ def offsetof(field)
6
+ Lib.type_get_offset_of(@type, field)
7
+ end
8
+
9
+ def anonymous?
10
+ self.spelling.match(/unnamed/)
11
+ end
12
+
13
+ def record_type
14
+ case self.spelling
15
+ when /struct/
16
+ :struct
17
+ when /union/
18
+ :union
19
+ else
20
+ raise("Unknown record type: #{self.spelling}")
21
+ end
22
+ end
23
+ end
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,98 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Released under the MIT License.
4
+ # Copyright, 2013, by Carlos Martín Nieto.
5
+ # Copyright, 2013-2024, by Samuel Williams.
6
+ # Copyright, 2013, by Takeshi Watanabe.
7
+ # Copyright, 2014, by Masahiro Sano.
8
+ # Copyright, 2014, by Niklas Therning.
9
+ # Copyright, 2024, by Charlie Savage.
10
+
11
+ module FFI
12
+ module Clang
13
+ module Types
14
+ class Type
15
+ attr_reader :type, :translation_unit
16
+
17
+ # Just hard code the types - they don't likely to change
18
+ def self.create(cxtype, translation_unit)
19
+ case cxtype[:kind]
20
+ when :type_pointer, :type_block_pointer, :type_obj_c_object_pointer, :type_member_pointer
21
+ Pointer.new(cxtype, translation_unit)
22
+ when :type_constant_array, :type_incomplete_array, :type_variable_array, :type_dependent_sized_array
23
+ Array.new(cxtype, translation_unit)
24
+ when :type_vector
25
+ Vector.new(cxtype, translation_unit)
26
+ when :type_function_no_proto, :type_function_proto
27
+ Function.new(cxtype, translation_unit)
28
+ when :type_elaborated
29
+ Elaborated.new(cxtype, translation_unit)
30
+ when :type_typedef
31
+ TypeDef.new(cxtype, translation_unit)
32
+ when :type_record
33
+ Record.new(cxtype, translation_unit)
34
+ else
35
+ Type.new(cxtype, translation_unit)
36
+ end
37
+ end
38
+
39
+ def initialize(type, translation_unit)
40
+ @type = type
41
+ @translation_unit = translation_unit
42
+ end
43
+
44
+ def kind
45
+ @type[:kind]
46
+ end
47
+
48
+ def kind_spelling
49
+ Lib.extract_string Lib.get_type_kind_spelling @type[:kind]
50
+ end
51
+
52
+ def spelling
53
+ Lib.extract_string Lib.get_type_spelling(@type)
54
+ end
55
+
56
+ def pod?
57
+ Lib.is_pod_type(@type) != 0
58
+ end
59
+
60
+ def const_qualified?
61
+ Lib.is_const_qualified_type(@type) != 0
62
+ end
63
+
64
+ def volatile_qualified?
65
+ Lib.is_volatile_qualified_type(@type) != 0
66
+ end
67
+
68
+ def restrict_qualified?
69
+ Lib.is_restrict_qualified_type(@type) != 0
70
+ end
71
+
72
+ def alignof
73
+ Lib.type_get_align_of(@type)
74
+ end
75
+
76
+ def sizeof
77
+ Lib.type_get_size_of(@type)
78
+ end
79
+
80
+ def ref_qualifier
81
+ Lib.type_get_cxx_ref_qualifier(@type)
82
+ end
83
+
84
+ def declaration
85
+ Cursor.new Lib.get_type_declaration(@type), @translation_unit
86
+ end
87
+
88
+ def ==(other)
89
+ Lib.equal_types(@type, other.type) != 0
90
+ end
91
+
92
+ def to_s
93
+ "#{self.class.name} <#{self.kind}: #{self.spelling}>"
94
+ end
95
+ end
96
+ end
97
+ end
98
+ end
@@ -0,0 +1,15 @@
1
+ module FFI
2
+ module Clang
3
+ module Types
4
+ class TypeDef < Type
5
+ def canonical
6
+ Type.create Lib.get_canonical_type(@type), @translation_unit
7
+ end
8
+
9
+ def anonymous?
10
+ self.canonical.kind == :type_record && self.canonical.anonymous?
11
+ end
12
+ end
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,15 @@
1
+ module FFI
2
+ module Clang
3
+ module Types
4
+ class Vector < Type
5
+ def element_type
6
+ Type.create Lib.get_element_type(@type), @translation_unit
7
+ end
8
+
9
+ def size
10
+ Lib.get_num_elements(@type)
11
+ end
12
+ end
13
+ end
14
+ end
15
+ end
@@ -3,10 +3,10 @@
3
3
  # Released under the MIT License.
4
4
  # Copyright, 2010, by Jari Bakken.
5
5
  # Copyright, 2012, by Hal Brodigan.
6
- # Copyright, 2013-2022, by Samuel Williams.
6
+ # Copyright, 2013-2024, by Samuel Williams.
7
7
 
8
8
  module FFI
9
9
  module Clang
10
- VERSION = "0.8.0"
10
+ VERSION = "0.10.0"
11
11
  end
12
12
  end
data/lib/ffi/clang.rb CHANGED
@@ -46,3 +46,12 @@ require_relative 'clang/unsaved_file'
46
46
  require_relative 'clang/token'
47
47
  require_relative 'clang/code_completion'
48
48
  require_relative 'clang/compilation_database'
49
+
50
+ require_relative 'clang/types/type'
51
+ require_relative 'clang/types/array'
52
+ require_relative 'clang/types/elaborated'
53
+ require_relative 'clang/types/function'
54
+ require_relative 'clang/types/pointer'
55
+ require_relative 'clang/types/record'
56
+ require_relative 'clang/types/type_def'
57
+ require_relative 'clang/types/vector'
data/license.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  Copyright, 2010-2012, by Jari Bakken.
4
4
  Copyright, 2012, by Hal Brodigan.
5
- Copyright, 2013-2022, by Samuel Williams.
5
+ Copyright, 2013-2024, by Samuel Williams.
6
6
  Copyright, 2013, by Garry Marshall.
7
7
  Copyright, 2013-2014, by Carlos Martín Nieto.
8
8
  Copyright, 2013, by Dave Wilkinson.
@@ -16,8 +16,9 @@ Copyright, 2017, by Cameron Dutro.
16
16
  Copyright, 2019, by Hayden Purdy.
17
17
  Copyright, 2019, by Michael Metivier.
18
18
  Copyright, 2019, by Dominic Sisnero.
19
- Copyright, 2020, by Luikore.
19
+ Copyright, 2020, by Zete Lui.
20
20
  Copyright, 2022, by Motonori Iwamuro.
21
+ Copyright, 2023-2024, by Charlie Savage.
21
22
 
22
23
  Permission is hereby granted, free of charge, to any person obtaining a copy
23
24
  of this software and associated documentation files (the "Software"), to deal