Class: Kilza::Objc
- Inherits:
-
Object
- Object
- Kilza::Objc
- Includes:
- Language
- Defined in:
- lib/kilza/language/objc.rb,
lib/kilza/language/objc.rb
Overview
Objective-C Language parser
Defined Under Namespace
Classes: Class
Instance Attribute Summary
Attributes included from Language
#base_name, #equal_keys, #json_string, #reserved_delimiter, #reserved_words, #types
Instance Method Summary collapse
- #classes(class_name) ⇒ Object
- #clazz(name) ⇒ Object
-
#initialize(json_string) ⇒ Objc
constructor
A new instance of Objc.
Constructor Details
#initialize(json_string) ⇒ Objc
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/kilza/language/objc.rb', line 20 def initialize(json_string) super(json_string) @reserved_delimiter = '_my' @reserved_words = %w( auto break case char const continue, class default do double else enum extern float for, goto if id implementation inline int interface long, new nonatomic property protocol readonly readwrite register, restrict retain return short signed sizeof static strong, struct switch typedef union unsafe_unretained unsigned void, volatile weak while _bool _complex _imaginary sel imp, bool nil yes no self super __strong __weak oneway, in out inout bycopy byref ) @types = { 'nilclass' => 'id', 'string' => 'NSString *', 'fixnum' => 'NSNumber *', 'float' => 'NSNumber *', 'falseclass' => 'NSNumber *', 'trueclass' => 'NSNumber *', 'hash' => 'NSObject *' } @equal_keys = %w(id identifier uid) end |
Instance Method Details
#classes(class_name) ⇒ Object
54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 |
# File 'lib/kilza/language/objc.rb', line 54 def classes(class_name) super(class_name) @classes.each do |cl| cl.properties.each do |pr| if pr.object? || (pr.array? && pr.null?) pr.type = pr.name.capitalize + ' *' cl.imports.push("#import \"#{pr.name.capitalize}.h\"") end pr.type = 'NSMutableArray *' if pr.array? pr.type = @types[pr.type] unless @types[pr.type].nil? end end end |
#clazz(name) ⇒ Object
50 51 52 |
# File 'lib/kilza/language/objc.rb', line 50 def clazz(name) Kilza::Objc::Class.new(name) end |