lib/rbplusplus/transformers/node.rb in rbplusplus-0.8 vs lib/rbplusplus/transformers/node.rb in rbplusplus-0.9
- old
+ new
@@ -1,77 +1,70 @@
module RbGCCXML
- class Node
- # Specifies to not export this node
+ class Node
+
+ # Specify to Rb++ that this node is not to be wrapped
def ignore
- @ignored = true
+ cache[:ignored] = true
end
-
- # Returns true if this node is ignored in exporting
+
+ # Un-ignore this node, useful if there's a glob ignore and the wrapper
+ # just wants a few of the classes
+ def unignore
+ cache[:ignored] = false
+ end
+
+ # Has this node been previously declared to not be wrapped?
def ignored?
- @ignored || false
+ !!cache[:ignored]
end
# Specifies that this node has been included somewhere else
- def moved=(val)
- @moved = val
+ def moved_to=(val)
+ cache[:moved_to] = val
end
-
+
# Change what the name of this node will be when wrapped into Ruby
def wrap_as(name)
- @renamed = name
+ cache[:wrap_as] = name
self
end
-
- # Returns true if the node has been moved
- def moved?
- @moved || false
+
+ # Where has this node moved to?
+ def moved_to
+ cache[:moved_to]
end
-
+
# Has this node been renamed
def renamed?
- (@renamed.nil? ? false : true)
+ !!cache[:wrap_as]
end
- alias_method :rbgccxml_namespaces, :namespaces
- def namespaces(*args) #:nodoc:
- nodes = rbgccxml_namespaces(*args)
- return cache(nodes)
+ alias_method :rbgccxml_name, :name
+ def name #:nodoc:
+ cache[:wrap_as] || rbgccxml_name
end
-
- alias_method :rbgccxml_classes, :classes
- def classes(*args) #:nodoc:
- nodes = rbgccxml_classes(*args)
- return cache(nodes)
+
+ def cpp_name
+ rbgccxml_name
end
-
- alias_method :rbgccxml_functions, :functions
- def functions(*args) #:nodoc:
- nodes = rbgccxml_functions(*args)
- return cache(nodes)
+
+ # In some cases, the automatic typedef lookup of rb++ can end up
+ # doing the wrong thing (for example, it can take a normal class
+ # and end up using the typedef for stl::container<>::value_type).
+ # Flag a given class as ignoring this typedef lookup if this
+ # situation happens.
+ def disable_typedef_lookup
+ cache[:disable_typedef_lookup] = true
end
-
- alias_method :rbgccxml_methods, :functions
- def methods(*args) #:nodoc:
- nodes = rbgccxml_methods(*args)
- return cache(nodes)
- end
-
- alias_method :rbgccxml_name, :name
- def name #:nodoc:
- @renamed || rbgccxml_name
+
+ def _disable_typedef_lookup? #:nodoc:
+ !!cache[:disable_typedef_lookup]
end
-
- private
- # Looks up the objects in the node cache.
- def cache(nodes)
- if nodes.is_a?(QueryResult)
- retv = QueryResult.new
- nodes.each do |node|
- retv << RbPlusPlus::NodeCache.instance.get(node)
- end
- return retv
- else
- return RbPlusPlus::NodeCache.instance.get(nodes)
- end
+
+ protected
+
+ # Get this node's settings cache
+ def cache
+ NodeCache.get(self)
end
- end
+ end
end