Changeset 3713

Show
Ignore:
Timestamp:
04/29/06 17:06:28 (3 years ago)
Author:
jburke
Message:

Landing bootstrap refactoring. See http://trac.dojotoolkit.org/ticket/627 for more info

Location:
trunk
Files:
6 added
79 modified

Legend:

Unmodified
Added
Removed
  • trunk/buildscripts/build.xml

    r3481 r3713  
    88                  should we support these as HTML? Or just JS files? 
    99                  NOTE: the following command issued from the top-level seems to work correctly: 
    10                         perl buildscripts/jslink.pl -pre cat -i release/testUsage.js -l src/bootstrap1.js -l src/hostenv_browser.js -l src/bootstrap2.js -l src/io/IO.js -l src/io/BrowserIO.js -o - > release/minimal.js 
     10                        perl buildscripts/jslink.pl -pre cat -i release/testUsage.js -l src/bootstrap1.js -l src/bootstrap2.js -l src/hostenv_browser.js -l src/io/IO.js -l src/io/BrowserIO.js -o - > release/minimal.js 
    1111                  This correctly "links" the files together, but mangles some 
    1212                  identifiers and places anonymous inner functions at the wrong places 
     
    486486                </concat> 
    487487                <!--  
    488                         clobber requireAfterIf and requireAfter statements since they 
     488                        clobber requireIf and requireAfterIf statements since they 
    489489                        aren't applicable in build 
    490490                --> 
    491                 <replaceregexp match="dojo.requireAfterIf\((.*?)\);"  
     491                <replaceregexp match="dojo.requireIf\((.*?)\);"  
    492492                        byline="true" flags="g" file="${release_dir}/source.__package__.js"> 
    493493                        <substitution expression=""/> 
    494494                </replaceregexp> 
    495495 
    496                 <replaceregexp match="dojo.requireAfter\((.*?)\);"  
     496                <replaceregexp match="dojo.requireAfterIf\((.*?)\);"  
    497497                        byline="true" flags="g" file="${release_dir}/source.__package__.js"> 
    498498                        <substitution expression=""/> 
  • trunk/buildscripts/doctool/inline.html

    r1568 r3713  
    133133dj_eval_object_path 
    134134dj_error_to_string 
    135 dj_debug 
    136 dj_throw 
    137 dj_rethrow 
    138135dj_eval 
    139 dj_unimplemented 
    140 dj_deprecated 
    141 dj_inherits 
    142136dj_load 
    143137dj_last_script_src 
  • trunk/buildscripts/getDependencyList.js

    r3005 r3713  
    2828 
    2929load("../src/bootstrap1.js"); 
     30load("../src/bootstrap2.js"); 
    3031load("../src/hostenv_rhino.js"); 
    31 load("../src/bootstrap2.js"); 
    3232// FIXME: is this really what we want to say? 
    3333dojo.render.html.capable = true; 
    3434 
    3535dojo.hostenv.loadedUris.push("../src/bootstrap1.js"); 
     36dojo.hostenv.loadedUris.push("../src/bootstrap2.js"); 
    3637if(!this["hostenvType"]){ 
    3738        hostenvType = "browser"; 
     
    4647        dojo.hostenv.loadedUris.push("../src/hostenv_"+hostenvType+".js"); 
    4748} 
    48 dojo.hostenv.loadedUris.push("../src/bootstrap2.js"); 
    4949 
    5050if(dependencies["prefixes"]){ 
     
    9595        var tmp; 
    9696        RegExp.lastIndex = 0; 
    97         var testExp = /dojo.(hostenv.loadModule|hosetnv.require|require|requireIf|requireAll|hostenv.conditionalLoadModule|hostenv.startPackage|hostenv.provide|provide)\([\w\W]*?\)/mg; 
     97        var testExp = /dojo.(hostenv.loadModule|hosetnv.require|require|hostenv.conditionalLoadModule|hostenv.startPackage|provide)\([\w\W]*?\)/mg; 
    9898        while((tmp = testExp.exec(contents)) != null){ 
    9999                deps.push(tmp[0]); 
     
    110110        var tmp; 
    111111        RegExp.lastIndex = 0; 
    112         var testExp = /dojo.(requireAfterIf|requireAfter)\([\w\W]*?\)/mg; 
     112        var testExp = /dojo.(requireAfterIf|requireIf)\([\w\W]*?\)/mg; 
    113113        while((tmp = testExp.exec(contents)) != null){ 
    114114                deps.push(tmp[0]); 
  • trunk/documents/apis/dojo.html

    r1562 r3713  
    44dj_eval_object_path 
    55dj_error_to_string 
    6 dj_debug 
    7 dj_throw 
    8 dj_rethrow 
    96dj_eval 
    10 dj_unimplemented 
    11 dj_deprecated 
    12 dj_inherits 
    137dj_load 
    148dj_last_script_src 
     
    2418require () 
    2519requireIf () 
    26 conditionalRequire () 
    27 kwCompoundRequire () 
    2820provide () 
    2921</pre><h3>Properties</h3><pre>Object <a href="version.html">version</a> 
  • trunk/documents/apis/hostenv.html

    r1562 r3713  
    44getVersion () 
    55getText (uri, _81, _82) 
    6 getLibraryScriptUri () 
    76getBaseScriptUri () 
    8 setBaseScriptUri (uri) 
    97loadPath (_37, _38, cb) 
    108loadUri (uri, cb) 
  • trunk/documents/articles/dojo_classes.rest

    r2522 r3713  
    137137 
    138138   fixes to ecmascript implementations 
    139    dj_import(), dj_class(), dj_throw(), and any othe pseduo language extensions 
     139   dj_import(), dj_class(), and any othe pseduo language extensions 
    140140 
    141141.. raw:: html 
  • trunk/documents/articles/fast_widget_authoring.rest

    r3130 r3713  
    7878    } 
    7979    // complete the inheritance process 
    80     dj_inherits(dojo.widget.SlideShow, dojo.widget.HtmlWidget); 
     80    dojo.inherits(dojo.widget.SlideShow, dojo.widget.HtmlWidget); 
    8181    // make it a tag 
    8282    dojo.widget.tags.addParseTreeHandler("dojo:slideshow"); 
  • trunk/documents/manual/rest/dojo.rest

    r3193 r3713  
    145145    been loaded. For example, the contents of ``src/io/__package__.js`` may be:: 
    146146     
    147         dojo.kwCompoundRequire({ 
     147        dojo.hostenv.conditionalLoadModule({ 
    148148            common: ["dojo.io"], 
    149149            rhino: ["dojo.io.RhinoIO"], 
     
    207207        Nothing. 
    208208 
    209 ``requireAfter(modulename)``: 
    210  
    211     Load ``modulename`` *after* the current namespace has finished evaluating. 
     209``requireAfterIf(condition, modulename)``: 
     210 
     211    Deprecated. Alias for requireIf. Use that method instead. 
     212 
     213    ``condition``: 
     214        String or Boolean. 
    212215 
    213216    ``modulename``: 
     
    217220        Nothing. 
    218221 
    219 ``requireAfterIf(condition, modulename)``: 
    220  
    221     Load ``modulename`` *after* the current namespace has finished evaluating if 
    222     ``condition`` is met. 
    223  
    224     ``condition``: 
    225         String or Boolean. 
    226  
    227     ``modulename``: 
    228         String. The name of the module to load. 
    229  
    230     *return*: 
    231         Nothing. 
    232  
    233 ``kwCompoundRequire(requireMap)``: 
     222``hostenv.conditionalLoadModule(requireMap)``: 
    234223 
    235224    Loads specified modules based on hostenv type. When the following map is 
    236225    used:: 
    237226 
    238         dojo.kwCompoundRequire({ 
     227        dojo.hostenv.conditionalLoadModule({ 
    239228            common: ["dojo.io"], 
    240229            rhino: ["dojo.io.RhinoIO"], 
  • trunk/dojo.js

    r3507 r3713  
    1414                hostEnv = "dashboard"; 
    1515        } 
    16         var tmps = ["bootstrap1.js", "hostenv_"+hostEnv+".js", "bootstrap2.js"]; 
     16        var tmps = ["bootstrap1.js", "bootstrap2.js", "hostenv_"+hostEnv+".js"]; 
    1717 
    1818        if(hostEnv == "dashboard"){ 
     
    5252        } 
    5353 
     54        //Support compatibility packages. Right now this only allows setting one 
     55        //compatibility package. Might need to revisit later down the line to support 
     56        //more than one. 
     57        if((this["djConfig"])&&(djConfig["compat"])){ 
     58                tmps.push("compat/" + djConfig["compat"] + ".js"); 
     59        } 
     60 
     61        if((this["djConfig"])&&((djConfig["isDebug"])||(djConfig["debugAtAllCosts"]))){ 
     62                tmps.push("debug.js"); 
     63        } 
     64 
    5465        if((this["djConfig"])&&(djConfig["debugAtAllCosts"])&&(!isRhino)&&(!isDashboard)){ 
    5566                tmps.push("browser_debug.js"); 
  • trunk/src/bootstrap1.js

    r3458 r3713  
    123123} 
    124124 
    125 dj_throw = dj_rethrow = function(m, e){ 
    126         dojo.deprecated("dj_throw and dj_rethrow deprecated, use dojo.raise instead"); 
    127         dojo.raise(m, e); 
    128 } 
    129  
    130 /** 
    131  * Produce a line of debug output.  
    132  * Does nothing unless djConfig.isDebug is true. 
    133  * varargs, joined with ''. 
    134  * Caller should not supply a trailing "\n". 
    135  */ 
    136 dojo.debug = function(){ 
    137         if (!djConfig.isDebug) { return; } 
    138         var args = arguments; 
    139         if(dj_undef("println", dojo.hostenv)){ 
    140                 dojo.raise("dojo.debug not available (yet?)"); 
    141         } 
    142         var isJUM = dj_global["jum"] && !dj_global["jum"].isBrowser; 
    143         var s = [(isJUM ? "": "DEBUG: ")]; 
    144         for(var i=0;i<args.length;++i){ 
    145                 if(!false && args[i] instanceof Error){ 
    146                         var msg = "[" + args[i].name + ": " + dojo.errorToString(args[i]) + 
    147                                 (args[i].fileName ? ", file: " + args[i].fileName : "") + 
    148                                 (args[i].lineNumber ? ", line: " + args[i].lineNumber : "") + "]"; 
    149                 } else { 
    150                         try { 
    151                                 var msg = String(args[i]); 
    152                         } catch(e) { 
    153                                 if(dojo.render.html.ie) { 
    154                                         var msg = "[ActiveXObject]"; 
    155                                 } else { 
    156                                         var msg = "[unknown]"; 
    157                                 } 
    158                         } 
    159                 } 
    160                 s.push(msg); 
    161         } 
    162         if(isJUM){ // this seems to be the only way to get JUM to "play nice" 
    163                 jum.debug(s.join(" ")); 
    164         }else{ 
    165                 dojo.hostenv.println(s.join(" ")); 
    166         } 
    167 } 
    168  
    169 /** 
    170  * this is really hacky for now - just  
    171  * display the properties of the object 
    172 **/ 
    173  
    174 dojo.debugShallow = function(obj){ 
    175         if (!djConfig.isDebug) { return; } 
    176         dojo.debug('------------------------------------------------------------'); 
    177         dojo.debug('Object: '+obj); 
    178         var props = []; 
    179         for(var prop in obj){ 
    180                 try { 
    181                         props.push(prop + ': ' + obj[prop]); 
    182                 } catch(E) { 
    183                         props.push(prop + ': ERROR - ' + E.message); 
    184                 } 
    185         } 
    186         props.sort(); 
    187         for(var i = 0; i < props.length; i++) { 
    188                 dojo.debug(props[i]); 
    189         } 
    190         dojo.debug('------------------------------------------------------------'); 
    191 } 
    192  
    193 var dj_debug = dojo.debug; 
     125//Stub functions so things don't break. 
     126dojo.debug = function(){} 
     127dojo.debugShallow = function(obj){} 
     128dojo.profile = { start: function(){}, end: function(){}, stop: function(){}, dump: function(){} }; 
    194129 
    195130/** 
     
    209144 * implemented. 
    210145 */ 
    211 dj_unimplemented = dojo.unimplemented = function(funcname, extra){ 
     146dojo.unimplemented = function(funcname, extra){ 
    212147        // FIXME: need to move this away from dj_* 
    213148        var mess = "'" + funcname + "' not implemented"; 
     
    219154 * Convenience for informing of deprecated behaviour. 
    220155 */ 
    221 dj_deprecated = dojo.deprecated = function(behaviour, extra, removal){ 
     156dojo.deprecated = function(behaviour, extra, removal){ 
    222157        var mess = "DEPRECATED: " + behaviour; 
    223158        if(extra){ mess += " " + extra; } 
    224159        if(removal){ mess += " -- will be removed in version: " + removal; } 
    225         dojo.debug(mess); 
    226 } 
    227  
    228 /** 
    229  * Convenience for informing of experimental code. 
    230  */ 
    231 dojo.experimental = function(packageName, extra){ 
    232         var mess = "EXPERIMENTAL: " + packageName; 
    233         mess += " -- Not yet ready for use.  APIs subject to change without notice."; 
    234         if(extra){ mess += " " + extra; } 
    235160        dojo.debug(mess); 
    236161} 
     
    248173        // DEPRICATED: super is a reserved word, use 'superclass' 
    249174        subclass['super'] = superclass.prototype; 
    250 } 
    251  
    252 dj_inherits = function(subclass, superclass){ 
    253         dojo.deprecated("dj_inherits deprecated, use dojo.inherits instead"); 
    254         dojo.inherits(subclass, superclass); 
    255175} 
    256176 
     
    322242        } 
    323243 
    324         var djc = djConfig; 
    325         function _def(obj, name, def){ 
    326                 return (dj_undef(name, obj) ? def : obj[name]); 
    327         } 
    328  
    329244        return { 
    330245                name_: '(unset)', 
    331246                version_: '(unset)', 
    332                 pkgFileName: "__package__", 
    333  
    334                 // for recursion protection 
    335                 loading_modules_: {}, 
    336                 loaded_modules_: {}, 
    337                 addedToLoadingCount: [], 
    338                 removedFromLoadingCount: [], 
    339                 inFlightCount: 0, 
    340                 // FIXME: it should be possible to pull module prefixes in from djConfig 
    341                 modulePrefixes_: { 
    342                         dojo: {name: "dojo", value: "src"} 
    343                 }, 
    344  
    345  
    346                 setModulePrefix: function(module, prefix){ 
    347                         this.modulePrefixes_[module] = {name: module, value: prefix}; 
    348                 }, 
    349  
    350                 getModulePrefix: function(module){ 
    351                         var mp = this.modulePrefixes_; 
    352                         if((mp[module])&&(mp[module]["name"])){ 
    353                                 return mp[module].value; 
    354                         } 
    355                         return module; 
    356                 }, 
    357  
    358                 getTextStack: [], 
    359                 loadUriStack: [], 
    360                 loadedUris: [], 
    361                 // lookup cache for modules. 
    362                 // NOTE: this is partially redundant a private variable in the jsdown 
    363                 // implementation, but we don't want to couple the two. 
    364                 // modules_ : {}, 
    365                 post_load_: false, 
    366                 modulesLoadedListeners: [], 
     247 
    367248                /** 
    368249                 * Return the name of the hostenv. 
     
    382263                getText: function(uri){ 
    383264                        dojo.unimplemented('getText', "uri=" + uri); 
    384                 }, 
    385  
    386                 /** 
    387                  * return the uri of the script that defined this function 
    388                  * private method that must be implemented by the hostenv. 
    389                  */ 
    390                 getLibraryScriptUri: function(){ 
    391                         // FIXME: need to implement!!! 
    392                         dojo.unimplemented('getLibraryScriptUri',''); 
    393265                } 
    394266        }; 
    395267})(); 
    396  
    397 /** 
    398  * Display a line of text to the user. 
    399  * The line argument should not contain a trailing "\n"; that is added by the 
    400  * implementation. 
    401  */ 
    402 //dojo.hostenv.println = function(line) {} 
    403  
    404 // **************************************************************** 
    405 // dojo.hostenv methods not defined in hostenv_*.js 
    406 // **************************************************************** 
    407268 
    408269/** 
     
    421282        return djConfig.baseScriptUri; 
    422283} 
    423  
    424 /** 
    425 * Set the base script uri. 
    426 */ 
    427 // In JScript .NET, see interface System._AppDomain implemented by 
    428 // System.AppDomain.CurrentDomain. Members include AppendPrivatePath, 
    429 // RelativeSearchPath, BaseDirectory. 
    430 dojo.hostenv.setBaseScriptUri = function(uri){ djConfig.baseScriptUri = uri } 
    431  
    432 /** 
    433  * Loads and interprets the script located at relpath, which is relative to the 
    434  * script root directory.  If the script is found but its interpretation causes 
    435  * a runtime exception, that exception is not caught by us, so the caller will 
    436  * see it.  We return a true value if and only if the script is found. 
    437  * 
    438  * For now, we do not have an implementation of a true search path.  We 
    439  * consider only the single base script uri, as returned by getBaseScriptUri(). 
    440  * 
    441  * @param relpath A relative path to a script (no leading '/', and typically 
    442  * ending in '.js'). 
    443  * @param module A module whose existance to check for after loading a path. 
    444  * Can be used to determine success or failure of the load. 
    445  */ 
    446 dojo.hostenv.loadPath = function(relpath, module /*optional*/, cb /*optional*/){ 
    447         if((relpath.charAt(0) == '/')||(relpath.match(/^\w+:/))){ 
    448                 dojo.raise("relpath '" + relpath + "'; must be relative"); 
    449         } 
    450         var uri = this.getBaseScriptUri() + relpath; 
    451         if(djConfig.cacheBust && dojo.render.html.capable) { uri += "?" + String(djConfig.cacheBust).replace(/\W+/g,""); } 
    452         try{ 
    453                 return ((!module) ? this.loadUri(uri, cb) : this.loadUriAndCheck(uri, module, cb)); 
    454         }catch(e){ 
    455                 dojo.debug(e); 
    456                 return false; 
    457         } 
    458 } 
    459  
    460 /** 
    461  * Reads the contents of the URI, and evaluates the contents. 
    462  * Returns true if it succeeded. Returns false if the URI reading failed. 
    463  * Throws if the evaluation throws. 
    464  * The result of the eval is not available to the caller. 
    465  */ 
    466 dojo.hostenv.loadUri = function(uri, cb){ 
    467         if(this.loadedUris[uri]){ 
    468                 return; 
    469         } 
    470         var contents = this.getText(uri, null, true); 
    471         if(contents == null){ return 0; } 
    472         this.loadedUris[uri] = true; 
    473         var value = dj_eval(contents); 
    474         return 1; 
    475 } 
    476  
    477 // FIXME: probably need to add logging to this method 
    478 dojo.hostenv.loadUriAndCheck = function(uri, module, cb){ 
    479         var ok = true; 
    480         try{ 
    481                 ok = this.loadUri(uri, cb); 
    482         }catch(e){ 
    483                 dojo.debug("failed loading ", uri, " with error: ", e); 
    484         } 
    485         return ((ok)&&(this.findModule(module, false))) ? true : false; 
    486 } 
    487  
    488 dojo.loaded = function(){ } 
    489  
    490 dojo.hostenv.loaded = function(){ 
    491         this.post_load_ = true; 
    492         var mll = this.modulesLoadedListeners; 
    493         for(var x=0; x<mll.length; x++){ 
    494                 mll[x](); 
    495         } 
    496         dojo.loaded(); 
    497 } 
    498  
    499 /* 
    500 Call styles: 
    501         dojo.addOnLoad(functionPointer) 
    502         dojo.addOnLoad(object, "functionName") 
    503 */ 
    504 dojo.addOnLoad = function(obj, fcnName) { 
    505         if(arguments.length == 1) { 
    506                 dojo.hostenv.modulesLoadedListeners.push(obj); 
    507         } else if(arguments.length > 1) { 
    508                 dojo.hostenv.modulesLoadedListeners.push(function() { 
    509                         obj[fcnName](); 
    510                 }); 
    511         } 
    512 } 
    513  
    514 dojo.hostenv.modulesLoaded = function(){ 
    515         if(this.post_load_){ return; } 
    516         if((this.loadUriStack.length==0)&&(this.getTextStack.length==0)){ 
    517                 if(this.inFlightCount > 0){