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,264 @@
1
+ <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
2
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
3
+ <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
4
+ <head>
5
+ <meta http-equiv="content-type" content="text/html; charset=utf-8" />
6
+ <meta name="generator" content="JsDoc Toolkit" />
7
+
8
+ <title>JsDoc Reference - _global_</title>
9
+
10
+ <style type="text/css">
11
+ /* default.css */
12
+ body
13
+ {
14
+ font: 12px "Lucida Grande", Tahoma, Arial, Helvetica, sans-serif;
15
+ width: 800px;
16
+ }
17
+
18
+ .header
19
+ {
20
+ clear: both;
21
+ background-color: #ccc;
22
+ padding: 8px;
23
+ }
24
+
25
+ h1
26
+ {
27
+ font-size: 150%;
28
+ font-weight: bold;
29
+ padding: 0;
30
+ margin: 1em 0 0 .3em;
31
+ }
32
+
33
+ hr
34
+ {
35
+ border: none 0;
36
+ border-top: 1px solid #7F8FB1;
37
+ height: 1px;
38
+ }
39
+
40
+ pre.code
41
+ {
42
+ display: block;
43
+ padding: 8px;
44
+ border: 1px dashed #ccc;
45
+ }
46
+
47
+ #index
48
+ {
49
+ margin-top: 24px;
50
+ float: left;
51
+ width: 160px;
52
+ position: absolute;
53
+ left: 8px;
54
+ background-color: #F3F3F3;
55
+ padding: 8px;
56
+ }
57
+
58
+ #content
59
+ {
60
+ margin-left: 190px;
61
+ width: 600px;
62
+ }
63
+
64
+ .classList
65
+ {
66
+ list-style-type: none;
67
+ padding: 0;
68
+ margin: 0 0 0 8px;
69
+ font-family: arial, sans-serif;
70
+ font-size: 1em;
71
+ overflow: auto;
72
+ }
73
+
74
+ .classList li
75
+ {
76
+ padding: 0;
77
+ margin: 0 0 8px 0;
78
+ }
79
+
80
+ .summaryTable { width: 100%; }
81
+
82
+ h1.classTitle
83
+ {
84
+ font-size:170%;
85
+ line-height:130%;
86
+ }
87
+
88
+ h2 { font-size: 110%; }
89
+ caption, div.sectionTitle
90
+ {
91
+ background-color: #7F8FB1;
92
+ color: #fff;
93
+ font-size:130%;
94
+ text-align: left;
95
+ padding: 2px 6px 2px 6px;
96
+ border: 1px #7F8FB1 solid;
97
+ }
98
+
99
+ div.sectionTitle { margin-bottom: 8px; }
100
+ .summaryTable thead { display: none; }
101
+
102
+ .summaryTable td
103
+ {
104
+ vertical-align: top;
105
+ padding: 4px;
106
+ border-bottom: 1px #7F8FB1 solid;
107
+ border-right: 1px #7F8FB1 solid;
108
+ }
109
+
110
+ /*col#summaryAttributes {}*/
111
+ .summaryTable td.attributes
112
+ {
113
+ border-left: 1px #7F8FB1 solid;
114
+ width: 140px;
115
+ text-align: right;
116
+ }
117
+
118
+ td.attributes, .fixedFont
119
+ {
120
+ line-height: 15px;
121
+ color: #002EBE;
122
+ font-family: "Courier New",Courier,monospace;
123
+ font-size: 13px;
124
+ }
125
+
126
+ .summaryTable td.nameDescription
127
+ {
128
+ text-align: left;
129
+ font-size: 13px;
130
+ line-height: 15px;
131
+ }
132
+
133
+ .summaryTable td.nameDescription, .description
134
+ {
135
+ line-height: 15px;
136
+ padding: 4px;
137
+ padding-left: 4px;
138
+ }
139
+
140
+ .summaryTable { margin-bottom: 8px; }
141
+
142
+ ul.inheritsList
143
+ {
144
+ list-style: square;
145
+ margin-left: 20px;
146
+ padding-left: 0;
147
+ }
148
+
149
+ .detailList {
150
+ margin-left: 20px;
151
+ line-height: 15px;
152
+ }
153
+ .detailList dt { margin-left: 20px; }
154
+
155
+ .detailList .heading
156
+ {
157
+ font-weight: bold;
158
+ padding-bottom: 6px;
159
+ margin-left: 0;
160
+ }
161
+
162
+ .light, td.attributes, .light a:link, .light a:visited
163
+ {
164
+ color: #777;
165
+ font-style: italic;
166
+ }
167
+
168
+ .fineprint
169
+ {
170
+ text-align: right;
171
+ font-size: 10px;
172
+ }
173
+ </style>
174
+ </head>
175
+
176
+ <body>
177
+ <!-- ============================== header ================================= -->
178
+ <!-- begin static/header.html -->
179
+ <div id="header">
180
+ </div>
181
+ <!-- end static/header.html -->
182
+
183
+ <!-- ============================== classes index ============================ -->
184
+ <div id="index">
185
+ <!-- begin publish.classesIndex -->
186
+ <div align="center"><a href="../index.html">Class Index</a>
187
+ | <a href="../files.html">File Index</a></div>
188
+ <hr />
189
+ <h2>Classes</h2>
190
+ <ul class="classList">
191
+
192
+ <li><i><a href="../symbols/_global_.html">_global_</a></i></li>
193
+
194
+ <li><a href="../symbols/Error.html">Error</a></li>
195
+
196
+ <li><a href="../symbols/File.html">File</a></li>
197
+
198
+ <li><a href="../symbols/File.NoSuchFileError.html">File.NoSuchFileError</a></li>
199
+
200
+ <li><a href="../symbols/Kernel.html">Kernel</a></li>
201
+
202
+ <li><a href="../symbols/LoadError.html">LoadError</a></li>
203
+
204
+ <li><a href="../symbols/SelfConceptError.html">SelfConceptError</a></li>
205
+
206
+ <li><a href="../symbols/Sys.html">Sys</a></li>
207
+
208
+ <li><a href="../symbols/XPCBuiltins.html">XPCBuiltins</a></li>
209
+
210
+ </ul>
211
+ <hr />
212
+ <!-- end publish.classesIndex -->
213
+ </div>
214
+
215
+ <div id="content">
216
+ <!-- ============================== class title ============================ -->
217
+ <h1 class="classTitle">
218
+
219
+ Built-In Namespace _global_
220
+ </h1>
221
+
222
+ <!-- ============================== class summary ========================== -->
223
+ <p class="description">
224
+
225
+
226
+
227
+
228
+
229
+ </p>
230
+
231
+ <!-- ============================== constructor summary ==================== -->
232
+
233
+
234
+ <!-- ============================== properties summary ===================== -->
235
+
236
+
237
+ <!-- ============================== methods summary ======================== -->
238
+
239
+ <!-- ============================== events summary ======================== -->
240
+
241
+
242
+ <!-- ============================== constructor details ==================== -->
243
+
244
+
245
+ <!-- ============================== field details ========================== -->
246
+
247
+
248
+ <!-- ============================== method details ========================= -->
249
+
250
+
251
+ <!-- ============================== event details ========================= -->
252
+
253
+
254
+ <hr />
255
+ </div>
256
+
257
+
258
+ <!-- ============================== footer ================================= -->
259
+ <div class="fineprint" style="clear:both">
260
+
261
+ Documentation generated by <a href="http://code.google.com/p/jsdoc-toolkit/" target="_blank">JsDoc Toolkit</a> 2.3.0 on Mon Oct 05 2009 22:11:35 GMT-0500 (CDT)
262
+ </div>
263
+ </body>
264
+ </html>
@@ -0,0 +1,82 @@
1
+ <html><head><meta http-equiv="content-type" content="text/html; charset=utf-8"> <style>
2
+ .KEYW {color: #933;}
3
+ .COMM {color: #bbb; font-style: italic;}
4
+ .NUMB {color: #393;}
5
+ .STRN {color: #393;}
6
+ .REGX {color: #339;}
7
+ .line {border-right: 1px dotted #666; color: #666; font-style: normal;}
8
+ </style></head><body><pre><span class='line'> 1</span> <span class="COMM">/**
9
+ <span class='line'> 2</span> * @fileoverview This file defines the implementation of our File object.
10
+ <span class='line'> 3</span> */</span><span class="WHIT">
11
+ <span class='line'> 4</span>
12
+ <span class='line'> 5</span> </span><span class="COMM">/**
13
+ <span class='line'> 6</span> * @class File class used for things such as creating filesystem paths, reading files, etc.
14
+ <span class='line'> 7</span> */</span><span class="WHIT">
15
+ <span class='line'> 8</span> </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="NAME">File</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
16
+ <span class='line'> 9</span>
17
+ <span class='line'> 10</span> </span><span class="COMM">/**
18
+ <span class='line'> 11</span> * @class Exception representing an error loading a file.
19
+ <span class='line'> 12</span> * @extends Error
20
+ <span class='line'> 13</span> * @constructor
21
+ <span class='line'> 14</span> * @param {String} message The error message to be given for this exception.
22
+ <span class='line'> 15</span> * @returns {Error}
23
+ <span class='line'> 16</span> */</span><span class="WHIT">
24
+ <span class='line'> 17</span> </span><span class="NAME">File.NoSuchFileError</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">message</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
25
+ <span class='line'> 18</span> </span><span class="WHIT"> </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">err</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">new</span><span class="WHIT"> </span><span class="NAME">Error</span><span class="PUNC">(</span><span class="NAME">message</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
26
+ <span class='line'> 19</span> </span><span class="WHIT"> </span><span class="NAME">err.name</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="STRN">"File.NoSuchFileError"</span><span class="PUNC">;</span><span class="WHIT">
27
+ <span class='line'> 20</span> </span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">err</span><span class="PUNC">;</span><span class="WHIT">
28
+ <span class='line'> 21</span> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
29
+ <span class='line'> 22</span>
30
+ <span class='line'> 23</span> </span><span class="COMM">/**
31
+ <span class='line'> 24</span> * Joins the given string arguments together using the operating system's native path
32
+ <span class='line'> 25</span> * separator.
33
+ <span class='line'> 26</span> * @param {String[]} components Set of strings to join together.
34
+ <span class='line'> 27</span> * @returns {String} The resulting path.
35
+ <span class='line'> 28</span> */</span><span class="WHIT">
36
+ <span class='line'> 29</span> </span><span class="NAME">File.join</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
37
+ <span class='line'> 30</span> </span><span class="WHIT"> </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">file</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">new</span><span class="WHIT"> </span><span class="NAME">XPCBuiltins.nsILocalFile</span><span class="PUNC">(</span><span class="NAME">arguments</span><span class="PUNC">[</span><span class="NUMB">0</span><span class="PUNC">]</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
38
+ <span class='line'> 31</span> </span><span class="WHIT">
39
+ <span class='line'> 32</span> </span><span class="KEYW">for</span><span class="PUNC">(</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">i</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NUMB">1</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="NAME">i</span><span class="WHIT"> </span><span class="PUNC">&lt;</span><span class="WHIT"> </span><span class="NAME">arguments.length</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="NAME">i</span><span class="PUNC">++</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
40
+ <span class='line'> 33</span> </span><span class="WHIT"> </span><span class="NAME">file.append</span><span class="PUNC">(</span><span class="NAME">arguments</span><span class="PUNC">[</span><span class="NAME">i</span><span class="PUNC">]</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
41
+ <span class='line'> 34</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
42
+ <span class='line'> 35</span> </span><span class="WHIT">
43
+ <span class='line'> 36</span> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">file.path</span><span class="PUNC">;</span><span class="WHIT">
44
+ <span class='line'> 37</span> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
45
+ <span class='line'> 38</span>
46
+ <span class='line'> 39</span> </span><span class="COMM">/**
47
+ <span class='line'> 40</span> * Reads the given number of bytes (or the entire contents if the argument is ommitted)
48
+ <span class='line'> 41</span> * from the specified file
49
+ <span class='line'> 42</span> * @param {String} filePath Path to a file.
50
+ <span class='line'> 43</span> * @param {int} [maxBytes] Number of bytes to read from the file. Defaults to entire file.
51
+ <span class='line'> 44</span> * @returns {String} The data read from the given file.
52
+ <span class='line'> 45</span> */</span><span class="WHIT">
53
+ <span class='line'> 46</span> </span><span class="NAME">File.read</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">filePath</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">maxBytes</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
54
+ <span class='line'> 47</span> </span><span class="WHIT"> </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">file</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">new</span><span class="WHIT"> </span><span class="NAME">XPCBuiltins.nsILocalFile</span><span class="PUNC">(</span><span class="NAME">filePath</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
55
+ <span class='line'> 48</span>
56
+ <span class='line'> 49</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="PUNC">!</span><span class="NAME">file.exists</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT"> </span><span class="KEYW">throw</span><span class="PUNC">(</span><span class="KEYW">new</span><span class="WHIT"> </span><span class="NAME">File.NoSuchFileError</span><span class="PUNC">(</span><span class="STRN">"No such file or directory - "</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">filePath</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
57
+ <span class='line'> 50</span>
58
+ <span class='line'> 51</span> </span><span class="WHIT"> </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">fileInputStream</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">$Cc</span><span class="PUNC">[</span><span class="STRN">"@mozilla.org/network/file-input-stream;1"</span><span class="PUNC">]</span><span class="PUNC">.</span><span class="NAME">createInstance</span><span class="PUNC">(</span><span class="NAME">$Ci.nsIFileInputStream</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
59
+ <span class='line'> 52</span> </span><span class="WHIT"> </span><span class="NAME">fileInputStream.init</span><span class="PUNC">(</span><span class="NAME">file</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="PUNC">-</span><span class="NUMB">1</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="PUNC">-</span><span class="NUMB">1</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NUMB">0</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
60
+ <span class='line'> 53</span> </span><span class="WHIT">
61
+ <span class='line'> 54</span> </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">binaryInputStream</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">$Cc</span><span class="PUNC">[</span><span class="STRN">"@mozilla.org/binaryinputstream;1"</span><span class="PUNC">]</span><span class="PUNC">.</span><span class="NAME">createInstance</span><span class="PUNC">(</span><span class="NAME">$Ci.nsIBinaryInputStream</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
62
+ <span class='line'> 55</span> </span><span class="WHIT"> </span><span class="NAME">binaryInputStream.setInputStream</span><span class="PUNC">(</span><span class="NAME">fileInputStream</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
63
+ <span class='line'> 56</span> </span><span class="WHIT">
64
+ <span class='line'> 57</span> </span><span class="KEYW">try</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
65
+ <span class='line'> 58</span> </span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">binaryInputStream.readBytes</span><span class="PUNC">(</span><span class="PUNC">(</span><span class="NAME">maxBytes</span><span class="WHIT"> </span><span class="PUNC">==</span><span class="WHIT"> </span><span class="KEYW">null</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">?</span><span class="WHIT"> </span><span class="NAME">binaryInputStream.available</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NAME">maxBytes</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
66
+ <span class='line'> 59</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT"> </span><span class="KEYW">catch</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">e</span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="NAME">e.result</span><span class="WHIT"> </span><span class="PUNC">==</span><span class="WHIT"> </span><span class="NAME">$Cr.NS_ERROR_FAILURE</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
67
+ <span class='line'> 60</span> </span><span class="WHIT"> </span><span class="COMM">// FIXME - hack</span><span class="WHIT">
68
+ <span class='line'> 61</span> </span><span class="WHIT"> </span><span class="COMM">// If we hit this, we're probably trying to read from a special device like a pipe. Fall back to</span><span class="WHIT">
69
+ <span class='line'> 62</span> </span><span class="WHIT"> </span><span class="COMM">// reading a byte at a time and returning when we likely hit EOF (as indicated by another exception)</span><span class="WHIT">
70
+ <span class='line'> 63</span> </span><span class="WHIT"> </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">output</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="STRN">''</span><span class="PUNC">;</span><span class="WHIT">
71
+ <span class='line'> 64</span> </span><span class="WHIT"> </span><span class="KEYW">while</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="KEYW">true</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
72
+ <span class='line'> 65</span> </span><span class="WHIT"> </span><span class="KEYW">try</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
73
+ <span class='line'> 66</span> </span><span class="WHIT"> </span><span class="NAME">output</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">output</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">binaryInputStream.readBytes</span><span class="PUNC">(</span><span class="PUNC">(</span><span class="NAME">maxBytes</span><span class="WHIT"> </span><span class="PUNC">==</span><span class="WHIT"> </span><span class="KEYW">null</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">?</span><span class="WHIT"> </span><span class="NUMB">1</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NAME">maxBytes</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
74
+ <span class='line'> 67</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">maxBytes</span><span class="WHIT"> </span><span class="PUNC">!=</span><span class="WHIT"> </span><span class="KEYW">null</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">output</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
75
+ <span class='line'> 68</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT"> </span><span class="KEYW">catch</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">e</span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="NAME">e.result</span><span class="WHIT"> </span><span class="PUNC">==</span><span class="WHIT"> </span><span class="NAME">$Cr.NS_ERROR_FAILURE</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
76
+ <span class='line'> 69</span> </span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">output</span><span class="PUNC">;</span><span class="WHIT">
77
+ <span class='line'> 70</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
78
+ <span class='line'> 71</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
79
+ <span class='line'> 72</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT"> </span><span class="KEYW">finally</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
80
+ <span class='line'> 73</span> </span><span class="WHIT"> </span><span class="NAME">binaryInputStream.close</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
81
+ <span class='line'> 74</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
82
+ <span class='line'> 75</span> </span><span class="PUNC">}</span><span class="PUNC">;</span></pre></body></html>
@@ -0,0 +1,250 @@
1
+ <html><head><meta http-equiv="content-type" content="text/html; charset=utf-8"> <style>
2
+ .KEYW {color: #933;}
3
+ .COMM {color: #bbb; font-style: italic;}
4
+ .NUMB {color: #393;}
5
+ .STRN {color: #393;}
6
+ .REGX {color: #339;}
7
+ .line {border-right: 1px dotted #666; color: #666; font-style: normal;}
8
+ </style></head><body><pre><span class='line'> 1</span> <span class="COMM">/**
9
+ <span class='line'> 2</span> * @fileoverview This file specifies a set of globally useful features/shortcuts
10
+ <span class='line'> 3</span> * and defines our "Kernel" object, which is the base for doing a lot of simple
11
+ <span class='line'> 4</span> * things with XPCOMCore such as loading in other files and printing to the
12
+ <span class='line'> 5</span> * console.
13
+ <span class='line'> 6</span> */</span><span class="WHIT">
14
+ <span class='line'> 7</span>
15
+ <span class='line'> 8</span> </span><span class="COMM">/**
16
+ <span class='line'> 9</span> * @class Exception representing an error loading a file.
17
+ <span class='line'> 10</span> * @extends Error
18
+ <span class='line'> 11</span> * @constructor
19
+ <span class='line'> 12</span> * @param {String} message The error message to be given for this exception.
20
+ <span class='line'> 13</span> * @returns {Error}
21
+ <span class='line'> 14</span> */</span><span class="WHIT">
22
+ <span class='line'> 15</span> </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="NAME">LoadError</span><span class="PUNC">(</span><span class="NAME">message</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
23
+ <span class='line'> 16</span> </span><span class="WHIT"> </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">err</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">new</span><span class="WHIT"> </span><span class="NAME">Error</span><span class="PUNC">(</span><span class="NAME">message</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
24
+ <span class='line'> 17</span> </span><span class="WHIT"> </span><span class="NAME">err.name</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">arguments.callee.name</span><span class="PUNC">;</span><span class="WHIT">
25
+ <span class='line'> 18</span> </span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">err</span><span class="PUNC">;</span><span class="WHIT">
26
+ <span class='line'> 19</span> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
27
+ <span class='line'> 20</span>
28
+ <span class='line'> 21</span> </span><span class="COMM">/**
29
+ <span class='line'> 22</span> * @class Exception representing an error determining what the path to the currently executing file is.
30
+ <span class='line'> 23</span> * @extends Error
31
+ <span class='line'> 24</span> * @constructor
32
+ <span class='line'> 25</span> * @param {String} message The error message to be given for this exception.
33
+ <span class='line'> 26</span> * @returns {Error}
34
+ <span class='line'> 27</span> */</span><span class="WHIT">
35
+ <span class='line'> 28</span> </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="NAME">SelfConceptError</span><span class="PUNC">(</span><span class="NAME">message</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
36
+ <span class='line'> 29</span> </span><span class="WHIT"> </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">err</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">new</span><span class="WHIT"> </span><span class="NAME">Error</span><span class="PUNC">(</span><span class="NAME">message</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
37
+ <span class='line'> 30</span> </span><span class="WHIT"> </span><span class="NAME">err.name</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">arguments.callee.name</span><span class="PUNC">;</span><span class="WHIT">
38
+ <span class='line'> 31</span> </span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">err</span><span class="PUNC">;</span><span class="WHIT">
39
+ <span class='line'> 32</span> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
40
+ <span class='line'> 33</span>
41
+ <span class='line'> 34</span> </span><span class="COMM">/**
42
+ <span class='line'> 35</span> * A pseudo-constructor to make JSDoc happy and actually document things in {@link Kernel}.
43
+ <span class='line'> 36</span> * If this method is called with an argument, all properties from {@link Kernel} are taken
44
+ <span class='line'> 37</span> * and defined as the return value of getter methods set on the given object.
45
+ <span class='line'> 38</span> * @class Our central 'class' containing a lot of properties and methods we need to
46
+ <span class='line'> 39</span> * build the rest of XPCOMCore on top of.
47
+ <span class='line'> 40</span> * @param {Object} mixinScope Optional argument, any object to mix {@link Kernel}'s properties
48
+ <span class='line'> 41</span> * into.
49
+ <span class='line'> 42</span> * @return The prototype object of the Kernel function.
50
+ <span class='line'> 43</span> */</span><span class="WHIT">
51
+ <span class='line'> 44</span> </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="NAME">Kernel</span><span class="PUNC">(</span><span class="NAME">mixinScope</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
52
+ <span class='line'> 45</span> </span><span class="WHIT"> </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">myPrototype</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">arguments.callee.prototype</span><span class="PUNC">;</span><span class="WHIT">
53
+ <span class='line'> 46</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">mixinScope</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
54
+ <span class='line'> 47</span> </span><span class="WHIT"> </span><span class="COMM">// FIXME - figure out a better way than this object jammed in here to special case our</span><span class="WHIT">
55
+ <span class='line'> 48</span> </span><span class="WHIT"> </span><span class="COMM">// methods we really want to be calling getters when they're mixed in.</span><span class="WHIT">
56
+ <span class='line'> 49</span> </span><span class="WHIT"> </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">callingGetters</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="STRN">'$CURRENT_FILE'</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="NAME">defaultArgs</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="PUNC">[</span><span class="NUMB">2</span><span class="PUNC">]</span><span class="PUNC">}</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">'$CURRENT_DIRECTORY'</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="NAME">defaultArgs</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="PUNC">[</span><span class="NUMB">3</span><span class="PUNC">]</span><span class="WHIT"> </span><span class="PUNC">}</span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
57
+ <span class='line'> 50</span> </span><span class="WHIT"> </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">makeGetter</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">attr</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">myPrototype</span><span class="PUNC">[</span><span class="NAME">attr</span><span class="PUNC">]</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT"> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
58
+ <span class='line'> 51</span> </span><span class="WHIT"> </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">makeCallingGetter</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">attr</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">argsArray</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
59
+ <span class='line'> 52</span> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
60
+ <span class='line'> 53</span> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">myPrototype</span><span class="PUNC">[</span><span class="NAME">attr</span><span class="PUNC">]</span><span class="PUNC">.</span><span class="NAME">apply</span><span class="PUNC">(</span><span class="KEYW">this</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">argsArray</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
61
+ <span class='line'> 54</span> </span><span class="PUNC">}</span><span class="WHIT">
62
+ <span class='line'> 55</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
63
+ <span class='line'> 56</span> </span><span class="WHIT">
64
+ <span class='line'> 57</span> </span><span class="KEYW">for</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">p</span><span class="WHIT"> </span><span class="KEYW">in</span><span class="WHIT"> </span><span class="NAME">myPrototype</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
65
+ <span class='line'> 58</span> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">callingGetters</span><span class="PUNC">[</span><span class="NAME">p</span><span class="PUNC">]</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
66
+ <span class='line'> 59</span> </span><span class="WHIT"> </span><span class="NAME">mixinScope.__defineGetter__</span><span class="PUNC">(</span><span class="NAME">p</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">makeCallingGetter</span><span class="PUNC">(</span><span class="NAME">p</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">callingGetters</span><span class="PUNC">[</span><span class="NAME">p</span><span class="PUNC">]</span><span class="PUNC">.</span><span class="NAME">defaultArgs</span><span class="WHIT"> </span><span class="PUNC">||</span><span class="WHIT"> </span><span class="PUNC">[</span><span class="PUNC">]</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
67
+ <span class='line'> 60</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT"> </span><span class="KEYW">else</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
68
+ <span class='line'> 61</span> </span><span class="WHIT"> </span><span class="NAME">mixinScope.__defineGetter__</span><span class="PUNC">(</span><span class="NAME">p</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">makeGetter</span><span class="PUNC">(</span><span class="NAME">p</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
69
+ <span class='line'> 62</span> </span><span class="PUNC">}</span><span class="WHIT">
70
+ <span class='line'> 63</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
71
+ <span class='line'> 64</span> </span><span class="WHIT">
72
+ <span class='line'> 65</span> </span><span class="COMM">// Load up our standard library into the mixinScope.</span><span class="WHIT">
73
+ <span class='line'> 66</span> </span><span class="WHIT"> </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">standardLibraries</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">[</span><span class="STRN">'file'</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">'sys'</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">'xpc_builtins'</span><span class="PUNC">]</span><span class="PUNC">;</span><span class="WHIT">
74
+ <span class='line'> 67</span> </span><span class="WHIT"> </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">standardLibraryLoader</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
75
+ <span class='line'> 68</span> </span><span class="WHIT"> </span><span class="NAME">standardLibraries.forEach</span><span class="PUNC">(</span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">library</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT"> </span><span class="NAME">require</span><span class="PUNC">(</span><span class="NAME">library</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="PUNC">}</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="KEYW">this</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
76
+ <span class='line'> 69</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
77
+ <span class='line'> 70</span> </span><span class="WHIT"> </span><span class="NAME">standardLibraryLoader.call</span><span class="PUNC">(</span><span class="NAME">mixinScope</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
78
+ <span class='line'> 71</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
79
+ <span class='line'> 72</span> </span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">myPrototype</span><span class="PUNC">;</span><span class="WHIT">
80
+ <span class='line'> 73</span> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
81
+ <span class='line'> 74</span>
82
+ <span class='line'> 75</span> </span><span class="NAME">Kernel.prototype</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
83
+ <span class='line'> 76</span> </span><span class="WHIT"> </span><span class="COMM">/**
84
+ <span class='line'> 77</span> * A shortcut constant to Components.classes.
85
+ <span class='line'> 78</span> */</span><span class="WHIT">
86
+ <span class='line'> 79</span> </span><span class="WHIT"> </span><span class="NAME">$Cc</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NAME">Components.classes</span><span class="PUNC">,</span><span class="WHIT">
87
+ <span class='line'> 80</span>
88
+ <span class='line'> 81</span> </span><span class="WHIT"> </span><span class="COMM">/**
89
+ <span class='line'> 82</span> * A shortcut constant to Components.interfaces.
90
+ <span class='line'> 83</span> */</span><span class="WHIT">
91
+ <span class='line'> 84</span> </span><span class="WHIT"> </span><span class="NAME">$Ci</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NAME">Components.interfaces</span><span class="PUNC">,</span><span class="WHIT">
92
+ <span class='line'> 85</span>
93
+ <span class='line'> 86</span> </span><span class="WHIT"> </span><span class="COMM">/**
94
+ <span class='line'> 87</span> * A shortcut constant to Components.results.
95
+ <span class='line'> 88</span> */</span><span class="WHIT">
96
+ <span class='line'> 89</span> </span><span class="WHIT"> </span><span class="NAME">$Cr</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NAME">Components.results</span><span class="PUNC">,</span><span class="WHIT">
97
+ <span class='line'> 90</span>
98
+ <span class='line'> 91</span> </span><span class="WHIT"> </span><span class="COMM">/**
99
+ <span class='line'> 92</span> * A shortcut constant to Components.utils.
100
+ <span class='line'> 93</span> */</span><span class="WHIT">
101
+ <span class='line'> 94</span> </span><span class="WHIT"> </span><span class="NAME">$Cu</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NAME">Components.utils</span><span class="PUNC">,</span><span class="WHIT">
102
+ <span class='line'> 95</span> </span><span class="WHIT">
103
+ <span class='line'> 96</span> </span><span class="COMM">/**
104
+ <span class='line'> 97</span> * Taking inspiration from Ruby, this defines the set of paths to check when
105
+ <span class='line'> 98</span> * trying to load a file via either {@link Kernel#load} or {@link Kernel#require}.
106
+ <span class='line'> 99</span> * @type Array
107
+ <span class='line'>100</span> */</span><span class="WHIT">
108
+ <span class='line'>101</span> </span><span class="WHIT"> </span><span class="NAME">$LOAD_PATH</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="PUNC">[</span><span class="NAME">XPCOMCoreConfig.getProperty</span><span class="PUNC">(</span><span class="STRN">'libRoot'</span><span class="PUNC">)</span><span class="PUNC">]</span><span class="PUNC">,</span><span class="WHIT">
109
+ <span class='line'>102</span>
110
+ <span class='line'>103</span> </span><span class="WHIT"> </span><span class="COMM">/**
111
+ <span class='line'>104</span> * Taking inspiration from Ruby, this defines the currently loaded files that
112
+ <span class='line'>105</span> * have been loaded through {@link Kernel#require}.
113
+ <span class='line'>106</span> * @type Array
114
+ <span class='line'>107</span> */</span><span class="WHIT">
115
+ <span class='line'>108</span> </span><span class="WHIT"> </span><span class="NAME">$LOADED_FEATURES</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="PUNC">[</span><span class="STRN">"kernel.js"</span><span class="PUNC">]</span><span class="PUNC">,</span><span class="WHIT">
116
+ <span class='line'>109</span> </span><span class="WHIT">
117
+ <span class='line'>110</span> </span><span class="COMM">/**
118
+ <span class='line'>111</span> * Taking inspiration from Ruby, this method tries to determine the filesystem path to
119
+ <span class='line'>112</span> * the caller code of this method.
120
+ <span class='line'>113</span> * NOTE - when {@link Kernel} is mixed into an object, this function gets mixed in via
121
+ <span class='line'>114</span> * a special case behaviour that makes it a getter that actually calls the function
122
+ <span class='line'>115</span> * rather than returning the function object itself. This is to facilitate being able
123
+ <span class='line'>116</span> * to call '$CURRENT_FILE' in your code rather than '$CURRENT_FILE()'. The stackTraversalDepth
124
+ <span class='line'>117</span> * parameter is there for this reason, since we need to traverse the stack further than
125
+ <span class='line'>118</span> * normal to find the calling scope than we normally would.
126
+ <span class='line'>119</span> * @returns {String} The path to the current file
127
+ <span class='line'>120</span> * @param {int} stackTraversalDepth Optional argument, how far to look up the stack to
128
+ <span class='line'>121</span> * figure out who called us. The default is usually safe.
129
+ <span class='line'>122</span> * @throws {SelfConceptError} Thrown when we can't figure out what the filesystem
130
+ <span class='line'>123</span> * path to the current file is.
131
+ <span class='line'>124</span> */</span><span class="WHIT">
132
+ <span class='line'>125</span> </span><span class="WHIT"> </span><span class="NAME">$CURRENT_FILE</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">stackTraversalDepth</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
133
+ <span class='line'>126</span> </span><span class="WHIT"> </span><span class="KEYW">try</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
134
+ <span class='line'>127</span> </span><span class="WHIT"> </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">stackTraversalDepth</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">stackTraversalDepth</span><span class="WHIT"> </span><span class="PUNC">||</span><span class="WHIT"> </span><span class="NUMB">1</span><span class="PUNC">;</span><span class="WHIT">
135
+ <span class='line'>128</span> </span><span class="WHIT"> </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">ioService</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">$Cc</span><span class="PUNC">[</span><span class="STRN">"@mozilla.org/network/io-service;1"</span><span class="PUNC">]</span><span class="PUNC">.</span><span class="NAME">getService</span><span class="PUNC">(</span><span class="NAME">$Ci.nsIIOService</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
136
+ <span class='line'>129</span> </span><span class="WHIT"> </span><span class="COMM">// FIXME - UGH. This is so seedy.</span><span class="WHIT">
137
+ <span class='line'>130</span> </span><span class="WHIT"> </span><span class="COMM">// Traverse up the stack as far as needed to get our caller's stack frame. Sometimes we need to</span><span class="WHIT">
138
+ <span class='line'>131</span> </span><span class="WHIT"> </span><span class="COMM">// traverse more than one level up, like when this function is actually called from a getter</span><span class="WHIT">
139
+ <span class='line'>132</span> </span><span class="WHIT"> </span><span class="COMM">// property that references it.</span><span class="WHIT">
140
+ <span class='line'>133</span> </span><span class="WHIT"> </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">callerStack</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">Components.stack</span><span class="PUNC">;</span><span class="WHIT">
141
+ <span class='line'>134</span> </span><span class="WHIT"> </span><span class="KEYW">for</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">i</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NUMB">0</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="NAME">i</span><span class="WHIT"> </span><span class="PUNC">&lt;</span><span class="WHIT"> </span><span class="NAME">stackTraversalDepth</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="NAME">i</span><span class="PUNC">++</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
142
+ <span class='line'>135</span> </span><span class="WHIT"> </span><span class="NAME">callerStack</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">callerStack.caller</span><span class="PUNC">;</span><span class="WHIT">
143
+ <span class='line'>136</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
144
+ <span class='line'>137</span> </span><span class="WHIT"> </span><span class="COMM">// Split based on the stupid fucking " -> " Gecko puts in the filename and get the last entry</span><span class="WHIT">
145
+ <span class='line'>138</span> </span><span class="WHIT"> </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">ostensiblyUs</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">callerStack.filename.split</span><span class="PUNC">(</span><span class="STRN">" -> "</span><span class="PUNC">)</span><span class="PUNC">.</span><span class="NAME">slice</span><span class="PUNC">(</span><span class="PUNC">-</span><span class="NUMB">1</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
146
+ <span class='line'>139</span> </span><span class="WHIT"> </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">callerFileURI</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">ioService.newURI</span><span class="PUNC">(</span><span class="NAME">ostensiblyUs</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="KEYW">null</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="KEYW">null</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
147
+ <span class='line'>140</span> </span><span class="WHIT"> </span><span class="COMM">// QI for an nsIFileURL which lets us get a handle on an actual file attribute and automagically does</span><span class="WHIT">
148
+ <span class='line'>141</span> </span><span class="WHIT"> </span><span class="COMM">// resource: URL resolution for us</span><span class="WHIT">
149
+ <span class='line'>142</span> </span><span class="WHIT"> </span><span class="NAME">callerFileURI.QueryInterface</span><span class="PUNC">(</span><span class="NAME">$Ci.nsIFileURL</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
150
+ <span class='line'>143</span> </span><span class="WHIT"> </span><span class="COMM">// And theoretically, we can now get a handle on an nsIFile and return the path of that.</span><span class="WHIT">
151
+ <span class='line'>144</span> </span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">callerFileURI.file.path</span><span class="PUNC">;</span><span class="WHIT">
152
+ <span class='line'>145</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT"> </span><span class="KEYW">catch</span><span class="PUNC">(</span><span class="NAME">e</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
153
+ <span class='line'>146</span> </span><span class="WHIT"> </span><span class="KEYW">throw</span><span class="PUNC">(</span><span class="KEYW">new</span><span class="WHIT"> </span><span class="NAME">SelfConceptError</span><span class="PUNC">(</span><span class="STRN">"The filesystem location of the current file could not be determined. -- "</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">e</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
154
+ <span class='line'>147</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
155
+ <span class='line'>148</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="PUNC">,</span><span class="WHIT">
156
+ <span class='line'>149</span> </span><span class="WHIT">
157
+ <span class='line'>150</span> </span><span class="COMM">/**
158
+ <span class='line'>151</span> * This method tries to determine the filesystem path to parent directory of the caller
159
+ <span class='line'>152</span> * code of this method NOTE - see the note on $CURRENT_FILE, as the same applies here.
160
+ <span class='line'>153</span> * @returns {String} The path to the current directory
161
+ <span class='line'>154</span> * @param {int} stackTraversalDepth Optional argument, how far to look up the stack to
162
+ <span class='line'>155</span> * figure out who called us. The default is usually safe.
163
+ <span class='line'>156</span> * @throws {SelfConceptError} Thrown when we can't figure out what the filesystem
164
+ <span class='line'>157</span> * path to the parent directory of the current file is.
165
+ <span class='line'>158</span> */</span><span class="WHIT">
166
+ <span class='line'>159</span> </span><span class="WHIT"> </span><span class="NAME">$CURRENT_DIRECTORY</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">stackTraversalDepth</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
167
+ <span class='line'>160</span> </span><span class="WHIT"> </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">stackTraversalDepth</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">stackTraversalDepth</span><span class="WHIT"> </span><span class="PUNC">||</span><span class="WHIT"> </span><span class="NUMB">2</span><span class="PUNC">;</span><span class="WHIT">
168
+ <span class='line'>161</span> </span><span class="WHIT"> </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">currentFilePath</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">Kernel.prototype.$CURRENT_FILE</span><span class="PUNC">(</span><span class="NAME">stackTraversalDepth</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
169
+ <span class='line'>162</span> </span><span class="WHIT">
170
+ <span class='line'>163</span> </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">file</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">new</span><span class="WHIT"> </span><span class="NAME">XPCBuiltins.nsILocalFile</span><span class="PUNC">(</span><span class="NAME">currentFilePath</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
171
+ <span class='line'>164</span> </span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">file.parent.path</span><span class="PUNC">;</span><span class="WHIT">
172
+ <span class='line'>165</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="PUNC">,</span><span class="WHIT">
173
+ <span class='line'>166</span> </span><span class="WHIT">
174
+ <span class='line'>167</span> </span><span class="COMM">/**
175
+ <span class='line'>168</span> * Returns a reference to an object allowing for get()/set() on environment variables.
176
+ <span class='line'>169</span> * @type nsIEnvironment
177
+ <span class='line'>170</span> */</span><span class="WHIT">
178
+ <span class='line'>171</span> </span><span class="WHIT">
179
+ <span class='line'>172</span> </span><span class="NAME">$ENV</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NAME">Components.classes</span><span class="PUNC">[</span><span class="STRN">"@mozilla.org/process/environment;1"</span><span class="PUNC">]</span><span class="PUNC">.</span><span class="NAME">getService</span><span class="PUNC">(</span><span class="NAME">Components.interfaces.nsIEnvironment</span><span class="PUNC">)</span><span class="PUNC">,</span><span class="WHIT">
180
+ <span class='line'>173</span> </span><span class="WHIT">
181
+ <span class='line'>174</span> </span><span class="COMM">/**
182
+ <span class='line'>175</span> * Prints a string to standard out, without a trailing newline.
183
+ <span class='line'>176</span> * @param {String} str String to print to standard out.
184
+ <span class='line'>177</span> */</span><span class="WHIT">
185
+ <span class='line'>178</span> </span><span class="WHIT"> </span><span class="NAME">print</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">str</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
186
+ <span class='line'>179</span> </span><span class="WHIT"> </span><span class="NAME">dump</span><span class="PUNC">(</span><span class="NAME">str</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
187
+ <span class='line'>180</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="PUNC">,</span><span class="WHIT">
188
+ <span class='line'>181</span> </span><span class="WHIT">
189
+ <span class='line'>182</span> </span><span class="COMM">/**
190
+ <span class='line'>183</span> * Prints a string to standard out, with a trailing newline.
191
+ <span class='line'>184</span> * @param {String} str String to print to standard out.
192
+ <span class='line'>185</span> */</span><span class="WHIT">
193
+ <span class='line'>186</span> </span><span class="WHIT"> </span><span class="NAME">puts</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">str</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
194
+ <span class='line'>187</span> </span><span class="WHIT"> </span><span class="NAME">print</span><span class="PUNC">(</span><span class="NAME">str</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">"\n"</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
195
+ <span class='line'>188</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="PUNC">,</span><span class="WHIT">
196
+ <span class='line'>189</span> </span><span class="WHIT">
197
+ <span class='line'>190</span> </span><span class="COMM">/**
198
+ <span class='line'>191</span> * Searches {@link Kernel#$LOAD_PATH} for files to load into the current global scope.
199
+ <span class='line'>192</span> * Files loaded via this method will not be added to {@link Kernel#$LOADED_FEATURES} and hence
200
+ <span class='line'>193</span> * can be repeatedly loaded and executed.
201
+ <span class='line'>194</span> * @param {String} featurePath Full or relative path including file extension to try and load.
202
+ <span class='line'>195</span> * @returns {Boolean} True if the file was loaded succesfully
203
+ <span class='line'>196</span> * @throws {LoadError} Thrown when we can't find the specified file in any directories specified
204
+ <span class='line'>197</span> * in {@link Kernel#$LOAD_PATH}.
205
+ <span class='line'>198</span> */</span><span class="WHIT">
206
+ <span class='line'>199</span> </span><span class="WHIT"> </span><span class="NAME">load</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">featurePath</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
207
+ <span class='line'>200</span> </span><span class="WHIT"> </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">loader</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">$Cc</span><span class="PUNC">[</span><span class="STRN">"@mozilla.org/moz/jssubscript-loader;1"</span><span class="PUNC">]</span><span class="PUNC">.</span><span class="NAME">getService</span><span class="PUNC">(</span><span class="NAME">$Ci.mozIJSSubScriptLoader</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
208
+ <span class='line'>201</span> </span><span class="WHIT"> </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">foundFile</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">null</span><span class="PUNC">;</span><span class="WHIT">
209
+ <span class='line'>202</span> </span><span class="WHIT"> </span><span class="COMM">// FIXME - so this is kinda shitty. We have an empty entry here so we default to just trying to load </span><span class="WHIT">
210
+ <span class='line'>203</span> </span><span class="WHIT"> </span><span class="COMM">// from an absolute path</span><span class="WHIT">
211
+ <span class='line'>204</span> </span><span class="WHIT"> </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">loadPath</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">$LOAD_PATH.concat</span><span class="PUNC">(</span><span class="PUNC">[</span><span class="STRN">""</span><span class="PUNC">]</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
212
+ <span class='line'>205</span> </span><span class="WHIT"> </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">loadPathLength</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">loadPath.length</span><span class="PUNC">;</span><span class="WHIT">
213
+ <span class='line'>206</span> </span><span class="WHIT"> </span><span class="COMM">// FIXME - mozilla bug here. if i use foreach on array it ignores the granted security privileges</span><span class="WHIT">
214
+ <span class='line'>207</span> </span><span class="WHIT"> </span><span class="KEYW">for</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">i</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NUMB">0</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="NAME">i</span><span class="WHIT"> </span><span class="PUNC">&lt;</span><span class="WHIT"> </span><span class="NAME">loadPathLength</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="NAME">i</span><span class="PUNC">++</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
215
+ <span class='line'>208</span> </span><span class="WHIT"> </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">potentialFile</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">$Cc</span><span class="PUNC">[</span><span class="STRN">"@mozilla.org/file/local;1"</span><span class="PUNC">]</span><span class="PUNC">.</span><span class="NAME">createInstance</span><span class="PUNC">(</span><span class="NAME">$Ci.nsILocalFile</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
216
+ <span class='line'>209</span> </span><span class="WHIT"> </span><span class="NAME">potentialFile.initWithPath</span><span class="PUNC">(</span><span class="NAME">loadPath</span><span class="PUNC">[</span><span class="NAME">i</span><span class="PUNC">]</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">"/"</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">featurePath</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
217
+ <span class='line'>210</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">potentialFile.exists</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
218
+ <span class='line'>211</span> </span><span class="NAME">foundFile</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">potentialFile</span><span class="PUNC">;</span><span class="WHIT">
219
+ <span class='line'>212</span> </span><span class="KEYW">break</span><span class="PUNC">;</span><span class="WHIT">
220
+ <span class='line'>213</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
221
+ <span class='line'>214</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
222
+ <span class='line'>215</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">foundFile</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
223
+ <span class='line'>216</span> </span><span class="WHIT"> </span><span class="NAME">foundFile.normalize</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
224
+ <span class='line'>217</span> </span><span class="WHIT"> </span><span class="NAME">loader.loadSubScript</span><span class="PUNC">(</span><span class="STRN">"file://"</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">encodeURI</span><span class="PUNC">(</span><span class="NAME">foundFile.path</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
225
+ <span class='line'>218</span> </span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="KEYW">true</span><span class="PUNC">;</span><span class="WHIT">
226
+ <span class='line'>219</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT"> </span><span class="KEYW">else</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
227
+ <span class='line'>220</span> </span><span class="WHIT"> </span><span class="KEYW">throw</span><span class="PUNC">(</span><span class="KEYW">new</span><span class="WHIT"> </span><span class="NAME">LoadError</span><span class="PUNC">(</span><span class="STRN">"no such file to load -- "</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">featurePath</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
228
+ <span class='line'>221</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
229
+ <span class='line'>222</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="PUNC">,</span><span class="WHIT">
230
+ <span class='line'>223</span>
231
+ <span class='line'>224</span> </span><span class="WHIT"> </span><span class="COMM">/**
232
+ <span class='line'>225</span> * Searches {@link Kernel#$LOAD_PATH} for features to load into the current global scope.
233
+ <span class='line'>226</span> * Files loaded via this method will be added to {@link Kernel#$LOADED_FEATURES} and hence two
234
+ <span class='line'>227</span> * consecutive calls to this method will not load and execute the code twice.
235
+ <span class='line'>228</span> * @returns {Boolean} True if successful, false if the specified feature has already been required.
236
+ <span class='line'>229</span> * @param {String} featurePath Full or relative path without the file extension to try and require.
237
+ <span class='line'>230</span> * @throws {LoadError} Thrown when we can't find the specified feature in any directories specified
238
+ <span class='line'>231</span> * in {@link Kernel#$LOAD_PATH}.
239
+ <span class='line'>232</span> */</span><span class="WHIT">
240
+ <span class='line'>233</span> </span><span class="NAME">require</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">feature</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
241
+ <span class='line'>234</span> </span><span class="WHIT"> </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">jsFeature</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">feature</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">".js"</span><span class="PUNC">;</span><span class="WHIT">
242
+ <span class='line'>235</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">$LOADED_FEATURES.indexOf</span><span class="PUNC">(</span><span class="NAME">jsFeature</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">==</span><span class="WHIT"> </span><span class="PUNC">-</span><span class="NUMB">1</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
243
+ <span class='line'>236</span> </span><span class="WHIT"> </span><span class="NAME">load</span><span class="PUNC">(</span><span class="NAME">jsFeature</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
244
+ <span class='line'>237</span> </span><span class="WHIT"> </span><span class="NAME">$LOADED_FEATURES.push</span><span class="PUNC">(</span><span class="NAME">jsFeature</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
245
+ <span class='line'>238</span> </span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="KEYW">true</span><span class="PUNC">;</span><span class="WHIT">
246
+ <span class='line'>239</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT"> </span><span class="KEYW">else</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
247
+ <span class='line'>240</span> </span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="KEYW">false</span><span class="PUNC">;</span><span class="WHIT">
248
+ <span class='line'>241</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
249
+ <span class='line'>242</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
250
+ <span class='line'>243</span> </span><span class="PUNC">}</span><span class="PUNC">;</span></pre></body></html>