예제 #1
0
  private static void writeVariables(String _package, String _class, String _object)
      throws Exception {
    // out.printf( "\t//varaibles defined in %s%s (and its super classes/interfaces)\n\n", _package,
    // _class );

    Class gl_class = Class.forName(_package + _class);

    // Field[] fields = gl_class.getDeclaredFields(); // returns private fields

    Field[] fields = gl_class.getFields(); // only public fields

    for (Field f : fields) {
      String s = f.toString();

      int i1 = s.lastIndexOf(".");

      String s1 = s.substring(0, i1);

      int i2 = s1.lastIndexOf(' ');

      String s2 = s1.substring(0, i2);

      s1 = s1.substring(i2 + 1);

      out.printf("\t%s %s = %s.%s;\n", s2, f.getName(), s1, f.getName());
    }
  }
예제 #2
0
  private static void writeMethods(String _package, String _class, String _object)
      throws Exception {
    // out.printf( "\t//methods defined in %s%s\n\n", _package, _class );

    Class gl_class = Class.forName(_package + _class);

    Method[] methods = gl_class.getDeclaredMethods();

    for (Method m : methods) {
      String s = m.toString();

      // if( s.startsWith( "private" ) )
      if (!s.startsWith("public")) {
        continue;
      }

      s = s.replace(_package + _class + ".", "");

      s = s.replace(" abstract", "");

      if (s.indexOf("static") == -1) {
        s = s.replace("public", "public static final");
      } else {
        s = s.replace("public static", "public static final");
      }

      int i0 = s.indexOf("(");
      int i1 = s.indexOf(")");

      String args0 = s.substring(i0 + 1, i1);

      String[] asirenist = args0.split(",");

      // out.println( s );

      String method_declaration = s.substring(0, i0) + "(";

      String ret = m.getReturnType().toString();

      String method_call = "";

      String runtime_call = "assert dprintln( \"";

      if (!ret.equals("void")) {
        method_call += "return ";
      }

      // method_call += "GLWrap." + _object + "." + m.getName() + "(";

      method_call += _object + "." + m.getName() + "(";

      runtime_call += m.getName() + "(";

      // runtime_call += _object + "." + m.getName() + "(";

      if (asirenist.length > 0 && asirenist[0].trim().length() > 0) {
        method_declaration += " ";
        method_call += " ";
        runtime_call += " ";

        for (int i = 0; i < asirenist.length; i++) {
          if (asirenist[i].equals("javax.media.opengl.GL")) {
            method_declaration += "/*" + asirenist[i] + " a" + i + "*/";

            method_call += "gl";
            // method_call += "GLWrap.gl";

            if (i < asirenist.length - 1) {
              method_declaration += " ";

              method_call += ", ";
            }
          } else if (asirenist[i].equals("javax.media.opengl.glu.GLU")) {
            method_declaration += "/*" + asirenist[i] + " a" + i + "*/";

            // method_call += "GLWrap.glu";
            method_call += "glu";

            if (i < asirenist.length - 1) {
              method_declaration += " ";

              method_call += ", ";
            }
          } else {
            method_declaration += asirenist[i] + " a" + i;

            method_call += "a" + i;

            if (i < asirenist.length - 1) {
              method_declaration += ", ";

              method_call += ", ";
            }
          }

          runtime_call += "\" + a" + i + " + \"";

          if (i < asirenist.length - 1) {
            runtime_call += ", ";
          }
        }

        method_declaration += " ";
        method_call += " ";
        runtime_call += " ";
      }
      method_declaration += ")";
      method_call += ");";
      runtime_call += ")\" );";

      out.println("\t" + method_declaration);
      out.println("\t{");
      // if( debug )
      {
        out.println("\t\t" + runtime_call);
      }
      out.println("\t\t" + method_call);
      out.println("\t}");

      // out.println( "   " + args0 );
    }

    out.println("\tprivate static boolean dprintln( String s )");
    out.println("\t{");
    out.println("\t\tSystem.err.println( s );");
    out.println("\t\treturn true;");
    out.println("\t}");
  }