Hi everyone,
I hope I'll be clear enough so this answer actually makes sense...
I have a chain of generators that are configured by one deferred binding property and I need the generators to produce different results based on this property. There aren't many examples on how to achieve this, I started by looking how i18n does that (which is the only generator I know that produces different results for different permutations) and soon after I realized that I need to output different implementation class names (obviously) to achieve that. Then the DistillerRebindPermutationOracle really sets proper implementation class names to interface names that are generated.
So far so good, I can change the behavior of this one generated class but what if my generator produces a code that needs to rebind another class by another generator. This is where I got stuck because permutations that belong to another configuration are trying to rebind classes that should (and are) never used in those permutations. The order of the subsequent rebinding is set by how the implementation names are sorted inside the DistillerRebindPermutationOracle result (given by a set of all rebound classes for all permutations).
Here is an example of what I'm trying to achieve:
public interface Factory {
Factory IMPL = GWT.create(Factory.class);
SomeObj getImpl();
}
//Config1 generated
public class FacoryImpl implements Factory {
public SomeObj() {
SomeObj result = new SomeObj();
INIT1.init(result);
}
public interface Init1 extends Initializer<SomeObj> {}
static Initializer<SomeObj> INIT1 = GWT.create(Init1.class);
}
//Config2 generated
public class FacoryImpl2 implements Factory {
public SomeObj() {
SomeObj result = new SomeObj();
INIT1.init(result);
}
public interface Init1 extends Initializer<SomeObj> {}
static Initializer<SomeObj> INIT1 = GWT.create(Init1.class);
}
Both of these classes are almost identical, this is expected and designed to work this way, the difference is in the initializers and this is where I'm getting errors during rebinding. FactoryImpl2.Init1 is rebound first in Config1 permutation context and it fails inside my code. My point is, since FactoryImpl2 is never used in permutation 1, why is the compiler trying to rebind it in this permutation? Is there some problem in my gwt.xml or are the generators just not designed to do this? Or is it implemented in such a way that classes that are never used are ignored later by dead code elimination and I should just generate stub implementations and leave the rest to the compiler. I could always compile both configurations separately and use custom bootstrap to load the proper module/permutation.
I would expect the initializers to look something like this:
//Config1
public class FactoryImpl_Init1Impl implements FactoryImpl.Init1 {
public void init(SomeObj o) {
o.setSomething(1);
}
}
//Config2
public class FactoryImpl2_Init1Impl2 implements FactoryImpl2.Init1 {
public void init(SomeObj o) {
o.setSomething(2);
}
}
Any help/clarification would be much appreciated!
Honza
You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-web-toolkit+unsubscribe@googlegroups.com.
To post to this group, send email to google-web-toolkit@googlegroups.com.
Visit this group at http://groups.google.com/group/google-web-toolkit.
For more options, visit https://groups.google.com/d/optout.
No comments:
Post a Comment