Author: [email protected]
Date: Wed Jan 14 09:17:15 2009
New Revision: 4449
Modified:
wiki/OverlayTypes.wiki
Log:
Edited wiki page through web user interface.
Modified: wiki/OverlayTypes.wiki
==============================================================================
--- wiki/OverlayTypes.wiki (original)
+++ wiki/OverlayTypes.wiki Wed Jan 14 09:17:15 2009
@@ -223,9 +223,33 @@
* Any given `...@singlejsoimpl` interface may be implemented by exactly one
overlay type, although that overlay type may be further extended. Any
number of non-overlay types may implement the interface. _This allows any
method defined in the interface to be statically-dispatched in the fallback
case._
* If a `...@singlejsoimpl` interfaces extends a non-trivial interface, that
super-interface must also be be annotated with `...@singlejsoimpl`.
* The `...@singlejsoimpl` annotation may only be applied to interfaces.
+ * Native JSNI methods may not refer to instance methods within
`...@singlejsoimpl` types, just as they may not refer to instance methods on
overlay types.
=== Hosted Mode Implementation ===
+The hosted-mode implementation relies on `JavaScriptObject$` implementing
all `...@singlejsoimpl` interfaces and supporting polymorphic dispatch. The
following bytecode transformations are applied: (note that code samples are
only intended to be representative of transformations applied)
+ * `JavaScriptObject$` implements all `...@singlejsoimpl` interfaces via the
disemboweled overlay types.
+ * All methods in a `...@singlejsoimpl` interface are renamed to include the
type name of the type.
+ * Implemented in `RewriteSingleJsoImplDispatches.java`.
+ * All call sites with a `...@singlejsoimpl` type as the owner are
rewritten with a mangled name. Call sites to more specific types are left
unchanged.
+ * `Person.getName()` would be transformed into
`Person.com_google_Person_getName()`
+ * _This allows `JavaScriptObject$` to unambiguously dispatch methods
with identical descriptors from unrelated interfaces_.
+ * `JavaScriptObject$` implements all of the mangled methods as
trampoline functions to the single JSO-derived implementation.
+ * Implemented in `WriteJsoImpl.java`.
+ {{{
+public String com_google_Person_someMethod(int a, int b) {
+ JsoPerson$.someMethod$(this, a, b);
+}
+}}}
+ * Non-overlay types that implement a `...@singlejsoimpl` interface have
trampoline methods added to call the un-mangled methods.
+ * Implemented in `RewriteSingleJsoImplDispatches.java`.
+ {{{
+public class JavaPerson implements Person {
+ public String com_google_Person_someMethod(int a, int b) {
+ return this.someMethod(a, b);
+}
+}}}
+ *
=== Web Mode Implementation ===
--~--~---------~--~----~------------~-------~--~----~
http://groups.google.com/group/Google-Web-Toolkit-Contributors
-~----------~----~----~----~------~----~------~--~---