[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[ff-cvs] fenfire/org/fenfire animation.test functional/F...
From: |
Tuomas J. Lukka |
Subject: |
[ff-cvs] fenfire/org/fenfire animation.test functional/F... |
Date: |
Fri, 31 Oct 2003 11:59:42 -0500 |
CVSROOT: /cvsroot/fenfire
Module name: fenfire
Branch:
Changes by: Tuomas J. Lukka <address@hidden> 03/10/31 11:59:41
Modified files:
org/fenfire : animation.test
org/fenfire/functional: FunctionCacheEntry.java
FunctionalTest.java
SuperFunctional1.java functionaltest.py
superfunctional1.test
org/fenfire/view/buoy: AbstractMainNode2D.java
Removed files:
org/fenfire/functional: SuperLazyBase.java
SuperLazyPureFunction.java
SuperLazyPureNodeFunction.java
superlazy.test
Log message:
sync
CVSWeb URLs:
http://savannah.gnu.org/cgi-bin/viewcvs/fenfire/fenfire/org/fenfire/animation.test.diff?tr1=1.2&tr2=1.3&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/fenfire/fenfire/org/fenfire/functional/FunctionCacheEntry.java.diff?tr1=1.3&tr2=1.4&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/fenfire/fenfire/org/fenfire/functional/FunctionalTest.java.diff?tr1=1.4&tr2=1.5&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/fenfire/fenfire/org/fenfire/functional/SuperFunctional1.java.diff?tr1=1.4&tr2=1.5&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/fenfire/fenfire/org/fenfire/functional/functionaltest.py.diff?tr1=1.3&tr2=1.4&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/fenfire/fenfire/org/fenfire/functional/superfunctional1.test.diff?tr1=1.3&tr2=1.4&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/fenfire/fenfire/org/fenfire/view/buoy/AbstractMainNode2D.java.diff?tr1=1.51&tr2=1.52&r1=text&r2=text
Patches:
Index: fenfire/org/fenfire/animation.test
diff -u fenfire/org/fenfire/animation.test:1.2
fenfire/org/fenfire/animation.test:1.3
--- fenfire/org/fenfire/animation.test:1.2 Sat Oct 18 02:06:29 2003
+++ fenfire/org/fenfire/animation.test Fri Oct 31 11:59:40 2003
@@ -31,6 +31,8 @@
special method call 'AbstractUpdateManager.chg()'
which should be done trough
the api which is added in near future.
+
+ fail: *
"""
str = 'grep -sr AbstractUpdateManager\.chg org/ | grep -v \{arch\} >
animation.test.log'
Index: fenfire/org/fenfire/functional/FunctionCacheEntry.java
diff -u fenfire/org/fenfire/functional/FunctionCacheEntry.java:1.3
fenfire/org/fenfire/functional/FunctionCacheEntry.java:1.4
--- fenfire/org/fenfire/functional/FunctionCacheEntry.java:1.3 Sat Oct 18
02:06:30 2003
+++ fenfire/org/fenfire/functional/FunctionCacheEntry.java Fri Oct 31
11:59:41 2003
@@ -40,7 +40,15 @@
*/
public class FunctionCacheEntry implements Obs {
+ /** The object to represent that this cache entry is dirty,
+ * and needs to be recalculated.
+ */
static final public Object DIRTY = new Object();
+ /** The object to represent that calculating this cache entry
+ * yielded an error and thus we don't have a value
+ * but recalculation is not possible either.
+ */
+ static final public Object ERROR = new Object();
/** The input this cache entry is for.
* Stored here so that it may be used as the hash key.
Index: fenfire/org/fenfire/functional/FunctionalTest.java
diff -u fenfire/org/fenfire/functional/FunctionalTest.java:1.4
fenfire/org/fenfire/functional/FunctionalTest.java:1.5
--- fenfire/org/fenfire/functional/FunctionalTest.java:1.4 Sat Oct 18
02:06:30 2003
+++ fenfire/org/fenfire/functional/FunctionalTest.java Fri Oct 31 11:59:41 2003
@@ -39,6 +39,7 @@
public class FunctionalTest {
public static boolean dbg = true;
private static void p(String s) { System.out.println(s); }
+
/** A function that appends its constructor parameter to
* its parameter.
*/
@@ -54,6 +55,31 @@
counter++;
if(dbg) p("G0.f - "+this.param+": "+o);
return ((String)o) + this.param;
+ }
+ }
+
+ /** A function that has both superlazy and error placeholders,
+ * and is otherwise like G0 except that it throws an error
+ * if the input is "E".
+ * The placeholder is the string "FOO" and the error placeholder is the
+ * string "ERROR".
+ */
+ static public class G0PlaceHolderError extends G0 {
+ static public Functional.Hints functionalHints =
+ (new Functional.HintsMaker())
+ .setHint(Functional.HINT_PLACEHOLDER, "FOO")
+ .setHint(Functional.HINT_ERRORPLACEHOLDER, "ERROR")
+ .make();
+
+ public G0PlaceHolderError(String param) {
+ super(param);
+ }
+
+ public Object f(Object o) {
+ Object r = super.f(o); // Increment counter
+ if("E".equals(o))
+ throw new Error("The error");
+ return r;
}
}
Index: fenfire/org/fenfire/functional/SuperFunctional1.java
diff -u fenfire/org/fenfire/functional/SuperFunctional1.java:1.4
fenfire/org/fenfire/functional/SuperFunctional1.java:1.5
--- fenfire/org/fenfire/functional/SuperFunctional1.java:1.4 Sat Oct 18
02:06:30 2003
+++ fenfire/org/fenfire/functional/SuperFunctional1.java Fri Oct 31
11:59:41 2003
@@ -157,11 +157,13 @@
protected class CachedFunctionInstance implements FunctionInstance {
private final PureFunction realFunction;
private final PureNodeFunction realNodeFunction;
+
+ private final Object placeHolder;
+ private final Object errorPlaceHolder;
private class WrapperFunction implements Function, NodeFunction {
private CachingMap cache;
CacheInfo cacheInfo;
- Object placeHolder;
public WrapperFunction(CacheInfo cacheInfo) {
this.cacheInfo = cacheInfo;
cache = new CachingMap(cacheInfo.n);
@@ -211,13 +213,20 @@
if(tickers != null) tickers = null;
int startticks = ntickers_upwards;
- if(realFunction != null) {
- this.value = realFunction.f(input);
- } else {
- ConstGraph graph = constGraph.getObservedConstGraph(
- this);
- this.value = realNodeFunction.f(graph, input);
- graph.close();
+ try {
+ if(realFunction != null) {
+ this.value = realFunction.f(input);
+ } else {
+ ConstGraph graph = constGraph.getObservedConstGraph(
+ this);
+ this.value = realNodeFunction.f(graph, input);
+ graph.close();
+ }
+ } catch(Throwable t) {
+ p("ERROR WHILE EVALUATING FUNCTION "+realNodeFunction
+ +" "+realFunction+":" + t);
+ t.printStackTrace();
+ this.value = ERROR;
}
if(dbg) p("Entry: called: "+this.input+" -> "+this.value);
@@ -241,6 +250,8 @@
// happen.
throw new Error("getvalue closed entry");
}
+ if(value == ERROR)
+ return errorPlaceHolder;
// Recalculate
if(value == DIRTY) {
if(dbg) p("Entry: getValue: recalc");
@@ -341,6 +352,27 @@
realNodeFunction = realNode;
wrapper = new WrapperFunction(cacheInfo);
wrapperWrapper = new WrapperWrapper();
+
+ DefaultHints h;
+ try {
+ java.lang.reflect.Field field ;
+ if(realFunction != null)
+ field = realFunction.getClass().getField("functionalHints");
+ else
+ field =
realNodeFunction.getClass().getField("functionalHints");
+ h = (DefaultHints)field.get(null);
+ } catch(NoSuchFieldException e) {
+ h = null;
+ } catch(IllegalAccessException e) {
+ throw new Error("Invalid field!");
+ }
+ if(h == null) {
+ this.placeHolder = null;
+ this.errorPlaceHolder = null;
+ } else {
+ this.placeHolder = h.hints.get(Functional.HINT_PLACEHOLDER);
+ this.errorPlaceHolder =
h.hints.get(Functional.HINT_ERRORPLACEHOLDER);
+ }
}
public Function getCallableFunction() {
return wrapperWrapper;
Index: fenfire/org/fenfire/functional/functionaltest.py
diff -u fenfire/org/fenfire/functional/functionaltest.py:1.3
fenfire/org/fenfire/functional/functionaltest.py:1.4
--- fenfire/org/fenfire/functional/functionaltest.py:1.3 Sat Oct 18
02:06:30 2003
+++ fenfire/org/fenfire/functional/functionaltest.py Fri Oct 31 11:59:41 2003
@@ -45,6 +45,17 @@
["YYY", node0])
return node1
+def createFunc1_error_ph(functional):
+ node0 = functional.createFunctionInstance(
+ "A",
+ FunctionalTest.G0PlaceHolderError,
+ ["XXX"])
+ node1 = functional.createFunctionInstance(
+ "B",
+ FunctionalTest.G1,
+ ["YYY", node0])
+ return node1
+
def createFunc1_Node(functional):
node0 = functional.createFunctionInstance(
"C",
Index: fenfire/org/fenfire/functional/superfunctional1.test
diff -u fenfire/org/fenfire/functional/superfunctional1.test:1.3
fenfire/org/fenfire/functional/superfunctional1.test:1.4
--- fenfire/org/fenfire/functional/superfunctional1.test:1.3 Sat Oct 18
02:06:30 2003
+++ fenfire/org/fenfire/functional/superfunctional1.test Fri Oct 31
11:59:41 2003
@@ -95,6 +95,40 @@
assert FunctionalTest.G1.counter == 10, FunctionalTest.G1.counter
+def testSuperlazy1_placeholder_error():
+ background = vob.util.ExplicitBackground()
+ functional = ff.functional.SuperFunctional1(None, background)
+
+ functional.cache("A", 100, 1)
+
+ node1 = createFunc1_error_ph(functional)
+ f = node1.getCallableFunction()
+ FunctionalTest.G0.counter = 0
+ FunctionalTest.G1.counter = 0
+
+ failUnlessEqual( f.f("A") , "FOOYYY")
+ failUnlessEqual( f.f("B") , "FOOYYY")
+ failUnlessEqual( f.f("A") , "FOOYYY")
+ failUnlessEqual( f.f("E") , "FOOYYY")
+ failUnlessEqual( f.f("B") , "FOOYYY")
+
+ assert FunctionalTest.G0.counter == 0, FunctionalTest.G0.counter
+ assert FunctionalTest.G1.counter == 5, FunctionalTest.G1.counter
+
+ for i in range(0, 5): background.performOneTask()
+
+ failUnlessEqual( f.f("A") , "AXXXYYY")
+ failUnlessEqual( f.f("B") , "BXXXYYY")
+ failUnlessEqual( f.f("A") , "AXXXYYY")
+ failUnlessEqual( f.f("E") , "ERRORYYY")
+ failUnlessEqual( f.f("B") , "BXXXYYY")
+ failUnlessEqual( f.f("E") , "ERRORYYY")
+ failUnlessEqual( f.f("E") , "ERRORYYY")
+
+ assert FunctionalTest.G0.counter == 3, FunctionalTest.G0.counter
+ assert FunctionalTest.G1.counter == 12, FunctionalTest.G1.counter
+
+
def testSuperlazy1_lowercache():
background = vob.util.ExplicitBackground()
functional = ff.functional.SuperFunctional1(None, background)
Index: fenfire/org/fenfire/view/buoy/AbstractMainNode2D.java
diff -u fenfire/org/fenfire/view/buoy/AbstractMainNode2D.java:1.51
fenfire/org/fenfire/view/buoy/AbstractMainNode2D.java:1.52
--- fenfire/org/fenfire/view/buoy/AbstractMainNode2D.java:1.51 Thu Oct 23
15:09:58 2003
+++ fenfire/org/fenfire/view/buoy/AbstractMainNode2D.java Fri Oct 31
11:59:41 2003
@@ -224,7 +224,6 @@
focus.setPan(pt[0], pt[1]);
clipPan();
- //AbstractUpdateManager.chg();
}
@@ -301,6 +300,7 @@
public Object getNodeOnPlane(VobScene oldVobScene, float x, float y) {
// XXX refactor me!
+ // I should be in CanvasView2D
int cs = getNodeCS(oldVobScene, x, y);
if(cs <= 1) return null;
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [ff-cvs] fenfire/org/fenfire animation.test functional/F...,
Tuomas J. Lukka <=