Hi all. 

I'm playing with GWT overlay types for learning better ways of overlaying 
and working with them more agile. In particular I found that JSO setters 
methods that return 'this' for method chaining are a good way of defining 
an object state in a single Java statement, just like they are done in 
JavaScript. I written about this in 
http://cancerberonia.blogspot.com/2012/12/guidelines-for-writing-gwt-overlay-types.html

This setters methods look like this: 

public native final MyJSO color(String val) /*-{
  this["color"]=val; 
  return this;
}-*/;

So I can define an object in a single Java Statement like 

MyJSO my1 = MyJSO.create().color("red").age(14); 

I feel very confortable with that approach and using it on my GWT projects 
based on JSOs. But to my surprise (thanks to IRC user niloc132), these 
setters are not inlined in the GWT compiler JavaScript output. Please, read 
last part of my blog post "About Performance". For each setter a JavaScript 
function is defined and called: the JSNI code is not inlined. So this is 
not a zero overhead solution (as my libraries promise). 

I tried different approachs for defining these setters, but with the same 
results in all cases. My question is, can I force the GWT compiler somehow 
to inline some of mine JSNI methods, perhaps with some annotation ? Do 
somebody have any suggestions for making setters returning 'this' to be 
inlined in javascript output instead of creating and calling javascript 
functions in javascript generated code ? 

Regards and thanks in advance. 

-- 
You received this message because you are subscribed to the Google Groups 
"Google Web Toolkit" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/google-web-toolkit/-/nP7VQfsZHvgJ.
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.

Reply via email to