diff --git a/website/api/defines.html b/website/api/defines.html
index 3219503c..de910b9e 100644
--- a/website/api/defines.html
+++ b/website/api/defines.html
@@ -4,9 +4,9 @@
The Duktape version is available through the DUK_VERSION
define,
with the numeric value (major * 10000) + (minor * 100) + patch
.
-The same value is available to Ecmascript code through __duk__.version
.
+The same value is available to Ecmascript code through Duktape.version
.
For example, version 1.2.3 would have DUK_VERSION
and
-__duk__.version
set to 10203.
+Duktape.version
set to 10203.
Structs and typedefs
diff --git a/website/guide/compatibility.html b/website/guide/compatibility.html
index 3246d494..6e0fd0cd 100644
--- a/website/guide/compatibility.html
+++ b/website/guide/compatibility.html
@@ -25,7 +25,7 @@ run make
in examples/coffee/
. For instance,
hello.coffee
:
print 'Hello world!'
-print 'version: ' + __duk__.version
+print 'version: ' + Duktape.version
compiles to:
@@ -34,7 +34,7 @@ print 'version: ' + __duk__.version
print('Hello world!');
- print('version: ' + __duk__.version);
+ print('version: ' + Duktape.version);
}).call(this);
diff --git a/website/guide/compiling.html b/website/guide/compiling.html
index 49c98928..79db7c87 100644
--- a/website/guide/compiling.html
+++ b/website/guide/compiling.html
@@ -323,9 +323,9 @@ relevant heap is destroyed. You can also break the reference loops manually
var f = function() { };
var g = function() { };
var h = function() { };
-__duk__.setFinalizer(f, function() { print('finalizer for f'); });
-__duk__.setFinalizer(g, function() { print('finalizer for g'); });
-__duk__.setFinalizer(h, function() { print('finalizer for h'); });
+Duktape.setFinalizer(f, function() { print('finalizer for f'); });
+Duktape.setFinalizer(g, function() { print('finalizer for g'); });
+Duktape.setFinalizer(h, function() { print('finalizer for h'); });
// not collected until heap destruction in a reference counting only build
f = null; // not collected immediately
@@ -339,6 +339,6 @@ h.prototype.constructor = null;
h = null; // collected immediately, finalizer runs
// no-op with refcount only, with mark-and-sweep finalizer for 'f' runs
-__duk__.gc();
+Duktape.gc();
diff --git a/website/guide/coroutines.html b/website/guide/coroutines.html
index 3b0e75b5..25ebee75 100644
--- a/website/guide/coroutines.html
+++ b/website/guide/coroutines.html
@@ -9,12 +9,12 @@ coroutine A resumes or initiates coroutine B, coroutine B runs until it yields
or finishes (either successfully or through an uncaught error), after which
coroutine A continues execution with the yield result.
-Coroutines are created with new __duk__.Thread()
, which gets as its
+
Coroutines are created with new Duktape.Thread()
, which gets as its
sole argument the initial function where the new coroutine begins execution on
its first resume. The resume argument becomes the initial function's first (and
only) argument value.
-A coroutine is resumed using __duk__.Thread.resume()
which takes the
+
A coroutine is resumed using Duktape.Thread.resume()
which takes the
following arguments: the coroutine to resume, the resume value, and (optionally)
a flag indicating whether the resume value is an ordinary value or an error to
be injected into the target coroutine. Injecting an error means that the resume
@@ -22,7 +22,7 @@ value will be "thrown" at the site of the target coroutine's last yield operatio
In other words, instead of returning with an ordinary value, the yield will
seemingly throw an error.
-A coroutine yields its current execution using __duk__.Thread.yield()
+
A coroutine yields its current execution using Duktape.Thread.yield()
which takes as its arguments: the value to yield, and (optionally) a flag indicating
whether the yield value is an ordinary value or an error to be thrown in the
context of the resuming coroutine. In other words, an error value causes the
@@ -55,7 +55,7 @@ they are present anywhere in the yielding coroutine's call stack:
// coroutine.js
function yielder(x) {
- var yield = __duk__.Thread.yield;
+ var yield = Duktape.Thread.yield;
print('yielder starting');
print('yielder arg:', x);
@@ -68,13 +68,13 @@ function yielder(x) {
return 123;
}
-var t = new __duk__.Thread(yielder);
+var t = new Duktape.Thread(yielder);
print('resume test');
-print('yielded with', __duk__.Thread.resume(t, 'foo'));
-print('yielded with', __duk__.Thread.resume(t, 'bar'));
-print('yielded with', __duk__.Thread.resume(t, 'quux'));
-print('yielded with', __duk__.Thread.resume(t, 'baz'));
+print('yielded with', Duktape.Thread.resume(t, 'foo'));
+print('yielded with', Duktape.Thread.resume(t, 'bar'));
+print('yielded with', Duktape.Thread.resume(t, 'quux'));
+print('yielded with', Duktape.Thread.resume(t, 'baz'));
print('finished');
diff --git a/website/guide/customjson.html b/website/guide/customjson.html
index 66ed0a05..3855f1df 100644
--- a/website/guide/customjson.html
+++ b/website/guide/customjson.html
@@ -30,10 +30,10 @@ readable format, most suitable for debugging, logging, etc.
JSONX is used as follows:
var obj = { foo: 0/0, bar: [ 1, undefined, 3 ] };
-print(__duk__.jsonxEnc(obj));
+print(Duktape.jsonxEnc(obj));
// prints out: {foo:NaN,bar:[1,undefined,3]}
-var dec = __duk__.jsonxDec('{ foo: 123, bar: undefined, quux: NaN }');
+var dec = Duktape.jsonxDec('{ foo: 123, bar: undefined, quux: NaN }');
print(dec.foo, dec.bar, dec.quux);
// prints out: 123 undefined NaN
@@ -51,10 +51,10 @@ are encoded as plain string data with the format "U+nnnnnnnn"
JSONC is used as follows:
var obj = { foo: 0/0, bar: [ 1, undefined, 3 ] };
-print(__duk__.jsoncEnc(obj));
+print(Duktape.jsoncEnc(obj));
// prints out: {"foo":{"_nan":true},"bar":[1,{"_undef":true},3]}
-var dec = __duk__.jsoncDec('{ "foo": 123, "bar": {"_undef":true}, "quux": {"_nan":true} }');
+var dec = Duktape.jsoncDec('{ "foo": 123, "bar": {"_undef":true}, "quux": {"_nan":true} }');
print(dec.foo, dec.bar, dec.quux);
// prints out: 123 [object Object] [object Object]
diff --git a/website/guide/duktapebuiltins.html b/website/guide/duktapebuiltins.html
index e66e1d5f..858de0d6 100644
--- a/website/guide/duktapebuiltins.html
+++ b/website/guide/duktapebuiltins.html
@@ -12,7 +12,7 @@ values.
-__duk__ | The Duktape built-in object. Contains miscellaneous implementation specific stuff. |
+Duktape | The Duktape built-in object. Contains miscellaneous implementation specific stuff. |
print | Non-standard, browser-like function for writing to stdout . |
alert | Non-standard, browser-like function for writing to stderr . |
@@ -40,7 +40,7 @@ flush afterwards. The bytes written depend on the arguments:
stderr
. Unlike a browser alert()
, the call
does not block.
-The __duk__ object
+The Duktape object
@@ -53,8 +53,8 @@ does not block.
env | Cryptic, version dependent summary of most important effective options like endianness and architecture. |
setFinalizer | Set finalizer of an object. |
getFinalizer | Set finalizer of an object. |
-enc | Encode a value: __duk__.enc('hex', 'foo') . |
-dec | Decode a value: __duk__.dec('base64', 'Zm9v') . |
+enc | Encode a value: Duktape.enc('hex', 'foo') . |
+dec | Decode a value: Duktape.dec('base64', 'Zm9v') . |
jsonxEnc | Like JSON.stringify() but encodes to JSONX custom format. |
jsonxDec | Like JSON.parse() but decodes from JSONX custom format. |
jsoncEnc | Like JSON.stringify() but encodes to JSONC custom format. |
@@ -74,33 +74,33 @@ does not block.
behavior. Version numbers can be compared directly: a logically higher version
will also be numerically higher. For example:
-if (typeof __duk__ !== 'object') {
+if (typeof Duktape !== 'object') {
print('not Duktape');
-} else if (__duk__.version >= 10203) {
+} else if (Duktape.version >= 10203) {
print('Duktape 1.2.3 or higher');
-} else if (__duk__.version >= 800) {
+} else if (Duktape.version >= 800) {
print('Duktape 0.8.0 or higher (but lower than 1.2.3)');
} else {
print('Duktape lower than 0.8.0');
}
-Remember to check for existence of __duk__
when doing feature
+
Remember to check for existence of Duktape
when doing feature
detection. Your code should typically work on as many engines as possible.
Avoid the common pitfall of using a direct identifier reference in the check:
// Bad idea: ReferenceError if missing
-if (!__duk__) {
+if (!Duktape) {
print('not Duktape');
}
// Better: check through 'this' (bound to global)
-if (!this.__duk__) {
+if (!this.Duktape) {
print('not Duktape');
}
// Better: use typeof to check also type explicitly
-if (typeof __duk__ !== 'object') {
+if (typeof Duktape !== 'object') {
print('not Duktape');
}
@@ -128,7 +128,7 @@ other values are string coerced and the internal byte representation
For example, to encode a string into base64:
-var result = __duk__.enc('base64', 'foo');
+var result = Duktape.enc('base64', 'foo');
print(result); // prints 'Zm9v'
@@ -136,17 +136,17 @@ print(result); // prints 'Zm9v'
first string coerced (it only really makes sense to decode strings), and
the result is always a buffer. For example:
-var result = __duk__.dec('base64', 'Zm9v');
+var result = Duktape.dec('base64', 'Zm9v');
print(typeof result, result); // prints 'buffer foo'
If you wish to get back a string value, you can simply:
-var result = String(__duk__.dec('base64', 'Zm9v'));
+var result = String(Duktape.dec('base64', 'Zm9v'));
print(typeof result, result); // prints 'string foo'
-__duk__.Buffer (constructor)
+Duktape.Buffer (constructor)
@@ -169,10 +169,10 @@ ordinary function and as a constructor:
using the custom ToBuffer
coercion. Returns a Buffer object
whose internal value is the buffer resulting from the coercion. The
internal prototype of the newly created Buffer will be the
- __duk__.Buffer.prototype
object.
+ Duktape.Buffer.prototype
object.
-__duk__.Buffer.prototype
+Duktape.Buffer.prototype
@@ -189,11 +189,11 @@ ordinary function and as a constructor:
toString()
and valueOf
accept both plain buffers and
Buffer objects as their this
binding. This allows code such as:
-var plain_buf = __duk__.Buffer('test');
+var plain_buf = Duktape.Buffer('test');
print(plain_buf.toString());
-__duk__.Pointer (constructor)
+Duktape.Pointer (constructor)
@@ -216,10 +216,10 @@ ordinary function and as a constructor:
using the custom ToPointer
coercion. Returns a Pointer object
whose internal value is the pointer resulting from the coercion. The
internal prototype of the newly created Pointer will be the
- __duk__.Pointer.prototype
object.
+ Duktape.Pointer.prototype
object.
-__duk__.Pointer.prototype
+Duktape.Pointer.prototype
@@ -236,11 +236,11 @@ ordinary function and as a constructor:
toString()
and valueOf
accept both plain pointers and
Pointer objects as their this
binding. This allows code such as:
-var plain_ptr = __duk__.Pointer({ test: 'object' });
+var plain_ptr = Duktape.Pointer({ test: 'object' });
print(plain_ptr.toString());
-__duk__.Thread (constructor)
+Duktape.Thread (constructor)
@@ -266,10 +266,10 @@ cases:
is thrown). The return value is a new thread whose initial function is
recorded to be the argument function (this function will start executing
when the new thread is first resumed). The internal prototype of the
- newly created Thread will be the __duk__.Thread.prototype
object.
+ newly created Thread will be the Duktape.Thread.prototype
object.
-__duk__.Thread.prototype
+Duktape.Thread.prototype
diff --git a/website/guide/finalization.html b/website/guide/finalization.html
index bd4621cd..3d2379fa 100644
--- a/website/guide/finalization.html
+++ b/website/guide/finalization.html
@@ -6,7 +6,7 @@
An object which has an internal finalizer property in its prototype
chain (or the object itself) is subject to finalization before being freed.
-The internal finalizer property is set using __duk__.setFinalizer()
+The internal finalizer property is set using Duktape.setFinalizer()
method. The finalizer may be triggered by either reference counting or
mark-and-sweep.
@@ -31,7 +31,7 @@ var a;
function init() {
a = { foo: 123 };
- __duk__.setFinalizer(a, function (x) {
+ Duktape.setFinalizer(a, function (x) {
print('finalizer, foo ->', x.foo);
});
}
@@ -46,7 +46,7 @@ a = null;
// mark-and-sweep finalizing happens here (at the latest) if
// refcounting is disabled
print('mark-and-sweep finalizer')
-__duk__.gc();
+Duktape.gc();
If you run this with the Duktape command line tool (with the default
diff --git a/website/guide/intro.html b/website/guide/intro.html
index a1895c95..25f6b2a8 100644
--- a/website/guide/intro.html
+++ b/website/guide/intro.html
@@ -48,7 +48,7 @@ no support for its features.
features (some are visible to applications, while others are internal):
- Additional built-ins:
print()
and alert()
borrowed from
- browsers, Duktape specific built-ins in the __duk__
global object
+ browsers, Duktape specific built-ins in the Duktape
global object
- Extended types: custom "buffer" and "pointer" types, extended string type
which supports arbitary binary strings and
non-BMP
diff --git a/website/guide/luacomparison.html b/website/guide/luacomparison.html
index e378aea5..b0bfc0e7 100644
--- a/website/guide/luacomparison.html
+++ b/website/guide/luacomparison.html
@@ -103,7 +103,7 @@ for a similar effect (though not with respect to performance):
There are no primitives for coroutine control in the Duktape API
(Lua API has e.g. lua_resume
). Coroutines can only be controlled
-using the functions exposed by the __duk__
built-in. Further,
+using the functions exposed by the Duktape
built-in. Further,
Duktape has quite many coroutine yield restrictions now; for instance,
coroutines cannot yield from inside constructor calls or getter/setter calls.
diff --git a/website/guide/programming.html b/website/guide/programming.html
index 2d75d34e..fc23d82b 100644
--- a/website/guide/programming.html
+++ b/website/guide/programming.html
@@ -442,7 +442,7 @@ duk_get_prop_string(ctx, -1, "my_state_variable");
The Duktape version is available through the DUK_VERSION
define,
with the numeric value (major * 10000) + (minor * 100) + patch
.
-The same value is available to Ecmascript code through __duk__.version
.
+The same value is available to Ecmascript code through Duktape.version
.
Calling code can use this define for Duktape version specific code.
For C code:
@@ -458,11 +458,11 @@ Calling code can use this define for Duktape version specific code.
For Ecmascript code (also see Duktape built-ins):
-if (typeof __duk__ !== 'object') {
+if (typeof Duktape !== 'object') {
print('not Duktape');
-} else if (__duk__.version >= 10203) {
+} else if (Duktape.version >= 10203) {
print('Duktape 1.2.3 or higher');
-} else if (__duk__.version >= 800) {
+} else if (Duktape.version >= 800) {
print('Duktape 0.8.0 or higher (but lower than 1.2.3)');
} else {
print('Duktape lower than 0.8.0');
diff --git a/website/guide/typealgorithms.html b/website/guide/typealgorithms.html
index d53254a4..f6f61c5e 100644
--- a/website/guide/typealgorithms.html
+++ b/website/guide/typealgorithms.html
@@ -227,12 +227,12 @@ is extended to custom types as follows:
If a plain buffer or pointer is used as a property access base value,
properties are looked up from the (initial) built-in prototype object
-(__duk__.Buffer.prototype
or __duk__.Pointer.prototype
).
+(Duktape.Buffer.prototype
or Duktape.Pointer.prototype
).
This mimics the behavior of standard types.
For example:
-duk> buf = __duk__.dec('hex', '414243'); // plain buffer
+duk> buf = Duktape.dec('hex', '414243'); // plain buffer
= ABC
duk> buf.toString;
= function toString() {/* native code */}