gscript r12 - trunk



Author: alexl
Date: Tue Sep 16 18:52:46 2008
New Revision: 12
URL: http://svn.gnome.org/viewvc/gscript?rev=12&view=rev

Log:
2008-09-16  Alexander Larsson  <alexl redhat com>

        * gtk.js:
	Allow return vals from AsyncRunner.call().




Modified:
   trunk/ChangeLog
   trunk/gtk.js

Modified: trunk/gtk.js
==============================================================================
--- trunk/gtk.js	(original)
+++ trunk/gtk.js	Tue Sep 16 18:52:46 2008
@@ -63,21 +63,24 @@
 	    ret = f.finish (res);
 	    f = gen.send(ret);
 	} catch (e if e instanceof StopIteration) {
-	    f = null;
+	    f = undefined;
 	} catch (e) {
 	    f = gen.throw(e);
 	}
-	if (f)
+	if (f != null && f instanceof Function && "finish" in f)
 	    f (async_cb);
 	else if (cb)
-	    cb ();
+	    cb (f);
     }
     let extra_args = [];
     for (let i = 1; i < arguments.length; i++)
 	extra_args[i-1] = arguments[i];
     let gen = this.fn.apply (this, extra_args);
     let f = gen.next();
-    f (async_cb);
+    if (f != null && f instanceof Function && "finish" in f)
+	f (async_cb);
+    else
+	cb(f);
 }
 
 /* Lets you call other async generators from an async generator */
@@ -97,14 +100,14 @@
 	args.push(arguments[i]);
     
     let f = function (cb) {
-	function wrap_cb () {
-	    cb (null, null);
+	function wrap_cb (res) {
+	    cb (null, res);
 	}
 	args[0] = wrap_cb;
 	runner.start.apply (runner, args);
     }
     f.finish = function (res) {
-	return undefined;
+	return res;
     }
     return f;
 }
@@ -122,6 +125,7 @@
 	var data3 = yield $open (filename, 0);
 	print ("data3 = " + data3);
 	print ("end of do_stuff2");
+	yield "the end (of do_stuff2)"
     });
 
 do_stuff = new AsyncRunner (function  (filename1, filename2) {



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]