ffi-clang 0.6.0 → 0.8.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (77) hide show
  1. checksums.yaml +4 -4
  2. checksums.yaml.gz.sig +4 -0
  3. data/ext/rakefile.rb +4 -0
  4. data/ext/teapot.rb +4 -3
  5. data/lib/ffi/clang/clang_version.rb +9 -19
  6. data/lib/ffi/clang/code_completion.rb +4 -18
  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 +92 -25
  10. data/lib/ffi/clang/diagnostic.rb +8 -21
  11. data/lib/ffi/clang/file.rb +4 -18
  12. data/lib/ffi/clang/index.rb +9 -20
  13. data/lib/ffi/clang/lib/clang_version.rb +5 -19
  14. data/lib/ffi/clang/lib/code_completion.rb +4 -18
  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 +185 -41
  18. data/lib/ffi/clang/lib/diagnostic.rb +8 -28
  19. data/lib/ffi/clang/lib/file.rb +5 -20
  20. data/lib/ffi/clang/lib/inclusions.rb +5 -19
  21. data/lib/ffi/clang/lib/index.rb +6 -20
  22. data/lib/ffi/clang/lib/source_location.rb +5 -20
  23. data/lib/ffi/clang/lib/source_range.rb +5 -22
  24. data/lib/ffi/clang/lib/string.rb +6 -20
  25. data/lib/ffi/clang/lib/token.rb +4 -18
  26. data/lib/ffi/clang/lib/translation_unit.rb +7 -21
  27. data/lib/ffi/clang/lib/type.rb +8 -20
  28. data/lib/ffi/clang/lib.rb +31 -23
  29. data/lib/ffi/clang/source_location.rb +7 -20
  30. data/lib/ffi/clang/source_range.rb +7 -22
  31. data/lib/ffi/clang/token.rb +4 -18
  32. data/lib/ffi/clang/translation_unit.rb +17 -23
  33. data/lib/ffi/clang/type.rb +7 -19
  34. data/lib/ffi/clang/unsaved_file.rb +6 -20
  35. data/lib/ffi/clang/version.rb +7 -21
  36. data/lib/ffi/clang.rb +9 -20
  37. data/license.md +38 -0
  38. data/readme.md +46 -0
  39. data.tar.gz.sig +0 -0
  40. metadata +78 -81
  41. metadata.gz.sig +2 -0
  42. data/.gitignore +0 -19
  43. data/.rspec +0 -5
  44. data/.travis.yml +0 -30
  45. data/Gemfile +0 -13
  46. data/README.md +0 -74
  47. data/Rakefile +0 -12
  48. data/examples/docs.cpp +0 -25
  49. data/examples/docs.rb +0 -31
  50. data/ffi-clang.gemspec +0 -26
  51. data/spec/ffi/clang/code_completion_spec.rb +0 -181
  52. data/spec/ffi/clang/comment_spec.rb +0 -453
  53. data/spec/ffi/clang/compilation_database_spec.rb +0 -176
  54. data/spec/ffi/clang/cursor_spec.rb +0 -701
  55. data/spec/ffi/clang/diagnostic_spec.rb +0 -89
  56. data/spec/ffi/clang/file_spec.rb +0 -82
  57. data/spec/ffi/clang/fixtures/a.c +0 -7
  58. data/spec/ffi/clang/fixtures/canonical.c +0 -5
  59. data/spec/ffi/clang/fixtures/class.cpp +0 -8
  60. data/spec/ffi/clang/fixtures/compile_commands.json +0 -17
  61. data/spec/ffi/clang/fixtures/completion.cxx +0 -8
  62. data/spec/ffi/clang/fixtures/docs.c +0 -1
  63. data/spec/ffi/clang/fixtures/docs.cc +0 -1
  64. data/spec/ffi/clang/fixtures/docs.h +0 -54
  65. data/spec/ffi/clang/fixtures/list.c +0 -11
  66. data/spec/ffi/clang/fixtures/location1.c +0 -7
  67. data/spec/ffi/clang/fixtures/simple.ast +0 -0
  68. data/spec/ffi/clang/fixtures/simple.c +0 -3
  69. data/spec/ffi/clang/fixtures/test.cxx +0 -62
  70. data/spec/ffi/clang/index_spec.rb +0 -90
  71. data/spec/ffi/clang/source_location_spec.rb +0 -138
  72. data/spec/ffi/clang/source_range_spec.rb +0 -74
  73. data/spec/ffi/clang/token_spec.rb +0 -82
  74. data/spec/ffi/clang/translation_unit_spec.rb +0 -214
  75. data/spec/ffi/clang/type_spec.rb +0 -273
  76. data/spec/ffi/clang/version_spec.rb +0 -28
  77. data/spec/spec_helper.rb +0 -51
metadata.gz.sig ADDED
@@ -0,0 +1,2 @@
1
+ KD ��!��F�p������D�� ަޚ�Q�� v�?��^��ڧ��
2
+ ����SJ���w��12�Dz�\AfUG��Қ$���/Lc�{�;�D��J3gX)��z١�m��U��`��'�TN���d}��"�M��MB Uj��ལ�
data/.gitignore DELETED
@@ -1,19 +0,0 @@
1
- *.gem
2
- *.rbc
3
- .bundle
4
- .config
5
- .yardoc
6
- Gemfile.lock
7
- InstalledFiles
8
- _yardoc
9
- coverage
10
- doc/
11
- lib/bundler/man
12
- pkg
13
- rdoc
14
- spec/reports
15
- test/tmp
16
- test/version_tmp
17
- tmp
18
-
19
- .rspec_status
data/.rspec DELETED
@@ -1,5 +0,0 @@
1
- --color
2
- --format documentation
3
- --backtrace
4
- --warnings
5
- --require spec_helper
data/.travis.yml DELETED
@@ -1,30 +0,0 @@
1
- language: ruby
2
- sudo: false
3
- before_install:
4
- - export LD_LIBRARY_PATH=/usr/lib/llvm-${LLVM_VERSION}/lib/
5
- - export PATH=/usr/lib/llvm-${LLVM_VERSION}/bin:$PATH
6
- matrix:
7
- include:
8
- - addons: {apt: {sources: [ubuntu-toolchain-r-test, llvm-toolchain-precise-3.6], packages: [libclang-3.6-dev, clang-3.6]}}
9
- env: LLVM_VERSION=3.6
10
- rvm: "2.4.0"
11
- - addons: {apt: {sources: [ubuntu-toolchain-r-test, llvm-toolchain-precise-3.7], packages: [libclang-3.7-dev, clang-3.7]}}
12
- env: LLVM_VERSION=3.7
13
- rvm: "2.4.0"
14
- # The default build:
15
- - &libclang-38
16
- addons: {apt: {sources: [ubuntu-toolchain-r-test, llvm-toolchain-precise-3.8], packages: [libclang-3.8-dev, clang-3.8]}}
17
- env: LLVM_VERSION=3.8
18
- rvm: "2.4.0"
19
- # A second build with the same configuration but using ruby 2.2.4
20
- - <<: *libclang-38
21
- rvm: "2.3.3"
22
- - addons: {apt: {sources: [ubuntu-toolchain-r-test, llvm-toolchain-precise-3.9], packages: [libclang-3.9-dev, clang-3.9]}}
23
- env: LLVM_VERSION=3.9
24
- rvm: "2.4.0"
25
- - addons: {apt: {sources: [ubuntu-toolchain-r-test, llvm-toolchain-precise-4.0], packages: [libclang-4.0-dev, clang-4.0]}}
26
- env: LLVM_VERSION=4.0
27
- rvm: "2.4.0"
28
- allow_failures:
29
- - env: LLVM_VERSION=4.0
30
- rvm: "2.4.0"
data/Gemfile DELETED
@@ -1,13 +0,0 @@
1
- source 'https://rubygems.org'
2
-
3
- gemspec
4
-
5
- group :development do
6
- gem 'transpec'
7
- gem 'pry'
8
- end
9
-
10
- group :test do
11
- gem 'simplecov'
12
- gem 'coveralls', require: false
13
- end
data/README.md DELETED
@@ -1,74 +0,0 @@
1
- # FFI::Clang
2
-
3
- A light-weight wrapper for Ruby exposing [libclang][1]. Works for libclang v3.4+.
4
-
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
-
8
- [1]: http://llvm.org/devmtg/2010-11/Gregor-libclang.pdf
9
-
10
- ## Installation
11
-
12
- Add this line to your application's Gemfile:
13
-
14
- gem 'ffi-clang'
15
-
16
- And then execute:
17
-
18
- $ bundle
19
-
20
- Or install it yourself as:
21
-
22
- $ gem install ffi-clang
23
-
24
- ## Usage
25
-
26
- Traverse the AST in the given file:
27
-
28
- index = Index.new
29
- translation_unit = index.parse_translation_unit("list.c")
30
- cursor = translation_unit.cursor
31
- cursor.visit_children do |cursor, parent|
32
- puts "#{cursor.kind} #{cursor.spelling.inspect}"
33
-
34
- next :recurse
35
- end
36
-
37
- ### Library Version
38
-
39
- Due to issues figuring out which library to use, we require you to manually specify it. For example, to run the tests, with MacPorts llvm/clang 3.4, use the following:
40
-
41
- LLVM_CONFIG=llvm-config-mp-3.4 rake
42
-
43
- ## Contributing
44
-
45
- 1. Fork it
46
- 2. Create your feature branch (`git checkout -b my-new-feature`)
47
- 3. Commit your changes (`git commit -am 'Add some feature'`)
48
- 4. Push to the branch (`git push origin my-new-feature`)
49
- 5. Create new Pull Request
50
-
51
- ## License
52
-
53
- Copyright, 2010-2012, by Jari Bakken.
54
- Copyright, 2013, by Samuel G. D. Williams. <http://www.codeotaku.com>
55
- Copyright, 2013, by Garry C. Marshall. <http://www.meaningfulname.net>
56
- Copyright, 2014, by Masahiro Sano.
57
-
58
- Permission is hereby granted, free of charge, to any person obtaining a copy
59
- of this software and associated documentation files (the "Software"), to deal
60
- in the Software without restriction, including without limitation the rights
61
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
62
- copies of the Software, and to permit persons to whom the Software is
63
- furnished to do so, subject to the following conditions:
64
-
65
- The above copyright notice and this permission notice shall be included in
66
- all copies or substantial portions of the Software.
67
-
68
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
69
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
70
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
71
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
72
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
73
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
74
- THE SOFTWARE.
data/Rakefile DELETED
@@ -1,12 +0,0 @@
1
- require "bundler/gem_tasks"
2
- require "rspec/core/rake_task"
3
-
4
- RSpec::Core::RakeTask.new(:spec) do |task|
5
- begin
6
- require('simplecov/version')
7
- task.rspec_opts = %w{--require simplecov} if ENV['COVERAGE']
8
- rescue LoadError
9
- end
10
- end
11
-
12
- task :default => :spec
data/examples/docs.cpp DELETED
@@ -1,25 +0,0 @@
1
-
2
- /** A test class which does nothing.
3
-
4
- This is used by `main`.
5
- */
6
- template<typename T>
7
- class Test {};
8
-
9
- /// This is a specialization for integers.
10
- template<>
11
- class Test<int> {
12
- public:
13
- /// The number of times it has been incremented.
14
- int count;
15
-
16
- };
17
-
18
- /// This always fails.
19
- /// @param argc The number of items in `argv`. At least 1.
20
- /// @param argv The command line arguments, with argv[0] being the command used to execute this program.
21
- int main(int argc, char ** argv) {
22
- Test<int> test;
23
-
24
- return 1;
25
- }
data/examples/docs.rb DELETED
@@ -1,31 +0,0 @@
1
- #!/usr/bin/env ruby
2
-
3
- require 'rainbow'
4
- require 'ffi/clang'
5
-
6
- index = FFI::Clang::Index.new
7
-
8
- # clang -Xclang -ast-dump -fsyntax-only ./examples/docs.cpp
9
-
10
- def title(declaration)
11
- puts ["Symbol:", Rainbow(declaration.spelling).blue.bright, "Type:", Rainbow(declaration.type.spelling).green, declaration.kind.to_s].join(' ')
12
- end
13
-
14
- ARGV.each do |path|
15
- translation_unit = index.parse_translation_unit(path)
16
-
17
- declarations = translation_unit.cursor.select(&:declaration?)
18
-
19
- declarations.each do |declaration|
20
- title declaration
21
-
22
- if location = declaration.location
23
- puts "Defined at #{location.file}:#{location.line}"
24
- end
25
-
26
- if comment = declaration.comment
27
- # puts Rainbow(comment.inspect).gray
28
- puts Rainbow(comment.text)
29
- end
30
- end
31
- end
data/ffi-clang.gemspec DELETED
@@ -1,26 +0,0 @@
1
- # coding: utf-8
2
- lib = File.expand_path('../lib', __FILE__)
3
- $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
- require 'ffi/clang/version'
5
-
6
- Gem::Specification.new do |spec|
7
- spec.name = "ffi-clang"
8
- spec.version = FFI::Clang::VERSION
9
- spec.authors = ["Jari Bakken", "Samuel Williams"]
10
- spec.email = ["Jari Bakken", "samuel.williams@oriontransfer.co.nz"]
11
- spec.description = %q{Ruby FFI bindings for libclang C interface.}
12
- spec.summary = %q{Ruby FFI bindings for libclang C interface.}
13
- spec.homepage = ""
14
- spec.license = "MIT"
15
-
16
- spec.files = `git ls-files`.split($/)
17
- spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
- spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
- spec.require_paths = ["lib"]
20
-
21
- spec.add_dependency "ffi"
22
-
23
- spec.add_development_dependency "bundler", "~> 1.3"
24
- spec.add_development_dependency "rspec", "~> 3.4.0"
25
- spec.add_development_dependency "rake"
26
- end
@@ -1,181 +0,0 @@
1
- # 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.
20
-
21
- describe CodeCompletion do
22
- let(:filename) { fixture_path("completion.cxx") }
23
- let(:translation_unit) { Index.new.parse_translation_unit(filename) }
24
- let(:line) { 7 }
25
- let(:column) { 6 }
26
- let(:results) { translation_unit.code_complete(filename, line, column) }
27
-
28
- describe "self.default_code_completion_options" do
29
- let(:options) { FFI::Clang::CodeCompletion.default_code_completion_options }
30
- it "returns a default set of code-completion options" do
31
- expect(options).to be_kind_of(Hash)
32
- options.keys.each { |key|
33
- expect(FFI::Clang::Lib::CodeCompleteFlags.symbols).to include(key)
34
- }
35
- end
36
- end
37
-
38
- describe CodeCompletion::Results do
39
- it "can be obtained from a translation unit" do
40
- expect(results).to be_kind_of(CodeCompletion::Results)
41
-
42
- # At least 40 results, depends on standard library implementation:
43
- expect(results.size).to be >= 40
44
-
45
- expect(results.results).to be_kind_of(Array)
46
- expect(results.results.first).to be_kind_of(CodeCompletion::Result)
47
- end
48
-
49
- it "calls dispose_code_complete_results on GC" do
50
- expect(Lib).to receive(:dispose_code_complete_results).at_least(:once)
51
- expect{results.free}.not_to raise_error
52
- end
53
-
54
- it "#each" do
55
- spy = double(stub: nil)
56
- expect(spy).to receive(:stub).exactly(results.size).times
57
- results.each { spy.stub }
58
- end
59
-
60
- it "#num_diagnostics" do
61
- expect(results.num_diagnostics).to eq(2)
62
- end
63
-
64
- it "#diagnostic" do
65
- expect(results.diagnostic(0)).to be_kind_of(Diagnostic)
66
- end
67
-
68
- it "#diagnostics" do
69
- expect(results.diagnostics).to be_kind_of(Array)
70
- expect(results.diagnostics.first).to be_kind_of(Diagnostic)
71
- expect(results.diagnostics.size).to eq(results.num_diagnostics)
72
- end
73
-
74
- it "#contexts" do
75
- expect(results.contexts).to be_kind_of(Hash)
76
- results.contexts.keys.each { |key|
77
- expect(FFI::Clang::Lib::CompletionContext.symbols).to include(key)
78
- }
79
- end
80
-
81
- it "#container_usr" do
82
- expect(results.container_usr).to be_kind_of(String)
83
- expect(results.container_usr).to match(/std.+vector/)
84
- end
85
-
86
- it "#container_kind" do
87
- expect(results.container_kind).to be_kind_of(Symbol)
88
- expect(results.container_kind).to eq(:cursor_class_decl)
89
- end
90
-
91
- it "#incomplete?" do
92
- expect(results.incomplete?).to be false
93
- end
94
-
95
- it "#objc_selector" do
96
- #TODO
97
- end
98
-
99
- it "#sort!" do
100
- results.sort!
101
-
102
- possibilities = results.first.string.chunks.select{|x| x[:kind] == :typed_text}.collect{|chunk| chunk[:text]}
103
-
104
- # may be sorted with typed_text kind, first result will start with 'a'.. not necessarily
105
- expect(possibilities).to be == possibilities.sort
106
- end
107
- end
108
-
109
- describe CodeCompletion::Result do
110
- let(:result) { results.results.first }
111
- it "#string" do
112
- expect(result.string).to be_kind_of(CodeCompletion::String)
113
- end
114
-
115
- it "#kind" do
116
- expect(result.kind).to be_kind_of(Symbol)
117
- end
118
- end
119
-
120
- describe CodeCompletion::String do
121
- let(:str) { results.sort!; results.find{|x| x.string.chunk_text(1) == 'assign'}.string }
122
-
123
- it "#num_chunks" do
124
- expect(str.num_chunks).to be >= 5
125
- end
126
-
127
- it "#chunk_kind" do
128
- expect(str.chunk_kind(0)).to eq(:result_type)
129
- expect(str.chunk_kind(1)).to eq(:typed_text)
130
- end
131
-
132
- it "#chunk_text" do
133
- expect(str.chunk_text(0)).to be =~ /void/
134
- expect(str.chunk_text(1)).to eq('assign')
135
- end
136
-
137
- it "#chunk_completion" do
138
- expect(str.chunk_completion(0)).to be_kind_of(CodeCompletion::String)
139
- end
140
-
141
- it "#chunks" do
142
- expect(str.chunks).to be_kind_of(Array)
143
- expect(str.chunks.first).to be_kind_of(Hash)
144
- expect(str.chunks.size).to eq(str.num_chunks)
145
- end
146
-
147
- it "#priority" do
148
- expect(str.priority).to be_kind_of(Integer)
149
- end
150
-
151
- it "#availability" do
152
- expect(str.availability).to be_kind_of(Symbol)
153
- expect(str.availability).to eq(:available)
154
- end
155
-
156
- it "#num_annotations" do
157
- expect(str.num_annotations).to be_kind_of(Integer)
158
- expect(str.num_annotations).to eq(0)
159
- end
160
-
161
- it "#annotation" do
162
- expect(str.annotation(100)).to be_nil
163
- # TODO: need tests for String which has annotation
164
- end
165
-
166
- it "#annotations" do
167
- expect(str.annotations).to be_kind_of(Array)
168
- # TODO: need tests for String which has annotation
169
- end
170
-
171
- it "#parent" do
172
- expect(str.parent).to be_kind_of(String)
173
- expect(str.parent).to be =~ /std.+vector/
174
- end
175
-
176
- it "#comment" do
177
- expect(str.comment).to be_nil
178
- # TODO: need tests for String which has real comment
179
- end
180
- end
181
- end