Subversion Repositories pub

Compare Revisions

No changes between revisions

Ignore whitespace Rev 55 → Rev 56

/pluggablejs/trunk/src/net/outlyer/plugins/SandboxImpl.java
24,6 → 24,8
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
 
// $Id$
 
import net.outlyer.plugins.Sandbox;
import java.io.File;
import java.io.IOException;
176,40 → 178,56
execute(false, null, null);
}
 
public <T> T createDelayedImplementation(Class<T> c, String objectName)
public <T> T createDelayedImplementation(final Class<T> c,
final String objectName)
throws PluginExecutionException {
System.err.println("createDelayedImple");
final String varImpl = uniqueVarName();
 
final StringBuilder code = new StringBuilder();
 
code.append("var ").append(objectName).append(" = {\n");
for (final Method method : c.getMethods()) {
if (method.getDeclaringClass() != c) {
continue;
}
code.append(method.getName()).append(": null,");
}
code.append("};\n");
 
code.append(varImpl).append(" = new ")
.append(c.getCanonicalName()).append("(").append(objectName).append(");");
//System.err.println(code.toString());
System.err.println(code.toString());
 
final ScriptEngine rhino = execute(true, code.toString(), null);
 
assert (c.isInstance(rhino.get(varImpl)));
return (T) rhino.get(varImpl);
}
 
public <T> T createDelayedImplementation(Class<T> c) throws PluginExecutionException {
public <T> T createDelayedImplementation(final Class<T> c)
throws PluginExecutionException {
return createDelayedImplementation(c, false);
}
public <T> T createDelayedImplementation(Class<T> c, boolean allowPartial) throws PluginExecutionException {
 
public <T> T createDelayedImplementation(final Class<T> c, boolean allowPartial)
throws PluginExecutionException {
return createDelayedImplementation(c, null, allowPartial);
}
 
public <T> T createDelayedImplementation(Class<T> interfaceClass, final T fallbackObject) throws PluginExecutionException {
public <T> T createDelayedImplementation(final Class<T> interfaceClass,
final T fallbackObject)
throws PluginExecutionException {
if (null == fallbackObject) {
throw new IllegalArgumentException("Can't use a null fallback object");
}
return createDelayedImplementation(interfaceClass, fallbackObject, true);
}
private <T> T createDelayedImplementation(Class<T> c, T fallback, boolean allowPartial) throws PluginExecutionException {
 
private <T> T createDelayedImplementation(final Class<T> c,
final T fallback,
boolean allowPartial)
throws PluginExecutionException {
final StringBuilder hack = new StringBuilder();
 
final String var = uniqueFQVarName();
218,16 → 236,16
final String varImpl = uniqueVarName();
 
hack.append(var).append("={\n");
 
final StringBuilder script = new StringBuilder();
 
final String varFallback = uniqueVarName();
 
for (final Method m : c.getMethods()) {
if (m.getDeclaringClass() != c) {
continue;
}
 
final String implFuncName = c.getSimpleName()+"_"+m.getName();
if (allowPartial) {
Property changes:
Added: svn:keywords
+Rev Id Date
\ No newline at end of property