Version 1 of tcl-duktape

Updated 2015-04-28 11:09:35 by dbohdan
What tcl-duktape
Description A binary Tcl extension that proves bindings for Duktape, an embedded JavaScript interpreter.
Platforms Tested on Linux and FreeBSD.
Prerequisites Tcl 8.5 or newer, TclOO required for the OO wrapper.
Updated 04/2015
License MIT

Duktape is just a pair of .c/.h files, which makes the package easy to build. tcl-duktape allows you to call JavaScript code from Tcl and exposes a jsproc interface similar to the cproc interface in Critcl that allows you to write procedures in JavaScript. Included in the package is a TclOO API wrapper for tcl-duktape objects and one for JSON objects. No means to register Tcl callbacks to be called from JavaScript are currently provided.

Sample code

#!/usr/bin/env tclsh
package require duktape
package require duktape::oo

set duktapeObj [::duktape::oo::Duktape new]
$duktapeObj jsproc ::add {{a 0 number} {b 0 number}} {
    return a + b
puts [add 1 2]
$duktapeObj destroy

See also