Package org.eclipse.swt.internal.ole.win32

Examples of org.eclipse.swt.internal.ole.win32.VARIANT


   *
   * @see com.google.gwt.dev.shell.JsValue#setNull()
   */
  @Override
  public void setNull() {
    setVariant(new Variant(0, COM.VT_NULL));
  }
View Full Code Here


  /**
   * Method copied from 3.3+ Variant class.
   */
  public static Variant win32_new(int varArgAddr) {
    try {
      Variant variant = new Variant();
      Method setDataMethod =
          variant.getClass().getDeclaredMethod("setData", new Class[]{int.class});
      setDataMethod.setAccessible(true);
      setDataMethod.invoke(variant, new Object[]{new Integer(varArgAddr)});
      return variant;
    } catch (Throwable e) {
      throw new RuntimeException(e);
View Full Code Here

   *
   * @see com.google.gwt.dev.shell.JsValue#setShort(short)
   */
  @Override
  public void setShort(short val) {
    setVariant(new Variant(val));
  }
View Full Code Here

   *
   * @see com.google.gwt.dev.shell.JsValue#setString(java.lang.String)
   */
  @Override
  public void setString(String val) {
    setVariant(new Variant(val));
  }
View Full Code Here

        WrappersCache.putWrapperForObject(cl, val, dispObj);
      }
    }
    IDispatch disp = new IDispatch(dispObj.getAddress());
    disp.AddRef();
    setVariant(new Variant(disp));
  }
View Full Code Here

    variant = val;
  }

  private Object tryToUnwrapWrappedJavaObject() {
    int globalRef = 0;
    Variant result = null;
    try {
      result = oleAutomationInvoke(variant.getDispatch(), IDispatchProxy.DISPID_MAGIC_GETGLOBALREF);
      if (result != null) {
        globalRef = result.getInt();
        if (globalRef != 0) {
          // This is really a Java object being passed back via an
          // IDispatchProxy.
          IDispatchProxy proxy = (IDispatchProxy) Utils.objFromGlobalRefInt(globalRef);
          return proxy.getTarget();
        }
      }
      return null;
    } finally {
      if (result != null) {
        result.dispose();
      }
    }
  }
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

    // Convert it to a variant (if the return type is void, return
    // a VT_EMPTY variant -- 'undefined' in JavaScript).
    //
    Class returnType = method.getReturnType();
    if (returnType.equals(Void.TYPE)) {
      return new Variant();
    }
    return SwtOleGlue.convertObjectToVariant(cl, returnType, result);
  }
View Full Code Here

  private int Invoke(int dispIdMember, int riid, int lcid, int dwFlags,
      int pDispParams, int pVarResult, int pExcepInfo, int pArgErr) {

    HResultException ex = null;
    Variant[] vArgs = null;
    Variant result = null;
    try {
      vArgs = extractVariantArrayFromDispParamsPtr(pDispParams);
      result = invoke(dispIdMember, dwFlags, vArgs);
      if (pVarResult != 0) {
        Variant.win32_copy(pVarResult, result);
      }
    } catch (HResultException e) {
      // Log to the console for detailed examination.
      //
      e.printStackTrace();
      ex = e;

    } catch (InvocationTargetException e) {
      // If we get here, it means an exception is being thrown from
      // Java back into JavaScript

      Throwable t = e.getTargetException();
      ex = new HResultException(t);
      ModuleSpace.setThrownJavaException(t);
    } catch (Exception e) {
      // Log to the console for detailed examination.
      //
      e.printStackTrace();
      ex = new HResultException(e);
    } finally {
      // We allocated variants for all arguments, so we must dispose them all.
      //
      for (int i = 0; i < vArgs.length; ++i) {
        if (vArgs[i] != null) {
          vArgs[i].dispose();
        }
      }

      if (result != null) {
        result.dispose();
      }
    }

    if (ex != null) {
      // Set up an exception for IE to throw.
View Full Code Here

      // 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)) {
          Method 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.
            IDispatchImpl funcObj = new MethodDispatch(classLoader, method);
            IDispatch disp = new IDispatch(funcObj.getAddress());
            disp.AddRef();
            return new Variant(disp);
          }
        } else if (javaDispatch.isField(dispId)) {
          Field field = javaDispatch.getField(dispId);
          if (flags == COM.DISPATCH_PROPERTYGET) {
            return SwtOleGlue.convertObjectToVariant(classLoader,
                field.getType(), javaDispatch.getFieldValue(dispId));
          } else if ((flags & (COM.DISPATCH_PROPERTYPUT | COM.DISPATCH_PROPERTYPUTREF)) != 0) {
            javaDispatch.setFieldValue(dispId, JsValueGlue.get(new JsValueIE6(
                params[0]), field.getType(), "Setting field '"
                + field.getName() + "'"));
            return new Variant();
          }
        }
      } else {
        // The specified member id is out of range.
        throw new HResultException(COM.DISP_E_MEMBERNOTFOUND);
View Full Code Here

TOP

Related Classes of org.eclipse.swt.internal.ole.win32.VARIANT

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.