Subversion Repositories pub

Compare Revisions

No changes between revisions

Ignore whitespace Rev 53 → Rev 56

/pluggablejs/trunk/src/net/outlyer/plugins/PluginLocator.java
24,6 → 24,8
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
 
// $Id$
 
import java.io.File;
import java.io.FileFilter;
import java.io.IOException;
Property changes:
Added: svn:keywords
+Rev Id Date
\ No newline at end of property
/pluggablejs/trunk/src/net/outlyer/plugins/PluginEnvironment.java
24,6 → 24,8
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
 
// $Id$
 
import java.net.URI;
 
/**
Property changes:
Added: svn:keywords
+Rev Id Date
\ No newline at end of property
/pluggablejs/trunk/src/net/outlyer/plugins/PluginObject.java
24,6 → 24,8
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
 
// $Id$
 
import java.util.LinkedList;
import java.util.List;
 
Property changes:
Added: svn:keywords
+Rev Id Date
\ No newline at end of property
/pluggablejs/trunk/src/net/outlyer/plugins/RuntimeHooks.java
24,6 → 24,8
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
 
// $Id$
 
/**
* Provides hooks to the execution
*/
Property changes:
Added: svn:keywords
+Rev Id Date
\ No newline at end of property
/pluggablejs/trunk/src/net/outlyer/plugins/Sandbox.java
24,6 → 24,8
* 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:
Added: svn:keywords
+Rev Id Date
\ No newline at end of property
/pluggablejs/trunk/src/net/outlyer/plugins/PluginExecutionException.java
24,6 → 24,8
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
 
// $Id$
 
/**
* PluginException produced when an execution failed.
*/
Property changes:
Added: svn:keywords
+Rev Id Date
\ No newline at end of property
/pluggablejs/trunk/src/net/outlyer/plugins/SandboxAccessorImpl.java
24,6 → 24,8
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
 
// $Id$
 
import java.util.concurrent.Callable;
 
/**
Property changes:
Added: svn:keywords
+Rev Id Date
\ No newline at end of property
/pluggablejs/trunk/src/net/outlyer/plugins/PluginEnvironmentImpl.java
24,6 → 24,8
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
 
// $Id$
 
import java.io.IOException;
import java.io.LineNumberReader;
import java.lang.reflect.Field;
59,8 → 61,10
private StringBuilder boilerPlate;
private List<String> acceptedTypes = null;
private int maxApi=API.REVISION;
int linesToCheckForSupport = 5;
// 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;
 
static final String EXPORTED_SANDBOX_VARIABLE = "$net.outlyer.runtime.sandbox";
{
Property changes:
Added: svn:keywords
+Rev Id Date
\ No newline at end of property
/pluggablejs/trunk/src/net/outlyer/plugins/Shell.java
24,6 → 24,8
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
 
// $Id$
 
import java.io.File;
import net.outlyer.plugins.utils.*;
 
45,9 → 47,11
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
pe.exportGlobalObject("ui", new UI());
// since GUI falls-back to UI if appropriate (so the ui object
// will use the "best" implementation)
pe.exportGlobalObject("ui", new GUI());
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:
Added: svn:keywords
+Rev Id Date
\ No newline at end of property
/pluggablejs/trunk/src/net/outlyer/plugins/API.java
24,6 → 24,8
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
 
// $Id$
 
/**
* API versioning
*/
Property changes:
Added: svn:keywords
+Rev Id Date
\ No newline at end of property
/pluggablejs/trunk/src/net/outlyer/plugins/PluginProperties.java
24,10 → 24,11
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
 
import net.outlyer.plugins.SandboxAccessorImpl;
// $Id$
 
/**
*
* Common properties of the plugin object. All of them
* take sane defaults.
*/
public class PluginProperties extends SandboxAccessorImpl {
public int apiVersion = 1;
Property changes:
Added: svn:keywords
+Rev Id Date
\ No newline at end of property
/pluggablejs/trunk/src/net/outlyer/plugins/SandboxProperties.java
23,6 → 23,9
* 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:
Added: svn:keywords
+Rev Id Date
\ No newline at end of property
/pluggablejs/trunk/src/net/outlyer/plugins/PluginException.java
24,6 → 24,8
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
 
// $Id$
 
/**
* Base exception
*/
Property changes:
Added: svn:keywords
+Rev Id Date
\ No newline at end of property
/pluggablejs/trunk/src/net/outlyer/plugins/utils/Hooks.java
24,13 → 24,14
* 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:
Added: svn:keywords
+Rev Id Date
\ No newline at end of property
/pluggablejs/trunk/src/net/outlyer/plugins/utils/GUI.java
24,6 → 24,8
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
 
// $Id$
 
import java.awt.GraphicsEnvironment;
import java.io.File;
import javax.swing.JFileChooser;
Property changes:
Added: svn:keywords
+Rev Id Date
\ No newline at end of property
/pluggablejs/trunk/src/net/outlyer/plugins/utils/package-info.java
4,6 → 4,8
* {@see net.outlyer.plugins.sandboxing.PluginEnvironment#exportGlobalObject}.
*/
 
// $Id$
 
package net.outlyer.plugins.utils;
 
/*
Property changes:
Added: svn:keywords
+Rev Id Date
\ No newline at end of property
/pluggablejs/trunk/src/net/outlyer/plugins/utils/UI.java
24,6 → 24,8
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
 
// $Id$
 
import java.io.File;
 
/**
Property changes:
Added: svn:keywords
+Rev Id Date
\ No newline at end of property
/pluggablejs/trunk/src/net/outlyer/plugins/utils/Input.java
24,6 → 24,8
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
 
// $Id$
 
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
30,7 → 32,7
import java.io.InputStreamReader;
 
/**
*
* Provides a simplified wrapper for input.
*/
public class Input {
 
Property changes:
Added: svn:keywords
+Rev Id Date
\ No newline at end of property
/pluggablejs/trunk/src/net/outlyer/plugins/utils/Output.java
24,10 → 24,12
* 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 {
 
41,6 → 43,10
this.ps = ps;
}
public void println() {
ps.println();
}
public void println(final String s) {
ps.println(s);
}
Property changes:
Added: svn:keywords
+Rev Id Date
\ No newline at end of property
/pluggablejs/trunk/src/net/outlyer/plugins/BasePluginObject.java
24,6 → 24,8
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
 
// $Id$
 
/**
* Simplest object to be exported as "plugin"
* @see PluginObject
Property changes:
Added: svn:keywords
+Rev Id Date
\ No newline at end of property
/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
/pluggablejs/trunk/src/net/outlyer/plugins/PluginReader.java
24,6 → 24,8
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
 
// $Id$
 
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
Property changes:
Added: svn:keywords
+Rev Id Date
\ No newline at end of property
/pluggablejs/trunk/src/net/outlyer/plugins/SandboxAccessor.java
24,6 → 24,8
* 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:
Added: svn:keywords
+Rev Id Date
\ No newline at end of property