xpcomcore-rubygem 0.3.1 → 0.3.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (146) hide show
  1. data/Rakefile +1 -1
  2. data/VERSION +1 -1
  3. data/xpcomcore-rubygem.gemspec +144 -2
  4. data/xpcomcore/LICENSE +21 -0
  5. data/xpcomcore/README +27 -0
  6. data/xpcomcore/Rakefile +83 -0
  7. data/xpcomcore/VERSION.yml +5 -0
  8. data/xpcomcore/bin/popen_helper.sh +47 -0
  9. data/xpcomcore/bootstrapper.js +32 -0
  10. data/xpcomcore/components/XPCOMCore.js +122 -0
  11. data/xpcomcore/doc/files.html +275 -0
  12. data/xpcomcore/doc/index.html +275 -0
  13. data/xpcomcore/doc/symbols/Error.html +264 -0
  14. data/xpcomcore/doc/symbols/File.NoSuchFileError.html +334 -0
  15. data/xpcomcore/doc/symbols/File.html +451 -0
  16. data/xpcomcore/doc/symbols/Kernel.html +1098 -0
  17. data/xpcomcore/doc/symbols/LoadError.html +334 -0
  18. data/xpcomcore/doc/symbols/SelfConceptError.html +334 -0
  19. data/xpcomcore/doc/symbols/Sys.html +394 -0
  20. data/xpcomcore/doc/symbols/XPCBuiltins.html +314 -0
  21. data/xpcomcore/doc/symbols/_global_.html +264 -0
  22. data/xpcomcore/doc/symbols/src/lib_file.js.html +82 -0
  23. data/xpcomcore/doc/symbols/src/lib_kernel.js.html +250 -0
  24. data/xpcomcore/doc/symbols/src/lib_sys.js.html +60 -0
  25. data/xpcomcore/doc/symbols/src/lib_xpc_builtins.js.html +20 -0
  26. data/xpcomcore/etc/jsdoc-toolkit/README.txt +186 -0
  27. data/xpcomcore/etc/jsdoc-toolkit/app/frame.js +33 -0
  28. data/xpcomcore/etc/jsdoc-toolkit/app/frame/Chain.js +102 -0
  29. data/xpcomcore/etc/jsdoc-toolkit/app/frame/Dumper.js +144 -0
  30. data/xpcomcore/etc/jsdoc-toolkit/app/frame/Hash.js +84 -0
  31. data/xpcomcore/etc/jsdoc-toolkit/app/frame/Link.js +153 -0
  32. data/xpcomcore/etc/jsdoc-toolkit/app/frame/Namespace.js +10 -0
  33. data/xpcomcore/etc/jsdoc-toolkit/app/frame/Opt.js +134 -0
  34. data/xpcomcore/etc/jsdoc-toolkit/app/frame/Reflection.js +26 -0
  35. data/xpcomcore/etc/jsdoc-toolkit/app/frame/String.js +93 -0
  36. data/xpcomcore/etc/jsdoc-toolkit/app/frame/Testrun.js +129 -0
  37. data/xpcomcore/etc/jsdoc-toolkit/app/handlers/FOODOC.js +26 -0
  38. data/xpcomcore/etc/jsdoc-toolkit/app/handlers/XMLDOC.js +26 -0
  39. data/xpcomcore/etc/jsdoc-toolkit/app/handlers/XMLDOC/DomReader.js +159 -0
  40. data/xpcomcore/etc/jsdoc-toolkit/app/handlers/XMLDOC/XMLDoc.js +16 -0
  41. data/xpcomcore/etc/jsdoc-toolkit/app/handlers/XMLDOC/XMLParse.js +292 -0
  42. data/xpcomcore/etc/jsdoc-toolkit/app/lib/JSDOC.js +104 -0
  43. data/xpcomcore/etc/jsdoc-toolkit/app/lib/JSDOC/DocComment.js +200 -0
  44. data/xpcomcore/etc/jsdoc-toolkit/app/lib/JSDOC/DocTag.js +294 -0
  45. data/xpcomcore/etc/jsdoc-toolkit/app/lib/JSDOC/JsDoc.js +126 -0
  46. data/xpcomcore/etc/jsdoc-toolkit/app/lib/JSDOC/JsPlate.js +109 -0
  47. data/xpcomcore/etc/jsdoc-toolkit/app/lib/JSDOC/Lang.js +144 -0
  48. data/xpcomcore/etc/jsdoc-toolkit/app/lib/JSDOC/Parser.js +145 -0
  49. data/xpcomcore/etc/jsdoc-toolkit/app/lib/JSDOC/PluginManager.js +33 -0
  50. data/xpcomcore/etc/jsdoc-toolkit/app/lib/JSDOC/Symbol.js +645 -0
  51. data/xpcomcore/etc/jsdoc-toolkit/app/lib/JSDOC/SymbolSet.js +241 -0
  52. data/xpcomcore/etc/jsdoc-toolkit/app/lib/JSDOC/TextStream.js +41 -0
  53. data/xpcomcore/etc/jsdoc-toolkit/app/lib/JSDOC/Token.js +18 -0
  54. data/xpcomcore/etc/jsdoc-toolkit/app/lib/JSDOC/TokenReader.js +332 -0
  55. data/xpcomcore/etc/jsdoc-toolkit/app/lib/JSDOC/TokenStream.js +133 -0
  56. data/xpcomcore/etc/jsdoc-toolkit/app/lib/JSDOC/Util.js +32 -0
  57. data/xpcomcore/etc/jsdoc-toolkit/app/lib/JSDOC/Walker.js +474 -0
  58. data/xpcomcore/etc/jsdoc-toolkit/app/main.js +111 -0
  59. data/xpcomcore/etc/jsdoc-toolkit/app/plugins/commentSrcJson.js +20 -0
  60. data/xpcomcore/etc/jsdoc-toolkit/app/plugins/frameworkPrototype.js +16 -0
  61. data/xpcomcore/etc/jsdoc-toolkit/app/plugins/functionCall.js +10 -0
  62. data/xpcomcore/etc/jsdoc-toolkit/app/plugins/publishSrcHilite.js +62 -0
  63. data/xpcomcore/etc/jsdoc-toolkit/app/plugins/symbolLink.js +10 -0
  64. data/xpcomcore/etc/jsdoc-toolkit/app/plugins/tagParamConfig.js +31 -0
  65. data/xpcomcore/etc/jsdoc-toolkit/app/plugins/tagSynonyms.js +43 -0
  66. data/xpcomcore/etc/jsdoc-toolkit/app/run.js +348 -0
  67. data/xpcomcore/etc/jsdoc-toolkit/app/t/TestDoc.js +144 -0
  68. data/xpcomcore/etc/jsdoc-toolkit/app/t/runner.js +13 -0
  69. data/xpcomcore/etc/jsdoc-toolkit/app/test.js +325 -0
  70. data/xpcomcore/etc/jsdoc-toolkit/app/test/addon.js +24 -0
  71. data/xpcomcore/etc/jsdoc-toolkit/app/test/anon_inner.js +14 -0
  72. data/xpcomcore/etc/jsdoc-toolkit/app/test/augments.js +31 -0
  73. data/xpcomcore/etc/jsdoc-toolkit/app/test/augments2.js +26 -0
  74. data/xpcomcore/etc/jsdoc-toolkit/app/test/borrows.js +46 -0
  75. data/xpcomcore/etc/jsdoc-toolkit/app/test/borrows2.js +23 -0
  76. data/xpcomcore/etc/jsdoc-toolkit/app/test/config.js +22 -0
  77. data/xpcomcore/etc/jsdoc-toolkit/app/test/constructs.js +18 -0
  78. data/xpcomcore/etc/jsdoc-toolkit/app/test/encoding.js +10 -0
  79. data/xpcomcore/etc/jsdoc-toolkit/app/test/encoding_other.js +12 -0
  80. data/xpcomcore/etc/jsdoc-toolkit/app/test/event.js +54 -0
  81. data/xpcomcore/etc/jsdoc-toolkit/app/test/exports.js +14 -0
  82. data/xpcomcore/etc/jsdoc-toolkit/app/test/functions_anon.js +39 -0
  83. data/xpcomcore/etc/jsdoc-toolkit/app/test/functions_nested.js +33 -0
  84. data/xpcomcore/etc/jsdoc-toolkit/app/test/global.js +13 -0
  85. data/xpcomcore/etc/jsdoc-toolkit/app/test/globals.js +25 -0
  86. data/xpcomcore/etc/jsdoc-toolkit/app/test/ignore.js +10 -0
  87. data/xpcomcore/etc/jsdoc-toolkit/app/test/inner.js +16 -0
  88. data/xpcomcore/etc/jsdoc-toolkit/app/test/jsdoc_test.js +477 -0
  89. data/xpcomcore/etc/jsdoc-toolkit/app/test/lend.js +33 -0
  90. data/xpcomcore/etc/jsdoc-toolkit/app/test/memberof.js +19 -0
  91. data/xpcomcore/etc/jsdoc-toolkit/app/test/memberof_constructor.js +17 -0
  92. data/xpcomcore/etc/jsdoc-toolkit/app/test/module.js +17 -0
  93. data/xpcomcore/etc/jsdoc-toolkit/app/test/name.js +19 -0
  94. data/xpcomcore/etc/jsdoc-toolkit/app/test/namespace_nested.js +23 -0
  95. data/xpcomcore/etc/jsdoc-toolkit/app/test/nocode.js +13 -0
  96. data/xpcomcore/etc/jsdoc-toolkit/app/test/oblit_anon.js +20 -0
  97. data/xpcomcore/etc/jsdoc-toolkit/app/test/overview.js +20 -0
  98. data/xpcomcore/etc/jsdoc-toolkit/app/test/param_inline.js +37 -0
  99. data/xpcomcore/etc/jsdoc-toolkit/app/test/params_optional.js +8 -0
  100. data/xpcomcore/etc/jsdoc-toolkit/app/test/prototype.js +17 -0
  101. data/xpcomcore/etc/jsdoc-toolkit/app/test/prototype_nested.js +9 -0
  102. data/xpcomcore/etc/jsdoc-toolkit/app/test/prototype_oblit.js +13 -0
  103. data/xpcomcore/etc/jsdoc-toolkit/app/test/prototype_oblit_constructor.js +24 -0
  104. data/xpcomcore/etc/jsdoc-toolkit/app/test/public.js +10 -0
  105. data/xpcomcore/etc/jsdoc-toolkit/app/test/scripts/code.js +5 -0
  106. data/xpcomcore/etc/jsdoc-toolkit/app/test/scripts/notcode.txt +5 -0
  107. data/xpcomcore/etc/jsdoc-toolkit/app/test/shared.js +42 -0
  108. data/xpcomcore/etc/jsdoc-toolkit/app/test/shared2.js +2 -0
  109. data/xpcomcore/etc/jsdoc-toolkit/app/test/shortcuts.js +22 -0
  110. data/xpcomcore/etc/jsdoc-toolkit/app/test/static_this.js +13 -0
  111. data/xpcomcore/etc/jsdoc-toolkit/app/test/synonyms.js +31 -0
  112. data/xpcomcore/etc/jsdoc-toolkit/app/test/tosource.js +23 -0
  113. data/xpcomcore/etc/jsdoc-toolkit/app/test/variable_redefine.js +14 -0
  114. data/xpcomcore/etc/jsdoc-toolkit/changes.txt +96 -0
  115. data/xpcomcore/etc/jsdoc-toolkit/conf/sample.conf +31 -0
  116. data/xpcomcore/etc/jsdoc-toolkit/java/build.xml +36 -0
  117. data/xpcomcore/etc/jsdoc-toolkit/java/build_1.4.xml +36 -0
  118. data/xpcomcore/etc/jsdoc-toolkit/java/classes/js.jar +0 -0
  119. data/xpcomcore/etc/jsdoc-toolkit/java/src/JsDebugRun.java +21 -0
  120. data/xpcomcore/etc/jsdoc-toolkit/java/src/JsRun.java +21 -0
  121. data/xpcomcore/etc/jsdoc-toolkit/jsdebug.jar +0 -0
  122. data/xpcomcore/etc/jsdoc-toolkit/jsrun.jar +0 -0
  123. data/xpcomcore/etc/jsdoc-toolkit/jsrun.sh +52 -0
  124. data/xpcomcore/etc/jsdoc-toolkit/templates/jsdoc/allclasses.tmpl +17 -0
  125. data/xpcomcore/etc/jsdoc-toolkit/templates/jsdoc/allfiles.tmpl +56 -0
  126. data/xpcomcore/etc/jsdoc-toolkit/templates/jsdoc/class.tmpl +646 -0
  127. data/xpcomcore/etc/jsdoc-toolkit/templates/jsdoc/index.tmpl +39 -0
  128. data/xpcomcore/etc/jsdoc-toolkit/templates/jsdoc/publish.js +200 -0
  129. data/xpcomcore/etc/jsdoc-toolkit/templates/jsdoc/static/default.css +162 -0
  130. data/xpcomcore/etc/jsdoc-toolkit/templates/jsdoc/static/header.html +2 -0
  131. data/xpcomcore/etc/jsdoc-toolkit/templates/jsdoc/static/index.html +19 -0
  132. data/xpcomcore/etc/jsdoc-toolkit/templates/jsdoc/symbol.tmpl +35 -0
  133. data/xpcomcore/lib/file.js +75 -0
  134. data/xpcomcore/lib/kernel.js +243 -0
  135. data/xpcomcore/lib/sys.js +52 -0
  136. data/xpcomcore/lib/xpc_builtins.js +13 -0
  137. data/xpcomcore/test/file_test.js +27 -0
  138. data/xpcomcore/test/fixtures/empty +0 -0
  139. data/xpcomcore/test/fixtures/love.js +1 -0
  140. data/xpcomcore/test/fixtures/mad_love.js +1 -0
  141. data/xpcomcore/test/fixtures/mad_world.js +1 -0
  142. data/xpcomcore/test/fixtures/syntax_error.js +1 -0
  143. data/xpcomcore/test/kernel_test.js +95 -0
  144. data/xpcomcore/test/sys_test.js +19 -0
  145. data/xpcomcore/test/xpc_builtins_test.js +8 -0
  146. metadata +143 -1
@@ -0,0 +1,133 @@
1
+ if (typeof JSDOC == "undefined") JSDOC = {};
2
+
3
+ /**
4
+ @constructor
5
+ */
6
+ JSDOC.TokenStream = function(tokens) {
7
+ this.tokens = (tokens || []);
8
+ this.rewind();
9
+ }
10
+
11
+ /**
12
+ @constructor
13
+ @private
14
+ */
15
+ function VoidToken(/**String*/type) {
16
+ this.toString = function() {return "<VOID type=\""+type+"\">"};
17
+ this.is = function(){return false;}
18
+ }
19
+
20
+ JSDOC.TokenStream.prototype.rewind = function() {
21
+ this.cursor = -1;
22
+ }
23
+
24
+ /**
25
+ @type JSDOC.Token
26
+ */
27
+ JSDOC.TokenStream.prototype.look = function(/**Number*/n, /**Boolean*/considerWhitespace) {
28
+ if (typeof n == "undefined") n = 0;
29
+
30
+ if (considerWhitespace == true) {
31
+ if (this.cursor+n < 0 || this.cursor+n > this.tokens.length) return {};
32
+ return this.tokens[this.cursor+n];
33
+ }
34
+ else {
35
+ var count = 0;
36
+ var i = this.cursor;
37
+
38
+ while (true) {
39
+ if (i < 0) return new JSDOC.Token("", "VOID", "START_OF_STREAM");
40
+ else if (i > this.tokens.length) return new JSDOC.Token("", "VOID", "END_OF_STREAM");
41
+
42
+ if (i != this.cursor && (this.tokens[i] === undefined || this.tokens[i].is("WHIT"))) {
43
+ if (n < 0) i--; else i++;
44
+ continue;
45
+ }
46
+
47
+ if (count == Math.abs(n)) {
48
+ return this.tokens[i];
49
+ }
50
+ count++;
51
+ (n < 0)? i-- : i++;
52
+ }
53
+
54
+ return new JSDOC.Token("", "VOID", "STREAM_ERROR"); // because null isn't an object and caller always expects an object
55
+ }
56
+ }
57
+
58
+ /**
59
+ @type JSDOC.Token|JSDOC.Token[]
60
+ */
61
+ JSDOC.TokenStream.prototype.next = function(/**Number*/howMany) {
62
+ if (typeof howMany == "undefined") howMany = 1;
63
+ if (howMany < 1) return null;
64
+ var got = [];
65
+
66
+ for (var i = 1; i <= howMany; i++) {
67
+ if (this.cursor+i >= this.tokens.length) {
68
+ return null;
69
+ }
70
+ got.push(this.tokens[this.cursor+i]);
71
+ }
72
+ this.cursor += howMany;
73
+
74
+ if (howMany == 1) {
75
+ return got[0];
76
+ }
77
+ else return got;
78
+ }
79
+
80
+ /**
81
+ @type JSDOC.Token[]
82
+ */
83
+ JSDOC.TokenStream.prototype.balance = function(/**String*/start, /**String*/stop) {
84
+ if (!stop) stop = JSDOC.Lang.matching(start);
85
+
86
+ var depth = 0;
87
+ var got = [];
88
+ var started = false;
89
+
90
+ while ((token = this.look())) {
91
+ if (token.is(start)) {
92
+ depth++;
93
+ started = true;
94
+ }
95
+
96
+ if (started) {
97
+ got.push(token);
98
+ }
99
+
100
+ if (token.is(stop)) {
101
+ depth--;
102
+ if (depth == 0) return got;
103
+ }
104
+ if (!this.next()) break;
105
+ }
106
+ }
107
+
108
+ JSDOC.TokenStream.prototype.getMatchingToken = function(/**String*/start, /**String*/stop) {
109
+ var depth = 0;
110
+ var cursor = this.cursor;
111
+
112
+ if (!start) {
113
+ start = JSDOC.Lang.matching(stop);
114
+ depth = 1;
115
+ }
116
+ if (!stop) stop = JSDOC.Lang.matching(start);
117
+
118
+ while ((token = this.tokens[cursor])) {
119
+ if (token.is(start)) {
120
+ depth++;
121
+ }
122
+
123
+ if (token.is(stop) && cursor) {
124
+ depth--;
125
+ if (depth == 0) return this.tokens[cursor];
126
+ }
127
+ cursor++;
128
+ }
129
+ }
130
+
131
+ JSDOC.TokenStream.prototype.insertAhead = function(/**JSDOC.Token*/token) {
132
+ this.tokens.splice(this.cursor+1, 0, token);
133
+ }
@@ -0,0 +1,32 @@
1
+ /**
2
+ * @namespace
3
+ * @deprecated Use {@link FilePath} instead.
4
+ */
5
+ JSDOC.Util = {
6
+ }
7
+
8
+ /**
9
+ * @deprecated Use {@link FilePath.fileName} instead.
10
+ */
11
+ JSDOC.Util.fileName = function(path) {
12
+ LOG.warn("JSDOC.Util.fileName is deprecated. Use FilePath.fileName instead.");
13
+ var nameStart = Math.max(path.lastIndexOf("/")+1, path.lastIndexOf("\\")+1, 0);
14
+ return path.substring(nameStart);
15
+ }
16
+
17
+ /**
18
+ * @deprecated Use {@link FilePath.fileExtension} instead.
19
+ */
20
+ JSDOC.Util.fileExtension = function(filename) {
21
+ LOG.warn("JSDOC.Util.fileExtension is deprecated. Use FilePath.fileExtension instead.");
22
+ return filename.split(".").pop().toLowerCase();
23
+ };
24
+
25
+ /**
26
+ * @deprecated Use {@link FilePath.dir} instead.
27
+ */
28
+ JSDOC.Util.dir = function(path) {
29
+ LOG.warn("JSDOC.Util.dir is deprecated. Use FilePath.dir instead.");
30
+ var nameStart = Math.max(path.lastIndexOf("/")+1, path.lastIndexOf("\\")+1, 0);
31
+ return path.substring(0, nameStart-1);
32
+ }
@@ -0,0 +1,474 @@
1
+ if (typeof JSDOC == "undefined") JSDOC = {};
2
+
3
+ /** @constructor */
4
+ JSDOC.Walker = function(/**JSDOC.TokenStream*/ts) {
5
+ this.init();
6
+ if (typeof ts != "undefined") {
7
+ this.walk(ts);
8
+ }
9
+ }
10
+
11
+ JSDOC.Walker.prototype.init = function() {
12
+ this.ts = null;
13
+
14
+ var globalSymbol = new JSDOC.Symbol("_global_", [], "GLOBAL", new JSDOC.DocComment(""));
15
+ globalSymbol.isNamespace = true;
16
+ globalSymbol.srcFile = "";
17
+ globalSymbol.isPrivate = false;
18
+ JSDOC.Parser.addSymbol(globalSymbol);
19
+ this.lastDoc = null;
20
+ this.token = null;
21
+
22
+ /**
23
+ The chain of symbols under which we are currently nested.
24
+ @type Array
25
+ */
26
+ this.namescope = [globalSymbol];
27
+ this.namescope.last = function(n){ if (!n) n = 0; return this[this.length-(1+n)] || "" };
28
+ }
29
+
30
+ JSDOC.Walker.prototype.walk = function(/**JSDOC.TokenStream*/ts) {
31
+ this.ts = ts;
32
+ while (this.token = this.ts.look()) {
33
+ if (this.token.popNamescope) {
34
+
35
+ var symbol = this.namescope.pop();
36
+ if (symbol.is("FUNCTION")) {
37
+ if (this.ts.look(1).is("LEFT_PAREN") && symbol.comment.getTag("function").length == 0) {
38
+ symbol.isa = "OBJECT";
39
+ }
40
+ }
41
+ }
42
+ this.step();
43
+ if (!this.ts.next()) break;
44
+ }
45
+ }
46
+
47
+ JSDOC.Walker.prototype.step = function() {
48
+ if (this.token.is("JSDOC")) { // it's a doc comment
49
+
50
+ var doc = new JSDOC.DocComment(this.token.data);
51
+
52
+
53
+ if (doc.getTag("exports").length > 0) {
54
+ var exports = doc.getTag("exports")[0];
55
+
56
+ exports.desc.match(/(\S+) as (\S+)/i);
57
+ var n1 = RegExp.$1;
58
+ var n2 = RegExp.$2;
59
+
60
+ if (!n1 && n2) throw "@exports tag requires a value like: 'name as ns.name'";
61
+
62
+ JSDOC.Parser.rename = (JSDOC.Parser.rename || {});
63
+ JSDOC.Parser.rename[n1] = n2
64
+ }
65
+
66
+ if (doc.getTag("lends").length > 0) {
67
+ var lends = doc.getTag("lends")[0];
68
+
69
+ var name = lends.desc
70
+ if (!name) throw "@lends tag requires a value.";
71
+
72
+ var symbol = new JSDOC.Symbol(name, [], "OBJECT", doc);
73
+
74
+ this.namescope.push(symbol);
75
+
76
+ var matching = this.ts.getMatchingToken("LEFT_CURLY");
77
+ if (matching) matching.popNamescope = name;
78
+ else LOG.warn("Mismatched } character. Can't parse code in file " + symbol.srcFile + ".");
79
+
80
+ this.lastDoc = null;
81
+ return true;
82
+ }
83
+ else if (doc.getTag("name").length > 0 && doc.getTag("overview").length == 0) { // it's a virtual symbol
84
+ var virtualName = doc.getTag("name")[0].desc;
85
+ if (!virtualName) throw "@name tag requires a value.";
86
+
87
+ var symbol = new JSDOC.Symbol(virtualName, [], "VIRTUAL", doc);
88
+
89
+ JSDOC.Parser.addSymbol(symbol);
90
+
91
+ this.lastDoc = null;
92
+ return true;
93
+ }
94
+ else if (doc.meta) { // it's a meta doclet
95
+ if (doc.meta == "@+") JSDOC.DocComment.shared = doc.src;
96
+ else if (doc.meta == "@-") JSDOC.DocComment.shared = "";
97
+ else if (doc.meta == "nocode+") JSDOC.Parser.conf.ignoreCode = true;
98
+ else if (doc.meta == "nocode-") JSDOC.Parser.conf.ignoreCode = JSDOC.opt.n;
99
+ else throw "Unrecognized meta comment: "+doc.meta;
100
+
101
+ this.lastDoc = null;
102
+ return true;
103
+ }
104
+ else if (doc.getTag("overview").length > 0) { // it's a file overview
105
+ symbol = new JSDOC.Symbol("", [], "FILE", doc);
106
+
107
+ JSDOC.Parser.addSymbol(symbol);
108
+
109
+ this.lastDoc = null;
110
+ return true;
111
+ }
112
+ else {
113
+ this.lastDoc = doc;
114
+ return false;
115
+ }
116
+ }
117
+ else if (!JSDOC.Parser.conf.ignoreCode) { // it's code
118
+ if (this.token.is("NAME")) { // it's the name of something
119
+ var symbol;
120
+ var name = this.token.data;
121
+ var doc = null; if (this.lastDoc) doc = this.lastDoc;
122
+ var params = [];
123
+
124
+ // it's inside an anonymous object
125
+ if (this.ts.look(1).is("COLON") && this.ts.look(-1).is("LEFT_CURLY") && !(this.ts.look(-2).is("JSDOC") || this.namescope.last().comment.getTag("lends").length || this.ts.look(-2).is("ASSIGN") || this.ts.look(-2).is("COLON"))) {
126
+ name = "$anonymous";
127
+ name = this.namescope.last().alias+"-"+name
128
+
129
+ params = [];
130
+
131
+ symbol = new JSDOC.Symbol(name, params, "OBJECT", doc);
132
+
133
+ JSDOC.Parser.addSymbol(symbol);
134
+
135
+ this.namescope.push(symbol);
136
+
137
+ var matching = this.ts.getMatchingToken(null, "RIGHT_CURLY");
138
+ if (matching) matching.popNamescope = name;
139
+ else LOG.warn("Mismatched } character. Can't parse code in file " + symbol.srcFile + ".");
140
+ }
141
+ // function foo() {}
142
+ else if (this.ts.look(-1).is("FUNCTION") && this.ts.look(1).is("LEFT_PAREN")) {
143
+ var isInner;
144
+
145
+ if (this.lastDoc) doc = this.lastDoc;
146
+ name = this.namescope.last().alias+"-"+name;
147
+ if (!this.namescope.last().is("GLOBAL")) isInner = true;
148
+
149
+ params = JSDOC.Walker.onParamList(this.ts.balance("LEFT_PAREN"));
150
+
151
+ symbol = new JSDOC.Symbol(name, params, "FUNCTION", doc);
152
+ if (isInner) symbol.isInner = true;
153
+
154
+ if (this.ts.look(1).is("JSDOC")) {
155
+ var inlineReturn = ""+this.ts.look(1).data;
156
+ inlineReturn = inlineReturn.replace(/(^\/\*\* *| *\*\/$)/g, "");
157
+ symbol.type = inlineReturn;
158
+ }
159
+
160
+ JSDOC.Parser.addSymbol(symbol);
161
+
162
+ this.namescope.push(symbol);
163
+
164
+ var matching = this.ts.getMatchingToken("LEFT_CURLY");
165
+ if (matching) matching.popNamescope = name;
166
+ else LOG.warn("Mismatched } character. Can't parse code in file " + symbol.srcFile + ".");
167
+ }
168
+ // foo = function() {}
169
+ else if (this.ts.look(1).is("ASSIGN") && this.ts.look(2).is("FUNCTION")) {
170
+ var isInner;
171
+ if (this.ts.look(-1).is("VAR") || this.isInner) {
172
+ name = this.namescope.last().alias+"-"+name
173
+ if (!this.namescope.last().is("GLOBAL")) isInner = true;
174
+ }
175
+ else if (name.indexOf("this.") == 0) {
176
+ name = this.resolveThis(name);
177
+ }
178
+
179
+ if (this.lastDoc) doc = this.lastDoc;
180
+ params = JSDOC.Walker.onParamList(this.ts.balance("LEFT_PAREN"));
181
+
182
+ symbol = new JSDOC.Symbol(name, params, "FUNCTION", doc);
183
+ if (isInner) symbol.isInner = true;
184
+
185
+ if (this.ts.look(1).is("JSDOC")) {
186
+ var inlineReturn = ""+this.ts.look(1).data;
187
+ inlineReturn = inlineReturn.replace(/(^\/\*\* *| *\*\/$)/g, "");
188
+ symbol.type = inlineReturn;
189
+ }
190
+
191
+ JSDOC.Parser.addSymbol(symbol);
192
+
193
+ this.namescope.push(symbol);
194
+
195
+ var matching = this.ts.getMatchingToken("LEFT_CURLY");
196
+ if (matching) matching.popNamescope = name;
197
+ else LOG.warn("Mismatched } character. Can't parse code in file " + symbol.srcFile + ".");
198
+ }
199
+ // foo = new function() {} or foo = (function() {}
200
+ else if (this.ts.look(1).is("ASSIGN") && (this.ts.look(2).is("NEW") || this.ts.look(2).is("LEFT_PAREN")) && this.ts.look(3).is("FUNCTION")) {
201
+ var isInner;
202
+ if (this.ts.look(-1).is("VAR") || this.isInner) {
203
+ name = this.namescope.last().alias+"-"+name
204
+ if (!this.namescope.last().is("GLOBAL")) isInner = true;
205
+ }
206
+ else if (name.indexOf("this.") == 0) {
207
+ name = this.resolveThis(name);
208
+ }
209
+
210
+ this.ts.next(3); // advance past the "new" or "("
211
+
212
+ if (this.lastDoc) doc = this.lastDoc;
213
+ params = JSDOC.Walker.onParamList(this.ts.balance("LEFT_PAREN"));
214
+
215
+ symbol = new JSDOC.Symbol(name, params, "OBJECT", doc);
216
+ if (isInner) symbol.isInner = true;
217
+
218
+ if (this.ts.look(1).is("JSDOC")) {
219
+ var inlineReturn = ""+this.ts.look(1).data;
220
+ inlineReturn = inlineReturn.replace(/(^\/\*\* *| *\*\/$)/g, "");
221
+ symbol.type = inlineReturn;
222
+ }
223
+
224
+ JSDOC.Parser.addSymbol(symbol);
225
+
226
+ symbol.scopeType = "INSTANCE";
227
+ this.namescope.push(symbol);
228
+
229
+ var matching = this.ts.getMatchingToken("LEFT_CURLY");
230
+ if (matching) matching.popNamescope = name;
231
+ else LOG.warn("Mismatched } character. Can't parse code in file " + symbol.srcFile + ".");
232
+ }
233
+ // foo: function() {}
234
+ else if (this.ts.look(1).is("COLON") && this.ts.look(2).is("FUNCTION")) {
235
+ name = (this.namescope.last().alias+"."+name).replace("#.", "#");
236
+
237
+ if (this.lastDoc) doc = this.lastDoc;
238
+ params = JSDOC.Walker.onParamList(this.ts.balance("LEFT_PAREN"));
239
+
240
+ if (doc && doc.getTag("constructs").length) {
241
+ name = name.replace(/\.prototype(\.|$)/, "#");
242
+
243
+ if (name.indexOf("#") > -1) name = name.match(/(^[^#]+)/)[0];
244
+ else name = this.namescope.last().alias;
245
+
246
+ symbol = new JSDOC.Symbol(name, params, "CONSTRUCTOR", doc);
247
+ }
248
+ else {
249
+ symbol = new JSDOC.Symbol(name, params, "FUNCTION", doc);
250
+ }
251
+
252
+ if (this.ts.look(1).is("JSDOC")) {
253
+ var inlineReturn = ""+this.ts.look(1).data;
254
+ inlineReturn = inlineReturn.replace(/(^\/\*\* *| *\*\/$)/g, "");
255
+ symbol.type = inlineReturn;
256
+ }
257
+
258
+ JSDOC.Parser.addSymbol(symbol);
259
+
260
+ this.namescope.push(symbol);
261
+
262
+ var matching = this.ts.getMatchingToken("LEFT_CURLY");
263
+ if (matching) matching.popNamescope = name;
264
+ else LOG.warn("Mismatched } character. Can't parse code in file " + symbol.srcFile + ".");
265
+ }
266
+ // foo = {}
267
+ else if (this.ts.look(1).is("ASSIGN") && this.ts.look(2).is("LEFT_CURLY")) {
268
+ var isInner;
269
+ if (this.ts.look(-1).is("VAR") || this.isInner) {
270
+ name = this.namescope.last().alias+"-"+name
271
+ if (!this.namescope.last().is("GLOBAL")) isInner = true;
272
+ }
273
+ else if (name.indexOf("this.") == 0) {
274
+ name = this.resolveThis(name);
275
+ }
276
+
277
+ if (this.lastDoc) doc = this.lastDoc;
278
+
279
+ symbol = new JSDOC.Symbol(name, params, "OBJECT", doc);
280
+ if (isInner) symbol.isInner = true;
281
+
282
+
283
+ if (doc) JSDOC.Parser.addSymbol(symbol);
284
+
285
+ this.namescope.push(symbol);
286
+
287
+ var matching = this.ts.getMatchingToken("LEFT_CURLY");
288
+ if (matching) matching.popNamescope = name;
289
+ else LOG.warn("Mismatched } character. Can't parse code in file " + symbol.srcFile + ".");
290
+ }
291
+ // var foo;
292
+ else if (this.ts.look(1).is("SEMICOLON")) {
293
+ var isInner;
294
+
295
+ if (this.ts.look(-1).is("VAR") || this.isInner) {
296
+ name = this.namescope.last().alias+"-"+name
297
+ if (!this.namescope.last().is("GLOBAL")) isInner = true;
298
+
299
+ if (this.lastDoc) doc = this.lastDoc;
300
+
301
+ symbol = new JSDOC.Symbol(name, params, "OBJECT", doc);
302
+ if (isInner) symbol.isInner = true;
303
+
304
+
305
+ if (doc) JSDOC.Parser.addSymbol(symbol);
306
+ }
307
+ }
308
+ // foo = x
309
+ else if (this.ts.look(1).is("ASSIGN")) {
310
+ var isInner;
311
+ if (this.ts.look(-1).is("VAR") || this.isInner) {
312
+ name = this.namescope.last().alias+"-"+name
313
+ if (!this.namescope.last().is("GLOBAL")) isInner = true;
314
+ }
315
+ else if (name.indexOf("this.") == 0) {
316
+ name = this.resolveThis(name);
317
+ }
318
+
319
+ if (this.lastDoc) doc = this.lastDoc;
320
+
321
+ symbol = new JSDOC.Symbol(name, params, "OBJECT", doc);
322
+ if (isInner) symbol.isInner = true;
323
+
324
+
325
+ if (doc) JSDOC.Parser.addSymbol(symbol);
326
+ }
327
+ // foo: {}
328
+ else if (this.ts.look(1).is("COLON") && this.ts.look(2).is("LEFT_CURLY")) {
329
+ name = (this.namescope.last().alias+"."+name).replace("#.", "#");
330
+
331
+ if (this.lastDoc) doc = this.lastDoc;
332
+
333
+ symbol = new JSDOC.Symbol(name, params, "OBJECT", doc);
334
+
335
+
336
+ if (doc) JSDOC.Parser.addSymbol(symbol);
337
+
338
+ this.namescope.push(symbol);
339
+
340
+ var matching = this.ts.getMatchingToken("LEFT_CURLY");
341
+ if (matching) matching.popNamescope = name;
342
+ else LOG.warn("Mismatched } character. Can't parse code in file " + symbol.srcFile + ".");
343
+ }
344
+ // foo: x
345
+ else if (this.ts.look(1).is("COLON")) {
346
+ name = (this.namescope.last().alias+"."+name).replace("#.", "#");;
347
+
348
+ if (this.lastDoc) doc = this.lastDoc;
349
+
350
+ symbol = new JSDOC.Symbol(name, params, "OBJECT", doc);
351
+
352
+
353
+ if (doc) JSDOC.Parser.addSymbol(symbol);
354
+ }
355
+ // foo(...)
356
+ else if (this.ts.look(1).is("LEFT_PAREN")) {
357
+ if (typeof JSDOC.PluginManager != "undefined") {
358
+ var functionCall = {name: name};
359
+
360
+ var cursor = this.ts.cursor;
361
+ params = JSDOC.Walker.onParamList(this.ts.balance("LEFT_PAREN"));
362
+ this.ts.cursor = cursor;
363
+
364
+ for (var i = 0; i < params.length; i++)
365
+ functionCall["arg" + (i + 1)] = params[i].name;
366
+
367
+ JSDOC.PluginManager.run("onFunctionCall", functionCall);
368
+ if (functionCall.doc) {
369
+ this.ts.insertAhead(new JSDOC.Token(functionCall.doc, "COMM", "JSDOC"));
370
+ }
371
+ }
372
+ }
373
+ this.lastDoc = null;
374
+ }
375
+ else if (this.token.is("FUNCTION")) { // it's an anonymous function
376
+ if (
377
+ (!this.ts.look(-1).is("COLON") || !this.ts.look(-1).is("ASSIGN"))
378
+ && !this.ts.look(1).is("NAME")
379
+ ) {
380
+ if (this.lastDoc) doc = this.lastDoc;
381
+
382
+ name = "$anonymous";
383
+ name = this.namescope.last().alias+"-"+name
384
+
385
+ params = JSDOC.Walker.onParamList(this.ts.balance("LEFT_PAREN"));
386
+
387
+ symbol = new JSDOC.Symbol(name, params, "FUNCTION", doc);
388
+
389
+ JSDOC.Parser.addSymbol(symbol);
390
+
391
+ this.namescope.push(symbol);
392
+
393
+ var matching = this.ts.getMatchingToken("LEFT_CURLY");
394
+ if (matching) matching.popNamescope = name;
395
+ else LOG.warn("Mismatched } character. Can't parse code in file " + symbol.srcFile + ".");
396
+ }
397
+ }
398
+ }
399
+ return true;
400
+ }
401
+
402
+ /**
403
+ Resolves what "this." means when it appears in a name.
404
+ @param name The name that starts with "this.".
405
+ @returns The name with "this." resolved.
406
+ */
407
+ JSDOC.Walker.prototype.resolveThis = function(name) {
408
+ name.match(/^this\.(.+)$/)
409
+ var nameFragment = RegExp.$1;
410
+ if (!nameFragment) return name;
411
+
412
+ var symbol = this.namescope.last();
413
+ var scopeType = symbol.scopeType || symbol.isa;
414
+
415
+ // if we are in a constructor function, `this` means the instance
416
+ if (scopeType == "CONSTRUCTOR") {
417
+ name = symbol.alias+"#"+nameFragment;
418
+ }
419
+
420
+ // if we are in an anonymous constructor function, `this` means the instance
421
+ else if (scopeType == "INSTANCE") {
422
+ name = symbol.alias+"."+nameFragment;
423
+ }
424
+
425
+ // if we are in a function, `this` means the container (possibly the global)
426
+ else if (scopeType == "FUNCTION") {
427
+ // in a method of a prototype, so `this` means the constructor
428
+ if (symbol.alias.match(/(^.*)[#.-][^#.-]+/)) {
429
+ var parentName = RegExp.$1;
430
+ var parent = JSDOC.Parser.symbols.getSymbol(parentName);
431
+
432
+ if (!parent) {
433
+ if (JSDOC.Lang.isBuiltin(parentName)) parent = JSDOC.Parser.addBuiltin(parentName);
434
+ else {
435
+ if (symbol.alias.indexOf("$anonymous") < 0) // these will be ignored eventually
436
+ LOG.warn("Trying to document "+symbol.alias+" without first documenting "+parentName+".");
437
+ }
438
+ }
439
+ if (parent) name = parentName+(parent.is("CONSTRUCTOR")?"#":".")+nameFragment;
440
+ }
441
+ else {
442
+ parent = this.namescope.last(1);
443
+ name = parent.alias+(parent.is("CONSTRUCTOR")?"#":".")+nameFragment;
444
+ }
445
+ }
446
+ // otherwise it means the global
447
+ else {
448
+ name = nameFragment;
449
+ }
450
+
451
+ return name;
452
+ }
453
+
454
+ JSDOC.Walker.onParamList = function(/**Array*/paramTokens) {
455
+ if (!paramTokens) {
456
+ LOG.warn("Malformed parameter list. Can't parse code.");
457
+ return [];
458
+ }
459
+ var params = [];
460
+ for (var i = 0, l = paramTokens.length; i < l; i++) {
461
+ if (paramTokens[i].is("JSDOC")) {
462
+ var paramType = paramTokens[i].data.replace(/(^\/\*\* *| *\*\/$)/g, "");
463
+
464
+ if (paramTokens[i+1] && paramTokens[i+1].is("NAME")) {
465
+ i++;
466
+ params.push({type: paramType, name: paramTokens[i].data});
467
+ }
468
+ }
469
+ else if (paramTokens[i].is("NAME")) {
470
+ params.push({name: paramTokens[i].data});
471
+ }
472
+ }
473
+ return params;
474
+ }