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