ffi-clang 0.7.0 → 0.9.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.
Files changed (80) hide show
  1. checksums.yaml +4 -4
  2. checksums.yaml.gz.sig +3 -0
  3. data/ext/rakefile.rb +4 -0
  4. data/ext/teapot.rb +4 -3
  5. data/lib/ffi/clang/clang_version.rb +10 -19
  6. data/lib/ffi/clang/code_completion.rb +8 -20
  7. data/lib/ffi/clang/comment.rb +7 -19
  8. data/lib/ffi/clang/compilation_database.rb +4 -18
  9. data/lib/ffi/clang/cursor.rb +117 -35
  10. data/lib/ffi/clang/diagnostic.rb +11 -23
  11. data/lib/ffi/clang/file.rb +4 -18
  12. data/lib/ffi/clang/index.rb +19 -23
  13. data/lib/ffi/clang/lib/clang_version.rb +5 -19
  14. data/lib/ffi/clang/lib/code_completion.rb +13 -26
  15. data/lib/ffi/clang/lib/comment.rb +7 -20
  16. data/lib/ffi/clang/lib/compilation_database.rb +4 -18
  17. data/lib/ffi/clang/lib/cursor.rb +102 -28
  18. data/lib/ffi/clang/lib/diagnostic.rb +7 -20
  19. data/lib/ffi/clang/lib/file.rb +7 -20
  20. data/lib/ffi/clang/lib/inclusions.rb +5 -19
  21. data/lib/ffi/clang/lib/index.rb +25 -20
  22. data/lib/ffi/clang/lib/printing_policy.rb +47 -0
  23. data/lib/ffi/clang/lib/source_location.rb +5 -20
  24. data/lib/ffi/clang/lib/source_range.rb +5 -22
  25. data/lib/ffi/clang/lib/string.rb +4 -20
  26. data/lib/ffi/clang/lib/token.rb +4 -18
  27. data/lib/ffi/clang/lib/translation_unit.rb +19 -21
  28. data/lib/ffi/clang/lib/type.rb +87 -22
  29. data/lib/ffi/clang/lib.rb +24 -28
  30. data/lib/ffi/clang/printing_policy.rb +36 -0
  31. data/lib/ffi/clang/source_location.rb +42 -38
  32. data/lib/ffi/clang/source_range.rb +7 -22
  33. data/lib/ffi/clang/token.rb +4 -18
  34. data/lib/ffi/clang/translation_unit.rb +10 -20
  35. data/lib/ffi/clang/type.rb +52 -25
  36. data/lib/ffi/clang/unsaved_file.rb +6 -20
  37. data/lib/ffi/clang/version.rb +7 -21
  38. data/lib/ffi/clang.rb +9 -20
  39. data/license.md +39 -0
  40. data/readme.md +56 -0
  41. data.tar.gz.sig +0 -0
  42. metadata +62 -116
  43. metadata.gz.sig +0 -0
  44. data/.editorconfig +0 -23
  45. data/.gitignore +0 -19
  46. data/.rspec +0 -5
  47. data/.travis.yml +0 -30
  48. data/Gemfile +0 -12
  49. data/README.md +0 -74
  50. data/Rakefile +0 -12
  51. data/examples/docs.cpp +0 -25
  52. data/examples/docs.rb +0 -31
  53. data/ffi-clang.gemspec +0 -25
  54. data/spec/ffi/clang/code_completion_spec.rb +0 -181
  55. data/spec/ffi/clang/comment_spec.rb +0 -453
  56. data/spec/ffi/clang/compilation_database_spec.rb +0 -180
  57. data/spec/ffi/clang/cursor_spec.rb +0 -741
  58. data/spec/ffi/clang/diagnostic_spec.rb +0 -89
  59. data/spec/ffi/clang/file_spec.rb +0 -82
  60. data/spec/ffi/clang/fixtures/a.c +0 -7
  61. data/spec/ffi/clang/fixtures/canonical.c +0 -5
  62. data/spec/ffi/clang/fixtures/class.cpp +0 -8
  63. data/spec/ffi/clang/fixtures/compile_commands.json +0 -17
  64. data/spec/ffi/clang/fixtures/completion.cxx +0 -8
  65. data/spec/ffi/clang/fixtures/docs.c +0 -1
  66. data/spec/ffi/clang/fixtures/docs.cc +0 -1
  67. data/spec/ffi/clang/fixtures/docs.h +0 -54
  68. data/spec/ffi/clang/fixtures/list.c +0 -11
  69. data/spec/ffi/clang/fixtures/location1.c +0 -7
  70. data/spec/ffi/clang/fixtures/simple.ast +0 -0
  71. data/spec/ffi/clang/fixtures/simple.c +0 -3
  72. data/spec/ffi/clang/fixtures/test.cxx +0 -62
  73. data/spec/ffi/clang/index_spec.rb +0 -90
  74. data/spec/ffi/clang/source_location_spec.rb +0 -138
  75. data/spec/ffi/clang/source_range_spec.rb +0 -74
  76. data/spec/ffi/clang/token_spec.rb +0 -82
  77. data/spec/ffi/clang/translation_unit_spec.rb +0 -220
  78. data/spec/ffi/clang/type_spec.rb +0 -273
  79. data/spec/ffi/clang/version_spec.rb +0 -28
  80. data/spec/spec_helper.rb +0 -51
@@ -1,23 +1,12 @@
1
- # Copyright, 2013, by Samuel G. D. Williams. <http://www.codeotaku.com>
2
- # Copyright, 2014, by Masahiro Sano.
3
- #
4
- # Permission is hereby granted, free of charge, to any person obtaining a copy
5
- # of this software and associated documentation files (the "Software"), to deal
6
- # in the Software without restriction, including without limitation the rights
7
- # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
- # copies of the Software, and to permit persons to whom the Software is
9
- # furnished to do so, subject to the following conditions:
10
- #
11
- # The above copyright notice and this permission notice shall be included in
12
- # all copies or substantial portions of the Software.
13
- #
14
- # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
- # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
- # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
- # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
- # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
- # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
20
- # THE SOFTWARE.
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, 2013-2014, by Masahiro Sano.
8
+ # Copyright, 2014, by Niklas Therning.
9
+ # Copyright, 2024, by Charlie Savage.
21
10
 
22
11
  module FFI
23
12
  module Clang
@@ -71,6 +60,71 @@ module FFI
71
60
  :type_variable_array, 115,
72
61
  :type_dependent_sized_array, 116,
73
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
74
128
  ]
75
129
 
76
130
  enum :calling_conv, [
@@ -86,6 +140,16 @@ module FFI
86
140
  :calling_conv_intel_ocl_bicc, 9,
87
141
  :calling_conv_x86_64_win64, 10,
88
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,
89
153
  :calling_conv_invalid, 100,
90
154
  :calling_conv_unexposed, 200
91
155
  ]
@@ -102,6 +166,7 @@ module FFI
102
166
  :layout_error_dependent, -3,
103
167
  :layout_error_not_constant_size, -4,
104
168
  :layout_error_invalid_field_name, -5,
169
+ :layout_error_undeduced, -6
105
170
  ]
106
171
 
107
172
  class CXType < FFI::Struct
@@ -120,7 +185,7 @@ module FFI
120
185
  attach_function :get_pointee_type, :clang_getPointeeType, [CXType.by_value], CXType.by_value
121
186
  attach_function :get_result_type, :clang_getResultType, [CXType.by_value], CXType.by_value
122
187
  attach_function :get_canonical_type, :clang_getCanonicalType, [CXType.by_value], CXType.by_value
123
-
188
+
124
189
  attach_function :type_get_class_type, :clang_Type_getClassType, [CXType.by_value], CXType.by_value
125
190
 
126
191
  attach_function :is_const_qualified_type, :clang_isConstQualifiedType, [CXType.by_value], :uint
@@ -139,7 +204,7 @@ module FFI
139
204
  attach_function :type_get_offset_of, :clang_Type_getOffsetOf, [CXType.by_value, :string], :long_long
140
205
 
141
206
  attach_function :type_get_cxx_ref_qualifier, :clang_Type_getCXXRefQualifier, [CXType.by_value], :ref_qualifier_kind
142
-
207
+
143
208
  attach_function :get_fuction_type_calling_conv, :clang_getFunctionTypeCallingConv, [CXType.by_value], :calling_conv
144
209
 
145
210
  attach_function :equal_types, :clang_equalTypes, [CXType.by_value, CXType.by_value], :uint
data/lib/ffi/clang/lib.rb CHANGED
@@ -1,23 +1,19 @@
1
- # Copyright, 2010-2012 by Jari Bakken.
2
- # Copyright, 2013, by Samuel G. D. Williams. <http://www.codeotaku.com>
3
- #
4
- # Permission is hereby granted, free of charge, to any person obtaining a copy
5
- # of this software and associated documentation files (the "Software"), to deal
6
- # in the Software without restriction, including without limitation the rights
7
- # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
- # copies of the Software, and to permit persons to whom the Software is
9
- # furnished to do so, subject to the following conditions:
10
- #
11
- # The above copyright notice and this permission notice shall be included in
12
- # all copies or substantial portions of the Software.
13
- #
14
- # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
- # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
- # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
- # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
- # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
- # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
20
- # THE SOFTWARE.
1
+ # frozen_string_literal: true
2
+
3
+ # Released under the MIT License.
4
+ # Copyright, 2010-2012, by Jari Bakken.
5
+ # Copyright, 2012, by Hal Brodigan.
6
+ # Copyright, 2013-2024, by Samuel Williams.
7
+ # Copyright, 2013-2014, by Carlos Martín Nieto.
8
+ # Copyright, 2013, by Takeshi Watanabe.
9
+ # Copyright, 2014, by Masahiro Sano.
10
+ # Copyright, 2014, by Greg Hazel.
11
+ # Copyright, 2014, by Niklas Therning.
12
+ # Copyright, 2016, by Mike Dalessio.
13
+ # Copyright, 2019, by Hayden Purdy.
14
+ # Copyright, 2019, by Dominic Sisnero.
15
+ # Copyright, 2020, by Zete Lui.
16
+ # Copyright, 2023, by Charlie Savage.
21
17
 
22
18
  require 'mkmf'
23
19
 
@@ -74,11 +70,11 @@ module FFI
74
70
  def self.bitmask_from(enum, opts)
75
71
  bitmask = 0
76
72
 
77
- opts.each do |key, value|
78
- if int = enum[key]
73
+ opts.each do |symbol|
74
+ if int = enum[symbol]
79
75
  bitmask |= int
80
76
  else
81
- raise Error, "unknown option: #{key.inspect}, expected one of #{enum.symbols}"
77
+ raise Error, "unknown option: #{symbol}, expected one of #{enum.symbols}"
82
78
  end
83
79
  end
84
80
 
@@ -87,19 +83,19 @@ module FFI
87
83
 
88
84
  def self.opts_from(enum, bitmask)
89
85
  bit = 1
90
- opts = {}
86
+ result = []
91
87
  while bitmask != 0
92
88
  if bitmask & 1
93
- if sym = enum[bit]
94
- opts[sym] = true
89
+ if symbol = enum[bit]
90
+ result << symbol
95
91
  else
96
- raise Error, "unknown values: #{bit}, expected one of #{enum.symbols}"
92
+ raise(Error, "unknown values: #{bit}, expected one of #{enum.symbols}")
97
93
  end
98
94
  end
99
95
  bitmask >>= 1
100
96
  bit <<= 1
101
97
  end
102
- opts
98
+ result
103
99
  end
104
100
  end
105
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
@@ -1,24 +1,12 @@
1
- # Copyright, 2010-2012 by Jari Bakken.
2
- # Copyright, 2013, by Samuel G. D. Williams. <http://www.codeotaku.com>
1
+ # frozen_string_literal: true
2
+
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.
7
+ # Copyright, 2013, by Garry Marshall.
3
8
  # Copyright, 2014, by Masahiro Sano.
4
- #
5
- # Permission is hereby granted, free of charge, to any person obtaining a copy
6
- # of this software and associated documentation files (the "Software"), to deal
7
- # in the Software without restriction, including without limitation the rights
8
- # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- # copies of the Software, and to permit persons to whom the Software is
10
- # furnished to do so, subject to the following conditions:
11
- #
12
- # The above copyright notice and this permission notice shall be included in
13
- # all copies or substantial portions of the Software.
14
- #
15
- # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
- # THE SOFTWARE.
9
+ # Copyright, 2024, by Charlie Savage.
22
10
 
23
11
  require_relative 'lib/source_location'
24
12
  require_relative 'lib/file'
@@ -43,22 +31,6 @@ module FFI
43
31
  Lib.location_is_from_main_file(@location) != 0
44
32
  end
45
33
 
46
- def expansion_location
47
- ExpansionLocation.new(@location)
48
- end
49
-
50
- def presumed_location
51
- PresumedLocation.new(@location)
52
- end
53
-
54
- def spelling_location
55
- SpellingLocation.new(@location)
56
- end
57
-
58
- def file_location
59
- FileLocation.new(@location)
60
- end
61
-
62
34
  def null?
63
35
  Lib.equal_locations(@location, Lib.get_null_location) != 0
64
36
  end
@@ -86,6 +58,14 @@ module FFI
86
58
  @column = column.get_uint(0)
87
59
  @offset = offset.get_uint(0)
88
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
89
69
  end
90
70
 
91
71
  class PresumedLocation < SourceLocation
@@ -95,8 +75,8 @@ module FFI
95
75
  super(location)
96
76
 
97
77
  cxstring = MemoryPointer.new Lib::CXString
98
- line = MemoryPointer.new :uint
99
- column = MemoryPointer.new :uint
78
+ line = MemoryPointer.new :uint
79
+ column = MemoryPointer.new :uint
100
80
 
101
81
  Lib::get_presumed_location(@location, cxstring, line, column)
102
82
 
@@ -104,6 +84,14 @@ module FFI
104
84
  @line = line.get_uint(0)
105
85
  @column = column.get_uint(0)
106
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
107
95
  end
108
96
 
109
97
  class SpellingLocation < SourceLocation
@@ -124,6 +112,14 @@ module FFI
124
112
  @column = column.get_uint(0)
125
113
  @offset = offset.get_uint(0)
126
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
127
123
  end
128
124
 
129
125
  class FileLocation < SourceLocation
@@ -144,6 +140,14 @@ module FFI
144
140
  @column = column.get_uint(0)
145
141
  @offset = offset.get_uint(0)
146
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
147
151
  end
148
152
  end
149
153
  end
@@ -1,26 +1,11 @@
1
- # -*- coding: utf-8 -*-
2
- # Copyright, 2010-2012 by Jari Bakken.
3
- # Copyright, 2013, by Samuel G. D. Williams. <http://www.codeotaku.com>
4
- # Copyright, 2013, by Garry C. Marshall. <http://www.meaningfulname.net>
1
+ # frozen_string_literal: true
2
+
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.
7
+ # Copyright, 2013, by Garry Marshall.
5
8
  # Copyright, 2014, by Masahiro Sano.
6
- #
7
- # Permission is hereby granted, free of charge, to any person obtaining a copy
8
- # of this software and associated documentation files (the "Software"), to deal
9
- # in the Software without restriction, including without limitation the rights
10
- # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11
- # copies of the Software, and to permit persons to whom the Software is
12
- # furnished to do so, subject to the following conditions:
13
- #
14
- # The above copyright notice and this permission notice shall be included in
15
- # all copies or substantial portions of the Software.
16
- #
17
- # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18
- # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19
- # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20
- # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21
- # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22
- # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
23
- # THE SOFTWARE.
24
9
 
25
10
  require_relative 'lib/source_range'
26
11
 
@@ -1,22 +1,8 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Released under the MIT License.
1
4
  # Copyright, 2014, by Masahiro Sano.
2
- #
3
- # Permission is hereby granted, free of charge, to any person obtaining a copy
4
- # of this software and associated documentation files (the "Software"), to deal
5
- # in the Software without restriction, including without limitation the rights
6
- # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7
- # copies of the Software, and to permit persons to whom the Software is
8
- # furnished to do so, subject to the following conditions:
9
- #
10
- # The above copyright notice and this permission notice shall be included in
11
- # all copies or substantial portions of the Software.
12
- #
13
- # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
- # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
- # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16
- # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
- # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18
- # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19
- # THE SOFTWARE.
5
+ # Copyright, 2014-2022, by Samuel Williams.
20
6
 
21
7
  require_relative 'lib/token'
22
8
  require_relative 'lib/cursor'
@@ -1,24 +1,14 @@
1
- # Copyright, 2010-2012 by Jari Bakken.
2
- # Copyright, 2013, by Samuel G. D. Williams. <http://www.codeotaku.com>
1
+ # frozen_string_literal: true
2
+
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.
7
+ # Copyright, 2013, by Garry Marshall.
3
8
  # Copyright, 2014, by Masahiro Sano.
4
- #
5
- # Permission is hereby granted, free of charge, to any person obtaining a copy
6
- # of this software and associated documentation files (the "Software"), to deal
7
- # in the Software without restriction, including without limitation the rights
8
- # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- # copies of the Software, and to permit persons to whom the Software is
10
- # furnished to do so, subject to the following conditions:
11
- #
12
- # The above copyright notice and this permission notice shall be included in
13
- # all copies or substantial portions of the Software.
14
- #
15
- # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
- # THE SOFTWARE.
9
+ # Copyright, 2014, by Greg Hazel.
10
+ # Copyright, 2019, by Michael Metivier.
11
+ # Copyright, 2022, by Motonori Iwamuro.
22
12
 
23
13
  require_relative 'lib/translation_unit'
24
14
  require_relative 'lib/inclusions'
@@ -1,23 +1,12 @@
1
- # Copyright, 2013, by Samuel G. D. Williams. <http://www.codeotaku.com>
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.
2
7
  # Copyright, 2014, by Masahiro Sano.
3
- #
4
- # Permission is hereby granted, free of charge, to any person obtaining a copy
5
- # of this software and associated documentation files (the "Software"), to deal
6
- # in the Software without restriction, including without limitation the rights
7
- # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
- # copies of the Software, and to permit persons to whom the Software is
9
- # furnished to do so, subject to the following conditions:
10
- #
11
- # The above copyright notice and this permission notice shall be included in
12
- # all copies or substantial portions of the Software.
13
- #
14
- # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
- # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
- # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
- # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
- # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
- # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
20
- # THE SOFTWARE.
8
+ # Copyright, 2014, by Niklas Therning.
9
+ # Copyright, 2024, by Charlie Savage.
21
10
 
22
11
  module FFI
23
12
  module Clang
@@ -53,8 +42,17 @@ module FFI
53
42
  Lib.get_num_arg_types(@type)
54
43
  end
55
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
+
56
50
  def pointee
57
- Type.new Lib.get_pointee_type(@type), @translation_unit
51
+ if self.pointer?
52
+ Type.new Lib.get_pointee_type(@type), @translation_unit
53
+ else
54
+ nil
55
+ end
58
56
  end
59
57
 
60
58
  def canonical
@@ -62,7 +60,11 @@ module FFI
62
60
  end
63
61
 
64
62
  def class_type
65
- Type.new Lib.type_get_class_type(@type), @translation_unit
63
+ if self.kind == :type_member_pointer
64
+ Type.new Lib.type_get_class_type(@type), @translation_unit
65
+ else
66
+ nil
67
+ end
66
68
  end
67
69
 
68
70
  def const_qualified?
@@ -77,24 +79,49 @@ module FFI
77
79
  Lib.is_restrict_qualified_type(@type) != 0
78
80
  end
79
81
 
82
+ def function?
83
+ [:type_function_no_proto, :type_function_proto].include?(self.kind)
84
+ end
85
+
80
86
  def arg_type(i)
81
- Type.new Lib.get_arg_type(@type, i), @translation_unit
87
+ if self.function?
88
+ Type.new Lib.get_arg_type(@type, i), @translation_unit
89
+ else
90
+ nil
91
+ end
82
92
  end
83
93
 
84
94
  def result_type
85
- Type.new Lib.get_result_type(@type), @translation_unit
95
+ if self.function?
96
+ Type.new Lib.get_result_type(@type), @translation_unit
97
+ else
98
+ nil
99
+ end
86
100
  end
87
101
 
88
102
  def element_type
89
- Type.new Lib.get_element_type(@type), @translation_unit
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
90
108
  end
91
109
 
92
110
  def num_elements
93
111
  Lib.get_num_elements(@type)
94
112
  end
95
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
+
96
119
  def array_element_type
97
- Type.new Lib.get_array_element_type(@type), @translation_unit
120
+ if self.array?
121
+ Type.new Lib.get_array_element_type(@type), @translation_unit
122
+ else
123
+ nil
124
+ end
98
125
  end
99
126
 
100
127
  def array_size
@@ -1,23 +1,9 @@
1
- # -*- coding: utf-8 -*-
2
- # Copyright, 2013, by Carlos Martín Nieto <cmn@dwim.me.
3
- #
4
- # Permission is hereby granted, free of charge, to any person obtaining a copy
5
- # of this software and associated documentation files (the "Software"), to deal
6
- # in the Software without restriction, including without limitation the rights
7
- # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
- # copies of the Software, and to permit persons to whom the Software is
9
- # furnished to do so, subject to the following conditions:
10
- #
11
- # The above copyright notice and this permission notice shall be included in
12
- # all copies or substantial portions of the Software.
13
- #
14
- # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
- # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
- # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
- # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
- # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
- # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
20
- # THE SOFTWARE.
1
+ # frozen_string_literal: true
2
+
3
+ # Released under the MIT License.
4
+ # Copyright, 2013, by Carlos Martín Nieto.
5
+ # Copyright, 2013-2022, by Samuel Williams.
6
+ # Copyright, 2014, by Masahiro Sano.
21
7
 
22
8
  module FFI
23
9
  module Clang
@@ -1,26 +1,12 @@
1
- # Copyright, 2010-2012 by Jari Bakken.
2
- # Copyright, 2016, by Samuel G. D. Williams. <http://www.codeotaku.com>
3
- #
4
- # Permission is hereby granted, free of charge, to any person obtaining a copy
5
- # of this software and associated documentation files (the "Software"), to deal
6
- # in the Software without restriction, including without limitation the rights
7
- # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
- # copies of the Software, and to permit persons to whom the Software is
9
- # furnished to do so, subject to the following conditions:
10
- #
11
- # The above copyright notice and this permission notice shall be included in
12
- # all copies or substantial portions of the Software.
13
- #
14
- # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
- # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
- # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
- # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
- # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
- # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
20
- # THE SOFTWARE.
1
+ # frozen_string_literal: true
2
+
3
+ # Released under the MIT License.
4
+ # Copyright, 2010, by Jari Bakken.
5
+ # Copyright, 2012, by Hal Brodigan.
6
+ # Copyright, 2013-2024, by Samuel Williams.
21
7
 
22
8
  module FFI
23
9
  module Clang
24
- VERSION = "0.7.0"
10
+ VERSION = "0.9.0"
25
11
  end
26
12
  end