Class: Jaspion::Kilza::Objc::Class
- Inherits:
-
Object
- Object
- Jaspion::Kilza::Objc::Class
show all
- Includes:
- Class
- Defined in:
- lib/jaspion/kilza/language/objc/class.rb
Instance Attribute Summary
Attributes included from Class
#name, #properties
Instance Method Summary
collapse
Methods included from Class
#code, #delete_import, #push_import, #to_s
Constructor Details
#initialize(name) ⇒ Class
Returns a new instance of Class.
7
8
9
10
|
# File 'lib/jaspion/kilza/language/objc/class.rb', line 7
def initialize(name)
name = name + RESERVED_CLASS_POSFIX unless RESERVED_WORDS.index(name.downcase).nil?
super(name)
end
|
Instance Method Details
#equals ⇒ Object
30
31
32
33
34
35
36
37
38
39
40
41
42
43
|
# File 'lib/jaspion/kilza/language/objc/class.rb', line 30
def equals
r = StringIO.new
r << '- (BOOL)isEqual:(id)anObject {'
fields = []
for pr in @properties
fields.push("[((#{@name}) anObject).#{pr.name} isEqual:#{pr.name}]") if pr.key?
end
r << "\n if (anObject instanceof #{@name}) {"
r << " return (" + fields.join(" &&\n ") + "});"
r << "\n }"
r << "\n return false;"
r << "\n}"
r.string
end
|
#imports ⇒ Object
26
27
28
|
# File 'lib/jaspion/kilza/language/objc/class.rb', line 26
def imports
@imports.sort.flatten
end
|
#push(pr) ⇒ Object
12
13
14
15
16
17
18
19
20
21
22
23
24
|
# File 'lib/jaspion/kilza/language/objc/class.rb', line 12
def push(pr)
if pr.object? || (pr.array? && pr.null?)
pr.type = pr.class_name + ' *'
push_import("#import \"#{pr.class_name}.h\"")
end
pr.type = 'NSMutableArray *' if pr.array?
unless Jaspion::Kilza::Objc::TYPES[pr.type].nil?
pr.type = Jaspion::Kilza::Objc::TYPES[pr.type]
end
super(pr)
end
|
#sources ⇒ Object
45
46
47
|
# File 'lib/jaspion/kilza/language/objc/class.rb', line 45
def sources
[code('objc', 'h'), code('objc', 'm')]
end
|