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
|
# 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 /^(?:unsigned\s+|signed\s+|long\s+)?\w+$/
SimpleVarType.new(type_decl.gsub(/\s+/, ' '))
when /^(\w+)\s*\*$/
class_name = $1
PointerVarType.new(class_name)
else
raise StandardError, "Cannot parse Obj-C type: '#{type_decl}'"
end
end
|
Instance Method Details
#needs_space? ⇒ Boolean
24
|
# File 'lib/xdry/parsing/parts/var_types.rb', line 24
def needs_space?; true; end
|
#to_source_with_space ⇒ Object
20
21
22
|
# File 'lib/xdry/parsing/parts/var_types.rb', line 20
def to_source_with_space
needs_space? ? "#{to_s} " : "#{to_s}"
end
|