You are viewing a plain text version of this content. The canonical link for it is here.
Posted to xap-commits@incubator.apache.org by mt...@apache.org on 2006/11/08 21:53:16 UTC

svn commit: r472656 - in /incubator/xap/trunk/src/xap: Xap.js util/Debug.js

Author: mturyn
Date: Wed Nov  8 13:53:15 2006
New Revision: 472656

URL: http://svn.apache.org/viewvc?view=rev&rev=472656
Log:
Fixed a couple of errors:  reference to a regexp now carried on xap.util.Debug rather than on Xap as before,
adjusted Debug.loadDebuggables() so it will handle an arguments-style object (length, numeric indices, but not an Array instance
---now just make sure that it isn't a sString instance).

Modified:
    incubator/xap/trunk/src/xap/Xap.js
    incubator/xap/trunk/src/xap/util/Debug.js

Modified: incubator/xap/trunk/src/xap/Xap.js
URL: http://svn.apache.org/viewvc/incubator/xap/trunk/src/xap/Xap.js?view=diff&rev=472656&r1=472655&r2=472656
==============================================================================
--- incubator/xap/trunk/src/xap/Xap.js (original)
+++ incubator/xap/trunk/src/xap/Xap.js Wed Nov  8 13:53:15 2006
@@ -15,7 +15,7 @@
  *
  */
  
-Xap = function () {}
+Xap = function(){}
 
 /**
  *	START OF PUBLIC METHODS FOR THE XAP CLASS USED TO 
@@ -69,6 +69,8 @@
 	djConfig.baseRelativePath = "../../src/dojo/";
 }
 
+
+
 Xap.ourLoadedClasses = new Object() ;
 
 
@@ -87,6 +89,11 @@
 	dojo.provide.apply(dojo,arguments);
 }
 
+
+
+
+
+
 /**
  * Method is used to require a class be loaded.  This 
  * works similar to a Java:
@@ -95,48 +102,44 @@
  * otherwise.
  * 
  */
-Xap.require = function(){
-	var result = false ;
+Xap.require = function () {
+	var result = false;
+	dojo.require("xap.util.Debug");
+	var theDebugger = Xap.getDebuggingObject();
 	
-	if( !xap || !xap.util || ! xap.util.Debug ){
-		dojo.require("xap.util.Debug") ;
-	}
-    // Modules will have to go through Dojo:
-	var toLoad = arguments[0] ;
-	var notModule = (toLoad.search(Xap.anyAsteriskRegexp)==-1) ;
-
-    // Don't overload, don't depend on ArrayHelper being around:
-	var alreadyLoaded = (Xap.ourLoadedClasses[toLoad])?true:false ;
-	if( alreadyLoaded ){
-		Xap._logString += "\nRedundant load attempt: "+toLoad ;
+	// Modules can't be loaded via script tags, just Dojo:
+	var toLoad = arguments[0];
+	// Note that if Xap.canDebug==true, we've loaded the debugging
+	// object---if not we never get to the reference:
+	var notModule = (toLoad.search(xap.util.Debug.anyAsteriskRegexp) == -1);
+
+	// Don't reload, don't depend on ArrayHelper being around
+	// yet, so keep the class names easily accessible in an Object:
+	var alreadyLoaded = (Xap.ourLoadedClasses[toLoad]) ? true : false;
+	if (alreadyLoaded) {
+		//Xap._logString += "nRedundant load attempt: "+toLoad ;
 		// We've already loaded this, so it's loadable:
 		result = true;
 	} else {
 
 		// do we need to reload this file?
 		//---is it in the "debuggables" list?--are we reloading everything?
-		var needToDebugLoad = notModule && 
-		                        (xap.util.Debug._debugAll || 
-		                        	(xap.util.Debug._debugLoad  //
-		                        		&& xap.util.Debug._debuggables[toLoad] //this is one to load
-		                        		)
-		                        );
-	
-		try {		
-			dojo.require.apply(dojo,arguments) ;
-			if(needToDebugLoad){
-				xap.util.Debug.addDebuggables([toLoad]) ;	
-				Xap.ourLoadedClasses[toLoad] = true ;			
+		var needToDebugLoad = theDebugger && notModule && (xap.util.Debug._debugAll || (xap.util.Debug._debugLoad && xap.util.Debug._debuggables[toLoad]));
+		try {
+			dojo.require.apply(dojo, arguments);
+			if (needToDebugLoad) {
+				xap.util.Debug.addDebuggables([toLoad]);
+				Xap.ourLoadedClasses[toLoad] = true;
 			}
-			result = true ;
-		} catch (ee) {
-			Xap._logString += '\n'+ee ;
-			result = false ;
+			result = true;
+		}
+		catch (ee) {
+			//Xap._logString += 'n'+ee ;
+			result = false;
 		}
 	}
-	
-	return result ;
-}
+	return result;
+};
 
 Xap.resolveConstructor = function(aString){
 	var result ;
@@ -183,3 +186,14 @@
 
 	subclassConstructor.s_log = xap.util.LogFactory.getLog( subclassName ) ;
 }
+
+Xap.getDebuggingObject = function(){
+// Eventually, make this smarter
+	if( !xap.util.Debug ){
+		return null ;
+	} else {
+		return xap.util.Debug ;
+	}
+}
+
+

Modified: incubator/xap/trunk/src/xap/util/Debug.js
URL: http://svn.apache.org/viewvc/incubator/xap/trunk/src/xap/util/Debug.js?view=diff&rev=472656&r1=472655&r2=472656
==============================================================================
--- incubator/xap/trunk/src/xap/util/Debug.js (original)
+++ incubator/xap/trunk/src/xap/util/Debug.js Wed Nov  8 13:53:15 2006
@@ -63,9 +63,8 @@
 		return;
 	}else{ 
 		// Just in case we got a string:
-		if (arguments[0] instanceof Array ){
+		if (!(arguments[0] instanceof String) ){
 			for (var nom in arguments[0]){
-				alert(nom) ;
 				xap.util.Debug._loadDebuggable(nom) ;
 			}
 		}