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 +4 -4
- data/.travis.yml +15 -18
- data/README.md +3 -3
- data/lib/ffi/clang/cursor.rb +16 -0
- data/lib/ffi/clang/lib.rb +21 -3
- data/lib/ffi/clang/lib/cursor.rb +9 -0
- data/lib/ffi/clang/lib/type.rb +3 -0
- data/lib/ffi/clang/type.rb +12 -0
- data/lib/ffi/clang/utils.rb +8 -3
- data/lib/ffi/clang/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d482ffe964ca4f9817152f6fd3da834657851673
|
4
|
+
data.tar.gz: 405d56c4688d22790a36b7406ff8e0cffc924d1e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f64cf1ee129eddde74597bd12a69dfa93c0eacfd5fd1cea9795dc51fa0915738bca97d4f88e4375fff714bc26c1ed23a434a52ea645c44667e9b3956a86f7d7b
|
7
|
+
data.tar.gz: 8895a0b39bc1ba92c4e5a799b736ee574254c925eabbaf89d30079664a75df6dd1546a23f5e5b3f545cb6929e0239ed1b0d7b9661ece208570e1512b8d3ebdb4
|
data/.travis.yml
CHANGED
@@ -1,22 +1,19 @@
|
|
1
1
|
language: ruby
|
2
|
-
|
3
|
-
|
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
|
-
|
22
|
-
|
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
|
3
|
+
A light-weight wrapper for Ruby exposing [libclang][1].
|
4
4
|
|
5
|
-
[](http://travis-ci.org/ioquatix/ffi-clang)
|
6
|
+
[](https://codeclimate.com/github/ioquatix/ffi-clang)
|
7
7
|
|
8
8
|
[1]: http://llvm.org/devmtg/2010-11/Gregor-libclang.pdf
|
9
9
|
|
data/lib/ffi/clang/cursor.rb
CHANGED
@@ -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)
|
data/lib/ffi/clang/lib.rb
CHANGED
@@ -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
|
45
|
+
libs << "clang"
|
28
46
|
|
29
47
|
if ENV['LIBCLANG']
|
30
48
|
libs << ENV['LIBCLANG']
|
31
|
-
elsif
|
32
|
-
llvm_library_dir = `#{
|
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'
|
data/lib/ffi/clang/lib/cursor.rb
CHANGED
@@ -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
|
data/lib/ffi/clang/lib/type.rb
CHANGED
@@ -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
|
data/lib/ffi/clang/type.rb
CHANGED
@@ -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
|
data/lib/ffi/clang/utils.rb
CHANGED
@@ -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
|
38
|
+
# Mac OS X: "Apple LLVM version 7.0.0 (clang-700.0.72)"
|
39
39
|
# Linux: "clang version 3.3"
|
40
|
-
|
41
|
-
|
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."
|
data/lib/ffi/clang/version.rb
CHANGED
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.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:
|
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.
|
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.
|