src/jsdoc/Symbol.vala
[roojspacker] / src / jsdoc / Symbol.vala
index 92c91cf..cbdd246 100644 (file)
@@ -10,35 +10,92 @@ namespace JSDOC {
 
        public  class Symbol : Object
        {
-       
-       
-//             public Symbol() {
-//                 this.init();
-//             },
-
-// probably needs vairous CTORS..
+               
+               private static bool regex_init = false;
+               private GLib.Regex regex_global;
+               private GLib.Regex regex_prototype;
+               
+               static void  regexInit()
+               {
+                       if (Symbol.regex_init = true) {
+                               return;
+                       }
+                       Symbol.regex_init = true;
+                       Symbol.regex_global = new GLib.Regex("^_global_[.#-]");
+                       Symbol.regex_prototype = new GLib.Regex("\\.prototype\\.?");
+               }
 
+               private string private_string_name = "";
+               private string private_name {
+               set {
+                               var n = Symbol.regex_global(value, value.length, 0, "");
+                       n =  Symbol.regex_prototype(n,n.length, 0, "#");
+                       while (true) {
+                               if (!n.has_suffix("#")) {
+                                       break;
+                                       }
+                                       n = n.substring(0, n.length-1);
+                               }
+                       
+                       this.private_string_name = n;
+               }
+               
+               }
+                
+        public string name {
+               get { return this.private_string_name; }
+               }
+               
+      
+        string defaultValue = "";
         
-        string name : "",
-        string defaultValue : "",
-        
-        
-        
-        params : [],
-        augments : [], // Doctag[]
-        exceptions : [],  // Doctag[]
-        inherits : [],  // Doctag[]
-        methods : [], // Symbol[]
-               //??
-        _params : [], //Doctag[]
-                properties : [], //Doctag[]
-        requires : [],  //Doctag[]
-        returns : [], //Doctag[]
-        see : [], //Doctag[]
-
-        srcFile : {}, //??
-        childClasses : [],
-        cfgs : {},
+               private Gee.ArrayList<DocTag> private_doctag_params;
+
+               private Gee.ArrayList<DocTag> private_params{
+                       set  {
+                               for (var i = 0; i < value.size; i++) {
+                                  
+                                   this.private_doctag_params.add(v.get(i));
+                               }
+                               //this.params = this._params;
+                       }
+               }
+     
+               Gee.ArrayList<string> private_string_params{
+                       set  {
+                               for (var i = 0; i < value.size; i++) {
+
+                                   //var ty = v[i].hasOwnProperty('type') ? v[i].type : '';
+                                   this.private_doctag_params.add( new DocTag(value.get(i)));
+                                          
+                                  //"param"+((ty)?" {"+ty+"}":"")+" "+v.get(i).name);
+                                   
+                               }
+                               
+                       }
+               }
+               public Gee.ArrayList<DocTag> params {
+                       get {
+                               return this.private_doctag_params;
+                       }
+               
+               }
+
+               private Gee.ArrayList<DocTag>  augments ;  
+
+               private Gee.ArrayList<DocTag>  exceptions ;
+
+               private Gee.ArrayList<DocTag>  inherits; 
+               private Gee.ArrayList<DocTag>  methods;
+
+               private Gee.ArrayList<DocTag> properties;
+               private Gee.ArrayList<DocTag> requires;
+               private Gee.ArrayList<DocTag> returns;
+               private Gee.ArrayList<DocTag> see ;
+
+         
+        //childClasses : [],
+        //cfgs : {},
         
         
         DocComment comment;
@@ -66,17 +123,17 @@ namespace JSDOC {
         public bool isPrivate = false;
         public bool isStatic = false;
         
-        string memberOf : "",
+        string memberOf = "";
+
 
-        string _name : "",
 
        
-        string since : "",
+        string since = "";
 
-        string type : "",
-        string version : "",
-        
-        string srcFile = ""
+        string type = "";
+        string version = "";
+       
+        string srcFile = "";
         
         
         
@@ -86,38 +143,40 @@ namespace JSDOC {
 
             
             //this.params = [];
-            this.$args = [];
+            //this.$args = [];
             
             //this.events = [];
-            this.exceptions = [];
-            this.inherits = [];
+            this.exceptions = new Gee.ArrayList<DocTag>();
+            this.inherits = new Gee.ArrayList<DocTag>();
             //
             this.isa = "OBJECT"; // OBJECT//FUNCTION
-            this.methods = [];
-            this._params = [];
-            this.properties = [];
-            this.requires = [];
-            this.returns = [];
-            this.see = [];
+            this.methods = new Gee.ArrayList<DocTag>();
+            //this.private_params = new Gee.ArrayList<DocTag>();
+            this.properties = new Gee.ArrayList<DocTag>();
+            this.requires = new Gee.ArrayList<DocTag>();
+            this.returns = new Gee.ArrayList<DocTag>();
+            this.see = new Gee.ArrayList<DocTag>();
  
             
             
             this.cfgs = {};
             // derived later?
-            this.inheritsFrom = [];
-            this.childClasses = [];
+            //this.inheritsFrom = [];
+            //this.childClasses = [];
             
             this.comment = new DocComment();
             this.comment.isUserComment =  false;
             
                
-        },
+        }
                
                Public Symbol.new_builtin(string name)
                {
+            Symbol.regexInit();
+            this.initArrays();
             this.srcFile = DocParser.currentSourceFile;
-                       this.setName( name );
-                       this.alias = this.getName();
+                       this.prviate_name =  name ;
+                       this.alias = this.name;
                        this.isa = "CONSTRUCTOR";
                        this.comment = new DocComment("");
                        this.comment.isUserComment =  false;
@@ -131,38 +190,7 @@ namespace JSDOC {
                }
                
 
-        //__defineSetter__("name",
-        setName  : function(n) { 
-                n = n.replace(/^_global_[.#-]/, ""); 
-                n = n.replace(/\.prototype\.?/g, '#'); 
-                 n = n.replace(/#$/g, ''); 
-                this._name = n;
-                this.name = n; // real!
-            },
-        //);
-        //__defineGetter__("name",
-        getName : function() { return this._name; },
-        //);
-        //__defineSetter__("params", 
-        setParams  :function(v) {
-                for (var i = 0, l = v.length; i < l; i++) {
-                    if (v[i].constructor != DocTag) { // may be a generic object parsed from signature, like {type:..., name:...}
-                        var ty = v[i].hasOwnProperty('type') ? v[i].type : '';
-                        this._params[i] = new DocTag(
-                            "param"+((ty)?" {"+ty+"}":"")+" "+v[i].name);
-                    }
-                    else {
-                        this._params[i] = v[i];
-                    }
-                }
-                this.params = this._params;
-            },
-        //);
-
-
-        //__defineGetter__("params",
-        getParams : function() { return this._params; },
-        //);
 
         public Symbol.new_populate_with_args(
                 string  name,
@@ -170,13 +198,15 @@ namespace JSDOC {
                 string isa,
                 string comment
         ) {
-            this.$args = arguments;
+            Symbol.regexInit();
+            this.initArrays();
+           // this.$args = arguments;
             //println("Symbol created: " + isa + ":" + name);
-            this.setName(name);
+            this.private_name = name;
             this.alias = this.getName();
-            this.setParams(params);
+            this.private_string_params = params; 
             this.isa = (isa == "VIRTUAL")? "OBJECT":isa;
-            this.comment = comment || new DocComment("")
+            this.comment =  new DocComment(comment);
             
             this.srcFile = DocParser.currentSourceFile;
             
@@ -186,15 +216,20 @@ namespace JSDOC {
                        this.alias = this.srcFile;
                }
 
-            this.setTags();
+            this.tagsFromComment();
             
-        },
+        }
 
-        setTags : function() {
+        void tagsFromComment() {
             // @author
             var authors = this.comment.getTag("author");
-            if (authors.length) {
-                this.author = authors.map(function($){return $.desc;}).join(", ");
+            if (authors.size) {
+                       // turns author into a string....
+                       this.author = "";
+                foreach(var a in authors) {
+                    this.author += (this.author == "") ? "": ", ";
+                    this.author += a.desc;
+                }
             }
             
             /*~t
@@ -215,7 +250,12 @@ namespace JSDOC {
             // @desc
             var descs = this.comment.getTag("desc");
             if (descs.length) {
-                this.desc = descs.map(function($){return $.desc;}).join("\n"); // multiple descriptions are concatenated into one
+                this.desc = "";
+                foreach(var d in desc) {
+                    this.desc = this.desc == "" ? "": "\n";
+                    this.desc += d.desc;
+                }
+
             }
             
             /*~t
@@ -229,7 +269,10 @@ namespace JSDOC {
                 
                 var overviews = this.comment.getTag("overview");
                 if (overviews.length) {
-                    this.desc = [this.desc].concat(overviews.map(function($){return $.desc;})).join("\n");
+                    foreach(var d in overviews) {
+                        this.desc = this.desc == "" ? "": "\n";
+                        this.desc += d.desc;
+                    }
                 }
             }
             
@@ -241,7 +284,11 @@ namespace JSDOC {
             // @since
             var sinces = this.comment.getTag("since");
             if (sinces.length) {
-                this.since = sinces.map(function($){return $.desc;}).join(", ");
+                this.since = "";
+                foreach(var d in sinces) {
+                    this.since = this.since == "" ? "": "\n";
+                    this.since += d.desc;
+                }
             }
             
             /*~t
@@ -252,7 +299,7 @@ namespace JSDOC {
             // @constant
             if (this.comment.getTag("constant").length) {
                 this.isConstant = true;
-                this.isa = 'OBJECT';
+                this.isa = "OBJECT";
             }
             
             /*~t
@@ -263,7 +310,11 @@ namespace JSDOC {
             // @version
             var versions = this.comment.getTag("version");
             if (versions.length) {
-                this.version = versions.map(function($){return $.desc;}).join(", ");
+                this.version = "";
+                 foreach(var d in versions) {
+                    this.version = this.version == "" ? "": "\n";
+                    this.version += d.desc;
+                }
             }
             
             /*~t
@@ -274,7 +325,11 @@ namespace JSDOC {
             // @deprecated
             var deprecateds = this.comment.getTag("deprecated");
             if (deprecateds.length) {
-                this.deprecated = deprecateds.map(function($){return $.desc;}).join("\n");
+                this.deprecated = "";
+                 foreach(var d in deprecateds) {
+                    this.deprecated = this.deprecated == "" ? "": "\n";
+                    this.deprecated += d.desc;
+                }
             }
             
             /*~t