Browse Source

rename __duk__ to Duktape in internal website

pull/1/head
Sami Vaarala 11 years ago
parent
commit
e72f6427b5
  1. 4
      website/api/defines.html
  2. 4
      website/guide/compatibility.html
  3. 8
      website/guide/compiling.html
  4. 18
      website/guide/coroutines.html
  5. 8
      website/guide/customjson.html
  6. 50
      website/guide/duktapebuiltins.html
  7. 6
      website/guide/finalization.html
  8. 2
      website/guide/intro.html
  9. 2
      website/guide/luacomparison.html
  10. 8
      website/guide/programming.html
  11. 4
      website/guide/typealgorithms.html

4
website/api/defines.html

@ -4,9 +4,9 @@
<p>The Duktape version is available through the <code>DUK_VERSION</code> define,
with the numeric value <code>(major * 10000) + (minor * 100) + patch</code>.
The same value is available to Ecmascript code through <code>__duk__.version</code>.
The same value is available to Ecmascript code through <code>Duktape.version</code>.
For example, version 1.2.3 would have <code>DUK_VERSION</code> and
<code>__duk__.version</code> set to 10203.</p>
<code>Duktape.version</code> set to 10203.</p>
<h2>Structs and typedefs</h2>
<pre class="c-code">

4
website/guide/compatibility.html

@ -25,7 +25,7 @@ run <code>make</code> in <code>examples/coffee/</code>. For instance,
<code>hello.coffee</code>:</p>
<pre class="coffeescript-code">
print 'Hello world!'
print 'version: ' + __duk__.version
print 'version: ' + Duktape.version
</pre>
<p>compiles to:</p>
@ -34,7 +34,7 @@ print 'version: ' + __duk__.version
print('Hello world!');
print('version: ' + __duk__.version);
print('version: ' + Duktape.version);
}).call(this);
</pre>

8
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();
</pre>

18
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.</p>
<p>Coroutines are created with <code>new __duk__.Thread()</code>, which gets as its
<p>Coroutines are created with <code>new Duktape.Thread()</code>, 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.</p>
<p>A coroutine is resumed using <code>__duk__.Thread.resume()</code> which takes the
<p>A coroutine is resumed using <code>Duktape.Thread.resume()</code> 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.</p>
<p>A coroutine yields its current execution using <code>__duk__.Thread.yield()</code>
<p>A coroutine yields its current execution using <code>Duktape.Thread.yield()</code>
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:</p>
<pre class="ecmascript-code">
// 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');
</pre>

8
website/guide/customjson.html

@ -30,10 +30,10 @@ readable format, most suitable for debugging, logging, etc.</p>
<p>JSONX is used as follows:</p>
<pre class="ecmascript-code">
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
</pre>
@ -51,10 +51,10 @@ are encoded as plain string data with the format "U+nnnnnnnn"
<p>JSONC is used as follows:</p>
<pre class="ecmascript-code">
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]
</pre>

50
website/guide/duktapebuiltins.html

@ -12,7 +12,7 @@ values.</p>
</tr>
</thead>
<tbody>
<tr><td class="propname">__duk__</td><td>The Duktape built-in object. Contains miscellaneous implementation specific stuff.</td></tr>
<tr><td class="propname">Duktape</td><td>The Duktape built-in object. Contains miscellaneous implementation specific stuff.</td></tr>
<tr><td class="propname">print</td><td>Non-standard, browser-like function for writing to <code>stdout</code>.</td></tr>
<tr><td class="propname">alert</td><td>Non-standard, browser-like function for writing to <code>stderr</code>.</td></tr>
</tbody>
@ -40,7 +40,7 @@ flush afterwards. The bytes written depend on the arguments:</p>
<code>stderr</code>. Unlike a browser <code>alert()</code>, the call
does not block.</p>
<h2>The __duk__ object</h2>
<h2>The Duktape object</h2>
<table>
<thead>
@ -53,8 +53,8 @@ does not block.</p>
<tr><td class="propname">env</td><td>Cryptic, version dependent summary of most important effective options like endianness and architecture.</td></tr>
<tr><td class="propname">setFinalizer</td><td>Set finalizer of an object.</td></tr>
<tr><td class="propname">getFinalizer</td><td>Set finalizer of an object.</td></tr>
<tr><td class="propname">enc</td><td>Encode a value: <code>__duk__.enc('hex', 'foo')</code>.</td></tr>
<tr><td class="propname">dec</td><td>Decode a value: <code>__duk__.dec('base64', 'Zm9v')</code>.</td></tr>
<tr><td class="propname">enc</td><td>Encode a value: <code>Duktape.enc('hex', 'foo')</code>.</td></tr>
<tr><td class="propname">dec</td><td>Decode a value: <code>Duktape.dec('base64', 'Zm9v')</code>.</td></tr>
<tr><td class="propname">jsonxEnc</td><td>Like <code>JSON.stringify()</code> but encodes to JSONX custom format.</td></tr>
<tr><td class="propname">jsonxDec</td><td>Like <code>JSON.parse()</code> but decodes from JSONX custom format.</td></tr>
<tr><td class="propname">jsoncEnc</td><td>Like <code>JSON.stringify()</code> but encodes to JSONC custom format.</td></tr>
@ -74,33 +74,33 @@ does not block.</p>
behavior. Version numbers can be compared directly: a logically higher version
will also be numerically higher. For example:</p>
<pre class="ecmascript-code">
if (typeof __duk__ !== 'object') {
if (typeof Duktape !== 'object') {
print('not Duktape');
} else if (__duk__.version &gt;= 10203) {
} else if (Duktape.version &gt;= 10203) {
print('Duktape 1.2.3 or higher');
} else if (__duk__.version &gt;= 800) {
} else if (Duktape.version &gt;= 800) {
print('Duktape 0.8.0 or higher (but lower than 1.2.3)');
} else {
print('Duktape lower than 0.8.0');
}
</pre>
<p>Remember to check for existence of <code>__duk__</code> when doing feature
<p>Remember to check for existence of <code>Duktape</code> 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:</p>
<pre class="ecmascript-code">
// 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');
}
</pre>
@ -128,7 +128,7 @@ other values are string coerced and the internal byte representation
<p>For example, to encode a string into base64:</p>
<pre class="ecmascript-code">
var result = __duk__.enc('base64', 'foo');
var result = Duktape.enc('base64', 'foo');
print(result); // prints 'Zm9v'
</pre>
@ -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:</p>
<pre class="ecmascript-code">
var result = __duk__.dec('base64', 'Zm9v');
var result = Duktape.dec('base64', 'Zm9v');
print(typeof result, result); // prints 'buffer foo'
</pre>
<p>If you wish to get back a string value, you can simply:</p>
<pre class="ecmascript-code">
var result = String(__duk__.dec('base64', 'Zm9v'));
var result = String(Duktape.dec('base64', 'Zm9v'));
print(typeof result, result); // prints 'string foo'
</pre>
<h2>__duk__.Buffer (constructor)</h2>
<h2>Duktape.Buffer (constructor)</h2>
<table>
<thead>
@ -169,10 +169,10 @@ ordinary function and as a constructor:</p>
using the custom <code>ToBuffer</code> 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
<code>__duk__.Buffer.prototype</code> object.</li>
<code>Duktape.Buffer.prototype</code> object.</li>
</ul>
<h2>__duk__.Buffer.prototype</h2>
<h2>Duktape.Buffer.prototype</h2>
<table>
<thead>
@ -189,11 +189,11 @@ ordinary function and as a constructor:</p>
<p><code>toString()</code> and <code>valueOf</code> accept both plain buffers and
Buffer objects as their <code>this</code> binding. This allows code such as:</p>
<pre class="ecmascript-code">
var plain_buf = __duk__.Buffer('test');
var plain_buf = Duktape.Buffer('test');
print(plain_buf.toString());
</pre>
<h2>__duk__.Pointer (constructor)</h2>
<h2>Duktape.Pointer (constructor)</h2>
<table>
<thead>
@ -216,10 +216,10 @@ ordinary function and as a constructor:</p>
using the custom <code>ToPointer</code> 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
<code>__duk__.Pointer.prototype</code> object.</li>
<code>Duktape.Pointer.prototype</code> object.</li>
</ul>
<h2>__duk__.Pointer.prototype</h2>
<h2>Duktape.Pointer.prototype</h2>
<table>
<thead>
@ -236,11 +236,11 @@ ordinary function and as a constructor:</p>
<p><code>toString()</code> and <code>valueOf</code> accept both plain pointers and
Pointer objects as their <code>this</code> binding. This allows code such as:</p>
<pre class="ecmascript-code">
var plain_ptr = __duk__.Pointer({ test: 'object' });
var plain_ptr = Duktape.Pointer({ test: 'object' });
print(plain_ptr.toString());
</pre>
<h2>__duk__.Thread (constructor)</h2>
<h2>Duktape.Thread (constructor)</h2>
<table>
<thead>
@ -266,10 +266,10 @@ cases:</p>
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 <code>__duk__.Thread.prototype</code> object.</li>
newly created Thread will be the <code>Duktape.Thread.prototype</code> object.</li>
</ul>
<h2>__duk__.Thread.prototype</h2>
<h2>Duktape.Thread.prototype</h2>
<table>
<thead>

6
website/guide/finalization.html

@ -6,7 +6,7 @@
<p>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 <code>__duk__.setFinalizer()</code>
The internal finalizer property is set using <code>Duktape.setFinalizer()</code>
method. The finalizer may be triggered by either reference counting or
mark-and-sweep.</p>
@ -31,7 +31,7 @@ var a;
function init() {
a = { foo: 123 };
__duk__.setFinalizer(a, function (x) {
Duktape.setFinalizer(a, function (x) {
print('finalizer, foo -&gt;', 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();
</pre>
<p>If you run this with the Duktape command line tool (with the default

2
website/guide/intro.html

@ -48,7 +48,7 @@ no support for its features.</p>
features (some are visible to applications, while others are internal):</p>
<ul>
<li>Additional built-ins: <code>print()</code> and <code>alert()</code> borrowed from
browsers, Duktape specific built-ins in the <code>__duk__</code> global object</li>
browsers, Duktape specific built-ins in the <code>Duktape</code> global object</li>
<li>Extended types: custom "buffer" and "pointer" types, extended string type
which supports arbitary binary strings and
non-<a href="http://en.wikipedia.org/wiki/Plane_(Unicode)#Basic_Multilingual_Plane">BMP</a>

2
website/guide/luacomparison.html

@ -103,7 +103,7 @@ for a similar effect (though not with respect to performance):
<p>There are no primitives for coroutine control in the Duktape API
(Lua API has e.g. <code>lua_resume</code>). Coroutines can only be controlled
using the functions exposed by the <code>__duk__</code> built-in. Further,
using the functions exposed by the <code>Duktape</code> built-in. Further,
Duktape has quite many coroutine yield restrictions now; for instance,
coroutines cannot yield from inside constructor calls or getter/setter calls.</p>

8
website/guide/programming.html

@ -442,7 +442,7 @@ duk_get_prop_string(ctx, -1, "my_state_variable");
<p>The Duktape version is available through the <code>DUK_VERSION</code> define,
with the numeric value <code>(major * 10000) + (minor * 100) + patch</code>.
The same value is available to Ecmascript code through <code>__duk__.version</code>.
The same value is available to Ecmascript code through <code>Duktape.version</code>.
Calling code can use this define for Duktape version specific code.</p>
<p>For C code:</p>
@ -458,11 +458,11 @@ Calling code can use this define for Duktape version specific code.</p>
<p>For Ecmascript code (also see <a href="#duktapebuiltins">Duktape built-ins</a>):</p>
<pre class="ecmascript-code">
if (typeof __duk__ !== 'object') {
if (typeof Duktape !== 'object') {
print('not Duktape');
} else if (__duk__.version &gt;= 10203) {
} else if (Duktape.version &gt;= 10203) {
print('Duktape 1.2.3 or higher');
} else if (__duk__.version &gt;= 800) {
} else if (Duktape.version &gt;= 800) {
print('Duktape 0.8.0 or higher (but lower than 1.2.3)');
} else {
print('Duktape lower than 0.8.0');

4
website/guide/typealgorithms.html

@ -227,12 +227,12 @@ is extended to custom types as follows:</p>
<p>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
(<code>__duk__.Buffer.prototype</code> or <code>__duk__.Pointer.prototype</code>).
(<code>Duktape.Buffer.prototype</code> or <code>Duktape.Pointer.prototype</code>).
This mimics the behavior of standard types.</p>
<p>For example:</p>
<pre>
duk&gt; buf = __duk__.dec('hex', '414243'); // plain buffer
duk&gt; buf = Duktape.dec('hex', '414243'); // plain buffer
= ABC
duk&gt; buf.toString;
= function toString() {/* native code */}

Loading…
Cancel
Save