gscript r11 - trunk



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

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

        * gtk.js:
	verify that AsyncRunner.call() caller is an
	AsyncRunner.



Modified:
   trunk/ChangeLog
   trunk/gtk.js

Modified: trunk/gtk.js
==============================================================================
--- trunk/gtk.js	(original)
+++ trunk/gtk.js	Tue Sep 16 18:36:48 2008
@@ -23,6 +23,7 @@
 
 function AsyncRunner(_fn) {
     this.fn = _fn;
+    this.fn.__asyncrunner = true
 }
 
 AsyncRunner.prototype.toString = function(cb) {
@@ -80,8 +81,16 @@
 }
 
 /* Lets you call other async generators from an async generator */
+AsyncRunner.prototype.call = function (/* args... */) {
 
-    AsyncRunner.prototype.call = function (/* args... */) {
+    /* Verify we're not being called wrongly */
+    let caller = arguments.callee.caller;
+    if ((caller == null) ||
+	!(caller instanceof Function) ||
+	!("__asyncrunner" in caller)) {
+	throw new Error ("Can only call AsyncRunner.call() from AsyncRunner function");
+    }
+    
     var args = [null];
     var runner = this;
     for (let i = 0; i < arguments.length; i++)



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