Package com.google.gwt.dev.shell

Examples of com.google.gwt.dev.shell.MethodAdaptor


      Field field = javaDispatch.getField(dispId);
      JsValueGlue.set(jsValue, classLoader, field.getType(),
          javaDispatch.getFieldValue(dispId));
      return;
    } else {
      MethodAdaptor method = javaDispatch.getMethod(dispId);
      AccessibleObject obj = method.getUnderlyingObject();
      DispatchMethod64 dispMethod = (DispatchMethod64) classLoader.getWrapperForObject(obj);
      if (dispMethod == null) {
        dispMethod = new MethodDispatch64(classLoader, method);
        classLoader.putWrapperForObject(obj, dispMethod);
      }
      jsValue.setWrappedFunction(method.toString(), dispMethod);
    }
  }
View Full Code Here


      Field field = javaDispatch.getField(dispId);
      JsValueGlue.set(jsValue, classLoader, field.getType(),
          javaDispatch.getFieldValue(dispId));
      return;
    } else {
      MethodAdaptor method = javaDispatch.getMethod(dispId);
      AccessibleObject obj = method.getUnderlyingObject();
      DispatchMethod32/*64*/ dispMethod = (DispatchMethod32/*64*/) classLoader.getWrapperForObject(obj);
      if (dispMethod == null) {
        dispMethod = new MethodDispatch32/*64*/(classLoader, method);
        classLoader.putWrapperForObject(obj, dispMethod);
      }
      jsValue.setWrappedFunction(method.toString(), dispMethod);
    }
  }
View Full Code Here

      Field field = javaDispatch.getField(dispId);
      JsValueGlue.set(jsValue, classLoader, field.getType(),
          javaDispatch.getFieldValue(dispId));
      return;
    } else {
      MethodAdaptor method = javaDispatch.getMethod(dispId);
      AccessibleObject obj = method.getUnderlyingObject();
      DispatchMethod dispMethod = (DispatchMethod) classLoader.getWrapperForObject(obj);
      if (dispMethod == null) {
        dispMethod = new MethodDispatch(classLoader, method);
        classLoader.putWrapperForObject(obj, dispMethod);
      }
      jsValue.setWrappedFunction(method.toString(), dispMethod);
    }
  }
View Full Code Here

    return null;
      }
      if (!javaDispatch.isMethod(dispId)) {
    return null;
      }
      final MethodAdaptor method = javaDispatch.getMethod(dispId);
      AccessibleObject obj = method.getUnderlyingObject();
      DispatchMethod dispMethod = (DispatchMethod) classLoader.getWrapperForObject(obj);
      if (dispMethod == null) {
      dispMethod = new MethodDispatch(classLoader, method);
      classLoader.putWrapperForObject(obj, dispMethod);
      }
View Full Code Here

          return new Variant(getTarget().toString());
        }

      } else if (dispId > 0) {
        if (javaDispatch.isMethod(dispId)) {
          MethodAdaptor method = javaDispatch.getMethod(dispId);
          if ((flags & COM.DISPATCH_METHOD) != 0) {
            // This is a method call.
            return callMethod(classLoader, getTarget(), params, method);
          } else if (flags == COM.DISPATCH_PROPERTYGET) {
            // The function is being accessed as a property.
            AccessibleObject obj = method.getUnderlyingObject();
            IDispatchImpl dispMethod = (IDispatchImpl) classLoader.getWrapperForObject(obj);
            if (dispMethod == null || dispMethod.refCount < 1) {
              dispMethod = new MethodDispatch(classLoader, method);
              classLoader.putWrapperForObject(obj, dispMethod);
            }
View Full Code Here

        if ((flags & COM.DISPATCH_METHOD) != 0) {
          // "m.toString()"
          return new Variant(toString());
        } else if ((flags & COM.DISPATCH_PROPERTYGET) != 0) {
          // "m.toString"
          MethodAdaptor toStringMethod;
          try {
            toStringMethod = new MethodAdaptor(
                Object.class.getDeclaredMethod("toString"));
          } catch (Throwable e) {
            throw new RuntimeException(
                "Failed to get Object.toString() method", e);
          }
          AccessibleObject obj = toStringMethod.getUnderlyingObject();
          IDispatchImpl dispMethod = (IDispatchImpl) classLoader.getWrapperForObject(obj);
          if (dispMethod == null || dispMethod.refCount < 1) {
            dispMethod = new MethodDispatch(classLoader, toStringMethod);
            classLoader.putWrapperForObject(obj, dispMethod);
          }
View Full Code Here

        } else if ((flags & COM.DISPATCH_PROPERTYGET) != 0) {
          // property get on the method itself
          try {
            Method gwtOnLoadMethod = getClass().getMethod("gwtOnLoad",
                new Class[] {IDispatch.class, String.class, String.class});
            MethodAdaptor methodAdaptor = new MethodAdaptor(gwtOnLoadMethod);
            IDispatchImpl funcObj = new MethodDispatch(null, methodAdaptor);
            IDispatch disp = new IDispatch(funcObj.getAddress());
            disp.AddRef();
            return new Variant(disp);
          } catch (Exception e) {
            // just return VT_EMPTY
            return new Variant();
          }
        }
        throw new HResultException(COM.E_NOTSUPPORTED);
      } else if (dispId == 2) {
        if ((flags & COM.DISPATCH_METHOD) != 0) {
          try {
            if (params.length < 1) {
              reportIncorrectInvocation("initModule", 1, params.length);
              throw new HResultException(COM.E_INVALIDARG);
            }
            String moduleName = (params[0].getType() == COM.VT_BSTR)
                ? params[0].getString() : null;
            boolean reload = initModule(moduleName);

            // boolean return type
            return new Variant(reload);
          } catch (SWTException e) {
            throw new HResultException(COM.E_INVALIDARG);
          }
        } else if ((flags & COM.DISPATCH_PROPERTYGET) != 0) {
          // property get on the method itself
          try {
            Method gwtOnLoadMethod = getClass().getMethod("initModule",
                new Class[] {String.class});
            MethodAdaptor methodAdaptor = new MethodAdaptor(gwtOnLoadMethod);
            IDispatchImpl funcObj = new MethodDispatch(null, methodAdaptor);
            IDispatch disp = new IDispatch(funcObj.getAddress());
            disp.AddRef();
            return new Variant(disp);
          } catch (Exception e) {
View Full Code Here

        H jsval = jsValue.getJsValue();
        // Native code will eat an extra ref.
        LowLevelWebKit.gcProtect(jsContext, jsval);
        return jsval;
      } else {
        MethodAdaptor method = javaDispatch.getMethod(dispId);
        AccessibleObject obj = method.getUnderlyingObject();
        DispatchMethod<?> dispMethod = (DispatchMethod<?>) classLoader.getWrapperForObject(obj);
        if (dispMethod == null) {
          dispMethod = new MethodDispatch<H>(classLoader, method);
          classLoader.putWrapperForObject(obj, dispMethod);
        }
        // Native code eats the same ref it gave us.
        return LowLevelWebKit.wrapDispatchMethod(jsContext, method.toString(), dispMethod);
      }
    } finally {
      LowLevelWebKit.popJsContext(jsContext);
    }
  }
View Full Code Here

      // GWT 2: called static scope with dispId as parameter
      if (dispId == 0 && (flags & COM.DISPATCH_METHOD) != 0 && params.length >= 2) {
      Variant dispIdVar = params[0]; // zero is dispId, next should be null (as 'this') for static context
      dispId = dispIdVar.getInt();
    if (javaDispatch.isMethod(dispId)) {
      MethodAdaptor method = javaDispatch.getMethod(dispId);
      Object target = getTarget();
      Object jthis = method.needsThis() ?
          JsValueGlue.get(new JsValueIE6(params[1]),
            classLoader,
            method.getDeclaringClass(),
            "this") : null;
      Variant[] otherParams = new Variant[params.length - 2];
      System.arraycopy(params, 2, otherParams, 0, otherParams.length);
      return callMethod(classLoader, jthis, otherParams, method);
    }     
      }
      // Whatever the caller asks for, try to find it via reflection.
      //
      if (dispId == DISPID_MAGIC_GETGLOBALREF && myGlobalRef != 0) {
        // Handle specially.
        //
        return new Variant(myGlobalRef);
      } else if (dispId == 0) {
        if ((flags & COM.DISPATCH_METHOD) != 0) {
          // implicit call -- "m()"
          // not supported -- fall through to unsupported failure
        } else if ((flags & COM.DISPATCH_PROPERTYGET) != 0) {
          // implicit toString -- "'foo' + m"
          return new Variant(getTarget().toString());
        }

      } else if (dispId > 0) {
        if (javaDispatch.isMethod(dispId)) {
          MethodAdaptor method = javaDispatch.getMethod(dispId);
          if ((flags & COM.DISPATCH_METHOD) != 0) {
            // This is a method call.
            return callMethod(classLoader, getTarget(), params, method);
          } else if (flags == COM.DISPATCH_PROPERTYGET) {
            // The function is being accessed as a property.
            AccessibleObject obj = method.getUnderlyingObject();
            IDispatchImpl dispMethod = (IDispatchImpl) classLoader.getWrapperForObject(obj);
            if (dispMethod == null || dispMethod.refCount < 1) {
              dispMethod = new MethodDispatch(classLoader, method);
              classLoader.putWrapperForObject(obj, dispMethod);
            }
View Full Code Here

        if ((flags & COM.DISPATCH_METHOD) != 0) {
          // "m.toString()"
          return new Variant(toString());
        } else if ((flags & COM.DISPATCH_PROPERTYGET) != 0) {
          // "m.toString"
          MethodAdaptor toStringMethod;
          try {
            toStringMethod = new MethodAdaptor(
                Object.class.getDeclaredMethod("toString"));
          } catch (Throwable e) {
            throw new RuntimeException(
                "Failed to get Object.toString() method", e);
          }
          AccessibleObject obj = toStringMethod.getUnderlyingObject();
          IDispatchImpl dispMethod = (IDispatchImpl) classLoader.getWrapperForObject(obj);
          if (dispMethod == null || dispMethod.refCount < 1) {
            dispMethod = new MethodDispatch(classLoader, toStringMethod);
            classLoader.putWrapperForObject(obj, dispMethod);
          }
View Full Code Here

TOP

Related Classes of com.google.gwt.dev.shell.MethodAdaptor

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.