Permalink
Browse files

merge

  • Loading branch information...
jdf committed Sep 15, 2010
2 parents 806bf64 + 15a754a commit 3f2da8afcfcbf75cf390c92946bc9e7daccebed3
Binary file not shown.
@@ -15,13 +15,23 @@
*/
package jycessing;
+import org.python.core.Py;
+import org.python.core.PyString;
+import org.python.util.InteractiveConsole;
+import org.python.util.PythonInterpreter;
+
+import processing.core.PApplet;
+
import java.io.BufferedReader;
import java.io.File;
import java.io.FileFilter;
import java.io.FileReader;
import java.io.FilenameFilter;
import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
import java.io.Reader;
+import java.io.UnsupportedEncodingException;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.net.URL;
@@ -30,13 +40,6 @@
import java.util.regex.Matcher;
import java.util.regex.Pattern;
-import org.python.core.Py;
-import org.python.core.PyString;
-import org.python.util.InteractiveConsole;
-import org.python.util.PythonInterpreter;
-
-import processing.core.PApplet;
-
public class Runner {
static boolean VERBOSE = false;
@@ -55,6 +58,10 @@ private static String read(final Reader r) throws IOException {
}
}
+ private static String read(final InputStream in) throws IOException {
+ return read(new InputStreamReader(in, "UTF-8"));
+ }
+
/**
* Add a URL (referring to a jar file or class directory) to the current
* classloader. Of course, this is a filthy hack, which depends on an
@@ -245,6 +252,7 @@ public static void runSketch(final String[] args, final String sketchPath,
// For error messages
interp.getLocals().__setitem__("__file__", new PyString(sketchPath));
+ interp.exec(read(Runner.class.getResourceAsStream("core.py")));
// Bind the sketch to a PApplet
final PAppletJythonDriver applet = new DriverImpl(
interp, sketchPath, sketchSource);
@@ -1,2 +1,2 @@
-#Sun Sep 12 10:52:49 EDT 2010
-buildnumber=0012
+#Tue Sep 14 16:34:57 EDT 2010
+buildnumber=0013
@@ -0,0 +1,30 @@
+from processing.core import PApplet
+from processing.core import PConstants
+from processing.core import PFont
+from processing.core import PGraphics
+from processing.core import PGraphics2D
+from processing.core import PGraphics3D
+from processing.core import PGraphicsJava2D
+from processing.core import PImage
+from processing.core import PLine
+from processing.core import PMatrix
+from processing.core import PMatrix2D
+from processing.core import PMatrix3D
+from processing.core import PPolygon
+from processing.core import PShape
+from processing.core import PShapeSVG
+from processing.core import PSmoothTriangle
+from processing.core import PStyle
+from processing.core import PTriangle
+from processing.core import PVector
+from processing.core import PVector
+
+def monkeypatch_method(cls):
+ def decorator(func):
+ setattr(cls, func.__name__, func)
+ return func
+ return decorator
+
+@monkeypatch_method(PVector)
+def __deepcopy__(self, memo):
+ return PVector(self.x, self.y, self.z)
@@ -7,8 +7,7 @@
def setup():
size(10, 10, P3D)
- print "OK"
noLoop();
def draw():
- pass
+ print "OK"
@@ -0,0 +1,2 @@
+print PVector(1, 2, 3)
+print PFont
@@ -19,6 +19,7 @@ private static String run(final String testResource) throws Exception {
System.setOut(new PrintStream(baos, true));
Runner.main(new String[] { "testing/test_resources/test_"
+ testResource + ".py" });
+ Thread.sleep(500);
return new String(baos.toByteArray()).replaceAll("\r\n", "\n")
.replaceAll("\r", "\n");
} finally {
@@ -94,6 +95,11 @@ public void calendar() throws Exception {
testImport("calendar");
}
+ @Test
+ public void processing_core() throws Exception {
+ assertEquals("[ 1.0, 2.0, 3.0 ]\n<type 'processing.core.PFont'>\n", run("pcore"));
+ }
+
public static void main(final String[] args) {
JUnitCore.runClasses(JycessingTests.class);
}

0 comments on commit 3f2da8a

Please sign in to comment.