Subversion Repositories pub

Compare Revisions

No changes between revisions

Ignore whitespace Rev 56 → Rev 53

/pluggablejs/trunk/src/net/outlyer/plugins/Sandbox.java
24,8 → 24,6
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
 
// $Id$
 
/**
* Public methods provided by the sandbox.
* Note that all methods in this interface imply a call to {@link #execute}.
Property changes:
Deleted: svn:keywords
-Rev Id Date
\ No newline at end of property
/pluggablejs/trunk/src/net/outlyer/plugins/PluginExecutionException.java
24,8 → 24,6
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
 
// $Id$
 
/**
* PluginException produced when an execution failed.
*/
Property changes:
Deleted: svn:keywords
-Rev Id Date
\ No newline at end of property
/pluggablejs/trunk/src/net/outlyer/plugins/SandboxAccessorImpl.java
24,8 → 24,6
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
 
// $Id$
 
import java.util.concurrent.Callable;
 
/**
Property changes:
Deleted: svn:keywords
-Rev Id Date
\ No newline at end of property
/pluggablejs/trunk/src/net/outlyer/plugins/PluginEnvironmentImpl.java
24,8 → 24,6
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
 
// $Id$
 
import java.io.IOException;
import java.io.LineNumberReader;
import java.lang.reflect.Field;
61,10 → 59,8
private StringBuilder boilerPlate;
private List<String> acceptedTypes = null;
private int maxApi=API.REVISION;
// Since these lines are evaluated they'll be executed twice
// so the lower the number the better to reduce unexpected side effects
int linesToCheckForSupport = 1;
 
int linesToCheckForSupport = 5;
static final String EXPORTED_SANDBOX_VARIABLE = "$net.outlyer.runtime.sandbox";
{
Property changes:
Deleted: svn:keywords
-Rev Id Date
\ No newline at end of property
/pluggablejs/trunk/src/net/outlyer/plugins/Shell.java
24,8 → 24,6
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
 
// $Id$
 
import java.io.File;
import net.outlyer.plugins.utils.*;
 
47,11 → 45,9
pe.exportGlobalObject("err", new Output(System.err));
pe.exportGlobalObject("hooks", new Hooks());
// Generally either UI or GUI should be used but not both
// since GUI falls-back to UI if appropriate (so the ui object
// will use the "best" implementation)
pe.exportGlobalObject("ui", new GUI());
// since GUI falls-back to UI if appropriate
pe.exportGlobalObject("ui", new UI());
pe.exportGlobalObject("gui", new GUI());
pe.exportGlobalObject("cui", new UI()); // cui stands for Console UI
final PluginObject po = new PluginObject();
pe.setPluginObject(po);
Property changes:
Deleted: svn:keywords
-Rev Id Date
\ No newline at end of property
/pluggablejs/trunk/src/net/outlyer/plugins/API.java
24,8 → 24,6
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
 
// $Id$
 
/**
* API versioning
*/
Property changes:
Deleted: svn:keywords
-Rev Id Date
\ No newline at end of property
/pluggablejs/trunk/src/net/outlyer/plugins/SandboxProperties.java
23,9 → 23,6
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
 
// $Id$
 
import java.net.URI;
 
/**
Property changes:
Deleted: svn:keywords
-Rev Id Date
\ No newline at end of property
/pluggablejs/trunk/src/net/outlyer/plugins/PluginProperties.java
24,11 → 24,10
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
 
// $Id$
import net.outlyer.plugins.SandboxAccessorImpl;
 
/**
* Common properties of the plugin object. All of them
* take sane defaults.
*
*/
public class PluginProperties extends SandboxAccessorImpl {
public int apiVersion = 1;
Property changes:
Deleted: svn:keywords
-Rev Id Date
\ No newline at end of property
/pluggablejs/trunk/src/net/outlyer/plugins/PluginException.java
24,8 → 24,6
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
 
// $Id$
 
/**
* Base exception
*/
Property changes:
Deleted: svn:keywords
-Rev Id Date
\ No newline at end of property
/pluggablejs/trunk/src/net/outlyer/plugins/SandboxImpl.java
24,8 → 24,6
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
 
// $Id$
 
import net.outlyer.plugins.Sandbox;
import java.io.File;
import java.io.IOException;
178,56 → 176,40
execute(false, null, null);
}
 
public <T> T createDelayedImplementation(final Class<T> c,
final String objectName)
public <T> T createDelayedImplementation(Class<T> c, 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(final Class<T> c)
throws PluginExecutionException {
public <T> T createDelayedImplementation(Class<T> c) throws PluginExecutionException {
return createDelayedImplementation(c, false);
}
 
public <T> T createDelayedImplementation(final Class<T> c, boolean allowPartial)
throws PluginExecutionException {
public <T> T createDelayedImplementation(Class<T> c, boolean allowPartial) throws PluginExecutionException {
return createDelayedImplementation(c, null, allowPartial);
}
 
public <T> T createDelayedImplementation(final Class<T> interfaceClass,
final T fallbackObject)
throws PluginExecutionException {
public <T> T createDelayedImplementation(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(final Class<T> c,
final T fallback,
boolean allowPartial)
throws PluginExecutionException {
private <T> T createDelayedImplementation(Class<T> c, T fallback, boolean allowPartial) throws PluginExecutionException {
final StringBuilder hack = new StringBuilder();
 
final String var = uniqueFQVarName();
236,16 → 218,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:
Deleted: svn:keywords
-Rev Id Date
\ No newline at end of property
/pluggablejs/trunk/src/net/outlyer/plugins/BasePluginObject.java
24,8 → 24,6
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
 
// $Id$
 
/**
* Simplest object to be exported as "plugin"
* @see PluginObject
Property changes:
Deleted: svn:keywords
-Rev Id Date
\ No newline at end of property
/pluggablejs/trunk/src/net/outlyer/plugins/utils/Hooks.java
24,14 → 24,13
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
 
// $Id$
 
import net.outlyer.plugins.SandboxAccessorImpl;
 
/**
* Provides hooks to points in time during execution.
*
*/
public class Hooks extends SandboxAccessorImpl {
// Due to Rhino's magic passing a JS function() is enough
public void atexit(Runnable callback) {
getSandbox().addEndHook(callback);
Property changes:
Deleted: svn:keywords
-Rev Id Date
\ No newline at end of property
/pluggablejs/trunk/src/net/outlyer/plugins/utils/package-info.java
4,8 → 4,6
* {@see net.outlyer.plugins.sandboxing.PluginEnvironment#exportGlobalObject}.
*/
 
// $Id$
 
package net.outlyer.plugins.utils;
 
/*
Property changes:
Deleted: svn:keywords
-Rev Id Date
\ No newline at end of property
/pluggablejs/trunk/src/net/outlyer/plugins/utils/GUI.java
24,8 → 24,6
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
 
// $Id$
 
import java.awt.GraphicsEnvironment;
import java.io.File;
import javax.swing.JFileChooser;
Property changes:
Deleted: svn:keywords
-Rev Id Date
\ No newline at end of property
/pluggablejs/trunk/src/net/outlyer/plugins/utils/UI.java
24,8 → 24,6
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
 
// $Id$
 
import java.io.File;
 
/**
Property changes:
Deleted: svn:keywords
-Rev Id Date
\ No newline at end of property
/pluggablejs/trunk/src/net/outlyer/plugins/utils/Input.java
24,8 → 24,6
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
 
// $Id$
 
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
32,7 → 30,7
import java.io.InputStreamReader;
 
/**
* Provides a simplified wrapper for input.
*
*/
public class Input {
 
Property changes:
Deleted: svn:keywords
-Rev Id Date
\ No newline at end of property
/pluggablejs/trunk/src/net/outlyer/plugins/utils/Output.java
24,12 → 24,10
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
 
// $Id$
 
import java.io.PrintStream;
 
/**
* Provides a simplified wrapper for output.
* Provides a simplified wrapper for output
*/
public class Output {
 
43,10 → 41,6
this.ps = ps;
}
public void println() {
ps.println();
}
public void println(final String s) {
ps.println(s);
}
Property changes:
Deleted: svn:keywords
-Rev Id Date
\ No newline at end of property
/pluggablejs/trunk/src/net/outlyer/plugins/PluginReader.java
24,8 → 24,6
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
 
// $Id$
 
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
Property changes:
Deleted: svn:keywords
-Rev Id Date
\ No newline at end of property
/pluggablejs/trunk/src/net/outlyer/plugins/SandboxAccessor.java
24,8 → 24,6
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
 
// $Id$
 
/**
* Optional interface for exported objects (see
* {@link net.outlyer.plugins.sandboxing.PluginEnvironment#exportGlobalObject}),
Property changes:
Deleted: svn:keywords
-Rev Id Date
\ No newline at end of property
/pluggablejs/trunk/src/net/outlyer/plugins/PluginLocator.java
24,8 → 24,6
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
 
// $Id$
 
import java.io.File;
import java.io.FileFilter;
import java.io.IOException;
Property changes:
Deleted: svn:keywords
-Rev Id Date
\ No newline at end of property
/pluggablejs/trunk/src/net/outlyer/plugins/PluginEnvironment.java
24,8 → 24,6
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
 
// $Id$
 
import java.net.URI;
 
/**
Property changes:
Deleted: svn:keywords
-Rev Id Date
\ No newline at end of property
/pluggablejs/trunk/src/net/outlyer/plugins/PluginObject.java
24,8 → 24,6
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
 
// $Id$
 
import java.util.LinkedList;
import java.util.List;
 
Property changes:
Deleted: svn:keywords
-Rev Id Date
\ No newline at end of property
/pluggablejs/trunk/src/net/outlyer/plugins/RuntimeHooks.java
24,8 → 24,6
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
 
// $Id$
 
/**
* Provides hooks to the execution
*/
Property changes:
Deleted: svn:keywords
-Rev Id Date
\ No newline at end of property