Package org.eclipse.swt.ole.win32

Examples of org.eclipse.swt.ole.win32.OleFrame


        if ((flags & COM.DISPATCH_METHOD) != 0) {
          // implicit call -- "m()"
          return callMethod(classLoader, dispIdOracle, null, params, method);
        } else if ((flags & COM.DISPATCH_PROPERTYGET) != 0) {
          // implicit toString -- "'foo' + m"
          return new Variant(toString());
        }
        break;
      case 1 :
        // toString
        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) WrappersCache.getWrapperForObject(classLoader, obj);
          if (dispMethod == null || dispMethod.refCount < 1) {
            dispMethod = new MethodDispatch(classLoader, dispIdOracle, toStringMethod);
            WrappersCache.putWrapperForObject(classLoader, obj, dispMethod);
          }
          IDispatch disp = new IDispatch(dispMethod.getAddress());
          disp.AddRef();
          return new Variant(disp);
        }
        break;
      case 2 :
        // call
        if ((flags & COM.DISPATCH_METHOD) != 0) {
          // "m.call(thisObj, arg)"
          /*
           * First param must be a this object of the correct type (for instance
           * methods). If method is static, it can be null.
           */
          Object jthis =
              JsValueGlue.get(
                new JsValueIE6(params[0]),
                classLoader,
                method.getDeclaringClass(),
                "this");
          Variant[] otherParams = new Variant[params.length - 1];
          System.arraycopy(params, 1, otherParams, 0, otherParams.length);
          return callMethod(classLoader, dispIdOracle, jthis, otherParams, method);
        } else if ((flags & COM.DISPATCH_PROPERTYGET) != 0) {
          // "m.call"
          // TODO: not supported
        }
        break;
      case 3 :
        // apply
        // TODO: not supported
        break;
      case IDispatchProxy.DISPID_MAGIC_GETGLOBALREF :
        // We are NOT in fact a "wrapped Java Object", but we don't want to
        // throw an exception for being asked.
        return new Variant(0);
      default :
        // The specified member id is out of range.
        throw new HResultException(COM.DISP_E_MEMBERNOTFOUND);
    }
    throw new HResultException(COM.E_NOTSUPPORTED);
View Full Code Here


          + name
          + "'");
      }
      int functionId = ids[0];
      // prepare function and "call" property
      Variant functionVariant = window.getProperty(functionId);
      OleAutomation function = functionVariant.getAutomation();
      int callId = function.getIDsOfNames(new String[]{"call"})[0];
      // dispose function variant (we have automation) and fill information object
      functionVariant.dispose();
      functionInfo = new NativeFunctionInfo(function, callId);
      m_nativeFunctions.put(name, functionInfo);
    }
    // invoke function
    return OleAutomationFix.invoke(functionInfo.m_function, functionInfo.m_callId, args);
View Full Code Here

   *          must be null if it is static.
   * @return the return value of the JavaScript function
   */
  protected Variant doInvokeOnWindow2(OleAutomation window, String name, Variant[] vArgs) {
    OleAutomation funcObj = null;
    Variant funcObjVar = null;
    try {
      // Get the function object and its 'call' method.
      //
      int[] ids = window.getIDsOfNames(new String[]{name});
      if (ids == null) {
        throw new RuntimeException("Could not find a native method with the signature '"
          + name
          + "'");
      }
      int functionId = ids[0];
      funcObjVar = window.getProperty(functionId);
      funcObj = funcObjVar.getAutomation();
      int callDispId = funcObj.getIDsOfNames(new String[]{"call"})[0];
      // Invoke it and return the result.
      //
      return funcObj.invoke(callDispId, vArgs);
    } finally {
      if (funcObjVar != null) {
        funcObjVar.dispose();
      }
      if (funcObj != null) {
        funcObj.dispose();
      }
    }
View Full Code Here

              isolatedClassLoader,
              dispatchIdOracle,
              types[i],
              args[i]);
      }
      Variant result = doInvokeOnWindow(name, vArgs);
      try {
        return new JsValueIE6(result);
      } finally {
        if (result != null) {
          result.dispose();
        }
      }
    } finally {
      // We allocated variants for all arguments, so we must dispose them all.
      //
View Full Code Here

    checkedExecute(jsni);
  }

  private void checkedExecute(String jsni) {
    try {
      Variant result = execute(jsni);
      if (result != null) {
        result.dispose();
      }
    } catch (RuntimeException e) {
      throw new RuntimeException("Failed to create JSNI methods", e);
    }
  }
View Full Code Here

  }

  private Variant execute(String code) {
    int[] dispIds = window.getIDsOfNames(new String[]{"execScript", "code"});
    Variant[] vArgs = new Variant[1];
    vArgs[0] = new Variant(code);
    int[] namedArgs = new int[1];
    namedArgs[0] = dispIds[1];
    Variant result = window.invoke(dispIds[0], vArgs, namedArgs);
    vArgs[0].dispose();
    if (result == null) {
      String lastError = window.getLastError();
      throw new RuntimeException("Error (" + lastError + ") executing JavaScript:\n" + code);
    }
View Full Code Here

    @Override
    protected Variant invoke(int dispId, int flags, Variant[] params) throws HResultException,
        InvocationTargetException {
      if (dispId == 0 && (flags & COM.DISPATCH_PROPERTYGET) != 0) {
        // MAGIC: this is the default property, let's just do toString()
        return new Variant(toString());
      } else if (dispId == 1) {
        if ((flags & COM.DISPATCH_METHOD) != 0) {
          try {
            IDispatch frameWnd =
                params[0].getType() == COM.VT_DISPATCH ? params[0].getDispatch() : null;
            boolean success = gwtOnLoad(frameWnd);
            // boolean return type
            return new Variant(success);
          } catch (SWTException e) {
            throw new HResultException(COM.E_INVALIDARG);
          }
        } else if ((flags & COM.DISPATCH_PROPERTYGET) != 0) {
          // property get on the method itself
          try {
            IDispatchImpl funcObj = new IDispatchImpl() {
              // do nothing, just return some IDispatch
              @Override
              protected Variant invoke(int dispId, int flags, Variant[] params)
                  throws HResultException, InstantiationException, InvocationTargetException {
                return new Variant();
              }

              @Override
              protected void getIDsOfNames(String[] names, int[] ids) throws HResultException {
              }
            };
            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);
      }
      // The specified member id is out of range.
View Full Code Here

  /**
   * @see OleAutomation#invoke(int, Variant[])
   */
  public static Variant invoke(OleAutomation automation, int dispIdMember, Variant[] rgvarg) {
    try {
      Variant pVarResult = new Variant();
      int result = invoke(automation, dispIdMember, COM.DISPATCH_METHOD, rgvarg, null, pVarResult);
      return (result == COM.S_OK) ? pVarResult : null;
    } catch (Throwable e) {
      throw ReflectionUtils.propagate(e);
    }
View Full Code Here

    }
  }

  private static Variant maybeCopyVariant(Variant variant) {
    if (variant == null) {
      return new Variant();
    }
    switch (variant.getType()) {
      case COM.VT_DISPATCH : {
        IDispatch dispatch = variant.getDispatch();
        dispatch.AddRef();
        return new Variant(dispatch);
      }
      case COM.VT_UNKNOWN : {
        IUnknown unknown = variant.getUnknown();
        unknown.AddRef();
        return new Variant(unknown);
      }
    }
    return variant;
  }
View Full Code Here

    IDispatch dispatch = variant.getDispatch();
    int[] ids = oleAutomationGetIdsOfNames(dispatch);
    if (ids == null) {
      return false;
    }
    Variant result = null;
    try {
      result = oleAutomationInvoke(dispatch, ids[0]);
      /*
       * If the return type of the valueOf method is string, we assume it is a
       * String wrapper object.
       */
      return result.getType() == COM.VT_BSTR;
    } finally {
      if (result != null) {
        result.dispose();
      }
    }
  }
View Full Code Here

TOP

Related Classes of org.eclipse.swt.ole.win32.OleFrame

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.