Changeset 79
- Timestamp:
- 11/08/06 12:38:41 (2 years ago)
- Files:
-
- branches/experimental/jsolait/lib/codecs.js (modified) (2 diffs)
- branches/experimental/jsolait/lib/crypto.js (modified) (2 diffs)
- branches/experimental/jsolait/lib/forms.js (modified) (1 diff)
- branches/experimental/jsolait/lib/itertools.js (modified) (7 diffs)
- branches/experimental/jsolait/lib/jsonrpc.js (modified) (2 diffs)
- branches/experimental/jsolait/lib/logging.js (modified) (9 diffs)
- branches/experimental/jsolait/lib/operators.js (modified) (9 diffs)
- branches/experimental/jsolait/lib/strings.js (modified) (1 diff)
- branches/experimental/jsolait/lib/testing.js (modified) (18 diffs)
- branches/experimental/jsolait/lib/urllib.js (modified) (5 diffs)
- branches/experimental/jsolait/lib/xml.js (modified) (3 diffs)
- branches/experimental/jsolait/lib/xmlrpc.js (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
branches/experimental/jsolait/lib/codecs.js
r77 r79 33 33 @return An array of encoder names. 34 34 **/ 35 deflistEncoders(){35 publ listEncoders(){ 36 36 var c=[]; 37 37 for(var attr in String.prototype){ … … 46 46 @return An array of decoder names. 47 47 **/ 48 deflistDecoders(){48 publ listDecoders(){ 49 49 var c=[]; 50 50 for(var attr in String.prototype){ branches/experimental/jsolait/lib/crypto.js
r77 r79 32 32 @return An array of encrypters names. 33 33 **/ 34 deflistEncrypters(){34 publ listEncrypters(){ 35 35 var c=[]; 36 36 for(var attr in String.prototype){ … … 45 45 @return An array of decrypters names. 46 46 **/ 47 deflistDecrypters(){47 publ listDecrypters(){ 48 48 var c=[]; 49 49 for(var attr in String.prototype){ branches/experimental/jsolait/lib/forms.js
r77 r79 190 190 }) ; 191 191 192 def__main__(){192 publ __main__(){ 193 193 var fm = new Form("http://localhost/echoform.py", "get"); 194 194 print("testing all sorts of chars, that should be encoded."); branches/experimental/jsolait/lib/itertools.js
r77 r79 185 185 @param step=1 The steps between each Item. 186 186 **/ 187 defrange(start, end, step){187 publ range(start, end, step){ 188 188 var r=new Range(Class); 189 189 r.__init__.apply(r, arguments); … … 285 285 @return An iterator object or the return value returned by the callback. 286 286 **/ 287 defiter(iterable, thisObj, cb){287 publ iter(iterable, thisObj, cb){ 288 288 var iterator; 289 289 if(iterable.__iter__ !==undefined){ … … 312 312 @param iteration The Iteration object handling the iteration. 313 313 **/ 314 defIterationCallback(item, iteration){};314 publ IterationCallback(item, iteration){}; 315 315 316 316 /** … … 322 322 @return A list containing all elements that were filtered. 323 323 **/ 324 deffilter(iterable, thisObj,cb){324 publ filter(iterable, thisObj,cb){ 325 325 var iterator = iter(iterable); 326 326 if(cb == null){ … … 339 339 @return A list containing new elements. 340 340 **/ 341 defmap(iterable, thisObj, cb){341 publ map(iterable, thisObj, cb){ 342 342 var iterator = iter(iterable); 343 343 if(cb == null){ … … 355 355 @return A list containing all elements. 356 356 **/ 357 deflist(iterable){357 publ list(iterable){ 358 358 return iter(iterable).__list__(); 359 359 }; … … 390 390 @return a Zipper iterator. 391 391 **/ 392 defzip(iterable){392 publ zip(iterable){ 393 393 var iterators =[]; 394 394 for(var i=0;i<arguments.length;i++){ branches/experimental/jsolait/lib/jsonrpc.js
r77 r79 87 87 @return An xml representation of the object. 88 88 **/ 89 defmarshall(obj){89 publ marshall(obj){ 90 90 if(obj == null){ 91 91 return "null"; … … 108 108 @return The JavaScript object created. 109 109 **/ 110 defunmarshall(source){110 publ unmarshall(source){ 111 111 try { 112 112 var obj; branches/experimental/jsolait/lib/logging.js
r77 r79 18 18 19 19 20 defgetLevelName(lvl){20 publ getLevelName(lvl){ 21 21 return levelNames[lvl]; 22 22 }; 23 defsetLevelName(lvl, name){23 publ setLevelName(lvl, name){ 24 24 levelNames[lvl]=name; 25 25 }; 26 26 27 defdebug(msg){27 publ debug(msg){ 28 28 if(rootLogger.handlers.length==0){ 29 29 basicConfig(0); … … 32 32 }; 33 33 34 definfo(msg){34 publ info(msg){ 35 35 if(rootLogger.handlers.length==0){ 36 36 basicConfig(0); … … 39 39 }; 40 40 41 defwarning(msg){41 publ warning(msg){ 42 42 if(rootLogger.handlers.length==0){ 43 43 basicConfig(0); … … 46 46 }; 47 47 48 deferror(msg, args){48 publ error(msg, args){ 49 49 if(rootLogger.handlers.length==0){ 50 50 basicConfig(0); … … 53 53 }; 54 54 55 defcritical(msg, args){55 publ critical(msg, args){ 56 56 if(rootLogger.handlers.length==0){ 57 57 basicConfig(0); … … 60 60 }; 61 61 62 deflog(level, msg, args){62 publ log(level, msg, args){ 63 63 if(rootLogger.handlers.length==0){ 64 64 basicConfig(0); … … 264 264 265 265 266 defbasicConfig(level, format){266 publ basicConfig(level, format){ 267 267 268 268 if(rootLogger.handlers.length == 0){ … … 281 281 var loggers={}; 282 282 283 defgetLogger(name){283 publ getLogger(name){ 284 284 if(name==undefined){ 285 285 l=rootLogger; … … 301 301 }; 302 302 303 defgetLoggerClass(){303 publ getLoggerClass(){ 304 304 return loggerClass; 305 305 }; 306 306 307 defsetLoggerClass(lc){307 publ setLoggerClass(lc){ 308 308 loggerClass=lc; 309 309 }; branches/experimental/jsolait/lib/operators.js
r77 r79 29 29 __version__= "$Revision: 20 $"; 30 30 31 deflt(a, b){31 publ lt(a, b){ 32 32 if((a!=null) && (a.__lt__!==undefined)){ 33 33 return a.__lt__(b); … … 39 39 }; 40 40 41 defle(a, b){41 publ le(a, b){ 42 42 if((a!=null) && (a.__le__!==undefined)){ 43 43 return a.__le__(b); … … 49 49 }; 50 50 51 defeq(a, b){51 publ eq(a, b){ 52 52 if((a!=null) && (a.__eq__!==undefined)){ 53 53 return a.__eq__(b); … … 59 59 }; 60 60 61 defne(a, b){61 publ ne(a, b){ 62 62 if((a!=null) && (a.__ne__!==undefined)){ 63 63 return a.__ne__(b); … … 69 69 }; 70 70 71 defis(a,b){71 publ is(a,b){ 72 72 if((a!=null) && (a.__is__!==undefined)){ 73 73 return a.__is__(b); … … 79 79 }; 80 80 81 defisnot(a,b){81 publ isnot(a,b){ 82 82 if((a!=null) && (a.__isnot__!==undefined)){ 83 83 return a.__isnot__(b); … … 89 89 }; 90 90 91 defge(a, b){91 publ ge(a, b){ 92 92 if((a!=null) && (a.__ge__!==undefined)){ 93 93 return a.__ge__(b); … … 99 99 }; 100 100 101 defgt(a, b){101 publ gt(a, b){ 102 102 if((a!=null) && (a.__gt__!==undefined)){ 103 103 return a.__gt__(b); … … 109 109 }; 110 110 111 defnot(a){111 publ not(a){ 112 112 if((a!=null) && (a.__not__!==undefined)){ 113 113 return a.__not__(); branches/experimental/jsolait/lib/strings.js
r77 r79 35 35 }); 36 36 37 defnaturalCompare(a, b){37 publ naturalCompare(a, b){ 38 38 var asplitter=new WordNumberStringSplitter(a); 39 39 var bsplitter=new WordNumberStringSplitter(b); branches/experimental/jsolait/lib/testing.js
r77 r79 39 39 @param ... The rest of the parameters are sent to the function as arguments. 40 40 */ 41 deftimeExec(repeat, fn){41 publ timeExec(repeat, fn){ 42 42 var args = []; 43 43 for(var i=2;i<arguments.length;i++){ … … 58 58 @return The time it took to run the function a single time. The time is averaged by the total time/repetitions 59 59 **/ 60 defprofile(min,fn){60 publ profile(min,fn){ 61 61 if(arguments.length==1){ 62 62 fn=min; … … 134 134 @param testScope A function to test. 135 135 **/ 136 deftest(name, testScope){136 publ test(name, testScope){ 137 137 if(arguments.length == 1){ 138 138 testScope = name; … … 147 147 Tests a module by running each of the modules test_ methods; 148 148 **/ 149 deftestModule(modObj){149 publ testModule(modObj){ 150 150 151 151 for(var key in modObj){ … … 173 173 @param failMsg='' A message to pass to the AssertFailed constructor in case the assertion fails. 174 174 **/ 175 defassert(comment, value, failMsg){175 publ assert(comment, value, failMsg){ 176 176 if(typeof comment == 'boolean'){ 177 177 failMsg=value; … … 190 190 @param value A boolean to test. 191 191 **/ 192 defassertTrue(comment, value){192 publ assertTrue(comment, value){ 193 193 if(arguments.length==1){ 194 194 value = comment; … … 203 203 @param value A boolean to test. 204 204 **/ 205 defassertFalse(comment, value){205 publ assertFalse(comment, value){ 206 206 if(arguments.length==1){ 207 207 value = comment; … … 216 216 @param value A boolean to test. 217 217 **/ 218 defassertEquals(comment, value1, value2){218 publ assertEquals(comment, value1, value2){ 219 219 if(arguments.length==2){ 220 220 value2=value1; … … 225 225 }; 226 226 227 defassertNotEquals(comment, value1, value2){227 publ assertNotEquals(comment, value1, value2){ 228 228 if(arguments.length==2){ 229 229 value2=value1; … … 234 234 }; 235 235 236 defassertIs(comment, value1, value2){236 publ assertIs(comment, value1, value2){ 237 237 if(arguments.length==2){ 238 238 value2=value1; … … 243 243 }; 244 244 245 defassertIsNot(comment, value1, value2){245 publ assertIsNot(comment, value1, value2){ 246 246 if(arguments.length==2){ 247 247 value2=value1; … … 252 252 }; 253 253 254 defassertNull(comment, value){254 publ assertNull(comment, value){ 255 255 if(arguments.length==1){ 256 256 value = comment; … … 260 260 }; 261 261 262 defassertNotNull(comment, value){262 publ assertNotNull(comment, value){ 263 263 if(arguments.length==1){ 264 264 value = comment; … … 268 268 }; 269 269 270 defassertUndefined(comment, value){270 publ assertUndefined(comment, value){ 271 271 if(arguments.length==1){ 272 272 value = comment; … … 276 276 }; 277 277 278 defassertNotUndefined(comment, value){278 publ assertNotUndefined(comment, value){ 279 279 if(arguments.length==1){ 280 280 value = comment; … … 284 284 }; 285 285 286 defassertNaN(comment, value){286 publ assertNaN(comment, value){ 287 287 if(arguments.length==1){ 288 288 value = comment; … … 292 292 }; 293 293 294 defassertNotNaN(comment, value){294 publ assertNotNaN(comment, value){ 295 295 if(arguments.length==1){ 296 296 value = comment; … … 300 300 }; 301 301 302 deffail(comment){302 publ fail(comment){ 303 303 throw new AssertFailed(comment, "Fail was called"); 304 304 }; 305 305 306 defobjectKeys(obj){306 publ objectKeys(obj){ 307 307 var keys=[]; 308 308 for(var n in obj){ branches/experimental/jsolait/lib/urllib.js
r77 r79 144 144 @return HTTP request object. 145 145 */ 146 defgetHTTP() {146 publ getHTTP() { 147 147 var obj; 148 148 try{ //to get the mozilla httprequest object … … 199 199 @return HTTP request object. 200 200 */ 201 defsendRequest(type, url, user, pass, data, headers, callback){201 publ sendRequest(type, url, user, pass, data, headers, callback){ 202 202 var async=false; 203 203 //check if the last argument is a function and treat it as callback; … … 293 293 @return HTTP request object. 294 294 */ 295 defgetURL(url, user, pass, headers, callback) {295 publ getURL(url, user, pass, headers, callback) { 296 296 var a=["GET"]; 297 297 for(var i=0;i<arguments.length;i++){ … … 312 312 @return HTTP request object. 313 313 */ 314 defpostURL(url, user, pass, data, headers, callback) {314 publ postURL(url, user, pass, data, headers, callback) { 315 315 var a= ["POST"]; 316 316 for(var i=0;i<arguments.length;i++){ … … 325 325 @return True if the module can make HTTP requests, false otherwise. 326 326 **/ 327 defisUsable(){327 publ isUsable(){ 328 328 try{ 329 329 getHTTP(); branches/experimental/jsolait/lib/xml.js
r77 r79 67 67 @return A DOM of the xml document. 68 68 */ 69 defparseXML(xml){69 publ parseXML(xml){ 70 70 var obj=null; 71 71 var isMoz=false; … … 125 125 @return The imported Node. 126 126 */ 127 defimportNode(importedNode, deep){127 publ importNode(importedNode, deep){ 128 128 deep = (deep==null) ? true : deep; 129 129 //constants from doom2 … … 225 225 @return A string containing the text for the XML. 226 226 */ 227 defnode2XML(node, nsPrefixMap, attrParent){227 publ node2XML(node, nsPrefixMap, attrParent){ 228 228 nsPrefixMap = (nsPrefixMap == null)?{}:nsPrefixMap; 229 229 var ELEMENT_NODE = 1; branches/experimental/jsolait/lib/xmlrpc.js
r77 r79 94 94 @return An xml representation of the object. 95 95 */ 96 defmarshall(obj){96 publ marshall(obj){ 97 97 if(obj.toXmlRpc!=null){ 98 98 return obj.toXmlRpc(); … … 115 115 @return The JavaScript object created from the XML. 116 116 */ 117 defunmarshall(xml){117 publ unmarshall(xml){ 118 118 try {//try to parse xml ... this will throw an Exception if failed 119 119 var doc = parseXML(xml); … … 132 132 @return The JavaScript object created from the XML. 133 133 */ 134 defunmarshallDoc(doc, xml){134 publ unmarshallDoc(doc, xml){ 135 135 try{ 136 136 var node = doc.documentElement; … … 815 815 816 816 817 def__main__(){817 publ __main__(){ 818 818 var s = new ServiceProxy("http://jsolait.net/test.py",['echo']); 819 819 print("creating ServiceProxy object using introspection for method construction...\n");
