-//<script type="text/javascript">
-
-XObject = imports.XObject.XObject;
-
-SymbolSet = imports.SymbolSet.SymbolSet;
-//Parser = imports.Parser.Parser;
-DocComment = imports.DocComment.DocComment;
-DocTag = imports.DocTag.DocTag;
+
/**
Create a new Symbol.
@class Represents a symbol in the source code.
*/
-Symbol = XObject.define(
- function() {
- this.init();
- if (arguments.length) this.populate.apply(this, arguments);
+
+
+namespace JSDOC {
+
+
+ public class Symbol : Object
+ {
+
+ 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 = "";
- },
- Object,
- {
+ 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 : {},
- name : "",
- defaultValue : "",
- params : [],
- $args : [], // original arguments used when constructing.
- addOn : "",
- alias : "",
- augments : [], // Doctag[]
- author : "",
- classDesc : "",
- comment : {},
- deprecated : "",
- desc : "",
+ DocComment comment;
+
+ //$args : [], // original arguments used when constructing.
+ string addOn = "";
+ public string alias = "";
+
+ string author = "";
+ string classDesc = "";
+
+ string deprecated = "";
+ string desc = "";
//events : false,
- example : "",
- exceptions : [], // Doctag[]
- inherits : [], // Doctag[]
+ string example = "";
+
//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 : {},
+ string isa = "OBJECT"; // OBJECT//FUNCTION
+ public bool isEvent = false;
+ public bool isConstant = false;
+ public bool isIgnored = false;
+ public bool isInner = false;
+ public bool isNamespace = false;
+ public bool isPrivate = false;
+ public bool isStatic = false;
-
+ string memberOf = "";
+
+
+
+
+ string since = "";
+
+ string type = "";
+ string version = "";
+
+ string srcFile = "";
- toJSON : function()
- {
-
-
- 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()
+
+ public void initArrays()
{
// only initialize arrays / objects..
- this.params = [];
- this.$args = [];
+
+
+ //this.params = [];
+ //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.srcFile = {};
+ 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;
- },
-
- serialize : function() {
- var keys = [];
- for (var p in this) {
- keys.push (p);
- }
- keys = keys.sort();
-
- var out = "";
- for (var i in keys) {
- if (typeof this[keys[i]] == "function") continue;
- out += " " +keys[i]+" => "+
- (
- (typeof(this[keys[i]]) != "object") ?
- this[keys[i]] :
- "[" +typeof(this[keys[i]])+"]"
- ) +
- ",\n";
- }
- return "\n{\n" + out + "}\n";
- },
-
- clone : function() {
- var clone = new Symbol();
- clone.populate.apply(clone, this.$args); // repopulate using the original arguments
- clone.srcFile = this.srcFile; // not the current srcFile, the one when the original was made
- return clone;
- },
-
-
-
-
- //__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; },
- //);
-
- populate : function(
- /** String */ name,
- /** Object[] */ params,
- /** String */ isa,
- /** DocComment */ comment
+ }
+
+ Public Symbol.new_builtin(string name)
+ {
+ Symbol.regexInit();
+ this.initArrays();
+ this.srcFile = DocParser.currentSourceFile;
+ this.prviate_name = name ;
+ this.alias = this.name;
+ this.isa = "CONSTRUCTOR";
+ this.comment = new DocComment("");
+ this.comment.isUserComment = false;
+ this.isNamespace = false;
+ this.srcFile = "";
+ this.isPrivate = false;
+ // init arrays....
+
+
+
+ }
+
+
+
+
+ public Symbol.new_populate_with_args(
+ string name,
+ Gee.ArrayList<string> params, // fixme???
+ string isa,
+ DocComment 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.srcFile = Symbol.srcFile;
+ this.comment = comment;
+
+ this.srcFile = DocParser.currentSourceFile;
- if (this.is("FILE") && !this.alias) this.alias = this.srcFile;
+ if (this.is("FILE") && !this.alias) { // this will never hapen???
+ this.alias = this.srcFile;
+ }
- this.setTags();
+ this.tagsFromComment();
- //if (typeof PluginManager != "undefined") {
- // PluginManager.run("onSymbol", this);
- //}
- },
+ }
- 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
// @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
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;
+ }
}
}
// @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
// @constant
if (this.comment.getTag("constant").length) {
this.isConstant = true;
- this.isa = 'OBJECT';
+ this.isa = "OBJECT";
}
/*~t
// @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
// @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
var sees = this.comment.getTag("see");
if (sees.length) {
var thisSee = this.see;
- sees.map(function($){thisSee.push($.desc);});
- }
+ foreach(var s in sees) {
+ this.see.add(s.desc);
+ }
+ }
/*~t
var sym = new Symbol("foo", [], "FILE", new DocComment("/**@see The other thing.*"+"/"));
if (properties.length) {
thisProperties = this.properties;
for (var i = 0; i < properties.length; i++) {
- var property = new Symbol(this.alias+"#"+properties[i].name, [], "OBJECT", new DocComment("/**"+properties[i].desc+"\n@name "+properties[i].name+"\n@memberOf "+this.alias+"#*/"));
+
+
+
+
+ var property = new Symbol.new_populate_with_args(
+ this.alias+"#"+properties[i].name,
+ new Gee.ArrayList<string>(),
+ "OBJECT",
+ new DocComment(
+ "/**"+properties[i].desc+"\n@name "+properties[i].name+"\n@memberOf "+this.alias+"#*/"
+ ));
// TODO: shouldn't the following happen in the addProperty method of Symbol?
property.name = properties[i].name;
property.memberOf = this.alias;
var returns = this.comment.getTag("return");
if (returns.length) { // there can be many return tags in a single doclet
this.returns = returns;
- this.type = returns.map(function($){return $.type}).join(", ");
- }
+
+ this.type = "";
+ foreach(var r in returns) {
+ this.type += this.type == "" ? "": ", ";
+ this.type += r.type;
+ }
+ }
/*~t
// todo
// @requires
var requires = this.comment.getTag("requires");
if (requires.length) {
- this.requires = requires.map(function($){return $.desc});
+ this.requires = new Gee.ArrayList<string>();
+ foreach(var r in requires) {
+ this.requires.push(r.desc);
+ }
}
/*~t