JSDOC/TokenReader.js
[gnome.introspection-doc-generator] / JSDOC / Symbol.js
index c27927d..7385547 100644 (file)
@@ -19,55 +19,134 @@ Symbol = XObject.define(
     Object,
     {
         
+        
+        name : "",
+        defaultValue : "",
+        params : [],
+        $args : [], // original arguments used when constructing.
+        addOn : "",
+        alias : "",
+        augments : [], // Doctag[]
+        author : "",
+        classDesc : "",
+        comment : {},
+        deprecated : "",
+        desc : "",
+        //events : false,
+        example : "",
+        exceptions : [],  // Doctag[]
+        inherits : [],  // Doctag[]
+        //inheritsFrom : [],
+        isa : "OBJECT", // OBJECT//FUNCTION
+        isEvent : false,
+        isConstant : false,
+        isIgnored : false,
+        isInner : false,
+        isNamespace : false,
+        isPrivate : false,
+        isStatic : false,
+        memberOf : "",
+        methods : [], // Symbol[]
+        _name : "",
+        _params : [], //Doctag[]
+        properties : [], //Doctag[]
+        requires : [],  //Doctag[]
+        returns : [], //Doctag[]
+        see : [], //Doctag[]
+        since : "",
+        srcFile : {},
+        type : "",
+        version : "",
+        childClasses : [],
+        cfgs : {},
+        
+        
             
-        /*
-        toQDump : function(t)
+        
+        toJSON : function()
         {
-            return toQDump(t, 'Symbol.fromDump({', '})', {});//new Symbol());
+            
+           
+            var ret = { '*object' : 'Symbol' };
+            for (var i in this) {
+                if (Symbol.hide.indexOf(i) > -1) {
+                    continue;
+                }
+                switch (typeof(this[i])) {
+                    case 'function':
+                        continue;
+                    case 'object':
+                        switch(i) {
+                            //arrays..
+                            case 'params' : 
+                            case 'augments' :                             
+                            case 'exceptions' :  
+                            case 'inherits' :
+                            case 'methods' :
+                            case '_params': 
+                            case 'properties': 
+                            case 'requires':
+                            case 'returns':
+                            case 'see':
+                            case 'cfgs': // key val of doctags..
+                            case 'comment' :
+                                ret[i] = this[i]
+                                continue; 
+                            
+                            //skip
+                            case 'inheritsFrom':
+                            case 'childClasses':
+                                continue;
+            
+                            default:
+                                print("object? :" + i);
+                                Seed.quit();
+                        }
+                        
+                        
+                    case 'string':
+                    case 'number':
+                    case 'boolean':
+                        ret[i] = this[i]; continue;
+                    default:
+                        
+                        print("unknown type:" + typeof(this[i]));
+                        print(JSON.stringify(this));
+                        Seed.quit();
+                   }
+            }
+            return ret;
+            
         },
-        */
+        
         init : function() 
         {
-            this.name = "";
-            this.defaultValue = "";
+            // only initialize arrays / objects..
             this.params = [];
             this.$args = [];
-            this.addOn = "";
-            this.alias = "";
-            this.augments = [];
-            this.author = "";
-            this.classDesc = "";
-            this.comment = { isUserComment: false };
-            //this.defaultValue = null;
-            this.deprecated = "";
-            this.desc = "";
-            this.events = [];
-            this.example = "";
+            
+            //this.events = [];
             this.exceptions = [];
             this.inherits = [];
-            this.inheritsFrom = [];
+            //
             this.isa = "OBJECT"; // OBJECT//FUNCTION
-            this.isEvent = false;
-            this.isConstant = false;
-            this.isIgnored = false;
-            this.isInner = false;
-            this.isNamespace = false;
-            this.isPrivate = false;
-            this.isStatic = false;
-            this.memberOf = "";
             this.methods = [];
-            this._name = "";
             this._params = [];
             this.properties = [];
             this.requires = [];
             this.returns = [];
             this.see = [];
-            this.since = "";
             this.srcFile = {};
-            this.type = "";
-            this.version = "";
-            this.childClasses = [];
+            
+            
             this.cfgs = {};
+            // derived later?
+            this.inheritsFrom = [];
+            this.childClasses = [];
+            
+            this.comment = new DocComment();
+            this.comment.isUserComment =  false;
+            
                
         },
 
@@ -279,6 +358,7 @@ Symbol = XObject.define(
             // @class
             var classes = this.comment.getTag("class");
             if (classes.length) {
+                //print(JSON.stringify(this,null,4));
                 this.isa = "CONSTRUCTOR";
                 this.classDesc = classes[0].desc; // desc can't apply to the constructor as there is none.
                 if (!this.classDesc) {
@@ -374,6 +454,7 @@ Symbol = XObject.define(
                 // @static
             if (this.comment.getTag("singleton").length) {
                 this.isStatic = true;
+                //print('------------- got singleton ---------------' + this.isa);
                 //if (this.isa == "CONSTRUCTOR") {
                 //     this.isNamespace = true;
                 //}
@@ -586,6 +667,11 @@ Symbol = XObject.define(
             if (memberOfs.length) {
                 this.memberOf = memberOfs[0].desc;
                 this.memberOf = this.memberOf.replace(/\.prototype\.?/g, "#");
+                this.name = this.name.split('.').pop();
+                this.name = this.name.split('#').pop();
+                this.name = this.memberOf + this.name;
+                this._name = this.name
+                this.alias = this.name;
             }
 
             /*~t
@@ -722,9 +808,13 @@ Symbol = XObject.define(
         }
 });
 
-
-
-
+/**
+ * Elements that are not serialized
+ * 
+ */
+Symbol.hide = [ 
+    '$args' // not needed AFAIK
+]
 
 Symbol.srcFile = ""; //running reference to the current file being parsed
 
@@ -739,4 +829,4 @@ Symbol.fromDump = function(t)
         ns[i] = t[i];
     }
     return ns;
-}
\ No newline at end of file
+}