ffi-clang 0.9.0 → 0.11.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.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +3 -3
- data/lib/ffi/clang/cursor.rb +68 -45
- data/lib/ffi/clang/lib/cursor.rb +16 -0
- data/lib/ffi/clang/lib/type.rb +15 -0
- data/lib/ffi/clang/types/array.rb +15 -0
- data/lib/ffi/clang/types/elaborated.rb +26 -0
- data/lib/ffi/clang/types/function.rb +43 -0
- data/lib/ffi/clang/types/pointer.rb +42 -0
- data/lib/ffi/clang/types/record.rb +26 -0
- data/lib/ffi/clang/types/type.rb +102 -0
- data/lib/ffi/clang/types/type_def.rb +15 -0
- data/lib/ffi/clang/types/vector.rb +15 -0
- data/lib/ffi/clang/version.rb +1 -1
- data/lib/ffi/clang.rb +9 -0
- data.tar.gz.sig +0 -0
- metadata +11 -4
- metadata.gz.sig +0 -0
- data/lib/ffi/clang/type.rb +0 -160
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 54ebc6d99d0f99d46028bd950f969bacaaf32e95b8824fa504902974357882d2
|
4
|
+
data.tar.gz: 9732b945316e50383c601f5f9938f555445d13f5ce25428a6acadfacb57df284
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e3bb22b3b0e304d05edd4628570642efb0ef7dea8fe588bd37c6d284e06291d0cf7561ceffc8ff9ded5450e1f7751943e91843cb29eaca5c59227cb891ea39cb
|
7
|
+
data.tar.gz: 74d1a5920126e62a88a089fa205cdfa1b117ea2e0b8ca90ebc7807395172c436c0d72ccdcb6384a00c6d1d47b96c30e5568e0e991a2bcb0d2fc4d36df8a02731
|
checksums.yaml.gz.sig
CHANGED
@@ -1,3 +1,3 @@
|
|
1
|
-
|
2
|
-
�
|
3
|
-
�
|
1
|
+
b���^P�r:���V<��j����WG�+�����_��X2gB~�ȥ��o�L �\���E��p�d�e3�?��� ��+�m;��O�O��baY,^�ӵ鴯�MVhF�e�]�[X��Y����pA�̱�^v�,����/l:T=�=�VΒuT�:u�:���Qbd"a2A�\���^�
|
2
|
+
�Ո��4#��~��:�ɹF8��O��q�T�k
|
3
|
+
K�F�{�A����J;"��8�$�XW��k�D��W~�d�����'�<>�����E�ew���M*��*)�b����'s�^~�X��;��Ö#�ۦi���'�~�m�E�u�
|
data/lib/ffi/clang/cursor.rb
CHANGED
@@ -20,11 +20,12 @@ require_relative 'printing_policy'
|
|
20
20
|
require_relative 'source_location'
|
21
21
|
require_relative 'source_range'
|
22
22
|
require_relative 'comment'
|
23
|
-
require_relative 'type'
|
24
23
|
|
25
24
|
module FFI
|
26
25
|
module Clang
|
27
26
|
class Cursor
|
27
|
+
include Enumerable
|
28
|
+
|
28
29
|
attr_reader :cursor
|
29
30
|
attr_reader :translation_unit
|
30
31
|
|
@@ -62,6 +63,14 @@ module FFI
|
|
62
63
|
CodeCompletion::String.new Lib.get_cursor_completion_string(@cursor)
|
63
64
|
end
|
64
65
|
|
66
|
+
def anonymous?
|
67
|
+
Lib.cursor_is_anonymous(@cursor) != 0
|
68
|
+
end
|
69
|
+
|
70
|
+
def anonymous_record_declaration?
|
71
|
+
Lib.cursor_is_anonymous_record_decl(@cursor) != 0
|
72
|
+
end
|
73
|
+
|
65
74
|
def declaration?
|
66
75
|
Lib.is_declaration(kind) != 0
|
67
76
|
end
|
@@ -137,6 +146,9 @@ module FFI
|
|
137
146
|
|
138
147
|
def qualified_name
|
139
148
|
if self.kind != :cursor_translation_unit
|
149
|
+
if self.semantic_parent.kind == :cursor_invalid_file
|
150
|
+
raise(ArgumentError, "Invalid semantic parent: #{self}")
|
151
|
+
end
|
140
152
|
result = self.semantic_parent.qualified_name
|
141
153
|
result ? "#{result}::#{self.spelling}" : self.spelling
|
142
154
|
end
|
@@ -155,7 +167,7 @@ module FFI
|
|
155
167
|
end
|
156
168
|
|
157
169
|
def kind
|
158
|
-
@cursor[:kind]
|
170
|
+
@cursor ? @cursor[:kind] : nil
|
159
171
|
end
|
160
172
|
|
161
173
|
def kind_spelling
|
@@ -163,15 +175,15 @@ module FFI
|
|
163
175
|
end
|
164
176
|
|
165
177
|
def type
|
166
|
-
Type.
|
178
|
+
Types::Type.create Lib.get_cursor_type(@cursor), @translation_unit
|
167
179
|
end
|
168
180
|
|
169
181
|
def result_type
|
170
|
-
Type.
|
182
|
+
Types::Type.create Lib.get_cursor_result_type(@cursor), @translation_unit
|
171
183
|
end
|
172
184
|
|
173
185
|
def underlying_type
|
174
|
-
Type.
|
186
|
+
Types::Type.create Lib.get_typedef_decl_underlying_type(@cursor), @translation_unit
|
175
187
|
end
|
176
188
|
|
177
189
|
def virtual_base?
|
@@ -211,7 +223,7 @@ module FFI
|
|
211
223
|
end
|
212
224
|
|
213
225
|
def enum_type
|
214
|
-
Type.
|
226
|
+
Types::Type.create Lib.get_enum_decl_integer_type(@cursor), @translation_unit
|
215
227
|
end
|
216
228
|
|
217
229
|
def specialized_template
|
@@ -269,14 +281,57 @@ module FFI
|
|
269
281
|
Lib.get_num_args @cursor
|
270
282
|
end
|
271
283
|
|
272
|
-
def
|
284
|
+
def each(recurse = true, &block)
|
285
|
+
return to_enum(:each, recurse) unless block_given?
|
286
|
+
|
273
287
|
adapter = Proc.new do |cxcursor, parent_cursor, unused|
|
274
|
-
block
|
288
|
+
# Call the block and capture the result. This lets advanced users
|
289
|
+
# modify the recursion on a case by case basis if needed
|
290
|
+
result = block.call Cursor.new(cxcursor, @translation_unit), Cursor.new(parent_cursor, @translation_unit)
|
291
|
+
case result
|
292
|
+
when :continue
|
293
|
+
:continue
|
294
|
+
when :recurse
|
295
|
+
:recurse
|
296
|
+
else
|
297
|
+
recurse ? :recurse : :continue
|
298
|
+
end
|
275
299
|
end
|
276
|
-
|
300
|
+
|
277
301
|
Lib.visit_children(@cursor, adapter, nil)
|
278
302
|
end
|
279
303
|
|
304
|
+
def visit_children(&block)
|
305
|
+
each(false, &block)
|
306
|
+
end
|
307
|
+
|
308
|
+
def ancestors_by_kind(*kinds)
|
309
|
+
result = Array.new
|
310
|
+
|
311
|
+
parent = self
|
312
|
+
while parent != self.semantic_parent
|
313
|
+
parent = self.semantic_parent
|
314
|
+
if kinds.include?(parent.kind)
|
315
|
+
result << parent
|
316
|
+
end
|
317
|
+
end
|
318
|
+
result
|
319
|
+
end
|
320
|
+
|
321
|
+
def find_by_kind(recurse, *kinds)
|
322
|
+
unless (recurse == nil || recurse == true || recurse == false)
|
323
|
+
raise("Recurse parameter must be nil or a boolean value. Value was: #{recurse}")
|
324
|
+
end
|
325
|
+
|
326
|
+
result = Array.new
|
327
|
+
self.each(recurse) do |child, parent|
|
328
|
+
if kinds.include?(child.kind)
|
329
|
+
result << child
|
330
|
+
end
|
331
|
+
end
|
332
|
+
result
|
333
|
+
end
|
334
|
+
|
280
335
|
def find_references_in_file(file = nil, &block)
|
281
336
|
file ||= Lib.extract_string Lib.get_translation_unit_spelling(@translation_unit)
|
282
337
|
|
@@ -293,6 +348,10 @@ module FFI
|
|
293
348
|
Lib.get_cursor_linkage(@cursor)
|
294
349
|
end
|
295
350
|
|
351
|
+
def exception_specification
|
352
|
+
Lib.get_cursor_exception_specification_type(@cursor)
|
353
|
+
end
|
354
|
+
|
296
355
|
def availability
|
297
356
|
Lib.get_cursor_availability(@cursor)
|
298
357
|
end
|
@@ -384,46 +443,10 @@ module FFI
|
|
384
443
|
Lib.get_cursor_hash(@cursor)
|
385
444
|
end
|
386
445
|
|
387
|
-
def find_all(*kinds)
|
388
|
-
filter do |child, parent|
|
389
|
-
kinds.include?(child.kind)
|
390
|
-
end
|
391
|
-
end
|
392
|
-
|
393
|
-
def find_first(*kinds)
|
394
|
-
find_all(*kinds).first
|
395
|
-
end
|
396
|
-
|
397
|
-
def filter
|
398
|
-
return to_enum(:select) unless block_given?
|
399
|
-
|
400
|
-
matching = []
|
401
|
-
|
402
|
-
self.visit_children do |child, parent|
|
403
|
-
if yield(child, parent)
|
404
|
-
matching << child
|
405
|
-
end
|
406
|
-
|
407
|
-
:recurse
|
408
|
-
end
|
409
|
-
|
410
|
-
return matching
|
411
|
-
end
|
412
|
-
|
413
|
-
def select
|
414
|
-
filter do |child, parent|
|
415
|
-
yield(child)
|
416
|
-
end
|
417
|
-
end
|
418
|
-
|
419
446
|
def to_s
|
420
447
|
"Cursor <#{self.kind.to_s.gsub(/^cursor_/, '')}: #{self.spelling}>"
|
421
448
|
end
|
422
449
|
|
423
|
-
def to_a
|
424
|
-
filter.collect{|child, parent| child}
|
425
|
-
end
|
426
|
-
|
427
450
|
def references(file = nil)
|
428
451
|
refs = []
|
429
452
|
self.find_references_in_file(file) do |cursor, unused|
|
data/lib/ffi/clang/lib/cursor.rb
CHANGED
@@ -319,6 +319,19 @@ module FFI
|
|
319
319
|
:external, 4,
|
320
320
|
]
|
321
321
|
|
322
|
+
enum :exception_specification_type, [
|
323
|
+
:none,
|
324
|
+
:dynamic_none,
|
325
|
+
:dynamic,
|
326
|
+
:ms_any,
|
327
|
+
:basic_noexcept,
|
328
|
+
:computed_noexcept,
|
329
|
+
:unevaluated,
|
330
|
+
:uninstantiated,
|
331
|
+
:unparsed,
|
332
|
+
:no_throw
|
333
|
+
]
|
334
|
+
|
322
335
|
class CXCursor < FFI::Struct
|
323
336
|
layout(
|
324
337
|
:kind, :cursor_kind,
|
@@ -441,6 +454,8 @@ module FFI
|
|
441
454
|
attach_function :find_references_in_file, :clang_findReferencesInFile, [CXCursor.by_value, :CXFile, CXCursorAndRangeVisitor.by_value], :result
|
442
455
|
|
443
456
|
attach_function :get_cursor_type, :clang_getCursorType, [CXCursor.by_value], CXType.by_value
|
457
|
+
attach_function :cursor_is_anonymous, :clang_Cursor_isAnonymous, [CXCursor.by_value], :uint
|
458
|
+
attach_function :cursor_is_anonymous_record_decl, :clang_Cursor_isAnonymousRecordDecl, [CXCursor.by_value], :uint
|
444
459
|
attach_function :get_cursor_result_type, :clang_getCursorResultType, [CXCursor.by_value], CXType.by_value
|
445
460
|
attach_function :get_typedef_decl_underlying_type, :clang_getTypedefDeclUnderlyingType, [CXCursor.by_value], CXType.by_value
|
446
461
|
attach_function :get_enum_decl_integer_type, :clang_getEnumDeclIntegerType, [CXCursor.by_value], CXType.by_value
|
@@ -452,6 +467,7 @@ module FFI
|
|
452
467
|
|
453
468
|
attach_function :get_cursor_availability, :clang_getCursorAvailability, [CXCursor.by_value], :availability
|
454
469
|
attach_function :get_cursor_linkage, :clang_getCursorLinkage, [CXCursor.by_value], :linkage_kind
|
470
|
+
attach_function :get_cursor_exception_specification_type, :clang_getCursorExceptionSpecificationType, [CXCursor.by_value], :exception_specification_type
|
455
471
|
attach_function :get_included_file, :clang_getIncludedFile, [CXCursor.by_value], :CXFile
|
456
472
|
attach_function :get_cursor_hash, :clang_hashCursor, [CXCursor.by_value], :uint
|
457
473
|
|
data/lib/ffi/clang/lib/type.rb
CHANGED
@@ -169,6 +169,20 @@ module FFI
|
|
169
169
|
:layout_error_undeduced, -6
|
170
170
|
]
|
171
171
|
|
172
|
+
# Also defined in cursor.rb
|
173
|
+
enum :exception_specification_type, [
|
174
|
+
:none,
|
175
|
+
:dynamic_none,
|
176
|
+
:dynamic,
|
177
|
+
:ms_any,
|
178
|
+
:basic_noexcept,
|
179
|
+
:computed_noexcept,
|
180
|
+
:unevaluated,
|
181
|
+
:uninstantiated,
|
182
|
+
:unparsed,
|
183
|
+
:no_throw
|
184
|
+
]
|
185
|
+
|
172
186
|
class CXType < FFI::Struct
|
173
187
|
layout(
|
174
188
|
:kind, :kind,
|
@@ -206,6 +220,7 @@ module FFI
|
|
206
220
|
attach_function :type_get_cxx_ref_qualifier, :clang_Type_getCXXRefQualifier, [CXType.by_value], :ref_qualifier_kind
|
207
221
|
|
208
222
|
attach_function :get_fuction_type_calling_conv, :clang_getFunctionTypeCallingConv, [CXType.by_value], :calling_conv
|
223
|
+
attach_function :get_exception_specification_type, :clang_getExceptionSpecificationType, [CXType.by_value], :exception_specification_type
|
209
224
|
|
210
225
|
attach_function :equal_types, :clang_equalTypes, [CXType.by_value, CXType.by_value], :uint
|
211
226
|
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,43 @@
|
|
1
|
+
module FFI
|
2
|
+
module Clang
|
3
|
+
module Types
|
4
|
+
class Function < Type
|
5
|
+
include Enumerable
|
6
|
+
|
7
|
+
def variadic?
|
8
|
+
Lib.is_function_type_variadic(@type) != 0
|
9
|
+
end
|
10
|
+
|
11
|
+
def args_size
|
12
|
+
Lib.get_num_arg_types(@type)
|
13
|
+
end
|
14
|
+
|
15
|
+
def arg_type(i)
|
16
|
+
Type.create Lib.get_arg_type(@type, i), @translation_unit
|
17
|
+
end
|
18
|
+
|
19
|
+
def arg_types
|
20
|
+
return to_enum(:arg_types) unless block_given?
|
21
|
+
|
22
|
+
self.args_size.times do |i|
|
23
|
+
yield self.arg_type(i)
|
24
|
+
end
|
25
|
+
|
26
|
+
self
|
27
|
+
end
|
28
|
+
|
29
|
+
def result_type
|
30
|
+
Type.create Lib.get_result_type(@type), @translation_unit
|
31
|
+
end
|
32
|
+
|
33
|
+
def calling_conv
|
34
|
+
Lib.get_fuction_type_calling_conv(@type)
|
35
|
+
end
|
36
|
+
|
37
|
+
def exception_specification
|
38
|
+
Lib.get_exception_specification_type(@type)
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
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,102 @@
|
|
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 are not 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 non_reference_type
|
89
|
+
Type.create Lib.get_non_reference_type(@type),@translation_unit
|
90
|
+
end
|
91
|
+
|
92
|
+
def ==(other)
|
93
|
+
Lib.equal_types(@type, other.type) != 0
|
94
|
+
end
|
95
|
+
|
96
|
+
def to_s
|
97
|
+
"#{self.class.name} <#{self.kind}: #{self.spelling}>"
|
98
|
+
end
|
99
|
+
end
|
100
|
+
end
|
101
|
+
end
|
102
|
+
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
|
data/lib/ffi/clang/version.rb
CHANGED
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.tar.gz.sig
CHANGED
Binary file
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ffi-clang
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.11.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Samuel Williams
|
@@ -55,7 +55,7 @@ cert_chain:
|
|
55
55
|
Q2K9NVun/S785AP05vKkXZEFYxqG6EW012U4oLcFl5MySFajYXRYbuUpH6AY+HP8
|
56
56
|
voD0MPg1DssDLKwXyt1eKD/+Fq0bFWhwVM/1XiAXL7lyYUyOq24KHgQ2Csg=
|
57
57
|
-----END CERTIFICATE-----
|
58
|
-
date: 2024-
|
58
|
+
date: 2024-11-13 00:00:00.000000000 Z
|
59
59
|
dependencies:
|
60
60
|
- !ruby/object:Gem::Dependency
|
61
61
|
name: ffi
|
@@ -110,7 +110,14 @@ files:
|
|
110
110
|
- lib/ffi/clang/source_range.rb
|
111
111
|
- lib/ffi/clang/token.rb
|
112
112
|
- lib/ffi/clang/translation_unit.rb
|
113
|
-
- lib/ffi/clang/
|
113
|
+
- lib/ffi/clang/types/array.rb
|
114
|
+
- lib/ffi/clang/types/elaborated.rb
|
115
|
+
- lib/ffi/clang/types/function.rb
|
116
|
+
- lib/ffi/clang/types/pointer.rb
|
117
|
+
- lib/ffi/clang/types/record.rb
|
118
|
+
- lib/ffi/clang/types/type.rb
|
119
|
+
- lib/ffi/clang/types/type_def.rb
|
120
|
+
- lib/ffi/clang/types/vector.rb
|
114
121
|
- lib/ffi/clang/unsaved_file.rb
|
115
122
|
- lib/ffi/clang/version.rb
|
116
123
|
- license.md
|
@@ -136,7 +143,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
136
143
|
- !ruby/object:Gem::Version
|
137
144
|
version: '0'
|
138
145
|
requirements: []
|
139
|
-
rubygems_version: 3.5.
|
146
|
+
rubygems_version: 3.5.22
|
140
147
|
signing_key:
|
141
148
|
specification_version: 4
|
142
149
|
summary: Ruby FFI bindings for libclang C interface.
|
metadata.gz.sig
CHANGED
Binary file
|
data/lib/ffi/clang/type.rb
DELETED
@@ -1,160 +0,0 @@
|
|
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
|
-
class Type
|
14
|
-
attr_reader :type
|
15
|
-
|
16
|
-
def initialize(type, translation_unit)
|
17
|
-
@type = type
|
18
|
-
@translation_unit = translation_unit
|
19
|
-
end
|
20
|
-
|
21
|
-
def kind
|
22
|
-
@type[:kind]
|
23
|
-
end
|
24
|
-
|
25
|
-
def kind_spelling
|
26
|
-
Lib.extract_string Lib.get_type_kind_spelling @type[:kind]
|
27
|
-
end
|
28
|
-
|
29
|
-
def spelling
|
30
|
-
Lib.extract_string Lib.get_type_spelling(@type)
|
31
|
-
end
|
32
|
-
|
33
|
-
def variadic?
|
34
|
-
Lib.is_function_type_variadic(@type) != 0
|
35
|
-
end
|
36
|
-
|
37
|
-
def pod?
|
38
|
-
Lib.is_pod_type(@type) != 0
|
39
|
-
end
|
40
|
-
|
41
|
-
def num_arg_types
|
42
|
-
Lib.get_num_arg_types(@type)
|
43
|
-
end
|
44
|
-
|
45
|
-
def pointer?
|
46
|
-
[:type_pointer, :type_block_pointer, :type_obj_c_object_pointer, :type_member_pointer].
|
47
|
-
include?(self.kind)
|
48
|
-
end
|
49
|
-
|
50
|
-
def pointee
|
51
|
-
if self.pointer?
|
52
|
-
Type.new Lib.get_pointee_type(@type), @translation_unit
|
53
|
-
else
|
54
|
-
nil
|
55
|
-
end
|
56
|
-
end
|
57
|
-
|
58
|
-
def canonical
|
59
|
-
Type.new Lib.get_canonical_type(@type), @translation_unit
|
60
|
-
end
|
61
|
-
|
62
|
-
def class_type
|
63
|
-
if self.kind == :type_member_pointer
|
64
|
-
Type.new Lib.type_get_class_type(@type), @translation_unit
|
65
|
-
else
|
66
|
-
nil
|
67
|
-
end
|
68
|
-
end
|
69
|
-
|
70
|
-
def const_qualified?
|
71
|
-
Lib.is_const_qualified_type(@type) != 0
|
72
|
-
end
|
73
|
-
|
74
|
-
def volatile_qualified?
|
75
|
-
Lib.is_volatile_qualified_type(@type) != 0
|
76
|
-
end
|
77
|
-
|
78
|
-
def restrict_qualified?
|
79
|
-
Lib.is_restrict_qualified_type(@type) != 0
|
80
|
-
end
|
81
|
-
|
82
|
-
def function?
|
83
|
-
[:type_function_no_proto, :type_function_proto].include?(self.kind)
|
84
|
-
end
|
85
|
-
|
86
|
-
def arg_type(i)
|
87
|
-
if self.function?
|
88
|
-
Type.new Lib.get_arg_type(@type, i), @translation_unit
|
89
|
-
else
|
90
|
-
nil
|
91
|
-
end
|
92
|
-
end
|
93
|
-
|
94
|
-
def result_type
|
95
|
-
if self.function?
|
96
|
-
Type.new Lib.get_result_type(@type), @translation_unit
|
97
|
-
else
|
98
|
-
nil
|
99
|
-
end
|
100
|
-
end
|
101
|
-
|
102
|
-
def element_type
|
103
|
-
if self.array? || [:type_vector, :type_complex].include?(self.kind)
|
104
|
-
Type.new Lib.get_element_type(@type), @translation_unit
|
105
|
-
else
|
106
|
-
nil
|
107
|
-
end
|
108
|
-
end
|
109
|
-
|
110
|
-
def num_elements
|
111
|
-
Lib.get_num_elements(@type)
|
112
|
-
end
|
113
|
-
|
114
|
-
def array?
|
115
|
-
[:type_constant_array, :type_incomplete_array, :type_variable_array, :type_dependent_sized_array].
|
116
|
-
include?(self.kind)
|
117
|
-
end
|
118
|
-
|
119
|
-
def array_element_type
|
120
|
-
if self.array?
|
121
|
-
Type.new Lib.get_array_element_type(@type), @translation_unit
|
122
|
-
else
|
123
|
-
nil
|
124
|
-
end
|
125
|
-
end
|
126
|
-
|
127
|
-
def array_size
|
128
|
-
Lib.get_array_size(@type)
|
129
|
-
end
|
130
|
-
|
131
|
-
def alignof
|
132
|
-
Lib.type_get_align_of(@type)
|
133
|
-
end
|
134
|
-
|
135
|
-
def sizeof
|
136
|
-
Lib.type_get_size_of(@type)
|
137
|
-
end
|
138
|
-
|
139
|
-
def offsetof(field)
|
140
|
-
Lib.type_get_offset_of(@type, field)
|
141
|
-
end
|
142
|
-
|
143
|
-
def ref_qualifier
|
144
|
-
Lib.type_get_cxx_ref_qualifier(@type)
|
145
|
-
end
|
146
|
-
|
147
|
-
def calling_conv
|
148
|
-
Lib.get_fuction_type_calling_conv(@type)
|
149
|
-
end
|
150
|
-
|
151
|
-
def declaration
|
152
|
-
Cursor.new Lib.get_type_declaration(@type), @translation_unit
|
153
|
-
end
|
154
|
-
|
155
|
-
def ==(other)
|
156
|
-
Lib.equal_types(@type, other.type) != 0
|
157
|
-
end
|
158
|
-
end
|
159
|
-
end
|
160
|
-
end
|