Class: XDry::VarType
- Inherits:
-
Object
show all
- Defined in:
- lib/xdry/parsing/parts/var_types.rb
Class Method Summary
collapse
Instance Method Summary
collapse
Class Method Details
.parse(type_decl) ⇒ Object
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
|
# File 'lib/xdry/parsing/parts/var_types.rb', line 5
def self.parse type_decl
type_decl = type_decl.strip
case type_decl
when /^id$/
IdVarType.new
when /^id\s*<\s*(\w+)\s*>$/
IdVarType.new($1)
when /^(?:unsigned\s+|signed\s+|long\s+)?\w+$/
SimpleVarType.new(type_decl.gsub(/\s+/, ' '))
when /^(\w+)\s*\*$/
class_name = $1
PointerVarType.new(class_name)
when /^(\w+)\s*\*\s*\*$/
class_name = $1
PointerPointerVarType.new(class_name)
else
puts "!! Cannot parse Obj-C type: '#{type_decl}'"
return UnknownVarType.new(type_decl)
end
end
|
Instance Method Details
#needs_space? ⇒ Boolean
30
|
# File 'lib/xdry/parsing/parts/var_types.rb', line 30
def needs_space?; true; end
|
#to_source_with_space ⇒ Object
26
27
28
|
# File 'lib/xdry/parsing/parts/var_types.rb', line 26
def to_source_with_space
needs_space? ? "#{to_s} " : "#{to_s}"
end
|