Class: C::FunctionDef
- Inherits:
-
Node
- Object
- Node
- C::FunctionDef
show all
- Defined in:
- lib/cast/to_s.rb,
lib/cast/parse.rb,
lib/cast/c_nodes.rb,
lib/cast/c_nodes.rb
Constant Summary
Constants inherited
from Node
Node::INSPECT_TAB
Instance Attribute Summary
Attributes inherited from Node
#parent, #pos, #subclasses
Class Method Summary
collapse
Instance Method Summary
collapse
Methods inherited from Node
#==, #=~, abstract, add_field, #assert_invariants, #attached?, child, #clone, #depth_first, #detach, #detached?, #dup, #each, #eql?, field, #fields, fields, #hash, inherited, initializer, #insert_next, #insert_prev, #inspect, inspect1, #list_next, #list_prev, #match?, #method_missing, new_at, #next, #node_after, #node_before, #postorder, #preorder, #prev, #remove_node, #replace_node, #replace_with, #reverse_depth_first, #reverse_each, #reverse_postorder, #reverse_preorder, subclasses_recursive, #swap_with
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
in the class C::Node
Class Method Details
.parse(s, parser = nil) ⇒ Object
117
118
119
120
121
122
123
124
125
126
|
# File 'lib/cast/parse.rb', line 117
def self.parse(s, parser=nil)
parser ||= C.default_parser
ents = parser.parse(s).entities
if ents.length == 1 && ents[0].is_a?(FunctionDef) return ents[0].detach
else
raise ParseError, "invalid FunctionDef"
end
end
|
Instance Method Details
#extern? ⇒ Boolean
196
197
198
|
# File 'lib/cast/c_nodes.rb', line 196
def extern?
storage.equal? :extern
end
|
#prototype=(val) ⇒ Object
202
203
204
|
# File 'lib/cast/c_nodes.rb', line 202
def prototype=(val)
self.no_prototype = !val
end
|
#prototype? ⇒ Boolean
205
206
207
|
# File 'lib/cast/c_nodes.rb', line 205
def prototype?
!no_prototype?
end
|
#static? ⇒ Boolean
199
200
201
|
# File 'lib/cast/c_nodes.rb', line 199
def static?
storage.equal? :static
end
|
#to_s ⇒ Object
54
55
56
57
58
59
60
61
62
63
64
65
66
67
|
# File 'lib/cast/to_s.rb', line 54
def to_s
str = ''
static? and str << 'static '
inline? and str << 'inline '
if no_prototype?
str << "#{type.to_s(name, true)}\n"
type.params.each do |p|
str << indent("#{p.to_s};\n")
end
str << "#{self.def.to_s(:hanging)}"
else
str << "#{type.to_s(name)}#{hang(self.def)}"
end
end
|