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.
- data/Rakefile +1 -1
- data/VERSION +1 -1
- data/xpcomcore-rubygem.gemspec +144 -2
- data/xpcomcore/LICENSE +21 -0
- data/xpcomcore/README +27 -0
- data/xpcomcore/Rakefile +83 -0
- data/xpcomcore/VERSION.yml +5 -0
- data/xpcomcore/bin/popen_helper.sh +47 -0
- data/xpcomcore/bootstrapper.js +32 -0
- data/xpcomcore/components/XPCOMCore.js +122 -0
- data/xpcomcore/doc/files.html +275 -0
- data/xpcomcore/doc/index.html +275 -0
- data/xpcomcore/doc/symbols/Error.html +264 -0
- data/xpcomcore/doc/symbols/File.NoSuchFileError.html +334 -0
- data/xpcomcore/doc/symbols/File.html +451 -0
- data/xpcomcore/doc/symbols/Kernel.html +1098 -0
- data/xpcomcore/doc/symbols/LoadError.html +334 -0
- data/xpcomcore/doc/symbols/SelfConceptError.html +334 -0
- data/xpcomcore/doc/symbols/Sys.html +394 -0
- data/xpcomcore/doc/symbols/XPCBuiltins.html +314 -0
- data/xpcomcore/doc/symbols/_global_.html +264 -0
- data/xpcomcore/doc/symbols/src/lib_file.js.html +82 -0
- data/xpcomcore/doc/symbols/src/lib_kernel.js.html +250 -0
- data/xpcomcore/doc/symbols/src/lib_sys.js.html +60 -0
- data/xpcomcore/doc/symbols/src/lib_xpc_builtins.js.html +20 -0
- data/xpcomcore/etc/jsdoc-toolkit/README.txt +186 -0
- data/xpcomcore/etc/jsdoc-toolkit/app/frame.js +33 -0
- data/xpcomcore/etc/jsdoc-toolkit/app/frame/Chain.js +102 -0
- data/xpcomcore/etc/jsdoc-toolkit/app/frame/Dumper.js +144 -0
- data/xpcomcore/etc/jsdoc-toolkit/app/frame/Hash.js +84 -0
- data/xpcomcore/etc/jsdoc-toolkit/app/frame/Link.js +153 -0
- data/xpcomcore/etc/jsdoc-toolkit/app/frame/Namespace.js +10 -0
- data/xpcomcore/etc/jsdoc-toolkit/app/frame/Opt.js +134 -0
- data/xpcomcore/etc/jsdoc-toolkit/app/frame/Reflection.js +26 -0
- data/xpcomcore/etc/jsdoc-toolkit/app/frame/String.js +93 -0
- data/xpcomcore/etc/jsdoc-toolkit/app/frame/Testrun.js +129 -0
- data/xpcomcore/etc/jsdoc-toolkit/app/handlers/FOODOC.js +26 -0
- data/xpcomcore/etc/jsdoc-toolkit/app/handlers/XMLDOC.js +26 -0
- data/xpcomcore/etc/jsdoc-toolkit/app/handlers/XMLDOC/DomReader.js +159 -0
- data/xpcomcore/etc/jsdoc-toolkit/app/handlers/XMLDOC/XMLDoc.js +16 -0
- data/xpcomcore/etc/jsdoc-toolkit/app/handlers/XMLDOC/XMLParse.js +292 -0
- data/xpcomcore/etc/jsdoc-toolkit/app/lib/JSDOC.js +104 -0
- data/xpcomcore/etc/jsdoc-toolkit/app/lib/JSDOC/DocComment.js +200 -0
- data/xpcomcore/etc/jsdoc-toolkit/app/lib/JSDOC/DocTag.js +294 -0
- data/xpcomcore/etc/jsdoc-toolkit/app/lib/JSDOC/JsDoc.js +126 -0
- data/xpcomcore/etc/jsdoc-toolkit/app/lib/JSDOC/JsPlate.js +109 -0
- data/xpcomcore/etc/jsdoc-toolkit/app/lib/JSDOC/Lang.js +144 -0
- data/xpcomcore/etc/jsdoc-toolkit/app/lib/JSDOC/Parser.js +145 -0
- data/xpcomcore/etc/jsdoc-toolkit/app/lib/JSDOC/PluginManager.js +33 -0
- data/xpcomcore/etc/jsdoc-toolkit/app/lib/JSDOC/Symbol.js +645 -0
- data/xpcomcore/etc/jsdoc-toolkit/app/lib/JSDOC/SymbolSet.js +241 -0
- data/xpcomcore/etc/jsdoc-toolkit/app/lib/JSDOC/TextStream.js +41 -0
- data/xpcomcore/etc/jsdoc-toolkit/app/lib/JSDOC/Token.js +18 -0
- data/xpcomcore/etc/jsdoc-toolkit/app/lib/JSDOC/TokenReader.js +332 -0
- data/xpcomcore/etc/jsdoc-toolkit/app/lib/JSDOC/TokenStream.js +133 -0
- data/xpcomcore/etc/jsdoc-toolkit/app/lib/JSDOC/Util.js +32 -0
- data/xpcomcore/etc/jsdoc-toolkit/app/lib/JSDOC/Walker.js +474 -0
- data/xpcomcore/etc/jsdoc-toolkit/app/main.js +111 -0
- data/xpcomcore/etc/jsdoc-toolkit/app/plugins/commentSrcJson.js +20 -0
- data/xpcomcore/etc/jsdoc-toolkit/app/plugins/frameworkPrototype.js +16 -0
- data/xpcomcore/etc/jsdoc-toolkit/app/plugins/functionCall.js +10 -0
- data/xpcomcore/etc/jsdoc-toolkit/app/plugins/publishSrcHilite.js +62 -0
- data/xpcomcore/etc/jsdoc-toolkit/app/plugins/symbolLink.js +10 -0
- data/xpcomcore/etc/jsdoc-toolkit/app/plugins/tagParamConfig.js +31 -0
- data/xpcomcore/etc/jsdoc-toolkit/app/plugins/tagSynonyms.js +43 -0
- data/xpcomcore/etc/jsdoc-toolkit/app/run.js +348 -0
- data/xpcomcore/etc/jsdoc-toolkit/app/t/TestDoc.js +144 -0
- data/xpcomcore/etc/jsdoc-toolkit/app/t/runner.js +13 -0
- data/xpcomcore/etc/jsdoc-toolkit/app/test.js +325 -0
- data/xpcomcore/etc/jsdoc-toolkit/app/test/addon.js +24 -0
- data/xpcomcore/etc/jsdoc-toolkit/app/test/anon_inner.js +14 -0
- data/xpcomcore/etc/jsdoc-toolkit/app/test/augments.js +31 -0
- data/xpcomcore/etc/jsdoc-toolkit/app/test/augments2.js +26 -0
- data/xpcomcore/etc/jsdoc-toolkit/app/test/borrows.js +46 -0
- data/xpcomcore/etc/jsdoc-toolkit/app/test/borrows2.js +23 -0
- data/xpcomcore/etc/jsdoc-toolkit/app/test/config.js +22 -0
- data/xpcomcore/etc/jsdoc-toolkit/app/test/constructs.js +18 -0
- data/xpcomcore/etc/jsdoc-toolkit/app/test/encoding.js +10 -0
- data/xpcomcore/etc/jsdoc-toolkit/app/test/encoding_other.js +12 -0
- data/xpcomcore/etc/jsdoc-toolkit/app/test/event.js +54 -0
- data/xpcomcore/etc/jsdoc-toolkit/app/test/exports.js +14 -0
- data/xpcomcore/etc/jsdoc-toolkit/app/test/functions_anon.js +39 -0
- data/xpcomcore/etc/jsdoc-toolkit/app/test/functions_nested.js +33 -0
- data/xpcomcore/etc/jsdoc-toolkit/app/test/global.js +13 -0
- data/xpcomcore/etc/jsdoc-toolkit/app/test/globals.js +25 -0
- data/xpcomcore/etc/jsdoc-toolkit/app/test/ignore.js +10 -0
- data/xpcomcore/etc/jsdoc-toolkit/app/test/inner.js +16 -0
- data/xpcomcore/etc/jsdoc-toolkit/app/test/jsdoc_test.js +477 -0
- data/xpcomcore/etc/jsdoc-toolkit/app/test/lend.js +33 -0
- data/xpcomcore/etc/jsdoc-toolkit/app/test/memberof.js +19 -0
- data/xpcomcore/etc/jsdoc-toolkit/app/test/memberof_constructor.js +17 -0
- data/xpcomcore/etc/jsdoc-toolkit/app/test/module.js +17 -0
- data/xpcomcore/etc/jsdoc-toolkit/app/test/name.js +19 -0
- data/xpcomcore/etc/jsdoc-toolkit/app/test/namespace_nested.js +23 -0
- data/xpcomcore/etc/jsdoc-toolkit/app/test/nocode.js +13 -0
- data/xpcomcore/etc/jsdoc-toolkit/app/test/oblit_anon.js +20 -0
- data/xpcomcore/etc/jsdoc-toolkit/app/test/overview.js +20 -0
- data/xpcomcore/etc/jsdoc-toolkit/app/test/param_inline.js +37 -0
- data/xpcomcore/etc/jsdoc-toolkit/app/test/params_optional.js +8 -0
- data/xpcomcore/etc/jsdoc-toolkit/app/test/prototype.js +17 -0
- data/xpcomcore/etc/jsdoc-toolkit/app/test/prototype_nested.js +9 -0
- data/xpcomcore/etc/jsdoc-toolkit/app/test/prototype_oblit.js +13 -0
- data/xpcomcore/etc/jsdoc-toolkit/app/test/prototype_oblit_constructor.js +24 -0
- data/xpcomcore/etc/jsdoc-toolkit/app/test/public.js +10 -0
- data/xpcomcore/etc/jsdoc-toolkit/app/test/scripts/code.js +5 -0
- data/xpcomcore/etc/jsdoc-toolkit/app/test/scripts/notcode.txt +5 -0
- data/xpcomcore/etc/jsdoc-toolkit/app/test/shared.js +42 -0
- data/xpcomcore/etc/jsdoc-toolkit/app/test/shared2.js +2 -0
- data/xpcomcore/etc/jsdoc-toolkit/app/test/shortcuts.js +22 -0
- data/xpcomcore/etc/jsdoc-toolkit/app/test/static_this.js +13 -0
- data/xpcomcore/etc/jsdoc-toolkit/app/test/synonyms.js +31 -0
- data/xpcomcore/etc/jsdoc-toolkit/app/test/tosource.js +23 -0
- data/xpcomcore/etc/jsdoc-toolkit/app/test/variable_redefine.js +14 -0
- data/xpcomcore/etc/jsdoc-toolkit/changes.txt +96 -0
- data/xpcomcore/etc/jsdoc-toolkit/conf/sample.conf +31 -0
- data/xpcomcore/etc/jsdoc-toolkit/java/build.xml +36 -0
- data/xpcomcore/etc/jsdoc-toolkit/java/build_1.4.xml +36 -0
- data/xpcomcore/etc/jsdoc-toolkit/java/classes/js.jar +0 -0
- data/xpcomcore/etc/jsdoc-toolkit/java/src/JsDebugRun.java +21 -0
- data/xpcomcore/etc/jsdoc-toolkit/java/src/JsRun.java +21 -0
- data/xpcomcore/etc/jsdoc-toolkit/jsdebug.jar +0 -0
- data/xpcomcore/etc/jsdoc-toolkit/jsrun.jar +0 -0
- data/xpcomcore/etc/jsdoc-toolkit/jsrun.sh +52 -0
- data/xpcomcore/etc/jsdoc-toolkit/templates/jsdoc/allclasses.tmpl +17 -0
- data/xpcomcore/etc/jsdoc-toolkit/templates/jsdoc/allfiles.tmpl +56 -0
- data/xpcomcore/etc/jsdoc-toolkit/templates/jsdoc/class.tmpl +646 -0
- data/xpcomcore/etc/jsdoc-toolkit/templates/jsdoc/index.tmpl +39 -0
- data/xpcomcore/etc/jsdoc-toolkit/templates/jsdoc/publish.js +200 -0
- data/xpcomcore/etc/jsdoc-toolkit/templates/jsdoc/static/default.css +162 -0
- data/xpcomcore/etc/jsdoc-toolkit/templates/jsdoc/static/header.html +2 -0
- data/xpcomcore/etc/jsdoc-toolkit/templates/jsdoc/static/index.html +19 -0
- data/xpcomcore/etc/jsdoc-toolkit/templates/jsdoc/symbol.tmpl +35 -0
- data/xpcomcore/lib/file.js +75 -0
- data/xpcomcore/lib/kernel.js +243 -0
- data/xpcomcore/lib/sys.js +52 -0
- data/xpcomcore/lib/xpc_builtins.js +13 -0
- data/xpcomcore/test/file_test.js +27 -0
- data/xpcomcore/test/fixtures/empty +0 -0
- data/xpcomcore/test/fixtures/love.js +1 -0
- data/xpcomcore/test/fixtures/mad_love.js +1 -0
- data/xpcomcore/test/fixtures/mad_world.js +1 -0
- data/xpcomcore/test/fixtures/syntax_error.js +1 -0
- data/xpcomcore/test/kernel_test.js +95 -0
- data/xpcomcore/test/sys_test.js +19 -0
- data/xpcomcore/test/xpc_builtins_test.js +8 -0
- metadata +143 -1
@@ -0,0 +1,241 @@
|
|
1
|
+
/** @constructor */
|
2
|
+
JSDOC.SymbolSet = function() {
|
3
|
+
this.init();
|
4
|
+
}
|
5
|
+
|
6
|
+
JSDOC.SymbolSet.prototype.init = function() {
|
7
|
+
this._index = new Hash();
|
8
|
+
}
|
9
|
+
|
10
|
+
JSDOC.SymbolSet.prototype.keys = function() {
|
11
|
+
return this._index.keys();
|
12
|
+
}
|
13
|
+
|
14
|
+
JSDOC.SymbolSet.prototype.hasSymbol = function(alias) {
|
15
|
+
return this._index.hasKey(alias);
|
16
|
+
}
|
17
|
+
|
18
|
+
JSDOC.SymbolSet.prototype.addSymbol = function(symbol) {
|
19
|
+
if (this.hasSymbol(symbol.alias)) {
|
20
|
+
LOG.warn("Overwriting symbol documentation for: "+symbol.alias + ".");
|
21
|
+
}
|
22
|
+
this._index.set(symbol.alias, symbol);
|
23
|
+
}
|
24
|
+
|
25
|
+
JSDOC.SymbolSet.prototype.getSymbol = function(alias) {
|
26
|
+
if (this.hasSymbol(alias)) return this._index.get(alias);
|
27
|
+
}
|
28
|
+
|
29
|
+
JSDOC.SymbolSet.prototype.getSymbolByName = function(name) {
|
30
|
+
for (var p = this._index.first(); p; p = this._index.next()) {
|
31
|
+
var symbol = p.value;
|
32
|
+
if (symbol.name == name) return symbol;
|
33
|
+
}
|
34
|
+
}
|
35
|
+
|
36
|
+
JSDOC.SymbolSet.prototype.toArray = function() {
|
37
|
+
return this._index.values();
|
38
|
+
}
|
39
|
+
|
40
|
+
JSDOC.SymbolSet.prototype.deleteSymbol = function(alias) {
|
41
|
+
if (!this.hasSymbol(alias)) return;
|
42
|
+
this._index.drop(alias);
|
43
|
+
}
|
44
|
+
|
45
|
+
JSDOC.SymbolSet.prototype.renameSymbol = function(oldName, newName) {
|
46
|
+
// todo: should check if oldname or newname already exist
|
47
|
+
this._index.replace(oldName, newName);
|
48
|
+
this._index.get(newName).alias = newName;
|
49
|
+
return newName;
|
50
|
+
}
|
51
|
+
|
52
|
+
JSDOC.SymbolSet.prototype.relate = function() {
|
53
|
+
this.resolveBorrows();
|
54
|
+
this.resolveMemberOf();
|
55
|
+
this.resolveAugments();
|
56
|
+
}
|
57
|
+
|
58
|
+
JSDOC.SymbolSet.prototype.resolveBorrows = function() {
|
59
|
+
for (var p = this._index.first(); p; p = this._index.next()) {
|
60
|
+
var symbol = p.value;
|
61
|
+
if (symbol.is("FILE") || symbol.is("GLOBAL")) continue;
|
62
|
+
|
63
|
+
var borrows = symbol.inherits;
|
64
|
+
for (var i = 0; i < borrows.length; i++) {
|
65
|
+
|
66
|
+
if (/#$/.test(borrows[i].alias)) {
|
67
|
+
LOG.warn("Attempted to borrow entire instance of "+borrows[i].alias+" but that feature is not yet implemented.");
|
68
|
+
return;
|
69
|
+
}
|
70
|
+
var borrowed = this.getSymbol(borrows[i].alias);
|
71
|
+
|
72
|
+
if (!borrowed) {
|
73
|
+
LOG.warn("Can't borrow undocumented "+borrows[i].alias+".");
|
74
|
+
continue;
|
75
|
+
}
|
76
|
+
|
77
|
+
if (borrows[i].as == borrowed.alias) {
|
78
|
+
var assumedName = borrowed.name.split(/([#.-])/).pop();
|
79
|
+
borrows[i].as = symbol.name+RegExp.$1+assumedName;
|
80
|
+
LOG.inform("Assuming borrowed as name is "+borrows[i].as+" but that feature is experimental.");
|
81
|
+
}
|
82
|
+
|
83
|
+
var borrowAsName = borrows[i].as;
|
84
|
+
var borrowAsAlias = borrowAsName;
|
85
|
+
if (!borrowAsName) {
|
86
|
+
LOG.warn("Malformed @borrow, 'as' is required.");
|
87
|
+
continue;
|
88
|
+
}
|
89
|
+
|
90
|
+
if (borrowAsName.length > symbol.alias.length && borrowAsName.indexOf(symbol.alias) == 0) {
|
91
|
+
borrowAsName = borrowAsName.replace(borrowed.alias, "")
|
92
|
+
}
|
93
|
+
else {
|
94
|
+
var joiner = "";
|
95
|
+
if (borrowAsName.charAt(0) != "#") joiner = ".";
|
96
|
+
borrowAsAlias = borrowed.alias + joiner + borrowAsName;
|
97
|
+
}
|
98
|
+
|
99
|
+
borrowAsName = borrowAsName.replace(/^[#.]/, "");
|
100
|
+
|
101
|
+
if (this.hasSymbol(borrowAsAlias)) continue;
|
102
|
+
|
103
|
+
var clone = borrowed.clone();
|
104
|
+
clone.name = borrowAsName;
|
105
|
+
clone.alias = borrowAsAlias;
|
106
|
+
this.addSymbol(clone);
|
107
|
+
}
|
108
|
+
}
|
109
|
+
}
|
110
|
+
|
111
|
+
JSDOC.SymbolSet.prototype.resolveMemberOf = function() {
|
112
|
+
for (var p = this._index.first(); p; p = this._index.next()) {
|
113
|
+
var symbol = p.value;
|
114
|
+
if (symbol.is("FILE") || symbol.is("GLOBAL")) continue;
|
115
|
+
|
116
|
+
// the memberOf value was provided in the @memberOf tag
|
117
|
+
else if (symbol.memberOf) {
|
118
|
+
|
119
|
+
// like foo.bar is a memberOf foo
|
120
|
+
if (symbol.alias.indexOf(symbol.memberOf) == 0) {
|
121
|
+
var memberMatch = new RegExp("^("+symbol.memberOf+")[.#-]?(.+)$");
|
122
|
+
var aliasParts = symbol.alias.match(memberMatch);
|
123
|
+
|
124
|
+
if (aliasParts) {
|
125
|
+
symbol.memberOf = aliasParts[1];
|
126
|
+
symbol.name = aliasParts[2];
|
127
|
+
}
|
128
|
+
|
129
|
+
var nameParts = symbol.name.match(memberMatch);
|
130
|
+
|
131
|
+
if (nameParts) {
|
132
|
+
symbol.name = nameParts[2];
|
133
|
+
}
|
134
|
+
}
|
135
|
+
// like bar is a memberOf foo
|
136
|
+
else {
|
137
|
+
var joiner = symbol.memberOf.charAt(symbol.memberOf.length-1);
|
138
|
+
if (!/[.#-]/.test(joiner)) symbol.memberOf += ".";
|
139
|
+
this.renameSymbol(symbol.alias, symbol.memberOf + symbol.name);
|
140
|
+
}
|
141
|
+
}
|
142
|
+
// the memberOf must be calculated
|
143
|
+
else {
|
144
|
+
var parts = symbol.alias.match(/^(.*[.#-])([^.#-]+)$/);
|
145
|
+
if (parts) {
|
146
|
+
symbol.memberOf = parts[1];
|
147
|
+
symbol.name = parts[2];
|
148
|
+
}
|
149
|
+
}
|
150
|
+
|
151
|
+
// set isStatic, isInner
|
152
|
+
if (symbol.memberOf) {
|
153
|
+
switch (symbol.memberOf.charAt(symbol.memberOf.length-1)) {
|
154
|
+
case '#' :
|
155
|
+
symbol.isStatic = false;
|
156
|
+
symbol.isInner = false;
|
157
|
+
break;
|
158
|
+
case '.' :
|
159
|
+
symbol.isStatic = true;
|
160
|
+
symbol.isInner = false;
|
161
|
+
break;
|
162
|
+
case '-' :
|
163
|
+
symbol.isStatic = false;
|
164
|
+
symbol.isInner = true;
|
165
|
+
break;
|
166
|
+
default: // memberOf ends in none of the above
|
167
|
+
symbol.isStatic = true;
|
168
|
+
break;
|
169
|
+
}
|
170
|
+
}
|
171
|
+
|
172
|
+
// unowned methods and fields belong to the global object
|
173
|
+
if (!symbol.is("CONSTRUCTOR") && !symbol.isNamespace && symbol.memberOf == "") {
|
174
|
+
symbol.memberOf = "_global_";
|
175
|
+
}
|
176
|
+
|
177
|
+
// clean up
|
178
|
+
if (symbol.memberOf.match(/[.#-]$/)) {
|
179
|
+
symbol.memberOf = symbol.memberOf.substr(0, symbol.memberOf.length-1);
|
180
|
+
}
|
181
|
+
// add to parent's methods or properties list
|
182
|
+
if (symbol.memberOf) {
|
183
|
+
|
184
|
+
var container = this.getSymbol(symbol.memberOf);
|
185
|
+
if (!container) {
|
186
|
+
if (JSDOC.Lang.isBuiltin(symbol.memberOf)) container = JSDOC.Parser.addBuiltin(symbol.memberOf);
|
187
|
+
else {
|
188
|
+
LOG.warn("Trying to document "+symbol.name +" as a member of undocumented symbol "+symbol.memberOf+".");
|
189
|
+
}
|
190
|
+
}
|
191
|
+
|
192
|
+
if (container) container.addMember(symbol);
|
193
|
+
}
|
194
|
+
}
|
195
|
+
}
|
196
|
+
|
197
|
+
JSDOC.SymbolSet.prototype.resolveAugments = function() {
|
198
|
+
for (var p = this._index.first(); p; p = this._index.next()) {
|
199
|
+
var symbol = p.value;
|
200
|
+
|
201
|
+
if (symbol.alias == "_global_" || symbol.is("FILE")) continue;
|
202
|
+
JSDOC.SymbolSet.prototype.walk.apply(this, [symbol]);
|
203
|
+
}
|
204
|
+
}
|
205
|
+
|
206
|
+
JSDOC.SymbolSet.prototype.walk = function(symbol) {
|
207
|
+
var augments = symbol.augments;
|
208
|
+
for(var i = 0; i < augments.length; i++) {
|
209
|
+
var contributer = this.getSymbol(augments[i]);
|
210
|
+
if (!contributer && JSDOC.Lang.isBuiltin(''+augments[i])) {
|
211
|
+
contributer = new JSDOC.Symbol("_global_."+augments[i], [], augments[i], new JSDOC.DocComment("Built in."));
|
212
|
+
contributer.isNamespace = true;
|
213
|
+
contributer.srcFile = "";
|
214
|
+
contributer.isPrivate = false;
|
215
|
+
JSDOC.Parser.addSymbol(contributer);
|
216
|
+
}
|
217
|
+
|
218
|
+
if (contributer) {
|
219
|
+
if (contributer.augments.length) {
|
220
|
+
JSDOC.SymbolSet.prototype.walk.apply(this, [contributer]);
|
221
|
+
}
|
222
|
+
|
223
|
+
symbol.inheritsFrom.push(contributer.alias);
|
224
|
+
//if (!isUnique(symbol.inheritsFrom)) {
|
225
|
+
// LOG.warn("Can't resolve augments: Circular reference: "+symbol.alias+" inherits from "+contributer.alias+" more than once.");
|
226
|
+
//}
|
227
|
+
//else {
|
228
|
+
var cmethods = contributer.methods;
|
229
|
+
var cproperties = contributer.properties;
|
230
|
+
|
231
|
+
for (var ci = 0, cl = cmethods.length; ci < cl; ci++) {
|
232
|
+
if (!cmethods[ci].isStatic) symbol.inherit(cmethods[ci]);
|
233
|
+
}
|
234
|
+
for (var ci = 0, cl = cproperties.length; ci < cl; ci++) {
|
235
|
+
if (!cproperties[ci].isStatic) symbol.inherit(cproperties[ci]);
|
236
|
+
}
|
237
|
+
//}
|
238
|
+
}
|
239
|
+
else LOG.warn("Can't augment contributer: "+augments[i]+", not found.");
|
240
|
+
}
|
241
|
+
}
|
@@ -0,0 +1,41 @@
|
|
1
|
+
|
2
|
+
/**
|
3
|
+
@constructor
|
4
|
+
*/
|
5
|
+
JSDOC.TextStream = function(text) {
|
6
|
+
if (typeof(text) == "undefined") text = "";
|
7
|
+
text = ""+text;
|
8
|
+
this.text = text;
|
9
|
+
this.cursor = 0;
|
10
|
+
}
|
11
|
+
|
12
|
+
JSDOC.TextStream.prototype.look = function(n) {
|
13
|
+
if (typeof n == "undefined") n = 0;
|
14
|
+
|
15
|
+
if (this.cursor+n < 0 || this.cursor+n >= this.text.length) {
|
16
|
+
var result = new String("");
|
17
|
+
result.eof = true;
|
18
|
+
return result;
|
19
|
+
}
|
20
|
+
return this.text.charAt(this.cursor+n);
|
21
|
+
}
|
22
|
+
|
23
|
+
JSDOC.TextStream.prototype.next = function(n) {
|
24
|
+
if (typeof n == "undefined") n = 1;
|
25
|
+
if (n < 1) return null;
|
26
|
+
|
27
|
+
var pulled = "";
|
28
|
+
for (var i = 0; i < n; i++) {
|
29
|
+
if (this.cursor+i < this.text.length) {
|
30
|
+
pulled += this.text.charAt(this.cursor+i);
|
31
|
+
}
|
32
|
+
else {
|
33
|
+
var result = new String("");
|
34
|
+
result.eof = true;
|
35
|
+
return result;
|
36
|
+
}
|
37
|
+
}
|
38
|
+
|
39
|
+
this.cursor += n;
|
40
|
+
return pulled;
|
41
|
+
}
|
@@ -0,0 +1,18 @@
|
|
1
|
+
if (typeof JSDOC == "undefined") JSDOC = {};
|
2
|
+
|
3
|
+
/**
|
4
|
+
@constructor
|
5
|
+
*/
|
6
|
+
JSDOC.Token = function(data, type, name) {
|
7
|
+
this.data = data;
|
8
|
+
this.type = type;
|
9
|
+
this.name = name;
|
10
|
+
}
|
11
|
+
|
12
|
+
JSDOC.Token.prototype.toString = function() {
|
13
|
+
return "<"+this.type+" name=\""+this.name+"\">"+this.data+"</"+this.type+">";
|
14
|
+
}
|
15
|
+
|
16
|
+
JSDOC.Token.prototype.is = function(what) {
|
17
|
+
return this.name === what || this.type === what;
|
18
|
+
}
|
@@ -0,0 +1,332 @@
|
|
1
|
+
if (typeof JSDOC == "undefined") JSDOC = {};
|
2
|
+
|
3
|
+
/**
|
4
|
+
@class Search a {@link JSDOC.TextStream} for language tokens.
|
5
|
+
*/
|
6
|
+
JSDOC.TokenReader = function() {
|
7
|
+
this.keepDocs = true;
|
8
|
+
this.keepWhite = false;
|
9
|
+
this.keepComments = false;
|
10
|
+
}
|
11
|
+
|
12
|
+
/**
|
13
|
+
@type {JSDOC.Token[]}
|
14
|
+
*/
|
15
|
+
JSDOC.TokenReader.prototype.tokenize = function(/**JSDOC.TextStream*/stream) {
|
16
|
+
var tokens = [];
|
17
|
+
/**@ignore*/ tokens.last = function() { return tokens[tokens.length-1]; }
|
18
|
+
/**@ignore*/ tokens.lastSym = function() {
|
19
|
+
for (var i = tokens.length-1; i >= 0; i--) {
|
20
|
+
if (!(tokens[i].is("WHIT") || tokens[i].is("COMM"))) return tokens[i];
|
21
|
+
}
|
22
|
+
}
|
23
|
+
|
24
|
+
while (!stream.look().eof) {
|
25
|
+
if (this.read_mlcomment(stream, tokens)) continue;
|
26
|
+
if (this.read_slcomment(stream, tokens)) continue;
|
27
|
+
if (this.read_dbquote(stream, tokens)) continue;
|
28
|
+
if (this.read_snquote(stream, tokens)) continue;
|
29
|
+
if (this.read_regx(stream, tokens)) continue;
|
30
|
+
if (this.read_numb(stream, tokens)) continue;
|
31
|
+
if (this.read_punc(stream, tokens)) continue;
|
32
|
+
if (this.read_newline(stream, tokens)) continue;
|
33
|
+
if (this.read_space(stream, tokens)) continue;
|
34
|
+
if (this.read_word(stream, tokens)) continue;
|
35
|
+
|
36
|
+
// if execution reaches here then an error has happened
|
37
|
+
tokens.push(new JSDOC.Token(stream.next(), "TOKN", "UNKNOWN_TOKEN"));
|
38
|
+
}
|
39
|
+
return tokens;
|
40
|
+
}
|
41
|
+
|
42
|
+
/**
|
43
|
+
@returns {Boolean} Was the token found?
|
44
|
+
*/
|
45
|
+
JSDOC.TokenReader.prototype.read_word = function(/**JSDOC.TokenStream*/stream, tokens) {
|
46
|
+
var found = "";
|
47
|
+
while (!stream.look().eof && JSDOC.Lang.isWordChar(stream.look())) {
|
48
|
+
found += stream.next();
|
49
|
+
}
|
50
|
+
|
51
|
+
if (found === "") {
|
52
|
+
return false;
|
53
|
+
}
|
54
|
+
else {
|
55
|
+
var name;
|
56
|
+
if ((name = JSDOC.Lang.keyword(found))) tokens.push(new JSDOC.Token(found, "KEYW", name));
|
57
|
+
else tokens.push(new JSDOC.Token(found, "NAME", "NAME"));
|
58
|
+
return true;
|
59
|
+
}
|
60
|
+
}
|
61
|
+
|
62
|
+
/**
|
63
|
+
@returns {Boolean} Was the token found?
|
64
|
+
*/
|
65
|
+
JSDOC.TokenReader.prototype.read_punc = function(/**JSDOC.TokenStream*/stream, tokens) {
|
66
|
+
var found = "";
|
67
|
+
var name;
|
68
|
+
while (!stream.look().eof && JSDOC.Lang.punc(found+stream.look())) {
|
69
|
+
found += stream.next();
|
70
|
+
}
|
71
|
+
|
72
|
+
if (found === "") {
|
73
|
+
return false;
|
74
|
+
}
|
75
|
+
else {
|
76
|
+
tokens.push(new JSDOC.Token(found, "PUNC", JSDOC.Lang.punc(found)));
|
77
|
+
return true;
|
78
|
+
}
|
79
|
+
}
|
80
|
+
|
81
|
+
/**
|
82
|
+
@returns {Boolean} Was the token found?
|
83
|
+
*/
|
84
|
+
JSDOC.TokenReader.prototype.read_space = function(/**JSDOC.TokenStream*/stream, tokens) {
|
85
|
+
var found = "";
|
86
|
+
|
87
|
+
while (!stream.look().eof && JSDOC.Lang.isSpace(stream.look())) {
|
88
|
+
found += stream.next();
|
89
|
+
}
|
90
|
+
|
91
|
+
if (found === "") {
|
92
|
+
return false;
|
93
|
+
}
|
94
|
+
else {
|
95
|
+
if (this.collapseWhite) found = " ";
|
96
|
+
if (this.keepWhite) tokens.push(new JSDOC.Token(found, "WHIT", "SPACE"));
|
97
|
+
return true;
|
98
|
+
}
|
99
|
+
}
|
100
|
+
|
101
|
+
/**
|
102
|
+
@returns {Boolean} Was the token found?
|
103
|
+
*/
|
104
|
+
JSDOC.TokenReader.prototype.read_newline = function(/**JSDOC.TokenStream*/stream, tokens) {
|
105
|
+
var found = "";
|
106
|
+
|
107
|
+
while (!stream.look().eof && JSDOC.Lang.isNewline(stream.look())) {
|
108
|
+
found += stream.next();
|
109
|
+
}
|
110
|
+
|
111
|
+
if (found === "") {
|
112
|
+
return false;
|
113
|
+
}
|
114
|
+
else {
|
115
|
+
if (this.collapseWhite) found = "\n";
|
116
|
+
if (this.keepWhite) tokens.push(new JSDOC.Token(found, "WHIT", "NEWLINE"));
|
117
|
+
return true;
|
118
|
+
}
|
119
|
+
}
|
120
|
+
|
121
|
+
/**
|
122
|
+
@returns {Boolean} Was the token found?
|
123
|
+
*/
|
124
|
+
JSDOC.TokenReader.prototype.read_mlcomment = function(/**JSDOC.TokenStream*/stream, tokens) {
|
125
|
+
if (stream.look() == "/" && stream.look(1) == "*") {
|
126
|
+
var found = stream.next(2);
|
127
|
+
|
128
|
+
while (!stream.look().eof && !(stream.look(-1) == "/" && stream.look(-2) == "*")) {
|
129
|
+
found += stream.next();
|
130
|
+
}
|
131
|
+
|
132
|
+
// to start doclet we allow /** or /*** but not /**/ or /****
|
133
|
+
if (/^\/\*\*([^\/]|\*[^*])/.test(found) && this.keepDocs) tokens.push(new JSDOC.Token(found, "COMM", "JSDOC"));
|
134
|
+
else if (this.keepComments) tokens.push(new JSDOC.Token(found, "COMM", "MULTI_LINE_COMM"));
|
135
|
+
return true;
|
136
|
+
}
|
137
|
+
return false;
|
138
|
+
}
|
139
|
+
|
140
|
+
/**
|
141
|
+
@returns {Boolean} Was the token found?
|
142
|
+
*/
|
143
|
+
JSDOC.TokenReader.prototype.read_slcomment = function(/**JSDOC.TokenStream*/stream, tokens) {
|
144
|
+
var found;
|
145
|
+
if (
|
146
|
+
(stream.look() == "/" && stream.look(1) == "/" && (found=stream.next(2)))
|
147
|
+
||
|
148
|
+
(stream.look() == "<" && stream.look(1) == "!" && stream.look(2) == "-" && stream.look(3) == "-" && (found=stream.next(4)))
|
149
|
+
) {
|
150
|
+
|
151
|
+
while (!stream.look().eof && !JSDOC.Lang.isNewline(stream.look())) {
|
152
|
+
found += stream.next();
|
153
|
+
}
|
154
|
+
|
155
|
+
if (this.keepComments) {
|
156
|
+
tokens.push(new JSDOC.Token(found, "COMM", "SINGLE_LINE_COMM"));
|
157
|
+
}
|
158
|
+
return true;
|
159
|
+
}
|
160
|
+
return false;
|
161
|
+
}
|
162
|
+
|
163
|
+
/**
|
164
|
+
@returns {Boolean} Was the token found?
|
165
|
+
*/
|
166
|
+
JSDOC.TokenReader.prototype.read_dbquote = function(/**JSDOC.TokenStream*/stream, tokens) {
|
167
|
+
if (stream.look() == "\"") {
|
168
|
+
// find terminator
|
169
|
+
var string = stream.next();
|
170
|
+
|
171
|
+
while (!stream.look().eof) {
|
172
|
+
if (stream.look() == "\\") {
|
173
|
+
if (JSDOC.Lang.isNewline(stream.look(1))) {
|
174
|
+
do {
|
175
|
+
stream.next();
|
176
|
+
} while (!stream.look().eof && JSDOC.Lang.isNewline(stream.look()));
|
177
|
+
string += "\\\n";
|
178
|
+
}
|
179
|
+
else {
|
180
|
+
string += stream.next(2);
|
181
|
+
}
|
182
|
+
}
|
183
|
+
else if (stream.look() == "\"") {
|
184
|
+
string += stream.next();
|
185
|
+
tokens.push(new JSDOC.Token(string, "STRN", "DOUBLE_QUOTE"));
|
186
|
+
return true;
|
187
|
+
}
|
188
|
+
else {
|
189
|
+
string += stream.next();
|
190
|
+
}
|
191
|
+
}
|
192
|
+
}
|
193
|
+
return false; // error! unterminated string
|
194
|
+
}
|
195
|
+
|
196
|
+
/**
|
197
|
+
@returns {Boolean} Was the token found?
|
198
|
+
*/
|
199
|
+
JSDOC.TokenReader.prototype.read_snquote = function(/**JSDOC.TokenStream*/stream, tokens) {
|
200
|
+
if (stream.look() == "'") {
|
201
|
+
// find terminator
|
202
|
+
var string = stream.next();
|
203
|
+
|
204
|
+
while (!stream.look().eof) {
|
205
|
+
if (stream.look() == "\\") { // escape sequence
|
206
|
+
string += stream.next(2);
|
207
|
+
}
|
208
|
+
else if (stream.look() == "'") {
|
209
|
+
string += stream.next();
|
210
|
+
tokens.push(new JSDOC.Token(string, "STRN", "SINGLE_QUOTE"));
|
211
|
+
return true;
|
212
|
+
}
|
213
|
+
else {
|
214
|
+
string += stream.next();
|
215
|
+
}
|
216
|
+
}
|
217
|
+
}
|
218
|
+
return false; // error! unterminated string
|
219
|
+
}
|
220
|
+
|
221
|
+
/**
|
222
|
+
@returns {Boolean} Was the token found?
|
223
|
+
*/
|
224
|
+
JSDOC.TokenReader.prototype.read_numb = function(/**JSDOC.TokenStream*/stream, tokens) {
|
225
|
+
if (stream.look() === "0" && stream.look(1) == "x") {
|
226
|
+
return this.read_hex(stream, tokens);
|
227
|
+
}
|
228
|
+
|
229
|
+
var found = "";
|
230
|
+
|
231
|
+
while (!stream.look().eof && JSDOC.Lang.isNumber(found+stream.look())){
|
232
|
+
found += stream.next();
|
233
|
+
}
|
234
|
+
|
235
|
+
if (found === "") {
|
236
|
+
return false;
|
237
|
+
}
|
238
|
+
else {
|
239
|
+
if (/^0[0-7]/.test(found)) tokens.push(new JSDOC.Token(found, "NUMB", "OCTAL"));
|
240
|
+
else tokens.push(new JSDOC.Token(found, "NUMB", "DECIMAL"));
|
241
|
+
return true;
|
242
|
+
}
|
243
|
+
}
|
244
|
+
/*t:
|
245
|
+
requires("../lib/JSDOC/TextStream.js");
|
246
|
+
requires("../lib/JSDOC/Token.js");
|
247
|
+
requires("../lib/JSDOC/Lang.js");
|
248
|
+
|
249
|
+
plan(3, "testing JSDOC.TokenReader.prototype.read_numb");
|
250
|
+
|
251
|
+
//// setup
|
252
|
+
var src = "function foo(num){while (num+8.0 >= 0x20 && num < 0777){}}";
|
253
|
+
var tr = new JSDOC.TokenReader();
|
254
|
+
var tokens = tr.tokenize(new JSDOC.TextStream(src));
|
255
|
+
|
256
|
+
var hexToken, octToken, decToken;
|
257
|
+
for (var i = 0; i < tokens.length; i++) {
|
258
|
+
if (tokens[i].name == "HEX_DEC") hexToken = tokens[i];
|
259
|
+
if (tokens[i].name == "OCTAL") octToken = tokens[i];
|
260
|
+
if (tokens[i].name == "DECIMAL") decToken = tokens[i];
|
261
|
+
}
|
262
|
+
////
|
263
|
+
|
264
|
+
is(decToken.data, "8.0", "decimal number is found in source.");
|
265
|
+
is(hexToken.data, "0x20", "hexdec number is found in source (issue #99).");
|
266
|
+
is(octToken.data, "0777", "octal number is found in source.");
|
267
|
+
*/
|
268
|
+
|
269
|
+
/**
|
270
|
+
@returns {Boolean} Was the token found?
|
271
|
+
*/
|
272
|
+
JSDOC.TokenReader.prototype.read_hex = function(/**JSDOC.TokenStream*/stream, tokens) {
|
273
|
+
var found = stream.next(2);
|
274
|
+
|
275
|
+
while (!stream.look().eof) {
|
276
|
+
if (JSDOC.Lang.isHexDec(found) && !JSDOC.Lang.isHexDec(found+stream.look())) { // done
|
277
|
+
tokens.push(new JSDOC.Token(found, "NUMB", "HEX_DEC"));
|
278
|
+
return true;
|
279
|
+
}
|
280
|
+
else {
|
281
|
+
found += stream.next();
|
282
|
+
}
|
283
|
+
}
|
284
|
+
return false;
|
285
|
+
}
|
286
|
+
|
287
|
+
/**
|
288
|
+
@returns {Boolean} Was the token found?
|
289
|
+
*/
|
290
|
+
JSDOC.TokenReader.prototype.read_regx = function(/**JSDOC.TokenStream*/stream, tokens) {
|
291
|
+
var last;
|
292
|
+
if (
|
293
|
+
stream.look() == "/"
|
294
|
+
&&
|
295
|
+
(
|
296
|
+
|
297
|
+
(
|
298
|
+
!(last = tokens.lastSym()) // there is no last, the regex is the first symbol
|
299
|
+
||
|
300
|
+
(
|
301
|
+
!last.is("NUMB")
|
302
|
+
&& !last.is("NAME")
|
303
|
+
&& !last.is("RIGHT_PAREN")
|
304
|
+
&& !last.is("RIGHT_BRACKET")
|
305
|
+
)
|
306
|
+
)
|
307
|
+
)
|
308
|
+
) {
|
309
|
+
var regex = stream.next();
|
310
|
+
|
311
|
+
while (!stream.look().eof) {
|
312
|
+
if (stream.look() == "\\") { // escape sequence
|
313
|
+
regex += stream.next(2);
|
314
|
+
}
|
315
|
+
else if (stream.look() == "/") {
|
316
|
+
regex += stream.next();
|
317
|
+
|
318
|
+
while (/[gmi]/.test(stream.look())) {
|
319
|
+
regex += stream.next();
|
320
|
+
}
|
321
|
+
|
322
|
+
tokens.push(new JSDOC.Token(regex, "REGX", "REGX"));
|
323
|
+
return true;
|
324
|
+
}
|
325
|
+
else {
|
326
|
+
regex += stream.next();
|
327
|
+
}
|
328
|
+
}
|
329
|
+
// error: unterminated regex
|
330
|
+
}
|
331
|
+
return false;
|
332
|
+
}
|