rbgccxml 1.0.4 → 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.
- checksums.yaml +4 -4
- data/Rakefile +0 -1
- data/lib/gccxml.rb +43 -10
- data/lib/rbgccxml/node.rb +1 -1
- data/lib/rbgccxml/node_cache.rb +1 -1
- data/lib/rbgccxml/nodes/enumeration.rb +2 -2
- data/lib/rbgccxml/nodes/types/array_type.rb +1 -1
- data/lib/rbgccxml/parser.rb +11 -3
- data/lib/rbgccxml/rbgccxml.rb +8 -5
- data/spec/arguments_test.rb +2 -2
- data/spec/classes_test.rb +15 -15
- data/spec/enumerations_test.rb +6 -6
- data/spec/function_pointers_test.rb +1 -1
- data/spec/functions_test.rb +1 -1
- data/spec/methods_test.rb +2 -2
- data/spec/namespaces_test.rb +2 -2
- data/spec/node_test.rb +15 -15
- data/spec/parser_test.rb +27 -26
- data/spec/pointer_to_member_test.rb +1 -1
- data/spec/query_results_test.rb +8 -8
- data/spec/structs_test.rb +2 -2
- data/spec/test_helper.rb +5 -0
- data/spec/types_test.rb +14 -13
- data/spec/variables_test.rb +1 -1
- metadata +13 -19
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7d57c734fb4b59009c8097e88aa691c5ff32cd92
|
4
|
+
data.tar.gz: 7fd21e9bb073cb3cdbcae2aefba5ed61fa346601
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a2e03bafc175cdf11d2ef4ebfcf23c9d1c2520df2c838fba024b208152f138c6b95b1d5ca83d6e48c269b61f896e6373e549d070dc15ebb425cc4b54ed949086
|
7
|
+
data.tar.gz: 0a7aeff311c0b8ad0787ad38d92aacfe35e83f8e3c11112ac047f4ecde65fff5235b3828b42f3a095d2cb23750add6f33ff4be5c3e072077f85b2658d5c0c2ba
|
data/Rakefile
CHANGED
data/lib/gccxml.rb
CHANGED
@@ -1,9 +1,11 @@
|
|
1
1
|
class GCCXML
|
2
2
|
|
3
3
|
def initialize()
|
4
|
-
@exe = find_exe.strip.chomp
|
5
4
|
@includes = []
|
6
5
|
@flags = []
|
6
|
+
|
7
|
+
@castxml_path = nil
|
8
|
+
@clangpp_path = nil
|
7
9
|
end
|
8
10
|
|
9
11
|
# Add an include path for parsing
|
@@ -16,30 +18,61 @@ class GCCXML
|
|
16
18
|
@flags << flags
|
17
19
|
end
|
18
20
|
|
21
|
+
# Set the full path to the `castxml` binary
|
22
|
+
def set_castxml_path(path)
|
23
|
+
@castxml_path = path
|
24
|
+
end
|
25
|
+
|
26
|
+
# Set the full path to the `clang++` binary
|
27
|
+
def set_clangpp_path(path)
|
28
|
+
@clangpp_path = path
|
29
|
+
end
|
30
|
+
|
19
31
|
# Run gccxml on the header file(s), sending the output to the passed in
|
20
32
|
# file.
|
21
33
|
def parse(header_file, to_file)
|
22
34
|
includes = @includes.flatten.uniq.map {|i| "-I#{i.chomp}"}.join(" ").chomp
|
23
35
|
flags = @flags.flatten.join(" ").chomp
|
24
|
-
|
25
|
-
|
36
|
+
flags += " -Wno-unused-command-line-argument --castxml-cc-gnu #{find_clang} --castxml-gccxml"
|
37
|
+
|
38
|
+
exe = find_exe.strip.chomp
|
39
|
+
cmd = "#{exe} #{includes} #{flags} -o #{to_file} #{header_file}"
|
40
|
+
raise "Error executing castxml command line: #{cmd}" unless system(cmd)
|
26
41
|
end
|
27
42
|
|
28
43
|
private
|
29
44
|
|
30
|
-
def windows?
|
31
|
-
RUBY_PLATFORM =~ /(mswin|cygwin)/
|
32
|
-
end
|
33
|
-
|
34
45
|
def find_exe
|
35
46
|
ext = windows? ? ".exe" : ""
|
36
|
-
binary = "
|
47
|
+
binary = @castxml_path || "castxml#{ext}"
|
37
48
|
|
38
|
-
if `#{binary} --version 2>&1` =~ /
|
49
|
+
if `#{binary} --version 2>&1` =~ /CastXML/
|
39
50
|
binary
|
40
51
|
else
|
41
|
-
|
52
|
+
path_msg =
|
53
|
+
if @castxml_path
|
54
|
+
"at #{@castxml_path}"
|
55
|
+
else
|
56
|
+
"on your PATH"
|
57
|
+
end
|
58
|
+
|
59
|
+
error_msg = "Unable to find a castxml executable #{path_msg}."
|
60
|
+
error_msg += "\nYou can set an explicit path with the `castxml_path` option to RbGCCXML.parse"
|
61
|
+
|
62
|
+
raise error_msg
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
def find_clang
|
67
|
+
if @clangpp_path
|
68
|
+
@clangpp_path
|
69
|
+
else
|
70
|
+
`which clang++`.strip
|
42
71
|
end
|
43
72
|
end
|
44
73
|
|
74
|
+
def windows?
|
75
|
+
RUBY_PLATFORM =~ /(mswin|cygwin)/
|
76
|
+
end
|
77
|
+
|
45
78
|
end
|
data/lib/rbgccxml/node.rb
CHANGED
@@ -3,7 +3,7 @@ module RbGCCXML
|
|
3
3
|
class NotQueryableException < RuntimeError; end
|
4
4
|
class UnsupportedMatcherException < RuntimeError; end
|
5
5
|
|
6
|
-
# A Node is part of the C++ code as dictated by
|
6
|
+
# A Node is part of the C++ code as dictated by CastXML. This class
|
7
7
|
# defines all of the starting points into the querying system, along
|
8
8
|
# with helper methods to access data from the C++ code itself.
|
9
9
|
#
|
data/lib/rbgccxml/node_cache.rb
CHANGED
@@ -19,9 +19,9 @@ module RbGCCXML
|
|
19
19
|
# };
|
20
20
|
#
|
21
21
|
def anonymous?
|
22
|
-
# The given
|
22
|
+
# The given CastXML name of an anon Enum is _[number]. We don't care what
|
23
23
|
# that number is, only that the name matches this format
|
24
|
-
self.name =~ /_\d+/
|
24
|
+
self.name =~ /_\d+/ || self.name == ""
|
25
25
|
end
|
26
26
|
|
27
27
|
end
|
data/lib/rbgccxml/parser.rb
CHANGED
@@ -20,6 +20,14 @@ module RbGCCXML
|
|
20
20
|
@gccxml.add_cxxflags flags
|
21
21
|
end
|
22
22
|
|
23
|
+
if path = config.delete(:castxml_path)
|
24
|
+
@gccxml.set_castxml_path path
|
25
|
+
end
|
26
|
+
|
27
|
+
if path = config.delete(:clangpp_path)
|
28
|
+
@gccxml.set_clangpp_path path
|
29
|
+
end
|
30
|
+
|
23
31
|
validate_glob(config[:files])
|
24
32
|
end
|
25
33
|
end
|
@@ -27,14 +35,14 @@ module RbGCCXML
|
|
27
35
|
# Starts the parsing process. If the parser was configured
|
28
36
|
# with one or more header files, this includes:
|
29
37
|
# 1. Creating a temp file for the resulting XML.
|
30
|
-
# 2. Finding all the files to run through
|
38
|
+
# 2. Finding all the files to run through CastXML
|
31
39
|
# 3. If applicable (more than one header was specified),
|
32
40
|
# build another temp file and #include the header files
|
33
|
-
# to ensure one and only one pass into
|
41
|
+
# to ensure one and only one pass into CastXML.
|
34
42
|
# 4. Build up our :: Namespace node and pass that back
|
35
43
|
# to the user for querying.
|
36
44
|
#
|
37
|
-
# If the parser was configured for pregenerated
|
45
|
+
# If the parser was configured for pregenerated CastXML
|
38
46
|
# output, we only have to perform step 4 above.
|
39
47
|
def parse
|
40
48
|
if @gccxml
|
data/lib/rbgccxml/rbgccxml.rb
CHANGED
@@ -3,11 +3,9 @@ module RbGCCXML
|
|
3
3
|
|
4
4
|
class << self
|
5
5
|
|
6
|
-
# Starting point to any RbGCCXML parsing project.
|
6
|
+
# Starting point to any RbGCCXML parsing project.
|
7
7
|
#
|
8
|
-
#
|
9
|
-
# or RbGCCXML.add_include_paths. Files can be one of many formats
|
10
|
-
# (and should always be full directory paths):
|
8
|
+
# Files can be one of many formats (and should always be full directory paths):
|
11
9
|
#
|
12
10
|
# <tt>"/path/to/file.h"</tt>
|
13
11
|
#
|
@@ -19,6 +17,11 @@ module RbGCCXML
|
|
19
17
|
#
|
20
18
|
# includes: A single string, or an array of strings of directory includes (-I directives)
|
21
19
|
# cxxflags: A single string, or an array of strings of other command line flags
|
20
|
+
# castxml_path: An explicit path to your castxml binary
|
21
|
+
# clangpp_path: An explicit path to your clang++ binary
|
22
|
+
#
|
23
|
+
# RbGCCXML will try to find both the clang++ and castxml binaries automatically,
|
24
|
+
# but if this is not working, these two options are available to give the actual path.
|
22
25
|
#
|
23
26
|
# Returns the Namespace Node linked to the global namespace "::".
|
24
27
|
def parse(files, options = {})
|
@@ -27,7 +30,7 @@ module RbGCCXML
|
|
27
30
|
@parser.parse
|
28
31
|
end
|
29
32
|
|
30
|
-
# Use this call to parse a pregenerated
|
33
|
+
# Use this call to parse a pregenerated CastXML file.
|
31
34
|
#
|
32
35
|
# Returns the Namespace Node linked to the global namespace "::".
|
33
36
|
def parse_xml(filename)
|
data/spec/arguments_test.rb
CHANGED
@@ -3,7 +3,7 @@ require "test_helper"
|
|
3
3
|
describe "Function and Method Arguments" do
|
4
4
|
|
5
5
|
before(:all) do
|
6
|
-
@arguments_source = RbGCCXML.parse(full_dir("headers/functions.
|
6
|
+
@arguments_source = RbGCCXML.parse(full_dir("headers/functions.hpp")).namespaces("functions")
|
7
7
|
end
|
8
8
|
|
9
9
|
specify "have type and to_cpp" do
|
@@ -20,7 +20,7 @@ describe "Function and Method Arguments" do
|
|
20
20
|
specify "can have a default value" do
|
21
21
|
test1 = @arguments_source.functions("test1")
|
22
22
|
test1.arguments[0].value.should be_nil
|
23
|
-
test1.arguments[1].value.should == "3.
|
23
|
+
test1.arguments[1].value.should == "3."
|
24
24
|
|
25
25
|
rockin = @arguments_source.functions("rockin")
|
26
26
|
rockin.arguments[1].value.should == "functions::test()"
|
data/spec/classes_test.rb
CHANGED
@@ -2,7 +2,7 @@ require "test_helper"
|
|
2
2
|
|
3
3
|
describe "Querying for classes" do
|
4
4
|
before do
|
5
|
-
@source ||= RbGCCXML.parse(full_dir("headers/classes.
|
5
|
+
@source ||= RbGCCXML.parse(full_dir("headers/classes.hpp")).namespaces("classes")
|
6
6
|
end
|
7
7
|
|
8
8
|
specify "can find all classes in a given namespace" do
|
@@ -76,14 +76,14 @@ describe "Querying for classes" do
|
|
76
76
|
test1 = @source.classes("Test1")
|
77
77
|
test4 = @source.classes("Test4")
|
78
78
|
|
79
|
-
test1.pure_virtual?.should
|
80
|
-
test4.pure_virtual?.should
|
79
|
+
test1.pure_virtual?.should == false
|
80
|
+
test4.pure_virtual?.should == true
|
81
81
|
end
|
82
82
|
end
|
83
83
|
|
84
84
|
describe "Querying for class constructors" do
|
85
85
|
before do
|
86
|
-
@source ||= RbGCCXML.parse(full_dir("headers/classes.
|
86
|
+
@source ||= RbGCCXML.parse(full_dir("headers/classes.hpp")).namespaces("classes")
|
87
87
|
end
|
88
88
|
|
89
89
|
specify "should have a list of constructors" do
|
@@ -99,38 +99,38 @@ describe "Querying for class constructors" do
|
|
99
99
|
test2.constructors.size.should == 3
|
100
100
|
|
101
101
|
# GCC generated copy constructors
|
102
|
-
copy = test2.constructors
|
103
|
-
copy.
|
102
|
+
copy = test2.constructors.detect {|c| c.artificial? }
|
103
|
+
copy.should_not be_nil
|
104
104
|
|
105
|
-
default = test2.constructors
|
106
|
-
default.
|
105
|
+
default = test2.constructors.detect {|c| c.arguments.size == 0 }
|
106
|
+
default.should_not be_nil
|
107
107
|
|
108
|
-
specific = test2.constructors
|
109
|
-
specific.
|
108
|
+
specific = test2.constructors.detect {|c| c.arguments.size == 1 }
|
109
|
+
specific.should_not be_nil
|
110
110
|
specific.arguments[0].cpp_type.name.should == "int"
|
111
111
|
end
|
112
112
|
end
|
113
113
|
|
114
114
|
describe "Querying for the class's deconstructor" do
|
115
115
|
before do
|
116
|
-
@source ||= RbGCCXML.parse(full_dir("headers/classes.
|
116
|
+
@source ||= RbGCCXML.parse(full_dir("headers/classes.hpp")).namespaces("classes")
|
117
117
|
end
|
118
118
|
|
119
119
|
specify "can tell if a class has an explicit destructor" do
|
120
120
|
test1 = @source.classes("Test1")
|
121
121
|
test1.destructor.should_not be_nil
|
122
|
-
test1.destructor.artificial?.should
|
122
|
+
test1.destructor.artificial?.should == false
|
123
123
|
|
124
124
|
test2 = @source.classes("Test2")
|
125
125
|
test2.destructor.should_not be_nil
|
126
|
-
test2.destructor.artificial?.should
|
126
|
+
test2.destructor.artificial?.should == true
|
127
127
|
end
|
128
128
|
|
129
129
|
end
|
130
130
|
|
131
131
|
describe "Query for class variables" do
|
132
132
|
before do
|
133
|
-
@source ||= RbGCCXML.parse(full_dir("headers/classes.
|
133
|
+
@source ||= RbGCCXML.parse(full_dir("headers/classes.hpp")).namespaces("classes")
|
134
134
|
end
|
135
135
|
|
136
136
|
specify "find all i-vars" do
|
@@ -148,7 +148,7 @@ end
|
|
148
148
|
|
149
149
|
describe "Query inheritance heirarchy" do
|
150
150
|
before do
|
151
|
-
@source ||= RbGCCXML.parse(full_dir("headers/inheritance.
|
151
|
+
@source ||= RbGCCXML.parse(full_dir("headers/inheritance.hpp")).namespaces("inheritance")
|
152
152
|
end
|
153
153
|
|
154
154
|
specify "can find a class's superclass" do
|
data/spec/enumerations_test.rb
CHANGED
@@ -2,7 +2,7 @@ require "test_helper"
|
|
2
2
|
|
3
3
|
describe "Querying for enumerations" do
|
4
4
|
before(:all) do
|
5
|
-
@enum_source = RbGCCXML.parse(full_dir("headers/enums.
|
5
|
+
@enum_source = RbGCCXML.parse(full_dir("headers/enums.hpp")).namespaces("enums")
|
6
6
|
end
|
7
7
|
|
8
8
|
specify "can query for enumerations" do
|
@@ -28,13 +28,13 @@ describe "Querying for enumerations" do
|
|
28
28
|
specify "properly prints out fully qualified C++ identifier for enum values" do
|
29
29
|
enum = @enum_source.enumerations("TestEnum")
|
30
30
|
enum.values.length.should == 3
|
31
|
-
enum.values[0].qualified_name.should == "enums::VALUE1"
|
32
|
-
enum.values[1].qualified_name.should == "enums::VALUE2"
|
33
|
-
enum.values[2].qualified_name.should == "enums::VALUE3"
|
31
|
+
enum.values[0].qualified_name.should == "::enums::VALUE1"
|
32
|
+
enum.values[1].qualified_name.should == "::enums::VALUE2"
|
33
|
+
enum.values[2].qualified_name.should == "::enums::VALUE3"
|
34
34
|
|
35
35
|
enum = @enum_source.classes("Inner").enumerations("InnerEnum")
|
36
|
-
enum.values[0].qualified_name.should == "enums::Inner::INNER_1"
|
37
|
-
enum.values[1].qualified_name.should == "enums::Inner::INNER_2"
|
36
|
+
enum.values[0].qualified_name.should == "::enums::Inner::INNER_1"
|
37
|
+
enum.values[1].qualified_name.should == "::enums::Inner::INNER_2"
|
38
38
|
end
|
39
39
|
|
40
40
|
specify "knows if an enumeration is anonymous" do
|
@@ -2,7 +2,7 @@ require "test_helper"
|
|
2
2
|
|
3
3
|
describe "Function pointers" do
|
4
4
|
before(:all) do
|
5
|
-
@fp_source = RbGCCXML.parse(full_dir("headers/types.
|
5
|
+
@fp_source = RbGCCXML.parse(full_dir("headers/types.hpp")).namespaces("types")
|
6
6
|
end
|
7
7
|
|
8
8
|
specify "have arguments" do
|
data/spec/functions_test.rb
CHANGED
@@ -3,7 +3,7 @@ require "test_helper"
|
|
3
3
|
describe "Querying for functions" do
|
4
4
|
|
5
5
|
before(:all) do
|
6
|
-
@functions_source = RbGCCXML.parse(full_dir("headers/functions.
|
6
|
+
@functions_source = RbGCCXML.parse(full_dir("headers/functions.hpp")).namespaces("functions")
|
7
7
|
end
|
8
8
|
|
9
9
|
specify "should be able to find all functions" do
|
data/spec/methods_test.rb
CHANGED
@@ -2,7 +2,7 @@ require "test_helper"
|
|
2
2
|
|
3
3
|
describe "Querying for class methods" do
|
4
4
|
before(:all) do
|
5
|
-
@adder_source = RbGCCXML.parse(full_dir("headers/Adder.
|
5
|
+
@adder_source = RbGCCXML.parse(full_dir("headers/Adder.hpp")).namespaces("classes")
|
6
6
|
end
|
7
7
|
|
8
8
|
specify "should be able to get the methods on a class" do
|
@@ -46,7 +46,7 @@ end
|
|
46
46
|
|
47
47
|
describe "Properties on Methods" do
|
48
48
|
before(:all) do
|
49
|
-
@classes_source = RbGCCXML.parse(full_dir("headers/classes.
|
49
|
+
@classes_source = RbGCCXML.parse(full_dir("headers/classes.hpp")).namespaces("classes")
|
50
50
|
end
|
51
51
|
|
52
52
|
specify "should be able to tell if a given method is static or not" do
|
data/spec/namespaces_test.rb
CHANGED
@@ -3,7 +3,7 @@ require "test_helper"
|
|
3
3
|
describe "Querying for namespaces" do
|
4
4
|
|
5
5
|
before do
|
6
|
-
@source ||= RbGCCXML.parse(full_dir("headers/namespaces.
|
6
|
+
@source ||= RbGCCXML.parse(full_dir("headers/namespaces.hpp"))
|
7
7
|
end
|
8
8
|
|
9
9
|
specify "can find a namespace" do
|
@@ -26,6 +26,6 @@ describe "Querying for namespaces" do
|
|
26
26
|
specify "handles namespace aliases" do
|
27
27
|
takes_class = @source.functions.find(:name => "takes_class")
|
28
28
|
aliased_arg = takes_class.arguments.first
|
29
|
-
aliased_arg.cpp_type.to_cpp.should == "upper::inner2::NamespacedClass"
|
29
|
+
aliased_arg.cpp_type.to_cpp.should == "::upper::inner2::NamespacedClass"
|
30
30
|
end
|
31
31
|
end
|
data/spec/node_test.rb
CHANGED
@@ -3,40 +3,40 @@ require "test_helper"
|
|
3
3
|
describe "Qualified name generation" do
|
4
4
|
|
5
5
|
specify "for namespaces" do
|
6
|
-
source = RbGCCXML.parse(full_dir("headers/namespaces.
|
6
|
+
source = RbGCCXML.parse(full_dir("headers/namespaces.hpp"))
|
7
7
|
|
8
8
|
upper = source.namespaces.find(:name => "upper")
|
9
|
-
upper.qualified_name.should == "upper"
|
9
|
+
upper.qualified_name.should == "::upper"
|
10
10
|
|
11
11
|
inner2 = upper.namespaces("inner2")
|
12
|
-
inner2.qualified_name.should == "upper::inner2"
|
12
|
+
inner2.qualified_name.should == "::upper::inner2"
|
13
13
|
end
|
14
14
|
|
15
15
|
specify "for classes" do
|
16
|
-
source = RbGCCXML.parse(full_dir("headers/classes.
|
16
|
+
source = RbGCCXML.parse(full_dir("headers/classes.hpp")).namespaces("classes")
|
17
17
|
|
18
18
|
test1 = source.classes.find(:name => "Test1")
|
19
|
-
test1.qualified_name.should == "classes::Test1"
|
19
|
+
test1.qualified_name.should == "::classes::Test1"
|
20
20
|
|
21
21
|
inner1 = test1.classes("Inner1")
|
22
|
-
inner1.qualified_name.should == "classes::Test1::Inner1"
|
22
|
+
inner1.qualified_name.should == "::classes::Test1::Inner1"
|
23
23
|
|
24
24
|
inner2 = inner1.classes("Inner2")
|
25
|
-
inner2.qualified_name.should == "classes::Test1::Inner1::Inner2"
|
25
|
+
inner2.qualified_name.should == "::classes::Test1::Inner1::Inner2"
|
26
26
|
end
|
27
27
|
|
28
28
|
specify "for functions" do
|
29
|
-
source = RbGCCXML.parse(full_dir("headers/functions.
|
29
|
+
source = RbGCCXML.parse(full_dir("headers/functions.hpp")).namespaces("functions")
|
30
30
|
test1 = source.functions("test1")
|
31
|
-
test1.qualified_name.should == "functions::test1"
|
31
|
+
test1.qualified_name.should == "::functions::test1"
|
32
32
|
end
|
33
33
|
|
34
34
|
specify "for methods in classes" do
|
35
|
-
source = RbGCCXML.parse(full_dir("headers/classes.
|
35
|
+
source = RbGCCXML.parse(full_dir("headers/classes.hpp")).namespaces("classes")
|
36
36
|
inner = source.classes("Test1").classes("Inner1")
|
37
37
|
func = inner.methods("innerFunc")
|
38
38
|
|
39
|
-
func.qualified_name.should == "classes::Test1::Inner1::innerFunc"
|
39
|
+
func.qualified_name.should == "::classes::Test1::Inner1::innerFunc"
|
40
40
|
end
|
41
41
|
|
42
42
|
end
|
@@ -44,7 +44,7 @@ end
|
|
44
44
|
describe "Misc access methods" do
|
45
45
|
|
46
46
|
specify "can tell if something is public, protected, and private" do
|
47
|
-
source = RbGCCXML.parse(full_dir("headers/misc.
|
47
|
+
source = RbGCCXML.parse(full_dir("headers/misc.hpp"))
|
48
48
|
access = source.namespaces("misc").classes("AccessSettings")
|
49
49
|
|
50
50
|
access.methods("privateMethod").should be_private
|
@@ -53,12 +53,12 @@ describe "Misc access methods" do
|
|
53
53
|
end
|
54
54
|
|
55
55
|
specify "can get the full file path of a node" do
|
56
|
-
source = RbGCCXML.parse(full_dir("headers/enums.
|
57
|
-
source.enumerations("TestEnum").file.should match(%r{enums.
|
56
|
+
source = RbGCCXML.parse(full_dir("headers/enums.hpp")).namespaces("enums")
|
57
|
+
source.enumerations("TestEnum").file.should match(%r{enums.hpp})
|
58
58
|
end
|
59
59
|
|
60
60
|
specify "returns nil if no file node is found" do
|
61
|
-
source = RbGCCXML.parse(full_dir("headers/enums.
|
61
|
+
source = RbGCCXML.parse(full_dir("headers/enums.hpp")).namespaces("enums")
|
62
62
|
source.file.should be_nil
|
63
63
|
end
|
64
64
|
|
data/spec/parser_test.rb
CHANGED
@@ -3,45 +3,34 @@ require "test_helper"
|
|
3
3
|
describe "Default parsing configuration" do
|
4
4
|
|
5
5
|
specify "can be given a raw XML file" do
|
6
|
-
|
7
|
-
RbGCCXML.parse_xml(full_dir("parsed/Adder.xml"))
|
8
|
-
end.should_not raise_error
|
6
|
+
RbGCCXML.parse_xml(full_dir("parsed/Adder.xml"))
|
9
7
|
end
|
10
8
|
|
11
9
|
specify "can parse a single header file" do
|
12
|
-
|
13
|
-
RbGCCXML.parse(full_dir("headers/Adder.h"))
|
14
|
-
end.should_not raise_error
|
10
|
+
RbGCCXML.parse(full_dir("headers/Adder.hpp"))
|
15
11
|
end
|
16
12
|
|
17
13
|
specify "can parse a glob" do
|
18
|
-
|
19
|
-
RbGCCXML.parse(full_dir("headers/*.hpp"))
|
20
|
-
end.should_not raise_error
|
14
|
+
RbGCCXML.parse(full_dir("headers/*.hpp"))
|
21
15
|
end
|
22
16
|
|
23
17
|
specify "can parse all files in a directory" do
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
:cxxflags => "-DMUST_BE_DEFINED")
|
28
|
-
end.should_not raise_error
|
18
|
+
RbGCCXML.parse(full_dir("headers"),
|
19
|
+
:includes => full_dir("headers/include"),
|
20
|
+
:cxxflags => "-DMUST_BE_DEFINED")
|
29
21
|
end
|
30
22
|
|
31
23
|
specify "can take an array of files" do
|
32
|
-
files = [full_dir("headers/Adder.
|
24
|
+
files = [full_dir("headers/Adder.hpp"),
|
33
25
|
full_dir("headers/Subtracter.hpp")]
|
34
|
-
|
35
|
-
|
36
|
-
end.should_not raise_error
|
26
|
+
|
27
|
+
RbGCCXML.parse(files)
|
37
28
|
end
|
38
29
|
|
39
30
|
specify "can take an array of globs" do
|
40
|
-
files = [full_dir("headers/*.
|
41
|
-
|
42
|
-
|
43
|
-
RbGCCXML.parse(files, :includes => full_dir("headers/include"))
|
44
|
-
end.should_not raise_error
|
31
|
+
files = [full_dir("headers/*.hpp")]
|
32
|
+
|
33
|
+
RbGCCXML.parse(files, :includes => full_dir("headers/include"))
|
45
34
|
end
|
46
35
|
|
47
36
|
specify "should throw an error if files aren't found" do
|
@@ -65,15 +54,27 @@ end
|
|
65
54
|
|
66
55
|
describe "Configurable parsing configuration" do
|
67
56
|
specify "can give extra include directories for parsing" do
|
68
|
-
found = RbGCCXML.parse full_dir("headers/with_includes.
|
57
|
+
found = RbGCCXML.parse full_dir("headers/with_includes.hpp"),
|
69
58
|
:includes => full_dir("headers/include")
|
70
59
|
found.namespaces("code").should_not be_nil
|
71
60
|
end
|
72
61
|
|
73
62
|
specify "can be given extra cxxflags for parsing" do
|
63
|
+
RbGCCXML.parse full_dir("headers/requires_define.hxx"),
|
64
|
+
:cxxflags => "-DMUST_BE_DEFINED"
|
65
|
+
end
|
66
|
+
|
67
|
+
specify "can give an explicit path to castxml" do
|
68
|
+
lambda do
|
69
|
+
RbGCCXML.parse full_dir("headers/requires_define.hxx"),
|
70
|
+
:castxml_path => "/not/here/castxml"
|
71
|
+
end.should raise_error(RuntimeError, %r{/not/here/castxml})
|
72
|
+
end
|
73
|
+
|
74
|
+
specify "can give an explicit path to clang++" do
|
74
75
|
lambda do
|
75
76
|
RbGCCXML.parse full_dir("headers/requires_define.hxx"),
|
76
|
-
:
|
77
|
-
end.
|
77
|
+
:clangpp_path => "/not/here/clang++"
|
78
|
+
end.should raise_error(RuntimeError, %r{/not/here/clang++})
|
78
79
|
end
|
79
80
|
end
|
@@ -3,7 +3,7 @@ require "test_helper"
|
|
3
3
|
describe "Pointer to member function or member variable" do
|
4
4
|
before(:all) do
|
5
5
|
@ptm_source = RbGCCXML.parse(
|
6
|
-
full_dir("headers/pointer_to_member.
|
6
|
+
full_dir("headers/pointer_to_member.hpp")).namespaces("pointer_to_member")
|
7
7
|
end
|
8
8
|
|
9
9
|
specify "finds the test struct" do
|
data/spec/query_results_test.rb
CHANGED
@@ -18,7 +18,7 @@ describe "Managing Query results" do
|
|
18
18
|
obj1 = MyObj.new
|
19
19
|
obj2 = MyObj.new
|
20
20
|
|
21
|
-
q = RbGCCXML::QueryResult.new
|
21
|
+
q = RbGCCXML::QueryResult.new
|
22
22
|
q << obj1 << obj2
|
23
23
|
|
24
24
|
q.call_me
|
@@ -52,7 +52,7 @@ end
|
|
52
52
|
describe "QueryResult#find :name" do
|
53
53
|
|
54
54
|
before(:all) do
|
55
|
-
@query_source = RbGCCXML.parse(full_dir("headers/queryable.
|
55
|
+
@query_source = RbGCCXML.parse(full_dir("headers/queryable.hpp")).namespaces("query")
|
56
56
|
end
|
57
57
|
|
58
58
|
specify "can find by regular name" do
|
@@ -72,7 +72,7 @@ end
|
|
72
72
|
describe "QueryResult#find :arguments" do
|
73
73
|
|
74
74
|
before(:all) do
|
75
|
-
@query_source = RbGCCXML.parse(full_dir("headers/queryable.
|
75
|
+
@query_source = RbGCCXML.parse(full_dir("headers/queryable.hpp")).namespaces("query")
|
76
76
|
end
|
77
77
|
|
78
78
|
specify "no arguments" do
|
@@ -135,7 +135,7 @@ end
|
|
135
135
|
describe "QueryResult#find :returns" do
|
136
136
|
|
137
137
|
before(:all) do
|
138
|
-
@query_source = RbGCCXML.parse(full_dir("headers/queryable.
|
138
|
+
@query_source = RbGCCXML.parse(full_dir("headers/queryable.hpp")).namespaces("query")
|
139
139
|
end
|
140
140
|
|
141
141
|
specify "by return type" do
|
@@ -175,7 +175,7 @@ end
|
|
175
175
|
describe "QueryResult#find access type" do
|
176
176
|
|
177
177
|
specify "can find according to public / private / protected" do
|
178
|
-
@query_source = RbGCCXML.parse(full_dir("headers/queryable.
|
178
|
+
@query_source = RbGCCXML.parse(full_dir("headers/queryable.hpp")).namespaces("query")
|
179
179
|
klass = @query_source.classes("AccessTester")
|
180
180
|
m = klass.methods.find(:access => :public)
|
181
181
|
m.name.should == "publicMethod"
|
@@ -192,7 +192,7 @@ end
|
|
192
192
|
describe "QueryResult#find multiple options" do
|
193
193
|
|
194
194
|
specify "by both return type and arguments (AND form, not OR)" do
|
195
|
-
@query_source = RbGCCXML.parse(full_dir("headers/queryable.
|
195
|
+
@query_source = RbGCCXML.parse(full_dir("headers/queryable.hpp")).namespaces("query")
|
196
196
|
func = @query_source.functions.find(:returns => :int, :arguments => [nil, nil])
|
197
197
|
func.should be_a_kind_of(RbGCCXML::Function)
|
198
198
|
func.name.should == "test4"
|
@@ -203,7 +203,7 @@ end
|
|
203
203
|
describe "QueryResult#find :all - Flag full source search" do
|
204
204
|
|
205
205
|
before(:all) do
|
206
|
-
@query_source = RbGCCXML.parse(full_dir("headers/queryable.
|
206
|
+
@query_source = RbGCCXML.parse(full_dir("headers/queryable.hpp")).namespaces("query")
|
207
207
|
end
|
208
208
|
|
209
209
|
specify "can find all :names regardless of nesting" do
|
@@ -215,7 +215,7 @@ describe "QueryResult#find :all - Flag full source search" do
|
|
215
215
|
func = @query_source.functions.find(:all, :arguments => ["MyType", "MyType"])
|
216
216
|
func.name.should == "nestedMyTypeArg"
|
217
217
|
end
|
218
|
-
|
218
|
+
|
219
219
|
specify "can find according to :returns " do
|
220
220
|
funcs = @query_source.functions.find(:all, :returns => "MyType")
|
221
221
|
funcs.size.should == 3
|
data/spec/structs_test.rb
CHANGED
@@ -2,7 +2,7 @@ require "test_helper"
|
|
2
2
|
|
3
3
|
describe "Querying for structs" do
|
4
4
|
before(:all) do
|
5
|
-
@structs_source = RbGCCXML.parse(full_dir("headers/structs.
|
5
|
+
@structs_source = RbGCCXML.parse(full_dir("headers/structs.hpp")).namespaces("structs")
|
6
6
|
end
|
7
7
|
|
8
8
|
specify "can find all structs in a given namespace" do
|
@@ -28,7 +28,7 @@ end
|
|
28
28
|
|
29
29
|
describe "Querying for struct constructors" do
|
30
30
|
before(:all) do
|
31
|
-
@structs_source = RbGCCXML.parse(full_dir("headers/structs.
|
31
|
+
@structs_source = RbGCCXML.parse(full_dir("headers/structs.hpp")).namespaces("structs")
|
32
32
|
end
|
33
33
|
|
34
34
|
specify "should have a list of constructors" do
|
data/spec/test_helper.rb
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
require 'rubygems'
|
2
2
|
require 'rspec'
|
3
3
|
require 'rbgccxml'
|
4
|
+
require 'pry'
|
4
5
|
|
5
6
|
module FileDirectoryHelpers
|
6
7
|
def full_dir(path)
|
@@ -10,4 +11,8 @@ end
|
|
10
11
|
|
11
12
|
RSpec.configure do |config|
|
12
13
|
config.include(FileDirectoryHelpers)
|
14
|
+
config.expect_with(:rspec) { |c| c.syntax = :should }
|
13
15
|
end
|
16
|
+
|
17
|
+
# Don't complain about blank `raise_error` usage right now
|
18
|
+
RSpec::Expectations.configuration.on_potential_false_positives = :nothing
|
data/spec/types_test.rb
CHANGED
@@ -3,14 +3,15 @@ require "test_helper"
|
|
3
3
|
describe "Proper Type handling" do
|
4
4
|
|
5
5
|
before(:all) do
|
6
|
-
@types_source = RbGCCXML.parse(full_dir("headers/types.
|
6
|
+
@types_source = RbGCCXML.parse(full_dir("headers/types.hpp")).namespaces("types")
|
7
7
|
end
|
8
8
|
|
9
9
|
specify "fundamental types" do
|
10
10
|
@types_source.functions.find(:returns => "int").length.should == 2
|
11
11
|
@types_source.functions.find(:returns => "float").name.should == "returnsFloat"
|
12
12
|
|
13
|
-
@types_source.functions("noReturnWithSizeT").arguments[0].to_cpp
|
13
|
+
output = @types_source.functions("noReturnWithSizeT").arguments[0].to_cpp
|
14
|
+
(output == "::std::size_t arg" || output == "::size_t arg").should == true
|
14
15
|
end
|
15
16
|
|
16
17
|
specify "typedefs" do
|
@@ -72,9 +73,9 @@ describe "Proper Type handling" do
|
|
72
73
|
end
|
73
74
|
|
74
75
|
describe "Printing types" do
|
75
|
-
|
76
|
+
|
76
77
|
before(:all) do
|
77
|
-
@types_source = RbGCCXML.parse(full_dir("headers/types.
|
78
|
+
@types_source = RbGCCXML.parse(full_dir("headers/types.hpp")).namespaces("types")
|
78
79
|
end
|
79
80
|
|
80
81
|
specify "types should print back properly into string format" do
|
@@ -87,30 +88,30 @@ describe "Printing types" do
|
|
87
88
|
@types_source.functions("returnsIntPointer").return_type.to_cpp.should == "int*"
|
88
89
|
|
89
90
|
# references
|
90
|
-
@types_source.functions("returnStructReference").return_type.to_cpp.should == "types::struct_type&"
|
91
|
+
@types_source.functions("returnStructReference").return_type.to_cpp.should == "::types::struct_type&"
|
91
92
|
@types_source.functions("returnStructReference").return_type.to_cpp(false).should == "struct_type&"
|
92
|
-
|
93
|
+
|
93
94
|
# printout full from the global namespace
|
94
|
-
@types_source.functions("returnsString").return_type.to_cpp.should == "others::string"
|
95
|
+
@types_source.functions("returnsString").return_type.to_cpp.should == "::others::string"
|
95
96
|
@types_source.functions("returnsString").return_type.to_cpp(false).should == "string"
|
96
97
|
|
97
98
|
# const
|
98
99
|
@types_source.functions("returnConstInt").return_type.to_cpp.should == "const int"
|
99
|
-
|
100
|
+
|
100
101
|
# const pointers
|
101
102
|
@types_source.functions("returnConstIntPointer").return_type.to_cpp.should == "const int*"
|
102
103
|
|
103
104
|
# const references
|
104
|
-
@types_source.functions("returnConstUserTypeRef").return_type.to_cpp.should == "const types::user_type&"
|
105
|
+
@types_source.functions("returnConstUserTypeRef").return_type.to_cpp.should == "const ::types::user_type&"
|
105
106
|
@types_source.functions("returnConstUserTypeRef").return_type.to_cpp(false).should == "const user_type&"
|
106
107
|
|
107
108
|
# const const
|
108
|
-
@types_source.functions("withConstPtrConst").arguments[0].to_cpp.should == "const types::user_type* const arg1"
|
109
|
+
@types_source.functions("withConstPtrConst").arguments[0].to_cpp.should == "const ::types::user_type* const arg1"
|
109
110
|
@types_source.functions("withConstPtrConst").arguments[0].to_cpp(false).should == "const user_type* const arg1"
|
110
111
|
|
111
112
|
# Enumerations
|
112
113
|
@types_source.functions("returnMyEnum").return_type.name.should == "myEnum"
|
113
|
-
@types_source.functions("returnMyEnum").return_type.to_cpp.should == "types::myEnum"
|
114
|
+
@types_source.functions("returnMyEnum").return_type.to_cpp.should == "::types::myEnum"
|
114
115
|
|
115
116
|
# Array Types
|
116
117
|
@types_source.functions("usesIntArray").arguments[0].name.should == "input"
|
@@ -126,14 +127,14 @@ describe "Printing types" do
|
|
126
127
|
@types_source.classes("user_type").variables("var1").cpp_type.name.should == "int"
|
127
128
|
@types_source.classes("user_type").variables("var2").cpp_type.name.should == "float"
|
128
129
|
|
129
|
-
@types_source.structs("struct_type").variables("myType").cpp_type.to_cpp.should == "types::user_type"
|
130
|
+
@types_source.structs("struct_type").variables("myType").cpp_type.to_cpp.should == "::types::user_type"
|
130
131
|
end
|
131
132
|
|
132
133
|
end
|
133
134
|
|
134
135
|
describe "Type comparitors" do
|
135
136
|
specify "can tell of a given type is a const" do
|
136
|
-
@types_source ||= RbGCCXML.parse(full_dir("headers/types.
|
137
|
+
@types_source ||= RbGCCXML.parse(full_dir("headers/types.hpp")).namespaces("types")
|
137
138
|
@types_source.functions("returnConstUserTypeRef").return_type.should be_const
|
138
139
|
@types_source.functions("returnConstIntPointer").return_type.should be_const
|
139
140
|
@types_source.functions("returnsUserType").return_type.should_not be_const
|
data/spec/variables_test.rb
CHANGED
@@ -3,7 +3,7 @@ require "test_helper"
|
|
3
3
|
describe "Querying for variables" do
|
4
4
|
|
5
5
|
before(:all) do
|
6
|
-
@variables_source ||= RbGCCXML.parse(full_dir("headers/classes.
|
6
|
+
@variables_source ||= RbGCCXML.parse(full_dir("headers/classes.hpp")).namespaces("classes")
|
7
7
|
end
|
8
8
|
|
9
9
|
specify "find global variables and constants" do
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rbgccxml
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0
|
4
|
+
version: 1.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jason Roelofs
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2017-10-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: nokogiri
|
@@ -17,9 +17,6 @@ dependencies:
|
|
17
17
|
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: 1.5.0
|
20
|
-
- - "<"
|
21
|
-
- !ruby/object:Gem::Version
|
22
|
-
version: 1.7.0
|
23
20
|
type: :runtime
|
24
21
|
prerelease: false
|
25
22
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -27,9 +24,6 @@ dependencies:
|
|
27
24
|
- - ">="
|
28
25
|
- !ruby/object:Gem::Version
|
29
26
|
version: 1.5.0
|
30
|
-
- - "<"
|
31
|
-
- !ruby/object:Gem::Version
|
32
|
-
version: 1.7.0
|
33
27
|
description: |
|
34
28
|
Rbgccxml is a library that parses out GCCXML (http://www.gccxml.org) output
|
35
29
|
and provides a simple but very powerful querying API for finding exactly
|
@@ -110,23 +104,23 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
110
104
|
version: '0'
|
111
105
|
requirements: []
|
112
106
|
rubyforge_project: rbplusplus
|
113
|
-
rubygems_version: 2.
|
107
|
+
rubygems_version: 2.6.13
|
114
108
|
signing_key:
|
115
109
|
specification_version: 4
|
116
110
|
summary: Ruby interface to GCCXML
|
117
111
|
test_files:
|
118
|
-
- spec/
|
119
|
-
- spec/
|
120
|
-
- spec/enumerations_test.rb
|
121
|
-
- spec/function_pointers_test.rb
|
112
|
+
- spec/variables_test.rb
|
113
|
+
- spec/node_test.rb
|
122
114
|
- spec/functions_test.rb
|
123
115
|
- spec/methods_test.rb
|
124
|
-
- spec/namespaces_test.rb
|
125
|
-
- spec/node_test.rb
|
126
|
-
- spec/parser_test.rb
|
127
|
-
- spec/pointer_to_member_test.rb
|
128
116
|
- spec/query_results_test.rb
|
129
117
|
- spec/structs_test.rb
|
130
|
-
- spec/
|
118
|
+
- spec/classes_test.rb
|
131
119
|
- spec/types_test.rb
|
132
|
-
- spec/
|
120
|
+
- spec/function_pointers_test.rb
|
121
|
+
- spec/parser_test.rb
|
122
|
+
- spec/namespaces_test.rb
|
123
|
+
- spec/test_helper.rb
|
124
|
+
- spec/arguments_test.rb
|
125
|
+
- spec/enumerations_test.rb
|
126
|
+
- spec/pointer_to_member_test.rb
|