Changeset 32

Show
Ignore:
Timestamp:
01/09/06 16:29:19 (3 years ago)
Author:
Jan-Klaas Kollhof
Message:

fixed bug in iter module for async. iterations. extended module lookup for submodules

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/jsolait/jsolait.js

    r31 r32  
    9595            if(i==0){//for the first base class just use it's proto as the final proto 
    9696                proto = baseProto; 
    97             }else{//for all others extend(do not override) the final proto with the properties in the baseProto 
     97            }else{//for all others extend(do not overwrite) the final proto with the properties in the baseProto 
    9898                for(var key in baseProto){ 
    9999                    if(proto[key] === undefined){ 
     
    145145                    return rslt.__call__.apply(rslt, arguments); 
    146146                }; 
    147  
     147                 
     148                //this will only work for the current class but not create any priv objects for any base class  
    148149                var proto=arguments.callee.prototype; 
    149150                for(var n in proto){ 
     
    184185                return rslt; 
    185186            } 
    186         }; 
     187        };  
    187188    }else{ 
    188189        //this is a 'normal' object constructor which does nothing but call the __init__ method 
     
    196197        }; 
    197198    } 
     199     
    198200 
    199201    //reset the constructor for new objects to the actual constructor. 
     
    440442    /*@moduleURIs end*/ 
    441443 
     444     
    442445    /** 
    443446        The base URIs to search for modules in.  
     
    543546        }else{ 
    544547            var src,modPath; 
     548             
     549            name = name.split('.'); 
     550                          
    545551            //check if jsolait already knows the path of the module 
    546             if(mod.knownModuleURIs[name] != undefined){ 
    547                 modPath = mod.knownModuleURIs[name].format(mod); 
     552            if(mod.knownModuleURIs[name[0]] != undefined){ 
     553                modPath = mod.knownModuleURIs[name[0]].format(mod); 
     554                if(name.length>1){ 
     555                    modPath = "%s%s.js".format(modPath, name.slice(1).join('/')); 
     556                } 
    548557                try{//to load the source of the module 
    549558                    src = mod.loadURI(modPath); 
     
    552561                } 
    553562            } 
    554  
     563             
    555564            if(src == null){//go through the search paths and try loading the module 
    556565                var failedURIs=[]; 
    557566                for(var i=0;i<mod.moduleSearchURIs.length; i++){ 
    558                     modPath = "%s/%s.js".format(mod.moduleSearchURIs[i].format(mod), name.split(".").join("/")); 
     567                    modPath = "%s/%s.js".format(mod.moduleSearchURIs[i].format(mod), name.join("/")); 
    559568                    try{ 
    560569                        src = mod.loadURI(modPath); 
     
    565574                } 
    566575                if(src == null){ 
    567                     throw new mod.ImportFailed(name, failedURIs); 
     576                    throw new mod.ImportFailed(name.join('.'), failedURIs); 
    568577                } 
    569578            } 
     
    575584                f(); 
    576585            }catch(e){ 
    577                 throw new mod.ImportFailed(name, [srcURI], e); 
    578             } 
    579  
    580             return mod.modules[name]; 
     586                throw new mod.ImportFailed(name.join('.'), [srcURI], e); 
     587            } 
     588 
     589            return mod.modules[name.join('.')]; 
    581590        } 
    582591    }; 
  • trunk/jsolait/lib/iter.js

    r30 r32  
    232232                this.isRunning = false; 
    233233                clearTimeout(this.timeout); 
    234                 delete iter.iterations[this.id]; 
     234                delete iter.iterations[this.__hash__()]; 
    235235            } 
    236236        }; 
     
    239239            if(this.isRunning == false){ 
    240240                this.isRunning = true; 
    241                 var id=0;//find unused id 
    242                 while(iter.iterations[id]!==undefined){ 
    243                     this.id++; 
    244                 } 
    245                 this.id = "" + id; 
    246                 iter.iterations[this.id] = this; 
     241                var id = this.__hash__(); 
     242                iter.iterations[id] = this; 
    247243                //let the iteration be handled using a timer 
    248                 this.timeout = setTimeout("iter.handleAsyncStep('" + this.id + "')", this.interval); 
     244                this.timeout = setTimeout("iter.handleAsyncStep('" + id + "')", this.interval); 
    249245            } 
    250246        }; 
     
    252248        publ.handleAsyncStep = function(){ 
    253249            if(this.isRunning){ 
    254                 tem=this.iterator.next(); 
     250                var item=this.iterator.next(); 
    255251                if(item === undefined){ 
    256252                    this.stop(); 
     
    258254                    //let the callback handle the item 
    259255                    this.callback.call(this.thisObj==null?this : this.thisObj,  item, this); 
    260                     this.timeout = setTimeout("iter.handleAsyncStep('" + this.id + "')", this.interval); 
     256                    this.timeout = setTimeout("iter.handleAsyncStep('" + this.__hash__()+ "')", this.interval); 
    261257                } 
    262258            } 
  • trunk/tools/build.js

    r29 r32  
    5959                         } 
    6060                    }     
     61                    var sfe=new Enumerator(fldr.SubFolders); 
     62                    for (;!sfe.atEnd(); sfe.moveNext()){ 
     63                        var f = sfe.item(); 
     64                        mods.push('"' + f.name  + '":"%(baseURI)s/'+libFolder+'/' + f.name + '/"'); 
     65                    } 
    6166                } 
    6267            } 
    63              
    64              
     68 
    6569            modDirs='mod.knownModuleURIs={' + mods.join(',') + '};'; 
    6670            s=s.join(modDirs);