Add full duktape project

This commit is contained in:
Nathan Whitehead committed 2022-09-20 10:52:21 -06:00
1 parent 6124faa872
commit 06cf09db55
999 files changed
+392829

No files matched your search

+117
View File
@@ -0,0 +1,117 @@
===============
Duktape authors
===============
Copyright
=========
Duktape copyrights are held by its authors. Each author has a copyright
to their contribution, and agrees to irrevocably license the contribution
under the Duktape ``LICENSE.txt``.
Authors
=======
Please include an e-mail address, a link to your GitHub profile, or something
similar to allow your contribution to be identified accurately.
The following people have contributed code, website contents, or Wiki contents,
and agreed to irrevocably license their contributions under the Duktape
``LICENSE.txt`` (in order of appearance):
* Sami Vaarala <[email protected]>
* Niki Dobrev
* Andreas Öman <[email protected]>
* László Langó <[email protected]>
* Legimet <[email protected]>
* Karl Skomski <[email protected]>
* Bruce Pascoe <[email protected]>
* René Hollander <[email protected]>
* Julien Hamaide (https://github.com/crazyjul)
* Sebastian Götte (https://github.com/jaseg)
* Tomasz Magulski (https://github.com/magul)
* \D. Bohdan (https://github.com/dbohdan)
* Ondřej Jirman (https://github.com/megous)
* Saúl Ibarra Corretgé <[email protected]>
* Jeremy HU <[email protected]>
* Ole André Vadla Ravnås (https://github.com/oleavr)
* Harold Brenes (https://github.com/harold-b)
* Oliver Crow (https://github.com/ocrow)
* Jakub Chłapiński (https://github.com/jchlapinski)
* Brett Vickers (https://github.com/beevik)
* Dominik Okwieka (https://github.com/okitec)
* Remko Tronçon (https://el-tramo.be)
* Romero Malaquias ([email protected])
* Michael Drake <[email protected]>
* Steven Don (https://github.com/shdon)
* Simon Stone (https://github.com/sstone1)
* \J. McC. (https://github.com/jmhmccr)
* Jakub Nowakowski (https://github.com/jimvonmoon)
* Tommy Nguyen (https://github.com/tn0502)
* Fabrice Fontaine (https://github.com/ffontaine)
* Christopher Hiller (https://github.com/boneskull)
* Gonzalo Diethelm (https://github.com/gonzus)
* Michal Kasperek (https://github.com/michalkas)
* Andrew Janke (https://github.com/apjanke)
* Steve Fan (https://github.com/stevefan1999)
* Edward Betts (https://github.com/edwardbetts)
* Ozhan Duz (https://github.com/webfolderio)
* Akos Kiss (https://github.com/akosthekiss)
* TheBrokenRail (https://github.com/TheBrokenRail)
* Jesse Doyle (https://github.com/jessedoyle)
* Gero Kuehn (https://github.com/dc6jgk)
* James Swift (https://github.com/phraemer)
* Luis de Bethencourt (https://github.com/luisbg)
* Ian Whyman (https://github.com/v00d00)
* Rick Sayre (https://github.com/whorfin)
* Craig Leres (https://github.com/leres)
* Maurici Abad (https://github.com/mauriciabad)
* Nancy Li (https://github.com/NancyLi1013)
* William Parks (https://github.com/WilliamParks)
* Sam Hellawell (https://github.com/samhellawell)
* Vladislavs Sokurenko (https://github.com/sokurenko)
Other contributions
===================
The following people have contributed something other than code (e.g. reported
bugs, provided ideas, etc; roughly in order of appearance):
* Greg Burns
* Anthony Rabine
* Carlos Costa
* Aurélien Bouilland
* Preet Desai (Pris Matic)
* judofyr (http://www.reddit.com/user/judofyr)
* Jason Woofenden
* Michał Przybyś
* Anthony Howe
* Conrad Pankoff
* Jim Schimpf
* Rajaran Gaunker (https://github.com/zimbabao)
* Andreas Öman
* Doug Sanden
* Josh Engebretson (https://github.com/JoshEngebretson)
* Remo Eichenberger (https://github.com/remoe)
* Mamod Mehyar (https://github.com/mamod)
* David Demelier (https://github.com/markand)
* Tim Caswell (https://github.com/creationix)
* Mitchell Blank Jr (https://github.com/mitchblank)
* https://github.com/yushli
* Seo Sanghyeon (https://github.com/sanxiyn)
* Han ChoongWoo (https://github.com/tunz)
* Joshua Peek (https://github.com/josh)
* Bruce E. Pascoe (https://github.com/fatcerberus)
* https://github.com/Kelledin
* https://github.com/sstruchtrup
* Michael Drake (https://github.com/tlsa)
* https://github.com/chris-y
* Laurent Zubiaur (https://github.com/lzubiaur)
* Neil Kolban (https://github.com/nkolban)
* Wilhelm Wanecek (https://github.com/wanecek)
* Andrew Janke (https://github.com/apjanke)
* Unamer (https://github.com/unamer)
* Karl Dahlke ([email protected])
If you are accidentally missing from this list, send me an e-mail
(``[email protected]``) and I'll fix the omission.
@@ -0,0 +1,48 @@
#
# Example Makefile for building a program with embedded Duktape.
# The example program here is the Duktape command line tool.
#
DUKTAPE_SOURCES = src/duktape.c
CMDLINE_SOURCES = \
examples/cmdline/duk_cmdline.c
CC ?= gcc
CC := $(CC)
CCOPTS = -Os -pedantic -std=c99 -Wall -fstrict-aliasing -fomit-frame-pointer
CCOPTS += -I./examples/cmdline -I./src # duktape.h and duk_config.h must be in include path
CCLIBS = -lm
# Enable print() and alert() for command line using an optional extra module.
CCOPTS += -DDUK_CMDLINE_PRINTALERT_SUPPORT -I./extras/print-alert
CMDLINE_SOURCES += extras/print-alert/duk_print_alert.c
# Enable console object (console.log() etc) for command line.
CCOPTS += -DDUK_CMDLINE_CONSOLE_SUPPORT -I./extras/console
CMDLINE_SOURCES += extras/console/duk_console.c
# Enable Duktape.Logger for command line.
CCOPTS += -DDUK_CMDLINE_LOGGING_SUPPORT -I./extras/logging
CMDLINE_SOURCES += extras/logging/duk_logging.c
# Enable Duktape 1.x module loading for command line.
CCOPTS += -DDUK_CMDLINE_MODULE_SUPPORT -I./extras/module-duktape
CMDLINE_SOURCES += extras/module-duktape/duk_module_duktape.c
# If you want linenoise, you can enable these. At the moment linenoise
# will cause some harmless compilation warnings.
#CCOPTS += -DDUK_CMDLINE_FANCY -I./linenoise
#CMDLINE_SOURCES += linenoise/linenoise.c
#duk: linenoise
# Use the tools/configure.py utility to modify Duktape default configuration:
# http://duktape.org/guide.html#compiling
# http://wiki.duktape.org/Configuring.html
duk: $(DUKTAPE_SOURCES) $(CMDLINE_SOURCES)
$(CC) $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) -o $@ $(DEFINES) $(CCOPTS) $(DUKTAPE_SOURCES) $(CMDLINE_SOURCES) $(CCLIBS)
linenoise/linenoise.c: linenoise
linenoise:
git clone https://github.com/antirez/linenoise.git
@@ -0,0 +1,7 @@
CC ?= gcc
CC := $(CC)
codepage:
$(CC) $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) -o $@ -std=c99 -O2 -Wall -Wextra -Isrc/ \
src/duktape.c examples/codepage-conv/duk_codepage_conv.c \
examples/codepage-conv/test.c -lm
@@ -0,0 +1,4 @@
dummy:
coffee -c examples/coffee/globals.coffee
coffee -c examples/coffee/hello.coffee
coffee -c examples/coffee/mandel.coffee
@@ -0,0 +1,42 @@
#
# Duktape command line tool with debugger support.
#
DUKTAPE_SOURCES = prep/duktape.c
# Windows (MinGW): use examples/debug-trans-socket/duk_trans_socket_windows.c
# and link with -lws2_32.
CMDLINE_SOURCES = \
examples/cmdline/duk_cmdline.c \
examples/debug-trans-socket/duk_trans_socket_unix.c
CC ?= gcc
CC := $(CC)
CCOPTS = -Os -pedantic -std=c99 -Wall -fstrict-aliasing -fomit-frame-pointer
CCOPTS += -I./prep -I./examples/cmdline -I./examples/debug-trans-socket
CCOPTS += -DDUK_CMDLINE_DEBUGGER_SUPPORT # enable --debugger in ./duk
CCLIBS = -lm
# Enable a few optional modules.
CCOPTS += -DDUK_CMDLINE_PRINTALERT_SUPPORT -I./extras/print-alert
CMDLINE_SOURCES += extras/print-alert/duk_print_alert.c
CCOPTS += -DDUK_CMDLINE_CONSOLE_SUPPORT -I./extras/console
CMDLINE_SOURCES += extras/console/duk_console.c
CCOPTS += -DDUK_CMDLINE_LOGGING_SUPPORT -I./extras/logging
CMDLINE_SOURCES += extras/logging/duk_logging.c
CCOPTS += -DDUK_CMDLINE_MODULE_SUPPORT -I./extras/module-duktape
CMDLINE_SOURCES += extras/module-duktape/duk_module_duktape.c
# Use tools/configure.py to prepare Duktape config header and sources with
# custom configuration.
duk: $(CMDLINE_SOURCES)
@rm -rf prep
python2 tools/configure.py \
--source-directory src-input \
--output-directory prep \
--config-metadata config \
-DDUK_USE_DEBUGGER_SUPPORT \
-DDUK_USE_INTERRUPT_COUNTER \
-DDUK_USE_DEBUGGER_DUMPHEAP \
-DDUK_USE_DEBUGGER_INSPECT
$(CC) $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) -o $@ $(DEFINES) $(CCOPTS) $(DUKTAPE_SOURCES) $(CMDLINE_SOURCES) $(CCLIBS)
+10
View File
@@ -0,0 +1,10 @@
#
# Example Makefile for building the eval example
#
CC ?= gcc
CC := $(CC)
eval:
$(CC) $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) -o $@ -std=c99 -O2 -Wall -Wextra -Isrc/ \
src/duktape.c examples/eval/eval.c -lm
@@ -0,0 +1,24 @@
#
# Example Makefile for building the eventloop example
#
CC ?= gcc
CC := $(CC)
evloop:
@echo "NOTE: The eventloop is an example intended to be used on Linux"
@echo " or other common UNIX variants. It is not fully portable."
@echo ""
$(CC) $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) -o $@ -std=c99 -Wall -Wextra -O2 -Isrc \
examples/eventloop/main.c \
examples/eventloop/c_eventloop.c \
examples/eventloop/poll.c \
examples/eventloop/socket.c \
examples/eventloop/fileio.c \
src/duktape.c \
-lm
@echo ""
@echo "NOTE: You must 'cd examples/eventloop' before you execute the"
@echo " eventloop binary: it relies on finding .js files in CWD"
+33
View File
@@ -0,0 +1,33 @@
#
# Example Makefile for building a program with embedded Duktape.
#
# There are two source sets in the distribution: (1) combined sources where
# you only need duktape.c, duktape.h, and duk_config.h, and (2) separate
# sources where you have a bunch of source and header files. Whichever
# you use, simply include the relevant sources into your C project. This
# Makefile uses the combined source file.
#
DUKTAPE_SOURCES = src/duktape.c
# Compiler options are quite flexible. GCC versions have a significant impact
# on the size of -Os code, e.g. gcc-4.6 is much worse than gcc-4.5.
CC ?= gcc
CC := $(CC)
CCOPTS = -Os -pedantic -std=c99 -Wall -fstrict-aliasing -fomit-frame-pointer
CCOPTS += -I./src # for combined sources
CCLIBS = -lm
DEFINES =
# If you want a 32-bit build on a 64-bit host
#CCOPTS += -m32
# Use the tools/configure.py utility to modify Duktape default configuration:
# http://duktape.org/guide.html#compiling
# http://wiki.duktape.org/Configuring.html
# For debugging, use -O0 -g -ggdb, and don't add -fomit-frame-pointer
hello: $(DUKTAPE_SOURCES) examples/hello/hello.c
$(CC) $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) -o $@ $(DEFINES) $(CCOPTS) $(DUKTAPE_SOURCES) examples/hello/hello.c $(CCLIBS)
@@ -0,0 +1,11 @@
#
# Example Makefile for building the jsoncbor example
#
CC ?= gcc
CC := $(CC)
jsoncbor:
$(CC) $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) -o $@ -std=c99 -Wall -Wextra -O2 -Isrc -Iextras/cbor \
src/duktape.c extras/cbor/jsoncbor.c \
-lm
@@ -0,0 +1,11 @@
#
# Example Makefile for building the jxpretty example
#
CC ?= gcc
CC := $(CC)
jxpretty:
$(CC) $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) -o $@ -std=c99 -Wall -Wextra -O2 -Isrc \
src/duktape.c examples/jxpretty/jxpretty.c \
-lm
@@ -0,0 +1,10 @@
#
# Example Makefile for building the sandbox example
#
CC ?= gcc
CC := $(CC)
sandbox:
$(CC) $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) -o $@ -std=c99 -O2 -Wall -Wextra -Isrc/ \
src/duktape.c examples/sandbox/sandbox.c -lm
@@ -0,0 +1,104 @@
#
# Example of how to build and install locally as a shared library
#
# Usage:
#
# $ make -f Makefile.sharedlibrary
# $ sudo make -f Makefile.sharedlibrary install
# $ make -f Makefile.sharedlibrary duk # --> example 'duk' linked to shared libduktape
#
# $ ls -l duk
# -rwxrwxr-x 1 duktape duktape 19407 Nov 30 15:48 duk
#
# $ ldd ./duk
# linux-vdso.so.1 => (0x00007ffd5ed3c000)
# libduktape.so.104 => /usr/local/lib/libduktape.so.104 (0x00007fb2f9753000)
# libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007fb2f944d000)
# libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007fb2f9088000)
# /lib64/ld-linux-x86-64.so.2 (0x00007fb2f9991000)
#
# Based on: http://tldp.org/HOWTO/Program-Library-HOWTO/shared-libraries.html
# Soname version must be bumped whenever a binary compatibility change occurs
# (and should not be bumped when the library is compatible). A simple Duktape
# convention is to set soname version to (100*MAJOR + MINOR), e.g. 104 for
# Duktape 1.4.x, so that it gets automatically bumped for major and minor
# releases (potentially binary incompatible), but not for patch releases.
# The formatted version is used for the pkg-config file.
DUK_VERSION = 20700
DUK_VERSION_FORMATTED = 2.7.0
SONAME_VERSION = 207
REAL_VERSION = $(SONAME_VERSION).$(DUK_VERSION)
# Mac has an unusual .so naming convention
ifeq ($(OS),Windows_NT)
DETECTED_OS := Windows
else
DETECTED_OS := $(shell uname -s)
endif
ifeq ($(DETECTED_OS),Darwin)
LD_SONAME_ARG=-install_name
SO_SONAME_SUFFIX=$(SONAME_VERSION).so
SO_REALNAME_SUFFIX=$(REAL_VERSION).so
else
LD_SONAME_ARG=-soname
SO_SONAME_SUFFIX=so.$(SONAME_VERSION)
SO_REALNAME_SUFFIX=so.$(REAL_VERSION)
endif
# Change to actual path for actual distribution packaging.
INSTALL_PREFIX ?= /usr/local
INSTALL_PREFIX := $(INSTALL_PREFIX)
DESTDIR ?=
DESTDIR := $(DESTDIR)
LIBDIR ?= /lib
LIBDIR := $(LIBDIR)
# The 'noline' variant may be more appropriate for some distributions; it
# doesn't have #line directives in the combined source.
DUKTAPE_SRCDIR = ./src
#DUKTAPE_SRCDIR = ./src-noline
CC ?= gcc
CC := $(CC)
.PHONY: all
all: libduktape.$(SO_REALNAME_SUFFIX) libduktaped.$(SO_REALNAME_SUFFIX) duktape.pc
# If the default duk_config.h is not suitable for the distribution, modify it
# before compiling the shared library and copy the same, edited duk_config.h
# to $INSTALL_PREFIX/include on installation.
libduktape.$(SO_REALNAME_SUFFIX):
$(CC) $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) -shared -fPIC -Wall -Wextra -Os -Wl,$(LD_SONAME_ARG),libduktape.$(SO_SONAME_SUFFIX) \
-o $@ $(DUKTAPE_SRCDIR)/duktape.c
libduktaped.$(SO_REALNAME_SUFFIX):
$(CC) $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) -shared -fPIC -g -Wall -Wextra -Os -Wl,$(LD_SONAME_ARG),libduktaped.$(SO_SONAME_SUFFIX) \
-o $@ $(DUKTAPE_SRCDIR)/duktape.c
duktape.pc:
sed -e "s|@PREFIX@|$(INSTALL_PREFIX)|" \
-e "s|@LIBDIR@|$(LIBDIR)|" \
-e "s|@VERSION@|$(DUK_VERSION_FORMATTED)|" \
duktape.pc.in \
> duktape.pc
# Symlinks depend on platform conventions.
.PHONY: install
install: libduktape.$(SO_REALNAME_SUFFIX) libduktaped.$(SO_REALNAME_SUFFIX) duktape.pc
mkdir -p $(DESTDIR)$(INSTALL_PREFIX)$(LIBDIR)/pkgconfig
cp $+ $(DESTDIR)$(INSTALL_PREFIX)$(LIBDIR)/
rm -f $(DESTDIR)$(INSTALL_PREFIX)$(LIBDIR)/libduktape.so $(DESTDIR)$(INSTALL_PREFIX)$(LIBDIR)/libduktape.$(SO_SONAME_SUFFIX)
ln -s libduktape.$(SO_REALNAME_SUFFIX) $(DESTDIR)$(INSTALL_PREFIX)$(LIBDIR)/libduktape.so
ln -s libduktape.$(SO_REALNAME_SUFFIX) $(DESTDIR)$(INSTALL_PREFIX)$(LIBDIR)/libduktape.$(SO_SONAME_SUFFIX)
rm -f $(DESTDIR)$(INSTALL_PREFIX)$(LIBDIR)/libduktaped.so $(DESTDIR)$(INSTALL_PREFIX)$(LIBDIR)/libduktaped.$(SO_SONAME_SUFFIX)
ln -s libduktaped.$(SO_REALNAME_SUFFIX) $(DESTDIR)$(INSTALL_PREFIX)$(LIBDIR)/libduktaped.so
ln -s libduktaped.$(SO_REALNAME_SUFFIX) $(DESTDIR)$(INSTALL_PREFIX)$(LIBDIR)/libduktaped.$(SO_SONAME_SUFFIX)
mv $(DESTDIR)$(INSTALL_PREFIX)$(LIBDIR)/duktape.pc $(DESTDIR)$(INSTALL_PREFIX)$(LIBDIR)/pkgconfig/
mkdir -p $(DESTDIR)$(INSTALL_PREFIX)/include/
cp $(DUKTAPE_SRCDIR)/duktape.h $(DUKTAPE_SRCDIR)/duk_config.h $(DESTDIR)$(INSTALL_PREFIX)/include/
CCOPTS = -I./examples/cmdline
duk:
$(CC) $(CCOPTS) -I$(INSTALL_PREFIX)/include -L$(INSTALL_PREFIX)$(LIBDIR) -Wall -Wextra -Os -o $@ ./examples/cmdline/duk_cmdline.c -lduktape -lm
+138
View File
@@ -0,0 +1,138 @@
=======
Duktape
=======
Duktape is a small and portable ECMAScript E5/E5.1 implementation. It is
intended to be easily embeddable into C programs, with a C API similar in
spirit to Lua's.
Duktape supports the full E5/E5.1 feature set (with some semantics updated
from ES2015+) including errors, Unicode strings, and regular expressions,
a subset of ECMAScript 2015 (E6) and ECMAScript 2016 (E7) features (e.g.
computed property names, Proxy objects, exponentiation operator, Reflect),
ES2015 ArrayBuffer/TypedView, Node.js Buffer, performance.now(), CBOR, and
WHATWG Encoding API living standard.
Duktape also provides a number of custom features such as error tracebacks,
additional data types for better C integration, combined reference counting
and mark-and sweep garbage collector, object finalizers, co-operative
threads a.k.a. coroutines, tail calls, a built-in debugger protocol, function
bytecode dump/load, and so on. Bundled extra modules provide functionality
such as CommonJS module loading and a logging framework.
You can browse Duktape programmer's API and other documentation at:
* http://duktape.org/
In particular, you should read the getting started section:
* http://duktape.org/guide.html#gettingstarted
More examples and how-to articles are in the Duktape Wiki:
* http://wiki.duktape.org/
To build an example command line tool with interactive evaluation (REPL) and
the ability to run script files::
$ cd <dist_root>
$ make -f Makefile.cmdline
[...]
$ ./duk
((o) Duktape
duk> print('Hello world!');
Hello world!
= undefined
$ ./duk mandel.js
[...]
To integrate Duktape into your program:
* Use ``tools/configure.py`` to prepare Duktape source and header files
for build::
# Duktape options can be customized via command line options.
# In this example, enable "fastint" support and disable ES2015
# Proxy support
$ python2 tools/configure.py --output-directory duktape-src \
-DDUK_USE_FASTINT -UDUK_USE_ES6_PROXY
* The output directory (duktape-src) will then contain ``duktape.c``,
``duktape.h``, and ``duk_config.h`` which you include in your build.
For more details, see:
* http://duktape.org/guide.html#compiling
* http://wiki.duktape.org/Configuring.html
This distributable contains:
* Pre-configured Duktape header and source files using the Duktape default
configuration:
* ``src/``: main Duktape library in a "single source file" format (duktape.c,
duktape.h, and duk_config.h).
* ``src-noline/``: contains a variant of ``src/duktape.c`` with no ``#line``
directives which is preferable for some users. See discussion in
https://github.com/svaarala/duktape/pull/363.
* ``src-separate/``: main Duktape library in multiple files format.
* ``src-input/``: raw input source files used by ``configure.py`` which
recreates the combined/separate prepared sources with specific options.
* ``tools/``: various Python tools, such as ``configure.py`` for preparing
a ``duk_config.h`` header and Duktape source files for compilation, see
http://wiki.duktape.org/Configuring.html.
* ``config/``: configuration metadata for ``configure.py``.
* ``examples/``: further examples for using Duktape. Although Duktape
itself is widely portable, some of the examples are Linux only.
For instance the ``eventloop`` example illustrates how ``setTimeout()``
and other standard timer functions could be implemented on Unix/Linux.
* ``extras/``: utilities and modules which don't comfortably fit into the
main Duktape library because of footprint or portability concerns.
Extras are maintained and bug fixed code, but don't have the same version
guarantees as the main Duktape library.
* ``polyfills/``: a few replacement suggestions for non-standard Javascript
functions provided by other implementations.
* ``debugger/``: a debugger with a web UI, see ``debugger/README.rst`` and
https://github.com/svaarala/duktape/blob/master/doc/debugger.rst for
details on Duktape debugger support. Also contains a JSON debug proxy
(one written in Node.js and another in DukLuv) to make talking to the
debug target easier.
* ``licenses/``: licensing information.
You can find release notes at:
* https://github.com/svaarala/duktape/blob/master/RELEASES.rst
(summary of all versions)
* https://github.com/svaarala/duktape/blob/master/doc/release-notes-v2-7.rst
(more detailed notes for this version)
This distributable contains Duktape version 2.7.0, created from git
commit 03d4d728f8365021de6955c649e6dcd05dcca99f (03d4d72-dirty).
Duktape is copyrighted by its authors (see ``AUTHORS.rst``) and licensed
under the MIT license (see ``LICENSE.txt``). String hashing algorithms are
based on the algorithm from Lua (MIT license), djb2 hash, and Murmurhash2
(MIT license). Pseudorandom number generator algorithms are based on
Adi Shamir's three-op algorithm, xoroshiro128+ (public domain), and SplitMix64
(public domain). Duktape module loader is based on the CommonJS module
loading specification (without sharing any code), CommonJS is under the MIT
license.
Have fun!
Sami Vaarala ([email protected])
@@ -0,0 +1,19 @@
=================
Duktape genconfig
=================
``genconfig`` is a helper script for coming up with a ``duk_config.h`` for
compiling Duktape for your platform.
To support this:
* It helps to create a ``duk_config.h`` for your platform/compiler
combination. You can give a base configuration and then force certain
values manually based on a YAML configuration file.
* It autogenerates documentation for config options based on option metadata
files written in YAML.
NOTE: ``tools/configure.py`` is now the preferred tool for preparing a config
header (using genconfig.py) and Duktape source files (using other tools) for
build.
@@ -0,0 +1,71 @@
# Architecture metadata.
autodetect:
-
name: x86
check: DUK_F_X86
include: architecture_x86.h.in
-
name: x64
check: DUK_F_X64
include: architecture_x64.h.in
-
name: x32
check: DUK_F_X32
include: architecture_x32.h.in
-
name: ARM 32-bit
check: DUK_F_ARM32
include: architecture_arm32.h.in
-
name: ARM 64-bit
check: DUK_F_ARM64
include: architecture_arm64.h.in
-
name: MIPS 32-bit
check: DUK_F_MIPS32
include: architecture_mips32.h.in
-
name: MIPS 64-bit
check: DUK_F_MIPS64
include: architecture_mips64.h.in
-
name: PowerPC 32-bit
check: DUK_F_PPC32
include: architecture_powerpc32.h.in
-
name: PowerPC 64-bit
check: DUK_F_PPC64
include: architecture_powerpc64.h.in
-
name: SPARC 32-bit
check: DUK_F_SPARC32
include: architecture_sparc32.h.in
-
name: SPARC 64-bit
check: DUK_F_SPARC64
include: architecture_sparc64.h.in
-
name: RISC-V 32-bit
check: DUK_F_RISCV32
include: architecture_riscv32.h.in
-
name: RISC-V 64-bit
check: DUK_F_RISCV64
include: architecture_riscv64.h.in
-
name: SuperH
check: DUK_F_SUPERH
include: architecture_superh.h.in
-
name: Motorola 68k
check: DUK_F_M68K
include: architecture_m68k.h.in
-
name: Emscripten
check: DUK_F_EMSCRIPTEN
include: architecture_emscripten.h.in
-
name: Generic
check: null
include: architecture_generic.h.in
@@ -0,0 +1,3 @@
#define DUK_USE_ARCH_STRING "arm32"
/* Byte order varies, so rely on autodetect. */
#define DUK_USE_PACKED_TVAL
@@ -0,0 +1,3 @@
#define DUK_USE_ARCH_STRING "arm64"
/* Byte order varies, so rely on autodetect. */
#undef DUK_USE_PACKED_TVAL
@@ -0,0 +1,5 @@
#define DUK_USE_ARCH_STRING "emscripten"
#if !defined(DUK_USE_BYTEORDER)
#define DUK_USE_BYTEORDER 1
#endif
#undef DUK_USE_PACKED_TVAL
@@ -0,0 +1,3 @@
/* These are necessary wild guesses. */
#define DUK_USE_ARCH_STRING "generic"
/* Rely on autodetection for byte order, alignment, and packed tval. */
@@ -0,0 +1,5 @@
#define DUK_USE_ARCH_STRING "m68k"
#if !defined(DUK_USE_BYTEORDER)
#define DUK_USE_BYTEORDER 3
#endif
#define DUK_USE_PACKED_TVAL
@@ -0,0 +1,3 @@
#define DUK_USE_ARCH_STRING "mips32"
/* MIPS byte order varies so rely on autodetection. */
#define DUK_USE_PACKED_TVAL
@@ -0,0 +1,3 @@
#define DUK_USE_ARCH_STRING "mips64"
/* MIPS byte order varies so rely on autodetection. */
#undef DUK_USE_PACKED_TVAL
@@ -0,0 +1,5 @@
#define DUK_USE_ARCH_STRING "ppc32"
#if !defined(DUK_USE_BYTEORDER)
#define DUK_USE_BYTEORDER 3
#endif
#define DUK_USE_PACKED_TVAL
@@ -0,0 +1,3 @@
#define DUK_USE_ARCH_STRING "ppc64"
/* No forced byteorder (both little and big endian are possible). */
#undef DUK_USE_PACKED_TVAL
@@ -0,0 +1,3 @@
#define DUK_USE_ARCH_STRING "riscv32"
#define DUK_USE_BYTEORDER 1
#define DUK_USE_PACKED_TVAL
@@ -0,0 +1,3 @@
#define DUK_USE_ARCH_STRING "riscv64"
#define DUK_USE_BYTEORDER 1
#undef DUK_USE_PACKED_TVAL
@@ -0,0 +1,3 @@
#define DUK_USE_ARCH_STRING "sparc32"
/* SPARC byte order varies so rely on autodetection. */
#define DUK_USE_PACKED_TVAL
@@ -0,0 +1,3 @@
#define DUK_USE_ARCH_STRING "sparc64"
/* SPARC byte order varies so rely on autodetection. */
#undef DUK_USE_PACKED_TVAL
@@ -0,0 +1,3 @@
#define DUK_USE_ARCH_STRING "sh"
/* Byte order varies, rely on autodetection. */
#define DUK_USE_PACKED_TVAL
@@ -0,0 +1,5 @@
#define DUK_USE_ARCH_STRING "x32"
#if !defined(DUK_USE_BYTEORDER)
#define DUK_USE_BYTEORDER 1
#endif
#define DUK_USE_PACKED_TVAL
@@ -0,0 +1,5 @@
#define DUK_USE_ARCH_STRING "x64"
#if !defined(DUK_USE_BYTEORDER)
#define DUK_USE_BYTEORDER 1
#endif
#undef DUK_USE_PACKED_TVAL
@@ -0,0 +1,14 @@
#define DUK_USE_ARCH_STRING "x86"
#if !defined(DUK_USE_BYTEORDER)
#define DUK_USE_BYTEORDER 1
#endif
#define DUK_USE_PACKED_TVAL
/* FreeBSD, -m32, and clang prior to 5.0 has union aliasing issues which
* break duk_tval copying. Disable packed duk_tval automatically.
*/
#if defined(DUK_F_FREEBSD) && defined(DUK_F_X86) && \
defined(__clang__) && defined(__clang_major__) && (__clang_major__ < 5)
#undef DUK_USE_PACKED_TVAL
#endif
@@ -0,0 +1,35 @@
# Compiler metadata.
autodetect:
-
name: Clang
check: DUK_F_CLANG
include: compiler_clang.h.in
-
name: GCC
check: DUK_F_GCC
include: compiler_gcc.h.in
-
name: MSVC
check: DUK_F_MSVC
include: compiler_msvc.h.in
-
name: Emscripten
check: DUK_F_EMSCRIPTEN
include: compiler_emscripten.h.in
-
name: TinyC
check: DUK_F_TINYC
include: compiler_tinyc.h.in
-
name: VBCC
check: DUK_F_VBCC
include: compiler_vbcc.h.in
-
name: Bruce's C compiler
check: DUK_F_BCC
include: compiler_bcc.h.in
-
name: Generic
check: null
include: compiler_generic.h.in
@@ -0,0 +1,24 @@
#undef DUK_USE_BRANCH_HINTS
#if defined(DUK_F_CPP)
#define DUK_USE_COMPILER_STRING "bcc++"
#else
#define DUK_USE_COMPILER_STRING "bcc"
#endif
/* Most portable */
#undef DUK_USE_VARIADIC_MACROS
/* Most portable, wastes space */
#undef DUK_USE_UNION_INITIALIZERS
/* Most portable, wastes space */
#define DUK_USE_FLEX_ONESIZE
/* Most portable, potentially wastes space */
#define DUK_USE_PACK_DUMMY_MEMBER
/* BCC, assume we're on x86. */
#if !defined(DUK_USE_BYTEORDER)
#define DUK_USE_BYTEORDER 1
#endif
@@ -0,0 +1,76 @@
#if defined(DUK_F_C99) || defined(DUK_F_CPP11)
/* C99 / C++11 and above: rely on va_copy() which is required. */
#define DUK_VA_COPY(dest,src) va_copy(dest,src)
#else
/* Clang: assume we have __va_copy() in non-C99 mode. */
#define DUK_VA_COPY(dest,src) __va_copy(dest,src)
#endif
#define DUK_NORETURN(decl) decl __attribute__((noreturn))
#if defined(__clang__) && defined(__has_builtin)
#if __has_builtin(__builtin_unreachable)
#define DUK_UNREACHABLE() do { __builtin_unreachable(); } while (0)
#endif
#endif
#define DUK_USE_BRANCH_HINTS
#define DUK_LIKELY(x) __builtin_expect((x), 1)
#define DUK_UNLIKELY(x) __builtin_expect((x), 0)
#if defined(__clang__) && defined(__has_builtin)
#if __has_builtin(__builtin_unpredictable)
#define DUK_UNPREDICTABLE(x) __builtin_unpredictable((x))
#endif
#endif
#if defined(DUK_F_C99) || defined(DUK_F_CPP11)
#define DUK_NOINLINE __attribute__((noinline))
#define DUK_INLINE inline
#define DUK_ALWAYS_INLINE inline __attribute__((always_inline))
#endif
/* DUK_HOT */
/* DUK_COLD */
#if defined(DUK_F_DLL_BUILD) && defined(DUK_F_WINDOWS)
#snippet "msvc_visibility.h.in"
#else
#snippet "gcc_clang_visibility.h.in"
#endif
#if defined(DUK_F_CPP)
#define DUK_USE_COMPILER_STRING "clang"
#else
#define DUK_USE_COMPILER_STRING "clang"
#endif
#undef DUK_USE_VARIADIC_MACROS
#if defined(DUK_F_C99) || defined(DUK_F_CPP11)
#define DUK_USE_VARIADIC_MACROS
#endif
#define DUK_USE_UNION_INITIALIZERS
#undef DUK_USE_FLEX_C99
#undef DUK_USE_FLEX_ZEROSIZE
#undef DUK_USE_FLEX_ONESIZE
#if defined(DUK_F_C99)
#define DUK_USE_FLEX_C99
#else
#define DUK_USE_FLEX_ZEROSIZE
#endif
#define DUK_USE_CLANG_PRAGMAS
#define DUK_USE_PACK_CLANG_ATTR
#if defined(__clang__) && defined(__has_builtin)
#if __has_builtin(__builtin_bswap64)
#define DUK_BSWAP64(x) ((duk_uint64_t) __builtin_bswap64((duk_uint64_t) (x)))
#endif
#if __has_builtin(__builtin_bswap32)
#define DUK_BSWAP32(x) ((duk_uint32_t) __builtin_bswap32((duk_uint32_t) (x)))
#endif
#if __has_builtin(__builtin_bswap16)
#define DUK_BSWAP16(x) ((duk_uint16_t) __builtin_bswap16((duk_uint16_t) (x)))
#endif
#endif
@@ -0,0 +1,45 @@
#define DUK_NORETURN(decl) decl __attribute__((noreturn))
#if defined(__clang__) && defined(__has_builtin)
#if __has_builtin(__builtin_unreachable)
#define DUK_UNREACHABLE() do { __builtin_unreachable(); } while (0)
#endif
#endif
#define DUK_USE_BRANCH_HINTS
#define DUK_LIKELY(x) __builtin_expect((x), 1)
#define DUK_UNLIKELY(x) __builtin_expect((x), 0)
#if defined(__clang__) && defined(__has_builtin)
#if __has_builtin(__builtin_unpredictable)
#define DUK_UNPREDICTABLE(x) __builtin_unpredictable((x))
#endif
#endif
#if defined(DUK_F_C99) || defined(DUK_F_CPP11)
#define DUK_NOINLINE __attribute__((noinline))
#define DUK_INLINE inline
#define DUK_ALWAYS_INLINE inline __attribute__((always_inline))
#endif
#snippet "gcc_clang_visibility.h.in"
#define DUK_USE_COMPILER_STRING "emscripten"
#undef DUK_USE_VARIADIC_MACROS
#if defined(DUK_F_C99) || defined(DUK_F_CPP11)
#define DUK_USE_VARIADIC_MACROS
#endif
#define DUK_USE_UNION_INITIALIZERS
#undef DUK_USE_FLEX_C99
#undef DUK_USE_FLEX_ZEROSIZE
#undef DUK_USE_FLEX_ONESIZE
#if defined(DUK_F_C99)
#define DUK_USE_FLEX_C99
#else
#define DUK_USE_FLEX_ZEROSIZE
#endif
#undef DUK_USE_GCC_PRAGMAS
#define DUK_USE_PACK_CLANG_ATTR
@@ -0,0 +1,99 @@
#if defined(DUK_F_C99) || defined(DUK_F_CPP11)
/* C99 / C++11 and above: rely on va_copy() which is required. */
#define DUK_VA_COPY(dest,src) va_copy(dest,src)
#else
/* GCC: assume we have __va_copy() in non-C99 mode. */
#define DUK_VA_COPY(dest,src) __va_copy(dest,src)
#endif
#if defined(DUK_F_GCC_VERSION) && (DUK_F_GCC_VERSION >= 20500L) && (DUK_F_GCC_VERSION < 50000L)
/* Since gcc-2.5.
*
* Disabled temporarily in GCC 5+ because of an unresolved noreturn-related
* issue: https://github.com/svaarala/duktape/issues/2155.
*/
#define DUK_NORETURN(decl) decl __attribute__((noreturn))
#endif
#if defined(DUK_F_GCC_VERSION) && (DUK_F_GCC_VERSION >= 40500L)
/* Since gcc-4.5. */
#define DUK_UNREACHABLE() do { __builtin_unreachable(); } while (0)
#endif
#define DUK_USE_BRANCH_HINTS
#if defined(DUK_F_GCC_VERSION) && (DUK_F_GCC_VERSION >= 40500L)
/* GCC: test not very accurate; enable only in relatively recent builds
* because of bugs in gcc-4.4 (http://lists.debian.org/debian-gcc/2010/04/msg00000.html)
*/
#define DUK_LIKELY(x) __builtin_expect((x), 1)
#define DUK_UNLIKELY(x) __builtin_expect((x), 0)
#endif
/* XXX: equivalent of clang __builtin_unpredictable? */
#if (defined(DUK_F_C99) || defined(DUK_F_CPP11)) && \
defined(DUK_F_GCC_VERSION) && (DUK_F_GCC_VERSION >= 30101)
#define DUK_NOINLINE __attribute__((noinline))
#define DUK_INLINE inline
#define DUK_ALWAYS_INLINE inline __attribute__((always_inline))
#endif
#if (defined(DUK_F_C99) || defined(DUK_F_CPP11)) && \
defined(DUK_F_GCC_VERSION) && (DUK_F_GCC_VERSION >= 40300)
#define DUK_HOT __attribute__((hot))
#define DUK_COLD __attribute__((cold))
#endif
#if defined(DUK_F_DLL_BUILD) && defined(DUK_F_WINDOWS)
#snippet "msvc_visibility.h.in"
#elif defined(DUK_F_GCC_VERSION) && (DUK_F_GCC_VERSION >= 40000)
#snippet "gcc_clang_visibility.h.in"
#endif
#if defined(DUK_F_MINGW)
#if defined(DUK_F_CPP)
#define DUK_USE_COMPILER_STRING "mingw++"
#else
#define DUK_USE_COMPILER_STRING "mingw"
#endif
#else
#if defined(DUK_F_CPP)
#define DUK_USE_COMPILER_STRING "g++"
#else
#define DUK_USE_COMPILER_STRING "gcc"
#endif
#endif
#undef DUK_USE_VARIADIC_MACROS
#if defined(DUK_F_C99) || (defined(DUK_F_CPP11) && defined(__GNUC__))
#define DUK_USE_VARIADIC_MACROS
#endif
#define DUK_USE_UNION_INITIALIZERS
#undef DUK_USE_FLEX_C99
#undef DUK_USE_FLEX_ZEROSIZE
#undef DUK_USE_FLEX_ONESIZE
#if defined(DUK_F_C99)
#define DUK_USE_FLEX_C99
#else
#define DUK_USE_FLEX_ZEROSIZE
#endif
/* Since 4.6 one can '#pragma GCC diagnostic push/pop'. */
#if defined(DUK_F_GCC_VERSION) && (DUK_F_GCC_VERSION >= 40600)
#define DUK_USE_GCC_PRAGMAS
#else
#undef DUK_USE_GCC_PRAGMAS
#endif
#define DUK_USE_PACK_GCC_ATTR
/* Availability varies based on platform (between GCC 4.4 and 4.8), and there
* are apparently some bugs in GCC 4.x. Check for GCC 5.0 before enabling
* these to be safe.
*/
#if defined(DUK_F_GCC_VERSION) && (DUK_F_GCC_VERSION >= 50000L)
#define DUK_BSWAP64(x) ((duk_uint64_t) __builtin_bswap64((duk_uint64_t) (x)))
#define DUK_BSWAP32(x) ((duk_uint32_t) __builtin_bswap32((duk_uint32_t) (x)))
#define DUK_BSWAP16(x) ((duk_uint16_t) __builtin_bswap16((duk_uint16_t) (x)))
#endif
@@ -0,0 +1,24 @@
#undef DUK_USE_BRANCH_HINTS
#if defined(DUK_F_CPP)
#define DUK_USE_COMPILER_STRING "generic-c++"
#else
#define DUK_USE_COMPILER_STRING "generic"
#endif
#undef DUK_USE_VARIADIC_MACROS
#if defined(DUK_F_C99) || defined(DUK_F_CPP11)
#define DUK_USE_VARIADIC_MACROS
#endif
/* C++ doesn't have standard designated union initializers ({ .foo = 1 }). */
#undef DUK_USE_UNION_INITIALIZERS
#if defined(DUK_F_C99)
#define DUK_USE_UNION_INITIALIZERS
#endif
/* Most portable, wastes space */
#define DUK_USE_FLEX_ONESIZE
/* Most portable, potentially wastes space */
#define DUK_USE_PACK_DUMMY_MEMBER
@@ -0,0 +1,84 @@
/* http://msdn.microsoft.com/en-us/library/aa235362(VS.60).aspx */
#define DUK_NORETURN(decl) __declspec(noreturn) decl
/* XXX: DUK_UNREACHABLE for msvc? */
#undef DUK_USE_BRANCH_HINTS
/* XXX: DUK_LIKELY, DUK_UNLIKELY for msvc? */
/* XXX: DUK_NOINLINE, DUK_INLINE, DUK_ALWAYS_INLINE for msvc? */
#if defined(DUK_F_DLL_BUILD) && defined(DUK_F_WINDOWS)
#snippet "msvc_visibility.h.in"
#endif
#if defined(DUK_F_CPP)
#define DUK_USE_COMPILER_STRING "msvc++"
#else
#define DUK_USE_COMPILER_STRING "msvc"
#endif
#undef DUK_USE_VARIADIC_MACROS
#if defined(DUK_F_C99)
#define DUK_USE_VARIADIC_MACROS
#elif defined(_MSC_VER) && (_MSC_VER >= 1400)
/* VS2005+ should have variadic macros even when they're not C99. */
#define DUK_USE_VARIADIC_MACROS
#endif
#undef DUK_USE_UNION_INITIALIZERS
#if defined(_MSC_VER) && (_MSC_VER >= 1800)
/* VS2013+ supports union initializers but there's a bug involving union-inside-struct:
* https://connect.microsoft.com/VisualStudio/feedback/details/805981
* The bug was fixed (at least) in VS2015 so check for VS2015 for now:
* https://blogs.msdn.microsoft.com/vcblog/2015/07/01/c-compiler-front-end-fixes-in-vs2015/
* Manually tested using VS2013, CL reports 18.00.31101, so enable for VS2013 too.
*/
#define DUK_USE_UNION_INITIALIZERS
#endif
#undef DUK_USE_FLEX_C99
#undef DUK_USE_FLEX_ZEROSIZE
#undef DUK_USE_FLEX_ONESIZE
#if defined(DUK_F_C99)
#define DUK_USE_FLEX_C99
#else
#define DUK_USE_FLEX_ZEROSIZE
#endif
#undef DUK_USE_GCC_PRAGMAS
#define DUK_USE_PACK_MSVC_PRAGMA
/* These have been tested from VS2008 onwards; may work in older VS versions
* too but not enabled by default.
*/
#if defined(_MSC_VER) && (_MSC_VER >= 1500)
#define DUK_NOINLINE __declspec(noinline)
#define DUK_INLINE __inline
#define DUK_ALWAYS_INLINE __forceinline
#endif
#if defined(_MSC_VER) && (_MSC_VER >= 1900)
#define DUK_SNPRINTF snprintf
#define DUK_VSNPRINTF vsnprintf
#else
/* (v)snprintf() is missing before MSVC 2015. Note that _(v)snprintf() does
* NOT NUL terminate on truncation, but Duktape code never assumes that.
* http://stackoverflow.com/questions/2915672/snprintf-and-visual-studio-2010
*/
#define DUK_SNPRINTF _snprintf
#define DUK_VSNPRINTF _vsnprintf
#endif
/* Avoid warning when doing DUK_UNREF(some_function). */
#if defined(_MSC_VER) && (_MSC_VER < 1500)
#pragma warning(disable: 4100 4101 4550 4551)
#define DUK_UNREF(x)
#else
#define DUK_UNREF(x) do { __pragma(warning(suppress:4100 4101 4550 4551)) (x); } while (0)
#endif
/* Older versions of MSVC don't support the LL/ULL suffix. */
#define DUK_U64_CONSTANT(x) x##ui64
#define DUK_I64_CONSTANT(x) x##i64
@@ -0,0 +1,18 @@
#undef DUK_USE_BRANCH_HINTS
#if defined(DUK_F_CPP)
#define DUK_USE_COMPILER_STRING "tinyc++"
#else
#define DUK_USE_COMPILER_STRING "tinyc"
#endif
/* http://bellard.org/tcc/tcc-doc.html#SEC7 */
#define DUK_USE_VARIADIC_MACROS
#define DUK_USE_UNION_INITIALIZERS
/* Most portable, wastes space */
#define DUK_USE_FLEX_ONESIZE
/* Most portable, potentially wastes space */
#define DUK_USE_PACK_DUMMY_MEMBER
@@ -0,0 +1,23 @@
#undef DUK_USE_BRANCH_HINTS
#if defined(DUK_F_CPP)
#define DUK_USE_COMPILER_STRING "vbcc-c++"
#else
#define DUK_USE_COMPILER_STRING "vbcc"
#endif
#undef DUK_USE_VARIADIC_MACROS
#if defined(DUK_F_C99) || defined(DUK_F_CPP11)
#define DUK_USE_VARIADIC_MACROS
#endif
/* VBCC supports C99 so check only for C99 for union initializer support.
* Designated union initializers would possibly work even without a C99 check.
*/
#undef DUK_USE_UNION_INITIALIZERS
#if defined(DUK_F_C99)
#define DUK_USE_UNION_INITIALIZERS
#endif
#define DUK_USE_FLEX_ZEROSIZE
#define DUK_USE_PACK_DUMMY_MEMBER
@@ -0,0 +1,8 @@
define: DUK_USE_32BIT_PTRS
introduced: 1.0.0
removed: 1.4.0
default: false
tags:
- portability
description: >
Pointers are 32-bit integer compatible.
@@ -0,0 +1,9 @@
define: DUK_USE_64BIT_OPS
introduced: 1.0.0
default: true
tags:
- portability
description: >
Use 64-bit integer operations. On some platforms 64-bit types may be
available but 64-bit operations don't work correctly e.g. in integer/float
casts.
@@ -0,0 +1,11 @@
define: DUK_USE_ALIGN_4
introduced: 1.0.0
removed: 1.3.0
related:
- DUK_USE_ALIGN_BY
default: false
tags:
- portability
description: >
Use 4-byte alignment for 64-bit integers and IEEE doubles.
Replaced by DUK_USE_ALIGN_BY.
@@ -0,0 +1,11 @@
define: DUK_USE_ALIGN_8
introduced: 1.0.0
removed: 1.3.0
related:
- DUK_USE_ALIGN_BY
default: false
tags:
- portability
description: >
Use 8-byte alignment for 64-bit integers and IEEE doubles.
Replaced by DUK_USE_ALIGN_BY.
@@ -0,0 +1,8 @@
define: DUK_USE_ALIGN_BY
introduced: 1.3.0
default: 8
tags:
- portability
description: >
Use N-byte alignment for 64-bit integers and IEEE doubles
(supported values are 1, 4, and 8).
@@ -0,0 +1,10 @@
define: DUK_USE_ALLOW_UNDEFINED_BEHAVIOR
introduced: 2.3.0
default: false
tags:
- portability
description: >
Allow technically undefined behavior such as out-of-range double-to-integer
casts, floating point division by zero, etc. which are likely to work on the
majority of platforms. Default is to avoid such behaviors, at the cost of
some footprint and performance.
@@ -0,0 +1,9 @@
define: DUK_USE_ARCH_STRING
introduced: 1.0.0
default:
string: "unknown"
tags:
- portability
description: >
Human-readable architecture string used in e.g. Duktape.env and debugger
protocol (example: x64).
@@ -0,0 +1,7 @@
define: DUK_USE_ARRAY_BUILTIN
introduced: 2.0.0
default: true
tags:
- ecmascript
description: >
Provide an Array built-in.
@@ -0,0 +1,15 @@
define: DUK_USE_ARRAY_FASTPATH
introduced: 2.0.0
default: true
tags:
- performance
- fastpath
- lowmemory
- compliance
description: >
Enable fast path for Array.prototype operations like push(), pop(), etc.
The fast path handles dense Array instances which are more common than
sparse arrays or non-array objects (which Array.prototype operations must
also support). The fast path assumes that Array.prototype doesn't contain
inherited index properties; such properties are very rarely used in
practical code. If compliance is critical, disable the fast path.
@@ -0,0 +1,14 @@
define: DUK_USE_ARRAY_PROP_FASTPATH
introduced: 2.0.0
default: true
tags:
- performance
- fastpath
- lowmemory
- compliance
description: >
Enable a shallow fast path check for Array index property reads and writes.
The fast path assumes Array.prototype doesn't have numeric index properties
which would be inherited and affect read/write behavior. This behavior is
non-compliant (but practical because such inherited properties are very
rare). Disable this option to ensure strict compliance.
@@ -0,0 +1,9 @@
define: DUK_USE_ASSERTIONS
introduced: 1.0.0
default: false
tags:
- development
- debug
description: >
Enable internal assert checks. These slow down execution considerably
so only use when debugging.
@@ -0,0 +1,8 @@
define: DUK_USE_ATAN2_WORKAROUNDS
introduced: 2.0.0
default: false
tags:
- portability
description: >
Enable workarounds to common atan2() semantics issues. At least Cygwin/MinGW
has such issues, see test-bug-mingw-math-issues.js.
@@ -0,0 +1,8 @@
define: DUK_USE_AUGMENT_ERROR_CREATE
introduced: 1.0.0
default: true
tags:
- ecmascript
description: >
Augment an ECMAScript error object at creation with tracedata or
fileName/lineNumber, or Duktape.errCreate (if enabled).
@@ -0,0 +1,8 @@
define: DUK_USE_AUGMENT_ERROR_THROW
introduced: 1.0.0
default: true
tags:
- ecmascript
description: >
Augment an ECMAScript error object at throw time with Duktape.errThrow
(if enabled).
@@ -0,0 +1,13 @@
define: DUK_USE_AVOID_PLATFORM_FUNCPTRS
introduced: 1.0.0
default: true
tags:
- portability
description: >
Don't assume that platform functions (e.g. math functions) are actual
functions. This option is needed if platform functions may be defined
as macros. This is certainly the case with some platform "polyfills"
which provide missing C99/C++11 functions through macros, and may be
the case with VS2013 (see GH-17).
This is now the default: the cost in footprint is negligible.
@@ -0,0 +1,10 @@
define: DUK_USE_BASE64_FASTPATH
introduced: 1.4.0
default: true
tags:
- performance
- fastpath
- lowmemory
description: >
Enable fast path for base64 encode/decode. The fast path uses a lookup
table at a small cost in footprint.
@@ -0,0 +1,7 @@
define: DUK_USE_BASE64_SUPPORT
introduced: 2.3.0
default: true
tags:
- codec
description: >
Enable base64 encoding/decoding support.
@@ -0,0 +1,7 @@
define: DUK_USE_BOOLEAN_BUILTIN
introduced: 2.0.0
default: true
tags:
- ecmascript
description: >
Provide a Boolean built-in.
@@ -0,0 +1,9 @@
define: DUK_USE_BRANCH_HINTS
introduced: 1.0.0
default: true
tags:
- portability
description: >
Use branch hints if the compiler supports them.
# XXX: Unused now, DUK_LIKELY and DUK_UNLIKELY are used instead.
@@ -0,0 +1,8 @@
define: DUK_USE_BROWSER_LIKE
introduced: 1.0.0
removed: 2.0.0
default: true
tags:
- ecmascript
description: >
Provide browser-like bindings: currently print() and alert().
@@ -0,0 +1,15 @@
define: DUK_USE_BUFFEROBJECT_SUPPORT
introduced: 1.3.0
default: true
tags:
- ecmascript2015
description: >
Enable support for Khronos/ES6 typed arrays and Node.js Buffer objects.
When disabled, Duktape custom plain buffer type is present and functional
in the C API. Plain buffers have virtual properties and you can read/write
buffer contents in ECMAScript code. Plain buffers will still inherit from
ArrayBuffer.prototype, but none of the ECMAScript buffer related bindings
will work. This includes all ArrayBuffer, typed array, and Node.js Buffer
methods. Native bindings which produce plain buffer results (like
Duktape.dec()) will still work.
@@ -0,0 +1,8 @@
define: DUK_USE_BUFLEN16
introduced: 1.1.0
default: false
tags:
- lowmemory
- experimental
description: >
Use a 16-bit buffer length field (for low memory environments).
@@ -0,0 +1,12 @@
define: DUK_USE_BUILTIN_INITJS
introduced: 1.0.0
removed: 2.0.0
default: true
tags:
- ecmascript
description: >
Use built-in .js init code when creating a new global context.
The .js init code (duk_initjs.js) provides some initialization
code that's nicer to implement in ECMAScript, and is also used
to provide some backwards compatibility bindings which are easy
to remove later.
@@ -0,0 +1,7 @@
define: DUK_USE_BYTECODE_DUMP_SUPPORT
introduced: 1.3.0
default: true
tags:
- api
description: >
Enable support for API calls to dump/load function bytecode.
@@ -0,0 +1,16 @@
define: DUK_USE_BYTEORDER
introduced: 1.4.0
default: 0 # no reasonable automatic default
tags:
- portability
description: >
Byte order for platform: 1 = little endian, 2 = mixed (arm hybrid) endian,
3 = big endian.
ARM mixed endian means integers are little endian but IEEE doubles have
mixed endianness: big endian bytes 12345678 are ordered in memory as
43218765. See http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.dui0056d/Bcfhgcgd.html.
(This define should be produced by duk_config.h; currently Duktape internals
use automatically derived defines DUK_USE_{INTEGER,DOUBLE}_{LE,BE_ME}
instead of using this define directly.)
@@ -0,0 +1,9 @@
define: DUK_USE_BYTEORDER_FORCED
introduced: 1.0.0
removed: 1.4.0
default: false
tags:
- portability
description: >
Byte order was forced (instead of being autodetected). This has no
functional impact but the forced status shows up in Duktape.env.
@@ -0,0 +1,9 @@
define: DUK_USE_CACHE_ACTIVATION
introduced: 2.2.0
default: true
tags:
- performance
description: >
Cache duk_activation records. When releasing a duk_activation, place it in
a free list for later reuse. Mark-and-sweep frees the free list to keep
memory usage in check.
@@ -0,0 +1,9 @@
define: DUK_USE_CACHE_CATCHER
introduced: 2.2.0
default: true
tags:
- performance
description: >
Cache duk_catcher records. When releasing a duk_catcher, place it in
a free list for later reuse. Mark-and-sweep frees the free list to keep
memory usage in check.
@@ -0,0 +1,10 @@
define: DUK_USE_CALLSTACK_LIMIT
introduced: 2.2.0
default: 10000
tags:
- misc
description: >
Maximum call stack size. If call stack would grow beyond this value, reject
the call in progress. This mainly protects against runaway recursion. Note
in particular that this limit is unrelated to the native C stack size which
has a separate limit define.
@@ -0,0 +1,9 @@
define: DUK_USE_CBOR_BUILTIN
introduced: 2.5.0
default: true
tags:
- codec
- cbor
- experimental
description: >
Provide a CBOR built-in with CBOR.encode() and CBOR.decode() functions.
@@ -0,0 +1,8 @@
define: DUK_USE_CBOR_DEC_RECLIMIT
introduced: 2.6.0
default: 1000
tags:
- portability
- cstackdepth
description: >
Maximum native stack recursion for CBOR decoding.
@@ -0,0 +1,8 @@
define: DUK_USE_CBOR_ENC_RECLIMIT
introduced: 2.6.0
default: 1000
tags:
- portability
- cstackdepth
description: >
Maximum native stack recursion for CBOR encoding.
@@ -0,0 +1,10 @@
define: DUK_USE_CBOR_SUPPORT
introduced: 2.5.0
default: true
tags:
- codec
- cbor
- experimental
description: >
Include CBOR support. When disabled, CBOR functions in the C API (and the
CBOR built-in, if enabled) will throw an error.
@@ -0,0 +1,8 @@
define: DUK_USE_CLANG_PRAGMAS
introduced: 2.5.0
default: false
tags:
- portability
description: >
Use Clang-specific pragmas, e.g. "#pragma clang diagnostic" to suppress
unnecessary warnings.
@@ -0,0 +1,11 @@
define: DUK_USE_COMMONJS_MODULES
introduced: 1.0.0
removed: 2.0.0
default: true
tags:
- ecmascript
description: >
Enable support for CommonJS modules. When enabled, the global require()
function provides a simple module loader facility which depends on the user
providing low level module searching functionality. When disabled, the
global require() function is present but throws an error.
@@ -0,0 +1,8 @@
define: DUK_USE_COMPILER_RECLIMIT
introduced: 1.3.0
default: 2500
tags:
- portability
- cstackdepth
description: >
ECMAScript compiler native call stack recursion limit.
@@ -0,0 +1,9 @@
define: DUK_USE_COMPILER_STRING
introduced: 1.0.0
default:
string: "unknown"
tags:
- portability
description: >
Human-readable compiler string used in e.g. Duktape.env and debugger
protocol (example: gcc).
@@ -0,0 +1,15 @@
define: DUK_USE_COMPUTED_INFINITY
introduced: 1.0.0
default: false
tags:
- portability
description: >
The DUK_DOUBLE_INFINITY is not a constant but refers to a global variable
with an IEEE double infinity value computed at run-time. Some compilers
don't provide a constant for infinity, and may incorrectly evaluate
(1 / 0) when doing constant folding.
When enabled, define DUK_DOUBLE_INFINITY as duk_computed_infinity.
# XXX: Remove computed infinity from Duktape itself and let user
# provide it instead?
@@ -0,0 +1,15 @@
define: DUK_USE_COMPUTED_NAN
introduced: 1.0.0
default: false
tags:
- portability
description: >
The DUK_DOUBLE_NAN is not a constant but refers to a global variable with
an IEEE NaN value computed at run-time. Some compilers don't provide a
constant for NaN, and may incorrectly evaluate (0 / 0) when doing
constant folding.
When enabled, define DUK_DOUBLE_NAN as duk_computed_nan.
# XXX: Remove computed NaN from Duktape itself and let user provide
# it instead?
@@ -0,0 +1,7 @@
define: DUK_USE_COROUTINE_SUPPORT
introduced: 2.0.0
default: true
tags:
- execution
description: >
Enable support for Duktape coroutines, i.e. yield/resume.
@@ -0,0 +1,9 @@
define: DUK_USE_CPP_EXCEPTIONS
introduced: 1.4.0
default: false
tags:
- portability
description: >
Use C++ exceptions instead of setjmp/longjmp for long control transfers.
This allows Duktape/C functions written in C++ to use automatic destructors
(RAII or scope-based resource management).
@@ -0,0 +1,21 @@
define: DUK_USE_DATAPTR16
introduced: 1.1.0
related:
- DUK_USE_DATAPTR_ENC16
- DUK_USE_DATAPTR_DEC16
default: false
tags:
- lowmemory
- experimental
description: >
Enable "compression" of arbitrary data pointers into an unsigned 16-bit
value. Use together with DUK_USE_DATAPTR_ENC16 and DUK_USE_DATAPTR_DEC16.
Pointers compressed are any void pointers in C code, not just the Duktape
heap. Also NULL pointer must encode and decode correctly.
Currently it is required that NULL encodes to integer 0, and integer
0 decodes to NULL. No other pointer can be encoded to 0.
NOTE: This feature option is currently unimplemented, i.e. Duktape won't
compress any data pointers at the moment.
@@ -0,0 +1,13 @@
define: DUK_USE_DATAPTR_DEC16
introduced: 1.1.0
requires:
- DUK_USE_DATAPTR16
default: false
tags:
- lowmemory
- experimental
description: >
Use together with DUK_USE_DATAPTR16 for arbitrary data pointer compression.
DUK_USE_DATAPTR_DEC16(udata,x) is a macro with a userdata and duk_uint16_t
argument, and a void ptr return value. The userdata argument is the heap
userdata value given at heap creation.
@@ -0,0 +1,15 @@
define: DUK_USE_DATAPTR_ENC16
introduced: 1.1.0
requires:
- DUK_USE_DATAPTR16
default: false
tags:
- lowmemory
- experimental
description: >
Use together with DUK_USE_DATAPTR16 for arbitrary data pointer compression.
DUK_USE_DATAPTR_ENC16(udata,p) is a macro with a userdata and void ptr
argument, and a duk_uint16_t return value. The userdata argument is the
heap userdata value given at heap creation. Currently it is required that
NULL encodes to integer 0, and integer 0 decodes to NULL. No other pointer
can be encoded to 0.
@@ -0,0 +1,7 @@
define: DUK_USE_DATE_BUILTIN
introduced: 2.0.0
default: true
tags:
- ecmascript
description: >
Provide a Date built-in.
@@ -0,0 +1,10 @@
define: DUK_USE_DATE_FMT_STRFTIME
introduced: 1.0.0
default: false
tags:
- date
- portability
description: >
Use strftime() to format Date values in native, platform specific format
before falling back into ISO 8601. When enabled, appropriate date/time
headers must be included.
@@ -0,0 +1,9 @@
define: DUK_USE_DATE_FORMAT_STRING
introduced: 1.3.0
default: false
tags:
- date
- portability
description: >
Optional macro for formatting a date in a platform dependent manner,
see datetime.rst.
@@ -0,0 +1,9 @@
define: DUK_USE_DATE_GET_LOCAL_TZOFFSET
introduced: 1.3.0
default: false
tags:
- date
- portability
description: >
Mandatory macro for getting the local time offset for a given datetime,
see datetime.rst.
@@ -0,0 +1,15 @@
define: DUK_USE_DATE_GET_NOW
introduced: 1.3.0
default: false
tags:
- date
- portability
description: >
Mandatory macro for getting the current time, see datetime.rst. The macro
is allowed (and recommended) to return millisecond fractions. The fractions
are truncated by the Date built-in, but are available via duk_get_now() C
API call.
If the time provided experiences time jumps or doesn't advance in realtime
(which is useful in some time virtualization scenarios), consider defining
DUK_USE_GET_MONOTONIC_TIME.
@@ -0,0 +1,9 @@
define: DUK_USE_DATE_NOW_GETTIMEOFDAY
introduced: 1.0.0
default: false
tags:
- date
- portability
description: >
Use gettimeofday() to get current datetime. When enabled, appropriate
date/time headers must be included.
@@ -0,0 +1,10 @@
define: DUK_USE_DATE_NOW_TIME
introduced: 1.0.0
default: false
tags:
- date
- portability
description: >
Use time() to get current datetime, with the limitation that datetime is
limited to one second resolution. When enabled, appropriate date/time
headers must be included.
@@ -0,0 +1,8 @@
define: DUK_USE_DATE_NOW_WINDOWS
introduced: 1.0.0
default: false
tags:
- date
- portability
description: >
Use Win32 API calls to get current datetime.
@@ -0,0 +1,9 @@
define: DUK_USE_DATE_NOW_WINDOWS_SUBMS
introduced: 2.2.0
default: false
tags:
- date
- portability
description: >
Like DUK_USE_DATE_NOW_WINDOWS but use GetSystemTimePreciseAsFileTime(),
available since Windows 8, for sub-millisecond resolution.
@@ -0,0 +1,9 @@
define: DUK_USE_DATE_PARSE_STRING
introduced: 1.3.0
default: false
tags:
- date
- portability
description: >
Optional macro for parsing a date in a platform dependent manner,
see datetime.rst.
@@ -0,0 +1,11 @@
define: DUK_USE_DATE_PRS_GETDATE
introduced: 1.3.0
default: false
tags:
- date
- portability
description: >
Use getdate_r() to parse a platform specific datetime string into ECMAScript
time. getdate_r() depends on DATEMSK being set so this is not always very
convenient for an embedded interpreter. When enabled, appropriate date/time
headers must be included.
@@ -0,0 +1,9 @@
define: DUK_USE_DATE_PRS_STRPTIME
introduced: 1.0.0
default: false
tags:
- date
- portability
description: >
Use strptime() to parse a platform specific datetime string into ECMAScript
time.
@@ -0,0 +1,11 @@
define: DUK_USE_DATE_TZO_GMTIME
introduced: 1.0.0
default: false
tags:
- date
- portability
description: >
Use gmtime() to get local time offset at a certain time.
When enabled, appropriate date/time headers must be included.
Since gmtime() is not re-entrant, this is not thread safe.
@@ -0,0 +1,9 @@
define: DUK_USE_DATE_TZO_GMTIME_R
introduced: 1.0.0
default: false
tags:
- date
- portability
description: >
Use gmtime_r() to get local time offset at a certain time.
When enabled, appropriate date/time headers must be included.
@@ -0,0 +1,8 @@
define: DUK_USE_DATE_TZO_GMTIME_S
introduced: 2.0.0
default: false
tags:
- date
- portability
description: >
Use gmtime_s() to get local time offset at a certain time.
Loaded 100 of 999 files, more files were not shown because too many files have changed in this diff. Show more