Class: Kilza::Objc
- Inherits:
-
Object
- Object
- Kilza::Objc
- Includes:
- Language
- Defined in:
- lib/kilza/language/objc.rb,
lib/kilza/language/objc.rb
Defined Under Namespace
Classes: Class
Instance Attribute Summary
Attributes included from Language
#base_name, #classes, #equal_keys, #json_string, #reserved_words, #types
Instance Method Summary collapse
- #get_class(name) ⇒ Object
-
#initialize(json_string) ⇒ Objc
constructor
A new instance of Objc.
- #parse(hash, class_name) ⇒ Object
Methods included from Language
Constructor Details
#initialize(json_string) ⇒ Objc
Returns a new instance of Objc.
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 |
# File 'lib/kilza/language/objc.rb', line 39 def initialize(json_string) super(json_string) @reserved_words = [ "auto", "break", "case", "char", "const", "continue", "class", "default", "do", "double", "else", "enum", "extern", "float", "for", "goto", "if", "id", "implementation", "inline", "int", "interface", "long", "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 *", "object" => "NSObject *" } @equal_keys = [ "id", "identifier", "uid" ] end |
Instance Method Details
#get_class(name) ⇒ Object
71 72 73 |
# File 'lib/kilza/language/objc.rb', line 71 def get_class(name) Kilza::Objc::Class.new(name) end |
#parse(hash, class_name) ⇒ Object
75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 |
# File 'lib/kilza/language/objc.rb', line 75 def parse(hash, class_name) super(hash, class_name) @classes.each { |cl| cl.properties.each { |pr| if pr.is_object? cl.imports.push("#import \"" + pr.name.capitalize + ".h\"") end if pr.is_array? pr.type = "NSMutableArray *" end pr.type = @types[pr.type] if not @types[pr.type].nil? } } end |