Revision a41ea686

b/webodf/Makefile
23 23

  
24 24
# --compilation_level ADVANCED_OPTIMIZATIONS does not work
25 25
compiled.js: $(JSFILES) externs.js
26
	java -jar $(COMPILERJAR) --define='IS_COMPILED_CODE=true' --warning_level VERBOSE --compilation_level SIMPLE_OPTIMIZATIONS --formatting PRETTY_PRINT --externs externs.js --use_only_custom_externs true $(foreach JSFILE,$(JSFILES), --js $(JSFILE)) --js_output_file compiled.js
26
	java -jar $(COMPILERJAR) --define='IS_COMPILED_CODE=true' --warning_level VERBOSE --compilation_level ADVANCED_OPTIMIZATIONS --formatting PRETTY_PRINT --externs externs.js --use_only_custom_externs true $(foreach JSFILE,$(JSFILES), --js $(JSFILE)) --js_output_file compiled.js
27 27

  
28 28
# make sure targets are deleted if a build exits with a non-zero status code
29 29
.DELETE_ON_ERROR:
b/webodf/externs.js
1 1
/**
2
 * es3
3
 */
4
/**
5
 * @constructor
6
 * @param {...*} var_args
7
 * @return {!Array}
8
 * @nosideeffects
9
 */
10
function Array(var_args) {}
11
/**
12
 * @param {...*} var_args
13
 * @return {!Array}
14
 * @this {Object}
15
 * @nosideeffects
16
 */
17
Array.prototype.concat = function (var_args) {};
18
/**
19
 * @param {*=} opt_begin Zero-based index at which to begin extraction.  A
20
 *     non-number type will be auto-cast by the browser to a number.
21
 * @param {*=} opt_end Zero-based index at which to end extraction.  slice
22
 *     extracts up to but not including end.
23
 * @return {!Array}
24
 * @this {Object}
25
 * @nosideeffects
26
 */
27
Array.prototype.slice = function (opt_begin, opt_end) {};
28
/**
29
 * @constructor
30
 * @param {*=} opt_str
31
 * @return {string}
32
 * @nosideeffects
33
 */
34
function String(opt_str) {}
35
/**
36
 * @param {*=} opt_separator
37
 * @param {number=} opt_limit
38
 * @return {!Array.<string>}
39
 * @nosideeffects
40
 */
41
String.prototype.split = function (opt_separator, opt_limit) {};
42

  
43
/**
44
 * @constructor
45
 */
46
function NodeJSObject() {}
47
/**
2 48
 * @param {string} path
49
 * @param {string} encoding
50
 * @param {Function} callback
51
 * @return {undefined}
52
 */
53
NodeJSObject.prototype.readFile = function (path, encoding, callback) {};
54
/**
55
 * @param {string} path
56
 * @param {string} encoding
57
 * @return {undefined}
58
 */
59
NodeJSObject.prototype.readFileSync = function (path, encoding) {};
60
/**
61
 * @param {string} path
62
 * @return {NodeJSObject}
3 63
 */
4 64
function require(path) {}
5 65
/**
6 66
 * @type {Object.<string, function(...)>}
7 67
 */
8
var console;
68
function console() {}
69
/**
70
 * @param {string} msg
71
 */
72
console.prototype.log = function (msg) {};
9 73
var process = {
10 74
    argv: []
11 75
};
......
33 97
var XMLHttpRequest;
34 98
var undefined;
35 99
function setTimeout(callback, time) {}
36
var Packages = {};
100
var Packages = {
101
    javax: {
102
        xml: {
103
            parsers: {
104
            }
105
        }
106
    },
107
    org: {
108
        xml: {
109
            sax: {
110
                EntityResolver: function () {},
111
                InputSource: function (reader) {}
112
            }
113
        }
114
    },
115
    java: {
116
        io: {
117
            File: function (path) {},
118
            FileReader: function (path) {}
119
        }
120
    }
121
};
122
/**
123
 * @constructor
124
 */
125
Packages.javax.xml.parsers.DocumentBuilder = function () {};
126
Packages.javax.xml.parsers.DocumentBuilder.prototype.setEntityResolver = function () {};
127
/**
128
 * @constructor
129
 */
130
Packages.javax.xml.parsers.DocumentBuilderFactory = function () {};
131
/**
132
 * @return {Packages.javax.xml.parsers.DocumentBuilderFactory}
133
 */
134
Packages.javax.xml.parsers.DocumentBuilderFactory.prototype.newInstance = function () {};
135
Packages.javax.xml.parsers.DocumentBuilderFactory.prototype.setValidating = function (value) {};
136
Packages.javax.xml.parsers.DocumentBuilderFactory.prototype.setNamespaceAware = function (value) {};
137
Packages.javax.xml.parsers.DocumentBuilderFactory.prototype.setExpandEntityReferences = function (value) {};
138
Packages.javax.xml.parsers.DocumentBuilderFactory.prototype.setSchema = function (value) {};
139
/**
140
 * @return {Packages.javax.xml.parsers.DocumentBuilder}
141
 */
142
Packages.javax.xml.parsers.DocumentBuilderFactory.prototype.newDocumentBuilder = function () {};
37 143
var window = {};
38 144
var eval = function(code) {}
39 145
var arguments;
b/webodf/lib/runtime.js
48 48
 * @return {Array.<string>}
49 49
 */
50 50
Runtime.prototype.libraryPaths = function () {};
51
/**
52
 * @return {string}
53
 */
54
Runtime.prototype.type = function () {};
51 55

  
52 56
/** @define {boolean} */
53 57
var IS_COMPILED_CODE = false;
......
144 148
    this.libraryPaths = function () {
145 149
        return ["../lib"];
146 150
    };
151
    this.type = function () {
152
        return "BrowserRuntime";
153
    };
147 154
}
148 155

  
149 156
/**
......
178 185
    this.currentDirectory = function () {
179 186
        return currentDirectory;
180 187
    };
188
    this.type = function () {
189
        return "NodeJSRuntime";
190
    };
181 191
}
182 192

  
183 193
/**
......
257 267
    this.currentDirectory = function () {
258 268
        return currentDirectory;
259 269
    };
270
    this.type = function () {
271
        return "RhinoRuntime";
272
    };
260 273
}
261 274

  
262 275
/**
......
292 305
    }
293 306
    /**
294 307
     * @param {string} classpath
295
     * @returns {Object|undefined}
308
     * @returns {undefined}
296 309
     */
297 310
    runtime.loadClass = function (classpath) {
311
        if (IS_COMPILED_CODE) {
312
            return;
313
        }
298 314
        if (classpath in cache) {
299
            return cache[classpath];
315
            return;
300 316
        }
301 317
        var names = classpath.split("."),
302 318
            impl;
303
        if (IS_COMPILED_CODE) {
304
            impl = eval(classpath + ";");
305
            cache[classpath] = impl;
306
            return impl;
307
        }
308 319
        function load(classpath) {
309 320
            var code, path, dirs, i;
310 321
            path = classpath.replace(".", "/") + ".js";
......
338 349
            throw "Loaded code is not for " + names[names.length - 1];
339 350
        }
340 351
        cache[classpath] = impl;
341
        return impl;
342 352
    };
343 353
}());
344 354
(function (args) {
345 355
    function run(argv) {
346
        if (argv.length === 0) {
356
        if (!argv.length) {
347 357
            return;
348 358
        }
349 359
        var script = argv[0];
......
363 373
        });
364 374
    }
365 375
    // if rhino or node.js, run the scripts provided as arguments
366
    if (runtime.constructor.name === "NodeJSRuntime") {
376
    if (runtime.type() === "NodeJSRuntime") {
367 377
        run(process.argv.slice(2));
368
    } else if (runtime.constructor.name === "RhinoRuntime") {
378
    } else if (runtime.type() === "RhinoRuntime") {
369 379
        run(args);
370 380
    }
371 381
}(typeof arguments !== "undefined" && arguments.slice && arguments.slice()));

Also available in: Unified diff