$_J("net.sf.j2s.ajax");
$_L(null,"net.sf.j2s.ajax.SimpleSource4ObjectiveC",["java.io.File","java.lang.StringBuffer","java.util.ArrayList","$.Date","$.HashSet","net.sf.j2s.ajax.ISimpleConstant","$.SimpleSerializable","$.SourceUtils"],function(){
c$=$_T(net.sf.j2s.ajax,"SimpleSource4ObjectiveC");
c$.generateHeaderFromInterface=$_M(c$,"generateHeaderFromInterface",
function(interfaceClazz){
var source=new StringBuffer();
var clazzName=interfaceClazz.getName();
var simpleClazzName=clazzName;
var idx=clazzName.lastIndexOf('.');
if(idx!=-1){
simpleClazzName=clazzName.substring(idx+1);
}var date=new java.util.Date();
source.append("//\r\n");
source.append("//  ");
source.append(simpleClazzName);
source.append(".h\r\n");
source.append("//  ");
source.append(net.sf.j2s.ajax.SimpleSource4ObjectiveC.folder);
source.append("\r\n");
source.append("//\r\n");
source.append("//  Generated by Java2Script.\r\n");
source.append("//  Copyright (c) ");
source.append(date.getYear()+1900);
source.append(" ");
source.append(net.sf.j2s.ajax.SimpleSource4ObjectiveC.company);
source.append(". All rights reserved.\r\n");
source.append("//\r\n");
source.append("\r\n");
var index=0;
net.sf.j2s.ajax.SourceUtils.insertLineComment(source,"",index++,true);
var superClazz=interfaceClazz.getSuperclass();
if(superClazz!=null){
var superClazzName=superClazz.getName();
var simpleSuperClazzName=superClazzName;
idx=superClazzName.lastIndexOf('.');
if(idx!=-1){
simpleSuperClazzName=superClazzName.substring(idx+1);
}source.append("#import \"");
source.append(simpleSuperClazzName);
source.append(".h\"\r\n");
source.append("\r\n");
net.sf.j2s.ajax.SourceUtils.insertLineComment(source,"",index++,true);
}var gotStaticFinalFields=false;
var clazzFields=interfaceClazz.getDeclaredFields();
for(var i=0;i<clazzFields.length;i++){
var f=clazzFields[i];
var modifiers=f.getModifiers();
if((modifiers&(1))!=0&&(modifiers&8)!=0&&(modifiers&16)!=0){
source.append("#define ");
if(net.sf.j2s.ajax.SimpleSource4ObjectiveC.constantPrefix!=null&&net.sf.j2s.ajax.SimpleSource4ObjectiveC.constantPrefix.length>0){
source.append(net.sf.j2s.ajax.SimpleSource4ObjectiveC.constantPrefix);
}source.append(simpleClazzName.toUpperCase());
source.append("_");
source.append(f.getName());
source.append(" ");
var type=f.getType();
if(type===Number){
try{
source.append(""+f.getInt(interfaceClazz));
}catch(e){
e.printStackTrace();
}
}else if(type===Number){
try{
source.append(f.getLong(interfaceClazz)+"L");
}catch(e){
e.printStackTrace();
}
}else if(type===Number){
try{
source.append(""+f.getShort(interfaceClazz));
}catch(e){
e.printStackTrace();
}
}else if(type===Number){
try{
source.append(""+f.getByte(interfaceClazz));
}catch(e){
e.printStackTrace();
}
}else if(type===Number){
try{
source.append("\'"+f.getChar(interfaceClazz)+"\'");
}catch(e){
e.printStackTrace();
}
}else if(type===Number){
try{
source.append(""+f.getFloat(interfaceClazz));
}catch(e){
e.printStackTrace();
}
}else if(type===Number){
try{
source.append(""+f.getDouble(interfaceClazz));
}catch(e){
e.printStackTrace();
}
}else if(type===Boolean){
try{
if(f.getBoolean(interfaceClazz)){
source.append("true");
}else{
source.append("false");
}}catch(e){
e.printStackTrace();
}
}else if(type===String){
try{
source.append("@\""+f.get(interfaceClazz)+"\"");
}catch(e){
e.printStackTrace();
}
}else{
System.out.println("Not supporting type "+type+" for field "+f.getName());
}source.append("\r\n");
gotStaticFinalFields=true;
}}
if(gotStaticFinalFields){
source.append("\r\n");
net.sf.j2s.ajax.SourceUtils.insertLineComment(source,"",index++,true);
}return source.toString();
},"Class");
c$.generateHeaderFromObject=$_M(c$,"generateHeaderFromObject",
function(s){
var source=new StringBuffer();
var clazz=s.getClass();
var clazzName=clazz.getName();
var simpleClazzName=clazzName;
var idx=clazzName.lastIndexOf('.');
if(idx!=-1){
simpleClazzName=clazzName.substring(idx+1);
}var date=new java.util.Date();
source.append("//\r\n");
source.append("//  ");
source.append(simpleClazzName);
source.append(".h\r\n");
source.append("//  ");
source.append(net.sf.j2s.ajax.SimpleSource4ObjectiveC.folder);
source.append("\r\n");
source.append("//\r\n");
source.append("//  Generated by Java2Script.\r\n");
source.append("//  Copyright (c) ");
source.append(date.getYear()+1900);
source.append(" ");
source.append(net.sf.j2s.ajax.SimpleSource4ObjectiveC.company);
source.append(". All rights reserved.\r\n");
source.append("//\r\n");
source.append("\r\n");
var index=0;
net.sf.j2s.ajax.SourceUtils.insertLineComment(source,"",index++,true);
var superClazz=s.getClass().getSuperclass();
var superClazzName=superClazz.getName();
var simpleSuperClazzName=superClazzName;
idx=superClazzName.lastIndexOf('.');
if(idx!=-1){
simpleSuperClazzName=superClazzName.substring(idx+1);
}source.append("#import \"");
source.append(simpleSuperClazzName);
source.append(".h\"\r\n");
source.append("\r\n");
var interfaces=s.getClass().getGenericInterfaces();
if(interfaces!=null&&interfaces.length>0){
for(var i=0;i<interfaces.length;i++){
var t=interfaces[i];
if(!net.sf.j2s.ajax.SimpleSerializable.isSubInterfaceOf(t,net.sf.j2s.ajax.ISimpleConstant)){
continue;
}var typeName=t.getName();
var simpleTypeName=typeName;
idx=simpleTypeName.lastIndexOf('.');
if(idx!=-1){
simpleTypeName=simpleTypeName.substring(idx+1);
}source.append("#import \"");
source.append(simpleTypeName);
source.append(".h\"\r\n");
}
source.append("\r\n");
}var gotStaticFinalFields=false;
var clazzFields=clazz.getDeclaredFields();
var fields=new java.util.ArrayList();
for(var i=0;i<clazzFields.length;i++){
var f=clazzFields[i];
var modifiers=f.getModifiers();
if((modifiers&(1))!=0&&(modifiers&(136))==0){
fields.add(f);
}}
var hasMoreImports=false;
var importedClasses=new java.util.HashSet();
for(var itr=fields.iterator();itr.hasNext();){
var field=itr.next();
var type=field.getType();
if(net.sf.j2s.ajax.SimpleSerializable.isSubclassOf(type,net.sf.j2s.ajax.SimpleSerializable)||net.sf.j2s.ajax.SimpleSerializable.isSubclassOf(type,Array)){
hasMoreImports=true;
var typeName=type.isArray()?type.getComponentType().getSimpleName():type.getSimpleName();
if(!importedClasses.contains(typeName)){
source.append("#import \"");
source.append(typeName);
source.append(".h\"\r\n");
importedClasses.add(typeName);
}}}
if(hasMoreImports){
source.append("\r\n");
}var defineAppended=false;
for(var i=0;i<clazzFields.length;i++){
var f=clazzFields[i];
var modifiers=f.getModifiers();
if((modifiers&(1))!=0&&(modifiers&8)!=0&&(modifiers&16)!=0){
if(!defineAppended){
net.sf.j2s.ajax.SourceUtils.insertLineComment(source,"",index++,true);
}defineAppended=true;
source.append("#define ");
if(net.sf.j2s.ajax.SimpleSource4ObjectiveC.constantPrefix!=null&&net.sf.j2s.ajax.SimpleSource4ObjectiveC.constantPrefix.length>0){
source.append(net.sf.j2s.ajax.SimpleSource4ObjectiveC.constantPrefix);
}source.append(simpleClazzName.toUpperCase());
source.append("_");
source.append(f.getName());
source.append(" ");
var type=f.getType();
if(type===Number){
try{
source.append(""+f.getInt(s.getClass()));
}catch(e){
e.printStackTrace();
}
}else if(type===Number){
try{
source.append(f.getLong(s.getClass())+"L");
}catch(e){
e.printStackTrace();
}
}else if(type===Number){
try{
source.append(""+f.getShort(s.getClass()));
}catch(e){
e.printStackTrace();
}
}else if(type===Number){
try{
source.append(""+f.getByte(s.getClass()));
}catch(e){
e.printStackTrace();
}
}else if(type===Number){
try{
source.append("\'"+f.getChar(s.getClass())+"\'");
}catch(e){
e.printStackTrace();
}
}else if(type===Number){
try{
source.append(""+f.getFloat(s.getClass()));
}catch(e){
e.printStackTrace();
}
}else if(type===Number){
try{
source.append(""+f.getDouble(s.getClass()));
}catch(e){
e.printStackTrace();
}
}else if(type===Boolean){
try{
if(f.getBoolean(s.getClass())){
source.append("true");
}else{
source.append("false");
}}catch(e){
e.printStackTrace();
}
}else if(type===String){
try{
source.append("@\""+f.get(s.getClass())+"\"");
}catch(e){
e.printStackTrace();
}
}else{
System.out.println("Not supporting type "+type+" for field "+f.getName());
}source.append("\r\n");
gotStaticFinalFields=true;
}}
if(gotStaticFinalFields){
source.append("\r\n");
}if(!defineAppended){
index++;
}net.sf.j2s.ajax.SourceUtils.insertLineComment(source,"",index++,true);
source.append("@protocol ");
source.append(simpleClazzName);
source.append("\r\n\r\n");
net.sf.j2s.ajax.SourceUtils.insertLineComment(source,"",index++,true);
source.append("@end\r\n\r\n");
net.sf.j2s.ajax.SourceUtils.insertLineComment(source,"",index++,true);
source.append("@interface ");
source.append(simpleClazzName);
source.append(" : ");
source.append(simpleSuperClazzName);
net.sf.j2s.ajax.SourceUtils.insertBlockComment(source,index++);
source.append("{\r\n");
source.append("\r\n");
net.sf.j2s.ajax.SourceUtils.insertLineComment(source,"\t",index++,true);
for(var itr=fields.iterator();itr.hasNext();){
var field=itr.next();
var name=field.getName();
var type=field.getType();
source.append("\t");
if(type===Number){
source.append("int ");
}else if(type===Number){
source.append("long long ");
}else if(type===Number){
source.append("short ");
}else if(type===Number){
source.append("int ");
}else if(type===Number){
source.append("int ");
}else if(type===Number){
source.append("double ");
}else if(type===Number){
source.append("float ");
}else if(type===Boolean){
source.append("BOOL ");
}else if(type===String){
source.append("NSString *");
}else if(net.sf.j2s.ajax.SimpleSerializable.isSubclassOf(type,net.sf.j2s.ajax.SimpleSerializable)){
source.append(type.getSimpleName());
source.append(" *");
}else if(type===Array){
if(s.bytesCompactMode()){
source.append("NSData *");
}else{
source.append("NSMutableArray<NSNumber> *");
}}else if(type===Array){
source.append("NSMutableArray<NSString> *");
}else if(net.sf.j2s.ajax.SimpleSerializable.isSubclassOf(type,Array)){
source.append("NSMutableArray<");
source.append(type.getComponentType().getSimpleName());
source.append("> *");
}else if(type===Array||type===Array||type===Array||type===Array||type===Array||type===Array||type===Array){
source.append("NSMutableArray<NSNumber> *");
}else{
System.out.println("Unsupported type "+type);
}source.append(name);
source.append(";\r\n");
}
source.append("\r\n");
net.sf.j2s.ajax.SourceUtils.insertLineComment(source,"\t",index++,true);
source.append("}\r\n");
source.append("\r\n");
net.sf.j2s.ajax.SourceUtils.insertLineComment(source,"",index++,true);
for(var itr=fields.iterator();itr.hasNext();){
var field=itr.next();
var name=field.getName();
var type=field.getType();
source.append("@property (nonatomic");
if(type===Number){
source.append(") int ");
}else if(type===Number){
source.append(") long long ");
}else if(type===Number){
source.append(") short ");
}else if(type===Number){
source.append(") int ");
}else if(type===Number){
source.append(") int ");
}else if(type===Number){
source.append(") double ");
}else if(type===Number){
source.append(") float ");
}else if(type===Boolean){
source.append(") BOOL ");
}else if(type===String){
source.append(", retain) NSString *");
}else if(net.sf.j2s.ajax.SimpleSerializable.isSubclassOf(type,net.sf.j2s.ajax.SimpleSerializable)){
source.append(", retain) ");
source.append(type.getSimpleName());
source.append(" *");
}else if(type===Array){
if(s.bytesCompactMode()){
source.append(", retain) NSData *");
}else{
source.append(", retain) NSMutableArray<NSNumber> *");
}}else if(type===Array){
source.append(", retain) NSMutableArray<NSString> *");
}else if(net.sf.j2s.ajax.SimpleSerializable.isSubclassOf(type,Array)){
source.append(", retain) NSMutableArray<");
source.append(type.getComponentType().getSimpleName());
source.append("> *");
}else if(type===Array||type===Array||type===Array||type===Array||type===Array||type===Array||type===Array||type===Array||net.sf.j2s.ajax.SimpleSerializable.isSubclassOf(type,Array)){
source.append(", retain) NSMutableArray<NSNumber> *");
}else{
System.out.println("Unsupported type "+type);
}source.append(name);
source.append(";\r\n");
}
source.append("\r\n");
net.sf.j2s.ajax.SourceUtils.insertLineComment(source,"",index++,true);
source.append("- (NSString *) className;\r\n");
source.append("- (NSMutableArray *) fields;\r\n");
source.append("\r\n");
net.sf.j2s.ajax.SourceUtils.insertLineComment(source,"",index++,true);
source.append("@end\r\n");
return source.toString();
},"net.sf.j2s.ajax.SimpleSerializable");
c$.generateImplementation=$_M(c$,"generateImplementation",
function(s){
var source=new StringBuffer();
var clazz=s.getClass();
var clazzName=clazz.getName();
var simpleClazzName=clazzName;
var idx=clazzName.lastIndexOf('.');
if(idx!=-1){
simpleClazzName=clazzName.substring(idx+1);
}var date=new java.util.Date();
source.append("//\r\n");
source.append("//  ");
source.append(simpleClazzName);
source.append(".m\r\n");
source.append("//  ");
source.append(net.sf.j2s.ajax.SimpleSource4ObjectiveC.folder);
source.append("\r\n");
source.append("//\r\n");
source.append("//  Generated by Java2Script.\r\n");
source.append("//  Copyright (c) ");
source.append(date.getYear()+1900);
source.append(" ");
source.append(net.sf.j2s.ajax.SimpleSource4ObjectiveC.company);
source.append(". All rights reserved.\r\n");
source.append("//\r\n");
source.append("\r\n");
var index=0;
net.sf.j2s.ajax.SourceUtils.insertLineComment(source,"",index++,true);
source.append("#import \"");
source.append(simpleClazzName);
source.append(".h\"\r\n");
source.append("\r\n");
net.sf.j2s.ajax.SourceUtils.insertLineComment(source,"",index++,true);
source.append("@implementation ");
source.append(simpleClazzName);
source.append("\r\n");
source.append("\r\n");
net.sf.j2s.ajax.SourceUtils.insertLineComment(source,"",index++,true);
var j2sIgnoredFileds=new java.util.HashSet();
var fields=new java.util.ArrayList();
var clazzFields=clazz.getDeclaredFields();
for(var i=0;i<clazzFields.length;i++){
var f=clazzFields[i];
var modifiers=f.getModifiers();
if((modifiers&(1))!=0&&(modifiers&(136))==0){
fields.add(f);
if((modifiers&4)!=0){
j2sIgnoredFileds.add(f.getName());
}}}
var needDealloc=false;
for(var itr=fields.iterator();itr.hasNext();){
var field=itr.next();
var name=field.getName();
var type=field.getType();
if(type===String||net.sf.j2s.ajax.SimpleSerializable.isSubclassOf(type,net.sf.j2s.ajax.SimpleSerializable)){
needDealloc=true;
}else if(type===Array||type===Array||type===Array||type===Array||type===Array||type===Array||type===Array||type===Array||type===Array||net.sf.j2s.ajax.SimpleSerializable.isSubclassOf(type,Array)){
needDealloc=true;
}source.append("@synthesize ");
source.append(name);
source.append(";\r\n");
}
source.append("\r\n");
net.sf.j2s.ajax.SourceUtils.insertLineComment(source,"",index++,true);
source.append("- (NSString *) className {\r\n");
net.sf.j2s.ajax.SourceUtils.insertLineComment(source,"\t",index++,false);
source.append("\treturn @\"");
source.append(clazzName);
source.append("\";\r\n");
net.sf.j2s.ajax.SourceUtils.insertLineComment(source,"\t",index++,false);
source.append("}\r\n");
source.append("\r\n");
source.append("- (NSMutableArray *) fields {\r\n");
source.append("\tNSMutableArray *arr = [super fields];\r\n");
net.sf.j2s.ajax.SourceUtils.insertLineComment(source,"\t",index++,false);
for(var itr=fields.iterator();itr.hasNext();){
var field=itr.next();
var name=field.getName();
if(j2sIgnoredFileds.contains(name)){
System.out.println("Ignoring ..."+name);
continue;
}var type=field.getType();
source.append("\t[arr addObject:[SimpleField makeField:@\"");
source.append(name);
source.append("\" withType:SimpleFieldType");
if(type===Number){
source.append("Int");
}else if(type===Number){
source.append("Long");
}else if(type===Number){
source.append("Short");
}else if(type===Number){
source.append("Byte");
}else if(type===Number){
source.append("Char");
}else if(type===Number){
source.append("Double");
}else if(type===Number){
source.append("Float");
}else if(type===Boolean){
source.append("Boolean");
}else if(type===String){
source.append("String");
}else if(net.sf.j2s.ajax.SimpleSerializable.isSubclassOf(type,net.sf.j2s.ajax.SimpleSerializable)){
source.append("Object");
}else if(type===Array){
source.append("IntArray");
}else if(type===Array){
source.append("LongArray");
}else if(type===Array){
source.append("ShortArray");
}else if(type===Array){
if(s.bytesCompactMode()){
source.append("ByteData");
}else{
source.append("ByteArray");
}}else if(type===Array){
source.append("CharArray");
}else if(type===Array){
source.append("FloatArray");
}else if(type===Array){
source.append("DoubleArray");
}else if(type===Array){
source.append("BooleanArray");
}else if(type===Array){
source.append("StringArray");
}else if(net.sf.j2s.ajax.SimpleSerializable.isSubclassOf(type,Array)){
source.append("ObjectArray");
}else{
System.out.println("Unsupported type "+type);
}source.append("]];\r\n");
}
net.sf.j2s.ajax.SourceUtils.insertLineComment(source,"\t",index++,false);
source.append("\treturn arr;\r\n");
source.append("}\r\n");
source.append("\r\n");
if(needDealloc){
source.append("- (void) dealloc {\r\n");
net.sf.j2s.ajax.SourceUtils.insertLineComment(source,"\t",index++,false);
for(var itr=fields.iterator();itr.hasNext();){
var field=itr.next();
var name=field.getName();
var type=field.getType();
if(type===String||net.sf.j2s.ajax.SimpleSerializable.isSubclassOf(type,net.sf.j2s.ajax.SimpleSerializable)||type===Array||type===Array||type===Array||type===Array||type===Array||type===Array||type===Array||type===Array||type===Array||net.sf.j2s.ajax.SimpleSerializable.isSubclassOf(type,Array)){
source.append("\tself.");
source.append(name);
source.append(" = nil;\r\n");
}}
net.sf.j2s.ajax.SourceUtils.insertLineComment(source,"\t",index++,false);
source.append("\t[super dealloc];\r\n");
source.append("}\r\n");
source.append("\r\n");
}net.sf.j2s.ajax.SourceUtils.insertLineComment(source,"",index++,true);
source.append("@end\r\n");
return source.toString();
},"net.sf.j2s.ajax.SimpleSerializable");
c$.main=$_M(c$,"main",
function(args){
if(args==null||args.length<5){
System.out.println("Usage: "+net.sf.j2s.ajax.SimpleSource4ObjectiveC.getName()+" <sources folder> <author> <orgization or company> <constant prefix> <factory name> <class> [class ...]");
return;
}var targetFolder=args[0];
var f=new java.io.File(targetFolder);
if(f.exists()){
if(!f.isDirectory()){
System.out.println("Target folder "+f.getAbsolutePath()+" is not a folder.");
return;
}}else{
var ok=f.mkdirs();
if(!ok){
System.out.println("Failed to create target folder "+f.getAbsolutePath()+".");
return;
}}($t$=net.sf.j2s.ajax.SimpleSource4ObjectiveC.folder=f.getName(),net.sf.j2s.ajax.SimpleSource4ObjectiveC.prototype.folder=net.sf.j2s.ajax.SimpleSource4ObjectiveC.folder,$t$);
($t$=net.sf.j2s.ajax.SimpleSource4ObjectiveC.author=args[1],net.sf.j2s.ajax.SimpleSource4ObjectiveC.prototype.author=net.sf.j2s.ajax.SimpleSource4ObjectiveC.author,$t$);
($t$=net.sf.j2s.ajax.SimpleSource4ObjectiveC.company=args[2],net.sf.j2s.ajax.SimpleSource4ObjectiveC.prototype.company=net.sf.j2s.ajax.SimpleSource4ObjectiveC.company,$t$);
($t$=net.sf.j2s.ajax.SimpleSource4ObjectiveC.constantPrefix=args[3],net.sf.j2s.ajax.SimpleSource4ObjectiveC.prototype.constantPrefix=net.sf.j2s.ajax.SimpleSource4ObjectiveC.constantPrefix,$t$);
var factoryClazz=args[4];
for(var i=5;i<args.length;i++){
var j2sSimpleClazz=args[i];
try{
var clazz=Class.forName(j2sSimpleClazz);
if(clazz.isInterface()){
var simpleName=j2sSimpleClazz;
var idx=j2sSimpleClazz.lastIndexOf('.');
if(idx!=-1){
simpleName=j2sSimpleClazz.substring(idx+1);
}var hSource=net.sf.j2s.ajax.SimpleSource4ObjectiveC.generateHeaderFromInterface(clazz);
net.sf.j2s.ajax.SourceUtils.updateSourceContent(new java.io.File(targetFolder,simpleName+".h"),hSource);
System.out.println(new java.io.File(targetFolder,simpleName+".h").getAbsolutePath());
continue;
}var inst=clazz.newInstance();
if($_O(inst,net.sf.j2s.ajax.SimpleSerializable)){
var s=inst;
var simpleName=j2sSimpleClazz;
var idx=j2sSimpleClazz.lastIndexOf('.');
if(idx!=-1){
simpleName=j2sSimpleClazz.substring(idx+1);
}var hSource=net.sf.j2s.ajax.SimpleSource4ObjectiveC.generateHeaderFromObject(s);
net.sf.j2s.ajax.SourceUtils.updateSourceContent(new java.io.File(targetFolder,simpleName+".h"),hSource);
System.out.println(new java.io.File(targetFolder,simpleName+".h").getAbsolutePath());
var mSource=net.sf.j2s.ajax.SimpleSource4ObjectiveC.generateImplementation(s);
net.sf.j2s.ajax.SourceUtils.updateSourceContent(new java.io.File(targetFolder,simpleName+".m"),mSource);
System.out.println(new java.io.File(targetFolder,simpleName+".m").getAbsolutePath());
}}catch(e){
System.out.println("Failed to generate source for "+j2sSimpleClazz);
e.printStackTrace();
}
}
var simpleClazzName=factoryClazz;
var idx=factoryClazz.lastIndexOf('.');
if(idx!=-1){
simpleClazzName=factoryClazz.substring(idx+1);
}{
var source=new StringBuffer();
var date=new java.util.Date();
source.append("//\r\n");
source.append("//  ");
source.append(simpleClazzName);
source.append(".h\r\n");
source.append("//  ");
source.append(net.sf.j2s.ajax.SimpleSource4ObjectiveC.folder);
source.append("\r\n");
source.append("//\r\n");
source.append("//  Generated by Java2Script.\r\n");
source.append("//  Copyright (c) ");
source.append(date.getYear()+1900);
source.append(" ");
source.append(net.sf.j2s.ajax.SimpleSource4ObjectiveC.company);
source.append(". All rights reserved.\r\n");
source.append("//\r\n");
source.append("\r\n");
var index=0;
net.sf.j2s.ajax.SourceUtils.insertLineComment(source,"",index++,true);
source.append("#import \"SimpleFactory.h\"\r\n");
source.append("\r\n");
for(var i=5;i<args.length;i++){
var j2sSimpleClazz=args[i];
try{
var clazz=Class.forName(j2sSimpleClazz);
if(clazz.isInterface()){
continue;
}var inst=clazz.newInstance();
if($_O(inst,net.sf.j2s.ajax.SimpleSerializable)){
if(!($_O(inst,net.sf.j2s.ajax.SimpleRPCRunnable))){
var simpleName=j2sSimpleClazz;
idx=j2sSimpleClazz.lastIndexOf('.');
if(idx!=-1){
simpleName=j2sSimpleClazz.substring(idx+1);
}source.append("#import \"");
source.append(simpleName);
source.append(".h\"\r\n");
}}}catch(e){
e.printStackTrace();
}
}
source.append("\r\n");
net.sf.j2s.ajax.SourceUtils.insertLineComment(source,"",index++,true);
source.append("@interface ");
source.append(simpleClazzName);
source.append(" : SimpleFactory");
net.sf.j2s.ajax.SourceUtils.insertBlockComment(source,index++);
source.append("{\r\n\r\n");
net.sf.j2s.ajax.SourceUtils.insertLineComment(source,"\t",index++,true);
source.append("}\r\n\r\n");
net.sf.j2s.ajax.SourceUtils.insertLineComment(source,"",index++,true);
source.append("- (id) createInstanceByClassName:(NSString *) className;\r\n");
source.append("\r\n");
net.sf.j2s.ajax.SourceUtils.insertLineComment(source,"",index++,true);
source.append("@end\r\n");
net.sf.j2s.ajax.SourceUtils.updateSourceContent(new java.io.File(targetFolder,simpleClazzName+".h"),source.toString());
}{
var source=new StringBuffer();
var date=new java.util.Date();
source.append("//\r\n");
source.append("//  ");
source.append(simpleClazzName);
source.append(".m\r\n");
source.append("//  ");
source.append(net.sf.j2s.ajax.SimpleSource4ObjectiveC.folder);
source.append("\r\n");
source.append("//\r\n");
source.append("//  Generated by Java2Script.\r\n");
source.append("//  Copyright (c) ");
source.append(date.getYear()+1900);
source.append(" ");
source.append(net.sf.j2s.ajax.SimpleSource4ObjectiveC.company);
source.append(". All rights reserved.\r\n");
source.append("//\r\n");
source.append("\r\n");
var index=0;
net.sf.j2s.ajax.SourceUtils.insertLineComment(source,"",index++,true);
source.append("#import \"");
source.append(simpleClazzName);
source.append(".h\"\r\n");
source.append("\r\n");
net.sf.j2s.ajax.SourceUtils.insertLineComment(source,"",index++,true);
source.append("@implementation ");
source.append(simpleClazzName);
source.append("\r\n");
source.append("\r\n");
net.sf.j2s.ajax.SourceUtils.insertLineComment(source,"",index++,true);
source.append("- (id) createInstanceByClassName:(NSString *) className {\r\n");
net.sf.j2s.ajax.SourceUtils.insertLineComment(source,"\t",index++,false);
for(var i=5;i<args.length;i++){
var j2sSimpleClazz=args[i];
try{
var clazz=Class.forName(j2sSimpleClazz);
if(clazz.isInterface()){
continue;
}var inst=clazz.newInstance();
if($_O(inst,net.sf.j2s.ajax.SimpleSerializable)){
if(!($_O(inst,net.sf.j2s.ajax.SimpleRPCRunnable))){
var simpleName=j2sSimpleClazz;
idx=j2sSimpleClazz.lastIndexOf('.');
if(idx!=-1){
simpleName=j2sSimpleClazz.substring(idx+1);
}source.append("\tif ([className compare:@\"");
source.append(j2sSimpleClazz);
source.append("\"] == 0) {\r\n");
source.append("\t\treturn [[[");
source.append(simpleName);
source.append(" alloc] init] autorelease];\r\n");
source.append("\t}\r\n");
}}}catch(e){
e.printStackTrace();
}
}
net.sf.j2s.ajax.SourceUtils.insertLineComment(source,"\t",index++,false);
source.append("\treturn nil;\r\n");
source.append("}\r\n");
source.append("\r\n");
net.sf.j2s.ajax.SourceUtils.insertLineComment(source,"",index++,true);
source.append("@end\r\n");
net.sf.j2s.ajax.SourceUtils.updateSourceContent(new java.io.File(targetFolder,simpleClazzName+".m"),source.toString());
}},"~A");
$_S(c$,
"folder","Project",
"author","Author",
"company","Company",
"constantPrefix","C_");
});
