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.
@@ -58,11 +58,13 @@ module RbGCCXML
58
58
  xml_file = @xml_file
59
59
  end
60
60
 
61
- document = Nokogiri::XML(::File.read(xml_file))
62
- # Everything starts at the :: Namespace
63
- global_ns = document.search("//Namespace[@name='::']")[0]
64
- XMLParsing.doc_root = document
65
- Namespace.new global_ns
61
+ NodeCache.clear
62
+
63
+ parser = SAXParser.new(xml_file)
64
+
65
+ # Runs the SAX parser and returns the root level node
66
+ # which will be the Namespace node for "::"
67
+ parser.parse
66
68
  end
67
69
 
68
70
  private
@@ -72,7 +72,7 @@ module RbGCCXML
72
72
 
73
73
  if options[0] == :all
74
74
  node_type = self[0].class.to_s.split(/::/)[-1]
75
- query_set = XMLParsing.find_all(:node_type => node_type)
75
+ query_set = NodeCache.all(node_type)
76
76
  options = options[1]
77
77
  else
78
78
  options = options[0]
@@ -149,7 +149,13 @@ module RbGCCXML
149
149
  # one Node is being returned by the Enumerable#find_all, returns that
150
150
  # single node.
151
151
  def find_all(&block)
152
- res = super
152
+ res = QueryResult.new(super)
153
+ res.length == 1 ? res[0] : res
154
+ end
155
+
156
+ # Same with #find_all, force to work as a QueryResult
157
+ def select(&block)
158
+ res = QueryResult.new(super)
153
159
  res.length == 1 ? res[0] : res
154
160
  end
155
161
 
@@ -0,0 +1,69 @@
1
+ module RbGCCXML
2
+
3
+ # Use SAX to parse the generated xml file.
4
+ # This will end up building the full tree of RbGCCXML::Nodes
5
+ # that fit the parsed C++ code.
6
+ class SAXParser
7
+ def initialize(xml_file)
8
+ @file = xml_file
9
+ @parser = Nokogiri::XML::SAX::Parser.new(ParserEventHandler.new)
10
+ end
11
+
12
+ # Kick off the process. When the parsing finishes, we take
13
+ # the root node of the tree and return it
14
+ def parse
15
+ @parser.parse(::File.open(@file))
16
+ NodeCache.root
17
+ end
18
+ end
19
+
20
+ # Our SAX Events handler class
21
+ class ParserEventHandler < Nokogiri::XML::SAX::Document
22
+
23
+ # Ignore types we don't handle yet
24
+ IGNORE_NODES = %w(
25
+ GCC_XML
26
+ Ellipsis
27
+ OperatorMethod
28
+ OperatorFunction
29
+ Unimplemented
30
+ Converter
31
+ OffsetType
32
+ )
33
+
34
+ # Some nodes are actually stored in XML as nested structures
35
+ NESTED_NODES = %w(Argument Base EnumValue)
36
+
37
+ def start_element(name, attributes = [])
38
+ attr_hash = Hash[*attributes]
39
+
40
+ # Need to build a node in memory for those
41
+ # that we don't directly support
42
+ if IGNORE_NODES.include?(name)
43
+ name = "Node"
44
+ end
45
+
46
+ node = RbGCCXML.const_get(name).new(attr_hash)
47
+
48
+ if NESTED_NODES.include?(name)
49
+ # Don't save node to cache. These nodes don't have
50
+ # ids on which we can index off of
51
+ @context_node.children << node
52
+ node.parent = @context_node
53
+ else
54
+ # Save node to node cache
55
+ NodeCache << node
56
+
57
+ # Save node for any XML children it might have later
58
+ @context_node = node
59
+ end
60
+ end
61
+
62
+ # Once the document is done parsing we process our node tree
63
+ def end_document
64
+ NodeCache.process_tree
65
+ end
66
+
67
+ end
68
+
69
+ end
data/lib/rbgccxml.rb CHANGED
@@ -1,13 +1,15 @@
1
1
  require 'gccxml'
2
2
 
3
3
  require 'rbgccxml/rbgccxml'
4
+ require 'vendor/facets/once'
4
5
 
5
6
  module RbGCCXML
6
7
 
7
8
  # Core classes
8
9
  autoload :Node, "rbgccxml/node"
9
10
  autoload :Parser, "rbgccxml/parser"
10
- autoload :XMLParsing, "rbgccxml/xml_parsing"
11
+ autoload :SAXParser, "rbgccxml/sax_parser"
12
+ autoload :NodeCache, "rbgccxml/node_cache"
11
13
  autoload :QueryResult, "rbgccxml/query_result"
12
14
 
13
15
  # Nodes
@@ -0,0 +1,59 @@
1
+ module Kernel #:nodoc:
2
+
3
+ # Directive for making your functions faster by trading
4
+ # space for time. When you "memoize" a method/function
5
+ # using #once its results are cached so that later calls
6
+ # with the same arguments return results from the cache
7
+ # instead of recalculating them.
8
+ #
9
+ # class T
10
+ # def initialize(a)
11
+ # @a = a
12
+ # end
13
+ # def a
14
+ # "#{@a ^ 3 + 4}"
15
+ # end
16
+ # once :a
17
+ # end
18
+ #
19
+ # t = T.new
20
+ # t.a.__id__ == t.a.__id__ #=> true
21
+ #
22
+ # This method can also be used at the instance level
23
+ # to cache singleton/eigen methods.
24
+ #
25
+ # Note, this method used to be called +cache+ along with
26
+ # it's other alias #memoize, but +once+ is the term used
27
+ # in PickAxe so it has been adopted instead. The #memoize
28
+ # alias has also been retained.
29
+ #
30
+ # CREDIT Robert Feldt
31
+ #
32
+ def once(*ids)
33
+ if ids.empty?
34
+ @_once ||= Hash::new{|h,k| h[k]={}}
35
+ else
36
+ base = (Module === self ? self : (class << self; self; end))
37
+ ids.each do |m|
38
+ base.module_eval <<-code
39
+ alias_method '#{ m }:once', '#{ m }'
40
+ private '#{ m }:once'
41
+ def #{ m }(*__a__,&__b__)
42
+ c = once['#{ m }']
43
+ k = [__a__,__b__]
44
+ if c.has_key? k
45
+ c[k]
46
+ else
47
+ c[k] = __send__('#{ m }:once',*__a__,&__b__)
48
+ end
49
+ end
50
+ code
51
+ end
52
+ end
53
+ end
54
+
55
+ # +once+ is also widely known as +memoize+.
56
+ alias_method :memoize, :once
57
+
58
+ end
59
+
@@ -1,29 +1,29 @@
1
1
  require "test_helper"
2
2
 
3
- context "Function and Method Arguments" do
3
+ describe "Function and Method Arguments" do
4
4
 
5
- setup do
6
- @@arguments_source ||= RbGCCXML.parse(full_dir("headers/functions.h")).namespaces("functions")
5
+ before(:all) do
6
+ @arguments_source = RbGCCXML.parse(full_dir("headers/functions.h")).namespaces("functions")
7
7
  end
8
8
 
9
9
  specify "have type and to_cpp" do
10
- test1 = @@arguments_source.functions("test1")
11
- test1.arguments.length.should.equal 2
10
+ test1 = @arguments_source.functions("test1")
11
+ test1.arguments.length.should == 2
12
12
 
13
- test1.arguments[0].to_cpp.should.equal "int x"
14
- test1.arguments[0].cpp_type.to_cpp.should.equal "int"
13
+ test1.arguments[0].to_cpp.should == "int x"
14
+ test1.arguments[0].cpp_type.to_cpp.should == "int"
15
15
 
16
- test1.arguments[1].to_cpp.should.equal "double y"
17
- test1.arguments[1].cpp_type.to_cpp.should.equal "double"
16
+ test1.arguments[1].to_cpp.should == "double y"
17
+ test1.arguments[1].cpp_type.to_cpp.should == "double"
18
18
  end
19
19
 
20
20
  specify "can have a default value" do
21
- test1 = @@arguments_source.functions("test1")
22
- test1.arguments[0].value.should.be nil
23
- test1.arguments[1].value.should.equal "3.0e+0"
21
+ test1 = @arguments_source.functions("test1")
22
+ test1.arguments[0].value.should be_nil
23
+ test1.arguments[1].value.should == "3.0e+0"
24
24
 
25
- rockin = @@arguments_source.functions("rockin")
26
- rockin.arguments[1].value.should.equal "functions::test()"
25
+ rockin = @arguments_source.functions("rockin")
26
+ rockin.arguments[1].value.should == "functions::test()"
27
27
  end
28
28
  end
29
29
 
data/test/classes_test.rb CHANGED
@@ -1,197 +1,202 @@
1
1
  require "test_helper"
2
2
 
3
- context "Querying for classes" do
4
- setup do
3
+ describe "Querying for classes" do
4
+ before do
5
5
  @source ||= RbGCCXML.parse(full_dir("headers/classes.h")).namespaces("classes")
6
6
  end
7
7
 
8
8
  specify "can find all classes in a given namespace" do
9
9
  classes = @source.classes
10
- classes.size.should.equal 4
10
+ classes.size.should == 4
11
11
 
12
- classes.find(:name => "Test1").should.not.be.nil
13
- classes.find(:name => "Test2").should.not.be.nil
14
- classes.find(:name => "Test3").should.not.be.nil
12
+ classes.find(:name => "Test1").should_not be_nil
13
+ classes.find(:name => "Test2").should_not be_nil
14
+ classes.find(:name => "Test3").should_not be_nil
15
15
  end
16
16
 
17
17
  specify "can find classes within classes" do
18
18
  test1 = @source.classes.find(:name => "Test1")
19
- test1.should.not.be.nil
20
- test1.should.be.kind_of RbGCCXML::Class
21
- test1.name.should.equal "Test1"
19
+ test1.should_not be_nil
20
+ test1.should be_kind_of(RbGCCXML::Class)
21
+ test1.name.should == "Test1"
22
22
 
23
23
  inner1 = test1.classes("Inner1")
24
- inner1.should.not.be.nil
25
- inner1.should.be.kind_of RbGCCXML::Class
26
- inner1.name.should.equal "Inner1"
24
+ inner1.should_not be_nil
25
+ inner1.should be_kind_of(RbGCCXML::Class)
26
+ inner1.name.should == "Inner1"
27
27
 
28
28
  inner2 = inner1.classes("Inner1")
29
- inner2.should.not.be.nil
30
- inner2.should.be.kind_of Array
31
- inner2.should.be.empty
29
+ inner2.should_not be_nil
30
+ inner2.should be_kind_of(Array)
31
+ inner2.should be_empty
32
32
 
33
33
  inner2 = inner1.classes("Inner2")
34
- inner2.should.not.be.nil
35
- inner2.should.be.kind_of RbGCCXML::Class
36
- inner2.name.should.equal "Inner2"
34
+ inner2.should_not be_nil
35
+ inner2.should be_kind_of(RbGCCXML::Class)
36
+ inner2.name.should == "Inner2"
37
37
  end
38
38
 
39
39
  specify "can find classes within classes by regex" do
40
40
  test1 = @source.classes(/t1/)
41
- test1.should.not.be.nil
42
- test1.should.be.kind_of RbGCCXML::Class
43
- test1.name.should.equal "Test1"
41
+ test1.should_not be_nil
42
+ test1.should be_kind_of(RbGCCXML::Class)
43
+ test1.name.should == "Test1"
44
44
 
45
45
  inner1 = test1.classes(/In.*1/)
46
- inner1.should.not.be.nil
47
- inner1.should.be.kind_of RbGCCXML::Class
48
- inner1.name.should.equal "Inner1"
46
+ inner1.should_not be_nil
47
+ inner1.should be_kind_of(RbGCCXML::Class)
48
+ inner1.name.should == "Inner1"
49
49
 
50
50
  inner2 = inner1.classes(/1/)
51
- inner2.should.not.be.nil
52
- inner2.should.be.kind_of Array
53
- inner2.should.be.empty
51
+ inner2.should_not be_nil
52
+ inner2.should be_kind_of(Array)
53
+ inner2.should be_empty
54
54
 
55
55
  inner2 = inner1.classes(/2/)
56
- inner2.should.not.be.nil
57
- inner2.should.be.kind_of RbGCCXML::Class
58
- inner2.name.should.equal "Inner2"
56
+ inner2.should_not be_nil
57
+ inner2.should be_kind_of(RbGCCXML::Class)
58
+ inner2.name.should == "Inner2"
59
59
  end
60
60
 
61
61
  specify "can find classes within classes by block" do
62
62
  # We're looking for any class that has virtual methods.
63
- test4 = @source.classes { |c| c.methods.any? { |m| m.virtual? } }
64
- test4.should.not.be.nil
65
- test4.should.be.kind_of RbGCCXML::Class
66
- test4.name.should.equal "Test4"
63
+ test4 = @source.classes.select { |c| c.methods.any? { |m| m.virtual? } }
64
+ test4.should_not be_nil
65
+ test4.should be_kind_of(RbGCCXML::Class)
66
+ test4.name.should == "Test4"
67
67
 
68
68
  # Fail case -- there's no methods that return double.
69
- test0 = @source.classes { |c| c.methods.any? { |m| m.return_type == "double" }}
70
- test0.should.not.be.nil
71
- test0.should.be.kind_of Array
72
- test0.should.be.empty
69
+ test0 = @source.classes.select { |c| c.methods.any? { |m| m.return_type == "double" }}
70
+ test0.should_not be_nil
71
+ test0.should be_kind_of(Array)
72
+ test0.should be_empty
73
73
  end
74
74
 
75
75
  specify "can tell if a class is pure virtual" 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 be_false
80
+ test4.pure_virtual?.should be_true
81
81
  end
82
82
  end
83
83
 
84
- context "Querying for class constructors" do
85
- setup do
84
+ describe "Querying for class constructors" do
85
+ before do
86
86
  @source ||= RbGCCXML.parse(full_dir("headers/classes.h")).namespaces("classes")
87
87
  end
88
88
 
89
89
  specify "should have a list of constructors" do
90
90
  test1 = @source.classes.find(:name => "Test1")
91
- test1.constructors.size.should.equal 2
91
+ test1.constructors.size.should == 2
92
92
 
93
93
  test2 = @source.classes.find(:name => "Test2")
94
- test2.constructors.size.should.equal 3
94
+ test2.constructors.size.should == 3
95
95
  end
96
96
 
97
97
  specify "constructors should have arguments" do
98
98
  test2 = @source.classes.find(:name => "Test2")
99
- test2.constructors.size.should.equal 3
99
+ test2.constructors.size.should == 3
100
100
 
101
101
  # GCC generated copy constructors
102
102
  copy = test2.constructors[0]
103
- copy.attributes[:artificial].should.equal "1"
103
+ copy.artificial?.should be_true
104
104
 
105
105
  default = test2.constructors[1]
106
- default.arguments.size.should.equal 0
106
+ default.arguments.size.should == 0
107
107
 
108
108
  specific = test2.constructors[2]
109
- specific.arguments.size.should.equal 1
110
- specific.arguments[0].cpp_type.name.should.equal "int"
109
+ specific.arguments.size.should == 1
110
+ specific.arguments[0].cpp_type.name.should == "int"
111
111
  end
112
112
  end
113
113
 
114
- context "Querying for the class's deconstructor" do
115
- setup do
114
+ describe "Querying for the class's deconstructor" do
115
+ before do
116
116
  @source ||= RbGCCXML.parse(full_dir("headers/classes.h")).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
- test1.destructor.should.not.be.nil
122
- test1.destructor.attributes[:artificial].should.be.nil
121
+ test1.destructor.should_not be_nil
122
+ test1.destructor.artificial?.should be_false
123
123
 
124
124
  test2 = @source.classes("Test2")
125
- test2.destructor.should.not.be.nil
126
- test2.destructor.attributes[:artificial].should.not.be.nil
125
+ test2.destructor.should_not be_nil
126
+ test2.destructor.artificial?.should be_true
127
127
  end
128
128
 
129
129
  end
130
130
 
131
- context "Query for class variables" do
132
- setup do
131
+ describe "Query for class variables" do
132
+ before do
133
133
  @source ||= RbGCCXML.parse(full_dir("headers/classes.h")).namespaces("classes")
134
134
  end
135
135
 
136
136
  specify "find all i-vars" do
137
137
  test1 = @source.classes("Test1")
138
- test1.variables.length.should.equal 4
138
+ test1.variables.length.should == 4
139
139
  end
140
140
 
141
141
  specify "can find by access level" do
142
142
  test1 = @source.classes("Test1")
143
- test1.variables.find(:access => "public").length.should.equal 2
144
- test1.variables.find(:access => "protected").name.should.equal "protVariable"
145
- test1.variables.find(:access => "private").name.should.equal "privateVariable"
143
+ test1.variables.find(:access => "public").length.should == 2
144
+ test1.variables.find(:access => "protected").name.should == "protVariable"
145
+ test1.variables.find(:access => "private").name.should == "privateVariable"
146
146
  end
147
147
  end
148
148
 
149
- context "Query inheritance heirarchy" do
150
- setup do
149
+ describe "Query inheritance heirarchy" do
150
+ before do
151
151
  @source ||= RbGCCXML.parse(full_dir("headers/inheritance.h")).namespaces("inheritance")
152
152
  end
153
153
 
154
154
  specify "can find a class's superclass" do
155
155
  pc = @source.classes("ParentClass")
156
- pc.superclass.should.be.nil
156
+ pc.superclass.should be_nil
157
157
 
158
158
  base1 = @source.classes("Base1")
159
- base1.superclass.should.not.be.nil
160
- base1.superclass.name.should.equal "ParentClass"
159
+ base1.superclass.should_not be_nil
160
+ base1.superclass.name.should == "ParentClass"
161
161
  end
162
162
 
163
163
  specify "can query for multiple inheritance" do
164
164
  multi = @source.classes("MultiBase")
165
- multi.superclasses.length.should.equal 2
166
- assert multi.superclasses.select {|sp| sp.name == "ParentClass"}
167
- assert multi.superclasses.select {|sp| sp.name == "Parent2"}
165
+ multi.superclasses.length.should == 2
166
+ multi.superclasses.select {|sp| sp.name == "ParentClass"}.should_not be_nil
167
+ multi.superclasses.select {|sp| sp.name == "Parent2"}.should_not be_nil
168
168
  end
169
169
 
170
170
  specify "calling #superclasses always returns an array" do
171
171
  pc = @source.classes("ParentClass")
172
- pc.superclasses.should.be.empty
172
+ pc.superclasses.should be_empty
173
173
 
174
174
  base1 = @source.classes("Base1")
175
- base1.superclasses.length.should.equal 1
176
- base1.superclasses[0].name.should.equal "ParentClass"
175
+ base1.superclasses.length.should == 1
176
+ base1.superclasses[0].name.should == "ParentClass"
177
177
  end
178
178
 
179
179
  specify "can infinitely climb the inheritance heirarchy" do
180
180
  low = @source.classes("VeryLow")
181
- low.superclass.superclass.superclass.name.should.equal "ParentClass"
181
+ low.superclass.superclass.superclass.name.should == "ParentClass"
182
182
  end
183
183
 
184
184
  specify "can query for types of inheritance" do
185
185
  pvb1 = @source.classes("PrivateBase1")
186
- pvb1.superclass(:public).should.be.nil
187
- pvb1.superclass(:protected).should.be.nil
188
- pvb1.superclass(:private).should.not.be.nil
186
+ pvb1.superclass(:public).should be_nil
187
+ pvb1.superclass(:protected).should be_nil
188
+ pvb1.superclass(:private).should_not be_nil
189
189
 
190
- pvb1.superclass(:private).name.should.equal "ParentClass"
190
+ pvb1.superclass(:private).name.should == "ParentClass"
191
191
 
192
- pvb1.superclasses(:public).length.should.equal 0
193
- pvb1.superclasses(:protected).length.should.equal 0
194
- pvb1.superclasses(:private).length.should.equal 1
192
+ pvb1.superclasses(:public).length.should == 0
193
+ pvb1.superclasses(:protected).length.should == 0
194
+ pvb1.superclasses(:private).length.should == 1
195
+
196
+ vlow = @source.classes("VeryLow")
197
+ vlow.superclasses(:public).length.should == 1
198
+ vlow.superclasses(:private).length.should == 0
199
+ vlow.superclasses(:protected).length.should == 1
195
200
  end
196
201
 
197
202
  end
@@ -1,51 +1,49 @@
1
1
  require "test_helper"
2
2
 
3
- context "Querying for enumerations" do
4
- setup do
5
- @@enum_source ||= RbGCCXML.parse(full_dir("headers/enums.h")).namespaces("enums")
3
+ describe "Querying for enumerations" do
4
+ before(:all) do
5
+ @enum_source = RbGCCXML.parse(full_dir("headers/enums.h")).namespaces("enums")
6
6
  end
7
7
 
8
8
  specify "can query for enumerations" do
9
- enums = @@enum_source.enumerations
10
- enums.length.should.equal 3
9
+ enums = @enum_source.enumerations
10
+ enums.length.should == 3
11
11
  end
12
12
 
13
13
  specify "can find specific enum values" do
14
- enum = @@enum_source.enumerations("TestEnum")
15
- enum.values.length.should.equal 3
16
- enum.values[0].name.should.equal "VALUE1"
17
- enum.values[1].name.should.equal "VALUE2"
18
- enum.values[2].name.should.equal "VALUE3"
14
+ enum = @enum_source.enumerations("TestEnum")
15
+ enum.values.length.should == 3
16
+ enum.values[0].name.should == "VALUE1"
17
+ enum.values[1].name.should == "VALUE2"
18
+ enum.values[2].name.should == "VALUE3"
19
19
  end
20
20
 
21
21
  specify "can find the given value of enum entries" do
22
- enum = @@enum_source.enumerations.find(:name => "MyEnum")
23
- enum.values[0].value.should.equal 3
24
- enum.values[1].value.should.equal 4
25
- enum.values[2].value.should.equal 7
22
+ enum = @enum_source.enumerations.find(:name => "MyEnum")
23
+ enum.values[0].value.should == 3
24
+ enum.values[1].value.should == 4
25
+ enum.values[2].value.should == 7
26
26
  end
27
27
 
28
28
  specify "properly prints out fully qualified C++ identifier for enum values" do
29
- enum = @@enum_source.enumerations("TestEnum")
30
- enum.values.length.should.equal 3
31
- enum.values[0].qualified_name.should.equal "enums::VALUE1"
32
- enum.values[1].qualified_name.should.equal "enums::VALUE2"
33
- enum.values[2].qualified_name.should.equal "enums::VALUE3"
34
-
35
- enum = @@enum_source.classes("Inner").enumerations("InnerEnum")
36
- enum.values[0].qualified_name.should.equal "enums::Inner::INNER_1"
37
- enum.values[1].qualified_name.should.equal "enums::Inner::INNER_2"
29
+ enum = @enum_source.enumerations("TestEnum")
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"
34
+
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"
38
38
  end
39
39
 
40
40
  specify "knows if an enumeration is anonymous" do
41
- found = @@enum_source.enumerations.select {|e| e.anonymous? }
42
- found.length.should.equal 1
43
- found = found[0]
44
-
45
- assert found.is_a?(RbGCCXML::Enumeration)
46
- found.values[0].value.should.equal 0
47
- found.values[1].value.should.equal 1
48
- found.values[2].value.should.equal 2
41
+ found = @enum_source.enumerations.select {|e| e.anonymous? }
42
+
43
+ found.should be_a(RbGCCXML::Enumeration)
44
+ found.values[0].value.should == 0
45
+ found.values[1].value.should == 1
46
+ found.values[2].value.should == 2
49
47
  end
50
48
 
51
49
  end
@@ -1,18 +1,18 @@
1
1
  require "test_helper"
2
2
 
3
- context "Function pointers" do
4
- setup do
5
- @@fp_source ||= RbGCCXML.parse(full_dir("headers/types.h")).namespaces("types")
3
+ describe "Function pointers" do
4
+ before(:all) do
5
+ @fp_source = RbGCCXML.parse(full_dir("headers/types.h")).namespaces("types")
6
6
  end
7
7
 
8
8
  specify "have arguments" do
9
- fp = @@fp_source.functions("takesCallback").arguments[0].cpp_type.base_type
9
+ fp = @fp_source.functions("takesCallback").arguments[0].cpp_type.base_type
10
10
  fp.arguments.length.should == 1
11
- fp.arguments[0].cpp_type.name.should.equal "int"
11
+ fp.arguments[0].cpp_type.name.should == "int"
12
12
  end
13
13
 
14
14
  specify "have return value" do
15
- fp = @@fp_source.functions("takesCallbackWithReturn").arguments[0].cpp_type.base_type
16
- fp.return_type.name.should.equal "int"
15
+ fp = @fp_source.functions("takesCallbackWithReturn").arguments[0].cpp_type.base_type
16
+ fp.return_type.name.should == "int"
17
17
  end
18
18
  end