ffi-clang 0.7.0 → 0.9.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +3 -0
- data/ext/rakefile.rb +4 -0
- data/ext/teapot.rb +4 -3
- data/lib/ffi/clang/clang_version.rb +10 -19
- data/lib/ffi/clang/code_completion.rb +8 -20
- data/lib/ffi/clang/comment.rb +7 -19
- data/lib/ffi/clang/compilation_database.rb +4 -18
- data/lib/ffi/clang/cursor.rb +117 -35
- data/lib/ffi/clang/diagnostic.rb +11 -23
- data/lib/ffi/clang/file.rb +4 -18
- data/lib/ffi/clang/index.rb +19 -23
- data/lib/ffi/clang/lib/clang_version.rb +5 -19
- data/lib/ffi/clang/lib/code_completion.rb +13 -26
- data/lib/ffi/clang/lib/comment.rb +7 -20
- data/lib/ffi/clang/lib/compilation_database.rb +4 -18
- data/lib/ffi/clang/lib/cursor.rb +102 -28
- data/lib/ffi/clang/lib/diagnostic.rb +7 -20
- data/lib/ffi/clang/lib/file.rb +7 -20
- data/lib/ffi/clang/lib/inclusions.rb +5 -19
- data/lib/ffi/clang/lib/index.rb +25 -20
- data/lib/ffi/clang/lib/printing_policy.rb +47 -0
- data/lib/ffi/clang/lib/source_location.rb +5 -20
- data/lib/ffi/clang/lib/source_range.rb +5 -22
- data/lib/ffi/clang/lib/string.rb +4 -20
- data/lib/ffi/clang/lib/token.rb +4 -18
- data/lib/ffi/clang/lib/translation_unit.rb +19 -21
- data/lib/ffi/clang/lib/type.rb +87 -22
- data/lib/ffi/clang/lib.rb +24 -28
- data/lib/ffi/clang/printing_policy.rb +36 -0
- data/lib/ffi/clang/source_location.rb +42 -38
- data/lib/ffi/clang/source_range.rb +7 -22
- data/lib/ffi/clang/token.rb +4 -18
- data/lib/ffi/clang/translation_unit.rb +10 -20
- data/lib/ffi/clang/type.rb +52 -25
- data/lib/ffi/clang/unsaved_file.rb +6 -20
- data/lib/ffi/clang/version.rb +7 -21
- data/lib/ffi/clang.rb +9 -20
- data/license.md +39 -0
- data/readme.md +56 -0
- data.tar.gz.sig +0 -0
- metadata +62 -116
- metadata.gz.sig +0 -0
- data/.editorconfig +0 -23
- data/.gitignore +0 -19
- data/.rspec +0 -5
- data/.travis.yml +0 -30
- data/Gemfile +0 -12
- data/README.md +0 -74
- data/Rakefile +0 -12
- data/examples/docs.cpp +0 -25
- data/examples/docs.rb +0 -31
- data/ffi-clang.gemspec +0 -25
- data/spec/ffi/clang/code_completion_spec.rb +0 -181
- data/spec/ffi/clang/comment_spec.rb +0 -453
- data/spec/ffi/clang/compilation_database_spec.rb +0 -180
- data/spec/ffi/clang/cursor_spec.rb +0 -741
- data/spec/ffi/clang/diagnostic_spec.rb +0 -89
- data/spec/ffi/clang/file_spec.rb +0 -82
- data/spec/ffi/clang/fixtures/a.c +0 -7
- data/spec/ffi/clang/fixtures/canonical.c +0 -5
- data/spec/ffi/clang/fixtures/class.cpp +0 -8
- data/spec/ffi/clang/fixtures/compile_commands.json +0 -17
- data/spec/ffi/clang/fixtures/completion.cxx +0 -8
- data/spec/ffi/clang/fixtures/docs.c +0 -1
- data/spec/ffi/clang/fixtures/docs.cc +0 -1
- data/spec/ffi/clang/fixtures/docs.h +0 -54
- data/spec/ffi/clang/fixtures/list.c +0 -11
- data/spec/ffi/clang/fixtures/location1.c +0 -7
- data/spec/ffi/clang/fixtures/simple.ast +0 -0
- data/spec/ffi/clang/fixtures/simple.c +0 -3
- data/spec/ffi/clang/fixtures/test.cxx +0 -62
- data/spec/ffi/clang/index_spec.rb +0 -90
- data/spec/ffi/clang/source_location_spec.rb +0 -138
- data/spec/ffi/clang/source_range_spec.rb +0 -74
- data/spec/ffi/clang/token_spec.rb +0 -82
- data/spec/ffi/clang/translation_unit_spec.rb +0 -220
- data/spec/ffi/clang/type_spec.rb +0 -273
- data/spec/ffi/clang/version_spec.rb +0 -28
- data/spec/spec_helper.rb +0 -51
@@ -1,180 +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 CompilationDatabase do
|
22
|
-
let(:dirpath) { fixture_path('') }
|
23
|
-
let(:cdb) { CompilationDatabase.new(dirpath) }
|
24
|
-
let(:file) { '/home/xxxxx/src/llvm-trunk/lib/Support/APFloat.cpp' }
|
25
|
-
|
26
|
-
it "can be created" do
|
27
|
-
expect(cdb).to be_kind_of(CompilationDatabase)
|
28
|
-
end
|
29
|
-
|
30
|
-
it "raises DatabaseLoadError if cannot be created" do
|
31
|
-
expect{CompilationDatabase.new('/not/exist/directory')}.to raise_error FFI::Clang::CompilationDatabase::DatabaseLoadError
|
32
|
-
end
|
33
|
-
|
34
|
-
it "calls compilation_database_dispose on GC" do
|
35
|
-
cdb.autorelease = false
|
36
|
-
# expect(Lib).to receive(:compilation_database_dispose).with(cdb).once
|
37
|
-
expect{cdb.free}.not_to raise_error
|
38
|
-
end
|
39
|
-
|
40
|
-
describe '#compile_commands' do
|
41
|
-
let(:not_found_file) { '/home/xxxxx/not_found_file_path' }
|
42
|
-
|
43
|
-
it "returns compile commands used for a file" do
|
44
|
-
expect(cdb.compile_commands(file)).to be_kind_of(CompilationDatabase::CompileCommands)
|
45
|
-
expect(cdb.compile_commands(file).size).to eq(1)
|
46
|
-
end
|
47
|
-
|
48
|
-
it "returns compile commands if the specified file is not found" do
|
49
|
-
expect(cdb.compile_commands(not_found_file)).to be_kind_of(CompilationDatabase::CompileCommands)
|
50
|
-
if FFI::Clang.clang_version_string[/\d+/].to_i >= 10
|
51
|
-
expect(cdb.compile_commands(not_found_file).size).to eq(1)
|
52
|
-
else
|
53
|
-
expect(cdb.compile_commands(not_found_file).size).to eq(0)
|
54
|
-
end
|
55
|
-
end
|
56
|
-
end
|
57
|
-
|
58
|
-
describe '#all_compile_commands' do
|
59
|
-
it "returns all compile commands in the database" do
|
60
|
-
expect(cdb.all_compile_commands).to be_kind_of(CompilationDatabase::CompileCommands)
|
61
|
-
expect(cdb.all_compile_commands.size).to eq(3)
|
62
|
-
end
|
63
|
-
end
|
64
|
-
|
65
|
-
describe CompilationDatabase::CompileCommands do
|
66
|
-
let(:commands) { cdb.compile_commands(file) }
|
67
|
-
|
68
|
-
it "calls compile_commands_dispose on GC" do
|
69
|
-
commands.autorelease = false
|
70
|
-
# expect(Lib).to receive(:compile_commands_dispose).with(commands).once
|
71
|
-
expect{commands.free}.not_to raise_error
|
72
|
-
end
|
73
|
-
|
74
|
-
describe '#size' do
|
75
|
-
it "returns the number of CompileCommand" do
|
76
|
-
expect(commands.size).to be_kind_of(Integer)
|
77
|
-
expect(commands.size).to eq(1)
|
78
|
-
end
|
79
|
-
|
80
|
-
it "returns the number of CompileCommand" do
|
81
|
-
expect(cdb.all_compile_commands.size).to eq(3)
|
82
|
-
end
|
83
|
-
end
|
84
|
-
|
85
|
-
describe '#command' do
|
86
|
-
it "returns the I'th CompileCommand" do
|
87
|
-
expect(commands.command(0)).to be_kind_of(CompilationDatabase::CompileCommand)
|
88
|
-
end
|
89
|
-
end
|
90
|
-
|
91
|
-
describe "#commands" do
|
92
|
-
it "returns all CompileCommand as Array" do
|
93
|
-
expect(commands.commands).to be_kind_of(Array)
|
94
|
-
expect(commands.commands.first).to be_kind_of(CompilationDatabase::CompileCommand)
|
95
|
-
expect(commands.commands.size).to eq(commands.size)
|
96
|
-
end
|
97
|
-
end
|
98
|
-
|
99
|
-
describe "#each" do
|
100
|
-
let(:spy) { double(stub: nil) }
|
101
|
-
it "calls block once for each CompileCommand" do
|
102
|
-
expect(spy).to receive(:stub).exactly(commands.size).times
|
103
|
-
commands.each { spy.stub }
|
104
|
-
end
|
105
|
-
end
|
106
|
-
end
|
107
|
-
|
108
|
-
describe CompilationDatabase::CompileCommand do
|
109
|
-
let(:cmd) { cdb.compile_commands(file).first }
|
110
|
-
|
111
|
-
describe '#directory' do
|
112
|
-
it "returns the working directory" do
|
113
|
-
expect(cmd.directory).to be_kind_of(String)
|
114
|
-
expect(cmd.directory).to eq('/home/xxxxx/src/build-trunk/lib/Support')
|
115
|
-
end
|
116
|
-
end
|
117
|
-
|
118
|
-
describe '#num_args' do
|
119
|
-
it "returns the number of CompileCommand" do
|
120
|
-
expect(cmd.num_args).to be_kind_of(Integer)
|
121
|
-
expect(cmd.num_args).to be >= 31 # clang may insert additional args
|
122
|
-
end
|
123
|
-
end
|
124
|
-
|
125
|
-
describe '#arg' do
|
126
|
-
it "returns the I'th argument value" do
|
127
|
-
expect(cmd.arg(0)).to be_kind_of(String)
|
128
|
-
expect(cmd.arg(0)).to eq('/opt/llvm/3.4/bin/clang++')
|
129
|
-
end
|
130
|
-
end
|
131
|
-
|
132
|
-
describe '#args' do
|
133
|
-
it "returns all argument values as Array" do
|
134
|
-
expect(cmd.args).to be_kind_of(Array)
|
135
|
-
expect(cmd.args.first).to be_kind_of(String)
|
136
|
-
expect(cmd.args.size).to eq(cmd.num_args)
|
137
|
-
end
|
138
|
-
end
|
139
|
-
|
140
|
-
describe '#num_mapped_sources' do
|
141
|
-
# TODO: a case which has mapped sources
|
142
|
-
|
143
|
-
it "returns the number of source mappings" do
|
144
|
-
# expect(cmd.num_mapped_sources).to be_kind_of(Integer)
|
145
|
-
# expect(cmd.num_mapped_sources).to eq(0)
|
146
|
-
end
|
147
|
-
end
|
148
|
-
|
149
|
-
describe '#mapped_source_path' do
|
150
|
-
it "returns the I'th mapped source path" do
|
151
|
-
# TODO: a case which returns real source path
|
152
|
-
# expect(cmd.mapped_source_path(0)).to be_kind_of(String)
|
153
|
-
end
|
154
|
-
|
155
|
-
it "returns nil if the index exceeds element size" do
|
156
|
-
# expect(cmd.mapped_source_path(1000)).to be_nil
|
157
|
-
end
|
158
|
-
end
|
159
|
-
|
160
|
-
describe '#mapped_source_content' do
|
161
|
-
it "returns the I'th mapped source content" do
|
162
|
-
# TODO: a case which returns real source path
|
163
|
-
# expect(cmd.mapped_source_content(0)).to be_kind_of(String)
|
164
|
-
end
|
165
|
-
|
166
|
-
it "returns nil if the index exceeds element size" do
|
167
|
-
# expect(cmd.mapped_source_content(1000)).to be_nil
|
168
|
-
end
|
169
|
-
end
|
170
|
-
|
171
|
-
describe '#mapped_sources' do
|
172
|
-
# TODO: a case which has mapped sources
|
173
|
-
|
174
|
-
it "returns all mapped sources as Array" do
|
175
|
-
# expect(cmd.mapped_sources).to be_kind_of(Array)
|
176
|
-
# expect(cmd.mapped_sources.size).to eq(cmd.num_mapped_sources)
|
177
|
-
end
|
178
|
-
end
|
179
|
-
end
|
180
|
-
end
|