ffi-clang 0.3.0 → 0.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rspec +4 -0
- data/.travis.yml +20 -9
- data/Gemfile +10 -1
- data/README.md +1 -1
- data/Rakefile +9 -9
- data/examples/docs.cpp +25 -0
- data/examples/docs.rb +31 -0
- data/ffi-clang.gemspec +1 -1
- data/lib/ffi/clang.rb +16 -13
- data/lib/ffi/clang/clang_version.rb +29 -0
- data/lib/ffi/clang/code_completion.rb +1 -1
- data/lib/ffi/clang/comment.rb +8 -4
- data/lib/ffi/clang/compilation_database.rb +1 -1
- data/lib/ffi/clang/cursor.rb +42 -15
- data/lib/ffi/clang/diagnostic.rb +6 -2
- data/lib/ffi/clang/file.rb +6 -9
- data/lib/ffi/clang/index.rb +4 -4
- data/lib/ffi/clang/lib.rb +1 -1
- data/lib/ffi/clang/lib/{utils.rb → clang_version.rb} +1 -1
- data/lib/ffi/clang/lib/code_completion.rb +2 -3
- data/lib/ffi/clang/lib/comment.rb +0 -2
- data/lib/ffi/clang/lib/compilation_database.rb +6 -9
- data/lib/ffi/clang/lib/cursor.rb +10 -18
- data/lib/ffi/clang/lib/diagnostic.rb +4 -4
- data/lib/ffi/clang/lib/file.rb +4 -6
- data/lib/ffi/clang/lib/inclusions.rb +2 -2
- data/lib/ffi/clang/lib/index.rb +0 -2
- data/lib/ffi/clang/lib/source_location.rb +6 -8
- data/lib/ffi/clang/lib/source_range.rb +1 -1
- data/lib/ffi/clang/lib/string.rb +0 -2
- data/lib/ffi/clang/lib/translation_unit.rb +2 -2
- data/lib/ffi/clang/lib/type.rb +8 -17
- data/lib/ffi/clang/source_location.rb +2 -2
- data/lib/ffi/clang/source_range.rb +16 -3
- data/lib/ffi/clang/token.rb +4 -4
- data/lib/ffi/clang/translation_unit.rb +5 -5
- data/lib/ffi/clang/type.rb +0 -14
- data/lib/ffi/clang/version.rb +2 -2
- data/spec/{clang → ffi/clang}/code_completion_spec.rb +6 -6
- data/spec/{clang → ffi/clang}/comment_spec.rb +22 -39
- data/spec/{clang → ffi/clang}/compilation_database_spec.rb +8 -10
- data/spec/{clang → ffi/clang}/cursor_spec.rb +89 -97
- data/spec/{clang → ffi/clang}/diagnostic_spec.rb +9 -10
- data/spec/{clang → ffi/clang}/file_spec.rb +3 -5
- data/spec/{fixtures → ffi/clang/fixtures}/a.c +0 -0
- data/spec/{fixtures → ffi/clang/fixtures}/canonical.c +0 -0
- data/spec/ffi/clang/fixtures/class.cpp +8 -0
- data/spec/{fixtures → ffi/clang/fixtures}/compile_commands.json +0 -0
- data/spec/{fixtures → ffi/clang/fixtures}/completion.cxx +0 -0
- data/spec/{fixtures → ffi/clang/fixtures}/docs.c +0 -0
- data/spec/{fixtures → ffi/clang/fixtures}/docs.cc +0 -0
- data/spec/{fixtures → ffi/clang/fixtures}/docs.h +0 -0
- data/spec/{fixtures → ffi/clang/fixtures}/list.c +0 -0
- data/spec/{fixtures → ffi/clang/fixtures}/location1.c +0 -0
- data/spec/ffi/clang/fixtures/simple.ast +0 -0
- data/spec/{fixtures → ffi/clang/fixtures}/simple.c +0 -0
- data/spec/{fixtures → ffi/clang/fixtures}/test.cxx +0 -0
- data/spec/{clang → ffi/clang}/index_spec.rb +17 -14
- data/spec/{clang → ffi/clang}/source_location_spec.rb +12 -14
- data/spec/{clang → ffi/clang}/source_range_spec.rb +12 -14
- data/spec/{clang → ffi/clang}/token_spec.rb +6 -8
- data/spec/{clang → ffi/clang}/translation_unit_spec.rb +28 -30
- data/spec/{clang → ffi/clang}/type_spec.rb +17 -33
- data/spec/ffi/clang/version_spec.rb +28 -0
- data/spec/spec_helper.rb +11 -37
- metadata +61 -55
- data/lib/ffi/clang/utils.rb +0 -89
- data/spec/clang/utils_spec.rb +0 -60
@@ -18,14 +18,12 @@
|
|
18
18
|
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
19
19
|
# THE SOFTWARE.
|
20
20
|
|
21
|
-
require 'spec_helper'
|
22
|
-
|
23
21
|
describe CodeCompletion do
|
24
22
|
let(:filename) { fixture_path("completion.cxx") }
|
25
|
-
let(:
|
23
|
+
let(:translation_unit) { Index.new.parse_translation_unit(filename) }
|
26
24
|
let(:line) { 7 }
|
27
25
|
let(:column) { 6 }
|
28
|
-
let(:results) {
|
26
|
+
let(:results) { translation_unit.code_complete(filename, line, column) }
|
29
27
|
|
30
28
|
describe "self.default_code_completion_options" do
|
31
29
|
let(:options) { FFI::Clang::CodeCompletion.default_code_completion_options }
|
@@ -101,8 +99,10 @@ describe CodeCompletion do
|
|
101
99
|
it "#sort!" do
|
102
100
|
results.sort!
|
103
101
|
|
104
|
-
|
105
|
-
|
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
106
|
end
|
107
107
|
end
|
108
108
|
|
@@ -19,59 +19,56 @@
|
|
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 'spec_helper'
|
23
|
-
|
24
22
|
describe Comment do
|
25
23
|
let(:cursor) { Index.new.parse_translation_unit(fixture_path("docs.cc")).cursor }
|
26
24
|
let (:comment) { find_first(cursor, :cursor_function).comment }
|
27
25
|
|
28
26
|
it "can be obtained from a cursor" do
|
29
|
-
comment.
|
30
|
-
comment.
|
31
|
-
comment.kind.
|
27
|
+
expect(comment).to be_kind_of(Comment)
|
28
|
+
expect(comment).to be_kind_of(FullComment)
|
29
|
+
expect(comment.kind).to equal(:comment_full)
|
32
30
|
end
|
33
31
|
|
34
32
|
it "can parse the brief description" do
|
35
33
|
para = comment.child
|
36
|
-
para.kind.
|
37
|
-
para.
|
34
|
+
expect(para.kind).to equal(:comment_paragraph)
|
35
|
+
expect(para).to be_kind_of(ParagraphComment)
|
38
36
|
text = para.child
|
39
|
-
text.kind.
|
40
|
-
text.
|
41
|
-
text.text.strip.
|
37
|
+
expect(text.kind).to equal(:comment_text)
|
38
|
+
expect(text).to be_kind_of(TextComment)
|
39
|
+
expect(text.text.strip).to eq("Short explanation")
|
42
40
|
end
|
43
41
|
|
44
42
|
it "can parse the longer description" do
|
45
43
|
para = comment.child(1)
|
46
|
-
para.kind.
|
47
|
-
para.num_children.
|
48
|
-
text = para.child
|
44
|
+
expect(para.kind).to equal(:comment_paragraph)
|
45
|
+
expect(para.num_children).to equal(2)
|
49
46
|
|
50
47
|
lines = (0..para.num_children-1).map do |i|
|
51
48
|
para.child(i).text
|
52
49
|
end
|
53
50
|
|
54
|
-
lines.
|
51
|
+
expect(lines).to eq([" This is a longer explanation",
|
55
52
|
" that spans multiple lines"])
|
56
53
|
end
|
57
54
|
|
58
55
|
it "has working helpers" do
|
59
|
-
comment.num_children.
|
56
|
+
expect(comment.num_children).to equal(8)
|
60
57
|
|
61
58
|
para = comment.child(1)
|
62
|
-
para.text.
|
59
|
+
expect(para.text).to eq(" This is a longer explanation\n that spans multiple lines")
|
63
60
|
end
|
64
61
|
|
65
62
|
it "understands params" do
|
66
63
|
[['input', " some input\n "], ['flags', " some flags\n "]].each_with_index do |v, child_idx|
|
67
64
|
param = comment.child(3 + child_idx)
|
68
|
-
param.
|
65
|
+
expect(param).to be_kind_of(ParamCommandComment)
|
69
66
|
|
70
|
-
param.valid_index
|
71
|
-
param.index.
|
72
|
-
param.name.
|
73
|
-
param.child.text.
|
74
|
-
param.comment.
|
67
|
+
expect(param.valid_index?).to be_truthy
|
68
|
+
expect(param.index).to be == child_idx
|
69
|
+
expect(param.name).to be == v[0]
|
70
|
+
expect(param.child.text).to be == v[1]
|
71
|
+
expect(param.comment).to be == v[1]
|
75
72
|
end
|
76
73
|
end
|
77
74
|
|
@@ -135,15 +132,10 @@ describe Comment do
|
|
135
132
|
end
|
136
133
|
|
137
134
|
describe "#text" do
|
138
|
-
it "returns HTML tag as string"
|
135
|
+
it "returns HTML tag as string" do
|
139
136
|
expect(html_start_tag_comments[0].text.strip).to eq('<br/>')
|
140
137
|
expect(html_start_tag_comments[1].text.strip).to eq('<a href="http://example.org/">')
|
141
138
|
end
|
142
|
-
|
143
|
-
it "returuns empty string", upto_3_3: true do
|
144
|
-
expect(html_start_tag_comments[0].text.strip).to eq('')
|
145
|
-
expect(html_start_tag_comments[1].text.strip).to eq('')
|
146
|
-
end
|
147
139
|
end
|
148
140
|
|
149
141
|
describe "#self_closing?" do
|
@@ -193,13 +185,9 @@ describe Comment do
|
|
193
185
|
end
|
194
186
|
|
195
187
|
describe "#text" do
|
196
|
-
it "returns HTML tag as string"
|
188
|
+
it "returns HTML tag as string" do
|
197
189
|
expect(html_end_tag_comment.text.strip).to eq('</a>')
|
198
190
|
end
|
199
|
-
|
200
|
-
it "returuns empty string", upto_3_3: true do
|
201
|
-
expect(html_end_tag_comment.text.strip).to eq('')
|
202
|
-
end
|
203
191
|
end
|
204
192
|
end
|
205
193
|
|
@@ -214,15 +202,10 @@ describe Comment do
|
|
214
202
|
end
|
215
203
|
|
216
204
|
describe "#to_html" do
|
217
|
-
it "converts a given full parsed comment to an HTML fragment"
|
205
|
+
it "converts a given full parsed comment to an HTML fragment" do
|
218
206
|
expect(comment.to_html).to be_kind_of(String)
|
219
207
|
expect(comment.to_html).to eq('<p class="para-brief"> this is a function.</p>')
|
220
208
|
end
|
221
|
-
|
222
|
-
it "converts a given full parsed comment to an HTML fragment", upto_3_3: true do
|
223
|
-
expect(comment.to_html).to be_kind_of(String)
|
224
|
-
expect(comment.to_html).to eq('<p class="para-brief"> this is a function. </p>')
|
225
|
-
end
|
226
209
|
end
|
227
210
|
|
228
211
|
describe "#to_xml" do
|
@@ -18,8 +18,6 @@
|
|
18
18
|
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
19
19
|
# THE SOFTWARE.
|
20
20
|
|
21
|
-
require 'spec_helper'
|
22
|
-
|
23
21
|
describe CompilationDatabase do
|
24
22
|
let(:dirpath) { fixture_path('') }
|
25
23
|
let(:cdb) { CompilationDatabase.new(dirpath) }
|
@@ -35,7 +33,7 @@ describe CompilationDatabase do
|
|
35
33
|
|
36
34
|
it "calls compilation_database_dispose on GC" do
|
37
35
|
cdb.autorelease = false
|
38
|
-
expect(Lib).to receive(:compilation_database_dispose).with(cdb).once
|
36
|
+
# expect(Lib).to receive(:compilation_database_dispose).with(cdb).once
|
39
37
|
expect{cdb.free}.not_to raise_error
|
40
38
|
end
|
41
39
|
|
@@ -53,7 +51,7 @@ describe CompilationDatabase do
|
|
53
51
|
end
|
54
52
|
end
|
55
53
|
|
56
|
-
describe '#all_compile_commands'
|
54
|
+
describe '#all_compile_commands' do
|
57
55
|
it "returns all compile commands in the database" do
|
58
56
|
expect(cdb.all_compile_commands).to be_kind_of(CompilationDatabase::CompileCommands)
|
59
57
|
expect(cdb.all_compile_commands.size).to eq(3)
|
@@ -65,7 +63,7 @@ describe CompilationDatabase do
|
|
65
63
|
|
66
64
|
it "calls compile_commands_dispose on GC" do
|
67
65
|
commands.autorelease = false
|
68
|
-
expect(Lib).to receive(:compile_commands_dispose).with(commands).once
|
66
|
+
# expect(Lib).to receive(:compile_commands_dispose).with(commands).once
|
69
67
|
expect{commands.free}.not_to raise_error
|
70
68
|
end
|
71
69
|
|
@@ -75,7 +73,7 @@ describe CompilationDatabase do
|
|
75
73
|
expect(commands.size).to eq(1)
|
76
74
|
end
|
77
75
|
|
78
|
-
it "returns the number of CompileCommand"
|
76
|
+
it "returns the number of CompileCommand" do
|
79
77
|
expect(cdb.all_compile_commands.size).to eq(3)
|
80
78
|
end
|
81
79
|
end
|
@@ -135,7 +133,7 @@ describe CompilationDatabase do
|
|
135
133
|
end
|
136
134
|
end
|
137
135
|
|
138
|
-
describe '#num_mapped_sources'
|
136
|
+
describe '#num_mapped_sources' do
|
139
137
|
# TODO: a case which has mapped sources
|
140
138
|
|
141
139
|
it "returns the number of source mappings" do
|
@@ -144,7 +142,7 @@ describe CompilationDatabase do
|
|
144
142
|
end
|
145
143
|
end
|
146
144
|
|
147
|
-
describe '#mapped_source_path'
|
145
|
+
describe '#mapped_source_path' do
|
148
146
|
it "returns the I'th mapped source path" do
|
149
147
|
# TODO: a case which returns real source path
|
150
148
|
# expect(cmd.mapped_source_path(0)).to be_kind_of(String)
|
@@ -155,7 +153,7 @@ describe CompilationDatabase do
|
|
155
153
|
end
|
156
154
|
end
|
157
155
|
|
158
|
-
describe '#mapped_source_content'
|
156
|
+
describe '#mapped_source_content' do
|
159
157
|
it "returns the I'th mapped source content" do
|
160
158
|
# TODO: a case which returns real source path
|
161
159
|
# expect(cmd.mapped_source_content(0)).to be_kind_of(String)
|
@@ -166,7 +164,7 @@ describe CompilationDatabase do
|
|
166
164
|
end
|
167
165
|
end
|
168
166
|
|
169
|
-
describe '#mapped_sources'
|
167
|
+
describe '#mapped_sources' do
|
170
168
|
# TODO: a case which has mapped sources
|
171
169
|
|
172
170
|
it "returns all mapped sources as Array" do
|
@@ -2,14 +2,14 @@
|
|
2
2
|
# Copyright, 2013, by Samuel G. D. Williams. <http://www.codeotaku.com>
|
3
3
|
# Copyright, 2013, by Garry C. Marshall. <http://www.meaningfulname.net>
|
4
4
|
# Copyright, 2014, by Masahiro Sano.
|
5
|
-
#
|
5
|
+
#
|
6
6
|
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
7
7
|
# of this software and associated documentation files (the "Software"), to deal
|
8
8
|
# in the Software without restriction, including without limitation the rights
|
9
9
|
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
10
10
|
# copies of the Software, and to permit persons to whom the Software is
|
11
11
|
# furnished to do so, subject to the following conditions:
|
12
|
-
#
|
12
|
+
#
|
13
13
|
# The above copyright notice and this permission notice shall be included in
|
14
14
|
# all copies or substantial portions of the Software.
|
15
15
|
#
|
@@ -21,7 +21,20 @@
|
|
21
21
|
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
22
22
|
# THE SOFTWARE.
|
23
23
|
|
24
|
-
|
24
|
+
describe "Function Call Cursors" do
|
25
|
+
let(:translation_unit) {Index.new.parse_translation_unit(fixture_path("class.cpp"))}
|
26
|
+
let(:cursor) {translation_unit.cursor}
|
27
|
+
let(:call) {find_first(cursor, :cursor_call_expr)}
|
28
|
+
|
29
|
+
it "should parse correctly" do
|
30
|
+
expect(translation_unit.diagnostics).to be_empty
|
31
|
+
end
|
32
|
+
|
33
|
+
it "should find a method call" do
|
34
|
+
call.should_not be_nil
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
25
38
|
|
26
39
|
describe Cursor do
|
27
40
|
let(:cursor) { Index.new.parse_translation_unit(fixture_path("list.c")).cursor }
|
@@ -30,15 +43,15 @@ describe Cursor do
|
|
30
43
|
let(:cursor_pp) { Index.new.parse_translation_unit(fixture_path("docs.c"),[],[],{detailed_preprocessing_record: true}).cursor }
|
31
44
|
|
32
45
|
it "can be obtained from a translation unit" do
|
33
|
-
cursor.
|
34
|
-
cursor.kind.
|
35
|
-
cursor.null
|
36
|
-
cursor.translation_unit
|
46
|
+
expect(cursor).to be_kind_of(Cursor)
|
47
|
+
expect(cursor.kind).to equal(:cursor_translation_unit)
|
48
|
+
expect(cursor.null?).to equal(false)
|
49
|
+
expect(cursor.translation_unit?).to equal(true)
|
37
50
|
end
|
38
51
|
|
39
52
|
it "returns the source location of the cursor" do
|
40
53
|
location = cursor.location
|
41
|
-
location.
|
54
|
+
expect(location).to be_kind_of(SourceLocation)
|
42
55
|
end
|
43
56
|
|
44
57
|
describe '#extent' do
|
@@ -52,20 +65,15 @@ describe Cursor do
|
|
52
65
|
expect(extent.start.line).to equal(1)
|
53
66
|
end
|
54
67
|
|
55
|
-
it 'has filename and posion at end point'
|
68
|
+
it 'has filename and posion at end point' do
|
56
69
|
expect(extent.end.file).to eq(fixture_path("list.c"))
|
57
70
|
expect(extent.end.line).to equal(12)
|
58
71
|
end
|
59
|
-
|
60
|
-
it 'has filename and posion at end point', upto_3_3: true do
|
61
|
-
expect(extent.end.file).to eq(fixture_path("list.c"))
|
62
|
-
expect(extent.end.line).to equal(11)
|
63
|
-
end
|
64
72
|
end
|
65
73
|
|
66
74
|
it "returns the path of the translation unit for the translation unit cursor" do
|
67
|
-
cursor.display_name.
|
68
|
-
cursor.spelling.
|
75
|
+
expect(cursor.display_name).to eq(fixture_path("list.c"))
|
76
|
+
expect(cursor.spelling).to eq(fixture_path("list.c"))
|
69
77
|
end
|
70
78
|
|
71
79
|
it "allows us to visit its children" do
|
@@ -74,29 +82,29 @@ describe Cursor do
|
|
74
82
|
counter += 1
|
75
83
|
:recurse
|
76
84
|
end
|
77
|
-
counter.
|
85
|
+
expect(counter).not_to equal(0)
|
78
86
|
end
|
79
87
|
|
80
88
|
describe "Null Cursor" do
|
81
89
|
it "can be a null cursor" do
|
82
|
-
Cursor.null_cursor.
|
83
|
-
Cursor.null_cursor.kind.
|
90
|
+
expect(Cursor.null_cursor).to be_kind_of(Cursor)
|
91
|
+
expect(Cursor.null_cursor.kind).to equal(:cursor_invalid_file)
|
84
92
|
end
|
85
93
|
|
86
94
|
it "is null?" do
|
87
|
-
Cursor.null_cursor.null
|
95
|
+
expect(Cursor.null_cursor.null?).to equal(true)
|
88
96
|
end
|
89
97
|
|
90
98
|
it "is invalid?" do
|
91
|
-
Cursor.null_cursor.invalid
|
99
|
+
expect(Cursor.null_cursor.invalid?).to equal(true)
|
92
100
|
end
|
93
101
|
|
94
102
|
it "compares as equal to another null cursor instance" do
|
95
|
-
Cursor.null_cursor.
|
103
|
+
expect(Cursor.null_cursor).to eq(Cursor.null_cursor)
|
96
104
|
end
|
97
105
|
|
98
106
|
it "should not equal a Translation Unit cursor" do
|
99
|
-
Cursor.null_cursor.
|
107
|
+
expect(Cursor.null_cursor).not_to eq(cursor)
|
100
108
|
end
|
101
109
|
end
|
102
110
|
|
@@ -104,23 +112,23 @@ describe Cursor do
|
|
104
112
|
let (:func) { find_first(cursor, :cursor_function) }
|
105
113
|
|
106
114
|
it "is not invalid?" do
|
107
|
-
func.invalid
|
115
|
+
expect(func.invalid?).to equal(false)
|
108
116
|
end
|
109
117
|
|
110
118
|
it "can find the first function declaration" do
|
111
|
-
func.
|
112
|
-
func.kind.
|
119
|
+
expect(func).not_to equal(nil)
|
120
|
+
expect(func.kind).to equal(:cursor_function)
|
113
121
|
end
|
114
122
|
|
115
123
|
it "has an extent representing the bounds of the function" do
|
116
|
-
func.extent.
|
117
|
-
func.extent.start.line.
|
118
|
-
func.extent.end.line.
|
124
|
+
expect(func.extent).to be_kind_of(SourceRange)
|
125
|
+
expect(func.extent.start.line).to equal(5)
|
126
|
+
expect(func.extent.end.line).to equal(5)
|
119
127
|
end
|
120
128
|
|
121
129
|
it "returns the name of the function" do
|
122
|
-
func.spelling.
|
123
|
-
func.display_name.
|
130
|
+
expect(func.spelling).to eq("sum")
|
131
|
+
expect(func.display_name).to eq("sum(union List *)")
|
124
132
|
end
|
125
133
|
end
|
126
134
|
|
@@ -128,18 +136,18 @@ describe Cursor do
|
|
128
136
|
let (:struct) { find_first(cursor, :cursor_struct) }
|
129
137
|
|
130
138
|
it "can find the first struct" do
|
131
|
-
struct.
|
132
|
-
struct.kind.
|
139
|
+
expect(struct).not_to equal(nil)
|
140
|
+
expect(struct.kind).to equal(:cursor_struct)
|
133
141
|
end
|
134
142
|
|
135
143
|
it "has an extent representing the bounds of the struct" do
|
136
|
-
struct.extent.start.line.
|
137
|
-
struct.extent.end.line.
|
144
|
+
expect(struct.extent.start.line).to equal(1)
|
145
|
+
expect(struct.extent.end.line).to equal(4)
|
138
146
|
end
|
139
147
|
|
140
148
|
it "returns the name of the struct" do
|
141
|
-
struct.spelling.
|
142
|
-
struct.display_name.
|
149
|
+
expect(struct.spelling).to eq("List")
|
150
|
+
expect(struct.display_name).to eq("List")
|
143
151
|
end
|
144
152
|
|
145
153
|
end
|
@@ -196,39 +204,27 @@ describe Cursor do
|
|
196
204
|
let(:public_cursor) { find_matching(cursor_cxx) { |child, parent|
|
197
205
|
child.kind == :cursor_field_decl and child.spelling == 'public_member_int' } }
|
198
206
|
|
199
|
-
it 'checks access control level is public'
|
207
|
+
it 'checks access control level is public' do
|
200
208
|
expect(public_cursor.public?).to be true
|
201
209
|
end
|
202
|
-
|
203
|
-
it 'returns false on clang 3.2', upto_3_2: true do
|
204
|
-
expect(public_cursor.public?).to be false
|
205
|
-
end
|
206
210
|
end
|
207
211
|
|
208
212
|
describe '#private?' do
|
209
213
|
let(:private_cursor) { find_matching(cursor_cxx) { |child, parent|
|
210
214
|
child.kind == :cursor_field_decl and child.spelling == 'private_member_int' } }
|
211
215
|
|
212
|
-
it 'checks access control level is private'
|
216
|
+
it 'checks access control level is private' do
|
213
217
|
expect(private_cursor.private?).to be true
|
214
218
|
end
|
215
|
-
|
216
|
-
it 'returns false on clang 3.2', upto_3_2: true do
|
217
|
-
expect(private_cursor.private?).to be false
|
218
|
-
end
|
219
219
|
end
|
220
220
|
|
221
221
|
describe '#protected?' do
|
222
222
|
let(:protected_cursor) { find_matching(cursor_cxx) { |child, parent|
|
223
223
|
child.kind == :cursor_field_decl and child.spelling == 'protected_member_int' } }
|
224
224
|
|
225
|
-
it 'checks access control level is protected'
|
225
|
+
it 'checks access control level is protected' do
|
226
226
|
expect(protected_cursor.protected?).to be true
|
227
227
|
end
|
228
|
-
|
229
|
-
it 'returns false on clang 3.2', upto_3_2: true do
|
230
|
-
expect(protected_cursor.protected?).to be false
|
231
|
-
end
|
232
228
|
end
|
233
229
|
|
234
230
|
describe '#preprocessing?' do
|
@@ -253,7 +249,7 @@ describe Cursor do
|
|
253
249
|
child.kind == :cursor_cxx_base_specifier and parent.spelling == 'B' } }
|
254
250
|
|
255
251
|
it 'checks cursor is virtual base' do
|
256
|
-
virtual_base_cursor.virtual_base
|
252
|
+
expect(virtual_base_cursor.virtual_base?).to equal true
|
257
253
|
end
|
258
254
|
end
|
259
255
|
|
@@ -262,17 +258,17 @@ describe Cursor do
|
|
262
258
|
child.kind == :cursor_cxx_method and child.spelling == 'func_a' } }
|
263
259
|
|
264
260
|
it 'checks member function is virtual' do
|
265
|
-
virtual_cursor.virtual
|
261
|
+
expect(virtual_cursor.virtual?).to equal true
|
266
262
|
end
|
267
263
|
end
|
268
264
|
|
269
|
-
describe '#pure_virtual?'
|
265
|
+
describe '#pure_virtual?' do
|
270
266
|
let(:pure_virtual_cursor) { find_matching(cursor_cxx) { |child, parent|
|
271
267
|
child.kind == :cursor_cxx_method and
|
272
268
|
child.spelling == 'func_a' and parent.spelling == 'A' } }
|
273
269
|
|
274
270
|
it 'checks member function is purely virtual' do
|
275
|
-
pure_virtual_cursor.pure_virtual
|
271
|
+
expect(pure_virtual_cursor.pure_virtual?).to equal true
|
276
272
|
end
|
277
273
|
end
|
278
274
|
|
@@ -281,7 +277,7 @@ describe Cursor do
|
|
281
277
|
child.kind == :cursor_cxx_method and child.spelling == 'func_b' } }
|
282
278
|
|
283
279
|
it 'checks cursor is static member function' do
|
284
|
-
static_method_cursor.static
|
280
|
+
expect(static_method_cursor.static?).to equal true
|
285
281
|
end
|
286
282
|
end
|
287
283
|
|
@@ -290,7 +286,7 @@ describe Cursor do
|
|
290
286
|
child.kind == :cursor_enum_constant_decl and child.spelling == 'EnumC' } }
|
291
287
|
|
292
288
|
it 'returns enum value' do
|
293
|
-
enum_value_cursor.enum_value.
|
289
|
+
expect(enum_value_cursor.enum_value).to equal 100
|
294
290
|
end
|
295
291
|
end
|
296
292
|
|
@@ -305,7 +301,7 @@ describe Cursor do
|
|
305
301
|
|
306
302
|
describe '#dynamic_call?' do
|
307
303
|
let(:dynamic_call) { find_matching(cursor_cxx) { |child, parent|
|
308
|
-
child.kind == :cursor_call_expr and child.spelling == 'func_a' and
|
304
|
+
child.kind == :cursor_call_expr and child.spelling == 'func_a' and
|
309
305
|
child.semantic_parent.spelling == 'f_dynamic_call' } }
|
310
306
|
|
311
307
|
it 'checks if the method call is dynamic' do
|
@@ -313,7 +309,7 @@ describe Cursor do
|
|
313
309
|
end
|
314
310
|
end
|
315
311
|
|
316
|
-
describe '#specialized_template'
|
312
|
+
describe '#specialized_template' do # looks not working on 3.2
|
317
313
|
let(:cursor_function) { find_matching(cursor_cxx) { |child, parent|
|
318
314
|
child.kind == :cursor_function and child.spelling == 'func_overloaded' } }
|
319
315
|
|
@@ -327,13 +323,13 @@ describe Cursor do
|
|
327
323
|
let (:structs) { find_all(cursor_canon, :cursor_struct) }
|
328
324
|
|
329
325
|
it "mathes 3 cursors" do
|
330
|
-
structs.size.
|
326
|
+
expect(structs.size).to eq(3)
|
331
327
|
end
|
332
328
|
|
333
329
|
it "refers the first cursor as canonical one" do
|
334
|
-
structs[0].canonical.
|
335
|
-
structs[1].canonical.
|
336
|
-
structs[2].canonical.
|
330
|
+
expect(structs[0].canonical).to eq(structs[0])
|
331
|
+
expect(structs[1].canonical).to eq(structs[0])
|
332
|
+
expect(structs[2].canonical).to eq(structs[0])
|
337
333
|
end
|
338
334
|
end
|
339
335
|
|
@@ -341,17 +337,17 @@ describe Cursor do
|
|
341
337
|
let (:structs) { find_all(cursor_canon, :cursor_struct) }
|
342
338
|
|
343
339
|
it "mathes 3 cursors" do
|
344
|
-
structs.size.
|
340
|
+
expect(structs.size).to eq(3)
|
345
341
|
end
|
346
342
|
|
347
343
|
it "refers the third cursor as definition one" do
|
348
|
-
structs[0].definition.
|
349
|
-
structs[1].definition.
|
350
|
-
structs[2].definition.
|
344
|
+
expect(structs[0].definition).to eq(structs[2])
|
345
|
+
expect(structs[1].definition).to eq(structs[2])
|
346
|
+
expect(structs[2].definition).to eq(structs[2])
|
351
347
|
end
|
352
348
|
end
|
353
349
|
|
354
|
-
describe '#template_kind'
|
350
|
+
describe '#template_kind' do # looks not working on 3.2
|
355
351
|
let(:template) { find_matching(cursor_cxx) { |child, parent|
|
356
352
|
child.kind == :cursor_function_template and child.spelling == 'func_overloaded' } }
|
357
353
|
|
@@ -365,12 +361,8 @@ describe Cursor do
|
|
365
361
|
let(:access_specifier_cursor) { find_matching(cursor_cxx) { |child, parent|
|
366
362
|
child.kind == :cursor_cxx_method and child.spelling == 'func_d' } }
|
367
363
|
|
368
|
-
it 'returns access specifier symbol'
|
369
|
-
access_specifier_cursor.access_specifier.
|
370
|
-
end
|
371
|
-
|
372
|
-
it 'returns access specifier symbol(invalid, why?)', upto_3_2: true do
|
373
|
-
access_specifier_cursor.access_specifier.should equal :invalid
|
364
|
+
it 'returns access specifier symbol' do
|
365
|
+
expect(access_specifier_cursor.access_specifier).to equal :private
|
374
366
|
end
|
375
367
|
end
|
376
368
|
|
@@ -379,11 +371,11 @@ describe Cursor do
|
|
379
371
|
let(:cxx_language_cursor) { find_matching(cursor_cxx) { |c, p| c.kind == :cursor_struct } }
|
380
372
|
|
381
373
|
it 'returns :c if the cursor language is C' do
|
382
|
-
c_language_cursor.language.
|
374
|
+
expect(c_language_cursor.language).to equal :c
|
383
375
|
end
|
384
376
|
|
385
377
|
it 'returns :c_plus_plus if the cursor language is C++' do
|
386
|
-
cxx_language_cursor.language.
|
378
|
+
expect(cxx_language_cursor.language).to equal :c_plus_plus
|
387
379
|
end
|
388
380
|
end
|
389
381
|
|
@@ -391,12 +383,12 @@ describe Cursor do
|
|
391
383
|
let (:struct) { find_first(cursor, :cursor_struct) }
|
392
384
|
|
393
385
|
it "can find the first struct" do
|
394
|
-
struct.
|
386
|
+
expect(struct).not_to equal(nil)
|
395
387
|
end
|
396
388
|
|
397
389
|
it "returns the translation unit that a cursor originated from" do
|
398
|
-
struct.translation_unit.
|
399
|
-
struct.translation_unit.spelling.
|
390
|
+
expect(struct.translation_unit).to be_kind_of(TranslationUnit)
|
391
|
+
expect(struct.translation_unit.spelling).to eq(fixture_path("list.c"))
|
400
392
|
end
|
401
393
|
end
|
402
394
|
|
@@ -405,11 +397,11 @@ describe Cursor do
|
|
405
397
|
let (:func) { find_first(cursor, :cursor_function) }
|
406
398
|
|
407
399
|
it "returns :external if the cursor is non-static function" do
|
408
|
-
func.linkage.
|
400
|
+
expect(func.linkage).to equal :external
|
409
401
|
end
|
410
402
|
|
411
403
|
it "returns :invalid if the cursor does not have linkage" do
|
412
|
-
ref.linkage.
|
404
|
+
expect(ref.linkage).to equal :invalid
|
413
405
|
end
|
414
406
|
end
|
415
407
|
|
@@ -418,7 +410,7 @@ describe Cursor do
|
|
418
410
|
child.kind == :cursor_cxx_method and child.spelling == 'func_d' and parent.spelling != 'D' } }
|
419
411
|
|
420
412
|
it 'returns base class as semantic parent' do
|
421
|
-
parent.semantic_parent.spelling.
|
413
|
+
expect(parent.semantic_parent.spelling).to eq('D')
|
422
414
|
end
|
423
415
|
end
|
424
416
|
|
@@ -427,7 +419,7 @@ describe Cursor do
|
|
427
419
|
child.kind == :cursor_cxx_method and child.spelling == 'func_d' and parent.spelling != 'D' } }
|
428
420
|
|
429
421
|
it 'returns translation unit as lexical parent' do
|
430
|
-
parent.lexical_parent.kind.
|
422
|
+
expect(parent.lexical_parent.kind).to eq(:cursor_translation_unit)
|
431
423
|
end
|
432
424
|
end
|
433
425
|
|
@@ -439,7 +431,7 @@ describe Cursor do
|
|
439
431
|
let (:struct) { find_all(cursor_canon, :cursor_struct).at(2) }
|
440
432
|
|
441
433
|
it "checks cursor is a definition" do
|
442
|
-
struct.definition
|
434
|
+
expect(struct.definition?).to be true
|
443
435
|
end
|
444
436
|
end
|
445
437
|
|
@@ -447,16 +439,16 @@ describe Cursor do
|
|
447
439
|
let (:func) { find_first(cursor, :cursor_function) }
|
448
440
|
|
449
441
|
it "returns something in string" do
|
450
|
-
func.usr.
|
442
|
+
expect(func.usr).to be_kind_of(String)
|
451
443
|
end
|
452
444
|
end
|
453
445
|
|
454
|
-
describe '#variadic?'
|
446
|
+
describe '#variadic?' do
|
455
447
|
let(:func) { find_matching(cursor_cxx) { |child, parent|
|
456
448
|
child.kind == :cursor_function and child.spelling == 'f_variadic' } }
|
457
449
|
|
458
450
|
it "checks cursor is a variadic function" do
|
459
|
-
func.variadic
|
451
|
+
expect(func.variadic?).to be true
|
460
452
|
end
|
461
453
|
end
|
462
454
|
|
@@ -467,7 +459,7 @@ describe Cursor do
|
|
467
459
|
child.kind == :cursor_type_ref and child.spelling == 'struct A' } }
|
468
460
|
|
469
461
|
it "returns a cursor that this cursor references" do
|
470
|
-
ref.referenced.
|
462
|
+
expect(ref.referenced).to eq(struct)
|
471
463
|
end
|
472
464
|
|
473
465
|
end
|
@@ -476,7 +468,7 @@ describe Cursor do
|
|
476
468
|
let (:func) { find_first(cursor, :cursor_function) }
|
477
469
|
|
478
470
|
it "computes hash for the cursor" do
|
479
|
-
func.hash.
|
471
|
+
expect(func.hash).to be_kind_of(Fixnum)
|
480
472
|
end
|
481
473
|
end
|
482
474
|
|
@@ -484,7 +476,7 @@ describe Cursor do
|
|
484
476
|
let (:func) { find_first(cursor, :cursor_function) }
|
485
477
|
|
486
478
|
it "returns :available for the cursor availability" do
|
487
|
-
func.availability.
|
479
|
+
expect(func.availability).to equal(:available)
|
488
480
|
end
|
489
481
|
end
|
490
482
|
|
@@ -492,8 +484,8 @@ describe Cursor do
|
|
492
484
|
let (:field) { find_first(cursor, :cursor_field_decl) }
|
493
485
|
|
494
486
|
it "returns type for the cursor" do
|
495
|
-
field.type.
|
496
|
-
field.type.kind.
|
487
|
+
expect(field.type).to be_kind_of(Type)
|
488
|
+
expect(field.type.kind).to equal(:type_int)
|
497
489
|
end
|
498
490
|
end
|
499
491
|
|
@@ -501,12 +493,12 @@ describe Cursor do
|
|
501
493
|
let (:typedef) { find_first(cursor_cxx, :cursor_typedef_decl) }
|
502
494
|
|
503
495
|
it "returns type that the cursor type is underlying" do
|
504
|
-
typedef.underlying_type.
|
505
|
-
typedef.underlying_type.kind.
|
496
|
+
expect(typedef.underlying_type).to be_kind_of(Type)
|
497
|
+
expect(typedef.underlying_type.kind).to equal(:type_pointer)
|
506
498
|
end
|
507
499
|
end
|
508
500
|
|
509
|
-
describe '#bitfield?'
|
501
|
+
describe '#bitfield?' do
|
510
502
|
let(:bitfield) { find_matching(cursor_cxx) { |child, parent|
|
511
503
|
child.kind == :cursor_field_decl and child.spelling == 'bit_field_a' } }
|
512
504
|
let(:non_bitfield) { find_matching(cursor_cxx) { |child, parent|
|
@@ -521,7 +513,7 @@ describe Cursor do
|
|
521
513
|
end
|
522
514
|
end
|
523
515
|
|
524
|
-
describe '#bitwidth'
|
516
|
+
describe '#bitwidth' do
|
525
517
|
let(:bitfield) { find_matching(cursor_cxx) { |child, parent|
|
526
518
|
child.kind == :cursor_field_decl and child.spelling == 'bit_field_a' } }
|
527
519
|
let(:non_bitfield) { find_matching(cursor_cxx) { |child, parent|
|