Permalink
Browse files

must add __repr__ for simple types

  • Loading branch information...
1 parent ff004cb commit 2076ca494c90ff3411525f2959e53b76d6118886 @jdf committed Jul 20, 2010
Showing with 27 additions and 1 deletion.
  1. +1 −1 .classpath
  2. +2 −0 .gitignore
  3. +7 −0 kinetictype.py
  4. +17 −0 src/jycessing/PAppletJythonDriver.java
View
2 .classpath
@@ -3,6 +3,6 @@
<classpathentry kind="src" path="src"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry combineaccessrules="false" kind="src" path="/processing-core"/>
- <classpathentry kind="lib" path="C:/jython2.5.2b1core/jython.jar"/>
+ <classpathentry kind="lib" path="C:/jython2.5.2b1core/jython.jar" sourcepath="C:/jython2.5.2b1src/src"/>
<classpathentry kind="output" path="bin"/>
</classpath>
View
2 .gitignore
@@ -4,3 +4,5 @@ src.zip
python-hack.jar
kinetic-type/
jython.jar
+jython_processing_demo
+
View
7 kinetictype.py
@@ -16,8 +16,14 @@ def setup():
size(640, 360, P3D)
textFont(loadFont("Univers-66.vlw"), 1.0)
fill(255)
+ frameRate(1000)
def draw():
+ if millis() % 100 == 0:
+ print frameRate
+ pass
+
+"""
background(0)
pushMatrix()
translate(-200, -50, -450)
@@ -42,3 +48,4 @@ def draw():
popMatrix()
scale(20)
text("%d fps"%int(frameRate), .5, 1)
+"""
View
17 src/jycessing/PAppletJythonDriver.java
@@ -127,6 +127,18 @@ public PyObject __call__() {
return new PyInteger(millis());
}
});
+
+ locals.__setitem__("frameCount", new PyObject() {
+ @Override
+ public PyObject __int__() {
+ return new PyInteger(frameCount);
+ }
+
+ @Override
+ public PyString __repr__() {
+ return new PyString(String.valueOf(frameCount));
+ }
+ });
locals.__setitem__("frameRate", new PyObject() {
@Override
public PyFloat __float__() {
@@ -142,6 +154,11 @@ public PyObject __call__(final PyObject newRateTarget) {
public PyObject __int__() {
return new PyInteger((int)frameRate);
}
+
+ @Override
+ public PyString __repr__() {
+ return new PyString(String.valueOf(frameRate));
+ }
});
locals.__setitem__("pushMatrix", new PyObject() {

0 comments on commit 2076ca4

Please sign in to comment.