Comment by cromwellian:

It would be interesting to consider Constructor() as being rewritten to a  
static method with an implicit call to createObject() and all references to  
this rewritten to this$static. e.g.

public Foo(int x, String y) {
   this.x = x;
   this.y = y;
}

rewritten to

public static Foo consFoo(int x, String y) {
   Foo this$static=createObject.cast();
   this$static.x=x;
   this$static.y=y;
   return this$static;
}

Moreover, you could consider any field declarations on Foo as having  
implicit native methods for getting and assignment. Thus,

public Foo extends JavaScriptObject {
   int x;
}

would implicitly have methods like

native int getX() /*-{ return x; }-*/;
native void setX(int x) /*-{ this.x=x; }-*/;

although these would only exist in the compiler/AST (purely for  
visualization purposes here). That way, needless boilerplate accessors in  
JSOs would be eliminated.

All of the usual JSO restrictions would apply. This is purely syntactic  
sugar. Stuff like field initializers and super calls in the constructor  
would still be banned (for now), although they could be supported via  
additional rewriting logic (like moving initializers into the synthesized  
factory method and super calls invoking super class factory methods which  
take this$static parameters)



For more information:
http://code.google.com/p/google-web-toolkit/wiki/OverlayTypes

--~--~---------~--~----~------------~-------~--~----~
http://groups.google.com/group/Google-Web-Toolkit-Contributors
-~----------~----~----~----~------~----~------~--~---

Reply via email to