001: /*
002: * Copyright 2007 Google Inc.
003: *
004: * Licensed under the Apache License, Version 2.0 (the "License"); you may not
005: * use this file except in compliance with the License. You may obtain a copy of
006: * the License at
007: *
008: * http://www.apache.org/licenses/LICENSE-2.0
009: *
010: * Unless required by applicable law or agreed to in writing, software
011: * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
012: * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
013: * License for the specific language governing permissions and limitations under
014: * the License.
015: */
016: package com.google.gwt.dev.shell;
017:
018: import com.google.gwt.core.ext.UnableToCompleteException;
019:
020: /**
021: * This interface contains all of the methods that must be exposed to a hosted
022: * mode application via its JavaScriptHost class. JavaScriptHost contains a
023: * method called setHost() that must be called when a new application is
024: * initialized.
025: *
026: * This interface works with JavaScriptHost to keep running applications at
027: * arms-length via an isolated class loader (this requires that there be no
028: * explicit dependencies between the shell and any client-side classes).
029: */
030: public interface ShellJavaScriptHost {
031:
032: /**
033: * Defines a new native JavaScript function.
034: *
035: * @param name the function's name, usually a JSNI signature
036: * @param paramNames parameter names
037: * @param js the script body
038: */
039: abstract void createNative(String file, int line, String name,
040: String[] paramNames, String js);
041:
042: /**
043: * Call this when a JavaScript exception is caught.
044: */
045: abstract void exceptionCaught(int number, String name,
046: String description);
047:
048: /**
049: * Invoke a native JavaScript function that returns a boolean value.
050: */
051: abstract boolean invokeNativeBoolean(String name, Object jthis ,
052: Class<?>[] types, Object[] args) throws Throwable;
053:
054: /**
055: * Invoke a native JavaScript function that returns a byte value.
056: */
057: abstract byte invokeNativeByte(String name, Object jthis ,
058: Class<?>[] types, Object[] args) throws Throwable;
059:
060: /**
061: * Invoke a native JavaScript function that returns a character value.
062: */
063: abstract char invokeNativeChar(String name, Object jthis ,
064: Class<?>[] types, Object[] args) throws Throwable;
065:
066: /**
067: * Invoke a native JavaScript function that returns a double value.
068: */
069: abstract double invokeNativeDouble(String name, Object jthis ,
070: Class<?>[] types, Object[] args) throws Throwable;
071:
072: /**
073: * Invoke a native JavaScript function that returns a float value.
074: */
075: abstract float invokeNativeFloat(String name, Object jthis ,
076: Class<?>[] types, Object[] args) throws Throwable;
077:
078: /**
079: * Invoke a native JavaScript function that returns a handle value.
080: */
081: abstract Object invokeNativeHandle(String name, Object jthis ,
082: Class<?> returnType, Class<?>[] types, Object[] args)
083: throws Throwable;
084:
085: /**
086: * Invoke a native JavaScript function that returns an integer value.
087: */
088: abstract int invokeNativeInt(String name, Object jthis ,
089: Class<?>[] types, Object[] args) throws Throwable;
090:
091: /**
092: * Invoke a native JavaScript function that returns a long value.
093: */
094: abstract long invokeNativeLong(String name, Object jthis ,
095: Class<?>[] types, Object[] args) throws Throwable;
096:
097: /**
098: * Invoke a native JavaScript function that returns an object value.
099: */
100: abstract Object invokeNativeObject(String name, Object jthis ,
101: Class<?>[] types, Object[] args) throws Throwable;
102:
103: /**
104: * Invoke a native JavaScript function that returns a short value.
105: */
106: abstract short invokeNativeShort(String name, Object jthis ,
107: Class<?>[] types, Object[] args) throws Throwable;
108:
109: /**
110: * Invoke a native JavaScript function that returns a string value.
111: */
112: abstract String invokeNativeString(String name, Object jthis ,
113: Class<?>[] types, Object[] args) throws Throwable;
114:
115: /**
116: * Invoke a native JavaScript function that returns no value.
117: */
118: abstract void invokeNativeVoid(String name, Object jthis ,
119: Class<?>[] types, Object[] args) throws Throwable;
120:
121: /**
122: * Logs to the dev shell logger.
123: */
124: abstract void log(String message, Throwable e);
125:
126: /**
127: * Resolves a deferred binding request and create the requested object.
128: */
129: abstract <T> T rebindAndCreate(String requestedTypeName)
130: throws UnableToCompleteException;
131: }
|