rbgccxml 1.0.4 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 699364de9e76fc6e26e91c47c8e643830951ce53
4
- data.tar.gz: b399c4678cc389452d0b80ac6b413d9bd60e0ea3
3
+ metadata.gz: 7d57c734fb4b59009c8097e88aa691c5ff32cd92
4
+ data.tar.gz: 7fd21e9bb073cb3cdbcae2aefba5ed61fa346601
5
5
  SHA512:
6
- metadata.gz: 14d9c3f05f8add667664d04fa87407c4c79b53455e94bb1e8bad5c139ea2e49ff82dcdd15ff4ee96b1d19a2865ab197de75ef4ea42d58aa58116f2bada74b73e
7
- data.tar.gz: 597c82458bb5fb5b5955a66b4d9f7d73b32636db7fd2e28a766ffe39542f5ab7d9ba8e5e1d81b302e58c6807a267190401907766d5e17802901997460604ccf7
6
+ metadata.gz: a2e03bafc175cdf11d2ef4ebfcf23c9d1c2520df2c838fba024b208152f138c6b95b1d5ca83d6e48c269b61f896e6373e549d070dc15ebb425cc4b54ed949086
7
+ data.tar.gz: 0a7aeff311c0b8ad0787ad38d92aacfe35e83f8e3c11112ac047f4ecde65fff5235b3828b42f3a095d2cb23750add6f33ff4be5c3e072077f85b2658d5c0c2ba
data/Rakefile CHANGED
@@ -1,5 +1,4 @@
1
1
  require 'rdoc/task'
2
- require 'rake/contrib/sshpublisher'
3
2
 
4
3
  require 'rspec/core/rake_task'
5
4
 
@@ -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
- cmd = "#{@exe} #{includes} #{flags} #{header_file} -fxml=#{to_file}"
25
- raise "Error executing gccxml command line: #{cmd}" unless system(cmd)
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 = "gccxml#{ext}"
47
+ binary = @castxml_path || "castxml#{ext}"
37
48
 
38
- if `#{binary} --version 2>&1` =~ /GCC-XML/
49
+ if `#{binary} --version 2>&1` =~ /CastXML/
39
50
  binary
40
51
  else
41
- raise "Unable to find the gccxml executable on your PATH."
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
@@ -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 GCC-XML. This class
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
  #
@@ -1,6 +1,6 @@
1
1
  module RbGCCXML
2
2
 
3
- # Manager of the tree of Nodes we build from GCC-XML.
3
+ # Manager of the tree of Nodes we build from CastXML.
4
4
  #
5
5
  # This is a static class that keeps around references to the
6
6
  # entire generated Node tree as well as other structures
@@ -19,9 +19,9 @@ module RbGCCXML
19
19
  # };
20
20
  #
21
21
  def anonymous?
22
- # The given GCC-XML name of an anon Enum is _[number]. We don't care what
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
@@ -2,7 +2,7 @@ module RbGCCXML
2
2
 
3
3
  # Node that represents <ArrayType>, which is any static array
4
4
  # declaration.
5
- # One oddity on how GCC-XML parses certain array designations:
5
+ # One oddity on how CastXML parses certain array designations:
6
6
  #
7
7
  # void func(int in[4][3]);
8
8
  #
@@ -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 GCC-XML.
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 GCC-XML.
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 GCC-XML
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
@@ -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
- # This method must be called *after* any calls to RbGCCXML.gccxml_path=
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 GCC-XML file.
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)
@@ -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.h")).namespaces("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.0e+0"
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()"
@@ -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.h")).namespaces("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 be_false
80
- test4.pure_virtual?.should be_true
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.h")).namespaces("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[0]
103
- copy.artificial?.should be_true
102
+ copy = test2.constructors.detect {|c| c.artificial? }
103
+ copy.should_not be_nil
104
104
 
105
- default = test2.constructors[1]
106
- default.arguments.size.should == 0
105
+ default = test2.constructors.detect {|c| c.arguments.size == 0 }
106
+ default.should_not be_nil
107
107
 
108
- specific = test2.constructors[2]
109
- specific.arguments.size.should == 1
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.h")).namespaces("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 be_false
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 be_true
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.h")).namespaces("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.h")).namespaces("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
@@ -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.h")).namespaces("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.h")).namespaces("types")
5
+ @fp_source = RbGCCXML.parse(full_dir("headers/types.hpp")).namespaces("types")
6
6
  end
7
7
 
8
8
  specify "have arguments" do
@@ -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.h")).namespaces("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
@@ -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.h")).namespaces("classes")
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.h")).namespaces("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
@@ -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.h"))
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
@@ -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.h"))
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.h")).namespaces("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.h")).namespaces("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.h")).namespaces("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.h"))
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.h")).namespaces("enums")
57
- source.enumerations("TestEnum").file.should match(%r{enums.h})
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.h")).namespaces("enums")
61
+ source = RbGCCXML.parse(full_dir("headers/enums.hpp")).namespaces("enums")
62
62
  source.file.should be_nil
63
63
  end
64
64
 
@@ -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
- lambda do
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
- lambda do
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
- lambda do
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
- lambda do
25
- RbGCCXML.parse(full_dir("headers"),
26
- :includes => full_dir("headers/include"),
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.h"),
24
+ files = [full_dir("headers/Adder.hpp"),
33
25
  full_dir("headers/Subtracter.hpp")]
34
- lambda do
35
- RbGCCXML.parse(files)
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/*.h"),
41
- full_dir("headers/*.hpp")]
42
- lambda do
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.h"),
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
- :cxxflags => "-DMUST_BE_DEFINED"
77
- end.should_not raise_error
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.h")).namespaces("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
@@ -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.h")).namespaces("query")
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.h")).namespaces("query")
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.h")).namespaces("query")
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.h")).namespaces("query")
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.h")).namespaces("query")
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.h")).namespaces("query")
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
@@ -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.h")).namespaces("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.h")).namespaces("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
@@ -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
@@ -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.h")).namespaces("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.should == "std::size_t arg"
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.h")).namespaces("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.h")).namespaces("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
@@ -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.h")).namespaces("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
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: 2014-05-05 00:00:00.000000000 Z
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.2.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/arguments_test.rb
119
- - spec/classes_test.rb
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/test_helper.rb
118
+ - spec/classes_test.rb
131
119
  - spec/types_test.rb
132
- - spec/variables_test.rb
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