Changeset 73
- Timestamp:
- 07/31/06 17:29:41 (2 years ago)
- Files:
-
- branches/experimental/jsolait/jsolait.js (modified) (34 diffs)
- branches/experimental/jsolait/jsolait.wsf (modified) (6 diffs)
- branches/experimental/jsolait/lib/asyncimprt.js (modified) (1 diff)
- branches/experimental/jsolait/lib/codecs.js (modified) (7 diffs)
- branches/experimental/jsolait/lib/crypto.js (modified) (5 diffs)
- branches/experimental/jsolait/lib/dom.js (modified) (6 diffs)
- branches/experimental/jsolait/lib/forms.js (modified) (6 diffs)
- branches/experimental/jsolait/lib/itertools.js (modified) (14 diffs)
- branches/experimental/jsolait/lib/jsonrpc.js (modified) (24 diffs)
- branches/experimental/jsolait/lib/lang.js (modified) (2 diffs)
- branches/experimental/jsolait/lib/net/sockets.js (modified) (8 diffs)
- branches/experimental/jsolait/lib/operators.js (modified) (13 diffs)
- branches/experimental/jsolait/lib/sets.js (modified) (8 diffs)
- branches/experimental/jsolait/lib/strings.js (modified) (9 diffs)
- branches/experimental/jsolait/lib/testing.js (modified) (18 diffs)
- branches/experimental/jsolait/lib/urllib.js (modified) (12 diffs)
- branches/experimental/jsolait/lib/xml.js (modified) (12 diffs)
- branches/experimental/jsolait/lib/xmlrpc.js (modified) (34 diffs)
- branches/experimental/test/test.js (modified) (2 diffs)
- branches/experimental/test/test_codecs.js (modified) (2 diffs)
- branches/experimental/test/test_core.js (modified) (4 diffs)
- branches/experimental/test/test_crypto.js (modified) (2 diffs)
- branches/experimental/test/test_itertools.js (modified) (3 diffs)
- branches/experimental/test/test_jsonrpc.js (modified) (2 diffs)
- branches/experimental/test/test_sets.js (modified) (2 diffs)
- branches/experimental/test/test_strings.js (modified) (2 diffs)
- branches/experimental/test/test_testing.js (modified) (5 diffs)
- branches/experimental/test/test_urllib.js (modified) (2 diffs)
- branches/experimental/test/test_xmlrpc.js (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
branches/experimental/jsolait/jsolait.js
r72 r73 30 30 **/ 31 31 32 jsolait=(function( publ){{with(publ){33 34 publ.__name__='jsolait';35 36 publ.__version__="$Revision$";37 38 publ.__str__ =function(){32 jsolait=(function(mod){ 33 34 mod.__name__='jsolait'; 35 36 mod.__version__="$Revision$"; 37 38 mod.__str__ =function(){ 39 39 return "[module '%s' version: %s]".format(this.__name__, (this.__version__+'').replace(/\$Revision:\s(\d+) \$/, "Rev.$1")); 40 40 }; 41 publ.toString=__str__;41 mod.toString=mod.__str__; 42 42 43 43 ///The location where jsolait is installed. 44 44 //do not edit the following lines, it will be replaced by the build script 45 45 /*@baseURI begin*/ 46 publ.baseURI="./jsolait";46 mod.baseURI="./jsolait"; 47 47 /*@baseURI end*/ 48 48 … … 50 50 //do not edit the following lines, it will be replaced by the build script 51 51 /*@moduleSourceURIs begin*/ 52 publ.moduleSourceURIs={};52 mod.moduleSourceURIs={}; 53 53 /*@moduleSourceURIs end*/ 54 54 … … 58 58 they may contain StringFormating symbols e.g '%(baseURI)s/lib' 59 59 **/ 60 publ.moduleSearchURIs = [".", "%(baseURI)s/lib"];60 mod.moduleSearchURIs = [".", "%(baseURI)s/lib"]; 61 61 62 publ.packagesURI = "%(baseURI)s/packages";63 64 publ.modules={};62 mod.packagesURI = "%(baseURI)s/packages"; 63 64 mod.modules={}; 65 65 66 66 /** … … 69 69 @return A string repr. the object. 70 70 **/ 71 publ.str = String;71 var str = String; 72 72 73 73 /** … … 77 77 @return A representation of the object. 78 78 **/ 79 publ.repr = function(obj){79 var repr = function(obj){ 80 80 if(obj == null){ 81 81 return null; … … 122 122 @return A String containing a id value for the obj. 123 123 **/ 124 publ.id = function(obj, forceId){124 var id = function(obj, forceId){ 125 125 switch(typeof obj.__id__){ 126 126 … … 134 134 return obj.__id__; 135 135 }else{ 136 throw new Exception('Objec cannot be IDed: %s'.format(obj));136 throw new mod.Exception('Objec cannot be IDed: %s'.format(obj)); 137 137 } 138 138 … … 154 154 @return A method which when run executes the function with the this-object being the obj specified. 155 155 **/ 156 publ.bind = function(obj, fn){156 var bind = function(obj, fn){ 157 157 return function(){ 158 158 return fn.apply(obj, arguments); … … 176 176 @return True if the object is an instance of cls. False otherwise. 177 177 **/ 178 publ.isinstance=function(obj, cls){178 var isinstance=function(obj, cls){ 179 179 if(obj instanceof cls){ 180 180 return true; … … 197 197 @return True if cls is a subclass of baseclass otherwise false. 198 198 **/ 199 publ.issubclass=function(cls, baseclass){199 var issubclass=function(cls, baseclass){ 200 200 if(baseclass === Object || cls===baseclass || (cls.prototype instanceof baseclass)){ 201 201 return true; … … 230 230 the super class' wrapper for calling inherited methods. 231 231 **/ 232 publ.Class=function(name, base1, classScope){232 var Class=function(name, base1, classScope){ 233 233 var args=[]; 234 234 for(var i=0;i<arguments.length;i++){ … … 406 406 Class.__createProto__=function(){ throw "Can't use Class as a base class.";}; 407 407 408 mod.Class = Class; 409 408 410 Function.__createProto__ = function(){ throw "Cannot inherit from Function. implement the callable interface instead using YourClass::__call__.";}; 409 411 Array.__createProto__=function(){ var r =[]; r.__str__ = Array.prototype.toString; return r; }; … … 414 416 String.__str__ =String.toString=function(){return "[class String]";}; 415 417 416 publ.Exception=Class(function(publ){418 mod.Exception=Class(function(publ,priv,supr){ 417 419 /** 418 420 Initializes a new Exception. … … 437 439 publ.toTraceString=function(indent){ 438 440 indent = indent==null ? 0 : indent; 439 440 441 //todo:use constructor.__name__? 441 var s="%s in %s:\n%s".format(this. name, this.module, this.message.indent(4)).indent(indent);442 var s="%s in %s:\n%s".format(this.constructor.__name__, this.module, this.message.indent(4)).indent(indent); 442 443 if(this.trace){ 443 444 if(this.trace.toTraceString){ … … 455 456 publ.message; 456 457 ///The module the Exception belongs to. 457 publ.module= publ;458 publ.module=mod; 458 459 ///The error which caused the Exception or undefined. 459 460 publ.trace; 460 461 }); 461 462 publ.ModuleClass=Class(function(publ){ 463 publ.__name__; 464 publ.__version__; 465 publ.__source__; 466 publ.__sourceURI__; 467 468 publ.__init__=function(name, source, sourceURI){ 469 this.__name__=name; 470 this.__version__=""; 471 this.__source__ = source; 472 this.__sourceURI__ = sourceURI; 473 }; 474 475 publ.__str__=function(){ 476 //todo:SVN adaption 477 return "[module '%s' version: %s]".format(this.__name__, (this.__version__+'').replace(/\$Revision:\s(\d+) \$/, "Rev.$1")); 478 }; 479 }); 480 462 481 463 /** 482 464 Creates an HTTP request object for retreiving files. 483 465 @return HTTP request object. 484 466 **/ 485 publ.getHTTPRequestObject=function() {467 mod.getHTTPRequestObject=function() { 486 468 var obj; 487 469 try{ //to get the mozilla httprequest object … … 497 479 obj = new ActiveXObject("microsoft.XMLHTTP"); 498 480 }catch(e){ 499 throw new Exception("Unable to get an HTTP request object.");481 throw new mod.Exception("Unable to get an HTTP request object."); 500 482 } 501 483 } … … 508 490 Thrown when a file could not be loaded. 509 491 **/ 510 publ.LoadURIFailed=Class(Exception, function(publ, priv,supr){492 mod.LoadURIFailed=Class(mod.Exception, function(publ, priv,supr){ 511 493 /** 512 494 Initializes a new LoadURIFailed Exception. … … 529 511 @return The content of the file. 530 512 **/ 531 publ.loadURI=function(uri, headers){513 mod.loadURI=function(uri, headers){ 532 514 headers = (headers !== undefined) ? headers : []; 533 515 try{ 534 var xmlhttp = getHTTPRequestObject();516 var xmlhttp = mod.getHTTPRequestObject(); 535 517 xmlhttp.open("GET", uri, false); 536 518 for(var i=0;i< headers.length;i++){ … … 539 521 xmlhttp.send(""); 540 522 }catch(e){ 541 throw new LoadURIFailed(uri, e);523 throw new mod.LoadURIFailed(uri, e); 542 524 } 543 525 //todo: the status checking needs testing … … 546 528 return s; 547 529 }else{ 548 throw new LoadURIFailed(uri, newException("Server did not respond with status code 200 but with: " + xmlhttp.status));530 throw new mod.LoadURIFailed(uri, new mod.Exception("Server did not respond with status code 200 but with: " + xmlhttp.status)); 549 531 } 550 532 }; … … 557 539 558 540 **/ 559 publ.getSearchURIsForModuleName=function(name){541 mod.getSearchURIsForModuleName=function(name){ 560 542 var sourceURI; 561 543 562 544 var searchURIs = []; 563 545 564 if(mod uleSourceURIs[name] != undefined){565 searchURIs.push(mod uleSourceURIs[name].format(jsolait));546 if(mod.moduleSourceURIs[name] != undefined){ 547 searchURIs.push(mod.moduleSourceURIs[name].format(mod)); 566 548 }else{ 567 549 name = name.split('.'); 568 550 if(name.length>1){ 569 if(mod uleSourceURIs[name[0]] != undefined){570 var uri = mod uleSourceURIs[name[0]].format(jsolait);551 if(mod.moduleSourceURIs[name[0]] != undefined){ 552 var uri = mod.moduleSourceURIs[name[0]].format(mod); 571 553 searchURIs.push("%s/%s.js".format(uri, name.slice(1).join('/'))); 572 554 } 573 searchURIs.push("%s/%s.js".format( packagesURI.format(jsolait),name.join('/')));555 searchURIs.push("%s/%s.js".format(mod.packagesURI.format(mod),name.join('/'))); 574 556 } 575 557 576 for(var i=0;i<mod uleSearchURIs.length; i++){577 searchURIs.push("%s/%s.js".format(mod uleSearchURIs[i].format(jsolait), name.join("/")));558 for(var i=0;i<mod.moduleSearchURIs.length; i++){ 559 searchURIs.push("%s/%s.js".format(mod.moduleSearchURIs[i].format(mod), name.join("/"))); 578 560 } 579 561 name = name.join("."); … … 585 567 Thrown when a module could not be found. 586 568 **/ 587 publ.LoadModuleFailed=Class(Exception, function(publ, supr){569 mod.LoadModuleFailed=Class(mod.Exception, function(publ, priv, supr){ 588 570 /** 589 571 Initializes a new LoadModuleFailed Exception. … … 610 592 @return The module object. 611 593 **/ 612 publ.loadModule = function(name){613 614 if(mod ules[name]){ //module already loaded615 return mod ules[name];594 mod.loadModule = function(name){ 595 596 if(mod.modules[name]){ //module already loaded 597 return mod.modules[name]; 616 598 }else{ 617 599 var src,sourceURI; 618 619 var searchURIs =getSearchURIsForModuleName(name); 620 600 var searchURIs = mod.getSearchURIsForModuleName(name); 621 601 var failedURIs=[]; 622 602 for(var i=0;i<searchURIs.length;i++){ 623 603 try{ 624 604 sourceURI = searchURIs[i]; 625 src = loadURI(sourceURI);605 src = mod.loadURI(sourceURI); 626 606 break; 627 607 }catch(e){ … … 629 609 } 630 610 } 631 632 611 if(src == null){ 633 throw new LoadModuleFailed(name, failedURIs);612 throw new mod.LoadModuleFailed(name, failedURIs); 634 613 }else{ 635 614 try{//interpret the script 636 var m = createModuleFromSource(name, src, sourceURI);615 var m = mod.createModuleFromSource(name, src, sourceURI); 637 616 return m; 638 617 }catch(e){ 639 throw new LoadModuleFailed(name, [sourceURI], e);618 throw new mod.LoadModuleFailed(name, [sourceURI], e); 640 619 } 641 620 } … … 643 622 }; 644 623 645 publ.__imprt__ = function(name, destinationScope){624 mod.__imprt__ = function(name, attachTo){ 646 625 var n=name.replace(/\s/g,"").split(":"); 647 626 name = n[0]; … … 652 631 } 653 632 654 var m = loadModule(name);633 var m = mod.loadModule(name); 655 634 656 635 if(items.length > 0){ 657 636 if(items[0] == '*'){ 658 637 for(var key in m){ 659 if(key.slice(0,2) != "__" && destinationScope[key] == undefined){660 destinationScope[key] = m[key];638 if(key.slice(0,2) != "__" && attachTo[key] == undefined){ 639 attachTo[key] = m[key]; 661 640 } 662 641 } 663 642 }else{ 664 643 for(var i=0;i<items.length;i++){ 665 destinationScope[items[i]] = m[items[i]]; 666 } 667 } 668 }else{ 669 destinationScope[name] = m; 670 } 671 }; 672 673 publ.CreateModuleFailed=Class(Exception, function(publ, supr){ 644 attachTo[items[i]] = m[items[i]]; 645 } 646 } 647 }else{ 648 attachTo[name] = m; 649 } 650 }; 651 652 var StringsOrCommentsOrImprt=/(\/\*([\n\r]|.)*?\*\/)|(\/\/.*)|('(\\'|.)*?')|("(\\"|.)*?")|\b(imprt\(.*?\))/g; 653 var ImprtStatement=/^imprt\(['"](.*?)['"]\)$/; 654 655 mod.getModuleDependenciesFromSource=function(source){ 656 657 var imprtStatements=[]; 658 var items=str(source).match(StringsOrCommentsOrImprt); 659 if(items){ 660 for(var i=0;i<items.length;i++){ 661 var item = items[i]; 662 var imprtStatement=item.match(ImprtStatement); 663 if(imprtStatement){ 664 imprtStatements.push(imprtStatement[1]); 665 } 666 } 667 } 668 return imprtStatements; 669 }; 670 671 mod.ModuleClass=Class(function(publ,priv,supr){ 672 publ.__name__; 673 publ.__version__; 674 publ.__source__; 675 publ.__sourceURI__; 676 677 publ.__init__=function(name, source, sourceURI){ 678 this.__name__=name; 679 this.__version__="0.0.0"; 680 this.__source__ = source; 681 this.__sourceURI__ = sourceURI; 682 this.Exception = Class(mod.Exception, new Function()); 683 this.Exception.prototype.module = this; 684 }; 685 686 publ.__str__=function(){ 687 //todo:SVN adaption 688 return "[module '%s' version: %s]".format(this.__name__, (this.__version__+'').replace(/\$Revision:\s(\d+) \$/, "Rev.$1")); 689 }; 690 }); 691 692 mod.CreateModuleFailed=Class(mod.Exception, function(publ, priv, supr){ 674 693 /** 675 694 Initializes a new CreateModuleFailed Exception. … … 682 701 }; 683 702 ///The module that could not be createed. 684 publ.module; 703 publ.failedModule; 704 705 publ.__str___=function(){ 706 return str(this.failedModule); 707 708 } 685 709 }); 686 710 687 publ.createModule=function(name, source, sourceURI, modFn){ 688 var newMod = new ModuleClass(name, source, sourceURI); 689 690 var privateScope={imprt: function(imp){ 691 var s = arguments.callee.scope; 692 __imprt__(imp, s); 693 }}; 694 privateScope.imprt.scope=privateScope; 695 privateScope.Exception = Class(Exception, new Function()); 696 privateScope.Exception.prototype.module = newMod; 711 mod.createModule=function(name, source, sourceURI, modFn){ 712 var newMod = new mod.ModuleClass(name, source, sourceURI); 713 714 try{//to run the module source 715 modFn.call(newMod, newMod); 716 }catch(e){ 717 throw new mod.CreateModuleFailed(newMod, e); 718 } 719 720 applyNames(newMod); 721 722 mod.modules[name] = newMod; 723 return newMod; 724 }; 725 726 mod.createModuleFromSource=function(name, source, sourceURI){ 727 var newMod = new mod.ModuleClass(name, source, sourceURI); 728 729 var deps=mod.getModuleDependenciesFromSource(source); 697 730 698 731 var locals={ … … 703 736 isinstance:isinstance, 704 737 issubclass:issubclass, 705 jsolait:jsolait,706 738 Class:Class 707 739 }; 708 740 741 for(var i=0;i<deps.length;i++){ 742 mod.__imprt__(deps[i], locals); 743 } 744 745 var argNames = ['mod', 'imprt', 'jsolait']; 746 var args = []; 747 748 args.push(newMod); 749 args.push(new Function("","")); 750 args.push(mod); 751 752 for(var key in locals){ 753 argNames.push(key); 754 args.push(locals[key]); 755 } 756 757 var modFn = new Function(argNames.join(","), source); 758 709 759 try{//to run the module source 710 modFn. call(newMod, newMod, privateScope, locals);760 modFn.apply(newMod, args); 711 761 }catch(e){ 712 throw new CreateModuleFailed(newMod, e);762 throw new mod.CreateModuleFailed(newMod, e); 713 763 } 714 764 715 765 applyNames(newMod); 716 applyNames(privateScope); 717 718 modules[name] = newMod; 766 mod.modules[name] = newMod; 719 767 return newMod; 720 };721 722 publ.createModuleFromSource=function(name, source, sourceURI){723 var modFn = new Function("publ,priv,__builtin__", "with(__builtin__){with(publ){with(priv){\n" + source + "\n}}}");724 return createModule(name, source, sourceURI, modFn);725 768 }; 726 769 727 publ.Module = function(name, modFn){728 return createModule(name, str(modFn), '', modFn);770 mod.Module = function(name, modFn){ 771 return mod.createModule(name, str(modFn), '', modFn); 729 772 }; 730 773 … … 835 878 if(sf){ 836 879 if(sf.join("") != this){ 837 throw new Exception("Unsupported formating string.");838 } 839 }else{ 840 throw new Exception("Unsupported formating string.");880 throw new mod.Exception("Unsupported formating string."); 881 } 882 }else{ 883 throw new mod.Exception("Unsupported formating string."); 841 884 } 842 885 var rslt=""; … … 853 896 }else if(s=="%s"){ //making %s faster 854 897 if(cnt>=arguments.length){ 855 throw new Exception("Not enough arguments for format string.");898 throw new mod.Exception("Not enough arguments for format string."); 856 899 }else{ 857 900 obj=arguments[cnt]; … … 870 913 obj = arguments[0][frmt.key]; 871 914 }else{ 872 throw new Exception("Object or associative array expected as formating value.");915 throw new mod.Exception("Object or associative array expected as formating value."); 873 916 } 874 917 }else{//get the current value 875 918 if(cnt>=arguments.length){ 876 throw new Exception("Not enough arguments for format string.");919 throw new mod.Exception("Not enough arguments for format string."); 877 920 }else{ 878 921 obj=arguments[cnt]; … … 899 942 s=pad(obj, frmt.paddingFlag, frmt.minLength); 900 943 }else{ 901 throw new Exception("Character of length 1 required.");944 throw new mod.Exception("Character of length 1 required."); 902 945 } 903 946 }else{ 904 throw new Exception("Character or Byte required.");947 throw new mod.Exception("Character or Byte required."); 905 948 } 906 949 }else if(typeof obj == "number"){ … … 961 1004 s=pad(s, frmt.paddingFlag, frmt.minLength);//do padding and justifiing 962 1005 }else{ 963 throw new Exception("Number required.");1006 throw new mod.Exception("Number required."); 964 1007 } 965 1008 } … … 1018 1061 }; 1019 1062 1020 applyNames( publ);1021 1022 return publ;1023 } }}({}));1063 applyNames(mod); 1064 1065 return mod; 1066 }({})); branches/experimental/jsolait/jsolait.wsf
r72 r73 33 33 <script language="JavaScript"> <![CDATA[ 34 34 35 jsolait.Module("jsolaitws", function( publ,priv,__builtin__){with(publ){with(priv){with(__builtin__){36 __version__ = "$Revision$"37 __sourceURI__ = 'file://' + WScript.scriptFullName;35 jsolait.Module("jsolaitws", function(mod){ 36 mod.__version__ = "$Revision$" 37 mod.__sourceURI__ = 'file://' + WScript.scriptFullName; 38 38 jsolait.__sourceURI__ = 'file://' + WScript.scriptFullName.slice(0,-3) + "js"; 39 39 … … 83 83 } 84 84 85 publ.run=function(){85 mod.run=function(){ 86 86 87 87 if (WScript.arguments.unnamed.length==0){ … … 106 106 } 107 107 108 if(fileName.toLowerCase() != jsolait.__sourceURI__.toLowerCase() && fileName.toLowerCase() != __sourceURI__.toLowerCase()){108 if(fileName.toLowerCase() != jsolait.__sourceURI__.toLowerCase() && fileName.toLowerCase() != mod.__sourceURI__.toLowerCase()){ 109 109 var src = jsolait.loadURI(fileName); 110 111 110 var modl = jsolait.createModuleFromSource("__main__", src, fileName); 112 111 try{ … … 123 122 break; 124 123 default: 125 args = repr(args);124 args = jsolait.repr(args); 126 125 } 127 126 f=new Function( "return " + args); … … 134 133 modl.__main__.apply(modl, args); 135 134 }catch(e){ 136 throw new Exception("runing %s __main__() failed\n".format(modl),e)135 throw new mod.Exception("runing %s __main__() failed\n".format(modl),e) 137 136 } 138 137 } … … 140 139 } 141 140 }; 142 } }}});141 }); 143 142 144 143 try{ branches/experimental/jsolait/lib/asyncimprt.js
r72 r73 1 1 2 2 Error.prototype.toString=function(){ 3 return this.message; 4 5 } 3 6 var applyNames=function(container){ 4 7 for(var n in container){ branches/experimental/jsolait/lib/codecs.js
r68 r73 1 1 /* 2 Copyright (c) 2004-200 6Jan-Klaas Kollhof2 Copyright (c) 2004-2005 Jan-Klaas Kollhof 3 3 4 4 This file is part of the JavaScript o lait library(jsolait). … … 28 28 @lastchangeddate $Date$ 29 29 */ 30 __version__ = "$Revision$"; 31 30 mod.__version__ = "$Revision$"; 32 31 /** 33 32 Returns all all available encoders. 34 33 @return An array of encoder names. 35 34 **/ 36 publ.listEncoders=function(){35 mod.listEncoders=function(){ 37 36 var c=[]; 38 37 for(var attr in String.prototype){ … … 47 46 @return An array of decoder names. 48 47 **/ 49 publ.listDecoders=function(){48 mod.listDecoders=function(){ 50 49 var c=[]; 51 50 for(var attr in String.prototype){ … … 71 70 return String.prototype[n].apply(this, args); 72 71 }else{ 73 throw new Exception("Decoder '%s' not found.".format(codec));72 throw new mod.Exception("Decoder '%s' not found.".format(codec)); 74 73 } 75 74 }; … … 89 88 return String.prototype[n].apply(this, args); 90 89 }else{ 91 throw new Exception("Ecnoder '%s' not found.".format(codec));90 throw new mod.Exception("Ecnoder '%s' not found.".format(codec)); 92 91 } 93 92 }; … … 117 116 } 118 117 }else{ 119 throw new Exception("String length must be divisible by 4.");118 throw new mod.Exception("String length must be divisible by 4."); 120 119 } 121 120 }; … … 222 221 return out.join(""); 223 222 }; 224 branches/experimental/jsolait/lib/crypto.js
r68 r73 1 1 /* 2 Copyright (c) 2003 -2006Jan-Klaas Kollhof2 Copyright (c) 2003 Jan-Klaas Kollhof 3 3 4 4 This file is part of the JavaScript o lait library(jsolait). … … 27 27 @lastchangeddate $Date$ 28 28 */ 29 __version__ = "$Revision$"; 30 29 mod.__version__="$Revision$"; 31 30 /** 32 31 Returns all all available encrypters. 33 32 @return An array of encrypters names. 34 33 **/ 35 publ.listEncrypters=function(){34 mod.listEncrypters=function(){ 36 35 var c=[]; 37 36 for(var attr in String.prototype){ … … 46 45 @return An array of decrypters names. 47 46 **/ 48 publ.listDecrypters=function(){47 mod.listDecrypters=function(){ 49 48 var c=[]; 50 49 for(var attr in String.prototype){ … … 70 69 return String.prototype[n].apply(this, args); 71 70 }else{ 72 throw new Exception("Decrypter '%s' not found.".format(crydec));71 throw new mod.Exception("Decrypter '%s' not found.".format(crydec)); 73 72 } 74 73 }; … … 87 86 return String.prototype[n].apply(this, args); 88 87 }else{ 89 throw new Exception("Encrypter '%s' not found.".format(crydec));88 throw new mod.Exception("Encrypter '%s' not found.".format(crydec)); 90 89 } 91 90 }; branches/experimental/jsolait/lib/dom.js
r68 r73 1 1 /* 2 Copyright (c) 2005 -2006Jan-Klaas Kollhof2 Copyright (c) 2005 Jan-Klaas Kollhof 3 3 4 4 This file is part of the JavaScript o lait library(jsolait). … … 25 25 @lastchangeddate $Date$ 26 26 **/ 27 28 __version__ = "$Revision$"; 27 mod.__version__="$Revision$"; 29 28 30 29 imprt("sets"); … … 33 32 Event class. 34 33 **/ 35 publ.Event=Class(function(publ, supr){34 mod.Event=Class(function(publ, supr){ 36 35 publ.__init__=function(type, target){ 37 36 this.type = type; … … 48 47 An EventTarget implementation. 49 48 **/ 50 publ.EventTarget =Class(function(publ, supr){49 mod.EventTarget =Class(function(publ, supr){ 51 50 publ.__init__=function(){ 52 51 this.eventListeners={}; … … 99 98 It forwards all events to handler methods using the evt.type as the name for the method. 100 99 **/ 101 publ.EventListener=Class(function(publ){100 mod.EventListener=Class(function(publ){ 102 101 /** 103 102 Handles events dispatched by an EventTarget. … … 115 114 A combination of an EventTarget and a EventListener. 116 115 **/ 117 publ.EventListenerTarget=Class(EventTarget,EventListener, function(publ, supr){116 mod.EventListenerTarget=Class(mod.EventTarget, mod.EventListener, function(publ, supr){ 118 117 }); branches/experimental/jsolait/lib/forms.js
r68 r73 1 1 /* 2 Copyright (c) 2005 -2006Jan-Klaas Kollhof2 Copyright (c) 2005 Jan-Klaas Kollhof 3 3 4 4 This file is part of the JavaScript O Lait library(jsolait). … … 28 28 **/ 29 29 30 __version__="$Revision$";30 mod.__version__="$Revision$"; 31 31 /** 32 32 A class that resembles the functionality of an HTML form. … … 34 34 by accessing the element as a named property of the form object(formObj.elemName ...). 35 35 **/ 36 publ.Form=Class(function(publ, supr){36 mod.Form=Class(function(publ, supr){ 37 37 ///Contains the form elements. 38 38 publ.elements=[]; … … 68 68 } 69 69 if(f == null){//add a new element 70 f = new Element(name, value);70 f = new mod.Element(name, value); 71 71 this.elements.push(f); 72 72 } … … 164 164 A form element class. 165 165 **/ 166 publ.Element=Class(function(publ, supr){166 mod.Element=Class(function(publ, supr){ 167 167 ///The name of the element. 168 168 publ.name=""; … … 188 188 }) ; 189 189 190 publ.__main__=function(){191 var fm = new Form("http://localhost/echoform.py", "get");190 mod.__main__=function(){ 191 var fm = new mod.Form("http://localhost/echoform.py", "get"); 192 192 print("testing all sorts of chars, the should be encoded."); 193 193 fm.set("testchars", "abcdefghijklmnopqrstuvwxyz1234567890 \n\t!@#$%^&*()_+-=[]{};'\\:\"|,./<>?"); branches/experimental/jsolait/lib/itertools.js
r68 r73 43 43 @lastchangeddate $Date$ 44 44 **/ 45 __version__ = "$Revision$" 46 45 mod.__version__="$Revision$"; 47 46 48 47 /** 49 48 Base class for Iterators. 50 49 **/ 51 publ.Iterator=Class(function(publ, supr){50 mod.Iterator=Class(function(publ, supr){ 52 51 /** 53 52 Returns the next item in the iteration. … … 124 123 125 124 publ.replace = function(item){ 126 throw new Exception("Iterator::replace() not implemented");125 throw new mod.Exception("Iterator::replace() not implemented"); 127 126 }; 128 127 }); … … 131 130 A simple range class to iterate over a range of numbers. 132 131 **/ 133 publ.Range =Class(Iterator, function(publ, supr){132 mod.Range =Class(mod.Iterator, function(publ, supr){ 134 133 /** 135 134 Initializes a new range. … … 185 184 @param step=1 The steps between each Item. 186 185 **/ 187 publ.range = function(start, end, step){ 188 var r=Range.__create__(arguments); 186 mod.range = function(start, end, step){ 187 var r=new mod.Range(Class); 188 r.__init__.apply(r, arguments); 189 189 return r; 190 190 }; … … 193 193 Iterator for Arrays. 194 194 **/ 195 publ.ArrayItereator=Class(Iterator, function(publ, supr){195 mod.ArrayItereator=Class(mod.Iterator, function(publ, supr){ 196 196 publ.__init__=function(array){ 197 197 this.array = array; … … 241 241 242 242 Array.prototype.__iter__ = function(){ 243 return new ArrayItereator(this);243 return new mod.ArrayItereator(this); 244 244 }; 245 245 … … 247 247 Iterator for Objects. 248 248 **/ 249 publ.ObjectIterator=Class(Iterator, function(publ, supr){249 mod.ObjectIterator=Class(mod.Iterator, function(publ, supr){ 250 250 publ.__init__=function(obj){ 251 251 this.obj = obj; … … 284 284 @return An iterator object or the return value returned by the callback. 285 285 **/ 286 publ.iter=function(iterable, thisObj, cb){286 mod.iter=function(iterable, thisObj, cb){ 287 287 var iterator; 288 288 if(iterable.__iter__ !==undefined){ 289 289 iterator = iterable.__iter__(); 290 290 }else if(iterable.length != null){ 291 iterator = new ArrayItereator(iterable);291 iterator = new mod.ArrayItereator(iterable); 292 292 }else if(iterable.constructor == Object){ 293 iterator = new ObjectIterator(iterable);293 iterator = new mod.ObjectIterator(iterable); 294 294 }else{ 295 throw new Exception("Iterable object does not provide __iter__ method or no Iterator found.");295 throw new mod.Exception("Iterable object does not provide __iter__ method or no Iterator found."); 296 296 } 297 297 if(arguments.length==1){ … … 311 311 @param iteration The Iteration object handling the iteration. 312 312 **/ 313 publ.IterationCallback = function(item, iteration){};313
