ffi-clang 0.2.1 → 0.3.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: ba2f1301bc825e8bb4bfe80ebe60ed2e2b20945a
4
- data.tar.gz: 4d33834e8851dfcf646cb934dfd5a0921f5d81e8
3
+ metadata.gz: d482ffe964ca4f9817152f6fd3da834657851673
4
+ data.tar.gz: 405d56c4688d22790a36b7406ff8e0cffc924d1e
5
5
  SHA512:
6
- metadata.gz: 93f851368ed6a50978407ab7227511d7a20fd12716cb6413615ab00b015867b384c8c3b8eb7e1921a3ddb2b95321202282dafc8a854459342f9243c4e66774ef
7
- data.tar.gz: 365b47a6501012f6498fdbc3c9754ca4b9a2226edd5853f4084b93ac552c97a82a9c440d0fce1eb6e6f00bdd9115d144b265a78973971feb8e6cb49f85ac3d41
6
+ metadata.gz: f64cf1ee129eddde74597bd12a69dfa93c0eacfd5fd1cea9795dc51fa0915738bca97d4f88e4375fff714bc26c1ed23a434a52ea645c44667e9b3956a86f7d7b
7
+ data.tar.gz: 8895a0b39bc1ba92c4e5a799b736ee574254c925eabbaf89d30079664a75df6dd1546a23f5e5b3f545cb6929e0239ed1b0d7b9661ece208570e1512b8d3ebdb4
@@ -1,22 +1,19 @@
1
1
  language: ruby
2
- rvm:
3
- - "2.0"
4
- - "2.1"
5
- env:
6
- - LLVM_VERSION=3.2
7
- - LLVM_VERSION=3.3
8
- - LLVM_VERSION=3.4
9
- - LLVM_VERSION=3.5
10
- install:
11
- - sudo add-apt-repository --yes ppa:h-rayflood/llvm
12
- - sudo add-apt-repository --yes ppa:ubuntu-toolchain-r/test
13
- - sudo add-apt-repository --yes 'deb http://llvm.org/apt/precise/ llvm-toolchain-precise main'
14
- - wget -O - http://llvm.org/apt/llvm-snapshot.gpg.key | sudo apt-key add -
15
- - sudo apt-get -qq update
16
- - sudo apt-get -qq install libclang-${LLVM_VERSION}-dev clang-${LLVM_VERSION}
2
+ sudo: false
3
+ before_install:
17
4
  - export LD_LIBRARY_PATH=/usr/lib/llvm-${LLVM_VERSION}/lib/
18
5
  - export PATH=/usr/lib/llvm-${LLVM_VERSION}/bin:$PATH
19
- - bundle install
20
6
  matrix:
21
- allow_failures:
22
- - env: LLVM_VERSION=3.5
7
+ include:
8
+ # The default build:
9
+ - &libclang-36
10
+ addons: {apt: {sources: [ubuntu-toolchain-r-test, llvm-toolchain-precise-3.6], packages: [libclang-3.6-dev, clang-3.6]}}
11
+ env: LLVM_VERSION=3.6
12
+ rvm: "2.3.0"
13
+ # A second build with the same configuration but using ruby 2.2.4
14
+ - <<: *libclang-36
15
+ rvm: "2.2.4"
16
+ # Other builds on other versions of LLVM, all using ruby 2.3.0
17
+ - addons: {apt: {sources: [ubuntu-toolchain-r-test, llvm-toolchain-precise-3.7], packages: [libclang-3.7-dev, clang-3.7]}}
18
+ env: LLVM_VERSION=3.7
19
+ rvm: "2.3.0"
data/README.md CHANGED
@@ -1,9 +1,9 @@
1
1
  # FFI::Clang
2
2
 
3
- A light weight wrapper for Ruby exposing [libclang][1].
3
+ A light-weight wrapper for Ruby exposing [libclang][1].
4
4
 
5
- [![Build Status](https://secure.travis-ci.org/ioquatix/ffi-clang.png)](http://travis-ci.org/ioquatix/ffi-clang)
6
- [![Code Climate](https://codeclimate.com/github/ioquatix/ffi-clang.png)](https://codeclimate.com/github/ioquatix/ffi-clang)
5
+ [![Build Status](https://secure.travis-ci.org/ioquatix/ffi-clang.svg)](http://travis-ci.org/ioquatix/ffi-clang)
6
+ [![Code Climate](https://codeclimate.com/github/ioquatix/ffi-clang.svg)](https://codeclimate.com/github/ioquatix/ffi-clang)
7
7
 
8
8
  [1]: http://llvm.org/devmtg/2010-11/Gregor-libclang.pdf
9
9
 
@@ -158,6 +158,10 @@ module FFI
158
158
  Type.new Lib.get_enum_decl_integer_type(@cursor), @translation_unit
159
159
  end
160
160
 
161
+ def typedef_type
162
+ Type.new Lib.get_typedef_decl_unerlying_type(@cursor), @translation_unit
163
+ end
164
+
161
165
  def virtual_base?
162
166
  Lib.is_virtual_base(@cursor) != 0
163
167
  end
@@ -194,6 +198,10 @@ module FFI
194
198
  Lib.get_enum_unsigned_value @cursor
195
199
  end
196
200
 
201
+ def enum_type
202
+ Type.new Lib.get_enum_type(@cursor), @translation_unit
203
+ end
204
+
197
205
  def specialized_template
198
206
  Cursor.new Lib.get_specialized_cursor_template(@cursor), @translation_unit
199
207
  end
@@ -234,6 +242,14 @@ module FFI
234
242
  @translation_unit
235
243
  end
236
244
 
245
+ def num_args
246
+ Lib.get_num_args @cursor
247
+ end
248
+
249
+ def variadic?
250
+ Lib.is_variadic(@cursor) != 0
251
+ end
252
+
237
253
  def visit_children(&block)
238
254
  adapter = Proc.new do |cxcursor, parent_cursor, unused|
239
255
  block.call Cursor.new(cxcursor, @translation_unit), Cursor.new(parent_cursor, @translation_unit)
@@ -19,17 +19,35 @@
19
19
  # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
20
20
  # THE SOFTWARE.
21
21
 
22
+ require 'mkmf'
23
+
22
24
  module FFI
23
25
  module Clang
24
26
  module Lib
25
27
  extend FFI::Library
28
+
29
+ # Use LLVM_CONFIG if it was explicitly specified:
30
+ llvm_config = ENV['LLVM_CONFIG']
31
+
32
+ # If we aren't building for a specific version (e.g. travis) try to find llvm-config
33
+ unless ENV['LLVM_VERSION']
34
+ llvm_config ||= MakeMakefile.find_executable0("llvm-config")
35
+ end
36
+
37
+ libs = []
38
+ begin
39
+ xcode_dir = `xcode-select -p`.chomp
40
+ libs << "#{xcode_dir}/Toolchains/XcodeDefault.xctoolchain/usr/lib/libclang.dylib"
41
+ rescue Errno::ENOENT => e
42
+ # Ignore
43
+ end
26
44
 
27
- libs = ["clang"]
45
+ libs << "clang"
28
46
 
29
47
  if ENV['LIBCLANG']
30
48
  libs << ENV['LIBCLANG']
31
- elsif ENV['LLVM_CONFIG']
32
- llvm_library_dir = `#{ENV['LLVM_CONFIG']} --libdir`.chomp
49
+ elsif llvm_config
50
+ llvm_library_dir = `#{llvm_config} --libdir`.chomp
33
51
 
34
52
  if FFI::Clang.platform == :darwin
35
53
  libs << llvm_library_dir + '/libclang.dylib'
@@ -348,6 +348,15 @@ module FFI
348
348
 
349
349
  attach_function :get_overridden_cursors, :clang_getOverriddenCursors, [CXCursor.by_value, :pointer, :pointer], :void
350
350
  attach_function :dispose_overridden_cursors, :clang_disposeOverriddenCursors, [:pointer], :void
351
+
352
+ attach_function :get_typedef_decl_unerlying_type, :clang_getTypedefDeclUnderlyingType, [CXCursor.by_value], CXType.by_value
353
+ attach_function :get_type_declaration, :clang_getTypeDeclaration, [CXType.by_value], CXCursor.by_value
354
+
355
+ attach_function :get_enum_type, :clang_getEnumDeclIntegerType, [CXCursor.by_value], CXType.by_value
356
+
357
+ attach_function :get_num_args, :clang_Cursor_getNumArguments, [CXCursor.by_value], :int
358
+
359
+ attach_function :is_variadic, :clang_Cursor_isVariadic, [CXCursor.by_value], :uint
351
360
  end
352
361
  end
353
362
  end
@@ -149,6 +149,9 @@ module FFI
149
149
  attach_function :get_fuction_type_calling_conv, :clang_getFunctionTypeCallingConv, [CXType.by_value], :calling_conv
150
150
 
151
151
  attach_function :equal_types, :clang_equalTypes, [CXType.by_value, CXType.by_value], :uint
152
+
153
+ attach_function :get_array_element_type, :clang_getArrayElementType, [CXType.by_value], CXType.by_value
154
+ attach_function :get_array_size, :clang_getArraySize, [CXType.by_value], :int
152
155
  end
153
156
  end
154
157
  end
@@ -130,6 +130,18 @@ module FFI
130
130
  def ==(other)
131
131
  Lib.equal_types(@type, other.type) != 0
132
132
  end
133
+
134
+ def declaration
135
+ Cursor.new Lib.get_type_declaration(@type), @translation_unit
136
+ end
137
+
138
+ def element_type
139
+ Type.new Lib.get_array_element_type(@type), @translation_unit
140
+ end
141
+
142
+ def array_size
143
+ Lib.get_array_size(@type)
144
+ end
133
145
  end
134
146
  end
135
147
  end
@@ -35,10 +35,14 @@ module FFI
35
35
  unless @@clang_version
36
36
  # Version string vary wildy:
37
37
  # Ubuntu: "Ubuntu clang version 3.0-6ubuntu3 (tags/RELEASE_30/final) (based on LLVM 3.0)"
38
- # Mac OS X: "Apple LLVM version 5.0 (clang-500.2.79) (based on LLVM 3.3svn)"
38
+ # Mac OS X: "Apple LLVM version 7.0.0 (clang-700.0.72)"
39
39
  # Linux: "clang version 3.3"
40
-
41
- if parts = clang_version_string.match(/(?:clang version|based on LLVM) (\d+)\.(\d+)(svn)?/)
40
+ if parts = clang_version_string.match(/^Apple LLVM version (\d+)\.(\d+).\d \(clang-.*\)$/)
41
+ @@clang_version = [3, 7] # Fake it.
42
+
43
+ puts "Using libclang: #{Lib::ffi_libraries[0].name}"
44
+ puts "Clang version detected: #{@@clang_version.inspect}"
45
+ elsif parts = clang_version_string.match(/(?:clang version|based on LLVM) (\d+)\.(\d+)(svn)?/)
42
46
  major = parts[1].to_i
43
47
  minor = parts[2].to_i
44
48
  rc = parts[3]
@@ -50,6 +54,7 @@ module FFI
50
54
 
51
55
  @@clang_version = [major, minor]
52
56
 
57
+ puts "Using libclang: #{Lib::ffi_libraries[0].name}"
53
58
  puts "Clang version detected: #{@@clang_version.inspect}"
54
59
  else
55
60
  abort "Invalid/unsupported clang version string."
@@ -21,6 +21,6 @@
21
21
 
22
22
  module FFI
23
23
  module Clang
24
- VERSION = "0.2.1"
24
+ VERSION = "0.3.0"
25
25
  end
26
26
  end
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.2.1
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jari Bakken
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2014-06-23 00:00:00.000000000 Z
12
+ date: 2016-02-04 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: ffi
@@ -161,7 +161,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
161
161
  version: '0'
162
162
  requirements: []
163
163
  rubyforge_project:
164
- rubygems_version: 2.2.2
164
+ rubygems_version: 2.5.1
165
165
  signing_key:
166
166
  specification_version: 4
167
167
  summary: Ruby FFI bindings for libclang C interface.