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

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


        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;
    logger.log(TreeLogger.SPAM, "INVOKE: jsFunction: " + jsFunction);

    Object jsArgs[] = new Object[args.length];
View Full Code Here


    throw new UnsupportedOperationException("loadModule must not be called");
  }

  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;
    }
    return new Value(value);
  }
View Full Code Here

   */
  static Value getProperty(BrowserChannel channel,
      HtmlUnitSessionHandler handler, int objectRef, int dispatchId) {
    if (!((BrowserChannelClient) 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.getHtmlPage()) {
      try {
        new InvokeSpecialMessage(channel, SpecialDispatchId.GetProperty, args).send();
        // TODO: refactor in order to remove cast.
        ReturnMessage returnMessage = ((BrowserChannelClient) 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(BrowserChannel channel,
      HtmlUnitSessionHandler 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.getHtmlPage()) {
View Full Code Here

        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;
    logger.log(TreeLogger.SPAM, "INVOKE: jsFunction: " + jsFunction);

    Object jsArgs[] = new Object[args.length];
View Full Code Here

    throw new UnsupportedOperationException("loadModule must not be called");
  }

  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;
    }
    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

      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 = serverChannel.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 = serverChannel.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 = serverChannel.convertFromJsValue(localObjects, jsRetVal);
    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 = serverChannel.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.