/pluggablejs/trunk/Makefile |
---|
3,6 → 3,8 |
DESTDIR:= |
JAR=dist/pluggablejs.jar |
bindir=$(DESTDIR)/$(prefix)/bin |
all: |
ant compile.downstream |
13,8 → 15,11 |
ant clean |
install: $(JAR) |
mkdir -p $(DESTDIR)/$(prefix)/share/java |
mkdir -p $(DESTDIR)/$(prefix)/share/java $(bindir)/ |
install -m644 -o0 -g0 $(JAR) $(DESTDIR)/$(prefix)/share/java/ |
cat pjsh.sh | sed 's\^prefix=.*$$\prefix=$(prefix)\g' > $(bindir)/pjsh |
chmod 755 $(bindir)/pjsh |
-chown root.root $(bindir)/pjsh |
uninstall: |
$(RM) $(DESTDIR)/$(prefix)/share/java/`basename "$(JAR)"` |
/pluggablejs/trunk/build.num |
---|
1,3 → 1,3 |
#Build Number for ANT. Do not edit! |
#Fri Jun 27 19:25:41 CEST 2008 |
build.number=27 |
#Fri Jun 27 22:16:02 CEST 2008 |
build.number=28 |
/pluggablejs/trunk/pjsh.sh |
---|
0,0 → 1,6 |
#!/bin/sh |
prefix=/usr/local |
JAR="$prefix/pluggablejs.jar" |
java -cp "$JAR" net.outlyer.plugins.Shell $@ |
Property changes: |
Added: svn:keywords |
+Rev Id Date |
\ No newline at end of property |
/pluggablejs/trunk/debian/changelog |
---|
1,11 → 1,6 |
pluggablejs (0.0build27-upstream.0) experimental; urgency=low |
pluggablejs (0.0build28-upstream.0) experimental; urgency=low |
* Repackaging |
* Initial public release. |
-- Toni Corvera <outlyer@gmail.com> Fri, 27 Jun 2008 19:25:49 +0200 |
-- Toni Corvera <outlyer@gmail.com> Sun, 29 Jun 2008 02:00:42 +0200 |
pluggablejs (0.0build14-upstream.0) experimental; urgency=low |
* Initial package. |
-- Toni Corvera <outlyer@gmail.com> Thu, 26 Jun 2008 03:08:21 +0200 |
/pluggablejs/trunk/samples/zeroer.js |
---|
0,0 → 1,63 |
// This file is put in the public domain |
// |
// $Id$ |
var FILE_SIZE_LIMIT = -1; |
var BUFFER_SIZE = 1024 * 1024; |
var DEFAULT_FILE_NAME = "zeroes"; |
java.lang.System.err.println("Disk Zero Filler v0.2"); |
var DiskZeroFiller = { |
zero: null, |
wipe: null, |
commonFill: null |
}; |
DiskZeroFiller.commonFill = function(filename, buffer) { |
// try |
var fos = new java.io.FileOutputStream(filename, false); |
java.lang.System.err.println(); |
var written = 0; |
var ignore = BUFFER_SIZE * 3; |
var reference = new java.io.File("."); |
var free; |
while (ignore < (free = reference.getUsableSpace())) { |
// Must use this form to not be ambiguous |
fos.write(buffer.array(), 0, buffer.array().length); |
written += buffer.array().length; |
java.lang.System.err.printf("\r%d w %d f // %.2fMiB w %.2fMiB", |
new Array( |
new java.lang.Long(written), new java.lang.Long(free), |
written / 1024.0 / 1024.0, |
free / 1024.0 / 1024.0 |
) |
); |
} |
java.lang.System.err.println(); |
fos.close(); |
}; |
DiskZeroFiller.zero = function(filename) { |
var buffer = java.nio.ByteBuffer.allocate(BUFFER_SIZE); |
java.util.Arrays.fill(buffer.array(), new java.lang.Byte(0)); |
this.commonFill(filename, buffer); |
}; |
DiskZeroFiller.wipe = function(filename) { |
var buffer = java.nio.ByteBuffer.allocate(BUFFER_SIZE); |
java.util.Arrays.fill(buffer.array(), new java.lang.Byte(0)); |
for (var i=0; i<BUFFER_SIZE; i+=2) { |
buffer.array()[i] = new java.lang.Byte(127); |
} |
this.commonFill(filename, buffer); |
}; |
DiskZeroFiller.zero("zeroes"); |
//DiskZeroFiller.wipe("wipe"); |
// vim:set ts=4 et ai: // |
Property changes: |
Added: svn:executable |
+* |
\ No newline at end of property |
Added: svn:keywords |
+Rev Id Date |
\ No newline at end of property |
/pluggablejs/trunk/samples/RhinoRun.java |
---|
0,0 → 1,54 |
// This file is put in the Public Domain, originally published |
// at <http://p.outlyer.net./javacode/> |
// $Id$ |
import java.io.BufferedReader; |
import java.io.File; |
import java.io.FileNotFoundException; |
import java.io.FileReader; |
import javax.script.ScriptEngine; |
import javax.script.ScriptEngineManager; |
import javax.script.ScriptException; |
/** |
* This is a wrapper around the rhino script engine, it will load a file |
* and try to eval() its contents. |
* |
* Usage: RhinoRun [inputfile.js] [inputfile2.js] |
*/ |
public class RhinoRun { |
public static void main(String...args) { |
if (args.length == 0) { |
System.err.printf("Usage: java [...] %s [file1.js [file2.js [...]]]\n", |
RhinoRun.class.getName()); |
System.exit(1); |
} |
final ScriptEngine rhino = new ScriptEngineManager().getEngineByName("rhino"); |
for (final String path : args) { |
try { |
final File file = new File(path); |
if (!file.isFile() || !file.canRead()) { |
throw new FileNotFoundException("Failed to access " + path); |
} |
rhino.eval(new BufferedReader(new FileReader(file))); |
} |
catch (final FileNotFoundException e) { |
System.err.println("Error: " + e.getMessage()); |
if (System.getProperty("debug", "0").equals("1")) { |
e.printStackTrace(System.err); |
} |
} |
catch (final ScriptException e) { |
System.err.println("Error: " + e.getMessage()); |
if (System.getProperty("debug", "0").equals("1")) { |
e.printStackTrace(System.err); |
} |
} |
} |
} |
} |
// vim:set ts=4 et ai: // |
Property changes: |
Added: svn:keywords |
+Rev Id Date |
\ No newline at end of property |
/pluggablejs/trunk/pjsh.cmd |
---|
0,0 → 1,11 |
@echo off |
REM $Id$ |
setlocal |
set prefix=. |
set JAR=%prefix%\pluggablejs.jar |
java -cp "%JAR%" net.outlyer.plugins.Shell %* |
endlocal |
Property changes: |
Added: svn:keywords |
+Rev Id Date |
\ No newline at end of property |
/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 |
/pluggablejs/trunk/. |
---|
Property changes: |
Modified: svn:mergeinfo |
Merged /pluggablejs/branches/1.0build28:r55 |