JSDOC/Symbol.js
[gnome.introspection-doc-generator] / JSDOC / Symbol.js
1 //<script type="text/javascript">
2
3 XObject         = imports.XObject.XObject;
4
5 SymbolSet       = imports.SymbolSet.SymbolSet;
6 //Parser          = imports.Parser.Parser;
7 DocComment      = imports.DocComment.DocComment;
8 DocTag          = imports.DocTag.DocTag;
9 /**
10         Create a new Symbol.
11         @class Represents a symbol in the source code.
12  */
13 Symbol = XObject.define(
14     function() {
15         this.init();
16         if (arguments.length) this.populate.apply(this, arguments);
17         
18     },
19     Object,
20     {
21         
22             
23         
24         toObject : function()
25         {
26             
27             function array2object(a , m)
28             {
29                 m = m || false;
30                 var r = [];
31                 a.forEach(function(e) {
32                     r.push(m ? e : e.toObject());
33                 }
34             }
35             var ret = { };
36             for (var i in this) {
37                 switch (typeof(this[i])) {
38                     case 'function':
39                         continue;
40                     case 'object':
41                     
42                         print("object? :" + i);
43                         Seed.quit();
44                     case 'string':
45                     case 'number':
46                         ret[i] = this[i]; continue;
47                     default:
48                         print("unknown type:" + typeof(this[i]));
49                         Seed.quit();
50                    }
51             }
52             
53             
54         },
55         
56         init : function() 
57         {
58             this.name = "";
59             this.defaultValue = "";
60             this.params = [];
61             this.$args = [];
62             this.addOn = "";
63             this.alias = "";
64             this.augments = [];
65             this.author = "";
66             this.classDesc = "";
67             this.comment = { isUserComment: false };
68             //this.defaultValue = null;
69             this.deprecated = "";
70             this.desc = "";
71             this.events = [];
72             this.example = "";
73             this.exceptions = [];
74             this.inherits = [];
75             this.inheritsFrom = [];
76             this.isa = "OBJECT"; // OBJECT//FUNCTION
77             this.isEvent = false;
78             this.isConstant = false;
79             this.isIgnored = false;
80             this.isInner = false;
81             this.isNamespace = false;
82             this.isPrivate = false;
83             this.isStatic = false;
84             this.memberOf = "";
85             this.methods = [];
86             this._name = "";
87             this._params = [];
88             this.properties = [];
89             this.requires = [];
90             this.returns = [];
91             this.see = [];
92             this.since = "";
93             this.srcFile = {};
94             this.type = "";
95             this.version = "";
96             this.childClasses = [];
97             this.cfgs = {};
98                
99         },
100
101         serialize : function() {
102             var keys = [];
103             for (var p in this) {
104                 keys.push (p);
105             }
106             keys = keys.sort();
107             
108             var out = "";
109             for (var i in keys) {
110                 if (typeof this[keys[i]] == "function") continue;
111                 out += "     " +keys[i]+" => "+
112                     (   
113                         (typeof(this[keys[i]]) != "object") ?  
114                             this[keys[i]] :
115                             "[" +typeof(this[keys[i]])+"]"
116                     ) + 
117                     ",\n";
118             }
119             return "\n{\n" + out + "}\n";
120         },
121
122         clone : function() {
123             var clone = new Symbol();
124             clone.populate.apply(clone, this.$args); // repopulate using the original arguments
125             clone.srcFile = this.srcFile; // not the current srcFile, the one when the original was made
126             return clone;
127         },
128
129
130
131
132         //__defineSetter__("name",
133         setName  : function(n) { 
134                 n = n.replace(/^_global_[.#-]/, ""); 
135                 n = n.replace(/\.prototype\.?/g, '#'); 
136                  n = n.replace(/#$/g, ''); 
137                 this._name = n;
138                 this.name = n; // real!
139             },
140         //);
141         //__defineGetter__("name",
142         getName : function() { return this._name; },
143         //);
144         //__defineSetter__("params", 
145         setParams  :function(v) {
146                 for (var i = 0, l = v.length; i < l; i++) {
147                     if (v[i].constructor != DocTag) { // may be a generic object parsed from signature, like {type:..., name:...}
148                         var ty = v[i].hasOwnProperty('type') ? v[i].type : '';
149                         this._params[i] = new DocTag(
150                             "param"+((ty)?" {"+ty+"}":"")+" "+v[i].name);
151                     }
152                     else {
153                         this._params[i] = v[i];
154                     }
155                 }
156                 this.params = this._params;
157             },
158         //);
159
160
161         //__defineGetter__("params",
162         getParams : function() { return this._params; },
163         //);
164
165         populate : function(
166                 /** String */ name,
167                 /** Object[] */ params,
168                 /** String */ isa,
169                 /** DocComment */ comment
170         ) {
171             this.$args = arguments;
172             //println("Symbol created: " + isa + ":" + name);
173             this.setName(name);
174             this.alias = this.getName();
175             this.setParams(params);
176             this.isa = (isa == "VIRTUAL")? "OBJECT":isa;
177             this.comment = comment || new DocComment("");
178             this.srcFile = Symbol.srcFile;
179             
180            
181             
182             if (this.is("FILE") && !this.alias) this.alias = this.srcFile;
183
184             this.setTags();
185             
186             //if (typeof PluginManager != "undefined") {
187             //    PluginManager.run("onSymbol", this);
188             //}
189         },
190
191         setTags : function() {
192             // @author
193             var authors = this.comment.getTag("author");
194             if (authors.length) {
195                 this.author = authors.map(function($){return $.desc;}).join(", ");
196             }
197             
198             /*~t
199                 assert("testing Symbol");
200                 
201                 requires("../lib/JSDOC/DocComment.js");
202                 requires("../frame/String.js");
203                 requires("../lib/JSDOC/DocTag.js");
204
205                 var sym = new Symbol("foo", [], "OBJECT", new DocComment("/**@author Joe Smith*"+"/"));
206                 assertEqual(sym.author, "Joe Smith", "@author tag, author is found.");
207             */
208             // @desc
209             var mth = this.comment.getTag("method");
210             if (mth.length) {
211                 this.isa = "FUNCTION";
212             }
213             // @desc
214             var descs = this.comment.getTag("desc");
215             if (descs.length) {
216                 this.desc = descs.map(function($){return $.desc;}).join("\n"); // multiple descriptions are concatenated into one
217             }
218             
219             /*~t
220                 var sym = new Symbol("foo", [], "OBJECT", new DocComment("/**@desc This is a description.*"+"/"));
221                 assertEqual(sym.desc, "This is a description.", "@desc tag, description is found.");
222             */
223             
224             // @overview
225             if (this.is("FILE")) {
226                 if (!this.alias) this.alias = this.srcFile;
227                 
228                 var overviews = this.comment.getTag("overview");
229                 if (overviews.length) {
230                     this.desc = [this.desc].concat(overviews.map(function($){return $.desc;})).join("\n");
231                 }
232             }
233             
234             /*~t
235                 var sym = new Symbol("foo", [], "FILE", new DocComment("/**@overview This is an overview.*"+"/"));
236                 assertEqual(sym.desc, "\nThis is an overview.", "@overview tag, description is found.");
237             */
238             
239             // @since
240             var sinces = this.comment.getTag("since");
241             if (sinces.length) {
242                 this.since = sinces.map(function($){return $.desc;}).join(", ");
243             }
244             
245             /*~t
246                 var sym = new Symbol("foo", [], "FILE", new DocComment("/**@since 1.01*"+"/"));
247                 assertEqual(sym.since, "1.01", "@since tag, description is found.");
248             */
249             
250             // @constant
251             if (this.comment.getTag("constant").length) {
252                 this.isConstant = true;
253                 this.isa = 'OBJECT';
254             }
255             
256             /*~t
257                 var sym = new Symbol("foo", [], "FILE", new DocComment("/**@constant*"+"/"));
258                 assertEqual(sym.isConstant, true, "@constant tag, isConstant set.");
259             */
260             
261             // @version
262             var versions = this.comment.getTag("version");
263             if (versions.length) {
264                 this.version = versions.map(function($){return $.desc;}).join(", ");
265             }
266             
267             /*~t
268                 var sym = new Symbol("foo", [], "FILE", new DocComment("/**@version 2.0x*"+"/"));
269                 assertEqual(sym.version, "2.0x", "@version tag, version is found.");
270             */
271             
272             // @deprecated
273             var deprecateds = this.comment.getTag("deprecated");
274             if (deprecateds.length) {
275                 this.deprecated = deprecateds.map(function($){return $.desc;}).join("\n");
276             }
277             
278             /*~t
279                 var sym = new Symbol("foo", [], "FILE", new DocComment("/**@deprecated Use other method.*"+"/"));
280                 assertEqual(sym.deprecated, "Use other method.", "@deprecated tag, desc is found.");
281             */
282             
283             // @example
284             var examples = this.comment.getTag("example");
285             if (examples.length) {
286                 this.example = examples[0];
287             }
288             
289             /*~t
290                 var sym = new Symbol("foo", [], "FILE", new DocComment("/**@example This\n  is an example.*"+"/"));
291                 assertEqual(sym.example, "This\n  is an example.", "@deprecated tag, desc is found.");
292             */
293             
294             // @see
295             var sees = this.comment.getTag("see");
296             if (sees.length) {
297                 var thisSee = this.see;
298                 sees.map(function($){thisSee.push($.desc);});
299             }
300             
301             /*~t
302                 var sym = new Symbol("foo", [], "FILE", new DocComment("/**@see The other thing.*"+"/"));
303                 assertEqual(sym.see, "The other thing.", "@see tag, desc is found.");
304             */
305             
306             // @class
307             var classes = this.comment.getTag("class");
308             if (classes.length) {
309                 this.isa = "CONSTRUCTOR";
310                 this.classDesc = classes[0].desc; // desc can't apply to the constructor as there is none.
311                 if (!this.classDesc) {
312                     this.classDesc = this.desc;
313                    }
314                 
315                 
316             }
317             
318             /*~t
319                 var sym = new Symbol("foo", [], "OBJECT", new DocComment("/**@class This describes the class.*"+"/"));
320                 assertEqual(sym.isa, "CONSTRUCTOR", "@class tag, makes symbol a constructor.");
321                 assertEqual(sym.classDesc, "This describes the class.", "@class tag, class description is found.");
322             */
323             
324             // @namespace
325             var namespaces = this.comment.getTag("namespace");
326             if (namespaces.length) {
327                 this.classDesc = namespaces[0].desc+"\n"+this.desc; // desc can't apply to the constructor as there is none.
328                 this.isNamespace = true;
329             }
330             
331             /*~t
332                 var sym = new Symbol("foo", [], "OBJECT", new DocComment("/**@namespace This describes the namespace.*"+"/"));
333                 assertEqual(sym.classDesc, "This describes the namespace.\n", "@namespace tag, class description is found.");
334             */
335             
336             // @param
337             var params = this.comment.getTag("param");
338             if (params.length) {
339                 // user-defined params overwrite those with same name defined by the parser
340                 var thisParams = this.getParams();
341
342                 if (thisParams.length == 0) { // none exist yet, so just bung all these user-defined params straight in
343                     this.setParams(params);
344                 }
345                 else { // need to overlay these user-defined params on to existing parser-defined params
346                     for (var i = 0, l = params.length; i < l; i++) {
347                         if (thisParams[i]) {
348                             if (params[i].type) thisParams[i].type = params[i].type;
349                             thisParams[i].name = params[i].name;
350                             thisParams[i].desc = params[i].desc;
351                             thisParams[i].isOptional = params[i].isOptional;
352                             thisParams[i].defaultValue = params[i].defaultValue;
353                         }
354                         else thisParams[i] = params[i];
355                     }
356                 }
357             }
358             
359             /*~t
360                 var sym = new Symbol("foo", [{type: "array", name: "pages"}], "FUNCTION", new DocComment("/**Description.*"+"/"));
361                 assertEqual(sym.params.length, 1, "parser defined param is found.");
362                 
363                 sym = new Symbol("foo", [], "FUNCTION", new DocComment("/**Description.\n@param {array} pages*"+"/"));
364                 assertEqual(sym.params.length, 1, "user defined param is found.");
365                 assertEqual(sym.params[0].type, "array", "user defined param type is found.");
366                 assertEqual(sym.params[0].name, "pages", "user defined param name is found.");
367                 
368                 sym = new Symbol("foo", [{type: "array", name: "pages"}], "FUNCTION", new DocComment("/**Description.\n@param {string} uid*"+"/"));
369                 assertEqual(sym.params.length, 1, "user defined param overwrites parser defined param.");
370                 assertEqual(sym.params[0].type, "string", "user defined param type overwrites parser defined param type.");
371                 assertEqual(sym.params[0].name, "uid", "user defined param name overwrites parser defined param name.");
372             
373                 sym = new Symbol("foo", [{type: "array", name: "pages"}, {type: "number", name: "count"}], "FUNCTION", new DocComment("/**Description.\n@param {string} uid*"+"/"));
374                 assertEqual(sym.params.length, 2, "user defined params  overlay parser defined params.");
375                 assertEqual(sym.params[1].type, "number", "user defined param type overlays parser defined param type.");
376                 assertEqual(sym.params[1].name, "count", "user defined param name overlays parser defined param name.");
377
378                 sym = new Symbol("foo", [], "FUNCTION", new DocComment("/**Description.\n@param {array} pages The pages description.*"+"/"));
379                 assertEqual(sym.params.length, 1, "user defined param with description is found.");
380                 assertEqual(sym.params[0].desc, "The pages description.", "user defined param description is found.");
381             */
382             
383             // @constructor
384             if (this.comment.getTag("constructor").length) {
385                 this.isa = "CONSTRUCTOR";
386             }
387             
388             /*~t
389                 var sym = new Symbol("foo", [], "OBJECT", new DocComment("/**@constructor*"+"/"));
390                 assertEqual(sym.isa, "CONSTRUCTOR", "@constructor tag, makes symbol a constructor.");
391             */
392             
393             // @static
394             if (this.comment.getTag("static").length) {
395                 this.isStatic = true;
396                 if (this.isa == "CONSTRUCTOR") {
397                     this.isNamespace = true;
398                 }
399             }
400             
401                 // @static
402             if (this.comment.getTag("singleton").length) {
403                 this.isStatic = true;
404                 //if (this.isa == "CONSTRUCTOR") {
405                 //      this.isNamespace = true;
406                 //}
407             }
408             
409             
410             
411             /*~t
412                 var sym = new Symbol("foo", [], "OBJECT", new DocComment("/**@static\n@constructor*"+"/"));
413                 assertEqual(sym.isStatic, true, "@static tag, makes isStatic true.");
414                 assertEqual(sym.isNamespace, true, "@static and @constructor tag, makes isNamespace true.");
415             */
416             
417             // @inner
418             if (this.comment.getTag("inner").length) {
419                 this.isInner = true;
420                 this.isStatic = false;
421             }
422             
423             /*~t
424                 var sym = new Symbol("foo", [], "OBJECT", new DocComment("/**@inner*"+"/"));
425                 assertEqual(sym.isStatic, false, "@inner tag, makes isStatic false.");
426                 assertEqual(sym.isInner, true, "@inner makes isInner true.");
427             */
428             
429             // @field
430             if (this.comment.getTag("field").length) {
431                 this.isa = "OBJECT";
432             }
433             
434             /*~t
435                 var sym = new Symbol("foo", [], "FUNCTION", new DocComment("/**@field*"+"/"));
436                 assertEqual(sym.isa, "OBJECT", "@field tag, makes symbol an object.");
437             */
438             
439             // @function
440             if (this.comment.getTag("function").length) {
441                 this.isa = "FUNCTION";
442             }
443             
444             // @param
445             if (this.comment.getTag("param").length && this.isa == "OBJECT" ) {
446                 // change a property to a function..
447                 this.isa = "FUNCTION";
448             }
449             
450             
451             /*~t
452                 var sym = new Symbol("foo", [], "OBJECT", new DocComment("/**@function*"+"/"));
453                 assertEqual(sym.isa, "FUNCTION", "@function tag, makes symbol a function.");
454             */
455             
456             // @event
457             var events = this.comment.getTag("event");
458             if (events.length) {
459                 this.isa = "FUNCTION";
460                 this.isEvent = true;
461             }
462             
463             /*~t
464                 var sym = new Symbol("foo", [], "OBJECT", new DocComment("/**@event*"+"/"));
465                 assertEqual(sym.isa, "FUNCTION", "@event tag, makes symbol a function.");
466                 assertEqual(sym.isEvent, true, "@event makes isEvent true.");
467             */
468             
469             // @name
470             var names = this.comment.getTag("name");
471             if (names.length) {
472                 this.setName(names[0].desc);
473             }
474             
475             /*~t
476                 // todo
477             */
478             
479             // @property
480             var properties = this.comment.getTag("property");
481             if (properties.length) {
482                 thisProperties = this.properties;
483                 for (var i = 0; i < properties.length; i++) {
484                     var property = new Symbol(this.alias+"#"+properties[i].name, [], "OBJECT", new DocComment("/**"+properties[i].desc+"\n@name "+properties[i].name+"\n@memberOf "+this.alias+"#*/"));
485                     // TODO: shouldn't the following happen in the addProperty method of Symbol?
486                     property.name = properties[i].name;
487                     property.memberOf = this.alias;
488                     if (properties[i].type) property.type = properties[i].type;
489                     if (properties[i].defaultValue) property.defaultValue = properties[i].defaultValue;
490                     this.addProperty(property);
491                     imports.Parser.Parser.addSymbol(property);
492                 }
493             }
494             
495             // config..
496             var conf = this.comment.getTag("cfg");
497             if (conf.length) {
498                 for (var i = 0; i < conf.length; i++) {
499                     this.addConfig(conf[i]);
500                 }
501             }
502             
503             /*~t
504                 // todo
505             */
506
507             // @return
508             var returns = this.comment.getTag("return");
509             if (returns.length) { // there can be many return tags in a single doclet
510                 this.returns = returns;
511                 this.type = returns.map(function($){return $.type}).join(", ");
512             }
513             
514             /*~t
515                 // todo
516             */
517             
518             // @exception
519             this.exceptions = this.comment.getTag("throws");
520             
521             /*~t
522                 // todo
523             */
524             
525             // @requires
526             var requires = this.comment.getTag("requires");
527             if (requires.length) {
528                 this.requires = requires.map(function($){return $.desc});
529             }
530             
531             /*~t
532                 // todo
533             */
534             
535             // @type
536             var types = this.comment.getTag("type");
537             if (types.length) {
538                 this.type = types[0].desc; //multiple type tags are ignored
539             }
540             
541             /*~t
542                 // todo
543             */
544             
545             // @private
546             if (this.comment.getTag("private").length || this.isInner) {
547                 this.isPrivate = true;
548             }
549             
550             // @ignore
551             if (this.comment.getTag("ignore").length) {
552                 this.isIgnored = true;
553             }
554             
555             /*~t
556                 // todo
557             */
558             
559             // @inherits ... as ...
560             var inherits = this.comment.getTag("inherits");
561             if (inherits.length) {
562                 for (var i = 0; i < inherits.length; i++) {
563                     if (/^\s*([a-z$0-9_.#-]+)(?:\s+as\s+([a-z$0-9_.#]+))?/i.test(inherits[i].desc)) {
564                         var inAlias = RegExp.$1;
565                         var inAs = RegExp.$2 || inAlias;
566
567                         if (inAlias) inAlias = inAlias.replace(/\.prototype\.?/g, "#");
568                         
569                         if (inAs) {
570                             inAs = inAs.replace(/\.prototype\.?/g, "#");
571                             inAs = inAs.replace(/^this\.?/, "#");
572                         }
573
574                         if (inAs.indexOf(inAlias) != 0) { //not a full namepath
575                             var joiner = ".";
576                             if (this.alias.charAt(this.alias.length-1) == "#" || inAs.charAt(0) == "#") {
577                                 joiner = "";
578                             }
579                             inAs = this.alias + joiner + inAs;
580                         }
581                     }
582                     this.inherits.push({alias: inAlias, as: inAs});
583                 }
584             }
585             
586             /*~t
587                 // todo
588             */
589
590             // @augments
591             this.augments = this.comment.getTag("augments");
592             
593             //@extends - Ext
594             if (this.comment.getTag("extends")) {   
595                 this.augments = this.comment.getTag("extends");
596             }
597             
598             
599             // @default
600             var defaults = this.comment.getTag("default");
601             if (defaults.length) {
602                 if (this.is("OBJECT")) {
603                     this.defaultValue = defaults[0].desc;
604                 }
605             }
606             
607             /*~t
608                 // todo
609             */
610             
611             // @memberOf
612             var memberOfs = this.comment.getTag("memberOf");
613             if (memberOfs.length) {
614                 this.memberOf = memberOfs[0].desc;
615                 this.memberOf = this.memberOf.replace(/\.prototype\.?/g, "#");
616             }
617
618             /*~t
619                 // todo
620             */
621             
622             // @public
623             if (this.comment.getTag("public").length) {
624                 this.isPrivate = false;
625             }
626             
627             /*~t
628                 // todo
629             */
630         },
631
632         is : function(what) {
633             return this.isa === what;
634         },
635
636         isBuiltin : function() {
637             return SymbolSet.isBuiltin(this.alias);
638         },
639
640         setType : function(/**String*/comment, /**Boolean*/overwrite) {
641             if (!overwrite && this.type) return;
642             var typeComment = DocComment.unwrapComment(comment);
643             this.type = typeComment;
644         },
645
646         inherit : function(symbol) {
647             if (!this.hasMember(symbol.name) && !symbol.isInner) {
648                 if (symbol.is("FUNCTION"))
649                     this.methods.push(symbol);
650                 else if (symbol.is("OBJECT"))
651                     this.properties.push(symbol);
652             }
653         },
654
655         hasMember : function(name) {
656             return (this.hasMethod(name) || this.hasProperty(name));
657         },
658
659         addMember : function(symbol) {
660             //println("ADDMEMBER: " + this.name +  " ++ " + symbol.name);
661             
662             if (symbol.comment.getTag("cfg").length == 1) { 
663                 symbol.comment.getTag("cfg")[0].memberOf = this.alias;
664                 this.addConfig(symbol.comment.getTag("cfg")[0]);
665                 return;
666             }
667             
668             if (symbol.is("FUNCTION")) { this.addMethod(symbol); }
669             else if (symbol.is("OBJECT")) { this.addProperty(symbol); }
670         },
671
672         hasMethod : function(name) {
673             var thisMethods = this.methods;
674             for (var i = 0, l = thisMethods.length; i < l; i++) {
675                 if (thisMethods[i].name == name) return true;
676                 if (thisMethods[i].alias == name) return true;
677             }
678             return false;
679         },
680
681         addMethod : function(symbol) {
682             var methodAlias = symbol.alias;
683             var thisMethods = this.methods;
684             for (var i = 0, l = thisMethods.length; i < l; i++) {
685                 if (thisMethods[i].alias == methodAlias) {
686                     thisMethods[i] = symbol; // overwriting previous method
687                     return;
688                 }
689             }
690             thisMethods.push(symbol); // new method with this alias
691         },
692
693         hasProperty : function(name) {
694             var thisProperties = this.properties;
695             for (var i = 0, l = thisProperties.length; i < l; i++) {
696                 if (thisProperties[i].name == name) return true;
697                 if (thisProperties[i].alias == name) return true;
698             }
699             return false;
700         },
701
702         addProperty : function(symbol) {
703             var propertyAlias = symbol.alias;
704             var thisProperties = this.properties;
705             for (var i = 0, l = thisProperties.length; i < l; i++) {
706                 if (thisProperties[i].alias == propertyAlias) {
707                     thisProperties[i] = symbol; // overwriting previous property
708                     return;
709                 }
710             }
711
712             thisProperties.push(symbol); // new property with this alias
713         },
714         
715         addDocTag : function(docTag)
716         {
717             this.comment.tags.push(docTag);
718             if (docTag.title == 'cfg') {
719                 this.addConfig(docTag);
720             }
721             
722         },
723         
724         addConfig : function(docTag)
725         {
726             if (typeof(docTag['memberOf']) == 'undefined') {
727                 // remove prototype data...
728                 //var a = this.alias.split('#')[0];
729                 //docTag.memberOf = a;
730                 docTag.memberOf = this.alias;
731             }
732             if (typeof(this.cfgs[docTag.name]) == 'undefined') {
733                 this.cfgs[docTag.name] = docTag;
734             }
735             
736         },
737         configToArray: function()
738         {
739             var r = [];
740             for(var ci in this.cfgs) {
741                 // dont show hidden!!
742                 if (this.cfgs[ci].desc.match(/@hide/)) {
743                     continue;
744                 }
745                 r.push(this.cfgs[ci]); 
746                
747             }
748             return r;
749         }
750 });
751
752
753
754
755
756 Symbol.srcFile = ""; //running reference to the current file being parsed
757
758
759 Symbol.fromDump = function(t)
760 {
761     var ns = new Symbol();
762     for (var i in t) {
763         if (typeof(ns[i]) == "undefined") {
764             println("ERR:no default for Symbol:"+ i);
765         }
766         ns[i] = t[i];
767     }
768     return ns;
769 }