private static void generateImplementationStructPairs( Proc proc, String mainName, PrintWriter outData) { if (proc.outputs.size() > 0) { outData.println("@implementation O" + mainName + "Rec"); for (int i = 0; i < proc.outputs.size(); i++) { Field field = (Field) proc.outputs.elementAt(i); if (field.type == Field.BLOB) { outData.println("@synthesize " + useLowerName(field) + "_len;"); outData.println("@synthesize " + useLowerName(field) + "_data;"); } else outData.println("@synthesize " + useLowerName(field) + ";"); if (isNull(field) == true) outData.println("@synthesize " + useLowerName(field) + "IsNull;"); } outData.println("- (id)init"); outData.println(" {"); outData.println(" self = [super init];"); outData.println(" return self;"); outData.println(" }"); outData.println("- (void)clear"); outData.println(" {"); for (int i = 0; i < proc.outputs.size(); i++) { Field field = (Field) proc.outputs.elementAt(i); clearCall(field, outData); if (isNull(field) == true) // && field.isEmptyOrAnsiAsNull() == false) outData.println(" self." + useLowerName(field) + "IsNull = NO;"); } outData.println(" }"); outData.println("- (void)write:(Writer*)writer"); outData.println(" {"); for (int i = 0; i < proc.outputs.size(); i++) { Field field = (Field) proc.outputs.elementAt(i); writeCall(field, outData); if (isNull(field) == true) // && field.isEmptyOrAnsiAsNull() == false) outData.println( " [writer putBoolean:self." + useLowerName(field) + "IsNull];[writer filler:6];"); } outData.println(" }"); outData.println("- (void)read:(Reader*)reader"); outData.println(" {"); for (int i = 0; i < proc.outputs.size(); i++) { Field field = (Field) proc.outputs.elementAt(i); readCall(field, outData); if (isNull(field) == true) // && field.isEmptyOrAnsiAsNull() == false) outData.println( " self." + useLowerName(field) + "IsNull = [reader getBoolean];[reader skip:6];"); } outData.println(" }"); outData.println("- (void)dealloc"); outData.println(" {"); for (int i = 0; i < proc.outputs.size(); i++) { Field field = (Field) proc.outputs.elementAt(i); freeCall(field, outData); } outData.println(" [super dealloc];"); outData.println(" }"); outData.println("@end"); outData.println(); } if (proc.inputs.size() + proc.dynamics.size() > 0) { outData.println("@implementation D" + mainName + "Rec"); for (int i = 0; i < proc.inputs.size(); i++) { Field field = (Field) proc.inputs.elementAt(i); if (proc.hasOutput(field.name)) continue; if (field.type == Field.BLOB) { outData.println("@synthesize " + useLowerName(field) + "_len;"); outData.println("@synthesize " + useLowerName(field) + "_data;"); } else outData.println("@synthesize " + useLowerName(field) + ";"); if (isNull(field) == true) outData.println("@synthesize " + useLowerName(field) + "IsNull;"); } for (int i = 0; i < proc.dynamics.size(); i++) { String name = (String) proc.dynamics.elementAt(i); Field field = new Field(); field.name = name; outData.println("@synthesize " + useLowerName(field) + ";"); } outData.println("- (id)init"); outData.println(" {"); outData.println(" self = [super init];"); outData.println(" return self;"); outData.println(" }"); outData.println("- (void)clear"); outData.println(" {"); if (proc.outputs.size() > 0) outData.println(" [super clear];"); for (int i = 0; i < proc.inputs.size(); i++) { Field field = (Field) proc.inputs.elementAt(i); clearCall(field, outData); if (isNull(field) == true) // && field.isEmptyOrAnsiAsNull() == false) outData.println(" self." + useLowerName(field) + "IsNull = NO;"); } for (int i = 0; i < proc.dynamics.size(); i++) { Field field = new Field(); field.name = (String) proc.dynamics.elementAt(i); field.length = ((Integer) proc.dynamicSizes.elementAt(i)).intValue(); field.type = Field.CHAR; clearCall(field, outData); } outData.println(" }"); outData.println("- (void)write:(Writer*)writer"); outData.println(" {"); if (proc.outputs.size() > 0) outData.println(" [super write:writer];"); for (int i = 0; i < proc.inputs.size(); i++) { Field field = (Field) proc.inputs.elementAt(i); writeCall(field, outData); if (isNull(field) == true) // && field.isEmptyOrAnsiAsNull() == false) outData.println( " [writer putBoolean:self." + useLowerName(field) + "IsNull];[writer filler:6];"); } for (int i = 0; i < proc.dynamics.size(); i++) { Field field = new Field(); field.name = (String) proc.dynamics.elementAt(i); field.length = ((Integer) proc.dynamicSizes.elementAt(i)).intValue(); field.type = Field.CHAR; writeCall(field, outData); } outData.println(" }"); outData.println("- (void)read:(Reader*)reader"); outData.println(" {"); if (proc.outputs.size() > 0) outData.println(" [super read:reader];"); for (int i = 0; i < proc.inputs.size(); i++) { Field field = (Field) proc.inputs.elementAt(i); readCall(field, outData); if (isNull(field) == true) // && field.isEmptyOrAnsiAsNull() == false) outData.println( " self." + useLowerName(field) + "IsNull = [reader getBoolean];[reader skip:6];"); } for (int i = 0; i < proc.dynamics.size(); i++) { Field field = new Field(); field.name = (String) proc.dynamics.elementAt(i); field.length = ((Integer) proc.dynamicSizes.elementAt(i)).intValue(); field.type = Field.CHAR; readCall(field, outData); } outData.println(" }"); outData.println("- (void)dealloc"); outData.println(" {"); for (int i = 0; i < proc.dynamics.size(); i++) { Field field = new Field(); field.name = (String) proc.dynamics.elementAt(i); outData.println(" [" + useLowerName(field) + " release];"); } outData.println(" [super dealloc];"); outData.println(" }"); outData.println("@end"); outData.println(); } }
/** Build of output data rec for user procedures */ static void generateUserOutputRecs(Table table, PrintWriter outData) { for (int i = 0; i < table.procs.size(); i++) { Proc proc = (Proc) table.procs.elementAt(i); if (proc.isData || proc.isStd || proc.hasNoData()) continue; if (proc.isStdExtended()) continue; String work = "(object)"; String superName = ""; if (proc.outputs.size() > 0) { for (int j = 0; j < proc.comments.size(); j++) outData.println("##" + (String) proc.comments.elementAt(j)); String typeChar = "D"; if (proc.hasDiscreteInput()) typeChar = "O"; work = "(" + typeChar + table.useName() + proc.upperFirst() + ")"; superName = typeChar + table.useName() + proc.upperFirst(); outData.println("## \\class " + typeChar + table.useName() + proc.upperFirst()); outData.println("class " + typeChar + table.useName() + proc.upperFirst() + "(object):"); outData.println( " def _make(self): return " + typeChar + table.useName() + proc.upperFirst() + "()"); if (proc.hasDiscreteInput()) outData.println( " def _name(self): return ('" + typeChar + table.useName() + proc.upperFirst() + "')"); else outData.println( " def _name(self): return ('D" + table.useName() + proc.upperFirst() + "', 'O" + table.useName() + proc.upperFirst() + "')"); generateDataFields( proc.outputs, "", typeChar + table.useName() + proc.upperFirst(), table.useName(), outData); outData.println(); } if (proc.hasDiscreteInput()) { outData.println("## \\class D" + table.useName() + proc.upperFirst()); outData.println("class D" + table.useName() + proc.upperFirst() + work + ":"); outData.println( " def _make(self): return D" + table.useName() + proc.upperFirst() + "()"); outData.println( " def _name(self): return ('D" + table.useName() + proc.upperFirst() + "')"); Vector<Field> discreteInputs = new Vector<Field>(); for (int j = 0; j < proc.inputs.size(); j++) { Field field = (Field) proc.inputs.elementAt(j); if (!proc.hasOutput(field.name)) discreteInputs.addElement(field); } for (int j = 0; j < proc.dynamics.size(); j++) { Field f = new Field(); Integer length = (Integer) proc.dynamicSizes.elementAt(j); f.name = (String) proc.dynamics.elementAt(j); f.type = Field.CHAR; f.length = length.intValue(); discreteInputs.addElement(f); } generateDataFields( discreteInputs, superName, "D" + table.useName() + proc.upperFirst(), table.useName(), outData); outData.println(); } else if (proc.outputs.size() > 0) { outData.println("## \\class O" + table.useName() + proc.upperFirst()); outData.println("## \\field see:O" + table.useName() + proc.upperFirst()); outData.println( "O" + table.useName() + proc.upperFirst() + " = D" + table.useName() + proc.upperFirst()); outData.println(); } if (pymodName.length() > 0) { coverFunctions = new Vector<String>(); outData.println( "class " + table.useName() + proc.upperFirst() + "(D" + table.useName() + proc.upperFirst() + "):"); outData.println( " def __init__(self): D" + table.useName() + proc.upperFirst() + ".__init__(self)"); if (proc.isMultipleInput) generateBulkAction(table, proc, outData); else if (proc.isInsert && proc.hasReturning) generateAction(table, proc, outData); else if (proc.outputs.size() > 0) if (proc.isSingle) generateSingle(table, proc, outData); else generateMultiple(table, proc, outData); else generateAction(table, proc, outData); outData.println(); for (int j = 0; j < coverFunctions.size(); j++) outData.println((String) coverFunctions.elementAt(j)); } } }
private static void generateInterfaceStructPairs( Proc proc, String mainName, PrintWriter outData) { if (proc.outputs.size() > 0) { outData.println("@interface O" + mainName + "Rec:NSObject"); outData.println("{"); outData.println(" @protected"); for (int i = 0; i < proc.outputs.size(); i++) { Field field = (Field) proc.outputs.elementAt(i); outData.println(" " + fieldDef(field)); if (isNull(field) == true) // && field.isEmptyOrAnsiAsNull() == false) outData.println(" BOOL " + useLowerName(field) + "IsNull;"); } outData.println("}"); for (int i = 0; i < proc.outputs.size(); i++) { Field field = (Field) proc.outputs.elementAt(i); if (field.type == Field.BLOB) { outData.println("@property (readwrite) int32 " + useLowerName(field) + "_len;"); outData.println("@property (retain) NSMutableData* " + useLowerName(field) + "_data;"); } else outData.println("@property (" + fieldProp(field) + ") " + fieldDef(field)); if (isNull(field) == true) // && field.isEmptyOrAnsiAsNull() == false) outData.println("@property (readwrite) BOOL " + useLowerName(field) + "IsNull;"); } outData.println("- (id)init;"); outData.println("- (void)clear;"); outData.println("- (void)write:(Writer*)writer;"); outData.println("- (void)read:(Reader*)reader;"); outData.println("- (void)dealloc;"); outData.println("@end"); if (proc.inputs.size() + proc.dynamics.size() == 0) outData.println("#define D" + mainName + "Rec O" + mainName + "Rec"); outData.println(); } if (proc.inputs.size() + proc.dynamics.size() > 0) { if (proc.outputs.size() > 0) outData.println("@interface D" + mainName + "Rec:O" + mainName + "Rec"); else outData.println("@interface D" + mainName + "Rec:NSObject"); outData.println("{"); outData.println(" @protected"); for (int j = 0; j < proc.inputs.size(); j++) { Field field = (Field) proc.inputs.elementAt(j); if (proc.hasOutput(field.name)) continue; outData.println(" " + fieldDef(field)); if (isNull(field) == true) outData.println(" BOOL " + useLowerName(field) + "IsNull;"); } for (int j = 0; j < proc.dynamics.size(); j++) { String s = (String) proc.dynamics.elementAt(j); Integer n = (Integer) proc.dynamicSizes.elementAt(j); Field field = new Field(); field.name = s; field.type = Field.CHAR; field.length = n.intValue(); outData.println(" " + fieldDef(field)); } outData.println("}"); for (int j = 0; j < proc.inputs.size(); j++) { Field field = (Field) proc.inputs.elementAt(j); if (proc.hasOutput(field.name)) continue; if (field.type == Field.BLOB) { outData.println("@property (readwrite) int32 " + useLowerName(field) + "_len;"); outData.println("@property (retain) NSMutableData* " + useLowerName(field) + "_data;"); } else outData.println("@property (" + fieldProp(field) + ") " + fieldDef(field)); if (isNull(field) == true) outData.println("@property (readwrite) BOOL " + useLowerName(field) + "IsNull;"); } for (int j = 0; j < proc.dynamics.size(); j++) { String s = (String) proc.dynamics.elementAt(j); Field field = new Field(); field.name = s; outData.println("@property (retain) NSString* " + useLowerName(field) + ";"); } outData.println("- (id)init;"); outData.println("- (void)clear;"); outData.println("- (void)write:(Writer*)writer;"); outData.println("- (void)read:(Reader*)reader;"); outData.println("- (void)dealloc;"); outData.println("@end"); if (proc.outputs.size() == 0) outData.println("#define O" + mainName + "Rec D" + mainName + "Rec"); outData.println(); } }