rbgccxml 0.9 → 0.9.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/Rakefile CHANGED
@@ -4,7 +4,7 @@ require 'rake/contrib/sshpublisher'
4
4
  require 'rake/gempackagetask'
5
5
 
6
6
  PROJECT_NAME = "rbgccxml"
7
- RBGCCXML_VERSION = "0.9"
7
+ RBGCCXML_VERSION = "0.9.1"
8
8
 
9
9
  task :default => :test
10
10
 
@@ -55,8 +55,11 @@ spec = Gem::Specification.new do |s|
55
55
  s.author = 'Jason Roelofs'
56
56
  s.email = 'jameskilton@gmail.com'
57
57
 
58
- s.add_dependency "libxml-ruby", "~>1.1"
59
- s.add_dependency "gccxml_gem", "~>0.9"
58
+ s.add_dependency "nokogiri", "~> 1.4.0"
59
+ s.add_dependency "gccxml_gem", "~> 0.9"
60
+
61
+ s.add_development_dependency "test-unit", "1.2.3"
62
+ s.add_development_dependency "mocha", "~> 0.9"
60
63
 
61
64
  s.description = <<-END
62
65
  Rbgccxml is a library that parses out GCCXML (http://www.gccxml.org) output
@@ -78,6 +81,4 @@ what you want out of the C++ source code
78
81
  end
79
82
 
80
83
  Rake::GemPackageTask.new(spec) do |pkg|
81
- pkg.need_zip = true
82
- pkg.need_tar = true
83
84
  end
data/lib/rbgccxml/node.rb CHANGED
@@ -13,7 +13,7 @@ module RbGCCXML
13
13
  # attempt to will throw a NotQueryableException.
14
14
  class Node
15
15
 
16
- # The underlying libxml node for this Node.
16
+ # The underlying xml node for this Node.
17
17
  attr_reader :node
18
18
 
19
19
  # Initialize this node according to the XML element passed in
@@ -26,15 +26,15 @@ module RbGCCXML
26
26
 
27
27
  # Get the C++ name of this node
28
28
  def name
29
- @node.attributes['name']
29
+ @node['name']
30
30
  end
31
31
 
32
32
  # Get the fully qualified (demangled) C++ name of this node.
33
33
  def qualified_name
34
- if @node.attributes["demangled"]
34
+ if @node["demangled"]
35
35
  # The 'demangled' attribute of the node for methods / functions is the
36
36
  # full signature, so cut that part out.
37
- @node.attributes["demangled"].split(/\(/)[0]
37
+ @node["demangled"].split(/\(/)[0]
38
38
  else
39
39
  parent ? "#{parent.qualified_name}::#{name}" : name
40
40
  end
@@ -42,27 +42,32 @@ module RbGCCXML
42
42
 
43
43
  # Is this node const qualified?
44
44
  def const?
45
- @node.attributes["const"] ? @node.attributes["const"] == "1" : false
45
+ @node["const"] ? @node["const"] == "1" : false
46
46
  end
47
47
 
48
48
  # Does this node have public access?
49
49
  def public?
50
- @node.attributes["access"] ? @node.attributes["access"] == "public" : true
50
+ @node["access"] ? @node["access"] == "public" : true
51
51
  end
52
52
 
53
53
  # Does this node have protected access?
54
54
  def protected?
55
- @node.attributes["access"] ? @node.attributes["access"] == "protected" : false
55
+ @node["access"] ? @node["access"] == "protected" : false
56
56
  end
57
57
 
58
58
  # Does this node have private access?
59
59
  def private?
60
- @node.attributes["access"] ? @node.attributes["access"] == "private" : false
60
+ @node["access"] ? @node["access"] == "private" : false
61
61
  end
62
62
 
63
- # Access to the underlying libxml node's attributes
63
+ # Access to the underlying xml node's attributes.
64
64
  def attributes
65
- @node.attributes
65
+ @node
66
+ end
67
+
68
+ # Access indivitual attributes directly
69
+ def [](val)
70
+ @node[val]
66
71
  end
67
72
 
68
73
  # Some C++ nodes are actually wrappers around other nodes. For example,
@@ -78,7 +83,7 @@ module RbGCCXML
78
83
  # Returns the full path to the file this node is found in.
79
84
  # Returns nil if no File node is found for this node
80
85
  def file
81
- file_id = @node.attributes["file"]
86
+ file_id = @node["file"]
82
87
  file_node = XMLParsing.find(:node_type => "File", :id => file_id) if file_id
83
88
  file_node ? file_node.attributes["name"] : nil
84
89
  end
@@ -86,8 +91,8 @@ module RbGCCXML
86
91
  # Returns the parent node of this node. e.g. function.parent will get the class
87
92
  # the function is contained in.
88
93
  def parent
89
- return nil if @node.attributes["context"].nil? || @node.attributes["context"] == "_1"
90
- XMLParsing.find(:id => @node.attributes["context"])
94
+ return nil if @node["context"].nil? || @node["context"] == "_1"
95
+ XMLParsing.find(:id => @node["context"])
91
96
  end
92
97
 
93
98
  # This is a unified search routine for finding nested nodes. It
@@ -10,7 +10,7 @@ module RbGCCXML
10
10
 
11
11
  # Get any default value for this argument
12
12
  def value
13
- attributes["default"]
13
+ self["default"]
14
14
  end
15
15
 
16
16
  # See Node#to_cpp, prints out C++ code for this argument
@@ -9,7 +9,7 @@ module RbGCCXML
9
9
 
10
10
  # Is this class pure virtual?
11
11
  def pure_virtual?
12
- @node.attributes["abstract"] ? @node.attributes["abstract"] == "1" : false
12
+ @node["abstract"] ? @node["abstract"] == "1" : false
13
13
  end
14
14
 
15
15
  # Find all the constructors for this class.
@@ -8,7 +8,7 @@ module RbGCCXML
8
8
 
9
9
  # Get the defined value of this EnumValue
10
10
  def value
11
- node.attributes["init"].to_i
11
+ node["init"].to_i
12
12
  end
13
13
 
14
14
  # The qualified name of an EnumValue doesn't
@@ -5,17 +5,17 @@ module RbGCCXML
5
5
 
6
6
  # Is this method static?
7
7
  def static?
8
- @node.attributes["static"] == "1"
8
+ @node["static"] == "1"
9
9
  end
10
10
 
11
11
  # Is this a virtual method?
12
12
  def virtual?
13
- @node.attributes["virtual"] == "1"
13
+ @node["virtual"] == "1"
14
14
  end
15
15
 
16
16
  # Is this a pure virtual method? A purely virtual method has no body.
17
17
  def purely_virtual?
18
- @node.attributes["pure_virtual"] == "1"
18
+ @node["pure_virtual"] == "1"
19
19
  end
20
20
 
21
21
  end
@@ -21,7 +21,7 @@ module RbGCCXML
21
21
  # See Node#to_cpp
22
22
  def to_cpp(qualified = true)
23
23
  type = XMLParsing.find_type_of(self.node, "type")
24
- "#{type.to_cpp(qualified)}[#{self.node.attributes["max"].gsub(/[^\d]/, '').to_i + 1}]"
24
+ "#{type.to_cpp(qualified)}[#{self.node["max"].gsub(/[^\d]/, '').to_i + 1}]"
25
25
  end
26
26
 
27
27
  end
@@ -16,7 +16,7 @@ module RbGCCXML
16
16
 
17
17
  # Is this node const?
18
18
  def const?
19
- self.node.attributes["const"].to_i == 1
19
+ self.node["const"].to_i == 1
20
20
  end
21
21
 
22
22
  end
@@ -0,0 +1,7 @@
1
+ module RbGCCXML
2
+
3
+ # Represents a <Union> node
4
+ class Union < Node
5
+ end
6
+
7
+ end
@@ -1,4 +1,4 @@
1
- require 'libxml'
1
+ require 'nokogiri'
2
2
 
3
3
  module RbGCCXML
4
4
 
@@ -58,10 +58,9 @@ module RbGCCXML
58
58
  xml_file = @xml_file
59
59
  end
60
60
 
61
- document = LibXML::XML::Document.file(xml_file)
62
- root = document.root
61
+ document = Nokogiri::XML(::File.read(xml_file))
63
62
  # Everything starts at the :: Namespace
64
- global_ns = root.find("//Namespace[@name='::']")[0]
63
+ global_ns = document.search("//Namespace[@name='::']")[0]
65
64
  XMLParsing.doc_root = document
66
65
  Namespace.new global_ns
67
66
  end
@@ -125,7 +125,7 @@ module RbGCCXML
125
125
  # Access type
126
126
  if access
127
127
  found[:access] ||= []
128
- found[:access] << node if node.attributes["access"] == access.to_s
128
+ found[:access] << node if node["access"] == access.to_s
129
129
  end
130
130
  end
131
131
 
@@ -40,7 +40,7 @@ module RbGCCXML
40
40
  attrs = options.map {|key, value| "[@#{key}='#{value}']"}.join
41
41
  xpath = "//#{type || '*'}#{attrs}"
42
42
 
43
- got = @@doc_root.find(xpath).first
43
+ got = @@doc_root.search(xpath).first
44
44
 
45
45
  if got
46
46
  result = build_type(type || got.name, got)
@@ -73,9 +73,9 @@ module RbGCCXML
73
73
  type = options.delete(:node_type)
74
74
  attrs = options.map {|key, value| "[@#{key}='#{value}']"}.join
75
75
 
76
- xpath = "//#{type}#{attrs}"
76
+ xpath = "//#{type || "*"}#{attrs}"
77
77
 
78
- found = @@doc_root.find(xpath)
78
+ found = @@doc_root.search(xpath)
79
79
 
80
80
  if found
81
81
  found.each do |got|
@@ -91,7 +91,7 @@ module RbGCCXML
91
91
  #
92
92
  # Returns a QueryResult with the findings.
93
93
  def self.find_nested_nodes_of_type(node, node_type)
94
- self.find_all(:node_type => node_type, :context => node.attributes["id"])
94
+ self.find_all(:node_type => node_type, :context => node["id"])
95
95
  end
96
96
 
97
97
  # Arguments are a special case in gccxml as they are actual children of
@@ -107,7 +107,7 @@ module RbGCCXML
107
107
  bases = get_children_nodes_of_type(node, "Base")
108
108
 
109
109
  if access_type
110
- bases = bases.select {|b| b.attributes["access"] == access_type.to_s }
110
+ bases = bases.select {|b| b["access"] == access_type.to_s }
111
111
  end
112
112
 
113
113
  bases.map {|b| b.cpp_type }
@@ -138,7 +138,7 @@ module RbGCCXML
138
138
  # +find_type_of(func_node, "returns")+ could return "std::string" node, "int" node, etc
139
139
  #
140
140
  def self.find_type_of(node, attr)
141
- self.find(:id => node.attributes[attr])
141
+ self.find(:id => node[attr])
142
142
  end
143
143
 
144
144
  private
data/lib/rbgccxml.rb CHANGED
@@ -27,6 +27,8 @@ module RbGCCXML
27
27
  autoload :Struct, "rbgccxml/nodes/struct"
28
28
  autoload :Variable, "rbgccxml/nodes/variable"
29
29
 
30
+ autoload :Union, "rbgccxml/nodes/union"
31
+
30
32
  # Type Management
31
33
  autoload :Type, "rbgccxml/nodes/type"
32
34
  autoload :Typedef, "rbgccxml/nodes/types/typedef"
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.9"
4
+ version: 0.9.1
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: 2009-10-22 00:00:00 -04:00
12
+ date: 2009-12-14 00:00:00 -05:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
- name: libxml-ruby
16
+ name: nokogiri
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: "1.1"
23
+ version: 1.4.0
24
24
  version:
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: gccxml_gem
@@ -32,6 +32,26 @@ dependencies:
32
32
  - !ruby/object:Gem::Version
33
33
  version: "0.9"
34
34
  version:
35
+ - !ruby/object:Gem::Dependency
36
+ name: test-unit
37
+ type: :development
38
+ version_requirement:
39
+ version_requirements: !ruby/object:Gem::Requirement
40
+ requirements:
41
+ - - "="
42
+ - !ruby/object:Gem::Version
43
+ version: 1.2.3
44
+ version:
45
+ - !ruby/object:Gem::Dependency
46
+ name: mocha
47
+ type: :development
48
+ version_requirement:
49
+ version_requirements: !ruby/object:Gem::Requirement
50
+ requirements:
51
+ - - ~>
52
+ - !ruby/object:Gem::Version
53
+ version: "0.9"
54
+ version:
35
55
  description: |
36
56
  Rbgccxml is a library that parses out GCCXML (http://www.gccxml.org) output
37
57
  and provides a simple but very powerful querying API for finding exactly
@@ -58,6 +78,7 @@ files:
58
78
  - lib/rbgccxml/nodes/field.rb
59
79
  - lib/rbgccxml/nodes/file.rb
60
80
  - lib/rbgccxml/nodes/base.rb
81
+ - lib/rbgccxml/nodes/union.rb
61
82
  - lib/rbgccxml/nodes/types/reference_type.rb
62
83
  - lib/rbgccxml/nodes/types/array_type.rb
63
84
  - lib/rbgccxml/nodes/types/typedef.rb