Exemplo n.º 1
0
  public static ImageObject initImageProto(RhinoCore core) throws PropertyException {

    int attributes = READONLY | DONTENUM | PERMANENT;

    // create prototype object
    ImageObject proto = new ImageObject("Image", core);
    proto.setPrototype(getObjectPrototype(core.global));

    Method[] methods = ImageObject.class.getMethods();
    for (int i = 0; i < methods.length; i++) {
      String methodName = methods[i].getName();

      if (methodName.startsWith("jsFunction_")) {
        methodName = methodName.substring(11);
        FunctionObject func = new FunctionObject(methodName, methods[i], proto);
        proto.defineProperty(methodName, func, attributes);
      } else if (methodName.startsWith("jsGet_")) {
        methodName = methodName.substring(6);
        proto.defineProperty(methodName, null, methods[i], null, attributes);
      }
    }

    return proto;
  }