lib/kilza/language/java.rb in kilza-1.0.2 vs lib/kilza/language/java.rb in kilza-1.0.4

- old
+ new

@@ -1,90 +1,71 @@ require 'date' module Kilza class Java - class Class include Kilza::Class + # Represents the Java class package attr_accessor :package def initialize(name, package = nil) super(name) @package = package end def sources - cur_path = File.expand_path(__FILE__) - java_path = File.join(File.dirname(cur_path), File.basename(cur_path, '.rb'), "java.erb") - eruby_java = Erubis::Eruby.new(File.read(java_path)) - - java = Kilza::Source.new - java.source = eruby_java.result(binding) - java.file_name = @name.capitalize + ".java" - - result = [ - java - ] - return result + [code('java', 'java')] end end - end end module Kilza + # Objective-C Language parser class Java include Kilza::Language def initialize(json_string) super(json_string) - @reserved_words = [ - "abstract", "continue", "for", "new", "switch", "assert", "default", "goto", - "package", "synchronized", "boolean", "do", "if", "private", "this", "break", "double", "implements", - "protected", "throw", "byte", "else", "import", "public", "throws", "case", "enum", "instanceof", - "null", "return", "transient", "catch", "extends", "int", "short", "try", "char", "final", "interface", "static", - "void", "class", "finally", "long", "strictfp", "volatile", "const", "float", "native", "super", "while" - ] + @reserved_words = %w( + abstract continue for new switch assert default goto, + package synchronized boolean do if private this break double implements, + protected throw byte else import public throws case enum instanceof, + null return transient catch extends int short try char final interface static, + void class finally long strictfp volatile const float native super while + ) @types = { - "nilclass" => "Object", - "string" => "String", - "fixnum" => "Long", - "float" => "Double", - "falseclass" => "Boolean", - "trueclass" => "Boolean", - "object" => "Object" + 'nilclass' => 'Object', + 'string' => 'String', + 'fixnum' => 'Long', + 'float' => 'Double', + 'falseclass' => 'Boolean', + 'trueclass' => 'Boolean', + 'hash' => 'Object' } - @equal_keys = [ - "id", - "identifier", - "uid" - ] + @equal_keys = %w(id identifier uid) end - def get_class(name) + def clazz(name) Kilza::Java::Class.new(name) end - def parse(hash, class_name) - super(hash, class_name) + def classes(class_name) + super(class_name) - @classes.each { |cl| - cl.properties.each { |pr| - if pr.is_object? - pr.type = pr.name.capitalize - end + @classes.each do |cl| + cl.properties.each do |pr| + pr.type = pr.name.capitalize if pr.object? || (pr.array? && pr.null?) - if pr.is_array? - cl.imports.push("import java.util.ArrayList;") if cl.imports.index("import java.util.ArrayList;").nil? - end + cl.imports.push('import java.util.ArrayList;') if pr.array? && + cl.imports.index('import java.util.ArrayList;').nil? - pr.type = @types[pr.type] if not @types[pr.type].nil? - } - } + pr.type = @types[pr.type] unless @types[pr.type].nil? + end + end end - end end