Esempio n. 1
0
 /** Build of output data rec for standard procedures */
 static void generateStdOutputRec(Table table, PrintWriter outData) {
   for (int i = 0; i < table.comments.size(); i++) {
     String s = (String) table.comments.elementAt(i);
     outData.println("## " + s);
   }
   outData.println("## \\class D" + table.useName());
   outData.println("class D" + table.useName() + "(object):");
   outData.println("    def _make(self): return D" + table.useName() + "()");
   outData.println(
       "    def _name(self): return ('D" + table.useName() + "','O" + table.useName() + "')");
   generateDataFields(table.fields, "", "D" + table.useName(), table.useName(), outData);
   outData.println();
   outData.println("## \\class O" + table.useName());
   outData.println("## \\field see:D" + table.useName());
   outData.println("O" + table.useName() + " = D" + table.useName());
   outData.println();
   if (pymodName.length() > 0) {
     outData.println("class " + table.useName() + "(D" + table.useName() + "):");
     outData.println("    def __init__(self): D" + table.useName() + ".__init__(self)");
     coverFunctions = new Vector<String>();
     for (int i = 0; i < table.procs.size(); i++) {
       Proc proc = (Proc) table.procs.elementAt(i);
       if (proc.isData == true || (proc.isStd == false && proc.isStdExtended() == false)) continue;
       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 i = 0; i < coverFunctions.size(); i++)
       outData.println((String) coverFunctions.elementAt(i));
   }
 }
Esempio n. 2
0
 private static void generateSingle(Table table, Proc proc, PrintWriter outData) {
   String dataStruct;
   if (proc.isStd || proc.isStdExtended()) dataStruct = table.useName();
   else dataStruct = table.useName() + proc.upperFirst();
   String parameters = "";
   boolean hasInput = (proc.inputs.size() > 0 || proc.dynamics.size() > 0);
   outData.println("    def " + proc.name + "(self):");
   outData.println("        ''' Single returns boolean and record");
   if (hasInput == true) {
     outData.println("        Input:");
     for (int f = 0; f < proc.inputs.size(); f++) {
       Field field = (Field) proc.inputs.elementAt(f);
       outData.println("            " + field.useName());
       parameters += ", " + field.useName() + "=" + defValue(field);
     }
     for (int f = 0; f < proc.dynamics.size(); f++) {
       String field = (String) proc.dynamics.elementAt(f);
       outData.println("            " + field);
       parameters += ", " + field + "=''";
     }
   }
   outData.println("        Output:");
   for (int f = 0; f < proc.outputs.size(); f++) {
     Field field = (Field) proc.outputs.elementAt(f);
     outData.println("            " + field.useName());
   }
   outData.println("        '''");
   outData.println(
       "        return " + pymodFront + table.useName() + proc.upperFirst() + "(self)");
   if (hasInput == true)
     generateInput(table.useName(), dataStruct, proc.name, parameters, outData);
   else generateCover(table.useName(), dataStruct, proc.name, outData);
 }
Esempio n. 3
0
 private static void generateAction(Table table, Proc proc, PrintWriter outData) {
   String dataStruct;
   if (proc.isStd || proc.isStdExtended()) dataStruct = table.useName();
   else dataStruct = table.useName() + proc.upperFirst();
   String parameters = "";
   outData.println("    def " + proc.name + "(self):");
   outData.println("        ''' Action");
   outData.println("        Input:");
   for (int f = 0; f < proc.inputs.size(); f++) {
     Field field = (Field) proc.inputs.elementAt(f);
     outData.println("            " + field.useName());
     parameters += ", " + field.useName() + "=" + defValue(field);
   }
   for (int f = 0; f < proc.dynamics.size(); f++) {
     String field = (String) proc.dynamics.elementAt(f);
     outData.println("            " + field);
     parameters += ", " + field + "=''";
   }
   outData.println("        '''");
   outData.println(
       "        return " + pymodFront + table.useName() + proc.upperFirst() + "(self)");
   generateInput(table.useName(), dataStruct, proc.name, parameters, outData);
 }
Esempio n. 4
0
 private static void generateInterfaceStructs(Table table, PrintWriter outData) {
   if (table.fields.size() > 0) {
     if (table.comments.size() > 0) {
       for (int i = 0; i < table.comments.size(); i++) {
         String s = (String) table.comments.elementAt(i);
         outData.println("// " + s);
       }
     }
     generateInterfaceTableStructs(table.fields, table.useName(), outData);
     generateEnumOrdinals(table, outData);
   }
   for (int i = 0; i < table.procs.size(); i++) {
     Proc proc = (Proc) table.procs.elementAt(i);
     if (proc.isData || proc.isStd || proc.isStdExtended() || proc.hasNoData()) continue;
     if (proc.comments.size() > 0) {
       for (int j = 0; j < proc.comments.size(); j++) {
         String s = (String) proc.comments.elementAt(j);
         outData.println("// " + s);
       }
     }
     generateInterfaceStructPairs(proc, table.useName() + proc.upperFirst(), outData);
   }
 }
Esempio n. 5
0
  /** 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));
      }
    }
  }