rbgccxml 0.9.1 → 1.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.
- data/Rakefile +8 -10
- data/lib/rbgccxml/node.rb +65 -64
- data/lib/rbgccxml/node_cache.rb +93 -0
- data/lib/rbgccxml/nodes/argument.rb +4 -1
- data/lib/rbgccxml/nodes/base.rb +1 -1
- data/lib/rbgccxml/nodes/class.rb +22 -15
- data/lib/rbgccxml/nodes/enum_value.rb +2 -4
- data/lib/rbgccxml/nodes/enumeration.rb +1 -1
- data/lib/rbgccxml/nodes/field.rb +3 -1
- data/lib/rbgccxml/nodes/function.rb +2 -2
- data/lib/rbgccxml/nodes/method.rb +3 -3
- data/lib/rbgccxml/nodes/namespace.rb +14 -0
- data/lib/rbgccxml/nodes/type.rb +4 -3
- data/lib/rbgccxml/nodes/types/array_type.rb +3 -2
- data/lib/rbgccxml/nodes/types/cv_qualified_type.rb +12 -6
- data/lib/rbgccxml/nodes/types/pointer_type.rb +2 -1
- data/lib/rbgccxml/nodes/types/reference_type.rb +2 -1
- data/lib/rbgccxml/parser.rb +7 -5
- data/lib/rbgccxml/query_result.rb +8 -2
- data/lib/rbgccxml/sax_parser.rb +69 -0
- data/lib/rbgccxml.rb +3 -1
- data/lib/vendor/facets/once.rb +59 -0
- data/test/arguments_test.rb +14 -14
- data/test/classes_test.rb +85 -80
- data/test/enumerations_test.rb +29 -31
- data/test/function_pointers_test.rb +7 -7
- data/test/functions_test.rb +20 -20
- data/test/methods_test.rb +26 -25
- data/test/namespaces_test.rb +6 -6
- data/test/node_test.rb +7 -7
- data/test/parser_test.rb +23 -23
- data/test/query_results_test.rb +81 -81
- data/test/structs_test.rb +19 -20
- data/test/test_helper.rb +5 -18
- data/test/types_test.rb +60 -58
- data/test/variables_test.rb +12 -12
- metadata +58 -63
- data/lib/rbgccxml/xml_parsing.rb +0 -152
data/test/functions_test.rb
CHANGED
@@ -1,49 +1,49 @@
|
|
1
1
|
require "test_helper"
|
2
2
|
|
3
|
-
|
3
|
+
describe "Querying for functions" do
|
4
4
|
|
5
|
-
|
6
|
-
|
5
|
+
before(:all) do
|
6
|
+
@functions_source = RbGCCXML.parse(full_dir("headers/functions.h")).namespaces("functions")
|
7
7
|
end
|
8
8
|
|
9
9
|
specify "should be able to find all functions" do
|
10
|
-
|
10
|
+
@functions_source.functions.length.should == 4
|
11
11
|
end
|
12
12
|
|
13
13
|
specify "can find functions by name" do
|
14
14
|
# Short-hand finding does #find(:name => "")
|
15
|
-
test1 =
|
16
|
-
test1.should
|
15
|
+
test1 = @functions_source.functions("test1")
|
16
|
+
test1.should be_a_kind_of(RbGCCXML::Function)
|
17
17
|
test1.name.should == "test1"
|
18
18
|
|
19
|
-
bool =
|
20
|
-
bool.should
|
19
|
+
bool = @functions_source.functions.find(:name => "bool_method")
|
20
|
+
bool.should be_a_kind_of(RbGCCXML::Function)
|
21
21
|
bool.name.should == "bool_method"
|
22
22
|
end
|
23
23
|
|
24
24
|
specify "should not have a classes finder" do
|
25
|
-
test1 =
|
26
|
-
|
25
|
+
test1 = @functions_source.functions("test1")
|
26
|
+
lambda do
|
27
27
|
test1.classes
|
28
|
-
end
|
28
|
+
end.should raise_error(RbGCCXML::NotQueryableException)
|
29
29
|
end
|
30
30
|
|
31
31
|
specify "should not have a namespaces finder" do
|
32
|
-
test1 =
|
33
|
-
|
32
|
+
test1 = @functions_source.functions("test1")
|
33
|
+
lambda do
|
34
34
|
test1.namespaces
|
35
|
-
end
|
35
|
+
end.should raise_error(RbGCCXML::NotQueryableException)
|
36
36
|
end
|
37
37
|
|
38
38
|
specify "should not have a functions finder" do
|
39
|
-
test1 =
|
40
|
-
|
41
|
-
test1.functions
|
42
|
-
end
|
39
|
+
test1 = @functions_source.functions("test1")
|
40
|
+
lambda do
|
41
|
+
test1.functions
|
42
|
+
end.should raise_error(RbGCCXML::NotQueryableException)
|
43
43
|
end
|
44
44
|
|
45
45
|
specify "can get list of arguments" do
|
46
|
-
test1 =
|
47
|
-
test1.arguments.length.should
|
46
|
+
test1 = @functions_source.functions("test1")
|
47
|
+
test1.arguments.length.should == 2
|
48
48
|
end
|
49
49
|
end
|
data/test/methods_test.rb
CHANGED
@@ -1,42 +1,43 @@
|
|
1
1
|
require "test_helper"
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
|
3
|
+
describe "Querying for class methods" do
|
4
|
+
before(:all) do
|
5
|
+
@adder_source = RbGCCXML.parse(full_dir("headers/Adder.h")).namespaces("classes")
|
6
6
|
end
|
7
7
|
|
8
8
|
specify "should be able to get the methods on a class" do
|
9
|
-
adder =
|
9
|
+
adder = @adder_source.classes.find(:name => "Adder")
|
10
10
|
methods = adder.methods
|
11
11
|
|
12
12
|
methods.size.should == 4
|
13
|
-
methods
|
14
|
-
|
15
|
-
|
16
|
-
|
13
|
+
found = methods.sort {|a, b| a.name <=> b.name}
|
14
|
+
found[0].name.should == "addFloats"
|
15
|
+
found[1].name.should == "addIntegers"
|
16
|
+
found[2].name.should == "addStrings"
|
17
|
+
found[3].name.should == "getClassName"
|
17
18
|
end
|
18
19
|
|
19
20
|
# The following are simplistic. functions_test tests the
|
20
21
|
# finder options much more completely. This is just to test
|
21
22
|
# that it works on Method objects fine
|
22
23
|
specify "should be able to get methods by name" do
|
23
|
-
adder =
|
24
|
+
adder = @adder_source.classes("Adder")
|
24
25
|
adder.methods("addIntegers").name.should == "addIntegers"
|
25
26
|
adder.methods.find(:name => "addStrings").name.should == "addStrings"
|
26
27
|
end
|
27
28
|
|
28
29
|
specify "can search methods via arguments" do
|
29
|
-
adder =
|
30
|
+
adder = @adder_source.classes("Adder")
|
30
31
|
adder.methods.find(:arguments => [:int, :int]).name.should == "addIntegers"
|
31
32
|
end
|
32
33
|
|
33
34
|
specify "can search methods via return type" do
|
34
|
-
adder =
|
35
|
+
adder = @adder_source.classes("Adder")
|
35
36
|
adder.methods.find(:returns => :float).name.should == "addFloats"
|
36
37
|
end
|
37
38
|
|
38
39
|
specify "can search via all options (AND)" do
|
39
|
-
adder =
|
40
|
+
adder = @adder_source.classes("Adder")
|
40
41
|
got = adder.methods.find(:returns => :int, :arguments => [nil, nil])
|
41
42
|
got.name.should == "addIntegers"
|
42
43
|
end
|
@@ -44,27 +45,27 @@ context "Querying for class methods" do
|
|
44
45
|
end
|
45
46
|
|
46
47
|
context "Properties on Methods" do
|
47
|
-
|
48
|
-
|
48
|
+
before(:all) do
|
49
|
+
@classes_source = RbGCCXML.parse(full_dir("headers/classes.h")).namespaces("classes")
|
49
50
|
end
|
50
51
|
|
51
52
|
specify "should be able to tell if a given method is static or not" do
|
52
|
-
test1 =
|
53
|
-
|
53
|
+
test1 = @classes_source.classes("Test1")
|
54
|
+
test1.methods("staticMethod").should be_static
|
54
55
|
|
55
|
-
test2 =
|
56
|
-
|
56
|
+
test2 = @classes_source.classes.find(:name => "Test2")
|
57
|
+
test2.methods("func1").should_not be_static
|
57
58
|
end
|
58
59
|
|
59
60
|
specify "should be able to tell if a given method is virtual or not" do
|
60
|
-
test4 =
|
61
|
-
|
62
|
-
|
61
|
+
test4 = @classes_source.classes("Test4")
|
62
|
+
test4.methods("func1").should be_virtual
|
63
|
+
test4.methods("func1").should_not be_purely_virtual
|
63
64
|
|
64
|
-
|
65
|
-
|
65
|
+
test4.methods("func2").should be_virtual
|
66
|
+
test4.methods("func2").should_not be_purely_virtual
|
66
67
|
|
67
|
-
|
68
|
-
|
68
|
+
test4.methods("func3").should be_virtual
|
69
|
+
test4.methods("func3").should be_purely_virtual
|
69
70
|
end
|
70
71
|
end
|
data/test/namespaces_test.rb
CHANGED
@@ -1,25 +1,25 @@
|
|
1
1
|
require "test_helper"
|
2
2
|
|
3
|
-
|
3
|
+
describe "Querying for namespaces" do
|
4
4
|
|
5
|
-
|
5
|
+
before do
|
6
6
|
@source ||= RbGCCXML.parse(full_dir("headers/namespaces.h"))
|
7
7
|
end
|
8
8
|
|
9
9
|
specify "can find a namespace" do
|
10
10
|
upper = @source.namespaces.find(:name => "upper")
|
11
|
-
upper.should
|
11
|
+
upper.should be_a_kind_of(RbGCCXML::Namespace)
|
12
12
|
|
13
13
|
inner1 = upper.namespaces("inner1")
|
14
|
-
inner1.should
|
14
|
+
inner1.should be_a_kind_of(RbGCCXML::Namespace)
|
15
15
|
inner1.name.should == "inner1"
|
16
16
|
|
17
17
|
inner2 = upper.namespaces("inner2")
|
18
|
-
inner2.should
|
18
|
+
inner2.should be_a_kind_of(RbGCCXML::Namespace)
|
19
19
|
inner2.name.should == "inner2"
|
20
20
|
|
21
21
|
nested = inner2.namespaces("nested")
|
22
|
-
nested.should
|
22
|
+
nested.should be_a_kind_of(RbGCCXML::Namespace)
|
23
23
|
nested.name.should == "nested"
|
24
24
|
end
|
25
25
|
end
|
data/test/node_test.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
require "test_helper"
|
2
2
|
|
3
|
-
|
3
|
+
describe "Qualified name generation" do
|
4
4
|
|
5
5
|
specify "for namespaces" do
|
6
6
|
source = RbGCCXML.parse(full_dir("headers/namespaces.h"))
|
@@ -41,25 +41,25 @@ context "Qualified name generation" do
|
|
41
41
|
|
42
42
|
end
|
43
43
|
|
44
|
-
|
44
|
+
describe "Misc access methods" do
|
45
45
|
|
46
46
|
specify "can tell if something is public, protected, and private" do
|
47
47
|
source = RbGCCXML.parse(full_dir("headers/misc.h"))
|
48
48
|
access = source.namespaces("misc").classes("AccessSettings")
|
49
49
|
|
50
|
-
|
51
|
-
|
52
|
-
|
50
|
+
access.methods("privateMethod").should be_private
|
51
|
+
access.methods("protectedMethod").should be_protected
|
52
|
+
access.methods("publicMethod").should be_public
|
53
53
|
end
|
54
54
|
|
55
55
|
specify "can get the full file path of a node" do
|
56
56
|
source = RbGCCXML.parse(full_dir("headers/enums.h")).namespaces("enums")
|
57
|
-
source.enumerations("TestEnum").file.should
|
57
|
+
source.enumerations("TestEnum").file.should match(%r{enums.h})
|
58
58
|
end
|
59
59
|
|
60
60
|
specify "returns nil if no file node is found" do
|
61
61
|
source = RbGCCXML.parse(full_dir("headers/enums.h")).namespaces("enums")
|
62
|
-
source.file.should
|
62
|
+
source.file.should be_nil
|
63
63
|
end
|
64
64
|
|
65
65
|
end
|
data/test/parser_test.rb
CHANGED
@@ -1,73 +1,73 @@
|
|
1
1
|
require "test_helper"
|
2
2
|
|
3
|
-
|
3
|
+
describe "Default parsing configuration" do
|
4
4
|
|
5
5
|
specify "can parse a single header file" do
|
6
|
-
|
6
|
+
lambda do
|
7
7
|
RbGCCXML.parse(full_dir("headers/Adder.h"))
|
8
|
-
end
|
8
|
+
end.should_not raise_error
|
9
9
|
end
|
10
10
|
|
11
11
|
specify "can parse a glob" do
|
12
|
-
|
12
|
+
lambda do
|
13
13
|
RbGCCXML.parse(full_dir("headers/*.hpp"))
|
14
|
-
end
|
14
|
+
end.should_not raise_error
|
15
15
|
end
|
16
16
|
|
17
17
|
specify "can parse all files in a directory" do
|
18
|
-
|
18
|
+
lambda do
|
19
19
|
RbGCCXML.parse(full_dir("headers"),
|
20
20
|
:includes => full_dir("headers/include"),
|
21
21
|
:cxxflags => "-DMUST_BE_DEFINED")
|
22
|
-
end
|
22
|
+
end.should_not raise_error
|
23
23
|
end
|
24
24
|
|
25
25
|
specify "can take an array of files" do
|
26
26
|
files = [full_dir("headers/Adder.h"),
|
27
27
|
full_dir("headers/Subtracter.hpp")]
|
28
|
-
|
28
|
+
lambda do
|
29
29
|
RbGCCXML.parse(files)
|
30
|
-
end
|
30
|
+
end.should_not raise_error
|
31
31
|
end
|
32
32
|
|
33
33
|
specify "can take an array of globs" do
|
34
34
|
files = [full_dir("headers/*.h"),
|
35
35
|
full_dir("headers/*.hpp")]
|
36
|
-
|
36
|
+
lambda do
|
37
37
|
RbGCCXML.parse(files, :includes => full_dir("headers/include"))
|
38
|
-
end
|
38
|
+
end.should_not raise_error
|
39
39
|
end
|
40
40
|
|
41
41
|
specify "should throw an error if files aren't found" do
|
42
|
-
|
42
|
+
lambda do
|
43
43
|
RbGCCXML.parse(full_dir("headers/Broken.hcc"))
|
44
|
-
end
|
44
|
+
end.should raise_error(RbGCCXML::SourceNotFoundError)
|
45
45
|
|
46
|
-
|
46
|
+
lambda do
|
47
47
|
RbGCCXML.parse(full_dir("hockers"))
|
48
|
-
end
|
48
|
+
end.should raise_error(RbGCCXML::SourceNotFoundError)
|
49
49
|
|
50
|
-
|
50
|
+
lambda do
|
51
51
|
RbGCCXML.parse(full_dir("something/*"))
|
52
|
-
end
|
52
|
+
end.should raise_error(RbGCCXML::SourceNotFoundError)
|
53
53
|
|
54
|
-
|
54
|
+
lambda do
|
55
55
|
RbGCCXML.parse([full_dir("something/*"), full_dir("anotherthing/*")])
|
56
|
-
end
|
56
|
+
end.should raise_error(RbGCCXML::SourceNotFoundError)
|
57
57
|
end
|
58
58
|
end
|
59
59
|
|
60
|
-
|
60
|
+
describe "Configurable parsing configuration" do
|
61
61
|
specify "can give extra include directories for parsing" do
|
62
62
|
found = RbGCCXML.parse full_dir("headers/with_includes.h"),
|
63
63
|
:includes => full_dir("headers/include")
|
64
|
-
found.namespaces("code").
|
64
|
+
found.namespaces("code").should_not be_nil
|
65
65
|
end
|
66
66
|
|
67
67
|
specify "can be given extra cxxflags for parsing" do
|
68
|
-
|
68
|
+
lambda do
|
69
69
|
RbGCCXML.parse full_dir("headers/requires_define.hxx"),
|
70
70
|
:cxxflags => "-DMUST_BE_DEFINED"
|
71
|
-
end
|
71
|
+
end.should_not raise_error
|
72
72
|
end
|
73
73
|
end
|
data/test/query_results_test.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
require "test_helper"
|
2
2
|
|
3
|
-
|
3
|
+
describe "Managing Query results" do
|
4
4
|
|
5
5
|
class MyObj
|
6
6
|
attr_accessor :call_me_called, :other_thingy_called
|
@@ -21,161 +21,164 @@ context "Managing Query results" do
|
|
21
21
|
q = RbGCCXML::QueryResult.new
|
22
22
|
q << obj1 << obj2
|
23
23
|
|
24
|
-
|
24
|
+
lambda do
|
25
25
|
q.call_me
|
26
26
|
q.other_thingy
|
27
|
-
end
|
27
|
+
end.should_not raise_error(NoMethodError)
|
28
28
|
|
29
|
-
|
30
|
-
|
29
|
+
obj1.call_me_called.should_not be_nil
|
30
|
+
obj1.other_thingy_called.should_not be_nil
|
31
31
|
|
32
|
-
|
33
|
-
|
32
|
+
obj2.call_me_called.should_not be_nil
|
33
|
+
obj2.other_thingy_called.should_not be_nil
|
34
34
|
|
35
|
-
|
35
|
+
lambda do
|
36
36
|
q.not_here
|
37
|
-
end
|
37
|
+
end.should raise_error(NoMethodError)
|
38
38
|
end
|
39
39
|
|
40
40
|
specify "should throw appropriately with an empty result set" do
|
41
|
-
|
41
|
+
lambda do
|
42
42
|
RbGCCXML::QueryResult.new.some_method
|
43
|
-
end
|
43
|
+
end.should raise_error(NoMethodError)
|
44
44
|
end
|
45
45
|
|
46
46
|
specify "should error out with unknown keys" do
|
47
|
-
|
47
|
+
lambda do
|
48
48
|
RbGCCXML::QueryResult.new.find(:key_bad => :hi_mom)
|
49
|
-
end
|
49
|
+
end.should raise_error
|
50
50
|
end
|
51
51
|
|
52
52
|
end
|
53
53
|
|
54
|
-
|
54
|
+
describe "QueryResult#find :name" do
|
55
55
|
|
56
|
-
|
57
|
-
|
56
|
+
before(:all) do
|
57
|
+
@query_source = RbGCCXML.parse(full_dir("headers/queryable.h")).namespaces("query")
|
58
58
|
end
|
59
59
|
|
60
60
|
specify "can find by regular name" do
|
61
|
-
func =
|
62
|
-
func.should
|
61
|
+
func = @query_source.functions.find(:name => "test4")
|
62
|
+
func.should be_a_kind_of(RbGCCXML::Function)
|
63
63
|
func.name.should == "test4"
|
64
64
|
end
|
65
65
|
|
66
66
|
specify "can find names by regex" do
|
67
|
-
bool =
|
68
|
-
bool.should
|
67
|
+
bool = @query_source.functions.find(:name => /bool/)
|
68
|
+
bool.should be_a_kind_of(RbGCCXML::Function)
|
69
69
|
bool.name.should == "bool_method"
|
70
70
|
end
|
71
71
|
|
72
72
|
end
|
73
73
|
|
74
|
-
|
74
|
+
describe "QueryResult#find :arguments" do
|
75
75
|
|
76
|
-
|
77
|
-
|
76
|
+
before(:all) do
|
77
|
+
@query_source = RbGCCXML.parse(full_dir("headers/queryable.h")).namespaces("query")
|
78
78
|
end
|
79
79
|
|
80
80
|
specify "no arguments" do
|
81
|
-
funcs =
|
82
|
-
|
83
|
-
|
81
|
+
funcs = @query_source.functions.find(:arguments => [])
|
82
|
+
funcs.detect {|f| f.name == "test1" }.should_not be_nil
|
83
|
+
funcs.detect {|f| f.name == "bool_method" }.should_not be_nil
|
84
84
|
end
|
85
85
|
|
86
86
|
specify "multiple arguments" do
|
87
87
|
# If we find just one result, we get it back
|
88
|
-
func =
|
89
|
-
|
88
|
+
func = @query_source.functions.find(:arguments => [:int])
|
89
|
+
func.should be_a_kind_of(RbGCCXML::Function)
|
90
90
|
func.name.should == "test2"
|
91
91
|
|
92
|
-
func =
|
93
|
-
|
92
|
+
func = @query_source.functions.find(:arguments => [:int, :float])
|
93
|
+
func.should be_a_kind_of(RbGCCXML::Function)
|
94
94
|
func.name.should == "test3"
|
95
95
|
end
|
96
96
|
|
97
97
|
specify "when searching arguments, can xspecify catch-all" do
|
98
|
-
funcs =
|
98
|
+
funcs = @query_source.functions.find(:arguments => [:int, nil])
|
99
99
|
funcs.size.should == 2
|
100
|
-
|
101
|
-
|
100
|
+
funcs.detect {|f| f.name == "test3" }.should_not be_nil
|
101
|
+
funcs.detect {|f| f.name == "test4" }.should_not be_nil
|
102
102
|
end
|
103
103
|
|
104
104
|
specify "works when using custom defined types" do
|
105
|
-
func =
|
106
|
-
func.name.should
|
105
|
+
func = @query_source.functions.find(:arguments => ["MyType"])
|
106
|
+
func.name.should == "testMyTypeArgs"
|
107
107
|
end
|
108
108
|
|
109
109
|
specify "works with pointers and references" do
|
110
|
-
func =
|
111
|
-
func.length.should
|
110
|
+
func = @query_source.functions.find(:arguments => ["MyType*"])
|
111
|
+
func.length.should == 2
|
112
112
|
|
113
|
-
func =
|
113
|
+
func = @query_source.functions.find(:arguments => ["MyType&"])
|
114
114
|
func.name.should == "testMyTypeArgsRef"
|
115
115
|
end
|
116
116
|
|
117
117
|
specify "works with qualified names" do
|
118
|
-
func =
|
119
|
-
func.name.should
|
118
|
+
func = @query_source.functions.find(:arguments => ["query::MyType"])
|
119
|
+
func.name.should == "testMyTypeArgs"
|
120
120
|
|
121
|
-
func =
|
122
|
-
func.name.should
|
121
|
+
func = @query_source.functions.find(:arguments => ["::query::MyType"])
|
122
|
+
func.name.should == "testMyTypeArgs"
|
123
123
|
end
|
124
124
|
|
125
125
|
specify "works with qualifiers like const" do
|
126
|
-
func =
|
126
|
+
func = @query_source.functions.find(:arguments => ["const MyType* const"])
|
127
|
+
func.name.should == "testConstMyTypeArgsConstPtr"
|
128
|
+
|
129
|
+
func = @query_source.functions.find(:arguments => ["MyType* const"])
|
130
|
+
func.name.should == "testConstMyTypeArgsConstPtr"
|
131
|
+
|
132
|
+
func = @query_source.functions.find(:arguments => ["const MyType*"])
|
127
133
|
func.name.should == "testMyTypeArgsConstPtr"
|
128
134
|
end
|
129
135
|
end
|
130
136
|
|
131
|
-
|
137
|
+
describe "QueryResult#find :returns" do
|
132
138
|
|
133
|
-
|
134
|
-
|
139
|
+
before(:all) do
|
140
|
+
@query_source = RbGCCXML.parse(full_dir("headers/queryable.h")).namespaces("query")
|
135
141
|
end
|
136
142
|
|
137
143
|
specify "by return type" do
|
138
|
-
funcs =
|
139
|
-
|
140
|
-
|
141
|
-
|
144
|
+
funcs = @query_source.functions.find(:returns => :void)
|
145
|
+
funcs.detect {|f| f.name == "test1" }.should_not be_nil
|
146
|
+
funcs.detect {|f| f.name == "test2" }.should_not be_nil
|
147
|
+
funcs.detect {|f| f.name == "test3" }.should_not be_nil
|
142
148
|
end
|
143
149
|
|
144
150
|
specify "works with custom defined types" do
|
145
|
-
func =
|
146
|
-
func.length.should
|
151
|
+
func = @query_source.functions.find(:returns => "MyType")
|
152
|
+
func.length.should == 2
|
147
153
|
end
|
148
154
|
|
149
155
|
specify "work with qualified names" do
|
150
|
-
func =
|
151
|
-
func.length.should
|
156
|
+
func = @query_source.functions.find(:returns => "query::MyType")
|
157
|
+
func.length.should == 2
|
152
158
|
|
153
|
-
func =
|
154
|
-
func.length.should
|
159
|
+
func = @query_source.functions.find(:returns => "::query::MyType")
|
160
|
+
func.length.should == 2
|
155
161
|
end
|
156
162
|
|
157
163
|
specify "works with pointers and references" do
|
158
|
-
func =
|
164
|
+
func = @query_source.functions.find(:returns => "MyType*")
|
159
165
|
func.name.should == "testMyTypePtr"
|
160
166
|
|
161
|
-
func =
|
167
|
+
func = @query_source.functions.find(:returns => "MyType&")
|
162
168
|
func.name.should == "testMyTypeRef"
|
163
169
|
end
|
164
170
|
|
165
171
|
specify "works with type modifiers (const)" do
|
166
|
-
func =
|
172
|
+
func = @query_source.functions.find(:returns => "const MyType")
|
167
173
|
func.name.should == "testMyTypeConst"
|
168
174
|
end
|
169
175
|
end
|
170
176
|
|
171
|
-
|
172
|
-
|
173
|
-
setup do
|
174
|
-
@@query_source ||= RbGCCXML.parse(full_dir("headers/queryable.h")).namespaces("query")
|
175
|
-
end
|
177
|
+
describe "QueryResult#find access type" do
|
176
178
|
|
177
179
|
specify "can find according to public / private / protected" do
|
178
|
-
|
180
|
+
@query_source = RbGCCXML.parse(full_dir("headers/queryable.h")).namespaces("query")
|
181
|
+
klass = @query_source.classes("AccessTester")
|
179
182
|
m = klass.methods.find(:access => :public)
|
180
183
|
m.name.should == "publicMethod"
|
181
184
|
|
@@ -188,42 +191,39 @@ context "QueryResult#find access type" do
|
|
188
191
|
|
189
192
|
end
|
190
193
|
|
191
|
-
|
192
|
-
|
193
|
-
setup do
|
194
|
-
@@query_source ||= RbGCCXML.parse(full_dir("headers/queryable.h")).namespaces("query")
|
195
|
-
end
|
194
|
+
describe "QueryResult#find multiple options" do
|
196
195
|
|
197
196
|
specify "by both return type and arguments (AND form, not OR)" do
|
198
|
-
|
199
|
-
|
197
|
+
@query_source = RbGCCXML.parse(full_dir("headers/queryable.h")).namespaces("query")
|
198
|
+
func = @query_source.functions.find(:returns => :int, :arguments => [nil, nil])
|
199
|
+
func.should be_a_kind_of(RbGCCXML::Function)
|
200
200
|
func.name.should == "test4"
|
201
201
|
end
|
202
202
|
|
203
203
|
end
|
204
204
|
|
205
|
-
|
205
|
+
describe "QueryResult#find :all - Flag full source search" do
|
206
206
|
|
207
|
-
|
208
|
-
|
207
|
+
before(:all) do
|
208
|
+
@query_source = RbGCCXML.parse(full_dir("headers/queryable.h")).namespaces("query")
|
209
209
|
end
|
210
210
|
|
211
211
|
specify "can find all :names regardless of nesting" do
|
212
|
-
func =
|
212
|
+
func = @query_source.functions.find(:all, :name => "nestedFunction")
|
213
213
|
func.name.should == "nestedFunction"
|
214
214
|
end
|
215
215
|
|
216
216
|
specify "can find according to :arguments" do
|
217
|
-
func =
|
217
|
+
func = @query_source.functions.find(:all, :arguments => ["MyType", "MyType"])
|
218
218
|
func.name.should == "nestedMyTypeArg"
|
219
219
|
end
|
220
220
|
|
221
221
|
specify "can find according to :returns " do
|
222
|
-
funcs =
|
222
|
+
funcs = @query_source.functions.find(:all, :returns => "MyType")
|
223
223
|
funcs.size.should == 3
|
224
|
-
|
225
|
-
|
226
|
-
|
224
|
+
funcs.detect {|f| f.name == "nestedMyTypeReturns"}.should_not be_nil
|
225
|
+
funcs.detect {|f| f.name == "testMyType"}.should_not be_nil
|
226
|
+
funcs.detect {|f| f.name == "testMyTypeConst"}.should_not be_nil
|
227
227
|
end
|
228
228
|
|
229
229
|
end
|