I'm very close, i've just compiled a GData JS example via the GData
GWT library - which retrieves a Calendar feed - and it worked.
Here are some of the implementation choices i've made so far:
- map all namespaces to be under com.google.gwt.gdata.client.*
- map all Object parameters to JavaScriptObject (some GData functions
receive generic JS objects for initialization purposes).
- implement JS classes as Overlay Types
- implement class constants as JSNI methods, for example:
public static native String REL_MESSAGE_TO() /*-{ return
$wnd.google.gdata.Who.REL_MESSAGE_TO; }-*/;
- implement constructors as JSNI methods (since i'm using Overlay
Types), for example:
public static native Who construct() /*-{ return new
$wnd.google.gdata.Who(undefined); }-*/;
- generate overloads for methods that have optional parameters or
multi-type parameters in JS, for example:
public final native void setValueString(String valueString) /*-
{ this.setValueString(valueString); }-*/;
public final native void setValueString() /*-{ this.setValueString
(undefined); }-*/;
- implement continuation callbacks (non success/failure) as Runnable,
for example:
public static final native boolean getInfo(Runnable callback) /*-
{ return $wnd.google.accounts.user.getInfo(function()
{ [email protected]::run()(); }); }-*/;
- implement success/failure callbacks as AsyncCallback<T>, for
example:
public final native CalendarAclFeed getAclFeed(String uri,
AsyncCallback<CalendarAclFeed> callback) /*-{
return this.getAclFeed(uri, function(result)
{ @com.google.gwt.gdata.client.impl.Utils::handleSuccessCallback(Lcom/
google/gwt/user/client/rpc/AsyncCallback;Ljava/lang/Object;)(callback,
result); }, function(error)
{ @com.google.gwt.gdata.client.impl.Utils::handleFailureCallback(Lcom/
google/gwt/user/client/rpc/AsyncCallback;Ljava/lang/String;)(callback,
error); });
}-*/;
- ignore all instance fields, since GData implements getters and
setters.
- use the existing AjaxLoader to loading the JS libraries.
Pending testing. Adding overloads has been interesting, for a given
method with n optional parameters there are 2^n overloads to be added
- plus some JS methods have multi-type parameters so those need to be
defined as well.
Here's a class from the GWT GData library (corresponds to
http://code.google.com/apis/gdata/jsdoc/1.8/google/gdata/Who.html):
package com.google.gwt.gdata.client;
import com.google.gwt.gdata.client.EntryLink;
import com.google.gwt.gdata.client.AttendeeType;
import com.google.gwt.gdata.client.AttendeeStatus;
import com.google.gwt.core.client.JavaScriptObject;
public class Who extends com.google.gwt.core.client.JavaScriptObject {
public static native String REL_EVENT_ATTENDEE() /*-{ return
$wnd.google.gdata.Who.REL_EVENT_ATTENDEE; }-*/;
public static native String REL_EVENT_ORGANIZER() /*-{ return
$wnd.google.gdata.Who.REL_EVENT_ORGANIZER; }-*/;
public static native String REL_EVENT_PERFORMER() /*-{ return
$wnd.google.gdata.Who.REL_EVENT_PERFORMER; }-*/;
public static native String REL_EVENT_SPEAKER() /*-{ return
$wnd.google.gdata.Who.REL_EVENT_SPEAKER; }-*/;
public static native String REL_MESSAGE_BCC() /*-{ return
$wnd.google.gdata.Who.REL_MESSAGE_BCC; }-*/;
public static native String REL_MESSAGE_CC() /*-{ return
$wnd.google.gdata.Who.REL_MESSAGE_CC; }-*/;
public static native String REL_MESSAGE_FROM() /*-{ return
$wnd.google.gdata.Who.REL_MESSAGE_FROM; }-*/;
public static native String REL_MESSAGE_REPLY_TO() /*-{ return
$wnd.google.gdata.Who.REL_MESSAGE_REPLY_TO; }-*/;
public static native String REL_MESSAGE_TO() /*-{ return
$wnd.google.gdata.Who.REL_MESSAGE_TO; }-*/;
public static native String REL_TASK_ASSIGNED_TO() /*-{ return
$wnd.google.gdata.Who.REL_TASK_ASSIGNED_TO; }-*/;
protected Who() { }
public static native Who construct(JavaScriptObject opt_params) /*-
{ return new $wnd.google.gdata.Who(opt_params); }-*/;
public static native Who construct() /*-{ return new
$wnd.google.gdata.Who(undefined); }-*/;
public final native AttendeeStatus getAttendeeStatus() /*-{ return
this.getAttendeeStatus(); }-*/;
public final native AttendeeType getAttendeeType() /*-{ return
this.getAttendeeType(); }-*/;
public final native String getEmail() /*-{ return this.getEmail(); }-
*/;
public final native EntryLink getEntryLink() /*-{ return
this.getEntryLink(); }-*/;
public final native String getRel() /*-{ return this.getRel(); }-*/;
public final native String getValueString() /*-{ return
this.getValueString(); }-*/;
public final native void setAttendeeStatus(JavaScriptObject
attendeeStatus) /*-{ this.setAttendeeStatus(attendeeStatus); }-*/;
public final native void setAttendeeStatus() /*-
{ this.setAttendeeStatus(undefined); }-*/;
public final native void setAttendeeStatus(AttendeeStatus
attendeeStatus) /*-{ this.setAttendeeStatus(attendeeStatus); }-*/;
public final native void setAttendeeType(JavaScriptObject
attendeeType) /*-{ this.setAttendeeType(attendeeType); }-*/;
public final native void setAttendeeType() /*-{ this.setAttendeeType
(undefined); }-*/;
public final native void setAttendeeType(AttendeeType attendeeType) /
*-{ this.setAttendeeType(attendeeType); }-*/;
public final native void setEmail(String email) /*-{ this.setEmail
(email); }-*/;
public final native void setEmail() /*-{ this.setEmail(undefined); }-
*/;
public final native void setEntryLink(JavaScriptObject entryLink) /*-
{ this.setEntryLink(entryLink); }-*/;
public final native void setEntryLink() /*-{ this.setEntryLink
(undefined); }-*/;
public final native void setEntryLink(EntryLink entryLink) /*-
{ this.setEntryLink(entryLink); }-*/;
public final native void setRel(String rel) /*-{ this.setRel(rel); }-
*/;
public final native void setRel() /*-{ this.setRel(undefined); }-*/;
public final native void setValueString(String valueString) /*-
{ this.setValueString(valueString); }-*/;
public final native void setValueString() /*-{ this.setValueString
(undefined); }-*/;
}
Bobby
On May 3, 9:05 pm, Eric Ayers <[email protected]> wrote:
> I think you should make it a separate module, but at this point, I think it
> should remain under gdata for now. I see other APIs use this namespace, but
> I will have to coordinate to see if it can truly be shared like AjaxLoader
> apis.
>
>
>
>
>
> On Sun, May 3, 2009 at 2:51 PM, Bobby <[email protected]> wrote:
>
> > Thanks Eric, it works for me. On a related topic, there's a namespace
> > in the GData API, google.accounts, that i think should be in its own
> > GWT module as well:
> >http://code.google.com/apis/gdata/jsdoc/1.8/google/accounts.html
>
> > It's used by GData to authenticate via AuthSub, but it's outside
> > GData.
>
> > Bobby
>
> > On May 3, 6:38 am, Eric Ayers <[email protected]> wrote:
> > > Hi guys,
> > > The AjaxLoader API will be put in public release soon. I've made a
> > release
> > > branch for it under subversion athttp://
> > gwt-google-apis.googlecode.com/svn/releases/ajaxloader/1.0
>
> > > -Eric.
>
> > > On Sun, May 3, 2009 at 2:40 AM, Bobby <[email protected]> wrote:
>
> > > > I'm going over the following pages carefully:
>
> > > >http://code.google.com/docreader/#p=gwt-google-apis&s=gwt-google-apis.
> > ..
>
> > > > Some GWT APIs, such as the Maps API, already have an implementation of
> > > > the AjaxLoader for loading Google JS libraries, so that's one less
> > > > thing to do.
>
> > > > Bobby
>
> > > > On Apr 27, 2:58 am, Bobby <[email protected]> wrote:
> > > > > I just came across some interesting docs, this one in particular
> > > > > covers almost all the questions i had in my original post (lots of
> > > > > TBDs though):
> > > >http://code.google.com/docreader/#p=gwt-google-apis&s=gwt-google-apis.
> > ..
>
> > > > > Also, check out what's underneath the "large efforts" heading in the
> > > > > wishlist page:
> > > >http://code.google.com/docreader/#p=gwt-google-apis&s=gwt-google-apis.
> > ..
>
> > > > > That's right, and here i am going it alone, you ought to be
> > > > > ashamed. :)
>
> > > > > Bobby
>
> > > > > On Apr 27, 2:21 am, Bobby <[email protected]> wrote:
>
> > > > > > I would prefer having a GWT library for GData, it seems within
> > reach.
>
> > > > > > Bobby
>
> > > > > > On Apr 26, 11:55 pm, Vitali Lovich <[email protected]> wrote:
>
> > > > > > > Couldn't arbitrary JS support be added using deferred binding?
> > Sure,
> > > > you
> > > > > > > wouldn't be able to do code completion, but you could call
> > arbitrary
> > > > JS
> > > > > > > functions & variables with 0-overhead. Might be a cool project
> > to do
> > > > (if
> > > > > > > Ray hasn't already done it :D).
>
> > > > > > > On Sun, Apr 26, 2009 at 11:43 PM, Bobby <[email protected]>
> > > > wrote:
>
> > > > > > > > I finally got the GData library to compile inside a GWT 1.6
> > test
> > > > app.
> > > > > > > > Now it's down to testing.
>
> > > > > > > > I'm considering auto generating a test app as well, otherwise i
> > > > won't
> > > > > > > > be able to find out what's broken, otherwise i have to test
> > each
> > > > class
> > > > > > > > manually.
>
> > > > > > > > It looks good at this point but i'm antecipating plenty of
> > > > headaches
> > > > > > > > in testing.
>
> > > > > > > > Bobby
>
> > > > > > > > On Apr 20, 6:51 pm, Bobby <[email protected]> wrote:
> > > > > > > > > The GData JS API is doing some fancy stuff to be able to POST
> > > > data
> > > > > > > > > across domains, etc, it's also fairly large (in number of
> > > > classes) and
> > > > > > > > > it's missing some large GData components (for Google Docs and
> > > > > > > > > Spreadsheets). All of this i'm guessing is why Google doesn't
> > > > have a
> > > > > > > > > GWT library out for GData yet. I wouldn't want to code this
> > > > manually
> > > > > > > > > but i if i can automate it then it's ok.
>
> > > > > > > > > > I'd rather wait to see some code ;-)
> > > > > > > > > > (and I have so many projects yet that I don't have time to
> > > > update...)
>
> > > > > > > > > Oh right, no chance, it's now or never (or whenever you feel
> > like
> > > > up
> > > > > > > > > to it, just let me know).
>
> > > > > > > > > I'm counting on being able to auto-generate a decent wrapper
> > > > without
> > > > > > > > > much difficulty, if this becomes complex or beyond my means
> > i'll
> > > > just
> > > > > > > > > let Google worry about it. This is why i want to test a rough
> > > > version
> > > > > > > > > of the wrapper ASAP.
>
> > > > > > > > > Anyway thanks for all the pointers, i'll post more questions
> > here
> > > > as
> > > > > > > > > they come up.
>
> > > > > > > > > Bobby
>
> > > > > > > > > On Apr 20, 6:04 pm, Thomas Broyer <[email protected]>
> > wrote:
>
> > > > > > > > > > On Mon, Apr 20, 2009 at 6:38 PM, Bobby wrote:
>
> > > > > > > > > > > I realize that your getConstant approach has an
> > > > initialization
> > > > > > > > > > > overhead but i'm going to overlook that so that i can get
> > the
> > > > > > > > > > > generated library to a point where i can test it and then
> > > > come back
> > > > > > > > > > > and revisit this. This will be more complex because the
> > GData
> > > > JS
> > > > > > > > > > > implementation allows "namespaces" to be loaded
> > dynamically
> > > > as
> > > > > > > > needed.
>
> > > > > > > > > > Given that the protocol is clearly defined and documented,
> > I
> > > > wonder if
> > > > > > > > > > a "pure GWT" implementation wouldn't be better...
> > > > > > > > > > Well, eventually, that could be your "v2.0" ;-)
>
> > > > > > > > > > > On the return type of the JS methods that receive
> > callbacks,
> > > > most
> > > > > > > > > > > likely these methods return void, i think that's just the
> > way
> > > > the
> > > > > > > > > > > JSDocs display - otherwise they would have to display
> > that as
> > > > > > > > > > > void updateEntry(<google.gdata.Entry function(Object)>
> > > > continuation,
> > > > > > > > > > > <google.gdata.Entry function(Error)> opt_errorHandler).
>
> > > > > > > > > > Er, you probably mean void updateEntry(<void
> > > > > > > > > > function(google.gdata.Entry)> continuation, <void
> > > > function(Error)>
> > > > > > > > > > opt_errorHandler)
>
> > > > > > > > > > > This type of ambiguity is why an 100% auto-generate is
> > not
> > > > going to
> > > > > > > > > > > happen - in addition to this there are a couple of
> > classes
> > > > missing
> > > > > > > > > > > from the JS Docs (i'll just fill those in from the GData
> > Java
> > > > docs).
>
> > > > > > > > > > Well, I don't know what you're generating from, but it
> > could be
> > > > as
> > > > > > > > > > easy as "if the method takes 2 arguments of type function,
> > the
> > > > second
> > > > > > > > > > one taking an Error argument, then convert them to an
> > > > AsyncCallback<T>
> > > > > > > > > > where T is the method's documented return type, and make
> > the
> > > > method
> > > > > > > > > > actually have a void return type".
>
> > > > > > > > > > > I like the idea of using an intermediate class to handle
> > the
> > > > > > > > > > > callbacks, i think you mentioned this in your original
> > reply
> > > > and i
> > > > > > > > > > > missed it.
>
> > > > > > > > > > Hmm, not quite sure what you're talking about...
>
> > > > > > > > > > > If you're interested, and since you already put some time
> > > > here i can
> > > > > > > > > > > add you as a member of this project:
> > > > > > > > > > >http://code.google.com/p/gdata-gwt-client/
> > > > > > > > > > > This way you get some credit.
>
> > > > > > > > > > I'd rather wait to see some code ;-)
> > > > > > > > > > (and I have so many projects yet that I don't have time to
> > > > update...)
>
> > > > > > > > > > > This is a key library for GWT in my
> > > > > > > > > > > opinion and it's missing - Google says they don't have
> > plans
> > > > to do
> > > > > > > > > > > this right now so it's a good opportunity.
>
> > > > > > > > > > Probably because they'd rather do it in GWT than as a GWT
> > > > wrapper
> > > > > > > > > > around the JS API, which is a bit more work probably...
> > > > > > > > > > (and they'd have to have time to maintain it, etc.)
>
> > > > > > > > > > Anyway, good luck ;-)
>
> > > > > > > > > > --
> > > > > > > > > > Thomas Broyer- Hide quoted text -
>
> > > > > > > > > - Show quoted text -- Hide quoted text -
>
> > > > > > > - Show quoted text -- Hide quoted text -
>
> > > > > > - Show quoted text -- Hide quoted text -
>
> > > > > - Show quoted text -
>
> > > --
> > > Eric Z. Ayers - GWT Team - Atlanta, GA USAhttp://
> > code.google.com/webtoolkit/- Hide quoted text -
>
> > > - Show quoted text -
>
> --
> Eric Z. Ayers - GWT Team - Atlanta, GA USAhttp://code.google.com/webtoolkit/-
> Hide quoted text -
>
> - Show quoted text -
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Google Web Toolkit" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/Google-Web-Toolkit?hl=en
-~----------~----~----~----~------~----~------~--~---