Пример #1
0
  public void addProxy() throws Exception {
    // implement PyProxy interface
    classfile.addField("__proxy", $pyObj, Modifier.PROTECTED);
    // setProxy methods
    Code code = classfile.addMethod("_setPyInstance", makeSig("V", $pyObj), Modifier.PUBLIC);
    code.aload(0);
    code.aload(1);
    code.putfield(classfile.name, "__proxy", $pyObj);
    code.return_();

    // getProxy method
    code = classfile.addMethod("_getPyInstance", makeSig($pyObj), Modifier.PUBLIC);
    code.aload(0);
    code.getfield(classfile.name, "__proxy", $pyObj);
    code.areturn();

    String pySys = "Lorg/python/core/PySystemState;";
    // implement PyProxy interface
    classfile.addField("__systemState", pySys, Modifier.PROTECTED | Modifier.TRANSIENT);

    // setProxy method
    code = classfile.addMethod("_setPySystemState", makeSig("V", pySys), Modifier.PUBLIC);

    code.aload(0);
    code.aload(1);
    code.putfield(classfile.name, "__systemState", pySys);
    code.return_();

    // getProxy method
    code = classfile.addMethod("_getPySystemState", makeSig(pySys), Modifier.PUBLIC);
    code.aload(0);
    code.getfield(classfile.name, "__systemState", pySys);
    code.areturn();
  }
Пример #2
0
 public void putfield(String c, String name, String type) throws IOException {
   putfield(pool.Fieldref(c, name, type));
 }