Duktape
Time 2021-11-24 23:13:59Web Name: Duktape
WebSite: http://www.duktape.org
ID:249364
Keywords:
Duktape,Description:
keywords: description: ((o) Duktape HomeDownloadAPIGuideWikiREPLDuktape
Duktape is an embeddable Javascript engine,with a focus on portability and compact footprint.
Duktape is easy to integrate into a C/C++ project: add duktape.c
,duktape.h
, and duk_config.h
to your build, and use theDuktape API to call ECMAScript functions from C code and vice versa.
Main featuresEmbeddable, portable, compact: can run on platforms with 160kB flash and 64kB RAMECMAScript E5/E5.1, with some semantics updated from ES2015+Partial support for ECMAScript 2015 (E6) and ECMAScript 2016 (E7), see Post-ES5 feature status and kangax/compat-tableES2015 TypedArray and Node.js Buffer bindingsCBOR bindingsEncoding API bindings based on the WHATWG Encoding Living Standardperformance.now()Built-in debuggerBuilt-in regular expression engineBuilt-in Unicode supportMinimal, retargetable platform dependenciesCombined reference counting and mark-and-sweep garbage collection with finalizationCoroutinesProperty virtualization using a subset of ECMAScript ES2015 Proxy objectBytecode dump/load for caching compiled functionsDistributable includes an optional logging framework, CommonJS-based module loading implementations, etcLiberal license (MIT)
Code and RAM footprint
For a "Hello world" example:
See GCC optionsfor minimizing code footprint. Full lowmemuses "pointer compression" and ROM-based strings/objects. ROM-based strings/objects canalso be used without other low memory options.
Current statusStable
SupportDuktape Wiki: wiki.duktape.orgUser community QA: Stack Overflow duktape tagBugs and feature requests: GitHub issuesGeneral discussion: IRC
#duktape
on chat.freenode.net
(webchat)Some projects using Duktape
See: Projects using Duktape.
If you're using Duktape in your project, send an e-mail or open a GitHubissue to be added to the list.
Similar engines
There are multiple Javascript engines targeting similar use cases as Duktape, at least:
Espruino (MPL v2.0)JerryScript (Apache License v2.0)MuJS (Affero GPL)quad-wheel (MIT License)QuickJS (MIT License)tiny-js (MIT license)v7 (GPL v2.0)Also see List of ECMAScript engines.
1 Add to build
(See Getting started for a moredetailed introduction.)
Add Duktape C source and header to your build. Any build system canbe used. The distributable contains an example Makefile for reference.In the simplest case:
$ gcc -std=c99 -otest test.c duktape.c -lm$ ./test1+2=3
To customize Duktape configuration,here to disable ECMAScript 6 Proxy
object support:
$ python2 duktape-2.6.0/tools/configure.py --output-directory src-duktape \ -UDUK_USE_ES6_PROXY$ ls src-duktape/duk_config.h duk_source_meta.json duktape.c duktape.h$ gcc -std=c99 -otest -Isrc-duktape \ test.c src-duktape/duktape.c -lm$ ./test1+2=3
2 Initialize a context
Initialize and use Duktape somewhere in your program:
/* test.c */#include stdio.h#include "duktape.h"int main(int argc, char *argv[]) { duk_context *ctx = duk_create_heap_default(); duk_eval_string(ctx, "1+2"); printf("1+2=%d\n", (int) duk_get_int(ctx, -1)); duk_destroy_heap(ctx); return 0;}
3 Add C function bindings
To call a C function from ECMAScript code, first declare yourC functions:
/* Being an embeddable engine, Duktape doesn't provide I/O * bindings by default. Here's a simple one argument print() * function. */static duk_ret_t native_print(duk_context *ctx) { printf("%s\n", duk_to_string(ctx, 0)); return 0; /* no return value (= undefined) */}/* Adder: add argument values. */static duk_ret_t native_adder(duk_context *ctx) { int i; int n = duk_get_top(ctx); /* #args */ double res = 0.0; for (i = 0; i n; i++) { res += duk_to_number(ctx, i); } duk_push_number(ctx, res); return 1; /* one return value */}
Register your functions e.g. into the global object:
duk_push_c_function(ctx, native_print, 1 /*nargs*/);duk_put_global_string(ctx, "print");duk_push_c_function(ctx, native_adder, DUK_VARARGS);duk_put_global_string(ctx, "adder");
You can then call your function from ECMAScript code:
duk_eval_string_noresult(ctx, "print('2+3=' + adder(2, 3));");
Duktape is (C) by its authorsand licensed under the MIT license.
TAGS:Duktape
<<< Thank you for your visit >>>
Websites to related : Pizzigati Designs | eco chic int
keywords:
description:
SAY HELLO
Eco Chic Sense Blog
keywords:
description:
Skip to content Main Menu HomeCC MethodMenu ToggleWhat is the Colour Comfort Method?The Psychology of ColourColour Positioni
keywords:web hosting, provider, php hosting,web hosting, free domain names, domain name, front page hosting, web site, web design, domain name registr
Nintendo Blast - quando o assunt keywords:
description:
CapaNotíciasAnálisesEspeciaisColunasSwitchConsolesFranquiasRevistaPodcastFórumAssineGameBlastConsoles, PC, Mobile e maisNint
keywords:
description:Free Computer Art Business & Investing ebooks. Thousands of free ebooks to choose from all are free.
keywords:
description:Best tactical flashlights available to the public today. We compared lumens, brand, quality, & warranty for the 10 most popular
keywords:
description:
Skip to main content This browser is no longer supported. Upgrade to Microsoft Edge to take advantage of the lates
keywords:
description:
Home About Speakers Agenda
keywords:
description:
ip-address.comHomeMy IPSpeedtestSitemapProxy CheckerProxy ListVerify Email AddressTrace Email AddressIP to Zip CodeIP Address D
keywords:
description:
Hot Websites