-
-
- apply : function(o, c, defaults){
- if(defaults){
- // no "this" reference for friendly out of scope calls
- JSDOC.apply(o, defaults);
- }
- if(o && c && typeof c == 'object'){
- for(var p in c){
- o[p] = c[p];
- }
- }
- return o;
- },
+
-
- /**
- * Qdump is used to generated cache dumps of objects
- * @arg mixed t - object/array to dump
- * @arg string prefix output with
- * @arg string suffix output with
- * @arg mixed defaults for the object - so they are not dumped..
- */
-
- toQDump : function(t, pref, suf, defs)
- {
- //println("got ToDump: " + pref +" ??? " + suf);
- //var ret = "JSDOC.Symbol.fromDump(";
- var qret = "";
- defs = (typeof(defs) == "undefined") ? {} : defs;
-
- var isAr = t.constructor == Array;
- var k = '';
- var v = '';
- for (var i in t) {
- // println("dump: " + i + " : " +typeof(t[i]));
-
- if (!isAr) {
- k = typeof(i) == "number" ? i +":" : i.toSource()+":" ;
- } else {
- if (typeof(i) != "number") {
- continue;
- }
-
- }
-
- v = t[i];
- //} else {
- // v = i;
- //}
-
-
-
- var def = defs[i];
- //if ((typeof(defs[i]) != 'undefined') && (v.toSource() == defs[i]).toSource()) {
- // continue;
- //}
-
-
-
-
- switch(typeof(v)) {
- case "function":
- continue;
-
-
-
- case 'string':
- if (def == v) {
- continue;
- }
-
- if (!v.length) { // ?? skip empty!!
- continue;
- }
-
- if (qret.length) {
- qret+=",";
- }
-
- qret += k + v.toSource();
- continue;
- case 'boolean':
-
- case 'number':
- if (def == v) {
- continue;
- }
- if (qret.length) {
- qret+=",";
- }
-
- qret += k + v;
-
- continue;
-
- // undefined?
- case "object":
-
- //if (i == 'tags') {
- // println(k +"?:" + (v.constructor == Array ? "ARRAY" : "OBJECT"));
- //}
-
- // what about raw objects...
- if (v.constructor == Array) {
- //println("ARRAYLEN:" + v.length);
- var toadd = JSDOC.toQDump(v, '[', ']');
- if (k == 'tags') {
- println("Array: " + toadd);
- }
-
- if (toadd == "[]") {
- continue;
- }
-
- if (qret.length) {
- qret+=",";
- }
- qret += k + toadd;
- //println("AFT AR:" + qret);
- continue;
- }
- if (v.constructor == Object) {
- var toadd = JSDOC.toQDump(v, '{', '}');
- if (toadd == "{}") {
- continue;
- }
-
- if (qret.length) {
- qret+=",";
- }
- qret += k + toadd;
- //println("AFT AR:" + qret);
- continue;
- }
- //println("v:toQdump" + typeof(v['toQDump']));
- if (typeof(v['toQDump']) != "undefined") {
- if (qret.length) {
- qret+=",";
- }
-
- qret += k + v.toQDump(v);
- continue;
- }
- println("SKIP " + i + " : " +typeof(t[i]) + ":" + t[i].toSource());
- continue;
-
- default:
- println("SKIP " + i + " : " +typeof(t[i]) );
-
- continue;
-
- }
- }
- // println(qret);
- //throw "done";
- return pref + qret + suf;
- },
- /**
- *
- * Depreciated - use Script.prettyDump() - cant remember real name..
- *
- *
- */
-
- prettyDump : function(src)
- {
- // println("tidy SRC");
- return Script.prettyDump(src);
- /*
- var ar = Script.tokenize(src);
- println("tidy" + ar.length);
- var eret = '';
- var indent = "";
- var lbr = 0;
-
- // this is reallllllllly sloooooowwwwww!!! = perhaps we should just dump it straight to the file!!!
-
- for( var i =0 ;i< ar.length; i++) {
-
- //println(ar[i].toSource());
- var tok = ar[i];
- //println("tidy" + i + ":" + tok.val);
- if ( (tok.val == '{') || (tok.val == '[') || (tok.val == '(') ) {
- indent += " ";
- eret += tok.val;
- lbr = true;
- continue;
- }
- if ( (tok.val == '}') || (tok.val == ']') || (tok.val == ')') ) {
-
- indent = indent.substring(2); // strip spaces..
- if (i < (ar.length-1) && ar[i+1].val == ',') {
- ar[i].val +=",";
- i++;
-
- }
- eret += (lbr ? "" : "\n" + indent ) + tok.val ;
- lbr = true;
- continue;
- }
- if ( (tok.val == ',')) {
- eret += tok.val;
- lbr = true;
- continue;
- }
- if (lbr) {
- eret += "\n" + indent;
- }
- lbr = false;
- eret += tok.val;
-
-
- }
- return eret;
- */
- }
-
+
+
};