forked from svaarala/duktape
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathduk_initjs.js
62 lines (53 loc) · 1.71 KB
/
duk_initjs.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
/*
* Init code for legacy compatibility.
*
* Compatibility properties / wrapper functions here allow Duktape to remain
* compatible for user code when core features are changed, without burdening
* the main C code with compatibility stuff.
*
* This file is minified with UglifyJS or the closure compiler. Both will
* rename variables, remove comments, and are clever enough to drop any
* "if (false) { ... }" blocks altogether, so that's an effective way to
* disable currently unneeded code.
*/
(function(G, D) {
'use strict';
function def(object, name, value) {
Object.defineProperty(object, name, {
value: value,
writable: true,
enumerable: false,
configurable: true
});
}
function defD(name, value) {
def(D, name, value);
}
// Compatibility for 'console.log'.
if (false) {
console = {
log: function() {
print(Array.prototype.join.call(arguments, ' '));
}
};
}
// Duktape.line() was removed in Duktape 0.11.0, here's an example
// replacement user code could use.
if (false) {
def(D, 'line', function () {
'use duk notail';
/* Tail calls are prevented to ensure calling activation exists.
* Call stack indices: -1 = Duktape.act, -2 = getCurrentLine, -3 = caller
*/
return (Duktape.act(-3) || {}).lineNumber;
});
}
// Logger object for C code provided by init code now.
if (true) {
def(D.Logger, 'clog', new D.Logger('C'));
}
// Tracking table for CommonJS module loading.
if (true) {
def(D, 'modLoaded', {});
}
})(this, Duktape);