Package com.google.gwt.dev.shell.BrowserChannel

Examples of com.google.gwt.dev.shell.BrowserChannel.Value


   */
  static Value getProperty(BrowserChannelClient channel,
      SessionHandlerClient handler, int objectRef, int dispatchId) {
    if (!channel.isConnected()) {
      // ignoring getProperty() after disconnect
      return new Value();
    }
    Value args[] = new Value[2];
    args[0] = new Value();
    args[0].setInt(objectRef);
    args[1] = new Value();
    args[1].setInt(dispatchId);

    synchronized (handler.getSynchronizationObject()) {
      try {
        new InvokeSpecialMessage(channel, SpecialDispatchId.GetProperty, args).send();
        ReturnMessage returnMessage = channel.reactToMessagesWhileWaitingForReturn(handler);
        if (!returnMessage.isException()) {
          return returnMessage.getReturnValue();
        }
      } catch (IOException e) {
      } catch (BrowserChannelException e) {
      }
    }
    return new Value();
  }
View Full Code Here


   * @param value value to store in the property
   * @return false if an error occurred
   */
  static boolean setProperty(BrowserChannelClient channel,
      SessionHandlerClient handler, int objectRef, int dispatchId, Value value) {
    Value args[] = new Value[3];
    for (int i = 0; i < args.length; i++) {
      args[i] = new Value();
    }
    args[0].setInt(objectRef);
    args[1].setInt(dispatchId);
    args[2] = value;
    synchronized (handler.getSynchronizationObject()) {
View Full Code Here

      } else if (obj instanceof SimpleScriptableProxy<?>) {
        jsThis = ((SimpleScriptableProxy<SimpleScriptable>) obj).getDelegee();
      } else {
        logger.log(TreeLogger.ERROR, "Unable to convert " + obj + " to either "
            + " ScriptableObject or SimpleScriptableProxy");
        return new ExceptionOrReturnValue(true, new Value(null));
      }
    }
    Object functionObject = ScriptableObject.getProperty(
        window, methodName);
    if (functionObject == ScriptableObject.NOT_FOUND) {
      logger.log(TreeLogger.ERROR, "function " + methodName
          + " NOT FOUND, thisObj: " + jsThis + ", methodName: " + methodName);
      // TODO: see if this maps to QUIT
      return new ExceptionOrReturnValue(true, new Value(null));
    }
    Function jsFunction = (Function) functionObject;
    if (logger.isLoggable(TreeLogger.SPAM)) {
      logger.log(TreeLogger.SPAM, "INVOKE: jsFunction: " + jsFunction);
    }
View Full Code Here

  /**
   * @param jsContext the Context
   */
  public Value makeValueFromJsval(Context jsContext, Object value) {
    if (value == Undefined.instance) {
      return new Value();
    }
    if (value instanceof JavaObject) {
      Value returnVal = new Value();
      int refId = ((JavaObject) value).getRefId();
      returnVal.setJavaObject(new JavaObjectRef(refId));
      return returnVal;
    }
    if (value instanceof Scriptable) {
      if (value instanceof ScriptableObject) {
        /*
         * HACK: check for native types like NativeString. NativeString is
         * package-protected. What other types do we need to check?
         */
        ScriptableObject scriptableValue = (ScriptableObject) value;
        String className = scriptableValue.getClassName();
        if (className.equals("String")) {
          return new Value(scriptableValue.toString());
        }
      }
      Integer refId = jsObjectToRef.get(value);
      if (refId == null) {
        refId = nextRefId++;
        jsObjectToRef.put((Scriptable) value, refId);
        refToJsObject.put(refId, (Scriptable) value);
      }
      Value returnVal = new Value();
      returnVal.setJsObject(new JsObjectRef(refId));
      return returnVal;
    }
    if (value instanceof ConsString) {
      return new Value(value.toString());
    }
    if (value instanceof Number) {
      return new Value(convertNumberFromJsval(((Number) value)));
    }
    return new Value(value);
  }
View Full Code Here

            + EXPECTED_NUM_ARGS
            + ", got "
            + args.length);
      }
      // thisObj is the javaObject.
      Value thisValue = makeValueFromJsval(context, thisObj);
      ExceptionOrReturnValue returnValue = JavaObject.getReturnFromJavaMethod(
          context, HtmlUnitSessionHandler.this, sessionData.getChannel(),
          TO_STRING_DISPATCH_ID, thisValue, EMPTY_VALUES);
      return HtmlUnitSessionHandler.this.makeJsvalFromValue(context,
          returnValue.getReturnValue());
View Full Code Here

      Object[] args) {

    if (args.length < 2) {
      return Undefined.instance;
    }
    Value valueArgs[] = new Value[args.length - 2];
    for (int i = 0; i < valueArgs.length; i++) {
      valueArgs[i] = sessionData.getSessionHandler().makeValueFromJsval(cx,
          args[i + 2]);
    }

    /**
     * Called when the JavaObject is invoked as a function. We ignore the
     * thisObj argument, which is usually the window object.
     *
     * Returns a JS array, with the first element being a boolean indicating
     * that an exception occured, and the second element is either the return
     * value or the exception which was thrown. In this case, we always return
     * false and raise the exception ourselves.
     */

    Value thisValue = sessionData.getSessionHandler().makeValueFromJsval(cx,
        args[1]);
    int dispatchId = ((Number) args[0]).intValue();

    ExceptionOrReturnValue returnValue = getReturnFromJavaMethod(cx,
        sessionData.getSessionHandler(), sessionData.getChannel(), dispatchId,
View Full Code Here

  }

  // ignoring the 'start' argument.
  @Override
  public Object get(int index, Scriptable start) {
    Value value = ServerMethods.getProperty(sessionData.getChannel(),
        sessionData.getSessionHandler(), objectRef, index);
    return sessionData.getSessionHandler().makeJsvalFromValue(jsContext, value);
  }
View Full Code Here

      TreeLogger branch = logger.branch(TreeLogger.SPAM,
          "Client special invoke of getProperty(" + dispId + " ["
              + ccl.getClassInfoByDispId(dispId).getMember(dispId) + "]) on "
              + obj.toString(), null);
      JsValueOOPHM jsval = (JsValueOOPHM) dispObj.getField(dispId);
      Value retVal = channel.convertFromJsValue(localObjects, jsval);
      branch.log(TreeLogger.SPAM, "result is " + retVal, null);
      return new ExceptionOrReturnValue(false, retVal);
    } catch (Throwable t) {
      JsValueOOPHM jsval = new JsValueOOPHM();
      JsValueGlue.set(jsval, moduleSpace.getIsolatedClassLoader(),
          t.getClass(), t);
      Value retVal = channel.convertFromJsValue(localObjects, jsval);
      return new ExceptionOrReturnValue(true, retVal);
    }
  }
View Full Code Here

    } catch (Throwable t) {
      exception = true;
      JsValueGlue.set(jsRetVal, moduleSpace.getIsolatedClassLoader(),
          t.getClass(), t);
    }
    Value retVal = channel.convertFromJsValue(localObjects, jsRetVal);
    jsToJavaCallEvent.end();
    return new ExceptionOrReturnValue(exception, retVal);
  }
View Full Code Here

      return new ExceptionOrReturnValue(false, newValue);
    } catch (Throwable t) {
      JsValueOOPHM jsval = new JsValueOOPHM();
      JsValueGlue.set(jsval, moduleSpace.getIsolatedClassLoader(),
          t.getClass(), t);
      Value retVal = channel.convertFromJsValue(localObjects, jsval);
      return new ExceptionOrReturnValue(true, retVal);
    }
  }
View Full Code Here

TOP

Related Classes of com.google.gwt.dev.shell.BrowserChannel.Value

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.