rbgccxml 0.8 → 0.9

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.
Files changed (43) hide show
  1. data/Rakefile +5 -5
  2. data/lib/rbgccxml/node.rb +75 -73
  3. data/lib/rbgccxml/nodes/argument.rb +13 -2
  4. data/lib/rbgccxml/nodes/base.rb +14 -0
  5. data/lib/rbgccxml/nodes/class.rb +46 -8
  6. data/lib/rbgccxml/nodes/constructor.rb +8 -1
  7. data/lib/rbgccxml/nodes/destructor.rb +7 -0
  8. data/lib/rbgccxml/nodes/enum_value.rb +6 -4
  9. data/lib/rbgccxml/nodes/enumeration.rb +21 -2
  10. data/lib/rbgccxml/nodes/field.rb +18 -0
  11. data/lib/rbgccxml/nodes/file.rb +4 -1
  12. data/lib/rbgccxml/nodes/function.rb +6 -4
  13. data/lib/rbgccxml/nodes/function_type.rb +7 -0
  14. data/lib/rbgccxml/nodes/method.rb +6 -4
  15. data/lib/rbgccxml/nodes/struct.rb +3 -2
  16. data/lib/rbgccxml/nodes/type.rb +5 -3
  17. data/lib/rbgccxml/nodes/types/array_type.rb +29 -0
  18. data/lib/rbgccxml/nodes/types/cv_qualified_type.rb +9 -5
  19. data/lib/rbgccxml/nodes/types/fundamental_type.rb +3 -2
  20. data/lib/rbgccxml/nodes/types/pointer_type.rb +6 -3
  21. data/lib/rbgccxml/nodes/types/reference_type.rb +6 -3
  22. data/lib/rbgccxml/nodes/types/typedef.rb +2 -2
  23. data/lib/rbgccxml/nodes/variable.rb +7 -0
  24. data/lib/rbgccxml/parser.rb +47 -32
  25. data/lib/rbgccxml/query_result.rb +62 -25
  26. data/lib/rbgccxml/rbgccxml.rb +13 -16
  27. data/lib/rbgccxml/xml_parsing.rb +65 -97
  28. data/lib/rbgccxml.rb +26 -22
  29. data/test/arguments_test.rb +29 -0
  30. data/test/classes_test.rb +164 -26
  31. data/test/enumerations_test.rb +27 -19
  32. data/test/function_pointers_test.rb +18 -0
  33. data/test/functions_test.rb +7 -2
  34. data/test/methods_test.rb +3 -3
  35. data/test/namespaces_test.rb +1 -1
  36. data/test/node_test.rb +11 -31
  37. data/test/parser_test.rb +1 -1
  38. data/test/query_results_test.rb +15 -14
  39. data/test/structs_test.rb +10 -12
  40. data/test/test_helper.rb +10 -2
  41. data/test/types_test.rb +63 -38
  42. data/test/variables_test.rb +26 -0
  43. metadata +46 -31
data/test/test_helper.rb CHANGED
@@ -1,6 +1,14 @@
1
- $: << File.expand_path(File.dirname(__FILE__) + "/../lib")
1
+ $LOAD_PATH.unshift File.expand_path(File.join(File.dirname(__FILE__), '..', 'lib'))
2
2
 
3
3
  require 'rubygems'
4
+
5
+ begin
6
+ # 1.9 needs this for test/spec to work
7
+ gem 'test-unit'
8
+ rescue LoadError
9
+ # Probably 1.8.x, we're ok
10
+ end
11
+
4
12
  require 'test/spec'
5
13
  require 'rbgccxml'
6
14
 
@@ -13,6 +21,6 @@ class Test::Unit::TestCase
13
21
  def teardown
14
22
  RbGCCXML::XMLParsing.clear_cache
15
23
  end
16
-
24
+
17
25
  end
18
26
 
data/test/types_test.rb CHANGED
@@ -1,4 +1,4 @@
1
- require File.dirname(__FILE__) + '/test_helper'
1
+ require "test_helper"
2
2
 
3
3
  context "Proper Type handling" do
4
4
 
@@ -7,59 +7,67 @@ context "Proper Type handling" do
7
7
  end
8
8
 
9
9
  specify "fundamental types" do
10
- assert @@types_source.functions.find(:returns => "int") == "returnsInt"
11
- assert @@types_source.functions.find(:returns => "float") == "returnsFloat"
10
+ @@types_source.functions.find(:returns => "int").length.should.equal 2
11
+ @@types_source.functions.find(:returns => "float").name.should.equal "returnsFloat"
12
12
  end
13
13
 
14
14
  xspecify "unsigned fundamental types" do
15
15
  end
16
16
 
17
17
  specify "typedefs" do
18
- assert @@types_source.functions.find(:returns => "myLongType") == "returnsLongType"
19
- assert @@types_source.functions.find(:returns => "myShortType") == "returnsShortType"
18
+ @@types_source.functions.find(:returns => "myLongType").name.should.equal "returnsLongType"
19
+ @@types_source.functions.find(:returns => "myShortType").name.should.equal "returnsShortType"
20
20
  end
21
21
 
22
22
  specify "user defined types (classes / structs)" do
23
- assert @@types_source.functions.find(:returns => "user_type") == "returnsUserType"
24
- assert @@types_source.functions.find(:returns => "struct_type") == "returnsStructType"
23
+ @@types_source.functions.find(:returns => "user_type").name.should.equal "returnsUserType"
24
+ @@types_source.functions.find(:returns => "struct_type").length.should.equal 2
25
25
  end
26
26
 
27
- # Are these three necessary or can it be just one?
28
27
  specify "pointers to user defined types" do
29
- assert @@types_source.functions.find(:returns => "user_type*") == "returnsUserTypePointer"
30
- assert @@types_source.functions.find(:returns => "struct_type*") == "returnsStructTypePointer"
28
+ @@types_source.functions.find(:returns => "user_type*").name.should.equal "returnsUserTypePointer"
29
+ @@types_source.functions.find(:returns => "struct_type*").name.should.equal "returnsStructTypePointer"
31
30
  end
32
31
 
33
32
  specify "pointers to fundamental types" do
34
- assert @@types_source.functions.find(:returns => "int*") == "returnsIntPointer"
33
+ @@types_source.functions.find(:returns => "int*").length.should.equal 2
35
34
  end
36
35
 
37
36
  specify "pointers to typedefs" do
38
- assert @@types_source.functions.find(:returns => "myLongType*") == "returnsLongTypePointer"
37
+ @@types_source.functions.find(:returns => "myLongType*").name.should.equal "returnsLongTypePointer"
39
38
  end
40
39
 
41
40
  specify "reference types" do
42
- assert @@types_source.functions.find(:returns => "struct_type&") == "returnStructReference"
41
+ @@types_source.functions.find(:returns => "struct_type&").name.should.equal "returnStructReference"
43
42
  end
44
43
 
45
44
  specify "const definitions (fundamental types)" do
46
- assert @@types_source.functions.find(:returns => "const int") == "returnConstInt"
45
+ @@types_source.functions.find(:returns => "const int").name.should.equal "returnConstInt"
47
46
  end
48
47
 
49
48
  specify "const definitions (defined types)" do
50
- assert @@types_source.functions.find(:returns => "const struct_type") == "returnConstStruct"
49
+ @@types_source.functions.find(:returns => "const struct_type").name.should.equal "returnConstStruct"
51
50
  end
52
51
 
53
52
  specify "const references" do
54
- assert @@types_source.functions.find(:returns => "const user_type&") == "returnConstUserTypeRef"
53
+ @@types_source.functions.find(:returns => "const user_type&").name.should.equal "returnConstUserTypeRef"
55
54
  end
56
55
 
57
56
  specify "const pointers" do
58
- assert @@types_source.functions.find(:returns => "const int*") == "returnConstIntPointer"
57
+ @@types_source.functions.find(:returns => "const int*").name.should.equal "returnConstIntPointer"
59
58
  end
60
59
 
61
60
  specify "enumerations" do
62
- assert @@types_source.functions.find(:returns => "myEnum") == "returnMyEnum"
61
+ @@types_source.functions.find(:returns => "myEnum").name.should.equal "returnMyEnum"
62
+ end
63
+
64
+ specify "arrays" do
65
+ @@types_source.functions.find(:arguments => ["int[4]*"]).name.should.equal "usesIntArray"
66
+ end
67
+
68
+ specify "function pointers" do
69
+ @@types_source.functions.find(:arguments => ["Callback"]).name.should.equal "takesCallback"
70
+ @@types_source.functions.find(:arguments => ["CallbackWithReturn"]).name.should.equal "takesCallbackWithReturn"
63
71
  end
64
72
 
65
73
  end
@@ -71,49 +79,66 @@ context "Printing types" do
71
79
  end
72
80
 
73
81
  specify "types should print back properly into string format" do
74
- @@types_source.functions.find(:returns => "int").return_type.to_s.should == "int"
75
- @@types_source.functions.find(:returns => "int").return_type.to_s(true).should == "int"
82
+ @@types_source.functions("returnsInt").return_type.name.should == "int"
83
+ @@types_source.functions("returnsInt").return_type.to_cpp.should == "int"
76
84
 
77
- @@types_source.functions.find(:returns => "float").return_type.to_s.should == "float"
85
+ @@types_source.functions("returnsFloat").return_type.name.should == "float"
78
86
 
79
87
  # pointers
80
- @@types_source.functions.find(:returns => "int*").return_type.to_s.should == "int*"
88
+ @@types_source.functions("returnsIntPointer").return_type.to_cpp.should == "int*"
81
89
 
82
90
  # references
83
- @@types_source.functions.find(:returns => "struct_type&").return_type.to_s.should == "struct_type&"
84
- @@types_source.functions.find(:returns => "struct_type&").return_type.to_s(true).should == "types::struct_type&"
91
+ @@types_source.functions("returnStructReference").return_type.to_cpp.should == "types::struct_type&"
92
+ @@types_source.functions("returnStructReference").return_type.to_cpp(false).should == "struct_type&"
85
93
 
86
94
  # printout full from the global namespace
87
- @@types_source.functions.find(:returns => "string").return_type.to_s(true).should == "others::string"
95
+ @@types_source.functions("returnsString").return_type.to_cpp.should == "others::string"
96
+ @@types_source.functions("returnsString").return_type.to_cpp(false).should == "string"
88
97
 
89
98
  # const
90
- @@types_source.functions.find(:returns => "const int").return_type.to_s.should == "const int"
99
+ @@types_source.functions("returnConstInt").return_type.to_cpp.should == "const int"
91
100
 
92
101
  # const pointers
93
- @@types_source.functions.find(:returns => "const int*").return_type.to_s.should == "const int*"
102
+ @@types_source.functions("returnConstIntPointer").return_type.to_cpp.should == "const int*"
94
103
 
95
104
  # const references
96
- @@types_source.functions.find(:returns => "const user_type&").return_type.to_s.should == "const user_type&"
97
- @@types_source.functions.find(:returns => "const user_type&").return_type.to_s(true).should == "const types::user_type&"
105
+ @@types_source.functions("returnConstUserTypeRef").return_type.to_cpp.should == "const types::user_type&"
106
+ @@types_source.functions("returnConstUserTypeRef").return_type.to_cpp(false).should == "const user_type&"
98
107
 
99
108
  # Enumerations
100
- @@types_source.functions.find(:returns => "myEnum").return_type.to_s.should == "myEnum"
101
- @@types_source.functions.find(:returns => "myEnum").return_type.to_s(true).should == "types::myEnum"
109
+ @@types_source.functions("returnMyEnum").return_type.name.should == "myEnum"
110
+ @@types_source.functions("returnMyEnum").return_type.to_cpp.should == "types::myEnum"
111
+
112
+ # Array Types
113
+ @@types_source.functions("usesIntArray").arguments[0].name.should == "input"
114
+ @@types_source.functions("usesIntArray").arguments[0].to_cpp.should == "int[4]* input"
102
115
  end
103
116
 
104
117
  specify "can get to the base C++ construct of given types" do
105
- @@types_source.functions.find(:returns => "const user_type&").return_type.base_type.to_s.should == "user_type"
106
- @@types_source.functions.find(:returns => "const int*").return_type.base_type.to_s.should == "int"
118
+ @@types_source.functions.find(:returns => "const user_type&").return_type.base_type.name.should == "user_type"
119
+ @@types_source.functions.find(:returns => "const int*").return_type.base_type.name.should == "int"
120
+ end
121
+
122
+ specify "can get types of class ivars" do
123
+ @@types_source.classes("user_type").variables("var1").cpp_type.name.should == "int"
124
+ @@types_source.classes("user_type").variables("var2").cpp_type.name.should == "float"
125
+
126
+ @@types_source.structs("struct_type").variables("myType").cpp_type.to_cpp.should == "types::user_type"
107
127
  end
108
128
 
109
129
  end
110
130
 
111
131
  context "Type comparitors" do
132
+ setup do
133
+ @@types_source ||= RbGCCXML.parse(full_dir("headers/types.h")).namespaces("types")
134
+ end
135
+
112
136
  specify "can tell of a given type is a const" do
113
- assert @@types_source.functions.find(:returns => "const user_type&").return_type.const?
114
- assert @@types_source.functions.find(:returns => "const int*").return_type.const?
115
- assert !@@types_source.functions.find(:returns => "user_type").return_type.const?
116
- assert !@@types_source.functions.find(:returns => "string").return_type.const?
117
- assert !@@types_source.functions.find(:returns => "int").return_type.const?
137
+ assert @@types_source.functions("returnConstUserTypeRef").return_type.const?
138
+ assert @@types_source.functions("returnConstIntPointer").return_type.const?
139
+ assert !@@types_source.functions("returnsUserType").return_type.const?
140
+
141
+ assert !@@types_source.functions("returnsString").return_type.const?
142
+ assert !@@types_source.functions("returnsInt").return_type.const?
118
143
  end
119
144
  end
@@ -0,0 +1,26 @@
1
+ require "test_helper"
2
+
3
+ context "Querying for variables" do
4
+
5
+ setup do
6
+ @@variables_source ||= RbGCCXML.parse(full_dir("headers/classes.h")).namespaces("classes")
7
+ end
8
+
9
+ specify "find global variables and constants" do
10
+ @@variables_source.variables.length.should.equal 2
11
+ end
12
+
13
+ specify "find class variables" do
14
+ test1 = @@variables_source.classes("Test1")
15
+ test1.variables.length.should.equal 4
16
+ test1.variables.find(:access => :public).length.should.equal 2
17
+ assert test1.variables("publicVariable")
18
+ assert test1.variables("publicVariable2")
19
+ end
20
+
21
+ specify "can also find constants" do
22
+ test1 = @@variables_source.classes("Test1")
23
+ test1.constants.length.should.equal 1
24
+ assert test1.constants("CONST")
25
+ end
26
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rbgccxml
3
3
  version: !ruby/object:Gem::Version
4
- version: "0.8"
4
+ version: "0.9"
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jason Roelofs
@@ -9,18 +9,18 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2008-07-22 00:00:00 -04:00
12
+ date: 2009-10-22 00:00:00 -04:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
- name: hpricot
16
+ name: libxml-ruby
17
17
  type: :runtime
18
18
  version_requirement:
19
19
  version_requirements: !ruby/object:Gem::Requirement
20
20
  requirements:
21
- - - "="
21
+ - - ~>
22
22
  - !ruby/object:Gem::Version
23
- version: "0.6"
23
+ version: "1.1"
24
24
  version:
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: gccxml_gem
@@ -28,11 +28,15 @@ dependencies:
28
28
  version_requirement:
29
29
  version_requirements: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - "="
31
+ - - ~>
32
32
  - !ruby/object:Gem::Version
33
- version: 0.9.1
33
+ version: "0.9"
34
34
  version:
35
- description: Rbgccxml is a library that parses out GCCXML (http://www.gccxml.org) output and provides a simple but very powerful querying API for finding exactly what you want out of the C++ source code
35
+ description: |
36
+ Rbgccxml is a library that parses out GCCXML (http://www.gccxml.org) output
37
+ and provides a simple but very powerful querying API for finding exactly
38
+ what you want out of the C++ source code
39
+
36
40
  email: jameskilton@gmail.com
37
41
  executables: []
38
42
 
@@ -43,31 +47,39 @@ extra_rdoc_files: []
43
47
  files:
44
48
  - TODO
45
49
  - Rakefile
50
+ - lib/rbgccxml.rb
51
+ - lib/jamis.rb
52
+ - lib/rbgccxml/rbgccxml.rb
46
53
  - lib/rbgccxml/parser.rb
54
+ - lib/rbgccxml/query_result.rb
55
+ - lib/rbgccxml/node.rb
56
+ - lib/rbgccxml/xml_parsing.rb
57
+ - lib/rbgccxml/nodes/function_type.rb
58
+ - lib/rbgccxml/nodes/field.rb
59
+ - lib/rbgccxml/nodes/file.rb
60
+ - lib/rbgccxml/nodes/base.rb
47
61
  - lib/rbgccxml/nodes/types/reference_type.rb
62
+ - lib/rbgccxml/nodes/types/array_type.rb
63
+ - lib/rbgccxml/nodes/types/typedef.rb
48
64
  - lib/rbgccxml/nodes/types/cv_qualified_type.rb
49
- - lib/rbgccxml/nodes/types/fundamental_type.rb
50
65
  - lib/rbgccxml/nodes/types/pointer_type.rb
51
- - lib/rbgccxml/nodes/types/typedef.rb
52
- - lib/rbgccxml/nodes/struct.rb
53
- - lib/rbgccxml/nodes/function.rb
54
- - lib/rbgccxml/nodes/file.rb
66
+ - lib/rbgccxml/nodes/types/fundamental_type.rb
67
+ - lib/rbgccxml/nodes/argument.rb
55
68
  - lib/rbgccxml/nodes/enumeration.rb
69
+ - lib/rbgccxml/nodes/function.rb
70
+ - lib/rbgccxml/nodes/enum_value.rb
71
+ - lib/rbgccxml/nodes/variable.rb
56
72
  - lib/rbgccxml/nodes/namespace.rb
57
- - lib/rbgccxml/nodes/argument.rb
58
- - lib/rbgccxml/nodes/type.rb
73
+ - lib/rbgccxml/nodes/destructor.rb
74
+ - lib/rbgccxml/nodes/struct.rb
59
75
  - lib/rbgccxml/nodes/constructor.rb
60
76
  - lib/rbgccxml/nodes/method.rb
77
+ - lib/rbgccxml/nodes/type.rb
61
78
  - lib/rbgccxml/nodes/class.rb
62
- - lib/rbgccxml/nodes/enum_value.rb
63
- - lib/rbgccxml/query_result.rb
64
- - lib/rbgccxml/xml_parsing.rb
65
- - lib/rbgccxml/node.rb
66
- - lib/rbgccxml/rbgccxml.rb
67
- - lib/jamis.rb
68
- - lib/rbgccxml.rb
69
- has_rdoc: false
79
+ has_rdoc: true
70
80
  homepage: http://rbplusplus.rubyforge.org/rbgccxml
81
+ licenses: []
82
+
71
83
  post_install_message:
72
84
  rdoc_options: []
73
85
 
@@ -88,19 +100,22 @@ required_rubygems_version: !ruby/object:Gem::Requirement
88
100
  requirements: []
89
101
 
90
102
  rubyforge_project: rbplusplus
91
- rubygems_version: 1.2.0
103
+ rubygems_version: 1.3.5
92
104
  signing_key:
93
- specification_version: 2
105
+ specification_version: 3
94
106
  summary: Ruby interface to GCCXML
95
107
  test_files:
96
- - test/classes_test.rb
97
- - test/node_test.rb
108
+ - test/enumerations_test.rb
109
+ - test/query_results_test.rb
98
110
  - test/methods_test.rb
99
- - test/structs_test.rb
111
+ - test/namespaces_test.rb
100
112
  - test/parser_test.rb
101
- - test/enumerations_test.rb
113
+ - test/variables_test.rb
114
+ - test/arguments_test.rb
102
115
  - test/functions_test.rb
103
116
  - test/test_helper.rb
117
+ - test/node_test.rb
118
+ - test/structs_test.rb
104
119
  - test/types_test.rb
105
- - test/query_results_test.rb
106
- - test/namespaces_test.rb
120
+ - test/classes_test.rb
121
+ - test/function_pointers_test.rb