public class MagicMethods extends Object
UnifyAst). Because these methods are only used in production
mode, the methods they override must implement the same functionality for gwt dev mode / pure java. It is
recommended to direct your magic methods outside of the class from which they are called; the contents of
the class they are sourced from will be included in production gwt compiles, so simply delegate your static
methods from X_Impl.someMethod -> Jre_Impl.someMethod, and do your work there. In order to inject your own
magic methods, simply include xapi.X_Inject in your gwt module, then add the following (assuming
your method is: MagicMethodGenerator.injectMagic(TreeLogger, JMethodCall, JMethod, Context, UnifyAstView), though you may
name your methods anything you please, and must return a JExpression or throw an exception. Returning null
will allow your code to compile, but you will hit mysterious null.nullMethod() errors. (in other words,
throw an exception instead of return null; unless you love hours of debugging.)| Constructor and Description |
|---|
MagicMethods() |
| Modifier and Type | Method and Description |
|---|---|
static com.google.gwt.dev.jjs.ast.JExpression |
rebindInstance(com.google.gwt.core.ext.TreeLogger logger,
com.google.gwt.dev.jjs.ast.JMethodCall x,
com.google.gwt.dev.jjs.ast.JMethod currentMethod,
com.google.gwt.dev.jjs.ast.Context context,
com.google.gwt.dev.jjs.UnifyAstView ast)
Replaces a call from
X_Inject.singleton(Class) by first a-0) generating a provider which will be
synchronous if an async call hasn't already been made, or a-1) generating a provider which will route
through the async provider, and return null before inited. |
static <T> com.google.gwt.dev.jjs.ast.JExpression |
rebindNewInstance(com.google.gwt.core.ext.TreeLogger logger,
com.google.gwt.dev.jjs.ast.JMethodCall x,
com.google.gwt.dev.jjs.ast.JMethod currentMethod,
com.google.gwt.dev.jjs.ast.Context context,
com.google.gwt.dev.jjs.UnifyAstView ast) |
static com.google.gwt.dev.jjs.ast.JExpression |
rebindSingleton(com.google.gwt.core.ext.TreeLogger logger,
com.google.gwt.dev.jjs.ast.JMethodCall x,
com.google.gwt.dev.jjs.ast.JMethod currentMethod,
com.google.gwt.dev.jjs.ast.Context context,
com.google.gwt.dev.jjs.UnifyAstView ast)
Replaces a call from
X_Inject.singleton(Class) by first a-0) generating a provider which will be
synchronous if an async call hasn't already been made, or a-1) generating a provider which will route
through the async provider, and return null before inited. |
static com.google.gwt.dev.jjs.ast.JExpression |
rebindSingletonAndCallback(com.google.gwt.core.ext.TreeLogger logger,
com.google.gwt.dev.jjs.ast.JMethodCall methodCall,
com.google.gwt.dev.jjs.ast.JMethod currentMethod,
com.google.gwt.dev.jjs.ast.Context context,
com.google.gwt.dev.jjs.UnifyAstView ast)
Replaces a call from
X_Inject.singletonAsync(Class, xapi.util.api.ReceivesValue) by first a)
generating an async provider, and then b) sending the value receiver into the async provider as a
callback. |
static com.google.gwt.dev.jjs.ast.JExpression |
rebindSingletonAsync(com.google.gwt.core.ext.TreeLogger logger,
com.google.gwt.dev.jjs.ast.JMethodCall methodCall,
com.google.gwt.dev.jjs.ast.JMethod currentMethod,
com.google.gwt.dev.jjs.ast.Context context,
com.google.gwt.dev.jjs.UnifyAstView ast)
Replaces a call from
X_Inject.singletonAsync(Class, xapi.util.api.ReceivesValue) by first a)
generating an async provider, and then b) sending the value receiver into the async provider as a
callback. |
static com.google.gwt.dev.jjs.ast.JExpression |
rebindSingletonLazy(com.google.gwt.core.ext.TreeLogger logger,
com.google.gwt.dev.jjs.ast.JMethodCall x,
com.google.gwt.dev.jjs.ast.JMethod currentMethod,
com.google.gwt.dev.jjs.ast.Context context,
com.google.gwt.dev.jjs.UnifyAstView ast)
Replaces a call from
X_Inject.singletonLazy(Class) by first a-0) generating a provider which will
be synchronous if an async call hasn't already been made, or a-1) generating a provider which will route
through the async provider, and return null before inited. |
static String |
toSourceName(com.google.gwt.dev.jjs.ast.JDeclaredType type) |
public static com.google.gwt.dev.jjs.ast.JExpression rebindSingletonAsync(com.google.gwt.core.ext.TreeLogger logger, com.google.gwt.dev.jjs.ast.JMethodCall methodCall, com.google.gwt.dev.jjs.ast.JMethod currentMethod, com.google.gwt.dev.jjs.ast.Context context, com.google.gwt.dev.jjs.UnifyAstView ast) throws com.google.gwt.core.ext.UnableToCompleteException
X_Inject.singletonAsync(Class, xapi.util.api.ReceivesValue) by first a)
generating an async provider, and then b) sending the value receiver into the async provider as a
callback. See the AsyncProxy class and AsyncInjectionGenerator for implementation.logger - - The logger to log to.methodCall - - The method call we are overwritingcurrentMethod - - The encapsulated method itselfcontext - - The method call context, so you can insert clinits / whatnotast - - A view over UnifyAst, exposing our basic needscom.google.gwt.core.ext.UnableToCompleteExceptionpublic static com.google.gwt.dev.jjs.ast.JExpression rebindSingletonAndCallback(com.google.gwt.core.ext.TreeLogger logger, com.google.gwt.dev.jjs.ast.JMethodCall methodCall, com.google.gwt.dev.jjs.ast.JMethod currentMethod, com.google.gwt.dev.jjs.ast.Context context, com.google.gwt.dev.jjs.UnifyAstView ast) throws com.google.gwt.core.ext.UnableToCompleteException
X_Inject.singletonAsync(Class, xapi.util.api.ReceivesValue) by first a)
generating an async provider, and then b) sending the value receiver into the async provider as a
callback. See the AsyncProxy class and AsyncInjectionGenerator for implementation.logger - - The logger to log to.methodCall - - The method call we are overwritingcurrentMethod - - The encapsulated method itselfcontext - - The method call context, so you can insert clinits / whatnotast - - A view over UnifyAst, exposing our basic needscom.google.gwt.core.ext.UnableToCompleteExceptionpublic static com.google.gwt.dev.jjs.ast.JExpression rebindSingletonLazy(com.google.gwt.core.ext.TreeLogger logger, com.google.gwt.dev.jjs.ast.JMethodCall x, com.google.gwt.dev.jjs.ast.JMethod currentMethod, com.google.gwt.dev.jjs.ast.Context context, com.google.gwt.dev.jjs.UnifyAstView ast) throws com.google.gwt.core.ext.UnableToCompleteException
X_Inject.singletonLazy(Class) by first a-0) generating a provider which will
be synchronous if an async call hasn't already been made, or a-1) generating a provider which will route
through the async provider, and return null before inited. then b) returning a simple lazy provider which
will poll the actual provider until it is set. If you use the
X_Inject.singletonAsync(Class, xapi.util.api.ReceivesValue) once, you should not use the
other two synchronous provider methods, as they may return null if you happen to request them before the
code split containing the service is downloaded.logger - - The logger to log to.methodCall - - The method call we are overwritingcurrentMethod - - The encapsulated method itselfcontext - - The method call context, so you can insert clinits / whatnotast - - A view over UnifyAst, exposing our basic needscom.google.gwt.core.ext.UnableToCompleteExceptionpublic static com.google.gwt.dev.jjs.ast.JExpression rebindSingleton(com.google.gwt.core.ext.TreeLogger logger, com.google.gwt.dev.jjs.ast.JMethodCall x, com.google.gwt.dev.jjs.ast.JMethod currentMethod, com.google.gwt.dev.jjs.ast.Context context, com.google.gwt.dev.jjs.UnifyAstView ast) throws com.google.gwt.core.ext.UnableToCompleteException
X_Inject.singleton(Class) by first a-0) generating a provider which will be
synchronous if an async call hasn't already been made, or a-1) generating a provider which will route
through the async provider, and return null before inited. then b) creates a lazy provider to call into
the synchronous provider finally c) calls .get() on the provider and return the value. If you use the
X_Inject.singletonAsync(Class, xapi.util.api.ReceivesValue) once, you should not use the
other two synchronous provider methods, as they may return null if you happen to request them before the
code split containing the service is downloaded.logger - - The logger to log to.methodCall - - The method call we are overwritingcurrentMethod - - The encapsulated method itselfcontext - - The method call context, so you can insert clinits / whatnotast - - A view over UnifyAst, exposing our basic needscom.google.gwt.core.ext.UnableToCompleteExceptionpublic static <T> com.google.gwt.dev.jjs.ast.JExpression rebindNewInstance(com.google.gwt.core.ext.TreeLogger logger, com.google.gwt.dev.jjs.ast.JMethodCall x, com.google.gwt.dev.jjs.ast.JMethod currentMethod, com.google.gwt.dev.jjs.ast.Context context, com.google.gwt.dev.jjs.UnifyAstView ast)
public static com.google.gwt.dev.jjs.ast.JExpression rebindInstance(com.google.gwt.core.ext.TreeLogger logger, com.google.gwt.dev.jjs.ast.JMethodCall x, com.google.gwt.dev.jjs.ast.JMethod currentMethod, com.google.gwt.dev.jjs.ast.Context context, com.google.gwt.dev.jjs.UnifyAstView ast) throws com.google.gwt.core.ext.UnableToCompleteException
X_Inject.singleton(Class) by first a-0) generating a provider which will be
synchronous if an async call hasn't already been made, or a-1) generating a provider which will route
through the async provider, and return null before inited. then b) creates a lazy provider to call into
the synchronous provider finally c) calls .get() on the provider and return the value. If you use the
X_Inject.singletonAsync(Class, xapi.util.api.ReceivesValue) once, you should not use the
other two synchronous provider methods, as they may return null if you happen to request them before the
code split containing the service is downloaded.logger - - The logger to log to.methodCall - - The method call we are overwritingcurrentMethod - - The encapsulated method itselfcontext - - The method call context, so you can insert clinits / whatnotast - - A view over UnifyAst, exposing our basic needscom.google.gwt.core.ext.UnableToCompleteExceptionpublic static String toSourceName(com.google.gwt.dev.jjs.ast.JDeclaredType type)
Copyright © December 07, 2012–2015 The Internet Party. All rights reserved.