packages feed

hs-duktape 0.1.5 → 1.0.0

raw patch · 12 files changed

+4760/−5167 lines, 12 filesdep +timebuild-type:Customsetup-changedPVP ok

version bump matches the API change (PVP)

Dependencies added: time

API changes (from Hackage documentation)

- Scripting.Duktape: instance Scripting.Duktape.Duktapeable (Data.Aeson.Types.Internal.Value -> Data.Aeson.Types.Internal.Value -> Data.Aeson.Types.Internal.Value -> Data.Aeson.Types.Internal.Value -> Data.Aeson.Types.Internal.Value -> GHC.Types.IO Data.Aeson.Types.Internal.Value)
- Scripting.Duktape: instance Scripting.Duktape.Duktapeable (Data.Aeson.Types.Internal.Value -> Data.Aeson.Types.Internal.Value -> Data.Aeson.Types.Internal.Value -> Data.Aeson.Types.Internal.Value -> GHC.Types.IO Data.Aeson.Types.Internal.Value)
- Scripting.Duktape: instance Scripting.Duktape.Duktapeable (Data.Aeson.Types.Internal.Value -> Data.Aeson.Types.Internal.Value -> Data.Aeson.Types.Internal.Value -> GHC.Types.IO Data.Aeson.Types.Internal.Value)
- Scripting.Duktape: instance Scripting.Duktape.Duktapeable (Data.Aeson.Types.Internal.Value -> Data.Aeson.Types.Internal.Value -> GHC.Types.IO Data.Aeson.Types.Internal.Value)
- Scripting.Duktape: instance Scripting.Duktape.Duktapeable (Data.Aeson.Types.Internal.Value -> GHC.Types.IO Data.Aeson.Types.Internal.Value)
- Scripting.Duktape: instance Scripting.Duktape.Duktapeable (GHC.Types.IO Data.Aeson.Types.Internal.Value)
+ Scripting.Duktape: instance (Scripting.Duktape.Duktapeable ξ, Data.Aeson.Types.FromJSON.FromJSON v) => Scripting.Duktape.Duktapeable (v -> ξ)
+ Scripting.Duktape: instance Data.Aeson.Types.ToJSON.ToJSON v => Scripting.Duktape.Duktapeable (GHC.Types.IO v)
+ Scripting.Duktape.Raw: InternalUData :: Ptr () -> InternalUData
+ Scripting.Duktape.Raw: [getInternalUData] :: InternalUData -> Ptr ()
+ Scripting.Duktape.Raw: c_DUK_RET_TYPE_ERROR :: CInt
+ Scripting.Duktape.Raw: createGovernedHeap :: FunPtr DukAllocFunction -> FunPtr DukReallocFunction -> FunPtr DukFreeFunction -> TimeoutCheck -> FunPtr DukFatalFunction -> IO (Maybe DuktapeCtx)
+ Scripting.Duktape.Raw: execTimeoutCheck :: DukExecTimeoutCheckFunction
+ Scripting.Duktape.Raw: newtype InternalUData
+ Scripting.Duktape.Raw: nullUData :: InternalUData
+ Scripting.Duktape.Raw: type CheckActionUData = Ptr TimeoutCheckWrapped
+ Scripting.Duktape.Raw: type DukExecTimeoutCheckFunction = Ptr () -> IO (CUInt)
+ Scripting.Duktape.Raw: type TimeoutCheck = IO Bool
+ Scripting.Duktape.Raw: type TimeoutCheckWrapped = FunPtr (IO Bool)
+ Scripting.Duktape.Raw: unwrapTimeoutCheck :: TimeoutCheckWrapped -> IO Bool
+ Scripting.Duktape.Raw: wrapTimeoutCheck :: IO Bool -> IO TimeoutCheckWrapped
- Scripting.Duktape.Raw: c_duk_destroy_heap :: FunPtr (Ptr DuktapeHeap -> IO ())
+ Scripting.Duktape.Raw: c_duk_destroy_heap :: Ptr DuktapeHeap -> IO ()
- Scripting.Duktape.Raw: createHeap :: FunPtr DukAllocFunction -> FunPtr DukReallocFunction -> FunPtr DukFreeFunction -> Ptr () -> FunPtr DukFatalFunction -> IO (Maybe DuktapeCtx)
+ Scripting.Duktape.Raw: createHeap :: FunPtr DukAllocFunction -> FunPtr DukReallocFunction -> FunPtr DukFreeFunction -> InternalUData -> FunPtr DukFatalFunction -> IO (Maybe DuktapeCtx)

Files

README.md view
@@ -1,5 +1,10 @@-# hs-duktape [![Hackage](https://img.shields.io/hackage/v/hs-duktape.svg?style=flat)](https://hackage.haskell.org/package/hs-duktape) [![Build Status](https://img.shields.io/travis/myfreeweb/hs-duktape.svg?style=flat)](https://travis-ci.org/myfreeweb/hs-duktape) [![MIT License](https://img.shields.io/badge/mit-license-green.svg?style=flat)](https://tldrlegal.com/license/mit-license)+[![Hackage](https://img.shields.io/hackage/v/hs-duktape.svg?style=flat)](https://hackage.haskell.org/package/hs-duktape)+[![Linux Build Status](https://img.shields.io/travis/myfreeweb/hs-duktape.svg?style=flat)](https://travis-ci.org/myfreeweb/hs-duktape)+[![Windows Build Status](https://img.shields.io/appveyor/ci/myfreeweb/hs-duktape.svg?style=flat)](https://ci.appveyor.com/project/myfreeweb/hs-duktape)+[![MIT License](https://img.shields.io/badge/mit-license-green.svg?style=flat)](https://tldrlegal.com/license/mit-license) +# hs-duktape+ Haskell bindings for [duktape], a very compact embedded ECMAScript (JavaScript) engine.  [duktape]: http://duktape.org@@ -46,21 +51,43 @@  ```haskell dukm <- createDuktapeCtx-let dbl (Number x) = return $ Number $ x * 2 ∷ IO Value+let dbl (Number x) = return $ Number $ x * 2 :: IO Value     dbl _ = return $ String "wtf"-reD ← exposeFnDuktape (fromJust ctx) Nothing "double" dbl +reD <- exposeFnDuktape (fromJust ctx) Nothing "double" dbl  ``` -The functions must be of type `IO ()`, `IO Value`, `Value -> IO Value`, `Value -> Value -> IO Value`... and so on, up to 5 arguments.-If you need more, use an `Object` `Value`, seriously.+The functions must be of type `IO ()`, `IO Value`, `Value -> IO Value`, `Value -> Value -> IO Value`... and so on.+(Or with any `ToJSON`/`FromJSON` values instead of `Value`) +### Advanced: Script execution timeout++Instead of `createDuktapeCtx`, you can use `createGovernedHeap` to enforce termination via a timeout:++```haskell+allowQuarterSecond :: IO (IO Bool)+allowQuarterSecond = do+  initializedAt <- getCurrentTime+  return $ do+    now <- getCurrentTime+    let diff = diffUTCTime now initializedAt+    return $ diff > 0.25+++guvnor <- allowQuarterSecond+ctx <- createGovernedHeap nullFunPtr nullFunPtr nullFunPtr guvnor nullFunPtr+result <- evalDuktape (fromJust ctx) "while (true) {}"+-- Left "RangeError: execution timeout"+```+ [Aeson]: https://hackage.haskell.org/package/aeson [lens-aeson]: https://hackage.haskell.org/package/lens-aeson  ## Development -Use [stack] to build.  +Note: The duktape configure script invoked by Cabal/Stack requires python 2 with the PyYAML library installed. `pip install PyYAML` is one way to achieve this. +Use [stack] to build.+ ```bash $ stack build @@ -73,12 +100,12 @@  Please feel free to submit pull requests! -By participating in this project you agree to follow the [Contributor Code of Conduct](http://contributor-covenant.org/version/1/4/).+By participating in this project you agree to follow the [Contributor Code of Conduct](https://contributor-covenant.org/version/1/4/).  [The list of contributors is available on GitHub](https://github.com/myfreeweb/hs-duktape/graphs/contributors).  ## License  Licensed under the MIT license (see to the `LICENSE` file).  -Haskell bindings: Copyright (c) 2015-2016 Greg V <greg@unrelenting.technology>  +Haskell bindings: Copyright (c) 2015-2018 Greg V <greg@unrelenting.technology>   Duktape: Copyright (c) 2013-2016 by Duktape authors (see duktape/AUTHORS.rst)
Setup.hs view
@@ -1,2 +1,78 @@-import Distribution.Simple-main = defaultMain+{-# OPTIONS_GHC -fno-warn-missing-signatures #-}+{-# LANGUAGE UnicodeSyntax, LambdaCase #-}++import           Data.List                          (isPrefixOf)+import           Distribution.Simple+import           Distribution.Types.HookedBuildInfo+import           System.Directory+import           System.Exit                        (ExitCode (..))+import           System.Process                     (callProcess, readProcessWithExitCode)++main = defaultMainWithHooks simpleUserHooks { preBuild = buildDuktape }++outputDir = "dukconfig/dist"+scriptFile = "duktape/tools/configure.py"+scriptArgs =+  [ "--output-directory", outputDir+  , "--source-directory", "duktape/src-input"+  , "--config-metadata", "duktape/config"+  , "--option-file", "dukconfig/config.yaml"+  ]+repoSource = "duktape/src/duktape.c"+builtSource = "dukconfig/dist/duktape.c"++buildDuktape _ _ = do+  script ← doesFileExist scriptFile+  if script then do+    createDirectoryIfMissing True outputDir+    needBuild ← filesCurrent+    if needBuild then do+      runScript+      done+    else done+  else done+  where+  done = return emptyHookedBuildInfo+  filesCurrent = do+    builtExists ← doesFileExist builtSource+    if builtExists then do+        repoTime ← getModificationTime repoSource+        builtTime ← getModificationTime builtSource+        return $ repoTime > builtTime+    else return True+  runScript =+    findPython >>= \case+        Right python →+          callProcess python (scriptFile : scriptArgs)+        Left reason → do+            putStrLn "Couldn't find Python 2 with PyYAML, which is required to configure duktape."+            putStrLn reason++-- Duketape's configure script requires python2 with PyYAML installed.+-- Check candidates "python2, python" and return one that will work or reasons why+findPython ∷ IO (Either String FilePath)+findPython =+  tryPython "python2" >>= \case+      Left reason2 →+          tryPython "python" >>= \case+              Left reason →+                  return $ Left $ concat ["python2: ", reason2, "\npython: ", reason]+              found → return found+      found → return found+  where+  tryPython exe = findExecutable exe >>= \case+                      Nothing → return $ Left "Executable not found."+                      Just path → checkPython path+  checkPython path =+      readProcessWithExitCode path ["--version"] "" >>= \case+          (ExitSuccess, "", version) → checkPrefix version path+          (ExitSuccess, version, "") → checkPrefix version path+          (ExitFailure _, out, err) → return $ Left (out ++ err)+          _ → return $ Left "Execution failed."+  checkPrefix version path+              | "Python 2" `isPrefixOf` version = checkPyYAML path+              | otherwise = return $ Left version+  checkPyYAML path =+      readProcessWithExitCode path ["-c", "import yaml"] "" >>= \case+          (ExitSuccess, "", _) → return $ Right path+          _ → return $ Left "No PyYaml installed."
+ dukconfig/dist/duk_config.h view
@@ -0,0 +1,3094 @@+/*+ *  duk_config.h configuration header generated by genconfig.py.+ *+ *  Git commit: e3714f4c48935824ac6589137b66237217f6da7f+ *  Git describe: v0.1.5-24-ge3714f4-dirty+ *  Git branch: master+ *+ *  Supported platforms:+ *      - Mac OSX, iPhone, Darwin+ *      - Orbis+ *      - OpenBSD+ *      - Generic BSD+ *      - Atari ST TOS+ *      - AmigaOS+ *      - Durango (XboxOne)+ *      - Windows+ *      - Flashplayer (Crossbridge)+ *      - QNX+ *      - TI-Nspire+ *      - Emscripten+ *      - Linux+ *      - Solaris+ *      - AIX+ *      - HPUX+ *      - Generic POSIX+ *      - Cygwin+ *      - Generic UNIX+ *      - Generic fallback+ *+ *  Supported architectures:+ *      - x86+ *      - x64+ *      - x32+ *      - ARM 32-bit+ *      - ARM 64-bit+ *      - MIPS 32-bit+ *      - MIPS 64-bit+ *      - PowerPC 32-bit+ *      - PowerPC 64-bit+ *      - SPARC 32-bit+ *      - SPARC 64-bit+ *      - SuperH+ *      - Motorola 68k+ *      - Emscripten+ *      - Generic+ *+ *  Supported compilers:+ *      - Clang+ *      - GCC+ *      - MSVC+ *      - Emscripten+ *      - TinyC+ *      - VBCC+ *      - Bruce's C compiler+ *      - Generic+ *+ */++#if !defined(DUK_CONFIG_H_INCLUDED)+#define DUK_CONFIG_H_INCLUDED++/*+ *  Intermediate helper defines+ */++/* DLL build detection */+/* not configured for DLL build */+#undef DUK_F_DLL_BUILD++/* Apple OSX, iOS */+#if defined(__APPLE__)+#define DUK_F_APPLE+#endif++/* FreeBSD */+#if defined(__FreeBSD__) || defined(__FreeBSD)+#define DUK_F_FREEBSD+#endif++/* Orbis (PS4) variant */+#if defined(DUK_F_FREEBSD) && defined(__ORBIS__)+#define DUK_F_ORBIS+#endif++/* OpenBSD */+#if defined(__OpenBSD__) || defined(__OpenBSD)+#define DUK_F_OPENBSD+#endif++/* NetBSD */+#if defined(__NetBSD__) || defined(__NetBSD)+#define DUK_F_NETBSD+#endif++/* BSD variant */+#if defined(DUK_F_FREEBSD) || defined(DUK_F_NETBSD) || defined(DUK_F_OPENBSD) || \+    defined(__bsdi__) || defined(__DragonFly__)+#define DUK_F_BSD+#endif++/* Atari ST TOS.  __TOS__ defined by PureC.  No platform define in VBCC+ * apparently, so to use with VBCC user must define __TOS__ manually.+  */+#if defined(__TOS__)+#define DUK_F_TOS+#endif++/* Motorola 68K.  Not defined by VBCC, so user must define one of these+ * manually when using VBCC.+ */+#if defined(__m68k__) || defined(M68000) || defined(__MC68K__)+#define DUK_F_M68K+#endif++/* AmigaOS.  Neither AMIGA nor __amigaos__ is defined on VBCC, so user must+ * define 'AMIGA' manually when using VBCC.+ */+#if defined(AMIGA) || defined(__amigaos__)+#define DUK_F_AMIGAOS+#endif++/* PowerPC */+#if defined(__powerpc) || defined(__powerpc__) || defined(__PPC__)+#define DUK_F_PPC+#if defined(__PPC64__) || defined(__LP64__) || defined(_LP64)+#define DUK_F_PPC64+#else+#define DUK_F_PPC32+#endif+#endif++/* Durango (Xbox One) */+#if defined(_DURANGO) || defined(_XBOX_ONE)+#define DUK_F_DURANGO+#endif++/* Windows, both 32-bit and 64-bit */+#if defined(_WIN32) || defined(WIN32) || defined(_WIN64) || defined(WIN64) || \+    defined(__WIN32__) || defined(__TOS_WIN__) || defined(__WINDOWS__)+#define DUK_F_WINDOWS+#if defined(_WIN64) || defined(WIN64)+#define DUK_F_WIN64+#else+#define DUK_F_WIN32+#endif+#endif++/* Flash player (e.g. Crossbridge) */+#if defined(__FLASHPLAYER__)+#define DUK_F_FLASHPLAYER+#endif++/* QNX */+#if defined(__QNX__)+#define DUK_F_QNX+#endif++/* TI-Nspire (using Ndless) */+#if defined(_TINSPIRE)+#define DUK_F_TINSPIRE+#endif++/* Emscripten (provided explicitly by user), improve if possible */+#if defined(EMSCRIPTEN)+#define DUK_F_EMSCRIPTEN+#endif++/* BCC (Bruce's C compiler): this is a "torture target" for compilation */+#if defined(__BCC__) || defined(__BCC_VERSION__)+#define DUK_F_BCC+#endif++/* Linux */+#if defined(__linux) || defined(__linux__) || defined(linux)+#define DUK_F_LINUX+#endif++/* illumos / Solaris */+#if defined(__sun) && defined(__SVR4)+#define DUK_F_SUN+#if defined(__SUNPRO_C) && (__SUNPRO_C < 0x550)+#define DUK_F_OLD_SOLARIS+/* Defines _ILP32 / _LP64 required by DUK_F_X86/DUK_F_X64.  Platforms+ * are processed before architectures, so this happens before the+ * DUK_F_X86/DUK_F_X64 detection is emitted.+ */+#include <sys/isa_defs.h>+#endif+#endif++/* AIX */+#if defined(_AIX)+/* defined(__xlc__) || defined(__IBMC__): works but too wide */+#define DUK_F_AIX+#endif++/* HPUX */+#if defined(__hpux)+#define DUK_F_HPUX+#if defined(__ia64)+#define DUK_F_HPUX_ITANIUM+#endif+#endif++/* POSIX */+#if defined(__posix)+#define DUK_F_POSIX+#endif++/* Cygwin */+#if defined(__CYGWIN__)+#define DUK_F_CYGWIN+#endif++/* Generic Unix (includes Cygwin) */+#if defined(__unix) || defined(__unix__) || defined(unix) || \+    defined(DUK_F_LINUX) || defined(DUK_F_BSD)+#define DUK_F_UNIX+#endif++/* Intel x86 (32-bit), x64 (64-bit) or x32 (64-bit but 32-bit pointers),+ * define only one of DUK_F_X86, DUK_F_X64, DUK_F_X32.+ * https://sites.google.com/site/x32abi/+ *+ * With DUK_F_OLD_SOLARIS the <sys/isa_defs.h> header must be included+ * before this.+ */+#if defined(__amd64__) || defined(__amd64) || \+    defined(__x86_64__) || defined(__x86_64) || \+    defined(_M_X64) || defined(_M_AMD64)+#if defined(__ILP32__) || defined(_ILP32)+#define DUK_F_X32+#else+#define DUK_F_X64+#endif+#elif defined(i386) || defined(__i386) || defined(__i386__) || \+      defined(__i486__) || defined(__i586__) || defined(__i686__) || \+      defined(__IA32__) || defined(_M_IX86) || defined(__X86__) || \+      defined(_X86_) || defined(__THW_INTEL__) || defined(__I86__)+#if defined(__LP64__) || defined(_LP64)+/* This should not really happen, but would indicate x64. */+#define DUK_F_X64+#else+#define DUK_F_X86+#endif+#endif++/* ARM */+#if defined(__arm__) || defined(__thumb__) || defined(_ARM) || defined(_M_ARM) || defined(__aarch64__)+#define DUK_F_ARM+#if defined(__LP64__) || defined(_LP64) || defined(__arm64) || defined(__arm64__) || defined(__aarch64__)+#define DUK_F_ARM64+#else+#define DUK_F_ARM32+#endif+#endif++/* MIPS.  Related defines: __MIPSEB__, __MIPSEL__, __mips_isa_rev, __LP64__ */+#if defined(__mips__) || defined(mips) || defined(_MIPS_ISA) || \+    defined(_R3000) || defined(_R4000) || defined(_R5900) || \+    defined(_MIPS_ISA_MIPS1) || defined(_MIPS_ISA_MIPS2) || \+    defined(_MIPS_ISA_MIPS3) || defined(_MIPS_ISA_MIPS4) || \+    defined(__mips) || defined(__MIPS__)+#define DUK_F_MIPS+#if defined(__LP64__) || defined(_LP64) || defined(__mips64) || \+    defined(__mips64__) || defined(__mips_n64)+#define DUK_F_MIPS64+#else+#define DUK_F_MIPS32+#endif+#endif++/* SPARC */+#if defined(sparc) || defined(__sparc) || defined(__sparc__)+#define DUK_F_SPARC+#if defined(__LP64__) || defined(_LP64)+#define DUK_F_SPARC64+#else+#define DUK_F_SPARC32+#endif+#endif++/* SuperH */+#if defined(__sh__) || \+    defined(__sh1__) || defined(__SH1__) || \+    defined(__sh2__) || defined(__SH2__) || \+    defined(__sh3__) || defined(__SH3__) || \+    defined(__sh4__) || defined(__SH4__) || \+    defined(__sh5__) || defined(__SH5__)+#define DUK_F_SUPERH+#endif++/* Clang */+#if defined(__clang__)+#define DUK_F_CLANG+#endif++/* C++ */+#undef DUK_F_CPP+#if defined(__cplusplus)+#define DUK_F_CPP+#endif++/* C99 or above */+#undef DUK_F_C99+#if defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L)+#define DUK_F_C99+#endif++/* C++11 or above */+#undef DUK_F_CPP11+#if defined(__cplusplus) && (__cplusplus >= 201103L)+#define DUK_F_CPP11+#endif++/* GCC.  Clang also defines __GNUC__ so don't detect GCC if using Clang. */+#if defined(__GNUC__) && !defined(__clang__) && !defined(DUK_F_CLANG)+#define DUK_F_GCC+#if defined(__GNUC__) && defined(__GNUC_MINOR__) && defined(__GNUC_PATCHLEVEL__)+/* Convenience, e.g. gcc 4.5.1 == 40501; http://stackoverflow.com/questions/6031819/emulating-gccs-builtin-unreachable */+#define DUK_F_GCC_VERSION  (__GNUC__ * 10000L + __GNUC_MINOR__ * 100L + __GNUC_PATCHLEVEL__)+#else+#error cannot figure out gcc version+#endif+#endif++/* MinGW.  Also GCC flags (DUK_F_GCC) are enabled now. */+#if defined(__MINGW32__) || defined(__MINGW64__)+#define DUK_F_MINGW+#endif++/* MSVC */+#if defined(_MSC_VER)+/* MSVC preprocessor defines: http://msdn.microsoft.com/en-us/library/b0084kay.aspx+ * _MSC_FULL_VER includes the build number, but it has at least two formats, see e.g.+ * BOOST_MSVC_FULL_VER in http://www.boost.org/doc/libs/1_52_0/boost/config/compiler/visualc.hpp+ */+#define DUK_F_MSVC+#if defined(_MSC_FULL_VER)+#if (_MSC_FULL_VER > 100000000)+#define DUK_F_MSVC_FULL_VER _MSC_FULL_VER+#else+#define DUK_F_MSCV_FULL_VER (_MSC_FULL_VER * 10)+#endif+#endif+#endif  /* _MSC_VER */++/* TinyC */+#if defined(__TINYC__)+/* http://bellard.org/tcc/tcc-doc.html#SEC9 */+#define DUK_F_TINYC+#endif++/* VBCC */+#if defined(__VBCC__)+#define DUK_F_VBCC+#endif++#if defined(ANDROID) || defined(__ANDROID__)+#define DUK_F_ANDROID+#endif++/* Atari Mint */+#if defined(__MINT__)+#define DUK_F_MINT+#endif++/*+ *  Platform autodetection+ */++/* Workaround for older C++ compilers before including <inttypes.h>,+ * see e.g.: https://sourceware.org/bugzilla/show_bug.cgi?id=15366+ */+#if defined(__cplusplus) && !defined(__STDC_LIMIT_MACROS)+#define __STDC_LIMIT_MACROS+#endif+#if defined(__cplusplus) && !defined(__STDC_CONSTANT_MACROS)+#define __STDC_CONSTANT_MACROS+#endif++#if defined(DUK_F_APPLE)+/* --- Mac OSX, iPhone, Darwin --- */+#define DUK_USE_DATE_NOW_GETTIMEOFDAY+#define DUK_USE_DATE_TZO_GMTIME_R+#define DUK_USE_DATE_PRS_STRPTIME+#define DUK_USE_DATE_FMT_STRFTIME+#include <TargetConditionals.h>+#include <architecture/byte_order.h>+#include <sys/param.h>+#include <sys/time.h>+#include <time.h>++/* http://stackoverflow.com/questions/5919996/how-to-detect-reliably-mac-os-x-ios-linux-windows-in-c-preprocessor */+#if TARGET_IPHONE_SIMULATOR+#define DUK_USE_OS_STRING "iphone-sim"+#elif TARGET_OS_IPHONE+#define DUK_USE_OS_STRING "iphone"+#elif TARGET_OS_MAC+#define DUK_USE_OS_STRING "osx"+#else+#define DUK_USE_OS_STRING "osx-unknown"+#endif++/* Use _setjmp() on Apple by default, see GH-55. */+#define DUK_JMPBUF_TYPE       jmp_buf+#define DUK_SETJMP(jb)        _setjmp((jb))+#define DUK_LONGJMP(jb)       _longjmp((jb), 1)+#elif defined(DUK_F_ORBIS)+/* --- Orbis --- */+/* Orbis = PS4 */+#define DUK_USE_DATE_NOW_GETTIMEOFDAY+#define DUK_USE_DATE_TZO_GMTIME_S+/* no parsing (not an error) */+#define DUK_USE_DATE_FMT_STRFTIME+#include <sys/types.h>+#include <machine/endian.h>+#include <sys/param.h>+#include <sys/time.h>+#include <time.h>++#define DUK_USE_OS_STRING  "orbis"+#elif defined(DUK_F_OPENBSD)+/* --- OpenBSD --- */+/* http://www.monkey.org/openbsd/archive/ports/0401/msg00089.html */+#define DUK_USE_DATE_NOW_GETTIMEOFDAY+#define DUK_USE_DATE_TZO_GMTIME_R+#define DUK_USE_DATE_PRS_STRPTIME+#define DUK_USE_DATE_FMT_STRFTIME+#include <sys/types.h>+#include <sys/endian.h>+#include <sys/param.h>+#include <sys/time.h>+#include <time.h>++#define DUK_USE_OS_STRING  "openbsd"+#elif defined(DUK_F_BSD)+/* --- Generic BSD --- */+#define DUK_USE_DATE_NOW_GETTIMEOFDAY+#define DUK_USE_DATE_TZO_GMTIME_R+#define DUK_USE_DATE_PRS_STRPTIME+#define DUK_USE_DATE_FMT_STRFTIME+#include <sys/types.h>+#include <sys/endian.h>+#include <sys/param.h>+#include <sys/time.h>+#include <time.h>++#define DUK_USE_OS_STRING  "bsd"+#elif defined(DUK_F_TOS)+/* --- Atari ST TOS --- */+#define DUK_USE_DATE_NOW_TIME+#define DUK_USE_DATE_TZO_GMTIME+/* no parsing (not an error) */+#define DUK_USE_DATE_FMT_STRFTIME+#include <time.h>++#define DUK_USE_OS_STRING  "tos"++/* TOS on M68K is always big endian. */+#if !defined(DUK_USE_BYTEORDER) && defined(DUK_F_M68K)+#define DUK_USE_BYTEORDER 3+#endif+#elif defined(DUK_F_AMIGAOS)+/* --- AmigaOS --- */+#if defined(DUK_F_M68K)+/* AmigaOS on M68k */+#define DUK_USE_DATE_NOW_TIME+#define DUK_USE_DATE_TZO_GMTIME+/* no parsing (not an error) */+#define DUK_USE_DATE_FMT_STRFTIME+#include <time.h>+#elif defined(DUK_F_PPC)+#define DUK_USE_DATE_NOW_GETTIMEOFDAY+#define DUK_USE_DATE_TZO_GMTIME_R+#define DUK_USE_DATE_PRS_STRPTIME+#define DUK_USE_DATE_FMT_STRFTIME+#include <time.h>+#if !defined(UINTPTR_MAX)+#define UINTPTR_MAX UINT_MAX+#endif+#else+#error AmigaOS but not M68K/PPC, not supported now+#endif++#define DUK_USE_OS_STRING "amigaos"++/* AmigaOS on M68K or PPC is always big endian. */+#if !defined(DUK_USE_BYTEORDER) && (defined(DUK_F_M68K) || defined(DUK_F_PPC))+#define DUK_USE_BYTEORDER 3+#endif+#elif defined(DUK_F_DURANGO)+/* --- Durango (XboxOne) --- */+/* Durango = XboxOne+ * Configuration is nearly identical to Windows, except for+ * DUK_USE_DATE_TZO_WINDOWS.+ */++/* Initial fix: disable secure CRT related warnings when compiling Duktape+ * itself (must be defined before including Windows headers).  Don't define+ * for user code including duktape.h.+ */+#if defined(DUK_COMPILING_DUKTAPE) && !defined(_CRT_SECURE_NO_WARNINGS)+#define _CRT_SECURE_NO_WARNINGS+#endif++/* MSVC does not have sys/param.h */+#define DUK_USE_DATE_NOW_WINDOWS+#define DUK_USE_DATE_TZO_WINDOWS_NO_DST+/* Note: PRS and FMT are intentionally left undefined for now.  This means+ * there is no platform specific date parsing/formatting but there is still+ * the ISO 8601 standard format.+ */+#if defined(DUK_COMPILING_DUKTAPE)+/* Only include when compiling Duktape to avoid polluting application build+ * with a lot of unnecessary defines.+ */+#include <windows.h>+#endif++#define DUK_USE_OS_STRING "durango"++#if !defined(DUK_USE_BYTEORDER)+#define DUK_USE_BYTEORDER 1+#endif+#elif defined(DUK_F_WINDOWS)+/* --- Windows --- */+/* Windows version can't obviously be determined at compile time,+ * but _WIN32_WINNT indicates the minimum version targeted:+ * - https://msdn.microsoft.com/en-us/library/6sehtctf.aspx+ */++/* Initial fix: disable secure CRT related warnings when compiling Duktape+ * itself (must be defined before including Windows headers).  Don't define+ * for user code including duktape.h.+ */+#if defined(DUK_COMPILING_DUKTAPE) && !defined(_CRT_SECURE_NO_WARNINGS)+#define _CRT_SECURE_NO_WARNINGS+#endif++/* Windows 32-bit and 64-bit are currently the same. */+/* MSVC does not have sys/param.h */++#if defined(DUK_COMPILING_DUKTAPE)+/* Only include when compiling Duktape to avoid polluting application build+ * with a lot of unnecessary defines.+ */+#include <windows.h>+#endif++/* GetSystemTimePreciseAsFileTime() available from Windows 8:+ * https://msdn.microsoft.com/en-us/library/windows/desktop/hh706895(v=vs.85).aspx+ */+#if defined(DUK_USE_DATE_NOW_WINDOWS_SUBMS) || defined(DUK_USE_DATE_NOW_WINDOWS)+/* User forced provider. */+#else+#if defined(_WIN32_WINNT) && (_WIN32_WINNT >= 0x0602)+#define DUK_USE_DATE_NOW_WINDOWS_SUBMS+#else+#define DUK_USE_DATE_NOW_WINDOWS+#endif+#endif++#define DUK_USE_DATE_TZO_WINDOWS++/* Note: PRS and FMT are intentionally left undefined for now.  This means+ * there is no platform specific date parsing/formatting but there is still+ * the ISO 8601 standard format.+ */++/* QueryPerformanceCounter() may go backwards in Windows XP, so enable for+ * Vista and later: https://msdn.microsoft.com/en-us/library/windows/desktop/dn553408(v=vs.85).aspx#qpc_support_in_windows_versions+ */+#if !defined(DUK_USE_GET_MONOTONIC_TIME_WINDOWS_QPC) && \+    defined(_WIN32_WINNT) && (_WIN32_WINNT >= 0x0600)+#define DUK_USE_GET_MONOTONIC_TIME_WINDOWS_QPC+#endif++#define DUK_USE_OS_STRING "windows"++/* On Windows, assume we're little endian.  Even Itanium which has a+ * configurable endianness runs little endian in Windows.+ */+#if !defined(DUK_USE_BYTEORDER)+#define DUK_USE_BYTEORDER 1+#endif+#elif defined(DUK_F_FLASHPLAYER)+/* --- Flashplayer (Crossbridge) --- */+#define DUK_USE_DATE_NOW_GETTIMEOFDAY+#define DUK_USE_DATE_TZO_GMTIME_R+#define DUK_USE_DATE_PRS_STRPTIME+#define DUK_USE_DATE_FMT_STRFTIME+#include <endian.h>+#include <sys/param.h>+#include <sys/time.h>+#include <time.h>++#define DUK_USE_OS_STRING "flashplayer"++#if !defined(DUK_USE_BYTEORDER) && defined(DUK_F_FLASHPLAYER)+#define DUK_USE_BYTEORDER 1+#endif+#elif defined(DUK_F_QNX)+/* --- QNX --- */+#if defined(DUK_F_QNX) && defined(DUK_COMPILING_DUKTAPE)+/* See: /opt/qnx650/target/qnx6/usr/include/sys/platform.h */+#define _XOPEN_SOURCE    600+#define _POSIX_C_SOURCE  200112L+#endif++#define DUK_USE_DATE_NOW_GETTIMEOFDAY+#define DUK_USE_DATE_TZO_GMTIME_R+#define DUK_USE_DATE_PRS_STRPTIME+#define DUK_USE_DATE_FMT_STRFTIME+#include <sys/types.h>+#include <sys/param.h>+#include <sys/time.h>+#include <time.h>++#define DUK_USE_OS_STRING "qnx"+#elif defined(DUK_F_TINSPIRE)+/* --- TI-Nspire --- */+#if defined(DUK_COMPILING_DUKTAPE) && !defined(_XOPEN_SOURCE)+#define _XOPEN_SOURCE    /* e.g. strptime */+#endif++#define DUK_USE_DATE_NOW_GETTIMEOFDAY+#define DUK_USE_DATE_TZO_GMTIME_R+#define DUK_USE_DATE_PRS_STRPTIME+#define DUK_USE_DATE_FMT_STRFTIME+#include <sys/types.h>+#include <sys/param.h>+#include <sys/time.h>+#include <time.h>++#define DUK_USE_OS_STRING "tinspire"+#elif defined(DUK_F_EMSCRIPTEN)+/* --- Emscripten --- */+#if defined(DUK_COMPILING_DUKTAPE)+#if !defined(_POSIX_C_SOURCE)+#define _POSIX_C_SOURCE  200809L+#endif+#if !defined(_GNU_SOURCE)+#define _GNU_SOURCE      /* e.g. getdate_r */+#endif+#if !defined(_XOPEN_SOURCE)+#define _XOPEN_SOURCE    /* e.g. strptime */+#endif+#endif  /* DUK_COMPILING_DUKTAPE */++#include <sys/types.h>+#if defined(DUK_F_BCC)+/* no endian.h */+#else+#include <endian.h>+#endif  /* DUK_F_BCC */+#include <sys/param.h>+#include <sys/time.h>+#include <time.h>+#include <stdint.h>++#define DUK_USE_DATE_NOW_GETTIMEOFDAY+#define DUK_USE_DATE_TZO_GMTIME_R+#define DUK_USE_DATE_PRS_STRPTIME+#define DUK_USE_DATE_FMT_STRFTIME++#define DUK_USE_OS_STRING "emscripten"+#elif defined(DUK_F_LINUX)+/* --- Linux --- */+#if defined(DUK_COMPILING_DUKTAPE)+#if !defined(_POSIX_C_SOURCE)+#define _POSIX_C_SOURCE  200809L+#endif+#if !defined(_GNU_SOURCE)+#define _GNU_SOURCE      /* e.g. getdate_r */+#endif+#if !defined(_XOPEN_SOURCE)+#define _XOPEN_SOURCE    /* e.g. strptime */+#endif+#endif  /* DUK_COMPILING_DUKTAPE */++#include <sys/types.h>+#if defined(DUK_F_BCC)+/* no endian.h or stdint.h */+#else+#include <endian.h>+#include <stdint.h>+#endif  /* DUK_F_BCC */+#include <sys/param.h>+#include <sys/time.h>+#include <time.h>++#define DUK_USE_DATE_NOW_GETTIMEOFDAY+#define DUK_USE_DATE_TZO_GMTIME_R+#define DUK_USE_DATE_PRS_STRPTIME+#define DUK_USE_DATE_FMT_STRFTIME++#if 0  /* XXX: safe condition? */+#define DUK_USE_GET_MONOTONIC_TIME_CLOCK_GETTIME+#endif++#define DUK_USE_OS_STRING "linux"+#elif defined(DUK_F_SUN)+/* --- Solaris --- */+#define DUK_USE_DATE_NOW_GETTIMEOFDAY+#define DUK_USE_DATE_TZO_GMTIME_R+#define DUK_USE_DATE_PRS_STRPTIME+#define DUK_USE_DATE_FMT_STRFTIME++#include <sys/types.h>+#if defined(DUK_F_OLD_SOLARIS)+/* Old Solaris with no endian.h, stdint.h */+#define DUK_F_NO_STDINT_H+#if !defined(DUK_USE_BYTEORDER)+#define DUK_USE_BYTEORDER 3+#endif+#else  /* DUK_F_OLD_SOLARIS */+#include <ast/endian.h>+#endif  /* DUK_F_OLD_SOLARIS */++#include <sys/param.h>+#include <sys/time.h>+#include <time.h>++#define DUK_USE_OS_STRING "solaris"+#elif defined(DUK_F_AIX)+/* --- AIX --- */+#if !defined(DUK_USE_BYTEORDER)+#define DUK_USE_BYTEORDER 3+#endif+#define DUK_USE_DATE_NOW_GETTIMEOFDAY+#define DUK_USE_DATE_TZO_GMTIME_R+#define DUK_USE_DATE_PRS_STRPTIME+#define DUK_USE_DATE_FMT_STRFTIME+#include <sys/param.h>+#include <sys/time.h>+#include <time.h>++#define DUK_USE_OS_STRING "aix"+#elif defined(DUK_F_HPUX)+/* --- HPUX --- */+#define DUK_F_NO_STDINT_H+#if !defined(DUK_USE_BYTEORDER)+#define DUK_USE_BYTEORDER 3+#endif+#define DUK_USE_DATE_NOW_GETTIMEOFDAY+#define DUK_USE_DATE_TZO_GMTIME_R+#define DUK_USE_DATE_PRS_STRPTIME+#define DUK_USE_DATE_FMT_STRFTIME+#include <sys/param.h>+#include <sys/time.h>+#include <time.h>++#define DUK_USE_OS_STRING "hpux"+#elif defined(DUK_F_POSIX)+/* --- Generic POSIX --- */+#define DUK_USE_DATE_NOW_GETTIMEOFDAY+#define DUK_USE_DATE_TZO_GMTIME_R+#define DUK_USE_DATE_PRS_STRPTIME+#define DUK_USE_DATE_FMT_STRFTIME+#include <sys/types.h>+#include <endian.h>+#include <sys/param.h>+#include <sys/time.h>+#include <time.h>++#define DUK_USE_OS_STRING "posix"+#elif defined(DUK_F_CYGWIN)+/* --- Cygwin --- */+/* don't use strptime() for now */+#define DUK_USE_DATE_NOW_GETTIMEOFDAY+#define DUK_USE_DATE_TZO_GMTIME_R+#define DUK_USE_DATE_FMT_STRFTIME+#include <sys/types.h>+#include <endian.h>+#include <sys/param.h>+#include <sys/time.h>+#include <time.h>++#define DUK_JMPBUF_TYPE       jmp_buf+#define DUK_SETJMP(jb)        _setjmp((jb))+#define DUK_LONGJMP(jb)       _longjmp((jb), 1)++#define DUK_USE_OS_STRING "windows"+#elif defined(DUK_F_UNIX)+/* --- Generic UNIX --- */+#define DUK_USE_DATE_NOW_GETTIMEOFDAY+#define DUK_USE_DATE_TZO_GMTIME_R+#define DUK_USE_DATE_PRS_STRPTIME+#define DUK_USE_DATE_FMT_STRFTIME+#include <time.h>+#include <sys/time.h>+#define DUK_USE_OS_STRING "unknown"+#else+/* --- Generic fallback --- */+/* The most portable current time provider is time(), but it only has a+ * one second resolution.+ */+#define DUK_USE_DATE_NOW_TIME++/* The most portable way to figure out local time offset is gmtime(),+ * but it's not thread safe so use with caution.+ */+#define DUK_USE_DATE_TZO_GMTIME++/* Avoid custom date parsing and formatting for portability. */+#undef DUK_USE_DATE_PRS_STRPTIME+#undef DUK_USE_DATE_FMT_STRFTIME++/* Rely on C89 headers only; time.h must be here. */+#include <time.h>++#define DUK_USE_OS_STRING "unknown"+#endif  /* autodetect platform */++/* Shared includes: C89 */+#include <stdio.h>+#include <stdlib.h>+#include <string.h>+#include <stdarg.h>  /* varargs */+#include <setjmp.h>+#include <stddef.h>  /* e.g. ptrdiff_t */+#include <math.h>+#include <limits.h>++/* date.h is omitted, and included per platform */++/* Shared includes: stdint.h is C99 */+#if defined(DUK_F_NO_STDINT_H)+/* stdint.h not available */+#else+/* Technically C99 (C++11) but found in many systems.  On some systems+ * __STDC_LIMIT_MACROS and __STDC_CONSTANT_MACROS must be defined before+ * including stdint.h (see above).+ */+#include <stdint.h>+#endif++/* <exception> is only included if needed, based on DUK_USE_xxx flags. */++/*+ *  Architecture autodetection+ */++#if defined(DUK_F_X86)+/* --- x86 --- */+#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+#define DUK_F_PACKED_TVAL_PROVIDED+#elif defined(DUK_F_X64)+/* --- x64 --- */+#define DUK_USE_ARCH_STRING "x64"+#if !defined(DUK_USE_BYTEORDER)+#define DUK_USE_BYTEORDER 1+#endif+#undef DUK_USE_PACKED_TVAL+#define DUK_F_PACKED_TVAL_PROVIDED+#elif defined(DUK_F_X32)+/* --- x32 --- */+#define DUK_USE_ARCH_STRING "x32"+#if !defined(DUK_USE_BYTEORDER)+#define DUK_USE_BYTEORDER 1+#endif+#define DUK_USE_PACKED_TVAL+#define DUK_F_PACKED_TVAL_PROVIDED+#elif defined(DUK_F_ARM32)+/* --- ARM 32-bit --- */+#define DUK_USE_ARCH_STRING "arm32"+/* Byte order varies, so rely on autodetect. */+#define DUK_USE_PACKED_TVAL+#define DUK_F_PACKED_TVAL_PROVIDED+#elif defined(DUK_F_ARM64)+/* --- ARM 64-bit --- */+#define DUK_USE_ARCH_STRING "arm64"+/* Byte order varies, so rely on autodetect. */+#undef DUK_USE_PACKED_TVAL+#define DUK_F_PACKED_TVAL_PROVIDED+#elif defined(DUK_F_MIPS32)+/* --- MIPS 32-bit --- */+#define DUK_USE_ARCH_STRING "mips32"+/* MIPS byte order varies so rely on autodetection. */+#define DUK_USE_PACKED_TVAL+#define DUK_F_PACKED_TVAL_PROVIDED+#elif defined(DUK_F_MIPS64)+/* --- MIPS 64-bit --- */+#define DUK_USE_ARCH_STRING "mips64"+/* MIPS byte order varies so rely on autodetection. */+#undef DUK_USE_PACKED_TVAL+#define DUK_F_PACKED_TVAL_PROVIDED+#elif defined(DUK_F_PPC32)+/* --- PowerPC 32-bit --- */+#define DUK_USE_ARCH_STRING "ppc32"+#if !defined(DUK_USE_BYTEORDER)+#define DUK_USE_BYTEORDER 3+#endif+#define DUK_USE_PACKED_TVAL+#define DUK_F_PACKED_TVAL_PROVIDED+#elif defined(DUK_F_PPC64)+/* --- PowerPC 64-bit --- */+#define DUK_USE_ARCH_STRING "ppc64"+#if !defined(DUK_USE_BYTEORDER)+#define DUK_USE_BYTEORDER 3+#endif+#undef DUK_USE_PACKED_TVAL+#define DUK_F_PACKED_TVAL_PROVIDED+#elif defined(DUK_F_SPARC32)+/* --- SPARC 32-bit --- */+#define DUK_USE_ARCH_STRING "sparc32"+/* SPARC byte order varies so rely on autodetection. */+#define DUK_USE_PACKED_TVAL+#define DUK_F_PACKED_TVAL_PROVIDED+#elif defined(DUK_F_SPARC64)+/* --- SPARC 64-bit --- */+#define DUK_USE_ARCH_STRING "sparc64"+/* SPARC byte order varies so rely on autodetection. */+#undef DUK_USE_PACKED_TVAL+#define DUK_F_PACKED_TVAL_PROVIDED+#elif defined(DUK_F_SUPERH)+/* --- SuperH --- */+#define DUK_USE_ARCH_STRING "sh"+/* Byte order varies, rely on autodetection. */+#define DUK_USE_PACKED_TVAL+#define DUK_F_PACKED_TVAL_PROVIDED+#elif defined(DUK_F_M68K)+/* --- Motorola 68k --- */+#define DUK_USE_ARCH_STRING "m68k"+#if !defined(DUK_USE_BYTEORDER)+#define DUK_USE_BYTEORDER 3+#endif+#define DUK_USE_PACKED_TVAL+#define DUK_F_PACKED_TVAL_PROVIDED+#elif defined(DUK_F_EMSCRIPTEN)+/* --- Emscripten --- */+#define DUK_USE_ARCH_STRING "emscripten"+#if !defined(DUK_USE_BYTEORDER)+#define DUK_USE_BYTEORDER 1+#endif+#undef DUK_USE_PACKED_TVAL+#define DUK_F_PACKED_TVAL_PROVIDED+#else+/* --- Generic --- */+/* These are necessary wild guesses. */+#define DUK_USE_ARCH_STRING "generic"+/* Rely on autodetection for byte order, alignment, and packed tval. */+#endif  /* autodetect architecture */++/*+ *  Compiler autodetection+ */++#if defined(DUK_F_CLANG)+/* --- Clang --- */+#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)+/* MSVC dllexport/dllimport: appropriate __declspec depends on whether we're+ * compiling Duktape or the application.+ */+#if defined(DUK_COMPILING_DUKTAPE)+#define DUK_EXTERNAL_DECL  extern __declspec(dllexport)+#define DUK_EXTERNAL       __declspec(dllexport)+#else+#define DUK_EXTERNAL_DECL  extern __declspec(dllimport)+#define DUK_EXTERNAL       should_not_happen+#endif+#if defined(DUK_SINGLE_FILE)+#define DUK_INTERNAL_DECL  static+#define DUK_INTERNAL       static+#else+#define DUK_INTERNAL_DECL  extern+#define DUK_INTERNAL       /*empty*/+#endif+#define DUK_LOCAL_DECL     static+#define DUK_LOCAL          static+#else+#define DUK_EXTERNAL_DECL  __attribute__ ((visibility("default"))) extern+#define DUK_EXTERNAL       __attribute__ ((visibility("default")))+#if defined(DUK_SINGLE_FILE)+#if (defined(DUK_F_GCC_VERSION) && DUK_F_GCC_VERSION >= 30101) || defined(DUK_F_CLANG)+/* Minimize warnings for unused internal functions with GCC >= 3.1.1 and+ * Clang.  Based on documentation it should suffice to have the attribute+ * in the declaration only, but in practice some warnings are generated unless+ * the attribute is also applied to the definition.+ */+#define DUK_INTERNAL_DECL  static __attribute__ ((unused))+#define DUK_INTERNAL       static __attribute__ ((unused))+#else+#define DUK_INTERNAL_DECL  static+#define DUK_INTERNAL       static+#endif+#else+#if (defined(DUK_F_GCC_VERSION) && DUK_F_GCC_VERSION >= 30101) || defined(DUK_F_CLANG)+#define DUK_INTERNAL_DECL  __attribute__ ((visibility("hidden"))) __attribute__ ((unused)) extern+#define DUK_INTERNAL       __attribute__ ((visibility("hidden"))) __attribute__ ((unused))+#else+#define DUK_INTERNAL_DECL  __attribute__ ((visibility("hidden"))) extern+#define DUK_INTERNAL       __attribute__ ((visibility("hidden")))+#endif+#endif+#define DUK_LOCAL_DECL     static+#define DUK_LOCAL          static+#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++#undef DUK_USE_GCC_PRAGMAS+#define DUK_USE_PACK_CLANG_ATTR+#elif defined(DUK_F_GCC)+/* --- GCC --- */+#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)+/* since gcc-2.5 */+#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)+/* MSVC dllexport/dllimport: appropriate __declspec depends on whether we're+ * compiling Duktape or the application.+ */+#if defined(DUK_COMPILING_DUKTAPE)+#define DUK_EXTERNAL_DECL  extern __declspec(dllexport)+#define DUK_EXTERNAL       __declspec(dllexport)+#else+#define DUK_EXTERNAL_DECL  extern __declspec(dllimport)+#define DUK_EXTERNAL       should_not_happen+#endif+#if defined(DUK_SINGLE_FILE)+#define DUK_INTERNAL_DECL  static+#define DUK_INTERNAL       static+#else+#define DUK_INTERNAL_DECL  extern+#define DUK_INTERNAL       /*empty*/+#endif+#define DUK_LOCAL_DECL     static+#define DUK_LOCAL          static+#elif defined(DUK_F_GCC_VERSION) && (DUK_F_GCC_VERSION >= 40000)+#define DUK_EXTERNAL_DECL  __attribute__ ((visibility("default"))) extern+#define DUK_EXTERNAL       __attribute__ ((visibility("default")))+#if defined(DUK_SINGLE_FILE)+#if (defined(DUK_F_GCC_VERSION) && DUK_F_GCC_VERSION >= 30101) || defined(DUK_F_CLANG)+/* Minimize warnings for unused internal functions with GCC >= 3.1.1 and+ * Clang.  Based on documentation it should suffice to have the attribute+ * in the declaration only, but in practice some warnings are generated unless+ * the attribute is also applied to the definition.+ */+#define DUK_INTERNAL_DECL  static __attribute__ ((unused))+#define DUK_INTERNAL       static __attribute__ ((unused))+#else+#define DUK_INTERNAL_DECL  static+#define DUK_INTERNAL       static+#endif+#else+#if (defined(DUK_F_GCC_VERSION) && DUK_F_GCC_VERSION >= 30101) || defined(DUK_F_CLANG)+#define DUK_INTERNAL_DECL  __attribute__ ((visibility("hidden"))) __attribute__ ((unused)) extern+#define DUK_INTERNAL       __attribute__ ((visibility("hidden"))) __attribute__ ((unused))+#else+#define DUK_INTERNAL_DECL  __attribute__ ((visibility("hidden"))) extern+#define DUK_INTERNAL       __attribute__ ((visibility("hidden")))+#endif+#endif+#define DUK_LOCAL_DECL     static+#define DUK_LOCAL          static+#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++#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+#elif defined(DUK_F_MSVC)+/* --- MSVC --- */+/* 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)+/* MSVC dllexport/dllimport: appropriate __declspec depends on whether we're+ * compiling Duktape or the application.+ */+#if defined(DUK_COMPILING_DUKTAPE)+#define DUK_EXTERNAL_DECL  extern __declspec(dllexport)+#define DUK_EXTERNAL       __declspec(dllexport)+#else+#define DUK_EXTERNAL_DECL  extern __declspec(dllimport)+#define DUK_EXTERNAL       should_not_happen+#endif+#if defined(DUK_SINGLE_FILE)+#define DUK_INTERNAL_DECL  static+#define DUK_INTERNAL       static+#else+#define DUK_INTERNAL_DECL  extern+#define DUK_INTERNAL       /*empty*/+#endif+#define DUK_LOCAL_DECL     static+#define DUK_LOCAL          static+#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+#elif defined(DUK_F_EMSCRIPTEN)+/* --- Emscripten --- */+#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++#define DUK_EXTERNAL_DECL  __attribute__ ((visibility("default"))) extern+#define DUK_EXTERNAL       __attribute__ ((visibility("default")))+#if defined(DUK_SINGLE_FILE)+#if (defined(DUK_F_GCC_VERSION) && DUK_F_GCC_VERSION >= 30101) || defined(DUK_F_CLANG)+/* Minimize warnings for unused internal functions with GCC >= 3.1.1 and+ * Clang.  Based on documentation it should suffice to have the attribute+ * in the declaration only, but in practice some warnings are generated unless+ * the attribute is also applied to the definition.+ */+#define DUK_INTERNAL_DECL  static __attribute__ ((unused))+#define DUK_INTERNAL       static __attribute__ ((unused))+#else+#define DUK_INTERNAL_DECL  static+#define DUK_INTERNAL       static+#endif+#else+#if (defined(DUK_F_GCC_VERSION) && DUK_F_GCC_VERSION >= 30101) || defined(DUK_F_CLANG)+#define DUK_INTERNAL_DECL  __attribute__ ((visibility("hidden"))) __attribute__ ((unused)) extern+#define DUK_INTERNAL       __attribute__ ((visibility("hidden"))) __attribute__ ((unused))+#else+#define DUK_INTERNAL_DECL  __attribute__ ((visibility("hidden"))) extern+#define DUK_INTERNAL       __attribute__ ((visibility("hidden")))+#endif+#endif+#define DUK_LOCAL_DECL     static+#define DUK_LOCAL          static++#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+#elif defined(DUK_F_TINYC)+/* --- TinyC --- */+#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+#elif defined(DUK_F_VBCC)+/* --- VBCC --- */+#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+#elif defined(DUK_F_BCC)+/* --- Bruce's C compiler --- */+#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+#else+/* --- Generic --- */+#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+#endif  /* autodetect compiler */++/* uclibc */+#if defined(__UCLIBC__)+#define DUK_F_UCLIBC+#endif++/*+ *  Wrapper typedefs and constants for integer types, also sanity check types.+ *+ *  C99 typedefs are quite good but not always available, and we want to avoid+ *  forcibly redefining the C99 typedefs.  So, there are Duktape wrappers for+ *  all C99 typedefs and Duktape code should only use these typedefs.  Type+ *  detection when C99 is not supported is best effort and may end up detecting+ *  some types incorrectly.+ *+ *  Pointer sizes are a portability problem: pointers to different types may+ *  have a different size and function pointers are very difficult to manage+ *  portably.+ *+ *  http://en.wikipedia.org/wiki/C_data_types#Fixed-width_integer_types+ *+ *  Note: there's an interesting corner case when trying to define minimum+ *  signed integer value constants which leads to the current workaround of+ *  defining e.g. -0x80000000 as (-0x7fffffffL - 1L).  See doc/code-issues.txt+ *  for a longer discussion.+ *+ *  Note: avoid typecasts and computations in macro integer constants as they+ *  can then no longer be used in macro relational expressions (such as+ *  #if DUK_SIZE_MAX < 0xffffffffUL).  There is internal code which relies on+ *  being able to compare DUK_SIZE_MAX against a limit.+ */++/* XXX: add feature options to force basic types from outside? */++#if !defined(INT_MAX)+#error INT_MAX not defined+#endif++/* Check that architecture is two's complement, standard C allows e.g.+ * INT_MIN to be -2**31+1 (instead of -2**31).+ */+#if defined(INT_MAX) && defined(INT_MIN)+#if INT_MAX != -(INT_MIN + 1)+#error platform does not seem complement of two+#endif+#else+#error cannot check complement of two+#endif++/* Pointer size determination based on __WORDSIZE or architecture when+ * that's not available.+ */+#if defined(DUK_F_X86) || defined(DUK_F_X32) || \+    defined(DUK_F_M68K) || defined(DUK_F_PPC32) || \+    defined(DUK_F_BCC) || \+    (defined(__WORDSIZE) && (__WORDSIZE == 32)) || \+    ((defined(DUK_F_OLD_SOLARIS) || defined(DUK_F_AIX) || \+      defined(DUK_F_HPUX)) && defined(_ILP32)) || \+    defined(DUK_F_ARM32)+#define DUK_F_32BIT_PTRS+#elif defined(DUK_F_X64) || \+      (defined(__WORDSIZE) && (__WORDSIZE == 64)) || \+   ((defined(DUK_F_OLD_SOLARIS) || defined(DUK_F_AIX) || \+     defined(DUK_F_HPUX)) && defined(_LP64)) || \+    defined(DUK_F_ARM64)+#define DUK_F_64BIT_PTRS+#else+/* not sure, not needed with C99 anyway */+#endif++/* Intermediate define for 'have inttypes.h' */+#undef DUK_F_HAVE_INTTYPES+#if defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L) && \+    !(defined(DUK_F_AMIGAOS) && defined(DUK_F_VBCC))+/* vbcc + AmigaOS has C99 but no inttypes.h */+#define DUK_F_HAVE_INTTYPES+#elif defined(__cplusplus) && (__cplusplus >= 201103L)+/* C++11 apparently ratified stdint.h */+#define DUK_F_HAVE_INTTYPES+#endif++/* Basic integer typedefs and limits, preferably from inttypes.h, otherwise+ * through automatic detection.+ */+#if defined(DUK_F_HAVE_INTTYPES)+/* C99 or compatible */++#define DUK_F_HAVE_64BIT+#include <inttypes.h>++typedef uint8_t duk_uint8_t;+typedef int8_t duk_int8_t;+typedef uint16_t duk_uint16_t;+typedef int16_t duk_int16_t;+typedef uint32_t duk_uint32_t;+typedef int32_t duk_int32_t;+typedef uint64_t duk_uint64_t;+typedef int64_t duk_int64_t;+typedef uint_least8_t duk_uint_least8_t;+typedef int_least8_t duk_int_least8_t;+typedef uint_least16_t duk_uint_least16_t;+typedef int_least16_t duk_int_least16_t;+typedef uint_least32_t duk_uint_least32_t;+typedef int_least32_t duk_int_least32_t;+typedef uint_least64_t duk_uint_least64_t;+typedef int_least64_t duk_int_least64_t;+typedef uint_fast8_t duk_uint_fast8_t;+typedef int_fast8_t duk_int_fast8_t;+typedef uint_fast16_t duk_uint_fast16_t;+typedef int_fast16_t duk_int_fast16_t;+typedef uint_fast32_t duk_uint_fast32_t;+typedef int_fast32_t duk_int_fast32_t;+typedef uint_fast64_t duk_uint_fast64_t;+typedef int_fast64_t duk_int_fast64_t;+typedef uintptr_t duk_uintptr_t;+typedef intptr_t duk_intptr_t;+typedef uintmax_t duk_uintmax_t;+typedef intmax_t duk_intmax_t;++#define DUK_UINT8_MIN         0+#define DUK_UINT8_MAX         UINT8_MAX+#define DUK_INT8_MIN          INT8_MIN+#define DUK_INT8_MAX          INT8_MAX+#define DUK_UINT_LEAST8_MIN   0+#define DUK_UINT_LEAST8_MAX   UINT_LEAST8_MAX+#define DUK_INT_LEAST8_MIN    INT_LEAST8_MIN+#define DUK_INT_LEAST8_MAX    INT_LEAST8_MAX+#define DUK_UINT_FAST8_MIN    0+#define DUK_UINT_FAST8_MAX    UINT_FAST8_MAX+#define DUK_INT_FAST8_MIN     INT_FAST8_MIN+#define DUK_INT_FAST8_MAX     INT_FAST8_MAX+#define DUK_UINT16_MIN        0+#define DUK_UINT16_MAX        UINT16_MAX+#define DUK_INT16_MIN         INT16_MIN+#define DUK_INT16_MAX         INT16_MAX+#define DUK_UINT_LEAST16_MIN  0+#define DUK_UINT_LEAST16_MAX  UINT_LEAST16_MAX+#define DUK_INT_LEAST16_MIN   INT_LEAST16_MIN+#define DUK_INT_LEAST16_MAX   INT_LEAST16_MAX+#define DUK_UINT_FAST16_MIN   0+#define DUK_UINT_FAST16_MAX   UINT_FAST16_MAX+#define DUK_INT_FAST16_MIN    INT_FAST16_MIN+#define DUK_INT_FAST16_MAX    INT_FAST16_MAX+#define DUK_UINT32_MIN        0+#define DUK_UINT32_MAX        UINT32_MAX+#define DUK_INT32_MIN         INT32_MIN+#define DUK_INT32_MAX         INT32_MAX+#define DUK_UINT_LEAST32_MIN  0+#define DUK_UINT_LEAST32_MAX  UINT_LEAST32_MAX+#define DUK_INT_LEAST32_MIN   INT_LEAST32_MIN+#define DUK_INT_LEAST32_MAX   INT_LEAST32_MAX+#define DUK_UINT_FAST32_MIN   0+#define DUK_UINT_FAST32_MAX   UINT_FAST32_MAX+#define DUK_INT_FAST32_MIN    INT_FAST32_MIN+#define DUK_INT_FAST32_MAX    INT_FAST32_MAX+#define DUK_UINT64_MIN        0+#define DUK_UINT64_MAX        UINT64_MAX+#define DUK_INT64_MIN         INT64_MIN+#define DUK_INT64_MAX         INT64_MAX+#define DUK_UINT_LEAST64_MIN  0+#define DUK_UINT_LEAST64_MAX  UINT_LEAST64_MAX+#define DUK_INT_LEAST64_MIN   INT_LEAST64_MIN+#define DUK_INT_LEAST64_MAX   INT_LEAST64_MAX+#define DUK_UINT_FAST64_MIN   0+#define DUK_UINT_FAST64_MAX   UINT_FAST64_MAX+#define DUK_INT_FAST64_MIN    INT_FAST64_MIN+#define DUK_INT_FAST64_MAX    INT_FAST64_MAX++#define DUK_UINTPTR_MIN       0+#define DUK_UINTPTR_MAX       UINTPTR_MAX+#define DUK_INTPTR_MIN        INTPTR_MIN+#define DUK_INTPTR_MAX        INTPTR_MAX++#define DUK_UINTMAX_MIN       0+#define DUK_UINTMAX_MAX       UINTMAX_MAX+#define DUK_INTMAX_MIN        INTMAX_MIN+#define DUK_INTMAX_MAX        INTMAX_MAX++#define DUK_SIZE_MIN          0+#define DUK_SIZE_MAX          SIZE_MAX+#undef DUK_SIZE_MAX_COMPUTED++#else  /* C99 types */++/* When C99 types are not available, we use heuristic detection to get+ * the basic 8, 16, 32, and (possibly) 64 bit types.  The fast/least+ * types are then assumed to be exactly the same for now: these could+ * be improved per platform but C99 types are very often now available.+ * 64-bit types are not available on all platforms; this is OK at least+ * on 32-bit platforms.+ *+ * This detection code is necessarily a bit hacky and can provide typedefs+ * and defines that won't work correctly on some exotic platform.+ */++#if (defined(CHAR_BIT) && (CHAR_BIT == 8)) || \+    (defined(UCHAR_MAX) && (UCHAR_MAX == 255))+typedef unsigned char duk_uint8_t;+typedef signed char duk_int8_t;+#else+#error cannot detect 8-bit type+#endif++#if defined(USHRT_MAX) && (USHRT_MAX == 65535UL)+typedef unsigned short duk_uint16_t;+typedef signed short duk_int16_t;+#elif defined(UINT_MAX) && (UINT_MAX == 65535UL)+/* On some platforms int is 16-bit but long is 32-bit (e.g. PureC) */+typedef unsigned int duk_uint16_t;+typedef signed int duk_int16_t;+#else+#error cannot detect 16-bit type+#endif++#if defined(UINT_MAX) && (UINT_MAX == 4294967295UL)+typedef unsigned int duk_uint32_t;+typedef signed int duk_int32_t;+#elif defined(ULONG_MAX) && (ULONG_MAX == 4294967295UL)+/* On some platforms int is 16-bit but long is 32-bit (e.g. PureC) */+typedef unsigned long duk_uint32_t;+typedef signed long duk_int32_t;+#else+#error cannot detect 32-bit type+#endif++/* 64-bit type detection is a bit tricky.+ *+ * ULLONG_MAX is a standard define.  __LONG_LONG_MAX__ and __ULONG_LONG_MAX__+ * are used by at least GCC (even if system headers don't provide ULLONG_MAX).+ * Some GCC variants may provide __LONG_LONG_MAX__ but not __ULONG_LONG_MAX__.+ *+ * ULL / LL constants are rejected / warned about by some compilers, even if+ * the compiler has a 64-bit type and the compiler/system headers provide an+ * unsupported constant (ULL/LL)!  Try to avoid using ULL / LL constants.+ * As a side effect we can only check that e.g. ULONG_MAX is larger than 32+ * bits but can't be sure it is exactly 64 bits.  Self tests will catch such+ * cases.+ */+#undef DUK_F_HAVE_64BIT+#if !defined(DUK_F_HAVE_64BIT) && defined(ULONG_MAX)+#if (ULONG_MAX > 4294967295UL)+#define DUK_F_HAVE_64BIT+typedef unsigned long duk_uint64_t;+typedef signed long duk_int64_t;+#endif+#endif+#if !defined(DUK_F_HAVE_64BIT) && defined(ULLONG_MAX)+#if (ULLONG_MAX > 4294967295UL)+#define DUK_F_HAVE_64BIT+typedef unsigned long long duk_uint64_t;+typedef signed long long duk_int64_t;+#endif+#endif+#if !defined(DUK_F_HAVE_64BIT) && defined(__ULONG_LONG_MAX__)+#if (__ULONG_LONG_MAX__ > 4294967295UL)+#define DUK_F_HAVE_64BIT+typedef unsigned long long duk_uint64_t;+typedef signed long long duk_int64_t;+#endif+#endif+#if !defined(DUK_F_HAVE_64BIT) && defined(__LONG_LONG_MAX__)+#if (__LONG_LONG_MAX__ > 2147483647L)+#define DUK_F_HAVE_64BIT+typedef unsigned long long duk_uint64_t;+typedef signed long long duk_int64_t;+#endif+#endif+#if !defined(DUK_F_HAVE_64BIT) && defined(DUK_F_MINGW)+#define DUK_F_HAVE_64BIT+typedef unsigned long duk_uint64_t;+typedef signed long duk_int64_t;+#endif+#if !defined(DUK_F_HAVE_64BIT) && defined(DUK_F_MSVC)+#define DUK_F_HAVE_64BIT+typedef unsigned __int64 duk_uint64_t;+typedef signed __int64 duk_int64_t;+#endif+#if !defined(DUK_F_HAVE_64BIT)+/* cannot detect 64-bit type, not always needed so don't error */+#endif++typedef duk_uint8_t duk_uint_least8_t;+typedef duk_int8_t duk_int_least8_t;+typedef duk_uint16_t duk_uint_least16_t;+typedef duk_int16_t duk_int_least16_t;+typedef duk_uint32_t duk_uint_least32_t;+typedef duk_int32_t duk_int_least32_t;+typedef duk_uint8_t duk_uint_fast8_t;+typedef duk_int8_t duk_int_fast8_t;+typedef duk_uint16_t duk_uint_fast16_t;+typedef duk_int16_t duk_int_fast16_t;+typedef duk_uint32_t duk_uint_fast32_t;+typedef duk_int32_t duk_int_fast32_t;+#if defined(DUK_F_HAVE_64BIT)+typedef duk_uint64_t duk_uint_least64_t;+typedef duk_int64_t duk_int_least64_t;+typedef duk_uint64_t duk_uint_fast64_t;+typedef duk_int64_t duk_int_fast64_t;+#endif+#if defined(DUK_F_HAVE_64BIT)+typedef duk_uint64_t duk_uintmax_t;+typedef duk_int64_t duk_intmax_t;+#else+typedef duk_uint32_t duk_uintmax_t;+typedef duk_int32_t duk_intmax_t;+#endif++/* Note: the funny looking computations for signed minimum 16-bit, 32-bit, and+ * 64-bit values are intentional as the obvious forms (e.g. -0x80000000L) are+ * -not- portable.  See code-issues.txt for a detailed discussion.+ */+#define DUK_UINT8_MIN         0UL+#define DUK_UINT8_MAX         0xffUL+#define DUK_INT8_MIN          (-0x80L)+#define DUK_INT8_MAX          0x7fL+#define DUK_UINT_LEAST8_MIN   0UL+#define DUK_UINT_LEAST8_MAX   0xffUL+#define DUK_INT_LEAST8_MIN    (-0x80L)+#define DUK_INT_LEAST8_MAX    0x7fL+#define DUK_UINT_FAST8_MIN    0UL+#define DUK_UINT_FAST8_MAX    0xffUL+#define DUK_INT_FAST8_MIN     (-0x80L)+#define DUK_INT_FAST8_MAX     0x7fL+#define DUK_UINT16_MIN        0UL+#define DUK_UINT16_MAX        0xffffUL+#define DUK_INT16_MIN         (-0x7fffL - 1L)+#define DUK_INT16_MAX         0x7fffL+#define DUK_UINT_LEAST16_MIN  0UL+#define DUK_UINT_LEAST16_MAX  0xffffUL+#define DUK_INT_LEAST16_MIN   (-0x7fffL - 1L)+#define DUK_INT_LEAST16_MAX   0x7fffL+#define DUK_UINT_FAST16_MIN   0UL+#define DUK_UINT_FAST16_MAX   0xffffUL+#define DUK_INT_FAST16_MIN    (-0x7fffL - 1L)+#define DUK_INT_FAST16_MAX    0x7fffL+#define DUK_UINT32_MIN        0UL+#define DUK_UINT32_MAX        0xffffffffUL+#define DUK_INT32_MIN         (-0x7fffffffL - 1L)+#define DUK_INT32_MAX         0x7fffffffL+#define DUK_UINT_LEAST32_MIN  0UL+#define DUK_UINT_LEAST32_MAX  0xffffffffUL+#define DUK_INT_LEAST32_MIN   (-0x7fffffffL - 1L)+#define DUK_INT_LEAST32_MAX   0x7fffffffL+#define DUK_UINT_FAST32_MIN   0UL+#define DUK_UINT_FAST32_MAX   0xffffffffUL+#define DUK_INT_FAST32_MIN    (-0x7fffffffL - 1L)+#define DUK_INT_FAST32_MAX    0x7fffffffL++/* 64-bit constants.  Since LL / ULL constants are not always available,+ * use computed values.  These values can't be used in preprocessor+ * comparisons; flag them as such.+ */+#if defined(DUK_F_HAVE_64BIT)+#define DUK_UINT64_MIN        ((duk_uint64_t) 0)+#define DUK_UINT64_MAX        ((duk_uint64_t) -1)+#define DUK_INT64_MIN         ((duk_int64_t) (~(DUK_UINT64_MAX >> 1)))+#define DUK_INT64_MAX         ((duk_int64_t) (DUK_UINT64_MAX >> 1))+#define DUK_UINT_LEAST64_MIN  DUK_UINT64_MIN+#define DUK_UINT_LEAST64_MAX  DUK_UINT64_MAX+#define DUK_INT_LEAST64_MIN   DUK_INT64_MIN+#define DUK_INT_LEAST64_MAX   DUK_INT64_MAX+#define DUK_UINT_FAST64_MIN   DUK_UINT64_MIN+#define DUK_UINT_FAST64_MAX   DUK_UINT64_MAX+#define DUK_INT_FAST64_MIN    DUK_INT64_MIN+#define DUK_INT_FAST64_MAX    DUK_INT64_MAX+#define DUK_UINT64_MIN_COMPUTED+#define DUK_UINT64_MAX_COMPUTED+#define DUK_INT64_MIN_COMPUTED+#define DUK_INT64_MAX_COMPUTED+#define DUK_UINT_LEAST64_MIN_COMPUTED+#define DUK_UINT_LEAST64_MAX_COMPUTED+#define DUK_INT_LEAST64_MIN_COMPUTED+#define DUK_INT_LEAST64_MAX_COMPUTED+#define DUK_UINT_FAST64_MIN_COMPUTED+#define DUK_UINT_FAST64_MAX_COMPUTED+#define DUK_INT_FAST64_MIN_COMPUTED+#define DUK_INT_FAST64_MAX_COMPUTED+#endif++#if defined(DUK_F_HAVE_64BIT)+#define DUK_UINTMAX_MIN       DUK_UINT64_MIN+#define DUK_UINTMAX_MAX       DUK_UINT64_MAX+#define DUK_INTMAX_MIN        DUK_INT64_MIN+#define DUK_INTMAX_MAX        DUK_INT64_MAX+#define DUK_UINTMAX_MIN_COMPUTED+#define DUK_UINTMAX_MAX_COMPUTED+#define DUK_INTMAX_MIN_COMPUTED+#define DUK_INTMAX_MAX_COMPUTED+#else+#define DUK_UINTMAX_MIN       0UL+#define DUK_UINTMAX_MAX       0xffffffffUL+#define DUK_INTMAX_MIN        (-0x7fffffffL - 1L)+#define DUK_INTMAX_MAX        0x7fffffffL+#endif++/* This detection is not very reliable. */+#if defined(DUK_F_32BIT_PTRS)+typedef duk_int32_t duk_intptr_t;+typedef duk_uint32_t duk_uintptr_t;+#define DUK_UINTPTR_MIN       DUK_UINT32_MIN+#define DUK_UINTPTR_MAX       DUK_UINT32_MAX+#define DUK_INTPTR_MIN        DUK_INT32_MIN+#define DUK_INTPTR_MAX        DUK_INT32_MAX+#elif defined(DUK_F_64BIT_PTRS) && defined(DUK_F_HAVE_64BIT)+typedef duk_int64_t duk_intptr_t;+typedef duk_uint64_t duk_uintptr_t;+#define DUK_UINTPTR_MIN       DUK_UINT64_MIN+#define DUK_UINTPTR_MAX       DUK_UINT64_MAX+#define DUK_INTPTR_MIN        DUK_INT64_MIN+#define DUK_INTPTR_MAX        DUK_INT64_MAX+#define DUK_UINTPTR_MIN_COMPUTED+#define DUK_UINTPTR_MAX_COMPUTED+#define DUK_INTPTR_MIN_COMPUTED+#define DUK_INTPTR_MAX_COMPUTED+#else+#error cannot determine intptr type+#endif++/* SIZE_MAX may be missing so use an approximate value for it. */+#undef DUK_SIZE_MAX_COMPUTED+#if !defined(SIZE_MAX)+#define DUK_SIZE_MAX_COMPUTED+#define SIZE_MAX              ((size_t) (-1))+#endif+#define DUK_SIZE_MIN          0+#define DUK_SIZE_MAX          SIZE_MAX++#endif  /* C99 types */++/* A few types are assumed to always exist. */+typedef size_t duk_size_t;+typedef ptrdiff_t duk_ptrdiff_t;++/* The best type for an "all around int" in Duktape internals is "at least+ * 32 bit signed integer" which is most convenient.  Same for unsigned type.+ * Prefer 'int' when large enough, as it is almost always a convenient type.+ */+#if defined(UINT_MAX) && (UINT_MAX >= 0xffffffffUL)+typedef int duk_int_t;+typedef unsigned int duk_uint_t;+#define DUK_INT_MIN           INT_MIN+#define DUK_INT_MAX           INT_MAX+#define DUK_UINT_MIN          0+#define DUK_UINT_MAX          UINT_MAX+#else+typedef duk_int_fast32_t duk_int_t;+typedef duk_uint_fast32_t duk_uint_t;+#define DUK_INT_MIN           DUK_INT_FAST32_MIN+#define DUK_INT_MAX           DUK_INT_FAST32_MAX+#define DUK_UINT_MIN          DUK_UINT_FAST32_MIN+#define DUK_UINT_MAX          DUK_UINT_FAST32_MAX+#endif++/* Same as 'duk_int_t' but guaranteed to be a 'fast' variant if this+ * distinction matters for the CPU.  These types are used mainly in the+ * executor where it might really matter.+ */+typedef duk_int_fast32_t duk_int_fast_t;+typedef duk_uint_fast32_t duk_uint_fast_t;+#define DUK_INT_FAST_MIN      DUK_INT_FAST32_MIN+#define DUK_INT_FAST_MAX      DUK_INT_FAST32_MAX+#define DUK_UINT_FAST_MIN     DUK_UINT_FAST32_MIN+#define DUK_UINT_FAST_MAX     DUK_UINT_FAST32_MAX++/* Small integers (16 bits or more) can fall back to the 'int' type, but+ * have a typedef so they are marked "small" explicitly.+ */+typedef int duk_small_int_t;+typedef unsigned int duk_small_uint_t;+#define DUK_SMALL_INT_MIN     INT_MIN+#define DUK_SMALL_INT_MAX     INT_MAX+#define DUK_SMALL_UINT_MIN    0+#define DUK_SMALL_UINT_MAX    UINT_MAX++/* Fast variants of small integers, again for really fast paths like the+ * executor.+ */+typedef duk_int_fast16_t duk_small_int_fast_t;+typedef duk_uint_fast16_t duk_small_uint_fast_t;+#define DUK_SMALL_INT_FAST_MIN    DUK_INT_FAST16_MIN+#define DUK_SMALL_INT_FAST_MAX    DUK_INT_FAST16_MAX+#define DUK_SMALL_UINT_FAST_MIN   DUK_UINT_FAST16_MIN+#define DUK_SMALL_UINT_FAST_MAX   DUK_UINT_FAST16_MAX++/* Boolean values are represented with the platform 'unsigned int'. */+typedef duk_small_uint_t duk_bool_t;+#define DUK_BOOL_MIN              DUK_SMALL_UINT_MIN+#define DUK_BOOL_MAX              DUK_SMALL_UINT_MAX++/* Index values must have at least 32-bit signed range. */+typedef duk_int_t duk_idx_t;+#define DUK_IDX_MIN               DUK_INT_MIN+#define DUK_IDX_MAX               DUK_INT_MAX++/* Unsigned index variant. */+typedef duk_uint_t duk_uidx_t;+#define DUK_UIDX_MIN              DUK_UINT_MIN+#define DUK_UIDX_MAX              DUK_UINT_MAX++/* Array index values, could be exact 32 bits.+ * Currently no need for signed duk_arridx_t.+ */+typedef duk_uint_t duk_uarridx_t;+#define DUK_UARRIDX_MIN           DUK_UINT_MIN+#define DUK_UARRIDX_MAX           DUK_UINT_MAX++/* Duktape/C function return value, platform int is enough for now to+ * represent 0, 1, or negative error code.  Must be compatible with+ * assigning truth values (e.g. duk_ret_t rc = (foo == bar);).+ */+typedef duk_small_int_t duk_ret_t;+#define DUK_RET_MIN               DUK_SMALL_INT_MIN+#define DUK_RET_MAX               DUK_SMALL_INT_MAX++/* Error codes are represented with platform int.  High bits are used+ * for flags and such, so 32 bits are needed.+ */+typedef duk_int_t duk_errcode_t;+#define DUK_ERRCODE_MIN           DUK_INT_MIN+#define DUK_ERRCODE_MAX           DUK_INT_MAX++/* Codepoint type.  Must be 32 bits or more because it is used also for+ * internal codepoints.  The type is signed because negative codepoints+ * are used as internal markers (e.g. to mark EOF or missing argument).+ * (X)UTF-8/CESU-8 encode/decode take and return an unsigned variant to+ * ensure duk_uint32_t casts back and forth nicely.  Almost everything+ * else uses the signed one.+ */+typedef duk_int_t duk_codepoint_t;+typedef duk_uint_t duk_ucodepoint_t;+#define DUK_CODEPOINT_MIN         DUK_INT_MIN+#define DUK_CODEPOINT_MAX         DUK_INT_MAX+#define DUK_UCODEPOINT_MIN        DUK_UINT_MIN+#define DUK_UCODEPOINT_MAX        DUK_UINT_MAX++/* IEEE float/double typedef. */+typedef float duk_float_t;+typedef double duk_double_t;++/* We're generally assuming that we're working on a platform with a 32-bit+ * address space.  If DUK_SIZE_MAX is a typecast value (which is necessary+ * if SIZE_MAX is missing), the check must be avoided because the+ * preprocessor can't do a comparison.+ */+#if !defined(DUK_SIZE_MAX)+#error DUK_SIZE_MAX is undefined, probably missing SIZE_MAX+#elif !defined(DUK_SIZE_MAX_COMPUTED)+#if DUK_SIZE_MAX < 0xffffffffUL+/* On some systems SIZE_MAX can be smaller than max unsigned 32-bit value+ * which seems incorrect if size_t is (at least) an unsigned 32-bit type.+ * However, it doesn't seem useful to error out compilation if this is the+ * case.+ */+#endif+#endif++/* Type used in public API declarations and user code.  Typedef maps to+ * 'struct duk_hthread' like the 'duk_hthread' typedef which is used+ * exclusively in internals.+ */+typedef struct duk_hthread duk_context;++/* Check whether we should use 64-bit integers or not.+ *+ * Quite incomplete now.  Use 64-bit types if detected (C99 or other detection)+ * unless they are known to be unreliable.  For instance, 64-bit types are+ * available on VBCC but seem to misbehave.+ */+#if defined(DUK_F_HAVE_64BIT) && !defined(DUK_F_VBCC)+#define DUK_USE_64BIT_OPS+#else+#undef DUK_USE_64BIT_OPS+#endif++/*+ *  Fill-ins for platform, architecture, and compiler+ */++/* An abort()-like primitive is needed by the default fatal error handler. */+#if !defined(DUK_ABORT)+#define DUK_ABORT             abort+#endif++#if !defined(DUK_SETJMP)+#define DUK_JMPBUF_TYPE       jmp_buf+#define DUK_SETJMP(jb)        setjmp((jb))+#define DUK_LONGJMP(jb)       longjmp((jb), 1)+#endif++#if 0+/* sigsetjmp() alternative */+#define DUK_JMPBUF_TYPE       sigjmp_buf+#define DUK_SETJMP(jb)        sigsetjmp((jb))+#define DUK_LONGJMP(jb)       siglongjmp((jb), 1)+#endif++/* Special naming to avoid conflict with e.g. DUK_FREE() in duk_heap.h+ * (which is unfortunately named).  May sometimes need replacement, e.g.+ * some compilers don't handle zero length or NULL correctly in realloc().+ */+#if !defined(DUK_ANSI_MALLOC)+#define DUK_ANSI_MALLOC      malloc+#endif+#if !defined(DUK_ANSI_REALLOC)+#define DUK_ANSI_REALLOC     realloc+#endif+#if !defined(DUK_ANSI_CALLOC)+#define DUK_ANSI_CALLOC      calloc+#endif+#if !defined(DUK_ANSI_FREE)+#define DUK_ANSI_FREE        free+#endif++/* ANSI C (various versions) and some implementations require that the+ * pointer arguments to memset(), memcpy(), and memmove() be valid values+ * even when byte size is 0 (even a NULL pointer is considered invalid in+ * this context).  Zero-size operations as such are allowed, as long as their+ * pointer arguments point to a valid memory area.  The DUK_MEMSET(),+ * DUK_MEMCPY(), and DUK_MEMMOVE() macros require this same behavior, i.e.:+ * (1) pointers must be valid and non-NULL, (2) zero size must otherwise be+ * allowed.  If these are not fulfilled, a macro wrapper is needed.+ *+ *   http://stackoverflow.com/questions/5243012/is-it-guaranteed-to-be-safe-to-perform-memcpy0-0-0+ *   http://lists.cs.uiuc.edu/pipermail/llvmdev/2007-October/011065.html+ *+ * Not sure what's the required behavior when a pointer points just past the+ * end of a buffer, which often happens in practice (e.g. zero size memmoves).+ * For example, if allocation size is 3, the following pointer would not+ * technically point to a valid memory byte:+ *+ *   <-- alloc -->+ *   | 0 | 1 | 2 | .....+ *                 ^-- p=3, points after last valid byte (2)+ */+#if !defined(DUK_MEMCPY)+#if defined(DUK_F_UCLIBC)+/* Old uclibcs have a broken memcpy so use memmove instead (this is overly wide+ * now on purpose): http://lists.uclibc.org/pipermail/uclibc-cvs/2008-October/025511.html+ */+#define DUK_MEMCPY       memmove+#else+#define DUK_MEMCPY       memcpy+#endif+#endif+#if !defined(DUK_MEMMOVE)+#define DUK_MEMMOVE      memmove+#endif+#if !defined(DUK_MEMCMP)+#define DUK_MEMCMP       memcmp+#endif+#if !defined(DUK_MEMSET)+#define DUK_MEMSET       memset+#endif+#if !defined(DUK_STRLEN)+#define DUK_STRLEN       strlen+#endif+#if !defined(DUK_STRCMP)+#define DUK_STRCMP       strcmp+#endif+#if !defined(DUK_STRNCMP)+#define DUK_STRNCMP      strncmp+#endif+#if !defined(DUK_SPRINTF)+#define DUK_SPRINTF      sprintf+#endif+#if !defined(DUK_SNPRINTF)+/* snprintf() is technically not part of C89 but usually available. */+#define DUK_SNPRINTF     snprintf+#endif+#if !defined(DUK_VSPRINTF)+#define DUK_VSPRINTF     vsprintf+#endif+#if !defined(DUK_VSNPRINTF)+/* vsnprintf() is technically not part of C89 but usually available. */+#define DUK_VSNPRINTF    vsnprintf+#endif+#if !defined(DUK_SSCANF)+#define DUK_SSCANF       sscanf+#endif+#if !defined(DUK_VSSCANF)+#define DUK_VSSCANF      vsscanf+#endif+#if !defined(DUK_MEMZERO)+#define DUK_MEMZERO(p,n) DUK_MEMSET((p), 0, (n))+#endif++#if !defined(DUK_DOUBLE_INFINITY)+#undef DUK_USE_COMPUTED_INFINITY+#if defined(DUK_F_GCC_VERSION) && (DUK_F_GCC_VERSION < 40600)+/* GCC older than 4.6: avoid overflow warnings related to using INFINITY */+#define DUK_DOUBLE_INFINITY  (__builtin_inf())+#elif defined(INFINITY)+#define DUK_DOUBLE_INFINITY  ((double) INFINITY)+#elif !defined(DUK_F_VBCC) && !defined(DUK_F_MSVC) && !defined(DUK_F_BCC) && \+      !defined(DUK_F_OLD_SOLARIS) && !defined(DUK_F_AIX)+#define DUK_DOUBLE_INFINITY  (1.0 / 0.0)+#else+/* In VBCC (1.0 / 0.0) results in a warning and 0.0 instead of infinity.+ * Use a computed infinity (initialized when a heap is created at the+ * latest).+ */+#define DUK_USE_COMPUTED_INFINITY+#define DUK_DOUBLE_INFINITY  duk_computed_infinity+#endif+#endif++#if !defined(DUK_DOUBLE_NAN)+#undef DUK_USE_COMPUTED_NAN+#if defined(NAN)+#define DUK_DOUBLE_NAN       NAN+#elif !defined(DUK_F_VBCC) && !defined(DUK_F_MSVC) && !defined(DUK_F_BCC) && \+      !defined(DUK_F_OLD_SOLARIS) && !defined(DUK_F_AIX)+#define DUK_DOUBLE_NAN       (0.0 / 0.0)+#else+/* In VBCC (0.0 / 0.0) results in a warning and 0.0 instead of NaN.+ * In MSVC (VS2010 Express) (0.0 / 0.0) results in a compile error.+ * Use a computed NaN (initialized when a heap is created at the+ * latest).+ */+#define DUK_USE_COMPUTED_NAN+#define DUK_DOUBLE_NAN       duk_computed_nan+#endif+#endif++/* Many platforms are missing fpclassify() and friends, so use replacements+ * if necessary.  The replacement constants (FP_NAN etc) can be anything but+ * match Linux constants now.+ */+#undef DUK_USE_REPL_FPCLASSIFY+#undef DUK_USE_REPL_SIGNBIT+#undef DUK_USE_REPL_ISFINITE+#undef DUK_USE_REPL_ISNAN+#undef DUK_USE_REPL_ISINF++/* Complex condition broken into separate parts. */+#undef DUK_F_USE_REPL_ALL+#if !(defined(FP_NAN) && defined(FP_INFINITE) && defined(FP_ZERO) && \+      defined(FP_SUBNORMAL) && defined(FP_NORMAL))+/* Missing some obvious constants. */+#define DUK_F_USE_REPL_ALL+#elif defined(DUK_F_AMIGAOS) && defined(DUK_F_VBCC)+/* VBCC is missing the built-ins even in C99 mode (perhaps a header issue). */+#define DUK_F_USE_REPL_ALL+#elif defined(DUK_F_AMIGAOS) && defined(DUK_F_M68K)+/* AmigaOS + M68K seems to have math issues even when using GCC cross+ * compilation.  Use replacements for all AmigaOS versions on M68K+ * regardless of compiler.+ */+#define DUK_F_USE_REPL_ALL+#elif defined(DUK_F_FREEBSD) && defined(DUK_F_CLANG)+/* Placeholder fix for (detection is wider than necessary):+ * http://llvm.org/bugs/show_bug.cgi?id=17788+ */+#define DUK_F_USE_REPL_ALL+#elif defined(DUK_F_UCLIBC)+/* At least some uclibc versions have broken floating point math.  For+ * example, fpclassify() can incorrectly classify certain NaN formats.+ * To be safe, use replacements.+ */+#define DUK_F_USE_REPL_ALL+#elif defined(DUK_F_AIX)+/* Older versions may be missing isnan(), etc. */+#define DUK_F_USE_REPL_ALL+#endif++#if defined(DUK_F_USE_REPL_ALL)+#define DUK_USE_REPL_FPCLASSIFY+#define DUK_USE_REPL_SIGNBIT+#define DUK_USE_REPL_ISFINITE+#define DUK_USE_REPL_ISNAN+#define DUK_USE_REPL_ISINF+#define DUK_FPCLASSIFY       duk_repl_fpclassify+#define DUK_SIGNBIT          duk_repl_signbit+#define DUK_ISFINITE         duk_repl_isfinite+#define DUK_ISNAN            duk_repl_isnan+#define DUK_ISINF            duk_repl_isinf+#define DUK_FP_NAN           0+#define DUK_FP_INFINITE      1+#define DUK_FP_ZERO          2+#define DUK_FP_SUBNORMAL     3+#define DUK_FP_NORMAL        4+#else+#define DUK_FPCLASSIFY       fpclassify+#define DUK_SIGNBIT          signbit+#define DUK_ISFINITE         isfinite+#define DUK_ISNAN            isnan+#define DUK_ISINF            isinf+#define DUK_FP_NAN           FP_NAN+#define DUK_FP_INFINITE      FP_INFINITE+#define DUK_FP_ZERO          FP_ZERO+#define DUK_FP_SUBNORMAL     FP_SUBNORMAL+#define DUK_FP_NORMAL        FP_NORMAL+#endif++#if defined(DUK_F_USE_REPL_ALL)+#undef DUK_F_USE_REPL_ALL+#endif++/* These functions don't currently need replacement but are wrapped for+ * completeness.  Because these are used as function pointers, they need+ * to be defined as concrete C functions (not macros).+ */+#if !defined(DUK_FABS)+#define DUK_FABS             fabs+#endif+#if !defined(DUK_FLOOR)+#define DUK_FLOOR            floor+#endif+#if !defined(DUK_CEIL)+#define DUK_CEIL             ceil+#endif+#if !defined(DUK_FMOD)+#define DUK_FMOD             fmod+#endif+#if !defined(DUK_POW)+#define DUK_POW              pow+#endif+#if !defined(DUK_ACOS)+#define DUK_ACOS             acos+#endif+#if !defined(DUK_ASIN)+#define DUK_ASIN             asin+#endif+#if !defined(DUK_ATAN)+#define DUK_ATAN             atan+#endif+#if !defined(DUK_ATAN2)+#define DUK_ATAN2            atan2+#endif+#if !defined(DUK_SIN)+#define DUK_SIN              sin+#endif+#if !defined(DUK_COS)+#define DUK_COS              cos+#endif+#if !defined(DUK_TAN)+#define DUK_TAN              tan+#endif+#if !defined(DUK_EXP)+#define DUK_EXP              exp+#endif+#if !defined(DUK_LOG)+#define DUK_LOG              log+#endif+#if !defined(DUK_SQRT)+#define DUK_SQRT             sqrt+#endif++/* The functions below exist only in C99/C++11 or later and need a workaround+ * for platforms that don't include them.  MSVC isn't detected as C99, but+ * these functions also exist in MSVC 2013 and later so include a clause for+ * that too.  Android doesn't have log2; disable all of these for Android.+ */+#if (defined(DUK_F_C99) || defined(DUK_F_CPP11) || (defined(_MSC_VER) && (_MSC_VER >= 1800))) && \+    !defined(DUK_F_ANDROID) && !defined(DUK_F_MINT)+#if !defined(DUK_CBRT)+#define DUK_CBRT             cbrt+#endif+#if !defined(DUK_LOG2)+#define DUK_LOG2             log2+#endif+#if !defined(DUK_LOG10)+#define DUK_LOG10            log10+#endif+#if !defined(DUK_TRUNC)+#define DUK_TRUNC            trunc+#endif+#endif  /* DUK_F_C99 etc */++/* NetBSD 6.0 x86 (at least) has a few problems with pow() semantics,+ * see test-bug-netbsd-math-pow.js.  MinGW has similar (but different)+ * issues, see test-bug-mingw-math-issues.js.  Enable pow() workarounds+ * for these targets.+ */+#undef DUK_USE_POW_WORKAROUNDS+#if defined(DUK_F_NETBSD) || defined(DUK_F_MINGW)+#define DUK_USE_POW_WORKAROUNDS+#endif++/* Similar workarounds for atan2() semantics issues.  MinGW issues are+ * documented in test-bug-mingw-math-issues.js.+ */+#undef DUK_USE_ATAN2_WORKAROUNDS+#if defined(DUK_F_MINGW)+#define DUK_USE_ATAN2_WORKAROUNDS+#endif++/* Rely as little as possible on compiler behavior for NaN comparison,+ * signed zero handling, etc.  Currently never activated but may be needed+ * for broken compilers.+ */+#undef DUK_USE_PARANOID_MATH++/* There was a curious bug where test-bi-date-canceling.js would fail e.g.+ * on 64-bit Ubuntu, gcc-4.8.1, -m32, and no -std=c99.  Some date computations+ * using doubles would be optimized which then broke some corner case tests.+ * The problem goes away by adding 'volatile' to the datetime computations.+ * Not sure what the actual triggering conditions are, but using this on+ * non-C99 systems solves the known issues and has relatively little cost+ * on other platforms.+ */+#undef DUK_USE_PARANOID_DATE_COMPUTATION+#if !defined(DUK_F_C99)+#define DUK_USE_PARANOID_DATE_COMPUTATION+#endif++/*+ *  Byte order and double memory layout detection+ *+ *  Endianness detection is a major portability hassle because the macros+ *  and headers are not standardized.  There's even variance across UNIX+ *  platforms.  Even with "standard" headers, details like underscore count+ *  varies between platforms, e.g. both __BYTE_ORDER and _BYTE_ORDER are used+ *  (Crossbridge has a single underscore, for instance).+ *+ *  The checks below are structured with this in mind: several approaches are+ *  used, and at the end we check if any of them worked.  This allows generic+ *  approaches to be tried first, and platform/compiler specific hacks tried+ *  last.  As a last resort, the user can force a specific endianness, as it's+ *  not likely that automatic detection will work on the most exotic platforms.+ *+ *  Duktape supports little and big endian machines.  There's also support+ *  for a hybrid used by some ARM machines where integers are little endian+ *  but IEEE double values use a mixed order (12345678 -> 43218765).  This+ *  byte order for doubles is referred to as "mixed endian".+ */++/* GCC and Clang provide endianness defines as built-in predefines, with+ * leading and trailing double underscores (e.g. __BYTE_ORDER__).  See+ * output of "make gccpredefs" and "make clangpredefs".  Clang doesn't+ * seem to provide __FLOAT_WORD_ORDER__; assume not mixed endian for clang.+ * http://gcc.gnu.org/onlinedocs/cpp/Common-Predefined-Macros.html+ */+#if !defined(DUK_USE_BYTEORDER) && defined(__BYTE_ORDER__)+#if defined(__ORDER_LITTLE_ENDIAN__) && (__BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__)+#if defined(__FLOAT_WORD_ORDER__) && defined(__ORDER_LITTLE_ENDIAN__) && (__FLOAT_WORD_ORDER__ == __ORDER_LITTLE_ENDIAN__)+#define DUK_USE_BYTEORDER 1+#elif defined(__FLOAT_WORD_ORDER__) && defined(__ORDER_BIG_ENDIAN__) && (__FLOAT_WORD_ORDER__ == __ORDER_BIG_ENDIAN__)+#define DUK_USE_BYTEORDER 2+#elif !defined(__FLOAT_WORD_ORDER__)+/* Float word order not known, assume not a hybrid. */+#define DUK_USE_BYTEORDER 1+#else+/* Byte order is little endian but cannot determine IEEE double word order. */+#endif  /* float word order */+#elif defined(__ORDER_BIG_ENDIAN__) && (__BYTE_ORDER__ == __ORDER_BIG_ENDIAN__)+#if defined(__FLOAT_WORD_ORDER__) && defined(__ORDER_BIG_ENDIAN__) && (__FLOAT_WORD_ORDER__ == __ORDER_BIG_ENDIAN__)+#define DUK_USE_BYTEORDER 3+#elif !defined(__FLOAT_WORD_ORDER__)+/* Float word order not known, assume not a hybrid. */+#define DUK_USE_BYTEORDER 3+#else+/* Byte order is big endian but cannot determine IEEE double word order. */+#endif  /* float word order */+#else+/* Cannot determine byte order; __ORDER_PDP_ENDIAN__ is related to 32-bit+ * integer ordering and is not relevant.+ */+#endif  /* integer byte order */+#endif  /* !defined(DUK_USE_BYTEORDER) && defined(__BYTE_ORDER__) */++/* More or less standard endianness predefines provided by header files.+ * The ARM hybrid case is detected by assuming that __FLOAT_WORD_ORDER+ * will be big endian, see: http://lists.mysql.com/internals/443.+ * On some platforms some defines may be present with an empty value which+ * causes comparisons to fail: https://github.com/svaarala/duktape/issues/453.+ */+#if !defined(DUK_USE_BYTEORDER)+#if defined(__BYTE_ORDER) && defined(__LITTLE_ENDIAN) && (__BYTE_ORDER == __LITTLE_ENDIAN) || \+    defined(_BYTE_ORDER) && defined(_LITTLE_ENDIAN) && (_BYTE_ORDER == _LITTLE_ENDIAN) || \+    defined(__LITTLE_ENDIAN__)+#if defined(__FLOAT_WORD_ORDER) && defined(__LITTLE_ENDIAN) && (__FLOAT_WORD_ORDER == __LITTLE_ENDIAN) || \+    defined(_FLOAT_WORD_ORDER) && defined(_LITTLE_ENDIAN) && (_FLOAT_WORD_ORDER == _LITTLE_ENDIAN)+#define DUK_USE_BYTEORDER 1+#elif defined(__FLOAT_WORD_ORDER) && defined(__BIG_ENDIAN) && (__FLOAT_WORD_ORDER == __BIG_ENDIAN) || \+      defined(_FLOAT_WORD_ORDER) && defined(_BIG_ENDIAN) && (_FLOAT_WORD_ORDER == _BIG_ENDIAN)+#define DUK_USE_BYTEORDER 2+#elif !defined(__FLOAT_WORD_ORDER) && !defined(_FLOAT_WORD_ORDER)+/* Float word order not known, assume not a hybrid. */+#define DUK_USE_BYTEORDER 1+#else+/* Byte order is little endian but cannot determine IEEE double word order. */+#endif  /* float word order */+#elif defined(__BYTE_ORDER) && defined(__BIG_ENDIAN) && (__BYTE_ORDER == __BIG_ENDIAN) || \+      defined(_BYTE_ORDER) && defined(_BIG_ENDIAN) && (_BYTE_ORDER == _BIG_ENDIAN) || \+      defined(__BIG_ENDIAN__)+#if defined(__FLOAT_WORD_ORDER) && defined(__BIG_ENDIAN) && (__FLOAT_WORD_ORDER == __BIG_ENDIAN) || \+    defined(_FLOAT_WORD_ORDER) && defined(_BIG_ENDIAN) && (_FLOAT_WORD_ORDER == _BIG_ENDIAN)+#define DUK_USE_BYTEORDER 3+#elif !defined(__FLOAT_WORD_ORDER) && !defined(_FLOAT_WORD_ORDER)+/* Float word order not known, assume not a hybrid. */+#define DUK_USE_BYTEORDER 3+#else+/* Byte order is big endian but cannot determine IEEE double word order. */+#endif  /* float word order */+#else+/* Cannot determine byte order. */+#endif  /* integer byte order */+#endif  /* !defined(DUK_USE_BYTEORDER) */++/* QNX gcc cross compiler seems to define e.g. __LITTLEENDIAN__ or __BIGENDIAN__:+ *  $ /opt/qnx650/host/linux/x86/usr/bin/i486-pc-nto-qnx6.5.0-gcc -dM -E - </dev/null | grep -ni endian+ *  67:#define __LITTLEENDIAN__ 1+ *  $ /opt/qnx650/host/linux/x86/usr/bin/mips-unknown-nto-qnx6.5.0-gcc -dM -E - </dev/null | grep -ni endian+ *  81:#define __BIGENDIAN__ 1+ *  $ /opt/qnx650/host/linux/x86/usr/bin/arm-unknown-nto-qnx6.5.0-gcc -dM -E - </dev/null | grep -ni endian+ *  70:#define __LITTLEENDIAN__ 1+ */+#if !defined(DUK_USE_BYTEORDER)+#if defined(__LITTLEENDIAN__)+#define DUK_USE_BYTEORDER 1+#elif defined(__BIGENDIAN__)+#define DUK_USE_BYTEORDER 3+#endif+#endif++/*+ *  Alignment requirement and support for unaligned accesses+ *+ *  Assume unaligned accesses are not supported unless specifically allowed+ *  in the target platform.  Some platforms may support unaligned accesses+ *  but alignment to 4 or 8 may still be desirable.  Note that unaligned+ *  accesses (and even pointers) relative to natural alignment (regardless+ *  of target alignment) are technically undefined behavior and thus+ *  compiler/architecture specific.+ */++/* If not forced, use safe default for alignment. */+#if !defined(DUK_USE_ALIGN_BY)+#define DUK_USE_ALIGN_BY 8+#endif++/* Compiler specific hackery needed to force struct size to match aligment,+ * see e.g. duk_hbuffer.h.+ *+ * http://stackoverflow.com/questions/11130109/c-struct-size-alignment+ * http://stackoverflow.com/questions/10951039/specifying-64-bit-alignment+ */+#if !(defined(DUK_USE_PACK_MSVC_PRAGMA) || defined(DUK_USE_PACK_GCC_ATTR) || \+      defined(DUK_USE_PACK_CLANG_ATTR) || defined(DUK_USE_PACK_DUMMY_MEMBER))+#define DUK_USE_PACK_DUMMY_MEMBER+#endif++#if !defined(DUK_VA_COPY)+/* We need va_copy() which is defined in C99 / C++11, so an awkward+ * replacement is needed for pre-C99 / pre-C++11 environments.  This+ * will quite likely need portability hacks for some non-C99+ * environments.+ */+#if defined(DUK_F_C99) || defined(DUK_F_CPP11)+/* C99 / C++11 and above: rely on va_copy() which is required.+ * Omit parenthesis on macro right side on purpose to minimize differences+ * to direct use.+ */+#define DUK_VA_COPY(dest,src) va_copy(dest,src)+#else+/* Pre-C99: va_list type is implementation dependent.  This replacement+ * assumes it is a plain value so that a simple assignment will work.+ * This is not the case on all platforms (it may be a single-array element,+ * for instance).+ */+#define DUK_VA_COPY(dest,src) do { (dest) = (src); } while (0)+#endif+#endif++#if !defined(DUK_MACRO_STRINGIFY)+/* Macro hackery to convert e.g. __LINE__ to a string without formatting,+ * see: http://stackoverflow.com/questions/240353/convert-a-preprocessor-token-to-a-string+ */+#define DUK_MACRO_STRINGIFY_HELPER(x)  #x+#define DUK_MACRO_STRINGIFY(x)  DUK_MACRO_STRINGIFY_HELPER(x)+#endif++#if !defined(DUK_CAUSE_SEGFAULT)+/* This can be used for testing; valgrind will then indicate the C call stack+ * leading to the call site.+ */+#define DUK_CAUSE_SEGFAULT()  do { *((volatile duk_uint32_t *) NULL) = (duk_uint32_t) 0xdeadbeefUL; } while (0)+#endif++#if !defined(DUK_UNREF)+/* Macro for suppressing warnings for potentially unreferenced variables.+ * The variables can be actually unreferenced or unreferenced in some+ * specific cases only; for instance, if a variable is only debug printed,+ * it is unreferenced when debug printing is disabled.  May cause warnings+ * for volatile arguments.+ */+#define DUK_UNREF(x)  do { (void) (x); } while (0)+#endif++/* Fillin for DUK_NORETURN; DUK_WO_NORETURN() is used to insert dummy+ * dummy statements after noreturn calls to silence harmless compiler+ * warnings, e.g.:+ *+ *   DUK_ERROR_TYPE(thr, "aiee");+ *   DUK_WO_NORETURN(return 0;);+ *+ * Statements inside DUK_WO_NORETURN() must NEVER be actually reachable,+ * and they're only included to satisfy the compiler.+ */+#if defined(DUK_NORETURN)+#define DUK_WO_NORETURN(stmt) do { } while (0)+#else+#define DUK_NORETURN(decl)  decl+#define DUK_WO_NORETURN(stmt) do { stmt } while (0)+#endif++#if !defined(DUK_UNREACHABLE)+/* Don't know how to declare unreachable point, so don't do it; this+ * may cause some spurious compilation warnings (e.g. "variable used+ * uninitialized").+ */+#define DUK_UNREACHABLE()  do { } while (0)+#endif++#if !defined(DUK_LOSE_CONST)+/* Convert any input pointer into a "void *", losing a const qualifier.+ * This is not fully portable because casting through duk_uintptr_t may+ * not work on all architectures (e.g. those with long, segmented pointers).+ */+#define DUK_LOSE_CONST(src) ((void *) (duk_uintptr_t) (src))+#endif++#if !defined(DUK_LIKELY)+#define DUK_LIKELY(x)    (x)+#endif+#if !defined(DUK_UNLIKELY)+#define DUK_UNLIKELY(x)  (x)+#endif+#if !defined(DUK_UNPREDICTABLE)+#define DUK_UNPREDICTABLE(x)  (x)+#endif++#if !defined(DUK_NOINLINE)+#define DUK_NOINLINE       /*nop*/+#endif+#if !defined(DUK_INLINE)+#define DUK_INLINE         /*nop*/+#endif+#if !defined(DUK_ALWAYS_INLINE)+#define DUK_ALWAYS_INLINE  /*nop*/+#endif++#if !defined(DUK_HOT)+#define DUK_HOT            /*nop*/+#endif+#if !defined(DUK_COLD)+#define DUK_COLD           /*nop*/+#endif++#if !defined(DUK_EXTERNAL_DECL)+#define DUK_EXTERNAL_DECL  extern+#endif+#if !defined(DUK_EXTERNAL)+#define DUK_EXTERNAL       /*empty*/+#endif+#if !defined(DUK_INTERNAL_DECL)+#if defined(DUK_SINGLE_FILE)+#define DUK_INTERNAL_DECL  static+#else+#define DUK_INTERNAL_DECL  extern+#endif+#endif+#if !defined(DUK_INTERNAL)+#if defined(DUK_SINGLE_FILE)+#define DUK_INTERNAL       static+#else+#define DUK_INTERNAL       /*empty*/+#endif+#endif+#if !defined(DUK_LOCAL_DECL)+#define DUK_LOCAL_DECL     static+#endif+#if !defined(DUK_LOCAL)+#define DUK_LOCAL          static+#endif++#if !defined(DUK_FILE_MACRO)+#define DUK_FILE_MACRO  __FILE__+#endif+#if !defined(DUK_LINE_MACRO)+#define DUK_LINE_MACRO  __LINE__+#endif+#if !defined(DUK_FUNC_MACRO)+#if defined(DUK_F_C99) || defined(DUK_F_CPP11)+#define DUK_FUNC_MACRO  __func__+#elif defined(__FUNCTION__)+#define DUK_FUNC_MACRO  __FUNCTION__+#else+#define DUK_FUNC_MACRO  "unknown"+#endif+#endif++#if !defined(DUK_BSWAP32)+#define DUK_BSWAP32(x) \+	((((duk_uint32_t) (x)) >> 24) | \+	 ((((duk_uint32_t) (x)) >> 8) & 0xff00UL) | \+	 ((((duk_uint32_t) (x)) << 8) & 0xff0000UL) | \+	 (((duk_uint32_t) (x)) << 24))+#endif+#if !defined(DUK_BSWAP16)+#define DUK_BSWAP16(x) \+	((duk_uint16_t) (x) >> 8) | \+	((duk_uint16_t) (x) << 8)+#endif++/* DUK_USE_VARIADIC_MACROS: required from compilers, so no fill-in. */+/* DUK_USE_UNION_INITIALIZERS: required from compilers, so no fill-in. */++#if !(defined(DUK_USE_FLEX_C99) || defined(DUK_USE_FLEX_ZEROSIZE) || defined(DUK_USE_FLEX_ONESIZE))+#if defined(DUK_F_C99)+#define DUK_USE_FLEX_C99+#else+#define DUK_USE_FLEX_ZEROSIZE  /* Not standard but common enough */+#endif+#endif++#if !(defined(DUK_USE_PACK_GCC_ATTR) || defined(DUK_USE_PACK_CLANG_ATTR) || \+      defined(DUK_USE_PACK_MSVC_PRAGMA) || defined(DUK_USE_PACK_DUMMY_MEMBER))+#define DUK_USE_PACK_DUMMY_MEMBER+#endif++#if 0  /* not defined by default */+#undef DUK_USE_GCC_PRAGMAS+#endif++#if !defined(DUK_U64_CONSTANT)+#define DUK_U64_CONSTANT(x) x##ULL+#endif+#if !defined(DUK_I64_CONSTANT)+#define DUK_I64_CONSTANT(x) x##LL+#endif++/* Workaround for GH-323: avoid inlining control when compiling from+ * multiple sources, as it causes compiler portability trouble.+ */+#if !defined(DUK_SINGLE_FILE)+#undef DUK_NOINLINE+#undef DUK_INLINE+#undef DUK_ALWAYS_INLINE+#define DUK_NOINLINE       /*nop*/+#define DUK_INLINE         /*nop*/+#define DUK_ALWAYS_INLINE  /*nop*/+#endif++/*+ *  Check whether or not a packed duk_tval representation is possible.+ *  What's basically required is that pointers are 32-bit values+ *  (sizeof(void *) == 4).  Best effort check, not always accurate.+ *  If guess goes wrong, crashes may result; self tests also verify+ *  the guess.+ */++/* Explicit marker needed; may be 'defined', 'undefined, 'or 'not provided'. */+#if !defined(DUK_F_PACKED_TVAL_PROVIDED)+#undef DUK_F_PACKED_TVAL_POSSIBLE++/* Strict C99 case: DUK_UINTPTR_MAX (= UINTPTR_MAX) should be very reliable */+#if !defined(DUK_F_PACKED_TVAL_POSSIBLE) && defined(DUK_UINTPTR_MAX)+#if (DUK_UINTPTR_MAX <= 0xffffffffUL)+#define DUK_F_PACKED_TVAL_POSSIBLE+#endif+#endif++/* Non-C99 case, still relying on DUK_UINTPTR_MAX, as long as it is not a computed value */+#if !defined(DUK_F_PACKED_TVAL_POSSIBLE) && defined(DUK_UINTPTR_MAX) && !defined(DUK_UINTPTR_MAX_COMPUTED)+#if (DUK_UINTPTR_MAX <= 0xffffffffUL)+#define DUK_F_PACKED_TVAL_POSSIBLE+#endif+#endif++/* DUK_SIZE_MAX (= SIZE_MAX) is often reliable */+#if !defined(DUK_F_PACKED_TVAL_POSSIBLE) && defined(DUK_SIZE_MAX) && !defined(DUK_SIZE_MAX_COMPUTED)+#if (DUK_SIZE_MAX <= 0xffffffffUL)+#define DUK_F_PACKED_TVAL_POSSIBLE+#endif+#endif++#undef DUK_USE_PACKED_TVAL+#if defined(DUK_F_PACKED_TVAL_POSSIBLE)+#define DUK_USE_PACKED_TVAL+#endif+#undef DUK_F_PACKED_TVAL_POSSIBLE++#endif  /* DUK_F_PACKED_TVAL_PROVIDED */+/* Object property allocation layout has implications for memory and code+ * footprint and generated code size/speed.  The best layout also depends+ * on whether the platform has alignment requirements or benefits from+ * having mostly aligned accesses.+ */+#undef DUK_USE_HOBJECT_LAYOUT_1+#undef DUK_USE_HOBJECT_LAYOUT_2+#undef DUK_USE_HOBJECT_LAYOUT_3+#if (DUK_USE_ALIGN_BY == 1)+/* On platforms without any alignment issues, layout 1 is preferable+ * because it compiles to slightly less code and provides direct access+ * to property keys.+ */+#define DUK_USE_HOBJECT_LAYOUT_1+#else+/* On other platforms use layout 2, which requires some padding but+ * is a bit more natural than layout 3 in ordering the entries.  Layout+ * 3 is currently not used.+ */+#define DUK_USE_HOBJECT_LAYOUT_2+#endif++/* GCC/clang inaccurate math would break compliance and probably duk_tval,+ * so refuse to compile.  Relax this if -ffast-math is tested to work.+ */+#if defined(__FAST_MATH__)+#error __FAST_MATH__ defined, refusing to compile+#endif++/*+ *  Forced options+ */++extern duk_bool_t hsduk_exec_timeout_check(void *udata);+#define DUK_USE_EXEC_TIMEOUT_CHECK(udata) hsduk_exec_timeout_check(udata)++#define DUK_USE_INTERRUPT_COUNTER++/*+ *  Autogenerated defaults+ */++#undef DUK_USE_ALLOW_UNDEFINED_BEHAVIOR+#define DUK_USE_ARRAY_BUILTIN+#define DUK_USE_ARRAY_FASTPATH+#define DUK_USE_ARRAY_PROP_FASTPATH+#undef DUK_USE_ASSERTIONS+#define DUK_USE_AUGMENT_ERROR_CREATE+#define DUK_USE_AUGMENT_ERROR_THROW+#define DUK_USE_AVOID_PLATFORM_FUNCPTRS+#define DUK_USE_BASE64_FASTPATH+#define DUK_USE_BASE64_SUPPORT+#define DUK_USE_BOOLEAN_BUILTIN+#define DUK_USE_BUFFEROBJECT_SUPPORT+#undef DUK_USE_BUFLEN16+#define DUK_USE_BYTECODE_DUMP_SUPPORT+#define DUK_USE_CACHE_ACTIVATION+#define DUK_USE_CACHE_CATCHER+#define DUK_USE_CALLSTACK_LIMIT 10000+#define DUK_USE_COMMONJS_MODULES+#define DUK_USE_COMPILER_RECLIMIT 2500+#define DUK_USE_COROUTINE_SUPPORT+#undef DUK_USE_CPP_EXCEPTIONS+#undef DUK_USE_DATAPTR16+#undef DUK_USE_DATAPTR_DEC16+#undef DUK_USE_DATAPTR_ENC16+#define DUK_USE_DATE_BUILTIN+#undef DUK_USE_DATE_FORMAT_STRING+#undef DUK_USE_DATE_GET_LOCAL_TZOFFSET+#undef DUK_USE_DATE_GET_NOW+#undef DUK_USE_DATE_PARSE_STRING+#undef DUK_USE_DATE_PRS_GETDATE+#undef DUK_USE_DEBUG+#undef DUK_USE_DEBUGGER_DUMPHEAP+#undef DUK_USE_DEBUGGER_INSPECT+#undef DUK_USE_DEBUGGER_PAUSE_UNCAUGHT+#undef DUK_USE_DEBUGGER_SUPPORT+#define DUK_USE_DEBUGGER_THROW_NOTIFY+#undef DUK_USE_DEBUGGER_TRANSPORT_TORTURE+#define DUK_USE_DEBUG_BUFSIZE 65536L+#define DUK_USE_DEBUG_LEVEL 0+#undef DUK_USE_DEBUG_WRITE+#define DUK_USE_DOUBLE_LINKED_HEAP+#define DUK_USE_DUKTAPE_BUILTIN+#define DUK_USE_ENCODING_BUILTINS+#define DUK_USE_ERRCREATE+#define DUK_USE_ERRTHROW+#define DUK_USE_ES6+#define DUK_USE_ES6_OBJECT_PROTO_PROPERTY+#define DUK_USE_ES6_OBJECT_SETPROTOTYPEOF+#define DUK_USE_ES6_PROXY+#define DUK_USE_ES6_REGEXP_SYNTAX+#define DUK_USE_ES6_UNICODE_ESCAPE+#define DUK_USE_ES7+#define DUK_USE_ES7_EXP_OPERATOR+#define DUK_USE_ES8+#define DUK_USE_ES9+#define DUK_USE_ESBC_LIMITS+#define DUK_USE_ESBC_MAX_BYTES 2147418112L+#define DUK_USE_ESBC_MAX_LINENUMBER 2147418112L+#undef DUK_USE_EXEC_FUN_LOCAL+#undef DUK_USE_EXEC_INDIRECT_BOUND_CHECK+#undef DUK_USE_EXEC_PREFER_SIZE+#define DUK_USE_EXEC_REGCONST_OPTIMIZE+#undef DUK_USE_EXPLICIT_NULL_INIT+#undef DUK_USE_EXTSTR_FREE+#undef DUK_USE_EXTSTR_INTERN_CHECK+#undef DUK_USE_FASTINT+#define DUK_USE_FAST_REFCOUNT_DEFAULT+#undef DUK_USE_FATAL_HANDLER+#define DUK_USE_FATAL_MAXLEN 128+#define DUK_USE_FINALIZER_SUPPORT+#undef DUK_USE_FINALIZER_TORTURE+#undef DUK_USE_FUNCPTR16+#undef DUK_USE_FUNCPTR_DEC16+#undef DUK_USE_FUNCPTR_ENC16+#define DUK_USE_FUNCTION_BUILTIN+#define DUK_USE_FUNC_FILENAME_PROPERTY+#define DUK_USE_FUNC_NAME_PROPERTY+#undef DUK_USE_GC_TORTURE+#undef DUK_USE_GET_MONOTONIC_TIME+#undef DUK_USE_GET_RANDOM_DOUBLE+#undef DUK_USE_GLOBAL_BINDING+#define DUK_USE_GLOBAL_BUILTIN+#undef DUK_USE_HEAPPTR16+#undef DUK_USE_HEAPPTR_DEC16+#undef DUK_USE_HEAPPTR_ENC16+#define DUK_USE_HEX_FASTPATH+#define DUK_USE_HEX_SUPPORT+#define DUK_USE_HOBJECT_ARRAY_ABANDON_LIMIT 2+#define DUK_USE_HOBJECT_ARRAY_FAST_RESIZE_LIMIT 9+#define DUK_USE_HOBJECT_ARRAY_MINGROW_ADD 16+#define DUK_USE_HOBJECT_ARRAY_MINGROW_DIVISOR 8+#define DUK_USE_HOBJECT_ENTRY_MINGROW_ADD 16+#define DUK_USE_HOBJECT_ENTRY_MINGROW_DIVISOR 8+#define DUK_USE_HOBJECT_HASH_PART+#define DUK_USE_HOBJECT_HASH_PROP_LIMIT 8+#define DUK_USE_HSTRING_ARRIDX+#define DUK_USE_HSTRING_CLEN+#undef DUK_USE_HSTRING_EXTDATA+#define DUK_USE_HSTRING_LAZY_CLEN+#define DUK_USE_HTML_COMMENTS+#define DUK_USE_IDCHAR_FASTPATH+#undef DUK_USE_INJECT_HEAP_ALLOC_ERROR+#undef DUK_USE_INTERRUPT_DEBUG_FIXUP+#define DUK_USE_JC+#define DUK_USE_JSON_BUILTIN+#define DUK_USE_JSON_DECNUMBER_FASTPATH+#define DUK_USE_JSON_DECSTRING_FASTPATH+#define DUK_USE_JSON_DEC_RECLIMIT 1000+#define DUK_USE_JSON_EATWHITE_FASTPATH+#define DUK_USE_JSON_ENC_RECLIMIT 1000+#define DUK_USE_JSON_QUOTESTRING_FASTPATH+#undef DUK_USE_JSON_STRINGIFY_FASTPATH+#define DUK_USE_JSON_SUPPORT+#define DUK_USE_JX+#define DUK_USE_LEXER_SLIDING_WINDOW+#undef DUK_USE_LIGHTFUNC_BUILTINS+#define DUK_USE_LITCACHE_SIZE 256+#define DUK_USE_MARK_AND_SWEEP_RECLIMIT 256+#define DUK_USE_MATH_BUILTIN+#define DUK_USE_NATIVE_CALL_RECLIMIT 1000+#define DUK_USE_NONSTD_ARRAY_SPLICE_DELCOUNT+#undef DUK_USE_NONSTD_FUNC_CALLER_PROPERTY+#undef DUK_USE_NONSTD_FUNC_SOURCE_PROPERTY+#define DUK_USE_NONSTD_FUNC_STMT+#define DUK_USE_NONSTD_GETTER_KEY_ARGUMENT+#define DUK_USE_NONSTD_JSON_ESC_U2028_U2029+#define DUK_USE_NONSTD_SETTER_KEY_ARGUMENT+#define DUK_USE_NONSTD_STRING_FROMCHARCODE_32BIT+#define DUK_USE_NUMBER_BUILTIN+#define DUK_USE_OBJECT_BUILTIN+#undef DUK_USE_OBJSIZES16+#undef DUK_USE_PARANOID_ERRORS+#define DUK_USE_PC2LINE+#define DUK_USE_PERFORMANCE_BUILTIN+#undef DUK_USE_PREFER_SIZE+#undef DUK_USE_PROMISE_BUILTIN+#define DUK_USE_PROVIDE_DEFAULT_ALLOC_FUNCTIONS+#undef DUK_USE_REFCOUNT16+#define DUK_USE_REFCOUNT32+#define DUK_USE_REFERENCE_COUNTING+#define DUK_USE_REFLECT_BUILTIN+#define DUK_USE_REGEXP_CANON_BITMAP+#undef DUK_USE_REGEXP_CANON_WORKAROUND+#define DUK_USE_REGEXP_COMPILER_RECLIMIT 10000+#define DUK_USE_REGEXP_EXECUTOR_RECLIMIT 10000+#define DUK_USE_REGEXP_SUPPORT+#undef DUK_USE_ROM_GLOBAL_CLONE+#undef DUK_USE_ROM_GLOBAL_INHERIT+#undef DUK_USE_ROM_OBJECTS+#define DUK_USE_ROM_PTRCOMP_FIRST 63488L+#undef DUK_USE_ROM_STRINGS+#define DUK_USE_SECTION_B+#undef DUK_USE_SELF_TESTS+#define DUK_USE_SHEBANG_COMMENTS+#undef DUK_USE_SHUFFLE_TORTURE+#define DUK_USE_SOURCE_NONBMP+#undef DUK_USE_STRHASH16+#undef DUK_USE_STRHASH_DENSE+#define DUK_USE_STRHASH_SKIP_SHIFT 5+#define DUK_USE_STRICT_DECL+#undef DUK_USE_STRICT_UTF8_SOURCE+#define DUK_USE_STRING_BUILTIN+#undef DUK_USE_STRLEN16+#define DUK_USE_STRTAB_GROW_LIMIT 17+#define DUK_USE_STRTAB_MAXSIZE 268435456L+#define DUK_USE_STRTAB_MINSIZE 1024+#undef DUK_USE_STRTAB_PTRCOMP+#define DUK_USE_STRTAB_RESIZE_CHECK_MASK 255+#define DUK_USE_STRTAB_SHRINK_LIMIT 6+#undef DUK_USE_STRTAB_TORTURE+#undef DUK_USE_SYMBOL_BUILTIN+#define DUK_USE_TAILCALL+#define DUK_USE_TARGET_INFO "unknown"+#define DUK_USE_TRACEBACKS+#define DUK_USE_TRACEBACK_DEPTH 10+#define DUK_USE_USER_DECLARE() /* no user declarations */+#define DUK_USE_VALSTACK_GROW_SHIFT 2+#define DUK_USE_VALSTACK_LIMIT 1000000L+#define DUK_USE_VALSTACK_SHRINK_CHECK_SHIFT 2+#define DUK_USE_VALSTACK_SHRINK_SLACK_SHIFT 4+#undef DUK_USE_VALSTACK_UNSAFE+#define DUK_USE_VERBOSE_ERRORS+#define DUK_USE_VERBOSE_EXECUTOR_ERRORS+#define DUK_USE_VOLUNTARY_GC+#define DUK_USE_ZERO_BUFFER_DATA++/*+ *  You may add overriding #define/#undef directives below for+ *  customization.  You of course cannot un-#include or un-typedef+ *  anything; these require direct changes above.+ */++/* __OVERRIDE_DEFINES__ */++/*+ *  Conditional includes+ */++#if defined(DUK_F_CPP) && defined(DUK_USE_CPP_EXCEPTIONS)+#include <exception>  /* std::exception */+#include <stdexcept>  /* std::runtime_error */+#endif++/*+ *  Date provider selection+ *+ *  User may define DUK_USE_DATE_GET_NOW() etc directly, in which case we'll+ *  rely on an external provider.  If this is not done, revert to previous+ *  behavior and use Unix/Windows built-in provider.+ */++#if defined(DUK_COMPILING_DUKTAPE)++#if defined(DUK_USE_DATE_GET_NOW)+/* External provider already defined. */+#elif defined(DUK_USE_DATE_NOW_GETTIMEOFDAY)+#define DUK_USE_DATE_GET_NOW(ctx)            duk_bi_date_get_now_gettimeofday()+#elif defined(DUK_USE_DATE_NOW_TIME)+#define DUK_USE_DATE_GET_NOW(ctx)            duk_bi_date_get_now_time()+#elif defined(DUK_USE_DATE_NOW_WINDOWS)+#define DUK_USE_DATE_GET_NOW(ctx)            duk_bi_date_get_now_windows()+#elif defined(DUK_USE_DATE_NOW_WINDOWS_SUBMS)+#define DUK_USE_DATE_GET_NOW(ctx)            duk_bi_date_get_now_windows_subms()+#else+#error no provider for DUK_USE_DATE_GET_NOW()+#endif++#if defined(DUK_USE_DATE_GET_LOCAL_TZOFFSET)+/* External provider already defined. */+#elif defined(DUK_USE_DATE_TZO_GMTIME_R) || defined(DUK_USE_DATE_TZO_GMTIME_S) || defined(DUK_USE_DATE_TZO_GMTIME)+#define DUK_USE_DATE_GET_LOCAL_TZOFFSET(d)   duk_bi_date_get_local_tzoffset_gmtime((d))+#elif defined(DUK_USE_DATE_TZO_WINDOWS)+#define DUK_USE_DATE_GET_LOCAL_TZOFFSET(d)   duk_bi_date_get_local_tzoffset_windows((d))+#elif defined(DUK_USE_DATE_TZO_WINDOWS_NO_DST)+#define DUK_USE_DATE_GET_LOCAL_TZOFFSET(d)   duk_bi_date_get_local_tzoffset_windows_no_dst((d))+#else+#error no provider for DUK_USE_DATE_GET_LOCAL_TZOFFSET()+#endif++#if defined(DUK_USE_DATE_PARSE_STRING)+/* External provider already defined. */+#elif defined(DUK_USE_DATE_PRS_STRPTIME)+#define DUK_USE_DATE_PARSE_STRING(ctx,str)   duk_bi_date_parse_string_strptime((ctx), (str))+#elif defined(DUK_USE_DATE_PRS_GETDATE)+#define DUK_USE_DATE_PARSE_STRING(ctx,str)   duk_bi_date_parse_string_getdate((ctx), (str))+#else+/* No provider for DUK_USE_DATE_PARSE_STRING(), fall back to ISO 8601 only. */+#endif++#if defined(DUK_USE_DATE_FORMAT_STRING)+/* External provider already defined. */+#elif defined(DUK_USE_DATE_FMT_STRFTIME)+#define DUK_USE_DATE_FORMAT_STRING(ctx,parts,tzoffset,flags) \+	duk_bi_date_format_parts_strftime((ctx), (parts), (tzoffset), (flags))+#else+/* No provider for DUK_USE_DATE_FORMAT_STRING(), fall back to ISO 8601 only. */+#endif++#if defined(DUK_USE_GET_MONOTONIC_TIME)+/* External provider already defined. */+#elif defined(DUK_USE_GET_MONOTONIC_TIME_CLOCK_GETTIME)+#define DUK_USE_GET_MONOTONIC_TIME(ctx)  duk_bi_date_get_monotonic_time_clock_gettime()+#elif defined(DUK_USE_GET_MONOTONIC_TIME_WINDOWS_QPC)+#define DUK_USE_GET_MONOTONIC_TIME(ctx)  duk_bi_date_get_monotonic_time_windows_qpc()+#else+/* No provider for DUK_USE_GET_MONOTONIC_TIME(), fall back to DUK_USE_DATE_GET_NOW(). */+#endif++#endif  /* DUK_COMPILING_DUKTAPE */++/*+ *  Convert DUK_USE_BYTEORDER, from whatever source, into currently used+ *  internal defines.  If detection failed, #error out.+ */++#if defined(DUK_USE_BYTEORDER)+#if (DUK_USE_BYTEORDER == 1)+#define DUK_USE_INTEGER_LE+#define DUK_USE_DOUBLE_LE+#elif (DUK_USE_BYTEORDER == 2)+#define DUK_USE_INTEGER_LE  /* integer endianness is little on purpose */+#define DUK_USE_DOUBLE_ME+#elif (DUK_USE_BYTEORDER == 3)+#define DUK_USE_INTEGER_BE+#define DUK_USE_DOUBLE_BE+#else+#error unsupported: byte order invalid+#endif  /* byte order */+#else+#error unsupported: byte order detection failed+#endif  /* defined(DUK_USE_BYTEORDER) */++#endif  /* DUK_CONFIG_H_INCLUDED */
+ dukconfig/dist/duktape.c view

file too large to diff

+ dukconfig/dist/duktape.h view
@@ -0,0 +1,1419 @@+/*+ *  Duktape public API for Duktape 2.3.0.+ *+ *  See the API reference for documentation on call semantics.  The exposed,+ *  supported API is between the "BEGIN PUBLIC API" and "END PUBLIC API"+ *  comments.  Other parts of the header are Duktape internal and related to+ *  e.g. platform/compiler/feature detection.+ *+ *  Git commit e3714f4c48935824ac6589137b66237217f6da7f (v0.1.5-24-ge3714f4-dirty).+ *  Git branch master.+ *+ *  See Duktape AUTHORS.rst and LICENSE.txt for copyright and+ *  licensing information.+ */++/* LICENSE.txt */+/*+ *  ===============+ *  Duktape license+ *  ===============+ *  + *  (http://opensource.org/licenses/MIT)+ *  + *  Copyright (c) 2013-2018 by Duktape authors (see AUTHORS.rst)+ *  + *  Permission is hereby granted, free of charge, to any person obtaining a copy+ *  of this software and associated documentation files (the "Software"), to deal+ *  in the Software without restriction, including without limitation the rights+ *  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell+ *  copies of the Software, and to permit persons to whom the Software is+ *  furnished to do so, subject to the following conditions:+ *  + *  The above copyright notice and this permission notice shall be included in+ *  all copies or substantial portions of the Software.+ *  + *  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR+ *  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,+ *  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE+ *  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER+ *  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,+ *  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN+ *  THE SOFTWARE.+ */++/* AUTHORS.rst */+/*+ *  ===============+ *  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 <sami.vaarala@iki.fi>+ *  * Niki Dobrev+ *  * Andreas \u00d6man <andreas@lonelycoder.com>+ *  * L\u00e1szl\u00f3 Lang\u00f3 <llango.u-szeged@partner.samsung.com>+ *  * Legimet <legimet.calc@gmail.com>+ *  * Karl Skomski <karl@skomski.com>+ *  * Bruce Pascoe <fatcerberus1@gmail.com>+ *  * Ren\u00e9 Hollander <rene@rene8888.at>+ *  * Julien Hamaide (https://github.com/crazyjul)+ *  * Sebastian G\u00f6tte (https://github.com/jaseg)+ *  * Tomasz Magulski (https://github.com/magul)+ *  * \D. Bohdan (https://github.com/dbohdan)+ *  * Ond\u0159ej Jirman (https://github.com/megous)+ *  * Sa\u00fal Ibarra Corretg\u00e9 <saghul@gmail.com>+ *  * Jeremy HU <huxingyi@msn.com>+ *  * Ole Andr\u00e9 Vadla Ravn\u00e5s (https://github.com/oleavr)+ *  * Harold Brenes (https://github.com/harold-b)+ *  * Oliver Crow (https://github.com/ocrow)+ *  * Jakub Ch\u0142api\u0144ski (https://github.com/jchlapinski)+ *  * Brett Vickers (https://github.com/beevik)+ *  * Dominik Okwieka (https://github.com/okitec)+ *  * Remko Tron\u00e7on (https://el-tramo.be)+ *  * Romero Malaquias (rbsm@ic.ufal.br)+ *  * Michael Drake <michael.drake@codethink.co.uk>+ *  * 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)+ *  + *  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\u00e9lien Bouilland+ *  * Preet Desai (Pris Matic)+ *  * judofyr (http://www.reddit.com/user/judofyr)+ *  * Jason Woofenden+ *  * Micha\u0142 Przyby\u015b+ *  * Anthony Howe+ *  * Conrad Pankoff+ *  * Jim Schimpf+ *  * Rajaran Gaunker (https://github.com/zimbabao)+ *  * Andreas \u00d6man+ *  * 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)+ *  + *  If you are accidentally missing from this list, send me an e-mail+ *  (``sami.vaarala@iki.fi``) and I'll fix the omission.+ */++#if !defined(DUKTAPE_H_INCLUDED)+#define DUKTAPE_H_INCLUDED++#define DUK_SINGLE_FILE++/*+ *  BEGIN PUBLIC API+ */++/*+ *  Version and Git commit identification+ */++/* Duktape version, (major * 10000) + (minor * 100) + patch.  Allows C code+ * to #if (DUK_VERSION >= NNN) against Duktape API version.  The same value+ * is also available to ECMAScript code in Duktape.version.  Unofficial+ * development snapshots have 99 for patch level (e.g. 0.10.99 would be a+ * development version after 0.10.0 but before the next official release).+ */+#define DUK_VERSION                       20300L++/* Git commit, describe, and branch for Duktape build.  Useful for+ * non-official snapshot builds so that application code can easily log+ * which Duktape snapshot was used.  Not available in the ECMAScript+ * environment.+ */+#define DUK_GIT_COMMIT                    "e3714f4c48935824ac6589137b66237217f6da7f"+#define DUK_GIT_DESCRIBE                  "v0.1.5-24-ge3714f4-dirty"+#define DUK_GIT_BRANCH                    "master"++/* External duk_config.h provides platform/compiler/OS dependent+ * typedefs and macros, and DUK_USE_xxx config options so that+ * the rest of Duktape doesn't need to do any feature detection.+ * DUK_VERSION is defined before including so that configuration+ * snippets can react to it.+ */+#include "duk_config.h"++/*+ *  Avoid C++ name mangling+ */++#if defined(__cplusplus)+extern "C" {+#endif++/*+ *  Some defines forwarded from feature detection+ */++#undef DUK_API_VARIADIC_MACROS+#if defined(DUK_USE_VARIADIC_MACROS)+#define DUK_API_VARIADIC_MACROS+#endif++#define DUK_API_NORETURN(decl) DUK_NORETURN(decl)++/*+ *  Public API specific typedefs+ *+ *  Many types are wrapped by Duktape for portability to rare platforms+ *  where e.g. 'int' is a 16-bit type.  See practical typing discussion+ *  in Duktape web documentation.+ */++struct duk_thread_state;+struct duk_memory_functions;+struct duk_function_list_entry;+struct duk_number_list_entry;+struct duk_time_components;++/* duk_context is now defined in duk_config.h because it may also be+ * referenced there by prototypes.+ */+typedef struct duk_thread_state duk_thread_state;+typedef struct duk_memory_functions duk_memory_functions;+typedef struct duk_function_list_entry duk_function_list_entry;+typedef struct duk_number_list_entry duk_number_list_entry;+typedef struct duk_time_components duk_time_components;++typedef duk_ret_t (*duk_c_function)(duk_context *ctx);+typedef void *(*duk_alloc_function) (void *udata, duk_size_t size);+typedef void *(*duk_realloc_function) (void *udata, void *ptr, duk_size_t size);+typedef void (*duk_free_function) (void *udata, void *ptr);+typedef void (*duk_fatal_function) (void *udata, const char *msg);+typedef void (*duk_decode_char_function) (void *udata, duk_codepoint_t codepoint);+typedef duk_codepoint_t (*duk_map_char_function) (void *udata, duk_codepoint_t codepoint);+typedef duk_ret_t (*duk_safe_call_function) (duk_context *ctx, void *udata);+typedef duk_size_t (*duk_debug_read_function) (void *udata, char *buffer, duk_size_t length);+typedef duk_size_t (*duk_debug_write_function) (void *udata, const char *buffer, duk_size_t length);+typedef duk_size_t (*duk_debug_peek_function) (void *udata);+typedef void (*duk_debug_read_flush_function) (void *udata);+typedef void (*duk_debug_write_flush_function) (void *udata);+typedef duk_idx_t (*duk_debug_request_function) (duk_context *ctx, void *udata, duk_idx_t nvalues);+typedef void (*duk_debug_detached_function) (duk_context *ctx, void *udata);++struct duk_thread_state {+	/* XXX: Enough space to hold internal suspend/resume structure.+	 * This is rather awkward and to be fixed when the internal+	 * structure is visible for the public API header.+	 */+	char data[128];+};++struct duk_memory_functions {+	duk_alloc_function alloc_func;+	duk_realloc_function realloc_func;+	duk_free_function free_func;+	void *udata;+};++struct duk_function_list_entry {+	const char *key;+	duk_c_function value;+	duk_idx_t nargs;+};++struct duk_number_list_entry {+	const char *key;+	duk_double_t value;+};++struct duk_time_components {+	duk_double_t year;          /* year, e.g. 2016, ECMAScript year range */+	duk_double_t month;         /* month: 1-12 */+	duk_double_t day;           /* day: 1-31 */+	duk_double_t hours;         /* hour: 0-59 */+	duk_double_t minutes;       /* minute: 0-59 */+	duk_double_t seconds;       /* second: 0-59 (in POSIX time no leap second) */+	duk_double_t milliseconds;  /* may contain sub-millisecond fractions */+	duk_double_t weekday;       /* weekday: 0-6, 0=Sunday, 1=Monday, ..., 6=Saturday */+};++/*+ *  Constants+ */++/* Duktape debug protocol version used by this build. */+#define DUK_DEBUG_PROTOCOL_VERSION        2++/* Used to represent invalid index; if caller uses this without checking,+ * this index will map to a non-existent stack entry.  Also used in some+ * API calls as a marker to denote "no value".+ */+#define DUK_INVALID_INDEX                 DUK_IDX_MIN++/* Indicates that a native function does not have a fixed number of args,+ * and the argument stack should not be capped/extended at all.+ */+#define DUK_VARARGS                       ((duk_int_t) (-1))++/* Number of value stack entries (in addition to actual call arguments)+ * guaranteed to be allocated on entry to a Duktape/C function.+ */+#define DUK_API_ENTRY_STACK               64U++/* Value types, used by e.g. duk_get_type() */+#define DUK_TYPE_MIN                      0U+#define DUK_TYPE_NONE                     0U    /* no value, e.g. invalid index */+#define DUK_TYPE_UNDEFINED                1U    /* ECMAScript undefined */+#define DUK_TYPE_NULL                     2U    /* ECMAScript null */+#define DUK_TYPE_BOOLEAN                  3U    /* ECMAScript boolean: 0 or 1 */+#define DUK_TYPE_NUMBER                   4U    /* ECMAScript number: double */+#define DUK_TYPE_STRING                   5U    /* ECMAScript string: CESU-8 / extended UTF-8 encoded */+#define DUK_TYPE_OBJECT                   6U    /* ECMAScript object: includes objects, arrays, functions, threads */+#define DUK_TYPE_BUFFER                   7U    /* fixed or dynamic, garbage collected byte buffer */+#define DUK_TYPE_POINTER                  8U    /* raw void pointer */+#define DUK_TYPE_LIGHTFUNC                9U    /* lightweight function pointer */+#define DUK_TYPE_MAX                      9U++/* Value mask types, used by e.g. duk_get_type_mask() */+#define DUK_TYPE_MASK_NONE                (1U << DUK_TYPE_NONE)+#define DUK_TYPE_MASK_UNDEFINED           (1U << DUK_TYPE_UNDEFINED)+#define DUK_TYPE_MASK_NULL                (1U << DUK_TYPE_NULL)+#define DUK_TYPE_MASK_BOOLEAN             (1U << DUK_TYPE_BOOLEAN)+#define DUK_TYPE_MASK_NUMBER              (1U << DUK_TYPE_NUMBER)+#define DUK_TYPE_MASK_STRING              (1U << DUK_TYPE_STRING)+#define DUK_TYPE_MASK_OBJECT              (1U << DUK_TYPE_OBJECT)+#define DUK_TYPE_MASK_BUFFER              (1U << DUK_TYPE_BUFFER)+#define DUK_TYPE_MASK_POINTER             (1U << DUK_TYPE_POINTER)+#define DUK_TYPE_MASK_LIGHTFUNC           (1U << DUK_TYPE_LIGHTFUNC)+#define DUK_TYPE_MASK_THROW               (1U << 10)  /* internal flag value: throw if mask doesn't match */+#define DUK_TYPE_MASK_PROMOTE             (1U << 11)  /* internal flag value: promote to object if mask matches */++/* Coercion hints */+#define DUK_HINT_NONE                     0    /* prefer number, unless input is a Date, in which+                                                * case prefer string (E5 Section 8.12.8)+                                                */+#define DUK_HINT_STRING                   1    /* prefer string */+#define DUK_HINT_NUMBER                   2    /* prefer number */++/* Enumeration flags for duk_enum() */+#define DUK_ENUM_INCLUDE_NONENUMERABLE    (1U << 0)    /* enumerate non-numerable properties in addition to enumerable */+#define DUK_ENUM_INCLUDE_HIDDEN           (1U << 1)    /* enumerate hidden symbols too (in Duktape 1.x called internal properties) */+#define DUK_ENUM_INCLUDE_SYMBOLS          (1U << 2)    /* enumerate symbols */+#define DUK_ENUM_EXCLUDE_STRINGS          (1U << 3)    /* exclude strings */+#define DUK_ENUM_OWN_PROPERTIES_ONLY      (1U << 4)    /* don't walk prototype chain, only check own properties */+#define DUK_ENUM_ARRAY_INDICES_ONLY       (1U << 5)    /* only enumerate array indices */+/* XXX: misleading name */+#define DUK_ENUM_SORT_ARRAY_INDICES       (1U << 6)    /* sort array indices (applied to full enumeration result, including inherited array indices); XXX: misleading name */+#define DUK_ENUM_NO_PROXY_BEHAVIOR        (1U << 7)    /* enumerate a proxy object itself without invoking proxy behavior */++/* Compilation flags for duk_compile() and duk_eval() */+/* DUK_COMPILE_xxx bits 0-2 are reserved for an internal 'nargs' argument.+ */+#define DUK_COMPILE_EVAL                  (1U << 3)    /* compile eval code (instead of global code) */+#define DUK_COMPILE_FUNCTION              (1U << 4)    /* compile function code (instead of global code) */+#define DUK_COMPILE_STRICT                (1U << 5)    /* use strict (outer) context for global, eval, or function code */+#define DUK_COMPILE_SHEBANG               (1U << 6)    /* allow shebang ('#! ...') comment on first line of source */+#define DUK_COMPILE_SAFE                  (1U << 7)    /* (internal) catch compilation errors */+#define DUK_COMPILE_NORESULT              (1U << 8)    /* (internal) omit eval result */+#define DUK_COMPILE_NOSOURCE              (1U << 9)    /* (internal) no source string on stack */+#define DUK_COMPILE_STRLEN                (1U << 10)   /* (internal) take strlen() of src_buffer (avoids double evaluation in macro) */+#define DUK_COMPILE_NOFILENAME            (1U << 11)   /* (internal) no filename on stack */+#define DUK_COMPILE_FUNCEXPR              (1U << 12)   /* (internal) source is a function expression (used for Function constructor) */++/* Flags for duk_def_prop() and its variants; base flags + a lot of convenience shorthands */+#define DUK_DEFPROP_WRITABLE              (1U << 0)    /* set writable (effective if DUK_DEFPROP_HAVE_WRITABLE set) */+#define DUK_DEFPROP_ENUMERABLE            (1U << 1)    /* set enumerable (effective if DUK_DEFPROP_HAVE_ENUMERABLE set) */+#define DUK_DEFPROP_CONFIGURABLE          (1U << 2)    /* set configurable (effective if DUK_DEFPROP_HAVE_CONFIGURABLE set) */+#define DUK_DEFPROP_HAVE_WRITABLE         (1U << 3)    /* set/clear writable */+#define DUK_DEFPROP_HAVE_ENUMERABLE       (1U << 4)    /* set/clear enumerable */+#define DUK_DEFPROP_HAVE_CONFIGURABLE     (1U << 5)    /* set/clear configurable */+#define DUK_DEFPROP_HAVE_VALUE            (1U << 6)    /* set value (given on value stack) */+#define DUK_DEFPROP_HAVE_GETTER           (1U << 7)    /* set getter (given on value stack) */+#define DUK_DEFPROP_HAVE_SETTER           (1U << 8)    /* set setter (given on value stack) */+#define DUK_DEFPROP_FORCE                 (1U << 9)    /* force change if possible, may still fail for e.g. virtual properties */+#define DUK_DEFPROP_SET_WRITABLE          (DUK_DEFPROP_HAVE_WRITABLE | DUK_DEFPROP_WRITABLE)+#define DUK_DEFPROP_CLEAR_WRITABLE        DUK_DEFPROP_HAVE_WRITABLE+#define DUK_DEFPROP_SET_ENUMERABLE        (DUK_DEFPROP_HAVE_ENUMERABLE | DUK_DEFPROP_ENUMERABLE)+#define DUK_DEFPROP_CLEAR_ENUMERABLE      DUK_DEFPROP_HAVE_ENUMERABLE+#define DUK_DEFPROP_SET_CONFIGURABLE      (DUK_DEFPROP_HAVE_CONFIGURABLE | DUK_DEFPROP_CONFIGURABLE)+#define DUK_DEFPROP_CLEAR_CONFIGURABLE    DUK_DEFPROP_HAVE_CONFIGURABLE+#define DUK_DEFPROP_W                     DUK_DEFPROP_WRITABLE+#define DUK_DEFPROP_E                     DUK_DEFPROP_ENUMERABLE+#define DUK_DEFPROP_C                     DUK_DEFPROP_CONFIGURABLE+#define DUK_DEFPROP_WE                    (DUK_DEFPROP_WRITABLE | DUK_DEFPROP_ENUMERABLE)+#define DUK_DEFPROP_WC                    (DUK_DEFPROP_WRITABLE | DUK_DEFPROP_CONFIGURABLE)+#define DUK_DEFPROP_WEC                   (DUK_DEFPROP_WRITABLE | DUK_DEFPROP_ENUMERABLE | DUK_DEFPROP_CONFIGURABLE)+#define DUK_DEFPROP_HAVE_W                DUK_DEFPROP_HAVE_WRITABLE+#define DUK_DEFPROP_HAVE_E                DUK_DEFPROP_HAVE_ENUMERABLE+#define DUK_DEFPROP_HAVE_C                DUK_DEFPROP_HAVE_CONFIGURABLE+#define DUK_DEFPROP_HAVE_WE               (DUK_DEFPROP_HAVE_WRITABLE | DUK_DEFPROP_HAVE_ENUMERABLE)+#define DUK_DEFPROP_HAVE_WC               (DUK_DEFPROP_HAVE_WRITABLE | DUK_DEFPROP_HAVE_CONFIGURABLE)+#define DUK_DEFPROP_HAVE_WEC              (DUK_DEFPROP_HAVE_WRITABLE | DUK_DEFPROP_HAVE_ENUMERABLE | DUK_DEFPROP_HAVE_CONFIGURABLE)+#define DUK_DEFPROP_SET_W                 DUK_DEFPROP_SET_WRITABLE+#define DUK_DEFPROP_SET_E                 DUK_DEFPROP_SET_ENUMERABLE+#define DUK_DEFPROP_SET_C                 DUK_DEFPROP_SET_CONFIGURABLE+#define DUK_DEFPROP_SET_WE                (DUK_DEFPROP_SET_WRITABLE | DUK_DEFPROP_SET_ENUMERABLE)+#define DUK_DEFPROP_SET_WC                (DUK_DEFPROP_SET_WRITABLE | DUK_DEFPROP_SET_CONFIGURABLE)+#define DUK_DEFPROP_SET_WEC               (DUK_DEFPROP_SET_WRITABLE | DUK_DEFPROP_SET_ENUMERABLE | DUK_DEFPROP_SET_CONFIGURABLE)+#define DUK_DEFPROP_CLEAR_W               DUK_DEFPROP_CLEAR_WRITABLE+#define DUK_DEFPROP_CLEAR_E               DUK_DEFPROP_CLEAR_ENUMERABLE+#define DUK_DEFPROP_CLEAR_C               DUK_DEFPROP_CLEAR_CONFIGURABLE+#define DUK_DEFPROP_CLEAR_WE              (DUK_DEFPROP_CLEAR_WRITABLE | DUK_DEFPROP_CLEAR_ENUMERABLE)+#define DUK_DEFPROP_CLEAR_WC              (DUK_DEFPROP_CLEAR_WRITABLE | DUK_DEFPROP_CLEAR_CONFIGURABLE)+#define DUK_DEFPROP_CLEAR_WEC             (DUK_DEFPROP_CLEAR_WRITABLE | DUK_DEFPROP_CLEAR_ENUMERABLE | DUK_DEFPROP_CLEAR_CONFIGURABLE)+#define DUK_DEFPROP_ATTR_W                (DUK_DEFPROP_HAVE_WEC | DUK_DEFPROP_W)+#define DUK_DEFPROP_ATTR_E                (DUK_DEFPROP_HAVE_WEC | DUK_DEFPROP_E)+#define DUK_DEFPROP_ATTR_C                (DUK_DEFPROP_HAVE_WEC | DUK_DEFPROP_C)+#define DUK_DEFPROP_ATTR_WE               (DUK_DEFPROP_HAVE_WEC | DUK_DEFPROP_WE)+#define DUK_DEFPROP_ATTR_WC               (DUK_DEFPROP_HAVE_WEC | DUK_DEFPROP_WC)+#define DUK_DEFPROP_ATTR_WEC              (DUK_DEFPROP_HAVE_WEC | DUK_DEFPROP_WEC)++/* Flags for duk_push_thread_raw() */+#define DUK_THREAD_NEW_GLOBAL_ENV         (1U << 0)    /* create a new global environment */++/* Flags for duk_gc() */+#define DUK_GC_COMPACT                    (1U << 0)    /* compact heap objects */++/* Error codes (must be 8 bits at most, see duk_error.h) */+#define DUK_ERR_NONE                      0    /* no error (e.g. from duk_get_error_code()) */+#define DUK_ERR_ERROR                     1    /* Error */+#define DUK_ERR_EVAL_ERROR                2    /* EvalError */+#define DUK_ERR_RANGE_ERROR               3    /* RangeError */+#define DUK_ERR_REFERENCE_ERROR           4    /* ReferenceError */+#define DUK_ERR_SYNTAX_ERROR              5    /* SyntaxError */+#define DUK_ERR_TYPE_ERROR                6    /* TypeError */+#define DUK_ERR_URI_ERROR                 7    /* URIError */++/* Return codes for C functions (shortcut for throwing an error) */+#define DUK_RET_ERROR                     (-DUK_ERR_ERROR)+#define DUK_RET_EVAL_ERROR                (-DUK_ERR_EVAL_ERROR)+#define DUK_RET_RANGE_ERROR               (-DUK_ERR_RANGE_ERROR)+#define DUK_RET_REFERENCE_ERROR           (-DUK_ERR_REFERENCE_ERROR)+#define DUK_RET_SYNTAX_ERROR              (-DUK_ERR_SYNTAX_ERROR)+#define DUK_RET_TYPE_ERROR                (-DUK_ERR_TYPE_ERROR)+#define DUK_RET_URI_ERROR                 (-DUK_ERR_URI_ERROR)++/* Return codes for protected calls (duk_safe_call(), duk_pcall()) */+#define DUK_EXEC_SUCCESS                  0+#define DUK_EXEC_ERROR                    1++/* Debug levels for DUK_USE_DEBUG_WRITE(). */+#define DUK_LEVEL_DEBUG                   0+#define DUK_LEVEL_DDEBUG                  1+#define DUK_LEVEL_DDDEBUG                 2++/*+ *  Macros to create Symbols as C statically constructed strings.+ *+ *  Call e.g. as DUK_HIDDEN_SYMBOL("myProperty") <=> ("\xFF" "myProperty").+ *  Local symbols have a unique suffix, caller should take care to avoid+ *  conflicting with the Duktape internal representation by e.g. prepending+ *  a '!' character: DUK_LOCAL_SYMBOL("myLocal", "!123").+ *+ *  Note that these can only be used for string constants, not dynamically+ *  created strings.+ */++#define DUK_HIDDEN_SYMBOL(x)     ("\xFF" x)+#define DUK_GLOBAL_SYMBOL(x)     ("\x80" x)+#define DUK_LOCAL_SYMBOL(x,uniq) ("\x81" x "\xff" uniq)+#define DUK_WELLKNOWN_SYMBOL(x)  ("\x81" x "\xff")++/*+ *  If no variadic macros, __FILE__ and __LINE__ are passed through globals+ *  which is ugly and not thread safe.+ */++#if !defined(DUK_API_VARIADIC_MACROS)+DUK_EXTERNAL_DECL const char *duk_api_global_filename;+DUK_EXTERNAL_DECL duk_int_t duk_api_global_line;+#endif++/*+ *  Context management+ */++DUK_EXTERNAL_DECL+duk_context *duk_create_heap(duk_alloc_function alloc_func,+                             duk_realloc_function realloc_func,+                             duk_free_function free_func,+                             void *heap_udata,+                             duk_fatal_function fatal_handler);+DUK_EXTERNAL_DECL void duk_destroy_heap(duk_context *ctx);++DUK_EXTERNAL_DECL void duk_suspend(duk_context *ctx, duk_thread_state *state);+DUK_EXTERNAL_DECL void duk_resume(duk_context *ctx, const duk_thread_state *state);++#define duk_create_heap_default() \+	duk_create_heap(NULL, NULL, NULL, NULL, NULL)++/*+ *  Memory management+ *+ *  Raw functions have no side effects (cannot trigger GC).+ */++DUK_EXTERNAL_DECL void *duk_alloc_raw(duk_context *ctx, duk_size_t size);+DUK_EXTERNAL_DECL void duk_free_raw(duk_context *ctx, void *ptr);+DUK_EXTERNAL_DECL void *duk_realloc_raw(duk_context *ctx, void *ptr, duk_size_t size);+DUK_EXTERNAL_DECL void *duk_alloc(duk_context *ctx, duk_size_t size);+DUK_EXTERNAL_DECL void duk_free(duk_context *ctx, void *ptr);+DUK_EXTERNAL_DECL void *duk_realloc(duk_context *ctx, void *ptr, duk_size_t size);+DUK_EXTERNAL_DECL void duk_get_memory_functions(duk_context *ctx, duk_memory_functions *out_funcs);+DUK_EXTERNAL_DECL void duk_gc(duk_context *ctx, duk_uint_t flags);++/*+ *  Error handling+ */++DUK_API_NORETURN(DUK_EXTERNAL_DECL void duk_throw_raw(duk_context *ctx));+#define duk_throw(ctx) \+	(duk_throw_raw((ctx)), (duk_ret_t) 0)+DUK_API_NORETURN(DUK_EXTERNAL_DECL void duk_fatal_raw(duk_context *ctx, const char *err_msg));+#define duk_fatal(ctx,err_msg) \+	(duk_fatal_raw((ctx), (err_msg)), (duk_ret_t) 0)+DUK_API_NORETURN(DUK_EXTERNAL_DECL void duk_error_raw(duk_context *ctx, duk_errcode_t err_code, const char *filename, duk_int_t line, const char *fmt, ...));++#if defined(DUK_API_VARIADIC_MACROS)+#define duk_error(ctx,err_code,...)  \+	(duk_error_raw((ctx), (duk_errcode_t) (err_code), (const char *) (DUK_FILE_MACRO), (duk_int_t) (DUK_LINE_MACRO), __VA_ARGS__), (duk_ret_t) 0)+#define duk_generic_error(ctx,...)  \+	(duk_error_raw((ctx), (duk_errcode_t) DUK_ERR_ERROR, (const char *) (DUK_FILE_MACRO), (duk_int_t) (DUK_LINE_MACRO), __VA_ARGS__), (duk_ret_t) 0)+#define duk_eval_error(ctx,...)  \+	(duk_error_raw((ctx), (duk_errcode_t) DUK_ERR_EVAL_ERROR, (const char *) (DUK_FILE_MACRO), (duk_int_t) (DUK_LINE_MACRO), __VA_ARGS__), (duk_ret_t) 0)+#define duk_range_error(ctx,...)  \+	(duk_error_raw((ctx), (duk_errcode_t) DUK_ERR_RANGE_ERROR, (const char *) (DUK_FILE_MACRO), (duk_int_t) (DUK_LINE_MACRO), __VA_ARGS__), (duk_ret_t) 0)+#define duk_reference_error(ctx,...)  \+	(duk_error_raw((ctx), (duk_errcode_t) DUK_ERR_REFERENCE_ERROR, (const char *) (DUK_FILE_MACRO), (duk_int_t) (DUK_LINE_MACRO), __VA_ARGS__), (duk_ret_t) 0)+#define duk_syntax_error(ctx,...)  \+	(duk_error_raw((ctx), (duk_errcode_t) DUK_ERR_SYNTAX_ERROR, (const char *) (DUK_FILE_MACRO), (duk_int_t) (DUK_LINE_MACRO), __VA_ARGS__), (duk_ret_t) 0)+#define duk_type_error(ctx,...)  \+	(duk_error_raw((ctx), (duk_errcode_t) DUK_ERR_TYPE_ERROR, (const char *) (DUK_FILE_MACRO), (duk_int_t) (DUK_LINE_MACRO), __VA_ARGS__), (duk_ret_t) 0)+#define duk_uri_error(ctx,...)  \+	(duk_error_raw((ctx), (duk_errcode_t) DUK_ERR_URI_ERROR, (const char *) (DUK_FILE_MACRO), (duk_int_t) (DUK_LINE_MACRO), __VA_ARGS__), (duk_ret_t) 0)+#else  /* DUK_API_VARIADIC_MACROS */+/* For legacy compilers without variadic macros a macro hack is used to allow+ * variable arguments.  While the macro allows "return duk_error(...)", it+ * will fail with e.g. "(void) duk_error(...)".  The calls are noreturn but+ * with a return value to allow the "return duk_error(...)" idiom.  This may+ * cause some compiler warnings, but without noreturn the generated code is+ * often worse.  The same approach as with variadic macros (using+ * "(duk_error(...), 0)") won't work due to the macro hack structure.+ */+DUK_API_NORETURN(DUK_EXTERNAL_DECL duk_ret_t duk_error_stash(duk_context *ctx, duk_errcode_t err_code, const char *fmt, ...));+DUK_API_NORETURN(DUK_EXTERNAL_DECL duk_ret_t duk_generic_error_stash(duk_context *ctx, const char *fmt, ...));+DUK_API_NORETURN(DUK_EXTERNAL_DECL duk_ret_t duk_eval_error_stash(duk_context *ctx, const char *fmt, ...));+DUK_API_NORETURN(DUK_EXTERNAL_DECL duk_ret_t duk_range_error_stash(duk_context *ctx, const char *fmt, ...));+DUK_API_NORETURN(DUK_EXTERNAL_DECL duk_ret_t duk_reference_error_stash(duk_context *ctx, const char *fmt, ...));+DUK_API_NORETURN(DUK_EXTERNAL_DECL duk_ret_t duk_syntax_error_stash(duk_context *ctx, const char *fmt, ...));+DUK_API_NORETURN(DUK_EXTERNAL_DECL duk_ret_t duk_type_error_stash(duk_context *ctx, const char *fmt, ...));+DUK_API_NORETURN(DUK_EXTERNAL_DECL duk_ret_t duk_uri_error_stash(duk_context *ctx, const char *fmt, ...));+#define duk_error  \+	(duk_api_global_filename = (const char *) (DUK_FILE_MACRO), \+	 duk_api_global_line = (duk_int_t) (DUK_LINE_MACRO), \+	 duk_error_stash)  /* last value is func pointer, arguments follow in parens */+#define duk_generic_error  \+	(duk_api_global_filename = (const char *) (DUK_FILE_MACRO), \+	 duk_api_global_line = (duk_int_t) (DUK_LINE_MACRO), \+	 duk_generic_error_stash)+#define duk_eval_error  \+	(duk_api_global_filename = (const char *) (DUK_FILE_MACRO), \+	 duk_api_global_line = (duk_int_t) (DUK_LINE_MACRO), \+	 duk_eval_error_stash)+#define duk_range_error  \+	(duk_api_global_filename = (const char *) (DUK_FILE_MACRO), \+	 duk_api_global_line = (duk_int_t) (DUK_LINE_MACRO), \+	 duk_range_error_stash)+#define duk_reference_error  \+	(duk_api_global_filename = (const char *) (DUK_FILE_MACRO), \+	 duk_api_global_line = (duk_int_t) (DUK_LINE_MACRO), \+	 duk_reference_error_stash)+#define duk_syntax_error  \+	(duk_api_global_filename = (const char *) (DUK_FILE_MACRO), \+	 duk_api_global_line = (duk_int_t) (DUK_LINE_MACRO), \+	 duk_syntax_error_stash)+#define duk_type_error  \+	(duk_api_global_filename = (const char *) (DUK_FILE_MACRO), \+	 duk_api_global_line = (duk_int_t) (DUK_LINE_MACRO), \+	 duk_type_error_stash)+#define duk_uri_error  \+	(duk_api_global_filename = (const char *) (DUK_FILE_MACRO), \+	 duk_api_global_line = (duk_int_t) (DUK_LINE_MACRO), \+	 duk_uri_error_stash)+#endif  /* DUK_API_VARIADIC_MACROS */++DUK_API_NORETURN(DUK_EXTERNAL_DECL void duk_error_va_raw(duk_context *ctx, duk_errcode_t err_code, const char *filename, duk_int_t line, const char *fmt, va_list ap));++#define duk_error_va(ctx,err_code,fmt,ap)  \+	(duk_error_va_raw((ctx), (duk_errcode_t) (err_code), (const char *) (DUK_FILE_MACRO), (duk_int_t) (DUK_LINE_MACRO), (fmt), (ap)), (duk_ret_t) 0)+#define duk_generic_error_va(ctx,fmt,ap)  \+	(duk_error_va_raw((ctx), (duk_errcode_t) DUK_ERR_ERROR, (const char *) (DUK_FILE_MACRO), (duk_int_t) (DUK_LINE_MACRO), (fmt), (ap)), (duk_ret_t) 0)+#define duk_eval_error_va(ctx,fmt,ap)  \+	(duk_error_va_raw((ctx), (duk_errcode_t) DUK_ERR_EVAL_ERROR, (const char *) (DUK_FILE_MACRO), (duk_int_t) (DUK_LINE_MACRO), (fmt), (ap)), (duk_ret_t) 0)+#define duk_range_error_va(ctx,fmt,ap)  \+	(duk_error_va_raw((ctx), (duk_errcode_t) DUK_ERR_RANGE_ERROR, (const char *) (DUK_FILE_MACRO), (duk_int_t) (DUK_LINE_MACRO), (fmt), (ap)), (duk_ret_t) 0)+#define duk_reference_error_va(ctx,fmt,ap)  \+	(duk_error_va_raw((ctx), (duk_errcode_t) DUK_ERR_REFERENCE_ERROR, (const char *) (DUK_FILE_MACRO), (duk_int_t) (DUK_LINE_MACRO), (fmt), (ap)), (duk_ret_t) 0)+#define duk_syntax_error_va(ctx,fmt,ap)  \+	(duk_error_va_raw((ctx), (duk_errcode_t) DUK_ERR_SYNTAX_ERROR, (const char *) (DUK_FILE_MACRO), (duk_int_t) (DUK_LINE_MACRO), (fmt), (ap)), (duk_ret_t) 0)+#define duk_type_error_va(ctx,fmt,ap)  \+	(duk_error_va_raw((ctx), (duk_errcode_t) DUK_ERR_TYPE_ERROR, (const char *) (DUK_FILE_MACRO), (duk_int_t) (DUK_LINE_MACRO), (fmt), (ap)), (duk_ret_t) 0)+#define duk_uri_error_va(ctx,fmt,ap)  \+	(duk_error_va_raw((ctx), (duk_errcode_t) DUK_ERR_URI_ERROR, (const char *) (DUK_FILE_MACRO), (duk_int_t) (DUK_LINE_MACRO), (fmt), (ap)), (duk_ret_t) 0)++/*+ *  Other state related functions+ */++DUK_EXTERNAL_DECL duk_bool_t duk_is_strict_call(duk_context *ctx);+DUK_EXTERNAL_DECL duk_bool_t duk_is_constructor_call(duk_context *ctx);++/*+ *  Stack management+ */++DUK_EXTERNAL_DECL duk_idx_t duk_normalize_index(duk_context *ctx, duk_idx_t idx);+DUK_EXTERNAL_DECL duk_idx_t duk_require_normalize_index(duk_context *ctx, duk_idx_t idx);+DUK_EXTERNAL_DECL duk_bool_t duk_is_valid_index(duk_context *ctx, duk_idx_t idx);+DUK_EXTERNAL_DECL void duk_require_valid_index(duk_context *ctx, duk_idx_t idx);++DUK_EXTERNAL_DECL duk_idx_t duk_get_top(duk_context *ctx);+DUK_EXTERNAL_DECL void duk_set_top(duk_context *ctx, duk_idx_t idx);+DUK_EXTERNAL_DECL duk_idx_t duk_get_top_index(duk_context *ctx);+DUK_EXTERNAL_DECL duk_idx_t duk_require_top_index(duk_context *ctx);++/* Although extra/top could be an unsigned type here, using a signed type+ * makes the API more robust to calling code calculation errors or corner+ * cases (where caller might occasionally come up with negative values).+ * Negative values are treated as zero, which is better than casting them+ * to a large unsigned number.  (This principle is used elsewhere in the+ * API too.)+ */+DUK_EXTERNAL_DECL duk_bool_t duk_check_stack(duk_context *ctx, duk_idx_t extra);+DUK_EXTERNAL_DECL void duk_require_stack(duk_context *ctx, duk_idx_t extra);+DUK_EXTERNAL_DECL duk_bool_t duk_check_stack_top(duk_context *ctx, duk_idx_t top);+DUK_EXTERNAL_DECL void duk_require_stack_top(duk_context *ctx, duk_idx_t top);++/*+ *  Stack manipulation (other than push/pop)+ */++DUK_EXTERNAL_DECL void duk_swap(duk_context *ctx, duk_idx_t idx1, duk_idx_t idx2);+DUK_EXTERNAL_DECL void duk_swap_top(duk_context *ctx, duk_idx_t idx);+DUK_EXTERNAL_DECL void duk_dup(duk_context *ctx, duk_idx_t from_idx);+DUK_EXTERNAL_DECL void duk_dup_top(duk_context *ctx);+DUK_EXTERNAL_DECL void duk_insert(duk_context *ctx, duk_idx_t to_idx);+DUK_EXTERNAL_DECL void duk_replace(duk_context *ctx, duk_idx_t to_idx);+DUK_EXTERNAL_DECL void duk_copy(duk_context *ctx, duk_idx_t from_idx, duk_idx_t to_idx);+DUK_EXTERNAL_DECL void duk_remove(duk_context *ctx, duk_idx_t idx);+DUK_EXTERNAL_DECL void duk_xcopymove_raw(duk_context *to_ctx, duk_context *from_ctx, duk_idx_t count, duk_bool_t is_copy);++#define duk_xmove_top(to_ctx,from_ctx,count) \+	duk_xcopymove_raw((to_ctx), (from_ctx), (count), 0 /*is_copy*/)+#define duk_xcopy_top(to_ctx,from_ctx,count) \+	duk_xcopymove_raw((to_ctx), (from_ctx), (count), 1 /*is_copy*/)++/*+ *  Push operations+ *+ *  Push functions return the absolute (relative to bottom of frame)+ *  position of the pushed value for convenience.+ *+ *  Note: duk_dup() is technically a push.+ */++DUK_EXTERNAL_DECL void duk_push_undefined(duk_context *ctx);+DUK_EXTERNAL_DECL void duk_push_null(duk_context *ctx);+DUK_EXTERNAL_DECL void duk_push_boolean(duk_context *ctx, duk_bool_t val);+DUK_EXTERNAL_DECL void duk_push_true(duk_context *ctx);+DUK_EXTERNAL_DECL void duk_push_false(duk_context *ctx);+DUK_EXTERNAL_DECL void duk_push_number(duk_context *ctx, duk_double_t val);+DUK_EXTERNAL_DECL void duk_push_nan(duk_context *ctx);+DUK_EXTERNAL_DECL void duk_push_int(duk_context *ctx, duk_int_t val);+DUK_EXTERNAL_DECL void duk_push_uint(duk_context *ctx, duk_uint_t val);+DUK_EXTERNAL_DECL const char *duk_push_string(duk_context *ctx, const char *str);+DUK_EXTERNAL_DECL const char *duk_push_lstring(duk_context *ctx, const char *str, duk_size_t len);+DUK_EXTERNAL_DECL void duk_push_pointer(duk_context *ctx, void *p);+DUK_EXTERNAL_DECL const char *duk_push_sprintf(duk_context *ctx, const char *fmt, ...);+DUK_EXTERNAL_DECL const char *duk_push_vsprintf(duk_context *ctx, const char *fmt, va_list ap);++/* duk_push_literal() may evaluate its argument (a C string literal) more than+ * once on purpose.  When speed is preferred, sizeof() avoids an unnecessary+ * strlen() at runtime.  Sizeof("foo") == 4, so subtract 1.  The argument+ * must be non-NULL and should not contain internal NUL characters as the+ * behavior will then depend on config options.+ */+#if defined(DUK_USE_PREFER_SIZE)+#define duk_push_literal(ctx,cstring)  duk_push_string((ctx), (cstring))+#else+DUK_EXTERNAL_DECL const char *duk_push_literal_raw(duk_context *ctx, const char *str, duk_size_t len);+#define duk_push_literal(ctx,cstring)  duk_push_literal_raw((ctx), (cstring), sizeof((cstring)) - 1U)+#endif++DUK_EXTERNAL_DECL void duk_push_this(duk_context *ctx);+DUK_EXTERNAL_DECL void duk_push_new_target(duk_context *ctx);+DUK_EXTERNAL_DECL void duk_push_current_function(duk_context *ctx);+DUK_EXTERNAL_DECL void duk_push_current_thread(duk_context *ctx);+DUK_EXTERNAL_DECL void duk_push_global_object(duk_context *ctx);+DUK_EXTERNAL_DECL void duk_push_heap_stash(duk_context *ctx);+DUK_EXTERNAL_DECL void duk_push_global_stash(duk_context *ctx);+DUK_EXTERNAL_DECL void duk_push_thread_stash(duk_context *ctx, duk_context *target_ctx);++DUK_EXTERNAL_DECL duk_idx_t duk_push_object(duk_context *ctx);+DUK_EXTERNAL_DECL duk_idx_t duk_push_bare_object(duk_context *ctx);+DUK_EXTERNAL_DECL duk_idx_t duk_push_array(duk_context *ctx);+DUK_EXTERNAL_DECL duk_idx_t duk_push_c_function(duk_context *ctx, duk_c_function func, duk_idx_t nargs);+DUK_EXTERNAL_DECL duk_idx_t duk_push_c_lightfunc(duk_context *ctx, duk_c_function func, duk_idx_t nargs, duk_idx_t length, duk_int_t magic);+DUK_EXTERNAL_DECL duk_idx_t duk_push_thread_raw(duk_context *ctx, duk_uint_t flags);+DUK_EXTERNAL_DECL duk_idx_t duk_push_proxy(duk_context *ctx, duk_uint_t proxy_flags);++#define duk_push_thread(ctx) \+	duk_push_thread_raw((ctx), 0 /*flags*/)++#define duk_push_thread_new_globalenv(ctx) \+	duk_push_thread_raw((ctx), DUK_THREAD_NEW_GLOBAL_ENV /*flags*/)++DUK_EXTERNAL_DECL duk_idx_t duk_push_error_object_raw(duk_context *ctx, duk_errcode_t err_code, const char *filename, duk_int_t line, const char *fmt, ...);++#if defined(DUK_API_VARIADIC_MACROS)+#define duk_push_error_object(ctx,err_code,...)  \+	duk_push_error_object_raw((ctx), (err_code), (const char *) (DUK_FILE_MACRO), (duk_int_t) (DUK_LINE_MACRO), __VA_ARGS__)+#else+DUK_EXTERNAL_DECL duk_idx_t duk_push_error_object_stash(duk_context *ctx, duk_errcode_t err_code, const char *fmt, ...);+/* Note: parentheses are required so that the comma expression works in assignments. */+#define duk_push_error_object  \+	(duk_api_global_filename = (const char *) (DUK_FILE_MACRO), \+	 duk_api_global_line = (duk_int_t) (DUK_LINE_MACRO), \+	 duk_push_error_object_stash)  /* last value is func pointer, arguments follow in parens */+#endif++DUK_EXTERNAL_DECL duk_idx_t duk_push_error_object_va_raw(duk_context *ctx, duk_errcode_t err_code, const char *filename, duk_int_t line, const char *fmt, va_list ap);+#define duk_push_error_object_va(ctx,err_code,fmt,ap)  \+	duk_push_error_object_va_raw((ctx), (err_code), (const char *) (DUK_FILE_MACRO), (duk_int_t) (DUK_LINE_MACRO), (fmt), (ap))++#define DUK_BUF_FLAG_DYNAMIC   (1 << 0)    /* internal flag: dynamic buffer */+#define DUK_BUF_FLAG_EXTERNAL  (1 << 1)    /* internal flag: external buffer */+#define DUK_BUF_FLAG_NOZERO    (1 << 2)    /* internal flag: don't zero allocated buffer */++DUK_EXTERNAL_DECL void *duk_push_buffer_raw(duk_context *ctx, duk_size_t size, duk_small_uint_t flags);++#define duk_push_buffer(ctx,size,dynamic) \+	duk_push_buffer_raw((ctx), (size), (dynamic) ? DUK_BUF_FLAG_DYNAMIC : 0)+#define duk_push_fixed_buffer(ctx,size) \+	duk_push_buffer_raw((ctx), (size), 0 /*flags*/)+#define duk_push_dynamic_buffer(ctx,size) \+	duk_push_buffer_raw((ctx), (size), DUK_BUF_FLAG_DYNAMIC /*flags*/)+#define duk_push_external_buffer(ctx) \+	((void) duk_push_buffer_raw((ctx), 0, DUK_BUF_FLAG_DYNAMIC | DUK_BUF_FLAG_EXTERNAL))++#define DUK_BUFOBJ_ARRAYBUFFER         0+#define DUK_BUFOBJ_NODEJS_BUFFER       1+#define DUK_BUFOBJ_DATAVIEW            2+#define DUK_BUFOBJ_INT8ARRAY           3+#define DUK_BUFOBJ_UINT8ARRAY          4+#define DUK_BUFOBJ_UINT8CLAMPEDARRAY   5+#define DUK_BUFOBJ_INT16ARRAY          6+#define DUK_BUFOBJ_UINT16ARRAY         7+#define DUK_BUFOBJ_INT32ARRAY          8+#define DUK_BUFOBJ_UINT32ARRAY         9+#define DUK_BUFOBJ_FLOAT32ARRAY        10+#define DUK_BUFOBJ_FLOAT64ARRAY        11++DUK_EXTERNAL_DECL void duk_push_buffer_object(duk_context *ctx, duk_idx_t idx_buffer, duk_size_t byte_offset, duk_size_t byte_length, duk_uint_t flags);++DUK_EXTERNAL_DECL duk_idx_t duk_push_heapptr(duk_context *ctx, void *ptr);++/*+ *  Pop operations+ */++DUK_EXTERNAL_DECL void duk_pop(duk_context *ctx);+DUK_EXTERNAL_DECL void duk_pop_n(duk_context *ctx, duk_idx_t count);+DUK_EXTERNAL_DECL void duk_pop_2(duk_context *ctx);+DUK_EXTERNAL_DECL void duk_pop_3(duk_context *ctx);++/*+ *  Type checks+ *+ *  duk_is_none(), which would indicate whether index it outside of stack,+ *  is not needed; duk_is_valid_index() gives the same information.+ */++DUK_EXTERNAL_DECL duk_int_t duk_get_type(duk_context *ctx, duk_idx_t idx);+DUK_EXTERNAL_DECL duk_bool_t duk_check_type(duk_context *ctx, duk_idx_t idx, duk_int_t type);+DUK_EXTERNAL_DECL duk_uint_t duk_get_type_mask(duk_context *ctx, duk_idx_t idx);+DUK_EXTERNAL_DECL duk_bool_t duk_check_type_mask(duk_context *ctx, duk_idx_t idx, duk_uint_t mask);++DUK_EXTERNAL_DECL duk_bool_t duk_is_undefined(duk_context *ctx, duk_idx_t idx);+DUK_EXTERNAL_DECL duk_bool_t duk_is_null(duk_context *ctx, duk_idx_t idx);+#define duk_is_null_or_undefined(ctx, idx) \+	((duk_get_type_mask((ctx), (idx)) & (DUK_TYPE_MASK_NULL | DUK_TYPE_MASK_UNDEFINED)) ? 1 : 0)++DUK_EXTERNAL_DECL duk_bool_t duk_is_boolean(duk_context *ctx, duk_idx_t idx);+DUK_EXTERNAL_DECL duk_bool_t duk_is_number(duk_context *ctx, duk_idx_t idx);+DUK_EXTERNAL_DECL duk_bool_t duk_is_nan(duk_context *ctx, duk_idx_t idx);+DUK_EXTERNAL_DECL duk_bool_t duk_is_string(duk_context *ctx, duk_idx_t idx);+DUK_EXTERNAL_DECL duk_bool_t duk_is_object(duk_context *ctx, duk_idx_t idx);+DUK_EXTERNAL_DECL duk_bool_t duk_is_buffer(duk_context *ctx, duk_idx_t idx);+DUK_EXTERNAL_DECL duk_bool_t duk_is_buffer_data(duk_context *ctx, duk_idx_t idx);+DUK_EXTERNAL_DECL duk_bool_t duk_is_pointer(duk_context *ctx, duk_idx_t idx);+DUK_EXTERNAL_DECL duk_bool_t duk_is_lightfunc(duk_context *ctx, duk_idx_t idx);++DUK_EXTERNAL_DECL duk_bool_t duk_is_symbol(duk_context *ctx, duk_idx_t idx);+DUK_EXTERNAL_DECL duk_bool_t duk_is_array(duk_context *ctx, duk_idx_t idx);+DUK_EXTERNAL_DECL duk_bool_t duk_is_function(duk_context *ctx, duk_idx_t idx);+DUK_EXTERNAL_DECL duk_bool_t duk_is_c_function(duk_context *ctx, duk_idx_t idx);+DUK_EXTERNAL_DECL duk_bool_t duk_is_ecmascript_function(duk_context *ctx, duk_idx_t idx);+DUK_EXTERNAL_DECL duk_bool_t duk_is_bound_function(duk_context *ctx, duk_idx_t idx);+DUK_EXTERNAL_DECL duk_bool_t duk_is_thread(duk_context *ctx, duk_idx_t idx);++#define duk_is_callable(ctx,idx) \+	duk_is_function((ctx), (idx))+DUK_EXTERNAL_DECL duk_bool_t duk_is_constructable(duk_context *ctx, duk_idx_t idx);++DUK_EXTERNAL_DECL duk_bool_t duk_is_dynamic_buffer(duk_context *ctx, duk_idx_t idx);+DUK_EXTERNAL_DECL duk_bool_t duk_is_fixed_buffer(duk_context *ctx, duk_idx_t idx);+DUK_EXTERNAL_DECL duk_bool_t duk_is_external_buffer(duk_context *ctx, duk_idx_t idx);++/* Buffers and lightfuncs are not considered primitive because they mimic+ * objects and e.g. duk_to_primitive() will coerce them instead of returning+ * them as is.  Symbols are represented as strings internally.+ */+#define duk_is_primitive(ctx,idx) \+	duk_check_type_mask((ctx), (idx), DUK_TYPE_MASK_UNDEFINED | \+	                                  DUK_TYPE_MASK_NULL | \+	                                  DUK_TYPE_MASK_BOOLEAN | \+	                                  DUK_TYPE_MASK_NUMBER | \+	                                  DUK_TYPE_MASK_STRING | \+	                                  DUK_TYPE_MASK_POINTER)++/* Symbols are object coercible, covered by DUK_TYPE_MASK_STRING. */+#define duk_is_object_coercible(ctx,idx) \+	duk_check_type_mask((ctx), (idx), DUK_TYPE_MASK_BOOLEAN | \+	                                  DUK_TYPE_MASK_NUMBER | \+	                                  DUK_TYPE_MASK_STRING | \+	                                  DUK_TYPE_MASK_OBJECT | \+	                                  DUK_TYPE_MASK_BUFFER | \+	                                  DUK_TYPE_MASK_POINTER | \+	                                  DUK_TYPE_MASK_LIGHTFUNC)++DUK_EXTERNAL_DECL duk_errcode_t duk_get_error_code(duk_context *ctx, duk_idx_t idx);+#define duk_is_error(ctx,idx) \+	(duk_get_error_code((ctx), (idx)) != 0)+#define duk_is_eval_error(ctx,idx) \+	(duk_get_error_code((ctx), (idx)) == DUK_ERR_EVAL_ERROR)+#define duk_is_range_error(ctx,idx) \+	(duk_get_error_code((ctx), (idx)) == DUK_ERR_RANGE_ERROR)+#define duk_is_reference_error(ctx,idx) \+	(duk_get_error_code((ctx), (idx)) == DUK_ERR_REFERENCE_ERROR)+#define duk_is_syntax_error(ctx,idx) \+	(duk_get_error_code((ctx), (idx)) == DUK_ERR_SYNTAX_ERROR)+#define duk_is_type_error(ctx,idx) \+	(duk_get_error_code((ctx), (idx)) == DUK_ERR_TYPE_ERROR)+#define duk_is_uri_error(ctx,idx) \+	(duk_get_error_code((ctx), (idx)) == DUK_ERR_URI_ERROR)++/*+ *  Get operations: no coercion, returns default value for invalid+ *  indices and invalid value types.+ *+ *  duk_get_undefined() and duk_get_null() would be pointless and+ *  are not included.+ */++DUK_EXTERNAL_DECL duk_bool_t duk_get_boolean(duk_context *ctx, duk_idx_t idx);+DUK_EXTERNAL_DECL duk_double_t duk_get_number(duk_context *ctx, duk_idx_t idx);+DUK_EXTERNAL_DECL duk_int_t duk_get_int(duk_context *ctx, duk_idx_t idx);+DUK_EXTERNAL_DECL duk_uint_t duk_get_uint(duk_context *ctx, duk_idx_t idx);+DUK_EXTERNAL_DECL const char *duk_get_string(duk_context *ctx, duk_idx_t idx);+DUK_EXTERNAL_DECL const char *duk_get_lstring(duk_context *ctx, duk_idx_t idx, duk_size_t *out_len);+DUK_EXTERNAL_DECL void *duk_get_buffer(duk_context *ctx, duk_idx_t idx, duk_size_t *out_size);+DUK_EXTERNAL_DECL void *duk_get_buffer_data(duk_context *ctx, duk_idx_t idx, duk_size_t *out_size);+DUK_EXTERNAL_DECL void *duk_get_pointer(duk_context *ctx, duk_idx_t idx);+DUK_EXTERNAL_DECL duk_c_function duk_get_c_function(duk_context *ctx, duk_idx_t idx);+DUK_EXTERNAL_DECL duk_context *duk_get_context(duk_context *ctx, duk_idx_t idx);+DUK_EXTERNAL_DECL void *duk_get_heapptr(duk_context *ctx, duk_idx_t idx);++/*+ *  Get-with-explicit default operations: like get operations but with an+ *  explicit default value.+ */++DUK_EXTERNAL_DECL duk_bool_t duk_get_boolean_default(duk_context *ctx, duk_idx_t idx, duk_bool_t def_value);+DUK_EXTERNAL_DECL duk_double_t duk_get_number_default(duk_context *ctx, duk_idx_t idx, duk_double_t def_value);+DUK_EXTERNAL_DECL duk_int_t duk_get_int_default(duk_context *ctx, duk_idx_t idx, duk_int_t def_value);+DUK_EXTERNAL_DECL duk_uint_t duk_get_uint_default(duk_context *ctx, duk_idx_t idx, duk_uint_t def_value);+DUK_EXTERNAL_DECL const char *duk_get_string_default(duk_context *ctx, duk_idx_t idx, const char *def_value);+DUK_EXTERNAL_DECL const char *duk_get_lstring_default(duk_context *ctx, duk_idx_t idx, duk_size_t *out_len, const char *def_ptr, duk_size_t def_len);+DUK_EXTERNAL_DECL void *duk_get_buffer_default(duk_context *ctx, duk_idx_t idx, duk_size_t *out_size, void *def_ptr, duk_size_t def_len);+DUK_EXTERNAL_DECL void *duk_get_buffer_data_default(duk_context *ctx, duk_idx_t idx, duk_size_t *out_size, void *def_ptr, duk_size_t def_len);+DUK_EXTERNAL_DECL void *duk_get_pointer_default(duk_context *ctx, duk_idx_t idx, void *def_value);+DUK_EXTERNAL_DECL duk_c_function duk_get_c_function_default(duk_context *ctx, duk_idx_t idx, duk_c_function def_value);+DUK_EXTERNAL_DECL duk_context *duk_get_context_default(duk_context *ctx, duk_idx_t idx, duk_context *def_value);+DUK_EXTERNAL_DECL void *duk_get_heapptr_default(duk_context *ctx, duk_idx_t idx, void *def_value);++/*+ *  Opt operations: like require operations but with an explicit default value+ *  when value is undefined or index is invalid, null and non-matching types+ *  cause a TypeError.+ */++DUK_EXTERNAL_DECL duk_bool_t duk_opt_boolean(duk_context *ctx, duk_idx_t idx, duk_bool_t def_value);+DUK_EXTERNAL_DECL duk_double_t duk_opt_number(duk_context *ctx, duk_idx_t idx, duk_double_t def_value);+DUK_EXTERNAL_DECL duk_int_t duk_opt_int(duk_context *ctx, duk_idx_t idx, duk_int_t def_value);+DUK_EXTERNAL_DECL duk_uint_t duk_opt_uint(duk_context *ctx, duk_idx_t idx, duk_uint_t def_value);+DUK_EXTERNAL_DECL const char *duk_opt_string(duk_context *ctx, duk_idx_t idx, const char *def_ptr);+DUK_EXTERNAL_DECL const char *duk_opt_lstring(duk_context *ctx, duk_idx_t idx, duk_size_t *out_len, const char *def_ptr, duk_size_t def_len);+DUK_EXTERNAL_DECL void *duk_opt_buffer(duk_context *ctx, duk_idx_t idx, duk_size_t *out_size, void *def_ptr, duk_size_t def_size);+DUK_EXTERNAL_DECL void *duk_opt_buffer_data(duk_context *ctx, duk_idx_t idx, duk_size_t *out_size, void *def_ptr, duk_size_t def_size);+DUK_EXTERNAL_DECL void *duk_opt_pointer(duk_context *ctx, duk_idx_t idx, void *def_value);+DUK_EXTERNAL_DECL duk_c_function duk_opt_c_function(duk_context *ctx, duk_idx_t idx, duk_c_function def_value);+DUK_EXTERNAL_DECL duk_context *duk_opt_context(duk_context *ctx, duk_idx_t idx, duk_context *def_value);+DUK_EXTERNAL_DECL void *duk_opt_heapptr(duk_context *ctx, duk_idx_t idx, void *def_value);++/*+ *  Require operations: no coercion, throw error if index or type+ *  is incorrect.  No defaulting.+ */++#define duk_require_type_mask(ctx,idx,mask) \+	((void) duk_check_type_mask((ctx), (idx), (mask) | DUK_TYPE_MASK_THROW))++DUK_EXTERNAL_DECL void duk_require_undefined(duk_context *ctx, duk_idx_t idx);+DUK_EXTERNAL_DECL void duk_require_null(duk_context *ctx, duk_idx_t idx);+DUK_EXTERNAL_DECL duk_bool_t duk_require_boolean(duk_context *ctx, duk_idx_t idx);+DUK_EXTERNAL_DECL duk_double_t duk_require_number(duk_context *ctx, duk_idx_t idx);+DUK_EXTERNAL_DECL duk_int_t duk_require_int(duk_context *ctx, duk_idx_t idx);+DUK_EXTERNAL_DECL duk_uint_t duk_require_uint(duk_context *ctx, duk_idx_t idx);+DUK_EXTERNAL_DECL const char *duk_require_string(duk_context *ctx, duk_idx_t idx);+DUK_EXTERNAL_DECL const char *duk_require_lstring(duk_context *ctx, duk_idx_t idx, duk_size_t *out_len);+DUK_EXTERNAL_DECL void duk_require_object(duk_context *ctx, duk_idx_t idx);+DUK_EXTERNAL_DECL void *duk_require_buffer(duk_context *ctx, duk_idx_t idx, duk_size_t *out_size);+DUK_EXTERNAL_DECL void *duk_require_buffer_data(duk_context *ctx, duk_idx_t idx, duk_size_t *out_size);+DUK_EXTERNAL_DECL void *duk_require_pointer(duk_context *ctx, duk_idx_t idx);+DUK_EXTERNAL_DECL duk_c_function duk_require_c_function(duk_context *ctx, duk_idx_t idx);+DUK_EXTERNAL_DECL duk_context *duk_require_context(duk_context *ctx, duk_idx_t idx);+DUK_EXTERNAL_DECL void duk_require_function(duk_context *ctx, duk_idx_t idx);+#define duk_require_callable(ctx,idx) \+	duk_require_function((ctx), (idx))+DUK_EXTERNAL_DECL void *duk_require_heapptr(duk_context *ctx, duk_idx_t idx);++/* Symbols are object coercible and covered by DUK_TYPE_MASK_STRING. */+#define duk_require_object_coercible(ctx,idx) \+	((void) duk_check_type_mask((ctx), (idx), DUK_TYPE_MASK_BOOLEAN | \+	                                            DUK_TYPE_MASK_NUMBER | \+	                                            DUK_TYPE_MASK_STRING | \+	                                            DUK_TYPE_MASK_OBJECT | \+	                                            DUK_TYPE_MASK_BUFFER | \+	                                            DUK_TYPE_MASK_POINTER | \+	                                            DUK_TYPE_MASK_LIGHTFUNC | \+	                                            DUK_TYPE_MASK_THROW))++/*+ *  Coercion operations: in-place coercion, return coerced value where+ *  applicable.  If index is invalid, throw error.  Some coercions may+ *  throw an expected error (e.g. from a toString() or valueOf() call)+ *  or an internal error (e.g. from out of memory).+ */++DUK_EXTERNAL_DECL void duk_to_undefined(duk_context *ctx, duk_idx_t idx);+DUK_EXTERNAL_DECL void duk_to_null(duk_context *ctx, duk_idx_t idx);+DUK_EXTERNAL_DECL duk_bool_t duk_to_boolean(duk_context *ctx, duk_idx_t idx);+DUK_EXTERNAL_DECL duk_double_t duk_to_number(duk_context *ctx, duk_idx_t idx);+DUK_EXTERNAL_DECL duk_int_t duk_to_int(duk_context *ctx, duk_idx_t idx);+DUK_EXTERNAL_DECL duk_uint_t duk_to_uint(duk_context *ctx, duk_idx_t idx);+DUK_EXTERNAL_DECL duk_int32_t duk_to_int32(duk_context *ctx, duk_idx_t idx);+DUK_EXTERNAL_DECL duk_uint32_t duk_to_uint32(duk_context *ctx, duk_idx_t idx);+DUK_EXTERNAL_DECL duk_uint16_t duk_to_uint16(duk_context *ctx, duk_idx_t idx);+DUK_EXTERNAL_DECL const char *duk_to_string(duk_context *ctx, duk_idx_t idx);+DUK_EXTERNAL_DECL const char *duk_to_lstring(duk_context *ctx, duk_idx_t idx, duk_size_t *out_len);+DUK_EXTERNAL_DECL void *duk_to_buffer_raw(duk_context *ctx, duk_idx_t idx, duk_size_t *out_size, duk_uint_t flags);+DUK_EXTERNAL_DECL void *duk_to_pointer(duk_context *ctx, duk_idx_t idx);+DUK_EXTERNAL_DECL void duk_to_object(duk_context *ctx, duk_idx_t idx);+DUK_EXTERNAL_DECL void duk_to_primitive(duk_context *ctx, duk_idx_t idx, duk_int_t hint);++#define DUK_BUF_MODE_FIXED      0   /* internal: request fixed buffer result */+#define DUK_BUF_MODE_DYNAMIC    1   /* internal: request dynamic buffer result */+#define DUK_BUF_MODE_DONTCARE   2   /* internal: don't care about fixed/dynamic nature */++#define duk_to_buffer(ctx,idx,out_size) \+	duk_to_buffer_raw((ctx), (idx), (out_size), DUK_BUF_MODE_DONTCARE)+#define duk_to_fixed_buffer(ctx,idx,out_size) \+	duk_to_buffer_raw((ctx), (idx), (out_size), DUK_BUF_MODE_FIXED)+#define duk_to_dynamic_buffer(ctx,idx,out_size) \+	duk_to_buffer_raw((ctx), (idx), (out_size), DUK_BUF_MODE_DYNAMIC)++/* safe variants of a few coercion operations */+DUK_EXTERNAL_DECL const char *duk_safe_to_lstring(duk_context *ctx, duk_idx_t idx, duk_size_t *out_len);+#define duk_safe_to_string(ctx,idx) \+	duk_safe_to_lstring((ctx), (idx), NULL)++/*+ *  Value length+ */++DUK_EXTERNAL_DECL duk_size_t duk_get_length(duk_context *ctx, duk_idx_t idx);+DUK_EXTERNAL_DECL void duk_set_length(duk_context *ctx, duk_idx_t idx, duk_size_t len);+#if 0+/* duk_require_length()? */+/* duk_opt_length()? */+#endif++/*+ *  Misc conversion+ */++DUK_EXTERNAL_DECL const char *duk_base64_encode(duk_context *ctx, duk_idx_t idx);+DUK_EXTERNAL_DECL void duk_base64_decode(duk_context *ctx, duk_idx_t idx);+DUK_EXTERNAL_DECL const char *duk_hex_encode(duk_context *ctx, duk_idx_t idx);+DUK_EXTERNAL_DECL void duk_hex_decode(duk_context *ctx, duk_idx_t idx);+DUK_EXTERNAL_DECL const char *duk_json_encode(duk_context *ctx, duk_idx_t idx);+DUK_EXTERNAL_DECL void duk_json_decode(duk_context *ctx, duk_idx_t idx);++DUK_EXTERNAL_DECL const char *duk_buffer_to_string(duk_context *ctx, duk_idx_t idx);++/*+ *  Buffer+ */++DUK_EXTERNAL_DECL void *duk_resize_buffer(duk_context *ctx, duk_idx_t idx, duk_size_t new_size);+DUK_EXTERNAL_DECL void *duk_steal_buffer(duk_context *ctx, duk_idx_t idx, duk_size_t *out_size);+DUK_EXTERNAL_DECL void duk_config_buffer(duk_context *ctx, duk_idx_t idx, void *ptr, duk_size_t len);++/*+ *  Property access+ *+ *  The basic function assumes key is on stack.  The _(l)string variant takes+ *  a C string as a property name; the _literal variant takes a C literal.+ *  The _index variant takes an array index as a property name (e.g. 123 is+ *  equivalent to the key "123").  The _heapptr variant takes a raw, borrowed+ *  heap pointer.+ */++DUK_EXTERNAL_DECL duk_bool_t duk_get_prop(duk_context *ctx, duk_idx_t obj_idx);+DUK_EXTERNAL_DECL duk_bool_t duk_get_prop_string(duk_context *ctx, duk_idx_t obj_idx, const char *key);+DUK_EXTERNAL_DECL duk_bool_t duk_get_prop_lstring(duk_context *ctx, duk_idx_t obj_idx, const char *key, duk_size_t key_len);+#if defined(DUK_USE_PREFER_SIZE)+#define duk_get_prop_literal(ctx,obj_idx,key)  duk_get_prop_string((ctx), (obj_idx), (key))+#else+DUK_EXTERNAL_DECL duk_bool_t duk_get_prop_literal_raw(duk_context *ctx, duk_idx_t obj_idx, const char *key, duk_size_t key_len);+#define duk_get_prop_literal(ctx,obj_idx,key)  duk_get_prop_literal_raw((ctx), (obj_idx), (key), sizeof((key)) - 1U)+#endif+DUK_EXTERNAL_DECL duk_bool_t duk_get_prop_index(duk_context *ctx, duk_idx_t obj_idx, duk_uarridx_t arr_idx);+DUK_EXTERNAL_DECL duk_bool_t duk_get_prop_heapptr(duk_context *ctx, duk_idx_t obj_idx, void *ptr);+DUK_EXTERNAL_DECL duk_bool_t duk_put_prop(duk_context *ctx, duk_idx_t obj_idx);+DUK_EXTERNAL_DECL duk_bool_t duk_put_prop_string(duk_context *ctx, duk_idx_t obj_idx, const char *key);+DUK_EXTERNAL_DECL duk_bool_t duk_put_prop_lstring(duk_context *ctx, duk_idx_t obj_idx, const char *key, duk_size_t key_len);+#if defined(DUK_USE_PREFER_SIZE)+#define duk_put_prop_literal(ctx,obj_idx,key)  duk_put_prop_string((ctx), (obj_idx), (key))+#else+DUK_EXTERNAL_DECL duk_bool_t duk_put_prop_literal_raw(duk_context *ctx, duk_idx_t obj_idx, const char *key, duk_size_t key_len);+#define duk_put_prop_literal(ctx,obj_idx,key)  duk_put_prop_literal_raw((ctx), (obj_idx), (key), sizeof((key)) - 1U)+#endif+DUK_EXTERNAL_DECL duk_bool_t duk_put_prop_index(duk_context *ctx, duk_idx_t obj_idx, duk_uarridx_t arr_idx);+DUK_EXTERNAL_DECL duk_bool_t duk_put_prop_heapptr(duk_context *ctx, duk_idx_t obj_idx, void *ptr);+DUK_EXTERNAL_DECL duk_bool_t duk_del_prop(duk_context *ctx, duk_idx_t obj_idx);+DUK_EXTERNAL_DECL duk_bool_t duk_del_prop_string(duk_context *ctx, duk_idx_t obj_idx, const char *key);+DUK_EXTERNAL_DECL duk_bool_t duk_del_prop_lstring(duk_context *ctx, duk_idx_t obj_idx, const char *key, duk_size_t key_len);+#if defined(DUK_USE_PREFER_SIZE)+#define duk_del_prop_literal(ctx,obj_idx,key)  duk_del_prop_string((ctx), (obj_idx), (key))+#else+DUK_EXTERNAL_DECL duk_bool_t duk_del_prop_literal_raw(duk_context *ctx, duk_idx_t obj_idx, const char *key, duk_size_t key_len);+#define duk_del_prop_literal(ctx,obj_idx,key)  duk_del_prop_literal_raw((ctx), (obj_idx), (key), sizeof((key)) - 1U)+#endif+DUK_EXTERNAL_DECL duk_bool_t duk_del_prop_index(duk_context *ctx, duk_idx_t obj_idx, duk_uarridx_t arr_idx);+DUK_EXTERNAL_DECL duk_bool_t duk_del_prop_heapptr(duk_context *ctx, duk_idx_t obj_idx, void *ptr);+DUK_EXTERNAL_DECL duk_bool_t duk_has_prop(duk_context *ctx, duk_idx_t obj_idx);+DUK_EXTERNAL_DECL duk_bool_t duk_has_prop_string(duk_context *ctx, duk_idx_t obj_idx, const char *key);+DUK_EXTERNAL_DECL duk_bool_t duk_has_prop_lstring(duk_context *ctx, duk_idx_t obj_idx, const char *key, duk_size_t key_len);+#if defined(DUK_USE_PREFER_SIZE)+#define duk_has_prop_literal(ctx,obj_idx,key)  duk_has_prop_string((ctx), (obj_idx), (key))+#else+DUK_EXTERNAL_DECL duk_bool_t duk_has_prop_literal_raw(duk_context *ctx, duk_idx_t obj_idx, const char *key, duk_size_t key_len);+#define duk_has_prop_literal(ctx,obj_idx,key)  duk_has_prop_literal_raw((ctx), (obj_idx), (key), sizeof((key)) - 1U)+#endif+DUK_EXTERNAL_DECL duk_bool_t duk_has_prop_index(duk_context *ctx, duk_idx_t obj_idx, duk_uarridx_t arr_idx);+DUK_EXTERNAL_DECL duk_bool_t duk_has_prop_heapptr(duk_context *ctx, duk_idx_t obj_idx, void *ptr);++DUK_EXTERNAL_DECL void duk_get_prop_desc(duk_context *ctx, duk_idx_t obj_idx, duk_uint_t flags);+DUK_EXTERNAL_DECL void duk_def_prop(duk_context *ctx, duk_idx_t obj_idx, duk_uint_t flags);++DUK_EXTERNAL_DECL duk_bool_t duk_get_global_string(duk_context *ctx, const char *key);+DUK_EXTERNAL_DECL duk_bool_t duk_get_global_lstring(duk_context *ctx, const char *key, duk_size_t key_len);+#if defined(DUK_USE_PREFER_SIZE)+#define duk_get_global_literal(ctx,key)  duk_get_global_string((ctx), (key))+#else+DUK_EXTERNAL_DECL duk_bool_t duk_get_global_literal_raw(duk_context *ctx, const char *key, duk_size_t key_len);+#define duk_get_global_literal(ctx,key)  duk_get_global_literal_raw((ctx), (key), sizeof((key)) - 1U)+#endif+DUK_EXTERNAL_DECL duk_bool_t duk_get_global_heapptr(duk_context *ctx, void *ptr);+DUK_EXTERNAL_DECL duk_bool_t duk_put_global_string(duk_context *ctx, const char *key);+DUK_EXTERNAL_DECL duk_bool_t duk_put_global_lstring(duk_context *ctx, const char *key, duk_size_t key_len);+#if defined(DUK_USE_PREFER_SIZE)+#define duk_put_global_literal(ctx,key)  duk_put_global_string((ctx), (key))+#else+DUK_EXTERNAL_DECL duk_bool_t duk_put_global_literal_raw(duk_context *ctx, const char *key, duk_size_t key_len);+#define duk_put_global_literal(ctx,key)  duk_put_global_literal_raw((ctx), (key), sizeof((key)) - 1U)+#endif+DUK_EXTERNAL_DECL duk_bool_t duk_put_global_heapptr(duk_context *ctx, void *ptr);++/*+ *  Inspection+ */++DUK_EXTERNAL_DECL void duk_inspect_value(duk_context *ctx, duk_idx_t idx);+DUK_EXTERNAL_DECL void duk_inspect_callstack_entry(duk_context *ctx, duk_int_t level);++/*+ *  Object prototype+ */++DUK_EXTERNAL_DECL void duk_get_prototype(duk_context *ctx, duk_idx_t idx);+DUK_EXTERNAL_DECL void duk_set_prototype(duk_context *ctx, duk_idx_t idx);++/*+ *  Object finalizer+ */++DUK_EXTERNAL_DECL void duk_get_finalizer(duk_context *ctx, duk_idx_t idx);+DUK_EXTERNAL_DECL void duk_set_finalizer(duk_context *ctx, duk_idx_t idx);++/*+ *  Global object+ */++DUK_EXTERNAL_DECL void duk_set_global_object(duk_context *ctx);++/*+ *  Duktape/C function magic value+ */++DUK_EXTERNAL_DECL duk_int_t duk_get_magic(duk_context *ctx, duk_idx_t idx);+DUK_EXTERNAL_DECL void duk_set_magic(duk_context *ctx, duk_idx_t idx, duk_int_t magic);+DUK_EXTERNAL_DECL duk_int_t duk_get_current_magic(duk_context *ctx);++/*+ *  Module helpers: put multiple function or constant properties+ */++DUK_EXTERNAL_DECL void duk_put_function_list(duk_context *ctx, duk_idx_t obj_idx, const duk_function_list_entry *funcs);+DUK_EXTERNAL_DECL void duk_put_number_list(duk_context *ctx, duk_idx_t obj_idx, const duk_number_list_entry *numbers);++/*+ *  Object operations+ */++DUK_EXTERNAL_DECL void duk_compact(duk_context *ctx, duk_idx_t obj_idx);+DUK_EXTERNAL_DECL void duk_enum(duk_context *ctx, duk_idx_t obj_idx, duk_uint_t enum_flags);+DUK_EXTERNAL_DECL duk_bool_t duk_next(duk_context *ctx, duk_idx_t enum_idx, duk_bool_t get_value);+DUK_EXTERNAL_DECL void duk_seal(duk_context *ctx, duk_idx_t obj_idx);+DUK_EXTERNAL_DECL void duk_freeze(duk_context *ctx, duk_idx_t obj_idx);++/*+ *  String manipulation+ */++DUK_EXTERNAL_DECL void duk_concat(duk_context *ctx, duk_idx_t count);+DUK_EXTERNAL_DECL void duk_join(duk_context *ctx, duk_idx_t count);+DUK_EXTERNAL_DECL void duk_decode_string(duk_context *ctx, duk_idx_t idx, duk_decode_char_function callback, void *udata);+DUK_EXTERNAL_DECL void duk_map_string(duk_context *ctx, duk_idx_t idx, duk_map_char_function callback, void *udata);+DUK_EXTERNAL_DECL void duk_substring(duk_context *ctx, duk_idx_t idx, duk_size_t start_char_offset, duk_size_t end_char_offset);+DUK_EXTERNAL_DECL void duk_trim(duk_context *ctx, duk_idx_t idx);+DUK_EXTERNAL_DECL duk_codepoint_t duk_char_code_at(duk_context *ctx, duk_idx_t idx, duk_size_t char_offset);++/*+ *  ECMAScript operators+ */++DUK_EXTERNAL_DECL duk_bool_t duk_equals(duk_context *ctx, duk_idx_t idx1, duk_idx_t idx2);+DUK_EXTERNAL_DECL duk_bool_t duk_strict_equals(duk_context *ctx, duk_idx_t idx1, duk_idx_t idx2);+DUK_EXTERNAL_DECL duk_bool_t duk_samevalue(duk_context *ctx, duk_idx_t idx1, duk_idx_t idx2);+DUK_EXTERNAL_DECL duk_bool_t duk_instanceof(duk_context *ctx, duk_idx_t idx1, duk_idx_t idx2);++/*+ *  Random+ */++DUK_EXTERNAL_DECL duk_double_t duk_random(duk_context *ctx);++/*+ *  Function (method) calls+ */++DUK_EXTERNAL_DECL void duk_call(duk_context *ctx, duk_idx_t nargs);+DUK_EXTERNAL_DECL void duk_call_method(duk_context *ctx, duk_idx_t nargs);+DUK_EXTERNAL_DECL void duk_call_prop(duk_context *ctx, duk_idx_t obj_idx, duk_idx_t nargs);+DUK_EXTERNAL_DECL duk_int_t duk_pcall(duk_context *ctx, duk_idx_t nargs);+DUK_EXTERNAL_DECL duk_int_t duk_pcall_method(duk_context *ctx, duk_idx_t nargs);+DUK_EXTERNAL_DECL duk_int_t duk_pcall_prop(duk_context *ctx, duk_idx_t obj_idx, duk_idx_t nargs);+DUK_EXTERNAL_DECL void duk_new(duk_context *ctx, duk_idx_t nargs);+DUK_EXTERNAL_DECL duk_int_t duk_pnew(duk_context *ctx, duk_idx_t nargs);+DUK_EXTERNAL_DECL duk_int_t duk_safe_call(duk_context *ctx, duk_safe_call_function func, void *udata, duk_idx_t nargs, duk_idx_t nrets);++/*+ *  Thread management+ */++/* There are currently no native functions to yield/resume, due to the internal+ * limitations on coroutine handling.  These will be added later.+ */++/*+ *  Compilation and evaluation+ */++DUK_EXTERNAL_DECL duk_int_t duk_eval_raw(duk_context *ctx, const char *src_buffer, duk_size_t src_length, duk_uint_t flags);+DUK_EXTERNAL_DECL duk_int_t duk_compile_raw(duk_context *ctx, const char *src_buffer, duk_size_t src_length, duk_uint_t flags);++/* plain */+#define duk_eval(ctx)  \+	((void) duk_eval_raw((ctx), NULL, 0, 1 /*args*/ | DUK_COMPILE_EVAL | DUK_COMPILE_NOFILENAME))++#define duk_eval_noresult(ctx)  \+	((void) duk_eval_raw((ctx), NULL, 0, 1 /*args*/ | DUK_COMPILE_EVAL | DUK_COMPILE_NORESULT | DUK_COMPILE_NOFILENAME))++#define duk_peval(ctx)  \+	(duk_eval_raw((ctx), NULL, 0, 1 /*args*/ | DUK_COMPILE_EVAL | DUK_COMPILE_SAFE | DUK_COMPILE_NOFILENAME))++#define duk_peval_noresult(ctx)  \+	(duk_eval_raw((ctx), NULL, 0, 1 /*args*/ | DUK_COMPILE_EVAL | DUK_COMPILE_SAFE | DUK_COMPILE_NORESULT | DUK_COMPILE_NOFILENAME))++#define duk_compile(ctx,flags)  \+	((void) duk_compile_raw((ctx), NULL, 0, 2 /*args*/ | (flags)))++#define duk_pcompile(ctx,flags)  \+	(duk_compile_raw((ctx), NULL, 0, 2 /*args*/ | (flags) | DUK_COMPILE_SAFE))++/* string */+#define duk_eval_string(ctx,src)  \+	((void) duk_eval_raw((ctx), (src), 0, 0 /*args*/ | DUK_COMPILE_EVAL | DUK_COMPILE_NOSOURCE | DUK_COMPILE_STRLEN | DUK_COMPILE_NOFILENAME))++#define duk_eval_string_noresult(ctx,src)  \+	((void) duk_eval_raw((ctx), (src), 0, 0 /*args*/ | DUK_COMPILE_EVAL | DUK_COMPILE_NOSOURCE | DUK_COMPILE_STRLEN | DUK_COMPILE_NORESULT | DUK_COMPILE_NOFILENAME))++#define duk_peval_string(ctx,src)  \+	(duk_eval_raw((ctx), (src), 0, 0 /*args*/ | DUK_COMPILE_EVAL | DUK_COMPILE_SAFE | DUK_COMPILE_NOSOURCE | DUK_COMPILE_STRLEN | DUK_COMPILE_NOFILENAME))++#define duk_peval_string_noresult(ctx,src)  \+	(duk_eval_raw((ctx), (src), 0, 0 /*args*/ | DUK_COMPILE_EVAL | DUK_COMPILE_SAFE | DUK_COMPILE_NOSOURCE | DUK_COMPILE_STRLEN | DUK_COMPILE_NORESULT | DUK_COMPILE_NOFILENAME))++#define duk_compile_string(ctx,flags,src)  \+	((void) duk_compile_raw((ctx), (src), 0, 0 /*args*/ | (flags) | DUK_COMPILE_NOSOURCE | DUK_COMPILE_STRLEN | DUK_COMPILE_NOFILENAME))++#define duk_compile_string_filename(ctx,flags,src)  \+	((void) duk_compile_raw((ctx), (src), 0, 1 /*args*/ | (flags) | DUK_COMPILE_NOSOURCE | DUK_COMPILE_STRLEN))++#define duk_pcompile_string(ctx,flags,src)  \+	(duk_compile_raw((ctx), (src), 0, 0 /*args*/ | (flags) | DUK_COMPILE_SAFE | DUK_COMPILE_NOSOURCE | DUK_COMPILE_STRLEN | DUK_COMPILE_NOFILENAME))++#define duk_pcompile_string_filename(ctx,flags,src)  \+	(duk_compile_raw((ctx), (src), 0, 1 /*args*/ | (flags) | DUK_COMPILE_SAFE | DUK_COMPILE_NOSOURCE | DUK_COMPILE_STRLEN))++/* lstring */+#define duk_eval_lstring(ctx,buf,len)  \+	((void) duk_eval_raw((ctx), buf, len, 0 /*args*/ | DUK_COMPILE_EVAL | DUK_COMPILE_NOSOURCE | DUK_COMPILE_NOFILENAME))++#define duk_eval_lstring_noresult(ctx,buf,len)  \+	((void) duk_eval_raw((ctx), buf, len, 0 /*args*/ | DUK_COMPILE_EVAL | DUK_COMPILE_NOSOURCE | DUK_COMPILE_NORESULT | DUK_COMPILE_NOFILENAME))++#define duk_peval_lstring(ctx,buf,len)  \+	(duk_eval_raw((ctx), buf, len, 0 /*args*/ | DUK_COMPILE_EVAL | DUK_COMPILE_NOSOURCE | DUK_COMPILE_SAFE | DUK_COMPILE_NOFILENAME))++#define duk_peval_lstring_noresult(ctx,buf,len)  \+	(duk_eval_raw((ctx), buf, len, 0 /*args*/ | DUK_COMPILE_EVAL | DUK_COMPILE_SAFE | DUK_COMPILE_NOSOURCE | DUK_COMPILE_NORESULT | DUK_COMPILE_NOFILENAME))++#define duk_compile_lstring(ctx,flags,buf,len)  \+	((void) duk_compile_raw((ctx), buf, len, 0 /*args*/ | (flags) | DUK_COMPILE_NOSOURCE | DUK_COMPILE_NOFILENAME))++#define duk_compile_lstring_filename(ctx,flags,buf,len)  \+	((void) duk_compile_raw((ctx), buf, len, 1 /*args*/ | (flags) | DUK_COMPILE_NOSOURCE))++#define duk_pcompile_lstring(ctx,flags,buf,len)  \+	(duk_compile_raw((ctx), buf, len, 0 /*args*/ | (flags) | DUK_COMPILE_SAFE | DUK_COMPILE_NOSOURCE | DUK_COMPILE_NOFILENAME))++#define duk_pcompile_lstring_filename(ctx,flags,buf,len)  \+	(duk_compile_raw((ctx), buf, len, 1 /*args*/ | (flags) | DUK_COMPILE_SAFE | DUK_COMPILE_NOSOURCE))++/*+ *  Bytecode load/dump+ */++DUK_EXTERNAL_DECL void duk_dump_function(duk_context *ctx);+DUK_EXTERNAL_DECL void duk_load_function(duk_context *ctx);++/*+ *  Debugging+ */++DUK_EXTERNAL_DECL void duk_push_context_dump(duk_context *ctx);++/*+ *  Debugger (debug protocol)+ */++DUK_EXTERNAL_DECL void duk_debugger_attach(duk_context *ctx,+                                           duk_debug_read_function read_cb,+                                           duk_debug_write_function write_cb,+                                           duk_debug_peek_function peek_cb,+                                           duk_debug_read_flush_function read_flush_cb,+                                           duk_debug_write_flush_function write_flush_cb,+                                           duk_debug_request_function request_cb,+                                           duk_debug_detached_function detached_cb,+                                           void *udata);+DUK_EXTERNAL_DECL void duk_debugger_detach(duk_context *ctx);+DUK_EXTERNAL_DECL void duk_debugger_cooperate(duk_context *ctx);+DUK_EXTERNAL_DECL duk_bool_t duk_debugger_notify(duk_context *ctx, duk_idx_t nvalues);+DUK_EXTERNAL_DECL void duk_debugger_pause(duk_context *ctx);++/*+ *  Time handling+ */++DUK_EXTERNAL_DECL duk_double_t duk_get_now(duk_context *ctx);+DUK_EXTERNAL_DECL void duk_time_to_components(duk_context *ctx, duk_double_t timeval, duk_time_components *comp);+DUK_EXTERNAL_DECL duk_double_t duk_components_to_time(duk_context *ctx, duk_time_components *comp);++/*+ *  Date provider related constants+ *+ *  NOTE: These are "semi public" - you should only use these if you write+ *  your own platform specific Date provider, see doc/datetime.rst.+ */++/* Millisecond count constants. */+#define DUK_DATE_MSEC_SECOND          1000L+#define DUK_DATE_MSEC_MINUTE          (60L * 1000L)+#define DUK_DATE_MSEC_HOUR            (60L * 60L * 1000L)+#define DUK_DATE_MSEC_DAY             (24L * 60L * 60L * 1000L)++/* ECMAScript date range is 100 million days from Epoch:+ * > 100e6 * 24 * 60 * 60 * 1000  // 100M days in millisecs+ * 8640000000000000+ * (= 8.64e15)+ */+#define DUK_DATE_MSEC_100M_DAYS         (8.64e15)+#define DUK_DATE_MSEC_100M_DAYS_LEEWAY  (8.64e15 + 24 * 3600e3)++/* ECMAScript year range:+ * > new Date(100e6 * 24 * 3600e3).toISOString()+ * '+275760-09-13T00:00:00.000Z'+ * > new Date(-100e6 * 24 * 3600e3).toISOString()+ * '-271821-04-20T00:00:00.000Z'+ */+#define DUK_DATE_MIN_ECMA_YEAR     (-271821L)+#define DUK_DATE_MAX_ECMA_YEAR     275760L++/* Part indices for internal breakdowns.  Part order from DUK_DATE_IDX_YEAR+ * to DUK_DATE_IDX_MILLISECOND matches argument ordering of ECMAScript API+ * calls (like Date constructor call).  Some functions in duk_bi_date.c+ * depend on the specific ordering, so change with care.  16 bits are not+ * enough for all parts (year, specifically).+ *+ * Must be in-sync with genbuiltins.py.+ */+#define DUK_DATE_IDX_YEAR           0  /* year */+#define DUK_DATE_IDX_MONTH          1  /* month: 0 to 11 */+#define DUK_DATE_IDX_DAY            2  /* day within month: 0 to 30 */+#define DUK_DATE_IDX_HOUR           3+#define DUK_DATE_IDX_MINUTE         4+#define DUK_DATE_IDX_SECOND         5+#define DUK_DATE_IDX_MILLISECOND    6+#define DUK_DATE_IDX_WEEKDAY        7  /* weekday: 0 to 6, 0=sunday, 1=monday, etc */+#define DUK_DATE_IDX_NUM_PARTS      8++/* Internal API call flags, used for various functions in duk_bi_date.c.+ * Certain flags are used by only certain functions, but since the flags+ * don't overlap, a single flags value can be passed around to multiple+ * functions.+ *+ * The unused top bits of the flags field are also used to pass values+ * to helpers (duk__get_part_helper() and duk__set_part_helper()).+ *+ * Must be in-sync with genbuiltins.py.+ */++/* NOTE: when writing a Date provider you only need a few specific+ * flags from here, the rest are internal.  Avoid using anything you+ * don't need.+ */++#define DUK_DATE_FLAG_NAN_TO_ZERO          (1 << 0)  /* timeval breakdown: internal time value NaN -> zero */+#define DUK_DATE_FLAG_NAN_TO_RANGE_ERROR   (1 << 1)  /* timeval breakdown: internal time value NaN -> RangeError (toISOString) */+#define DUK_DATE_FLAG_ONEBASED             (1 << 2)  /* timeval breakdown: convert month and day-of-month parts to one-based (default is zero-based) */+#define DUK_DATE_FLAG_EQUIVYEAR            (1 << 3)  /* timeval breakdown: replace year with equivalent year in the [1971,2037] range for DST calculations */+#define DUK_DATE_FLAG_LOCALTIME            (1 << 4)  /* convert time value to local time */+#define DUK_DATE_FLAG_SUB1900              (1 << 5)  /* getter: subtract 1900 from year when getting year part */+#define DUK_DATE_FLAG_TOSTRING_DATE        (1 << 6)  /* include date part in string conversion result */+#define DUK_DATE_FLAG_TOSTRING_TIME        (1 << 7)  /* include time part in string conversion result */+#define DUK_DATE_FLAG_TOSTRING_LOCALE      (1 << 8)  /* use locale specific formatting if available */+#define DUK_DATE_FLAG_TIMESETTER           (1 << 9)  /* setter: call is a time setter (affects hour, min, sec, ms); otherwise date setter (affects year, month, day-in-month) */+#define DUK_DATE_FLAG_YEAR_FIXUP           (1 << 10) /* setter: perform 2-digit year fixup (00...99 -> 1900...1999) */+#define DUK_DATE_FLAG_SEP_T                (1 << 11) /* string conversion: use 'T' instead of ' ' as a separator */+#define DUK_DATE_FLAG_VALUE_SHIFT          12        /* additional values begin at bit 12 */++/*+ *  ROM pointer compression+ */++/* Support array for ROM pointer compression.  Only declared when ROM+ * pointer compression is active.+ */+#if defined(DUK_USE_ROM_OBJECTS) && defined(DUK_USE_HEAPPTR16)+DUK_EXTERNAL_DECL const void * const duk_rom_compressed_pointers[];+#endif++/*+ *  C++ name mangling+ */++#if defined(__cplusplus)+/* end 'extern "C"' wrapper */+}+#endif++/*+ *  END PUBLIC API+ */++#endif  /* DUKTAPE_H_INCLUDED */
− duktape/src/duk_config.h
@@ -1,3424 +0,0 @@-/*- *  duk_config.h configuration header generated by genconfig.py.- *- *  Git commit: 3f5e91704aff97c754f6ef5d44aedc5e529d1b16- *  Git describe: v2.0.1- *  Git branch: v2.0-maintenance- *- *  Supported platforms:- *      - Mac OSX, iPhone, Darwin- *      - Orbis- *      - OpenBSD- *      - Generic BSD- *      - Atari ST TOS- *      - AmigaOS- *      - Windows- *      - Flashplayer (Crossbridge)- *      - QNX- *      - TI-Nspire- *      - Emscripten- *      - Linux- *      - Solaris- *      - Generic POSIX- *      - Cygwin- *      - Generic UNIX- *      - Generic fallback- *- *  Supported architectures:- *      - x86- *      - x64- *      - x32- *      - ARM 32-bit- *      - ARM 64-bit- *      - MIPS 32-bit- *      - MIPS 64-bit- *      - PowerPC 32-bit- *      - PowerPC 64-bit- *      - SPARC 32-bit- *      - SPARC 64-bit- *      - SuperH- *      - Motorola 68k- *      - Emscripten- *      - Generic- *- *  Supported compilers:- *      - Clang- *      - GCC- *      - MSVC- *      - Emscripten- *      - TinyC- *      - VBCC- *      - Bruce's C compiler- *      - Generic- *- */--#if !defined(DUK_CONFIG_H_INCLUDED)-#define DUK_CONFIG_H_INCLUDED--/*- *  Intermediate helper defines- */--/* DLL build detection */-/* not configured for DLL build */-#undef DUK_F_DLL_BUILD--/* Apple OSX, iOS */-#if defined(__APPLE__)-#define DUK_F_APPLE-#endif--/* FreeBSD */-#if defined(__FreeBSD__) || defined(__FreeBSD)-#define DUK_F_FREEBSD-#endif--/* Orbis (PS4) variant */-#if defined(DUK_F_FREEBSD) && defined(__ORBIS__)-#define DUK_F_ORBIS-#endif--/* OpenBSD */-#if defined(__OpenBSD__) || defined(__OpenBSD)-#define DUK_F_OPENBSD-#endif--/* NetBSD */-#if defined(__NetBSD__) || defined(__NetBSD)-#define DUK_F_NETBSD-#endif--/* BSD variant */-#if defined(DUK_F_FREEBSD) || defined(DUK_F_NETBSD) || defined(DUK_F_OPENBSD) || \-    defined(__bsdi__) || defined(__DragonFly__)-#define DUK_F_BSD-#endif--/* Atari ST TOS.  __TOS__ defined by PureC.  No platform define in VBCC- * apparently, so to use with VBCC user must define __TOS__ manually.-  */-#if defined(__TOS__)-#define DUK_F_TOS-#endif--/* Motorola 68K.  Not defined by VBCC, so user must define one of these- * manually when using VBCC.- */-#if defined(__m68k__) || defined(M68000) || defined(__MC68K__)-#define DUK_F_M68K-#endif--/* AmigaOS.  Neither AMIGA nor __amigaos__ is defined on VBCC, so user must- * define 'AMIGA' manually when using VBCC.- */-#if defined(AMIGA) || defined(__amigaos__)-#define DUK_F_AMIGAOS-#endif--/* PowerPC */-#if defined(__powerpc) || defined(__powerpc__) || defined(__PPC__)-#define DUK_F_PPC-#if defined(__PPC64__) || defined(__LP64__) || defined(_LP64)-#define DUK_F_PPC64-#else-#define DUK_F_PPC32-#endif-#endif--/* Windows, both 32-bit and 64-bit */-#if defined(_WIN32) || defined(WIN32) || defined(_WIN64) || defined(WIN64) || \-    defined(__WIN32__) || defined(__TOS_WIN__) || defined(__WINDOWS__)-#define DUK_F_WINDOWS-#if defined(_WIN64) || defined(WIN64)-#define DUK_F_WIN64-#else-#define DUK_F_WIN32-#endif-#endif--/* Flash player (e.g. Crossbridge) */-#if defined(__FLASHPLAYER__)-#define DUK_F_FLASHPLAYER-#endif--/* QNX */-#if defined(__QNX__)-#define DUK_F_QNX-#endif--/* TI-Nspire (using Ndless) */-#if defined(_TINSPIRE)-#define DUK_F_TINSPIRE-#endif--/* Emscripten (provided explicitly by user), improve if possible */-#if defined(EMSCRIPTEN)-#define DUK_F_EMSCRIPTEN-#endif--/* BCC (Bruce's C compiler): this is a "torture target" for compilation */-#if defined(__BCC__) || defined(__BCC_VERSION__)-#define DUK_F_BCC-#endif--/* Linux */-#if defined(__linux) || defined(__linux__) || defined(linux)-#define DUK_F_LINUX-#endif--/* illumos / Solaris */-#if defined(__sun) && defined(__SVR4)-#define DUK_F_SUN-#endif--/* POSIX */-#if defined(__posix)-#define DUK_F_POSIX-#endif--/* Cygwin */-#if defined(__CYGWIN__)-#define DUK_F_CYGWIN-#endif--/* Generic Unix (includes Cygwin) */-#if defined(__unix) || defined(__unix__) || defined(unix) || \-    defined(DUK_F_LINUX) || defined(DUK_F_BSD)-#define DUK_F_UNIX-#endif--/* stdint.h not available */-#if defined(DUK_F_WINDOWS) && defined(_MSC_VER)-#if (_MSC_VER < 1700)-/* VS2012+ has stdint.h, < VS2012 does not (but it's available for download). */-#define DUK_F_NO_STDINT_H-#endif-#endif-#if !defined(DUK_F_NO_STDINT_H) && (defined(DUK_F_TOS) || defined(DUK_F_BCC))-#define DUK_F_NO_STDINT_H-#endif--/* C++ */-#undef DUK_F_CPP-#if defined(__cplusplus)-#define DUK_F_CPP-#endif--/* Intel x86 (32-bit), x64 (64-bit) or x32 (64-bit but 32-bit pointers),- * define only one of DUK_F_X86, DUK_F_X64, DUK_F_X32.- * https://sites.google.com/site/x32abi/- */-#if defined(__amd64__) || defined(__amd64) || \-    defined(__x86_64__) || defined(__x86_64) || \-    defined(_M_X64) || defined(_M_AMD64)-#if defined(__ILP32__) || defined(_ILP32)-#define DUK_F_X32-#else-#define DUK_F_X64-#endif-#elif defined(i386) || defined(__i386) || defined(__i386__) || \-      defined(__i486__) || defined(__i586__) || defined(__i686__) || \-      defined(__IA32__) || defined(_M_IX86) || defined(__X86__) || \-      defined(_X86_) || defined(__THW_INTEL__) || defined(__I86__)-#if defined(__LP64__) || defined(_LP64)-/* This should not really happen, but would indicate x64. */-#define DUK_F_X64-#else-#define DUK_F_X86-#endif-#endif--/* ARM */-#if defined(__arm__) || defined(__thumb__) || defined(_ARM) || defined(_M_ARM) || defined(__aarch64__)-#define DUK_F_ARM-#if defined(__LP64__) || defined(_LP64) || defined(__arm64) || defined(__arm64__) || defined(__aarch64__)-#define DUK_F_ARM64-#else-#define DUK_F_ARM32-#endif-#endif--/* MIPS.  Related defines: __MIPSEB__, __MIPSEL__, __mips_isa_rev, __LP64__ */-#if defined(__mips__) || defined(mips) || defined(_MIPS_ISA) || \-    defined(_R3000) || defined(_R4000) || defined(_R5900) || \-    defined(_MIPS_ISA_MIPS1) || defined(_MIPS_ISA_MIPS2) || \-    defined(_MIPS_ISA_MIPS3) || defined(_MIPS_ISA_MIPS4) || \-    defined(__mips) || defined(__MIPS__)-#define DUK_F_MIPS-#if defined(__LP64__) || defined(_LP64) || defined(__mips64) || \-    defined(__mips64__) || defined(__mips_n64)-#define DUK_F_MIPS64-#else-#define DUK_F_MIPS32-#endif-#endif--/* SPARC */-#if defined(sparc) || defined(__sparc) || defined(__sparc__)-#define DUK_F_SPARC-#if defined(__LP64__) || defined(_LP64)-#define DUK_F_SPARC64-#else-#define DUK_F_SPARC32-#endif-#endif--/* SuperH */-#if defined(__sh__) || \-    defined(__sh1__) || defined(__SH1__) || \-    defined(__sh2__) || defined(__SH2__) || \-    defined(__sh3__) || defined(__SH3__) || \-    defined(__sh4__) || defined(__SH4__) || \-    defined(__sh5__) || defined(__SH5__)-#define DUK_F_SUPERH-#endif--/* Clang */-#if defined(__clang__)-#define DUK_F_CLANG-#endif--/* C99 or above */-#undef DUK_F_C99-#if defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L)-#define DUK_F_C99-#endif--/* C++11 or above */-#undef DUK_F_CPP11-#if defined(__cplusplus) && (__cplusplus >= 201103L)-#define DUK_F_CPP11-#endif--/* GCC.  Clang also defines __GNUC__ so don't detect GCC if using Clang. */-#if defined(__GNUC__) && !defined(__clang__) && !defined(DUK_F_CLANG)-#define DUK_F_GCC-#if defined(__GNUC__) && defined(__GNUC_MINOR__) && defined(__GNUC_PATCHLEVEL__)-/* Convenience, e.g. gcc 4.5.1 == 40501; http://stackoverflow.com/questions/6031819/emulating-gccs-builtin-unreachable */-#define DUK_F_GCC_VERSION  (__GNUC__ * 10000L + __GNUC_MINOR__ * 100L + __GNUC_PATCHLEVEL__)-#else-#error cannot figure out gcc version-#endif-#endif--/* MinGW.  Also GCC flags (DUK_F_GCC) are enabled now. */-#if defined(__MINGW32__) || defined(__MINGW64__)-#define DUK_F_MINGW-#endif--/* MSVC */-#if defined(_MSC_VER)-/* MSVC preprocessor defines: http://msdn.microsoft.com/en-us/library/b0084kay.aspx- * _MSC_FULL_VER includes the build number, but it has at least two formats, see e.g.- * BOOST_MSVC_FULL_VER in http://www.boost.org/doc/libs/1_52_0/boost/config/compiler/visualc.hpp- */-#define DUK_F_MSVC-#if defined(_MSC_FULL_VER)-#if (_MSC_FULL_VER > 100000000)-#define DUK_F_MSVC_FULL_VER _MSC_FULL_VER-#else-#define DUK_F_MSCV_FULL_VER (_MSC_FULL_VER * 10)-#endif-#endif-#endif  /* _MSC_VER */--/* TinyC */-#if defined(__TINYC__)-/* http://bellard.org/tcc/tcc-doc.html#SEC9 */-#define DUK_F_TINYC-#endif--/* VBCC */-#if defined(__VBCC__)-#define DUK_F_VBCC-#endif--/*- *  Platform autodetection- */--/* Workaround for older C++ compilers before including <inttypes.h>,- * see e.g.: https://sourceware.org/bugzilla/show_bug.cgi?id=15366- */-#if defined(__cplusplus) && !defined(__STDC_LIMIT_MACROS)-#define __STDC_LIMIT_MACROS-#endif-#if defined(__cplusplus) && !defined(__STDC_CONSTANT_MACROS)-#define __STDC_CONSTANT_MACROS-#endif--#if defined(DUK_F_APPLE)-/* --- Mac OSX, iPhone, Darwin --- */-#define DUK_USE_DATE_NOW_GETTIMEOFDAY-#define DUK_USE_DATE_TZO_GMTIME_R-#define DUK_USE_DATE_PRS_STRPTIME-#define DUK_USE_DATE_FMT_STRFTIME-#include <TargetConditionals.h>-#include <architecture/byte_order.h>-#include <sys/param.h>-#include <sys/time.h>-#include <time.h>--/* http://stackoverflow.com/questions/5919996/how-to-detect-reliably-mac-os-x-ios-linux-windows-in-c-preprocessor */-#if TARGET_IPHONE_SIMULATOR-#define DUK_USE_OS_STRING "iphone-sim"-#elif TARGET_OS_IPHONE-#define DUK_USE_OS_STRING "iphone"-#elif TARGET_OS_MAC-#define DUK_USE_OS_STRING "osx"-#else-#define DUK_USE_OS_STRING "osx-unknown"-#endif--/* Use _setjmp() on Apple by default, see GH-55. */-#define DUK_JMPBUF_TYPE       jmp_buf-#define DUK_SETJMP(jb)        _setjmp((jb))-#define DUK_LONGJMP(jb)       _longjmp((jb), 1)-#elif defined(DUK_F_ORBIS)-/* --- Orbis --- */-/* Orbis = PS4 */-#define DUK_USE_DATE_NOW_GETTIMEOFDAY-#define DUK_USE_DATE_TZO_GMTIME_S-/* no parsing (not an error) */-#define DUK_USE_DATE_FMT_STRFTIME-#include <sys/types.h>-#include <machine/endian.h>-#include <sys/param.h>-#include <sys/time.h>-#include <time.h>--#define DUK_USE_OS_STRING  "orbis"-#elif defined(DUK_F_OPENBSD)-/* --- OpenBSD --- */-/* http://www.monkey.org/openbsd/archive/ports/0401/msg00089.html */-#define DUK_USE_DATE_NOW_GETTIMEOFDAY-#define DUK_USE_DATE_TZO_GMTIME_R-#define DUK_USE_DATE_PRS_STRPTIME-#define DUK_USE_DATE_FMT_STRFTIME-#include <sys/types.h>-#include <sys/endian.h>-#include <sys/param.h>-#include <sys/time.h>-#include <time.h>--#define DUK_USE_OS_STRING  "openbsd"-#elif defined(DUK_F_BSD)-/* --- Generic BSD --- */-#define DUK_USE_DATE_NOW_GETTIMEOFDAY-#define DUK_USE_DATE_TZO_GMTIME_R-#define DUK_USE_DATE_PRS_STRPTIME-#define DUK_USE_DATE_FMT_STRFTIME-#include <sys/types.h>-#include <sys/endian.h>-#include <sys/param.h>-#include <sys/time.h>-#include <time.h>--#define DUK_USE_OS_STRING  "bsd"-#elif defined(DUK_F_TOS)-/* --- Atari ST TOS --- */-#define DUK_USE_DATE_NOW_TIME-#define DUK_USE_DATE_TZO_GMTIME-/* no parsing (not an error) */-#define DUK_USE_DATE_FMT_STRFTIME-#include <time.h>--#define DUK_USE_OS_STRING  "tos"--/* TOS on M68K is always big endian. */-#if !defined(DUK_USE_BYTEORDER) && defined(DUK_F_M68K)-#define DUK_USE_BYTEORDER 3-#endif-#elif defined(DUK_F_AMIGAOS)-/* --- AmigaOS --- */-#if defined(DUK_F_M68K)-/* AmigaOS on M68k */-#define DUK_USE_DATE_NOW_TIME-#define DUK_USE_DATE_TZO_GMTIME-/* no parsing (not an error) */-#define DUK_USE_DATE_FMT_STRFTIME-#include <time.h>-#elif defined(DUK_F_PPC)-#define DUK_USE_DATE_NOW_GETTIMEOFDAY-#define DUK_USE_DATE_TZO_GMTIME_R-#define DUK_USE_DATE_PRS_STRPTIME-#define DUK_USE_DATE_FMT_STRFTIME-#include <time.h>-#if !defined(UINTPTR_MAX)-#define UINTPTR_MAX UINT_MAX-#endif-#else-#error AmigaOS but not M68K/PPC, not supported now-#endif--#define DUK_USE_OS_STRING "amigaos"--/* AmigaOS on M68K or PPC is always big endian. */-#if !defined(DUK_USE_BYTEORDER) && (defined(DUK_F_M68K) || defined(DUK_F_PPC))-#define DUK_USE_BYTEORDER 3-#endif-#elif defined(DUK_F_WINDOWS)-/* --- Windows --- */-/* Initial fix: disable secure CRT related warnings when compiling Duktape- * itself (must be defined before including Windows headers).  Don't define- * for user code including duktape.h.- */-#if defined(DUK_COMPILING_DUKTAPE) && !defined(_CRT_SECURE_NO_WARNINGS)-#define _CRT_SECURE_NO_WARNINGS-#endif--/* Windows 32-bit and 64-bit are currently the same. */-/* MSVC does not have sys/param.h */-#define DUK_USE_DATE_NOW_WINDOWS-#define DUK_USE_DATE_TZO_WINDOWS-/* Note: PRS and FMT are intentionally left undefined for now.  This means- * there is no platform specific date parsing/formatting but there is still- * the ISO 8601 standard format.- */-#if defined(DUK_COMPILING_DUKTAPE)-/* Only include when compiling Duktape to avoid polluting application build- * with a lot of unnecessary defines.- */-#include <windows.h>-#endif--#define DUK_USE_OS_STRING "windows"--/* On Windows, assume we're little endian.  Even Itanium which has a- * configurable endianness runs little endian in Windows.- */-#if !defined(DUK_USE_BYTEORDER)-#define DUK_USE_BYTEORDER 1-#endif-#elif defined(DUK_F_FLASHPLAYER)-/* --- Flashplayer (Crossbridge) --- */-#define DUK_USE_DATE_NOW_GETTIMEOFDAY-#define DUK_USE_DATE_TZO_GMTIME_R-#define DUK_USE_DATE_PRS_STRPTIME-#define DUK_USE_DATE_FMT_STRFTIME-#include <endian.h>-#include <sys/param.h>-#include <sys/time.h>-#include <time.h>--#define DUK_USE_OS_STRING "flashplayer"--#if !defined(DUK_USE_BYTEORDER) && defined(DUK_F_FLASHPLAYER)-#define DUK_USE_BYTEORDER 1-#endif-#elif defined(DUK_F_QNX)-/* --- QNX --- */-#if defined(DUK_F_QNX) && defined(DUK_COMPILING_DUKTAPE)-/* See: /opt/qnx650/target/qnx6/usr/include/sys/platform.h */-#define _XOPEN_SOURCE    600-#define _POSIX_C_SOURCE  200112L-#endif--#define DUK_USE_DATE_NOW_GETTIMEOFDAY-#define DUK_USE_DATE_TZO_GMTIME_R-#define DUK_USE_DATE_PRS_STRPTIME-#define DUK_USE_DATE_FMT_STRFTIME-#include <sys/types.h>-#include <sys/param.h>-#include <sys/time.h>-#include <time.h>--#define DUK_USE_OS_STRING "qnx"-#elif defined(DUK_F_TINSPIRE)-/* --- TI-Nspire --- */-#define DUK_USE_DATE_NOW_GETTIMEOFDAY-#define DUK_USE_DATE_TZO_GMTIME_R-#define DUK_USE_DATE_PRS_STRPTIME-#define DUK_USE_DATE_FMT_STRFTIME-#include <sys/types.h>-#include <sys/param.h>-#include <sys/time.h>-#include <time.h>--#define DUK_USE_OS_STRING "tinspire"-#elif defined(DUK_F_EMSCRIPTEN)-/* --- Emscripten --- */-#if defined(DUK_COMPILING_DUKTAPE)-#if !defined(_POSIX_C_SOURCE)-#define _POSIX_C_SOURCE  200809L-#endif-#if !defined(_GNU_SOURCE)-#define _GNU_SOURCE      /* e.g. getdate_r */-#endif-#if !defined(_XOPEN_SOURCE)-#define _XOPEN_SOURCE    /* e.g. strptime */-#endif-#endif  /* DUK_COMPILING_DUKTAPE */--#include <sys/types.h>-#if defined(DUK_F_BCC)-/* no endian.h */-#else-#include <endian.h>-#endif  /* DUK_F_BCC */-#include <sys/param.h>-#include <sys/time.h>-#include <time.h>-#include <stdint.h>--#define DUK_USE_DATE_NOW_GETTIMEOFDAY-#define DUK_USE_DATE_TZO_GMTIME_R-#define DUK_USE_DATE_PRS_STRPTIME-#define DUK_USE_DATE_FMT_STRFTIME--#define DUK_USE_OS_STRING "emscripten"-#elif defined(DUK_F_LINUX)-/* --- Linux --- */-#if defined(DUK_COMPILING_DUKTAPE)-#if !defined(_POSIX_C_SOURCE)-#define _POSIX_C_SOURCE  200809L-#endif-#if !defined(_GNU_SOURCE)-#define _GNU_SOURCE      /* e.g. getdate_r */-#endif-#if !defined(_XOPEN_SOURCE)-#define _XOPEN_SOURCE    /* e.g. strptime */-#endif-#endif  /* DUK_COMPILING_DUKTAPE */--#include <sys/types.h>-#if defined(DUK_F_BCC)-/* no endian.h or stdint.h */-#else-#include <endian.h>-#include <stdint.h>-#endif  /* DUK_F_BCC */-#include <sys/param.h>-#include <sys/time.h>-#include <time.h>--#define DUK_USE_DATE_NOW_GETTIMEOFDAY-#define DUK_USE_DATE_TZO_GMTIME_R-#define DUK_USE_DATE_PRS_STRPTIME-#define DUK_USE_DATE_FMT_STRFTIME--#define DUK_USE_OS_STRING "linux"-#elif defined(DUK_F_SUN)-/* --- Solaris --- */-#define DUK_USE_DATE_NOW_GETTIMEOFDAY-#define DUK_USE_DATE_TZO_GMTIME_R-#define DUK_USE_DATE_PRS_STRPTIME-#define DUK_USE_DATE_FMT_STRFTIME--#include <sys/types.h>-#include <ast/endian.h>-#include <sys/param.h>-#include <sys/time.h>-#include <time.h>--#define DUK_USE_OS_STRING "solaris"-#elif defined(DUK_F_POSIX)-/* --- Generic POSIX --- */-#define DUK_USE_DATE_NOW_GETTIMEOFDAY-#define DUK_USE_DATE_TZO_GMTIME_R-#define DUK_USE_DATE_PRS_STRPTIME-#define DUK_USE_DATE_FMT_STRFTIME-#include <sys/types.h>-#include <endian.h>-#include <sys/param.h>-#include <sys/time.h>-#include <time.h>--#define DUK_USE_OS_STRING "posix"-#elif defined(DUK_F_CYGWIN)-/* --- Cygwin --- */-/* don't use strptime() for now */-#define DUK_USE_DATE_NOW_GETTIMEOFDAY-#define DUK_USE_DATE_TZO_GMTIME_R-#define DUK_USE_DATE_FMT_STRFTIME-#include <sys/types.h>-#include <endian.h>-#include <sys/param.h>-#include <sys/time.h>-#include <time.h>--#define DUK_JMPBUF_TYPE       jmp_buf-#define DUK_SETJMP(jb)        _setjmp((jb))-#define DUK_LONGJMP(jb)       _longjmp((jb), 1)--#define DUK_USE_OS_STRING "windows"-#elif defined(DUK_F_UNIX)-/* --- Generic UNIX --- */-#define DUK_USE_DATE_NOW_GETTIMEOFDAY-#define DUK_USE_DATE_TZO_GMTIME_R-#define DUK_USE_DATE_PRS_STRPTIME-#define DUK_USE_DATE_FMT_STRFTIME-#include <time.h>-#include <sys/time.h>-#define DUK_USE_OS_STRING "unknown"-#else-/* --- Generic fallback --- */-/* The most portable current time provider is time(), but it only has a- * one second resolution.- */-#define DUK_USE_DATE_NOW_TIME--/* The most portable way to figure out local time offset is gmtime(),- * but it's not thread safe so use with caution.- */-#define DUK_USE_DATE_TZO_GMTIME--/* Avoid custom date parsing and formatting for portability. */-#undef DUK_USE_DATE_PRS_STRPTIME-#undef DUK_USE_DATE_FMT_STRFTIME--/* Rely on C89 headers only; time.h must be here. */-#include <time.h>--#define DUK_USE_OS_STRING "unknown"-#endif  /* autodetect platform */--/* Shared includes: C89 */-#include <stdio.h>-#include <stdlib.h>-#include <string.h>-#include <stdarg.h>  /* varargs */-#include <setjmp.h>-#include <stddef.h>  /* e.g. ptrdiff_t */-#include <math.h>-#include <limits.h>--/* date.h is omitted, and included per platform */--/* Shared includes: stdint.h is C99 */-#if defined(DUK_F_NO_STDINT_H)-/* stdint.h not available */-#else-/* Technically C99 (C++11) but found in many systems.  On some systems- * __STDC_LIMIT_MACROS and __STDC_CONSTANT_MACROS must be defined before- * including stdint.h (see above).- */-#include <stdint.h>-#endif--#if defined(DUK_F_CPP)-#include <exception>  /* std::exception */-#endif--/*- *  Architecture autodetection- */--#if defined(DUK_F_X86)-/* --- x86 --- */-#define DUK_USE_ARCH_STRING "x86"-#if !defined(DUK_USE_BYTEORDER)-#define DUK_USE_BYTEORDER 1-#endif-/* XXX: This is technically not guaranteed because it's possible to configure- * an x86 to require aligned accesses with Alignment Check (AC) flag.- */-#if !defined(DUK_USE_ALIGN_BY)-#define DUK_USE_ALIGN_BY 1-#endif-#define DUK_USE_PACKED_TVAL-#define DUK_F_PACKED_TVAL_PROVIDED-#elif defined(DUK_F_X64)-/* --- x64 --- */-#define DUK_USE_ARCH_STRING "x64"-#if !defined(DUK_USE_BYTEORDER)-#define DUK_USE_BYTEORDER 1-#endif-/* XXX: This is technically not guaranteed because it's possible to configure- * an x86 to require aligned accesses with Alignment Check (AC) flag.- */-#if !defined(DUK_USE_ALIGN_BY)-#define DUK_USE_ALIGN_BY 1-#endif-#undef DUK_USE_PACKED_TVAL-#define DUK_F_PACKED_TVAL_PROVIDED-#elif defined(DUK_F_X32)-/* --- x32 --- */-#define DUK_USE_ARCH_STRING "x32"-#if !defined(DUK_USE_BYTEORDER)-#define DUK_USE_BYTEORDER 1-#endif-/* XXX: This is technically not guaranteed because it's possible to configure- * an x86 to require aligned accesses with Alignment Check (AC) flag.- */-#if !defined(DUK_USE_ALIGN_BY)-#define DUK_USE_ALIGN_BY 1-#endif-#define DUK_USE_PACKED_TVAL-#define DUK_F_PACKED_TVAL_PROVIDED-#elif defined(DUK_F_ARM32)-/* --- ARM 32-bit --- */-#define DUK_USE_ARCH_STRING "arm32"-/* Byte order varies, so rely on autodetect. */-#if !defined(DUK_USE_ALIGN_BY)-#define DUK_USE_ALIGN_BY 4-#endif-#define DUK_USE_PACKED_TVAL-#define DUK_F_PACKED_TVAL_PROVIDED-#elif defined(DUK_F_ARM64)-/* --- ARM 64-bit --- */-#define DUK_USE_ARCH_STRING "arm64"-/* Byte order varies, so rely on autodetect. */-#if !defined(DUK_USE_ALIGN_BY)-#define DUK_USE_ALIGN_BY 8-#endif-#undef DUK_USE_PACKED_TVAL-#define DUK_F_PACKED_TVAL_PROVIDED-#elif defined(DUK_F_MIPS32)-/* --- MIPS 32-bit --- */-#define DUK_USE_ARCH_STRING "mips32"-/* MIPS byte order varies so rely on autodetection. */-/* Based on 'make checkalign' there are no alignment requirements on- * Linux MIPS except for doubles, which need align by 4.  Alignment- * requirements vary based on target though.- */-#if !defined(DUK_USE_ALIGN_BY)-#define DUK_USE_ALIGN_BY 4-#endif-#define DUK_USE_PACKED_TVAL-#define DUK_F_PACKED_TVAL_PROVIDED-#elif defined(DUK_F_MIPS64)-/* --- MIPS 64-bit --- */-#define DUK_USE_ARCH_STRING "mips64"-/* MIPS byte order varies so rely on autodetection. */-/* Good default is a bit arbitrary because alignment requirements- * depend on target.  See https://github.com/svaarala/duktape/issues/102.- */-#if !defined(DUK_USE_ALIGN_BY)-#define DUK_USE_ALIGN_BY 8-#endif-#undef DUK_USE_PACKED_TVAL-#define DUK_F_PACKED_TVAL_PROVIDED-#elif defined(DUK_F_PPC32)-/* --- PowerPC 32-bit --- */-#define DUK_USE_ARCH_STRING "ppc32"-#if !defined(DUK_USE_BYTEORDER)-#define DUK_USE_BYTEORDER 3-#endif-#if !defined(DUK_USE_ALIGN_BY)-#define DUK_USE_ALIGN_BY 8-#endif-#define DUK_USE_PACKED_TVAL-#define DUK_F_PACKED_TVAL_PROVIDED-#elif defined(DUK_F_PPC64)-/* --- PowerPC 64-bit --- */-#define DUK_USE_ARCH_STRING "ppc64"-#if !defined(DUK_USE_BYTEORDER)-#define DUK_USE_BYTEORDER 3-#endif-#if !defined(DUK_USE_ALIGN_BY)-#define DUK_USE_ALIGN_BY 8-#endif-#undef DUK_USE_PACKED_TVAL-#define DUK_F_PACKED_TVAL_PROVIDED-#elif defined(DUK_F_SPARC32)-/* --- SPARC 32-bit --- */-#define DUK_USE_ARCH_STRING "sparc32"-/* SPARC byte order varies so rely on autodetection. */-#if !defined(DUK_USE_ALIGN_BY)-#define DUK_USE_ALIGN_BY 8-#endif-#define DUK_USE_PACKED_TVAL-#define DUK_F_PACKED_TVAL_PROVIDED-#elif defined(DUK_F_SPARC64)-/* --- SPARC 64-bit --- */-#define DUK_USE_ARCH_STRING "sparc64"-/* SPARC byte order varies so rely on autodetection. */-#if !defined(DUK_USE_ALIGN_BY)-#define DUK_USE_ALIGN_BY 8-#endif-#undef DUK_USE_PACKED_TVAL-#define DUK_F_PACKED_TVAL_PROVIDED-#elif defined(DUK_F_SUPERH)-/* --- SuperH --- */-#define DUK_USE_ARCH_STRING "sh"-/* Byte order varies, rely on autodetection. */-/* Based on 'make checkalign' there are no alignment requirements on- * Linux SH4, but align by 4 is probably a good basic default.- */-#if !defined(DUK_USE_ALIGN_BY)-#define DUK_USE_ALIGN_BY 4-#endif-#define DUK_USE_PACKED_TVAL-#define DUK_F_PACKED_TVAL_PROVIDED-#elif defined(DUK_F_M68K)-/* --- Motorola 68k --- */-#define DUK_USE_ARCH_STRING "m68k"-#if !defined(DUK_USE_BYTEORDER)-#define DUK_USE_BYTEORDER 3-#endif-#if !defined(DUK_USE_ALIGN_BY)-#define DUK_USE_ALIGN_BY 8-#endif-#define DUK_USE_PACKED_TVAL-#define DUK_F_PACKED_TVAL_PROVIDED-#elif defined(DUK_F_EMSCRIPTEN)-/* --- Emscripten --- */-#define DUK_USE_ARCH_STRING "emscripten"-#if !defined(DUK_USE_BYTEORDER)-#define DUK_USE_BYTEORDER 1-#endif-#if !defined(DUK_USE_ALIGN_BY)-#define DUK_USE_ALIGN_BY 8-#endif-#undef DUK_USE_PACKED_TVAL-#define DUK_F_PACKED_TVAL_PROVIDED-#else-/* --- Generic --- */-/* These are necessary wild guesses. */-#define DUK_USE_ARCH_STRING "generic"-/* Rely on autodetection for byte order, alignment, and packed tval. */-#endif  /* autodetect architecture */--/*- *  Compiler autodetection- */--#if defined(DUK_F_CLANG)-/* --- Clang --- */-#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--#if defined(DUK_F_DLL_BUILD) && defined(DUK_F_WINDOWS)-/* MSVC dllexport/dllimport: appropriate __declspec depends on whether we're- * compiling Duktape or the application.- */-#if defined(DUK_COMPILING_DUKTAPE)-#define DUK_EXTERNAL_DECL  extern __declspec(dllexport)-#define DUK_EXTERNAL       __declspec(dllexport)-#else-#define DUK_EXTERNAL_DECL  extern __declspec(dllimport)-#define DUK_EXTERNAL       should_not_happen-#endif-#if defined(DUK_SINGLE_FILE)-#define DUK_INTERNAL_DECL  static-#define DUK_INTERNAL       static-#else-#define DUK_INTERNAL_DECL  extern-#define DUK_INTERNAL       /*empty*/-#endif-#define DUK_LOCAL_DECL     static-#define DUK_LOCAL          static-#else-#define DUK_EXTERNAL_DECL  __attribute__ ((visibility("default"))) extern-#define DUK_EXTERNAL       __attribute__ ((visibility("default")))-#if defined(DUK_SINGLE_FILE)-#if (defined(DUK_F_GCC_VERSION) && DUK_F_GCC_VERSION >= 30101) || defined(DUK_F_CLANG)-/* Minimize warnings for unused internal functions with GCC >= 3.1.1 and- * Clang.  Based on documentation it should suffice to have the attribute- * in the declaration only, but in practice some warnings are generated unless- * the attribute is also applied to the definition.- */-#define DUK_INTERNAL_DECL  static __attribute__ ((unused))-#define DUK_INTERNAL       static __attribute__ ((unused))-#else-#define DUK_INTERNAL_DECL  static-#define DUK_INTERNAL       static-#endif-#else-#if (defined(DUK_F_GCC_VERSION) && DUK_F_GCC_VERSION >= 30101) || defined(DUK_F_CLANG)-#define DUK_INTERNAL_DECL  __attribute__ ((visibility("hidden"))) __attribute__ ((unused)) extern-#define DUK_INTERNAL       __attribute__ ((visibility("hidden"))) __attribute__ ((unused))-#else-#define DUK_INTERNAL_DECL  __attribute__ ((visibility("hidden"))) extern-#define DUK_INTERNAL       __attribute__ ((visibility("hidden")))-#endif-#endif-#define DUK_LOCAL_DECL     static-#define DUK_LOCAL          static-#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--#undef DUK_USE_GCC_PRAGMAS-#define DUK_USE_PACK_CLANG_ATTR-#elif defined(DUK_F_GCC)-/* --- GCC --- */-#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)-/* since gcc-2.5 */-#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_DLL_BUILD) && defined(DUK_F_WINDOWS)-/* MSVC dllexport/dllimport: appropriate __declspec depends on whether we're- * compiling Duktape or the application.- */-#if defined(DUK_COMPILING_DUKTAPE)-#define DUK_EXTERNAL_DECL  extern __declspec(dllexport)-#define DUK_EXTERNAL       __declspec(dllexport)-#else-#define DUK_EXTERNAL_DECL  extern __declspec(dllimport)-#define DUK_EXTERNAL       should_not_happen-#endif-#if defined(DUK_SINGLE_FILE)-#define DUK_INTERNAL_DECL  static-#define DUK_INTERNAL       static-#else-#define DUK_INTERNAL_DECL  extern-#define DUK_INTERNAL       /*empty*/-#endif-#define DUK_LOCAL_DECL     static-#define DUK_LOCAL          static-#elif defined(DUK_F_GCC_VERSION) && (DUK_F_GCC_VERSION >= 40000)-#define DUK_EXTERNAL_DECL  __attribute__ ((visibility("default"))) extern-#define DUK_EXTERNAL       __attribute__ ((visibility("default")))-#if defined(DUK_SINGLE_FILE)-#if (defined(DUK_F_GCC_VERSION) && DUK_F_GCC_VERSION >= 30101) || defined(DUK_F_CLANG)-/* Minimize warnings for unused internal functions with GCC >= 3.1.1 and- * Clang.  Based on documentation it should suffice to have the attribute- * in the declaration only, but in practice some warnings are generated unless- * the attribute is also applied to the definition.- */-#define DUK_INTERNAL_DECL  static __attribute__ ((unused))-#define DUK_INTERNAL       static __attribute__ ((unused))-#else-#define DUK_INTERNAL_DECL  static-#define DUK_INTERNAL       static-#endif-#else-#if (defined(DUK_F_GCC_VERSION) && DUK_F_GCC_VERSION >= 30101) || defined(DUK_F_CLANG)-#define DUK_INTERNAL_DECL  __attribute__ ((visibility("hidden"))) __attribute__ ((unused)) extern-#define DUK_INTERNAL       __attribute__ ((visibility("hidden"))) __attribute__ ((unused))-#else-#define DUK_INTERNAL_DECL  __attribute__ ((visibility("hidden"))) extern-#define DUK_INTERNAL       __attribute__ ((visibility("hidden")))-#endif-#endif-#define DUK_LOCAL_DECL     static-#define DUK_LOCAL          static-#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--#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-#elif defined(DUK_F_MSVC)-/* --- MSVC --- */-/* 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)-/* MSVC dllexport/dllimport: appropriate __declspec depends on whether we're- * compiling Duktape or the application.- */-#if defined(DUK_COMPILING_DUKTAPE)-#define DUK_EXTERNAL_DECL  extern __declspec(dllexport)-#define DUK_EXTERNAL       __declspec(dllexport)-#else-#define DUK_EXTERNAL_DECL  extern __declspec(dllimport)-#define DUK_EXTERNAL       should_not_happen-#endif-#if defined(DUK_SINGLE_FILE)-#define DUK_INTERNAL_DECL  static-#define DUK_INTERNAL       static-#else-#define DUK_INTERNAL_DECL  extern-#define DUK_INTERNAL       /*empty*/-#endif-#define DUK_LOCAL_DECL     static-#define DUK_LOCAL          static-#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). */-#define DUK_UNREF(x)  do { __pragma(warning(suppress:4100 4101 4550 4551)) (x); } while (0)-#elif defined(DUK_F_EMSCRIPTEN)-/* --- Emscripten --- */-#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--#define DUK_EXTERNAL_DECL  __attribute__ ((visibility("default"))) extern-#define DUK_EXTERNAL       __attribute__ ((visibility("default")))-#if defined(DUK_SINGLE_FILE)-#if (defined(DUK_F_GCC_VERSION) && DUK_F_GCC_VERSION >= 30101) || defined(DUK_F_CLANG)-/* Minimize warnings for unused internal functions with GCC >= 3.1.1 and- * Clang.  Based on documentation it should suffice to have the attribute- * in the declaration only, but in practice some warnings are generated unless- * the attribute is also applied to the definition.- */-#define DUK_INTERNAL_DECL  static __attribute__ ((unused))-#define DUK_INTERNAL       static __attribute__ ((unused))-#else-#define DUK_INTERNAL_DECL  static-#define DUK_INTERNAL       static-#endif-#else-#if (defined(DUK_F_GCC_VERSION) && DUK_F_GCC_VERSION >= 30101) || defined(DUK_F_CLANG)-#define DUK_INTERNAL_DECL  __attribute__ ((visibility("hidden"))) __attribute__ ((unused)) extern-#define DUK_INTERNAL       __attribute__ ((visibility("hidden"))) __attribute__ ((unused))-#else-#define DUK_INTERNAL_DECL  __attribute__ ((visibility("hidden"))) extern-#define DUK_INTERNAL       __attribute__ ((visibility("hidden")))-#endif-#endif-#define DUK_LOCAL_DECL     static-#define DUK_LOCAL          static--#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-#elif defined(DUK_F_TINYC)-/* --- TinyC --- */-#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-#elif defined(DUK_F_VBCC)-/* --- VBCC --- */-#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-#elif defined(DUK_F_BCC)-/* --- Bruce's C compiler --- */-#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-#else-/* --- Generic --- */-#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-#endif  /* autodetect compiler */--/* uclibc */-#if defined(__UCLIBC__)-#define DUK_F_UCLIBC-#endif--/*- *  Wrapper typedefs and constants for integer types, also sanity check types.- *- *  C99 typedefs are quite good but not always available, and we want to avoid- *  forcibly redefining the C99 typedefs.  So, there are Duktape wrappers for- *  all C99 typedefs and Duktape code should only use these typedefs.  Type- *  detection when C99 is not supported is best effort and may end up detecting- *  some types incorrectly.- *- *  Pointer sizes are a portability problem: pointers to different types may- *  have a different size and function pointers are very difficult to manage- *  portably.- *- *  http://en.wikipedia.org/wiki/C_data_types#Fixed-width_integer_types- *- *  Note: there's an interesting corner case when trying to define minimum- *  signed integer value constants which leads to the current workaround of- *  defining e.g. -0x80000000 as (-0x7fffffffL - 1L).  See doc/code-issues.txt- *  for a longer discussion.- *- *  Note: avoid typecasts and computations in macro integer constants as they- *  can then no longer be used in macro relational expressions (such as- *  #if DUK_SIZE_MAX < 0xffffffffUL).  There is internal code which relies on- *  being able to compare DUK_SIZE_MAX against a limit.- */--/* XXX: add feature options to force basic types from outside? */--#if !defined(INT_MAX)-#error INT_MAX not defined-#endif--/* Check that architecture is two's complement, standard C allows e.g.- * INT_MIN to be -2**31+1 (instead of -2**31).- */-#if defined(INT_MAX) && defined(INT_MIN)-#if INT_MAX != -(INT_MIN + 1)-#error platform does not seem complement of two-#endif-#else-#error cannot check complement of two-#endif--/* Pointer size determination based on __WORDSIZE or architecture when- * that's not available.- */-#if defined(DUK_F_X86) || defined(DUK_F_X32) || \-    defined(DUK_F_M68K) || defined(DUK_F_PPC32) || \-    defined(DUK_F_BCC) || \-    (defined(__WORDSIZE) && (__WORDSIZE == 32))-#define DUK_F_32BIT_PTRS-#elif defined(DUK_F_X64) || \-      (defined(__WORDSIZE) && (__WORDSIZE == 64))-#define DUK_F_64BIT_PTRS-#else-/* not sure, not needed with C99 anyway */-#endif--/* Intermediate define for 'have inttypes.h' */-#undef DUK_F_HAVE_INTTYPES-#if defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L) && \-    !(defined(DUK_F_AMIGAOS) && defined(DUK_F_VBCC))-/* vbcc + AmigaOS has C99 but no inttypes.h */-#define DUK_F_HAVE_INTTYPES-#elif defined(__cplusplus) && (__cplusplus >= 201103L)-/* C++11 apparently ratified stdint.h */-#define DUK_F_HAVE_INTTYPES-#endif--/* Basic integer typedefs and limits, preferably from inttypes.h, otherwise- * through automatic detection.- */-#if defined(DUK_F_HAVE_INTTYPES)-/* C99 or compatible */--#define DUK_F_HAVE_64BIT-#include <inttypes.h>--typedef uint8_t duk_uint8_t;-typedef int8_t duk_int8_t;-typedef uint16_t duk_uint16_t;-typedef int16_t duk_int16_t;-typedef uint32_t duk_uint32_t;-typedef int32_t duk_int32_t;-typedef uint64_t duk_uint64_t;-typedef int64_t duk_int64_t;-typedef uint_least8_t duk_uint_least8_t;-typedef int_least8_t duk_int_least8_t;-typedef uint_least16_t duk_uint_least16_t;-typedef int_least16_t duk_int_least16_t;-typedef uint_least32_t duk_uint_least32_t;-typedef int_least32_t duk_int_least32_t;-typedef uint_least64_t duk_uint_least64_t;-typedef int_least64_t duk_int_least64_t;-typedef uint_fast8_t duk_uint_fast8_t;-typedef int_fast8_t duk_int_fast8_t;-typedef uint_fast16_t duk_uint_fast16_t;-typedef int_fast16_t duk_int_fast16_t;-typedef uint_fast32_t duk_uint_fast32_t;-typedef int_fast32_t duk_int_fast32_t;-typedef uint_fast64_t duk_uint_fast64_t;-typedef int_fast64_t duk_int_fast64_t;-typedef uintptr_t duk_uintptr_t;-typedef intptr_t duk_intptr_t;-typedef uintmax_t duk_uintmax_t;-typedef intmax_t duk_intmax_t;--#define DUK_UINT8_MIN         0-#define DUK_UINT8_MAX         UINT8_MAX-#define DUK_INT8_MIN          INT8_MIN-#define DUK_INT8_MAX          INT8_MAX-#define DUK_UINT_LEAST8_MIN   0-#define DUK_UINT_LEAST8_MAX   UINT_LEAST8_MAX-#define DUK_INT_LEAST8_MIN    INT_LEAST8_MIN-#define DUK_INT_LEAST8_MAX    INT_LEAST8_MAX-#define DUK_UINT_FAST8_MIN    0-#define DUK_UINT_FAST8_MAX    UINT_FAST8_MAX-#define DUK_INT_FAST8_MIN     INT_FAST8_MIN-#define DUK_INT_FAST8_MAX     INT_FAST8_MAX-#define DUK_UINT16_MIN        0-#define DUK_UINT16_MAX        UINT16_MAX-#define DUK_INT16_MIN         INT16_MIN-#define DUK_INT16_MAX         INT16_MAX-#define DUK_UINT_LEAST16_MIN  0-#define DUK_UINT_LEAST16_MAX  UINT_LEAST16_MAX-#define DUK_INT_LEAST16_MIN   INT_LEAST16_MIN-#define DUK_INT_LEAST16_MAX   INT_LEAST16_MAX-#define DUK_UINT_FAST16_MIN   0-#define DUK_UINT_FAST16_MAX   UINT_FAST16_MAX-#define DUK_INT_FAST16_MIN    INT_FAST16_MIN-#define DUK_INT_FAST16_MAX    INT_FAST16_MAX-#define DUK_UINT32_MIN        0-#define DUK_UINT32_MAX        UINT32_MAX-#define DUK_INT32_MIN         INT32_MIN-#define DUK_INT32_MAX         INT32_MAX-#define DUK_UINT_LEAST32_MIN  0-#define DUK_UINT_LEAST32_MAX  UINT_LEAST32_MAX-#define DUK_INT_LEAST32_MIN   INT_LEAST32_MIN-#define DUK_INT_LEAST32_MAX   INT_LEAST32_MAX-#define DUK_UINT_FAST32_MIN   0-#define DUK_UINT_FAST32_MAX   UINT_FAST32_MAX-#define DUK_INT_FAST32_MIN    INT_FAST32_MIN-#define DUK_INT_FAST32_MAX    INT_FAST32_MAX-#define DUK_UINT64_MIN        0-#define DUK_UINT64_MAX        UINT64_MAX-#define DUK_INT64_MIN         INT64_MIN-#define DUK_INT64_MAX         INT64_MAX-#define DUK_UINT_LEAST64_MIN  0-#define DUK_UINT_LEAST64_MAX  UINT_LEAST64_MAX-#define DUK_INT_LEAST64_MIN   INT_LEAST64_MIN-#define DUK_INT_LEAST64_MAX   INT_LEAST64_MAX-#define DUK_UINT_FAST64_MIN   0-#define DUK_UINT_FAST64_MAX   UINT_FAST64_MAX-#define DUK_INT_FAST64_MIN    INT_FAST64_MIN-#define DUK_INT_FAST64_MAX    INT_FAST64_MAX--#define DUK_UINTPTR_MIN       0-#define DUK_UINTPTR_MAX       UINTPTR_MAX-#define DUK_INTPTR_MIN        INTPTR_MIN-#define DUK_INTPTR_MAX        INTPTR_MAX--#define DUK_UINTMAX_MIN       0-#define DUK_UINTMAX_MAX       UINTMAX_MAX-#define DUK_INTMAX_MIN        INTMAX_MIN-#define DUK_INTMAX_MAX        INTMAX_MAX--#define DUK_SIZE_MIN          0-#define DUK_SIZE_MAX          SIZE_MAX-#undef DUK_SIZE_MAX_COMPUTED--#else  /* C99 types */--/* When C99 types are not available, we use heuristic detection to get- * the basic 8, 16, 32, and (possibly) 64 bit types.  The fast/least- * types are then assumed to be exactly the same for now: these could- * be improved per platform but C99 types are very often now available.- * 64-bit types are not available on all platforms; this is OK at least- * on 32-bit platforms.- *- * This detection code is necessarily a bit hacky and can provide typedefs- * and defines that won't work correctly on some exotic platform.- */--#if (defined(CHAR_BIT) && (CHAR_BIT == 8)) || \-    (defined(UCHAR_MAX) && (UCHAR_MAX == 255))-typedef unsigned char duk_uint8_t;-typedef signed char duk_int8_t;-#else-#error cannot detect 8-bit type-#endif--#if defined(USHRT_MAX) && (USHRT_MAX == 65535UL)-typedef unsigned short duk_uint16_t;-typedef signed short duk_int16_t;-#elif defined(UINT_MAX) && (UINT_MAX == 65535UL)-/* On some platforms int is 16-bit but long is 32-bit (e.g. PureC) */-typedef unsigned int duk_uint16_t;-typedef signed int duk_int16_t;-#else-#error cannot detect 16-bit type-#endif--#if defined(UINT_MAX) && (UINT_MAX == 4294967295UL)-typedef unsigned int duk_uint32_t;-typedef signed int duk_int32_t;-#elif defined(ULONG_MAX) && (ULONG_MAX == 4294967295UL)-/* On some platforms int is 16-bit but long is 32-bit (e.g. PureC) */-typedef unsigned long duk_uint32_t;-typedef signed long duk_int32_t;-#else-#error cannot detect 32-bit type-#endif--/* 64-bit type detection is a bit tricky.- *- * ULLONG_MAX is a standard define.  __LONG_LONG_MAX__ and __ULONG_LONG_MAX__- * are used by at least GCC (even if system headers don't provide ULLONG_MAX).- * Some GCC variants may provide __LONG_LONG_MAX__ but not __ULONG_LONG_MAX__.- *- * ULL / LL constants are rejected / warned about by some compilers, even if- * the compiler has a 64-bit type and the compiler/system headers provide an- * unsupported constant (ULL/LL)!  Try to avoid using ULL / LL constants.- * As a side effect we can only check that e.g. ULONG_MAX is larger than 32- * bits but can't be sure it is exactly 64 bits.  Self tests will catch such- * cases.- */-#undef DUK_F_HAVE_64BIT-#if !defined(DUK_F_HAVE_64BIT) && defined(ULONG_MAX)-#if (ULONG_MAX > 4294967295UL)-#define DUK_F_HAVE_64BIT-typedef unsigned long duk_uint64_t;-typedef signed long duk_int64_t;-#endif-#endif-#if !defined(DUK_F_HAVE_64BIT) && defined(ULLONG_MAX)-#if (ULLONG_MAX > 4294967295UL)-#define DUK_F_HAVE_64BIT-typedef unsigned long long duk_uint64_t;-typedef signed long long duk_int64_t;-#endif-#endif-#if !defined(DUK_F_HAVE_64BIT) && defined(__ULONG_LONG_MAX__)-#if (__ULONG_LONG_MAX__ > 4294967295UL)-#define DUK_F_HAVE_64BIT-typedef unsigned long long duk_uint64_t;-typedef signed long long duk_int64_t;-#endif-#endif-#if !defined(DUK_F_HAVE_64BIT) && defined(__LONG_LONG_MAX__)-#if (__LONG_LONG_MAX__ > 2147483647L)-#define DUK_F_HAVE_64BIT-typedef unsigned long long duk_uint64_t;-typedef signed long long duk_int64_t;-#endif-#endif-#if !defined(DUK_F_HAVE_64BIT) && \-    (defined(DUK_F_MINGW) || defined(DUK_F_MSVC))-/* Both MinGW and MSVC have a 64-bit type. */-#define DUK_F_HAVE_64BIT-typedef unsigned long duk_uint64_t;-typedef signed long duk_int64_t;-#endif-#if !defined(DUK_F_HAVE_64BIT)-/* cannot detect 64-bit type, not always needed so don't error */-#endif--typedef duk_uint8_t duk_uint_least8_t;-typedef duk_int8_t duk_int_least8_t;-typedef duk_uint16_t duk_uint_least16_t;-typedef duk_int16_t duk_int_least16_t;-typedef duk_uint32_t duk_uint_least32_t;-typedef duk_int32_t duk_int_least32_t;-typedef duk_uint8_t duk_uint_fast8_t;-typedef duk_int8_t duk_int_fast8_t;-typedef duk_uint16_t duk_uint_fast16_t;-typedef duk_int16_t duk_int_fast16_t;-typedef duk_uint32_t duk_uint_fast32_t;-typedef duk_int32_t duk_int_fast32_t;-#if defined(DUK_F_HAVE_64BIT)-typedef duk_uint64_t duk_uint_least64_t;-typedef duk_int64_t duk_int_least64_t;-typedef duk_uint64_t duk_uint_fast64_t;-typedef duk_int64_t duk_int_fast64_t;-#endif-#if defined(DUK_F_HAVE_64BIT)-typedef duk_uint64_t duk_uintmax_t;-typedef duk_int64_t duk_intmax_t;-#else-typedef duk_uint32_t duk_uintmax_t;-typedef duk_int32_t duk_intmax_t;-#endif--/* Note: the funny looking computations for signed minimum 16-bit, 32-bit, and- * 64-bit values are intentional as the obvious forms (e.g. -0x80000000L) are- * -not- portable.  See code-issues.txt for a detailed discussion.- */-#define DUK_UINT8_MIN         0UL-#define DUK_UINT8_MAX         0xffUL-#define DUK_INT8_MIN          (-0x80L)-#define DUK_INT8_MAX          0x7fL-#define DUK_UINT_LEAST8_MIN   0UL-#define DUK_UINT_LEAST8_MAX   0xffUL-#define DUK_INT_LEAST8_MIN    (-0x80L)-#define DUK_INT_LEAST8_MAX    0x7fL-#define DUK_UINT_FAST8_MIN    0UL-#define DUK_UINT_FAST8_MAX    0xffUL-#define DUK_INT_FAST8_MIN     (-0x80L)-#define DUK_INT_FAST8_MAX     0x7fL-#define DUK_UINT16_MIN        0UL-#define DUK_UINT16_MAX        0xffffUL-#define DUK_INT16_MIN         (-0x7fffL - 1L)-#define DUK_INT16_MAX         0x7fffL-#define DUK_UINT_LEAST16_MIN  0UL-#define DUK_UINT_LEAST16_MAX  0xffffUL-#define DUK_INT_LEAST16_MIN   (-0x7fffL - 1L)-#define DUK_INT_LEAST16_MAX   0x7fffL-#define DUK_UINT_FAST16_MIN   0UL-#define DUK_UINT_FAST16_MAX   0xffffUL-#define DUK_INT_FAST16_MIN    (-0x7fffL - 1L)-#define DUK_INT_FAST16_MAX    0x7fffL-#define DUK_UINT32_MIN        0UL-#define DUK_UINT32_MAX        0xffffffffUL-#define DUK_INT32_MIN         (-0x7fffffffL - 1L)-#define DUK_INT32_MAX         0x7fffffffL-#define DUK_UINT_LEAST32_MIN  0UL-#define DUK_UINT_LEAST32_MAX  0xffffffffUL-#define DUK_INT_LEAST32_MIN   (-0x7fffffffL - 1L)-#define DUK_INT_LEAST32_MAX   0x7fffffffL-#define DUK_UINT_FAST32_MIN   0UL-#define DUK_UINT_FAST32_MAX   0xffffffffUL-#define DUK_INT_FAST32_MIN    (-0x7fffffffL - 1L)-#define DUK_INT_FAST32_MAX    0x7fffffffL--/* 64-bit constants.  Since LL / ULL constants are not always available,- * use computed values.  These values can't be used in preprocessor- * comparisons; flag them as such.- */-#if defined(DUK_F_HAVE_64BIT)-#define DUK_UINT64_MIN        ((duk_uint64_t) 0)-#define DUK_UINT64_MAX        ((duk_uint64_t) -1)-#define DUK_INT64_MIN         ((duk_int64_t) (~(DUK_UINT64_MAX >> 1)))-#define DUK_INT64_MAX         ((duk_int64_t) (DUK_UINT64_MAX >> 1))-#define DUK_UINT_LEAST64_MIN  DUK_UINT64_MIN-#define DUK_UINT_LEAST64_MAX  DUK_UINT64_MAX-#define DUK_INT_LEAST64_MIN   DUK_INT64_MIN-#define DUK_INT_LEAST64_MAX   DUK_INT64_MAX-#define DUK_UINT_FAST64_MIN   DUK_UINT64_MIN-#define DUK_UINT_FAST64_MAX   DUK_UINT64_MAX-#define DUK_INT_FAST64_MIN    DUK_INT64_MIN-#define DUK_INT_FAST64_MAX    DUK_INT64_MAX-#define DUK_UINT64_MIN_COMPUTED-#define DUK_UINT64_MAX_COMPUTED-#define DUK_INT64_MIN_COMPUTED-#define DUK_INT64_MAX_COMPUTED-#define DUK_UINT_LEAST64_MIN_COMPUTED-#define DUK_UINT_LEAST64_MAX_COMPUTED-#define DUK_INT_LEAST64_MIN_COMPUTED-#define DUK_INT_LEAST64_MAX_COMPUTED-#define DUK_UINT_FAST64_MIN_COMPUTED-#define DUK_UINT_FAST64_MAX_COMPUTED-#define DUK_INT_FAST64_MIN_COMPUTED-#define DUK_INT_FAST64_MAX_COMPUTED-#endif--#if defined(DUK_F_HAVE_64BIT)-#define DUK_UINTMAX_MIN       DUK_UINT64_MIN-#define DUK_UINTMAX_MAX       DUK_UINT64_MAX-#define DUK_INTMAX_MIN        DUK_INT64_MIN-#define DUK_INTMAX_MAX        DUK_INT64_MAX-#define DUK_UINTMAX_MIN_COMPUTED-#define DUK_UINTMAX_MAX_COMPUTED-#define DUK_INTMAX_MIN_COMPUTED-#define DUK_INTMAX_MAX_COMPUTED-#else-#define DUK_UINTMAX_MIN       0UL-#define DUK_UINTMAX_MAX       0xffffffffUL-#define DUK_INTMAX_MIN        (-0x7fffffffL - 1L)-#define DUK_INTMAX_MAX        0x7fffffffL-#endif--/* This detection is not very reliable. */-#if defined(DUK_F_32BIT_PTRS)-typedef duk_int32_t duk_intptr_t;-typedef duk_uint32_t duk_uintptr_t;-#define DUK_UINTPTR_MIN       DUK_UINT32_MIN-#define DUK_UINTPTR_MAX       DUK_UINT32_MAX-#define DUK_INTPTR_MIN        DUK_INT32_MIN-#define DUK_INTPTR_MAX        DUK_INT32_MAX-#elif defined(DUK_F_64BIT_PTRS) && defined(DUK_F_HAVE_64BIT)-typedef duk_int64_t duk_intptr_t;-typedef duk_uint64_t duk_uintptr_t;-#define DUK_UINTPTR_MIN       DUK_UINT64_MIN-#define DUK_UINTPTR_MAX       DUK_UINT64_MAX-#define DUK_INTPTR_MIN        DUK_INT64_MIN-#define DUK_INTPTR_MAX        DUK_INT64_MAX-#define DUK_UINTPTR_MIN_COMPUTED-#define DUK_UINTPTR_MAX_COMPUTED-#define DUK_INTPTR_MIN_COMPUTED-#define DUK_INTPTR_MAX_COMPUTED-#else-#error cannot determine intptr type-#endif--/* SIZE_MAX may be missing so use an approximate value for it. */-#undef DUK_SIZE_MAX_COMPUTED-#if !defined(SIZE_MAX)-#define DUK_SIZE_MAX_COMPUTED-#define SIZE_MAX              ((size_t) (-1))-#endif-#define DUK_SIZE_MIN          0-#define DUK_SIZE_MAX          SIZE_MAX--#endif  /* C99 types */--/* A few types are assumed to always exist. */-typedef size_t duk_size_t;-typedef ptrdiff_t duk_ptrdiff_t;--/* The best type for an "all around int" in Duktape internals is "at least- * 32 bit signed integer" which is most convenient.  Same for unsigned type.- * Prefer 'int' when large enough, as it is almost always a convenient type.- */-#if defined(UINT_MAX) && (UINT_MAX >= 0xffffffffUL)-typedef int duk_int_t;-typedef unsigned int duk_uint_t;-#define DUK_INT_MIN           INT_MIN-#define DUK_INT_MAX           INT_MAX-#define DUK_UINT_MIN          0-#define DUK_UINT_MAX          UINT_MAX-#else-typedef duk_int_fast32_t duk_int_t;-typedef duk_uint_fast32_t duk_uint_t;-#define DUK_INT_MIN           DUK_INT_FAST32_MIN-#define DUK_INT_MAX           DUK_INT_FAST32_MAX-#define DUK_UINT_MIN          DUK_UINT_FAST32_MIN-#define DUK_UINT_MAX          DUK_UINT_FAST32_MAX-#endif--/* Same as 'duk_int_t' but guaranteed to be a 'fast' variant if this- * distinction matters for the CPU.  These types are used mainly in the- * executor where it might really matter.- */-typedef duk_int_fast32_t duk_int_fast_t;-typedef duk_uint_fast32_t duk_uint_fast_t;-#define DUK_INT_FAST_MIN      DUK_INT_FAST32_MIN-#define DUK_INT_FAST_MAX      DUK_INT_FAST32_MAX-#define DUK_UINT_FAST_MIN     DUK_UINT_FAST32_MIN-#define DUK_UINT_FAST_MAX     DUK_UINT_FAST32_MAX--/* Small integers (16 bits or more) can fall back to the 'int' type, but- * have a typedef so they are marked "small" explicitly.- */-typedef int duk_small_int_t;-typedef unsigned int duk_small_uint_t;-#define DUK_SMALL_INT_MIN     INT_MIN-#define DUK_SMALL_INT_MAX     INT_MAX-#define DUK_SMALL_UINT_MIN    0-#define DUK_SMALL_UINT_MAX    UINT_MAX--/* Fast variants of small integers, again for really fast paths like the- * executor.- */-typedef duk_int_fast16_t duk_small_int_fast_t;-typedef duk_uint_fast16_t duk_small_uint_fast_t;-#define DUK_SMALL_INT_FAST_MIN    DUK_INT_FAST16_MIN-#define DUK_SMALL_INT_FAST_MAX    DUK_INT_FAST16_MAX-#define DUK_SMALL_UINT_FAST_MIN   DUK_UINT_FAST16_MIN-#define DUK_SMALL_UINT_FAST_MAX   DUK_UINT_FAST16_MAX--/* Boolean values are represented with the platform 'int'. */-typedef duk_small_int_t duk_bool_t;-#define DUK_BOOL_MIN              DUK_SMALL_INT_MIN-#define DUK_BOOL_MAX              DUK_SMALL_INT_MAX--/* Index values must have at least 32-bit signed range. */-typedef duk_int_t duk_idx_t;-#define DUK_IDX_MIN               DUK_INT_MIN-#define DUK_IDX_MAX               DUK_INT_MAX--/* Unsigned index variant. */-typedef duk_uint_t duk_uidx_t;-#define DUK_UIDX_MIN              DUK_UINT_MIN-#define DUK_UIDX_MAX              DUK_UINT_MAX--/* Array index values, could be exact 32 bits.- * Currently no need for signed duk_arridx_t.- */-typedef duk_uint_t duk_uarridx_t;-#define DUK_UARRIDX_MIN           DUK_UINT_MIN-#define DUK_UARRIDX_MAX           DUK_UINT_MAX--/* Duktape/C function return value, platform int is enough for now to- * represent 0, 1, or negative error code.  Must be compatible with- * assigning truth values (e.g. duk_ret_t rc = (foo == bar);).- */-typedef duk_small_int_t duk_ret_t;-#define DUK_RET_MIN               DUK_SMALL_INT_MIN-#define DUK_RET_MAX               DUK_SMALL_INT_MAX--/* Error codes are represented with platform int.  High bits are used- * for flags and such, so 32 bits are needed.- */-typedef duk_int_t duk_errcode_t;-#define DUK_ERRCODE_MIN           DUK_INT_MIN-#define DUK_ERRCODE_MAX           DUK_INT_MAX--/* Codepoint type.  Must be 32 bits or more because it is used also for- * internal codepoints.  The type is signed because negative codepoints- * are used as internal markers (e.g. to mark EOF or missing argument).- * (X)UTF-8/CESU-8 encode/decode take and return an unsigned variant to- * ensure duk_uint32_t casts back and forth nicely.  Almost everything- * else uses the signed one.- */-typedef duk_int_t duk_codepoint_t;-typedef duk_uint_t duk_ucodepoint_t;-#define DUK_CODEPOINT_MIN         DUK_INT_MIN-#define DUK_CODEPOINT_MAX         DUK_INT_MAX-#define DUK_UCODEPOINT_MIN        DUK_UINT_MIN-#define DUK_UCODEPOINT_MAX        DUK_UINT_MAX--/* IEEE float/double typedef. */-typedef float duk_float_t;-typedef double duk_double_t;--/* We're generally assuming that we're working on a platform with a 32-bit- * address space.  If DUK_SIZE_MAX is a typecast value (which is necessary- * if SIZE_MAX is missing), the check must be avoided because the- * preprocessor can't do a comparison.- */-#if !defined(DUK_SIZE_MAX)-#error DUK_SIZE_MAX is undefined, probably missing SIZE_MAX-#elif !defined(DUK_SIZE_MAX_COMPUTED)-#if DUK_SIZE_MAX < 0xffffffffUL-/* On some systems SIZE_MAX can be smaller than max unsigned 32-bit value- * which seems incorrect if size_t is (at least) an unsigned 32-bit type.- * However, it doesn't seem useful to error out compilation if this is the- * case.- */-#endif-#endif--/* Type for public API calls. */-typedef struct duk_hthread duk_context;--/* Check whether we should use 64-bit integers or not.- *- * Quite incomplete now.  Use 64-bit types if detected (C99 or other detection)- * unless they are known to be unreliable.  For instance, 64-bit types are- * available on VBCC but seem to misbehave.- */-#if defined(DUK_F_HAVE_64BIT) && !defined(DUK_F_VBCC)-#define DUK_USE_64BIT_OPS-#else-#undef DUK_USE_64BIT_OPS-#endif--/*- *  Fill-ins for platform, architecture, and compiler- */--/* An abort()-like primitive is needed by the default fatal error handler. */-#if !defined(DUK_ABORT)-#define DUK_ABORT             abort-#endif--#if !defined(DUK_SETJMP)-#define DUK_JMPBUF_TYPE       jmp_buf-#define DUK_SETJMP(jb)        setjmp((jb))-#define DUK_LONGJMP(jb)       longjmp((jb), 1)-#endif--#if 0-/* sigsetjmp() alternative */-#define DUK_JMPBUF_TYPE       sigjmp_buf-#define DUK_SETJMP(jb)        sigsetjmp((jb))-#define DUK_LONGJMP(jb)       siglongjmp((jb), 1)-#endif--/* Special naming to avoid conflict with e.g. DUK_FREE() in duk_heap.h- * (which is unfortunately named).  May sometimes need replacement, e.g.- * some compilers don't handle zero length or NULL correctly in realloc().- */-#if !defined(DUK_ANSI_MALLOC)-#define DUK_ANSI_MALLOC      malloc-#endif-#if !defined(DUK_ANSI_REALLOC)-#define DUK_ANSI_REALLOC     realloc-#endif-#if !defined(DUK_ANSI_CALLOC)-#define DUK_ANSI_CALLOC      calloc-#endif-#if !defined(DUK_ANSI_FREE)-#define DUK_ANSI_FREE        free-#endif--/* ANSI C (various versions) and some implementations require that the- * pointer arguments to memset(), memcpy(), and memmove() be valid values- * even when byte size is 0 (even a NULL pointer is considered invalid in- * this context).  Zero-size operations as such are allowed, as long as their- * pointer arguments point to a valid memory area.  The DUK_MEMSET(),- * DUK_MEMCPY(), and DUK_MEMMOVE() macros require this same behavior, i.e.:- * (1) pointers must be valid and non-NULL, (2) zero size must otherwise be- * allowed.  If these are not fulfilled, a macro wrapper is needed.- *- *   http://stackoverflow.com/questions/5243012/is-it-guaranteed-to-be-safe-to-perform-memcpy0-0-0- *   http://lists.cs.uiuc.edu/pipermail/llvmdev/2007-October/011065.html- *- * Not sure what's the required behavior when a pointer points just past the- * end of a buffer, which often happens in practice (e.g. zero size memmoves).- * For example, if allocation size is 3, the following pointer would not- * technically point to a valid memory byte:- *- *   <-- alloc -->- *   | 0 | 1 | 2 | .....- *                 ^-- p=3, points after last valid byte (2)- */-#if !defined(DUK_MEMCPY)-#if defined(DUK_F_UCLIBC)-/* Old uclibcs have a broken memcpy so use memmove instead (this is overly wide- * now on purpose): http://lists.uclibc.org/pipermail/uclibc-cvs/2008-October/025511.html- */-#define DUK_MEMCPY       memmove-#else-#define DUK_MEMCPY       memcpy-#endif-#endif-#if !defined(DUK_MEMMOVE)-#define DUK_MEMMOVE      memmove-#endif-#if !defined(DUK_MEMCMP)-#define DUK_MEMCMP       memcmp-#endif-#if !defined(DUK_MEMSET)-#define DUK_MEMSET       memset-#endif-#if !defined(DUK_STRLEN)-#define DUK_STRLEN       strlen-#endif-#if !defined(DUK_STRCMP)-#define DUK_STRCMP       strcmp-#endif-#if !defined(DUK_STRNCMP)-#define DUK_STRNCMP      strncmp-#endif-#if !defined(DUK_SPRINTF)-#define DUK_SPRINTF      sprintf-#endif-#if !defined(DUK_SNPRINTF)-/* snprintf() is technically not part of C89 but usually available. */-#define DUK_SNPRINTF     snprintf-#endif-#if !defined(DUK_VSPRINTF)-#define DUK_VSPRINTF     vsprintf-#endif-#if !defined(DUK_VSNPRINTF)-/* vsnprintf() is technically not part of C89 but usually available. */-#define DUK_VSNPRINTF    vsnprintf-#endif-#if !defined(DUK_SSCANF)-#define DUK_SSCANF       sscanf-#endif-#if !defined(DUK_VSSCANF)-#define DUK_VSSCANF      vsscanf-#endif-#if !defined(DUK_MEMZERO)-#define DUK_MEMZERO(p,n) DUK_MEMSET((p), 0, (n))-#endif--#if !defined(DUK_DOUBLE_INFINITY)-#undef DUK_USE_COMPUTED_INFINITY-#if defined(DUK_F_GCC_VERSION) && (DUK_F_GCC_VERSION < 40600)-/* GCC older than 4.6: avoid overflow warnings related to using INFINITY */-#define DUK_DOUBLE_INFINITY  (__builtin_inf())-#elif defined(INFINITY)-#define DUK_DOUBLE_INFINITY  ((double) INFINITY)-#elif !defined(DUK_F_VBCC) && !defined(DUK_F_MSVC) && !defined(DUK_F_BCC)-#define DUK_DOUBLE_INFINITY  (1.0 / 0.0)-#else-/* In VBCC (1.0 / 0.0) results in a warning and 0.0 instead of infinity.- * Use a computed infinity (initialized when a heap is created at the- * latest).- */-#define DUK_USE_COMPUTED_INFINITY-#define DUK_DOUBLE_INFINITY  duk_computed_infinity-#endif-#endif--#if !defined(DUK_DOUBLE_NAN)-#undef DUK_USE_COMPUTED_NAN-#if defined(NAN)-#define DUK_DOUBLE_NAN       NAN-#elif !defined(DUK_F_VBCC) && !defined(DUK_F_MSVC) && !defined(DUK_F_BCC)-#define DUK_DOUBLE_NAN       (0.0 / 0.0)-#else-/* In VBCC (0.0 / 0.0) results in a warning and 0.0 instead of NaN.- * In MSVC (VS2010 Express) (0.0 / 0.0) results in a compile error.- * Use a computed NaN (initialized when a heap is created at the- * latest).- */-#define DUK_USE_COMPUTED_NAN-#define DUK_DOUBLE_NAN       duk_computed_nan-#endif-#endif--/* Many platforms are missing fpclassify() and friends, so use replacements- * if necessary.  The replacement constants (FP_NAN etc) can be anything but- * match Linux constants now.- */-#undef DUK_USE_REPL_FPCLASSIFY-#undef DUK_USE_REPL_SIGNBIT-#undef DUK_USE_REPL_ISFINITE-#undef DUK_USE_REPL_ISNAN-#undef DUK_USE_REPL_ISINF--/* Complex condition broken into separate parts. */-#undef DUK_F_USE_REPL_ALL-#if !(defined(FP_NAN) && defined(FP_INFINITE) && defined(FP_ZERO) && \-      defined(FP_SUBNORMAL) && defined(FP_NORMAL))-/* Missing some obvious constants. */-#define DUK_F_USE_REPL_ALL-#elif defined(DUK_F_AMIGAOS) && defined(DUK_F_VBCC)-/* VBCC is missing the built-ins even in C99 mode (perhaps a header issue). */-#define DUK_F_USE_REPL_ALL-#elif defined(DUK_F_AMIGAOS) && defined(DUK_F_M68K)-/* AmigaOS + M68K seems to have math issues even when using GCC cross- * compilation.  Use replacements for all AmigaOS versions on M68K- * regardless of compiler.- */-#define DUK_F_USE_REPL_ALL-#elif defined(DUK_F_FREEBSD) && defined(DUK_F_CLANG)-/* Placeholder fix for (detection is wider than necessary):- * http://llvm.org/bugs/show_bug.cgi?id=17788- */-#define DUK_F_USE_REPL_ALL-#elif defined(DUK_F_UCLIBC)-/* At least some uclibc versions have broken floating point math.  For- * example, fpclassify() can incorrectly classify certain NaN formats.- * To be safe, use replacements.- */-#define DUK_F_USE_REPL_ALL-#endif--#if defined(DUK_F_USE_REPL_ALL)-#define DUK_USE_REPL_FPCLASSIFY-#define DUK_USE_REPL_SIGNBIT-#define DUK_USE_REPL_ISFINITE-#define DUK_USE_REPL_ISNAN-#define DUK_USE_REPL_ISINF-#define DUK_FPCLASSIFY       duk_repl_fpclassify-#define DUK_SIGNBIT          duk_repl_signbit-#define DUK_ISFINITE         duk_repl_isfinite-#define DUK_ISNAN            duk_repl_isnan-#define DUK_ISINF            duk_repl_isinf-#define DUK_FP_NAN           0-#define DUK_FP_INFINITE      1-#define DUK_FP_ZERO          2-#define DUK_FP_SUBNORMAL     3-#define DUK_FP_NORMAL        4-#else-#define DUK_FPCLASSIFY       fpclassify-#define DUK_SIGNBIT          signbit-#define DUK_ISFINITE         isfinite-#define DUK_ISNAN            isnan-#define DUK_ISINF            isinf-#define DUK_FP_NAN           FP_NAN-#define DUK_FP_INFINITE      FP_INFINITE-#define DUK_FP_ZERO          FP_ZERO-#define DUK_FP_SUBNORMAL     FP_SUBNORMAL-#define DUK_FP_NORMAL        FP_NORMAL-#endif--#if defined(DUK_F_USE_REPL_ALL)-#undef DUK_F_USE_REPL_ALL-#endif--/* These functions don't currently need replacement but are wrapped for- * completeness.  Because these are used as function pointers, they need- * to be defined as concrete C functions (not macros).- */-#if !defined(DUK_FABS)-#define DUK_FABS             fabs-#endif-#if !defined(DUK_FLOOR)-#define DUK_FLOOR            floor-#endif-#if !defined(DUK_CEIL)-#define DUK_CEIL             ceil-#endif-#if !defined(DUK_FMOD)-#define DUK_FMOD             fmod-#endif-#if !defined(DUK_POW)-#define DUK_POW              pow-#endif-#if !defined(DUK_ACOS)-#define DUK_ACOS             acos-#endif-#if !defined(DUK_ASIN)-#define DUK_ASIN             asin-#endif-#if !defined(DUK_ATAN)-#define DUK_ATAN             atan-#endif-#if !defined(DUK_ATAN2)-#define DUK_ATAN2            atan2-#endif-#if !defined(DUK_SIN)-#define DUK_SIN              sin-#endif-#if !defined(DUK_COS)-#define DUK_COS              cos-#endif-#if !defined(DUK_TAN)-#define DUK_TAN              tan-#endif-#if !defined(DUK_EXP)-#define DUK_EXP              exp-#endif-#if !defined(DUK_LOG)-#define DUK_LOG              log-#endif-#if !defined(DUK_SQRT)-#define DUK_SQRT             sqrt-#endif--/* The functions below exist only in C99/C++11 or later and need a workaround- * for platforms that don't include them.  MSVC isn't detected as C99, but- * these functions also exist in MSVC 2013 and later so include a clause for- * that too.- */-#if defined(DUK_F_C99) || defined(DUK_F_CPP11) || (defined(_MSC_VER) && (_MSC_VER >= 1800))-#if !defined(DUK_CBRT)-#define DUK_CBRT             cbrt-#endif-#if !defined(DUK_LOG2)-#define DUK_LOG2             log2-#endif-#if !defined(DUK_LOG10)-#define DUK_LOG10            log10-#endif-#if !defined(DUK_TRUNC)-#define DUK_TRUNC            trunc-#endif-#endif  /* DUK_F_C99 */--/* NetBSD 6.0 x86 (at least) has a few problems with pow() semantics,- * see test-bug-netbsd-math-pow.js.  MinGW has similar (but different)- * issues, see test-bug-mingw-math-issues.js.  Enable pow() workarounds- * for these targets.- */-#undef DUK_USE_POW_WORKAROUNDS-#if defined(DUK_F_NETBSD) || defined(DUK_F_MINGW)-#define DUK_USE_POW_WORKAROUNDS-#endif--/* Similar workarounds for atan2() semantics issues.  MinGW issues are- * documented in test-bug-mingw-math-issues.js.- */-#undef DUK_USE_ATAN2_WORKAROUNDS-#if defined(DUK_F_MINGW)-#define DUK_USE_ATAN2_WORKAROUNDS-#endif--/* Rely as little as possible on compiler behavior for NaN comparison,- * signed zero handling, etc.  Currently never activated but may be needed- * for broken compilers.- */-#undef DUK_USE_PARANOID_MATH--/* There was a curious bug where test-bi-date-canceling.js would fail e.g.- * on 64-bit Ubuntu, gcc-4.8.1, -m32, and no -std=c99.  Some date computations- * using doubles would be optimized which then broke some corner case tests.- * The problem goes away by adding 'volatile' to the datetime computations.- * Not sure what the actual triggering conditions are, but using this on- * non-C99 systems solves the known issues and has relatively little cost- * on other platforms.- */-#undef DUK_USE_PARANOID_DATE_COMPUTATION-#if !defined(DUK_F_C99)-#define DUK_USE_PARANOID_DATE_COMPUTATION-#endif--/*- *  Byte order and double memory layout detection- *- *  Endianness detection is a major portability hassle because the macros- *  and headers are not standardized.  There's even variance across UNIX- *  platforms.  Even with "standard" headers, details like underscore count- *  varies between platforms, e.g. both __BYTE_ORDER and _BYTE_ORDER are used- *  (Crossbridge has a single underscore, for instance).- *- *  The checks below are structured with this in mind: several approaches are- *  used, and at the end we check if any of them worked.  This allows generic- *  approaches to be tried first, and platform/compiler specific hacks tried- *  last.  As a last resort, the user can force a specific endianness, as it's- *  not likely that automatic detection will work on the most exotic platforms.- *- *  Duktape supports little and big endian machines.  There's also support- *  for a hybrid used by some ARM machines where integers are little endian- *  but IEEE double values use a mixed order (12345678 -> 43218765).  This- *  byte order for doubles is referred to as "mixed endian".- */--/* GCC and Clang provide endianness defines as built-in predefines, with- * leading and trailing double underscores (e.g. __BYTE_ORDER__).  See- * output of "make gccpredefs" and "make clangpredefs".  Clang doesn't- * seem to provide __FLOAT_WORD_ORDER__; assume not mixed endian for clang.- * http://gcc.gnu.org/onlinedocs/cpp/Common-Predefined-Macros.html- */-#if !defined(DUK_USE_BYTEORDER) && defined(__BYTE_ORDER__)-#if defined(__ORDER_LITTLE_ENDIAN__) && (__BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__)-#if defined(__FLOAT_WORD_ORDER__) && defined(__ORDER_LITTLE_ENDIAN__) && (__FLOAT_WORD_ORDER__ == __ORDER_LITTLE_ENDIAN__)-#define DUK_USE_BYTEORDER 1-#elif defined(__FLOAT_WORD_ORDER__) && defined(__ORDER_BIG_ENDIAN__) && (__FLOAT_WORD_ORDER__ == __ORDER_BIG_ENDIAN__)-#define DUK_USE_BYTEORDER 2-#elif !defined(__FLOAT_WORD_ORDER__)-/* Float word order not known, assume not a hybrid. */-#define DUK_USE_BYTEORDER 1-#else-/* Byte order is little endian but cannot determine IEEE double word order. */-#endif  /* float word order */-#elif defined(__ORDER_BIG_ENDIAN__) && (__BYTE_ORDER__ == __ORDER_BIG_ENDIAN__)-#if defined(__FLOAT_WORD_ORDER__) && defined(__ORDER_BIG_ENDIAN__) && (__FLOAT_WORD_ORDER__ == __ORDER_BIG_ENDIAN__)-#define DUK_USE_BYTEORDER 3-#elif !defined(__FLOAT_WORD_ORDER__)-/* Float word order not known, assume not a hybrid. */-#define DUK_USE_BYTEORDER 3-#else-/* Byte order is big endian but cannot determine IEEE double word order. */-#endif  /* float word order */-#else-/* Cannot determine byte order; __ORDER_PDP_ENDIAN__ is related to 32-bit- * integer ordering and is not relevant.- */-#endif  /* integer byte order */-#endif  /* !defined(DUK_USE_BYTEORDER) && defined(__BYTE_ORDER__) */--/* More or less standard endianness predefines provided by header files.- * The ARM hybrid case is detected by assuming that __FLOAT_WORD_ORDER- * will be big endian, see: http://lists.mysql.com/internals/443.- * On some platforms some defines may be present with an empty value which- * causes comparisons to fail: https://github.com/svaarala/duktape/issues/453.- */-#if !defined(DUK_USE_BYTEORDER)-#if defined(__BYTE_ORDER) && defined(__LITTLE_ENDIAN) && (__BYTE_ORDER == __LITTLE_ENDIAN) || \-    defined(_BYTE_ORDER) && defined(_LITTLE_ENDIAN) && (_BYTE_ORDER == _LITTLE_ENDIAN) || \-    defined(__LITTLE_ENDIAN__)-#if defined(__FLOAT_WORD_ORDER) && defined(__LITTLE_ENDIAN) && (__FLOAT_WORD_ORDER == __LITTLE_ENDIAN) || \-    defined(_FLOAT_WORD_ORDER) && defined(_LITTLE_ENDIAN) && (_FLOAT_WORD_ORDER == _LITTLE_ENDIAN)-#define DUK_USE_BYTEORDER 1-#elif defined(__FLOAT_WORD_ORDER) && defined(__BIG_ENDIAN) && (__FLOAT_WORD_ORDER == __BIG_ENDIAN) || \-      defined(_FLOAT_WORD_ORDER) && defined(_BIG_ENDIAN) && (_FLOAT_WORD_ORDER == _BIG_ENDIAN)-#define DUK_USE_BYTEORDER 2-#elif !defined(__FLOAT_WORD_ORDER) && !defined(_FLOAT_WORD_ORDER)-/* Float word order not known, assume not a hybrid. */-#define DUK_USE_BYTEORDER 1-#else-/* Byte order is little endian but cannot determine IEEE double word order. */-#endif  /* float word order */-#elif defined(__BYTE_ORDER) && defined(__BIG_ENDIAN) && (__BYTE_ORDER == __BIG_ENDIAN) || \-      defined(_BYTE_ORDER) && defined(_BIG_ENDIAN) && (_BYTE_ORDER == _BIG_ENDIAN) || \-      defined(__BIG_ENDIAN__)-#if defined(__FLOAT_WORD_ORDER) && defined(__BIG_ENDIAN) && (__FLOAT_WORD_ORDER == __BIG_ENDIAN) || \-    defined(_FLOAT_WORD_ORDER) && defined(_BIG_ENDIAN) && (_FLOAT_WORD_ORDER == _BIG_ENDIAN)-#define DUK_USE_BYTEORDER 3-#elif !defined(__FLOAT_WORD_ORDER) && !defined(_FLOAT_WORD_ORDER)-/* Float word order not known, assume not a hybrid. */-#define DUK_USE_BYTEORDER 3-#else-/* Byte order is big endian but cannot determine IEEE double word order. */-#endif  /* float word order */-#else-/* Cannot determine byte order. */-#endif  /* integer byte order */-#endif  /* !defined(DUK_USE_BYTEORDER) */--/* QNX gcc cross compiler seems to define e.g. __LITTLEENDIAN__ or __BIGENDIAN__:- *  $ /opt/qnx650/host/linux/x86/usr/bin/i486-pc-nto-qnx6.5.0-gcc -dM -E - </dev/null | grep -ni endian- *  67:#define __LITTLEENDIAN__ 1- *  $ /opt/qnx650/host/linux/x86/usr/bin/mips-unknown-nto-qnx6.5.0-gcc -dM -E - </dev/null | grep -ni endian- *  81:#define __BIGENDIAN__ 1- *  $ /opt/qnx650/host/linux/x86/usr/bin/arm-unknown-nto-qnx6.5.0-gcc -dM -E - </dev/null | grep -ni endian- *  70:#define __LITTLEENDIAN__ 1- */-#if !defined(DUK_USE_BYTEORDER)-#if defined(__LITTLEENDIAN__)-#define DUK_USE_BYTEORDER 1-#elif defined(__BIGENDIAN__)-#define DUK_USE_BYTEORDER 3-#endif-#endif--/*- *  Alignment requirement and support for unaligned accesses- *- *  Assume unaligned accesses are not supported unless specifically allowed- *  in the target platform.  Some platforms may support unaligned accesses- *  but alignment to 4 or 8 may still be desirable.- */--/* If not provided, use safe default for alignment. */-#if !defined(DUK_USE_ALIGN_BY)-#define DUK_USE_ALIGN_BY 8-#endif--/* Compiler specific hackery needed to force struct size to match aligment,- * see e.g. duk_hbuffer.h.- *- * http://stackoverflow.com/questions/11130109/c-struct-size-alignment- * http://stackoverflow.com/questions/10951039/specifying-64-bit-alignment- */-#if !(defined(DUK_USE_PACK_MSVC_PRAGMA) || defined(DUK_USE_PACK_GCC_ATTR) || \-      defined(DUK_USE_PACK_CLANG_ATTR) || defined(DUK_USE_PACK_DUMMY_MEMBER))-#define DUK_USE_PACK_DUMMY_MEMBER-#endif--#if !defined(DUK_VA_COPY)-/* We need va_copy() which is defined in C99 / C++11, so an awkward- * replacement is needed for pre-C99 / pre-C++11 environments.  This- * will quite likely need portability hacks for some non-C99- * environments.- */-#if defined(DUK_F_C99) || defined(DUK_F_CPP11)-/* C99 / C++11 and above: rely on va_copy() which is required.- * Omit parenthesis on macro right side on purpose to minimize differences- * to direct use.- */-#define DUK_VA_COPY(dest,src) va_copy(dest,src)-#else-/* Pre-C99: va_list type is implementation dependent.  This replacement- * assumes it is a plain value so that a simple assignment will work.- * This is not the case on all platforms (it may be a single-array element,- * for instance).- */-#define DUK_VA_COPY(dest,src) do { (dest) = (src); } while (0)-#endif-#endif--#if !defined(DUK_MACRO_STRINGIFY)-/* Macro hackery to convert e.g. __LINE__ to a string without formatting,- * see: http://stackoverflow.com/questions/240353/convert-a-preprocessor-token-to-a-string- */-#define DUK_MACRO_STRINGIFY_HELPER(x)  #x-#define DUK_MACRO_STRINGIFY(x)  DUK_MACRO_STRINGIFY_HELPER(x)-#endif--#if !defined(DUK_CAUSE_SEGFAULT)-/* This can be used for testing; valgrind will then indicate the C call stack- * leading to the call site.- */-#define DUK_CAUSE_SEGFAULT()  do { *((volatile duk_uint32_t *) NULL) = (duk_uint32_t) 0xdeadbeefUL; } while (0)-#endif-#if !defined(DUK_UNREF)-/* Macro for suppressing warnings for potentially unreferenced variables.- * The variables can be actually unreferenced or unreferenced in some- * specific cases only; for instance, if a variable is only debug printed,- * it is unreferenced when debug printing is disabled.- */-#define DUK_UNREF(x)  do { (void) (x); } while (0)-#endif-#if !defined(DUK_NORETURN)-#define DUK_NORETURN(decl)  decl-#endif-#if !defined(DUK_UNREACHABLE)-/* Don't know how to declare unreachable point, so don't do it; this- * may cause some spurious compilation warnings (e.g. "variable used- * uninitialized").- */-#define DUK_UNREACHABLE()  do { } while (0)-#endif-#if !defined(DUK_LOSE_CONST)-/* Convert any input pointer into a "void *", losing a const qualifier.- * This is not fully portable because casting through duk_uintptr_t may- * not work on all architectures (e.g. those with long, segmented pointers).- */-#define DUK_LOSE_CONST(src) ((void *) (duk_uintptr_t) (src))-#endif--#if !defined(DUK_LIKELY)-#define DUK_LIKELY(x)    (x)-#endif-#if !defined(DUK_UNLIKELY)-#define DUK_UNLIKELY(x)  (x)-#endif-#if !defined(DUK_UNPREDICTABLE)-#define DUK_UNPREDICTABLE(x)  (x)-#endif--#if !defined(DUK_NOINLINE)-#define DUK_NOINLINE       /*nop*/-#endif-#if !defined(DUK_INLINE)-#define DUK_INLINE         /*nop*/-#endif-#if !defined(DUK_ALWAYS_INLINE)-#define DUK_ALWAYS_INLINE  /*nop*/-#endif--#if !defined(DUK_EXTERNAL_DECL)-#define DUK_EXTERNAL_DECL  extern-#endif-#if !defined(DUK_EXTERNAL)-#define DUK_EXTERNAL       /*empty*/-#endif-#if !defined(DUK_INTERNAL_DECL)-#if defined(DUK_SINGLE_FILE)-#define DUK_INTERNAL_DECL  static-#else-#define DUK_INTERNAL_DECL  extern-#endif-#endif-#if !defined(DUK_INTERNAL)-#if defined(DUK_SINGLE_FILE)-#define DUK_INTERNAL       static-#else-#define DUK_INTERNAL       /*empty*/-#endif-#endif-#if !defined(DUK_LOCAL_DECL)-#define DUK_LOCAL_DECL     static-#endif-#if !defined(DUK_LOCAL)-#define DUK_LOCAL          static-#endif--#if !defined(DUK_FILE_MACRO)-#define DUK_FILE_MACRO  __FILE__-#endif-#if !defined(DUK_LINE_MACRO)-#define DUK_LINE_MACRO  __LINE__-#endif-#if !defined(DUK_FUNC_MACRO)-#if defined(DUK_F_C99) || defined(DUK_F_CPP11)-#define DUK_FUNC_MACRO  __func__-#elif defined(__FUNCTION__)-#define DUK_FUNC_MACRO  __FUNCTION__-#else-#define DUK_FUNC_MACRO  "unknown"-#endif-#endif--#if !defined(DUK_BSWAP32)-#define DUK_BSWAP32(x) \-	((((duk_uint32_t) (x)) >> 24) | \-	 ((((duk_uint32_t) (x)) >> 8) & 0xff00UL) | \-	 ((((duk_uint32_t) (x)) << 8) & 0xff0000UL) | \-	 (((duk_uint32_t) (x)) << 24))-#endif-#if !defined(DUK_BSWAP16)-#define DUK_BSWAP16(x) \-	((duk_uint16_t) (x) >> 8) | \-	((duk_uint16_t) (x) << 8)-#endif--/* DUK_USE_VARIADIC_MACROS: required from compilers, so no fill-in. */-/* DUK_USE_UNION_INITIALIZERS: required from compilers, so no fill-in. */--#if !(defined(DUK_USE_FLEX_C99) || defined(DUK_USE_FLEX_ZEROSIZE) || defined(DUK_USE_FLEX_ONESIZE))-#if defined(DUK_F_C99)-#define DUK_USE_FLEX_C99-#else-#define DUK_USE_FLEX_ZEROSIZE  /* Not standard but common enough */-#endif-#endif--#if !(defined(DUK_USE_PACK_GCC_ATTR) || defined(DUK_USE_PACK_CLANG_ATTR) || \-      defined(DUK_USE_PACK_MSVC_PRAGMA) || defined(DUK_USE_PACK_DUMMY_MEMBER))-#define DUK_USE_PACK_DUMMY_MEMBER-#endif--#if 0  /* not defined by default */-#undef DUK_USE_GCC_PRAGMAS-#endif--/* Workaround for GH-323: avoid inlining control when compiling from- * multiple sources, as it causes compiler portability trouble.- */-#if !defined(DUK_SINGLE_FILE)-#undef DUK_NOINLINE-#undef DUK_INLINE-#undef DUK_ALWAYS_INLINE-#define DUK_NOINLINE       /*nop*/-#define DUK_INLINE         /*nop*/-#define DUK_ALWAYS_INLINE  /*nop*/-#endif--/*- *  Check whether or not a packed duk_tval representation is possible.- *  What's basically required is that pointers are 32-bit values- *  (sizeof(void *) == 4).  Best effort check, not always accurate.- *  If guess goes wrong, crashes may result; self tests also verify- *  the guess.- */--/* Explicit marker needed; may be 'defined', 'undefined, 'or 'not provided'. */-#if !defined(DUK_F_PACKED_TVAL_PROVIDED)-#undef DUK_F_PACKED_TVAL_POSSIBLE--/* Strict C99 case: DUK_UINTPTR_MAX (= UINTPTR_MAX) should be very reliable */-#if !defined(DUK_F_PACKED_TVAL_POSSIBLE) && defined(DUK_UINTPTR_MAX)-#if (DUK_UINTPTR_MAX <= 0xffffffffUL)-#define DUK_F_PACKED_TVAL_POSSIBLE-#endif-#endif--/* Non-C99 case, still relying on DUK_UINTPTR_MAX, as long as it is not a computed value */-#if !defined(DUK_F_PACKED_TVAL_POSSIBLE) && defined(DUK_UINTPTR_MAX) && !defined(DUK_UINTPTR_MAX_COMPUTED)-#if (DUK_UINTPTR_MAX <= 0xffffffffUL)-#define DUK_F_PACKED_TVAL_POSSIBLE-#endif-#endif--/* DUK_SIZE_MAX (= SIZE_MAX) is often reliable */-#if !defined(DUK_F_PACKED_TVAL_POSSIBLE) && defined(DUK_SIZE_MAX) && !defined(DUK_SIZE_MAX_COMPUTED)-#if (DUK_SIZE_MAX <= 0xffffffffUL)-#define DUK_F_PACKED_TVAL_POSSIBLE-#endif-#endif--#undef DUK_USE_PACKED_TVAL-#if defined(DUK_F_PACKED_TVAL_POSSIBLE)-#define DUK_USE_PACKED_TVAL-#endif--#undef DUK_F_PACKED_TVAL_POSSIBLE-#endif  /* DUK_F_PACKED_TVAL_PROVIDED */-/* Object property allocation layout has implications for memory and code- * footprint and generated code size/speed.  The best layout also depends- * on whether the platform has alignment requirements or benefits from- * having mostly aligned accesses.- */-#undef DUK_USE_HOBJECT_LAYOUT_1-#undef DUK_USE_HOBJECT_LAYOUT_2-#undef DUK_USE_HOBJECT_LAYOUT_3-#if (DUK_USE_ALIGN_BY == 1)-/* On platforms without any alignment issues, layout 1 is preferable- * because it compiles to slightly less code and provides direct access- * to property keys.- */-#define DUK_USE_HOBJECT_LAYOUT_1-#else-/* On other platforms use layout 2, which requires some padding but- * is a bit more natural than layout 3 in ordering the entries.  Layout- * 3 is currently not used.- */-#define DUK_USE_HOBJECT_LAYOUT_2-#endif--/* GCC/clang inaccurate math would break compliance and probably duk_tval,- * so refuse to compile.  Relax this if -ffast-math is tested to work.- */-#if defined(__FAST_MATH__)-#error __FAST_MATH__ defined, refusing to compile-#endif--/*- *  Autogenerated defaults- */--#define DUK_USE_ARRAY_BUILTIN-#define DUK_USE_ARRAY_FASTPATH-#define DUK_USE_ARRAY_PROP_FASTPATH-#undef DUK_USE_ASSERTIONS-#define DUK_USE_AUGMENT_ERROR_CREATE-#define DUK_USE_AUGMENT_ERROR_THROW-#define DUK_USE_AVOID_PLATFORM_FUNCPTRS-#define DUK_USE_BASE64_FASTPATH-#define DUK_USE_BOOLEAN_BUILTIN-#define DUK_USE_BUFFEROBJECT_SUPPORT-#undef DUK_USE_BUFLEN16-#define DUK_USE_BYTECODE_DUMP_SUPPORT-#define DUK_USE_COMMONJS_MODULES-#define DUK_USE_COMPILER_RECLIMIT 2500-#define DUK_USE_COROUTINE_SUPPORT-#undef DUK_USE_CPP_EXCEPTIONS-#undef DUK_USE_DATAPTR16-#undef DUK_USE_DATAPTR_DEC16-#undef DUK_USE_DATAPTR_ENC16-#define DUK_USE_DATE_BUILTIN-#undef DUK_USE_DATE_FORMAT_STRING-#undef DUK_USE_DATE_GET_LOCAL_TZOFFSET-#undef DUK_USE_DATE_GET_NOW-#undef DUK_USE_DATE_PARSE_STRING-#undef DUK_USE_DATE_PRS_GETDATE-#undef DUK_USE_DEBUG-#undef DUK_USE_DEBUGGER_DUMPHEAP-#undef DUK_USE_DEBUGGER_INSPECT-#undef DUK_USE_DEBUGGER_PAUSE_UNCAUGHT-#undef DUK_USE_DEBUGGER_SUPPORT-#define DUK_USE_DEBUGGER_THROW_NOTIFY-#undef DUK_USE_DEBUGGER_TRANSPORT_TORTURE-#define DUK_USE_DEBUG_BUFSIZE 65536L-#define DUK_USE_DEBUG_LEVEL 0-#undef DUK_USE_DEBUG_WRITE-#define DUK_USE_DOUBLE_LINKED_HEAP-#define DUK_USE_DUKTAPE_BUILTIN-#define DUK_USE_ENCODING_BUILTINS-#define DUK_USE_ERRCREATE-#define DUK_USE_ERRTHROW-#define DUK_USE_ES6-#define DUK_USE_ES6_OBJECT_PROTO_PROPERTY-#define DUK_USE_ES6_OBJECT_SETPROTOTYPEOF-#define DUK_USE_ES6_PROXY-#define DUK_USE_ES6_REGEXP_SYNTAX-#define DUK_USE_ES6_UNICODE_ESCAPE-#define DUK_USE_ES7_EXP_OPERATOR-#define DUK_USE_ESBC_LIMITS-#define DUK_USE_ESBC_MAX_BYTES 2147418112L-#define DUK_USE_ESBC_MAX_LINENUMBER 2147418112L-#undef DUK_USE_EXEC_FUN_LOCAL-#undef DUK_USE_EXEC_INDIRECT_BOUND_CHECK-#undef DUK_USE_EXEC_PREFER_SIZE-#define DUK_USE_EXEC_REGCONST_OPTIMIZE-#undef DUK_USE_EXEC_TIMEOUT_CHECK-#undef DUK_USE_EXPLICIT_NULL_INIT-#undef DUK_USE_EXTSTR_FREE-#undef DUK_USE_EXTSTR_INTERN_CHECK-#undef DUK_USE_FASTINT-#define DUK_USE_FAST_REFCOUNT_DEFAULT-#undef DUK_USE_FATAL_HANDLER-#define DUK_USE_FINALIZER_SUPPORT-#undef DUK_USE_FUNCPTR16-#undef DUK_USE_FUNCPTR_DEC16-#undef DUK_USE_FUNCPTR_ENC16-#define DUK_USE_FUNCTION_BUILTIN-#define DUK_USE_FUNC_FILENAME_PROPERTY-#define DUK_USE_FUNC_NAME_PROPERTY-#undef DUK_USE_GC_TORTURE-#undef DUK_USE_GET_RANDOM_DOUBLE-#define DUK_USE_GLOBAL_BUILTIN-#undef DUK_USE_HEAPPTR16-#undef DUK_USE_HEAPPTR_DEC16-#undef DUK_USE_HEAPPTR_ENC16-#define DUK_USE_HEX_FASTPATH-#define DUK_USE_HOBJECT_HASH_PART-#define DUK_USE_HSTRING_ARRIDX-#define DUK_USE_HSTRING_CLEN-#undef DUK_USE_HSTRING_EXTDATA-#define DUK_USE_IDCHAR_FASTPATH-#undef DUK_USE_INTERRUPT_COUNTER-#undef DUK_USE_INTERRUPT_DEBUG_FIXUP-#define DUK_USE_JC-#define DUK_USE_JSON_BUILTIN-#define DUK_USE_JSON_DECNUMBER_FASTPATH-#define DUK_USE_JSON_DECSTRING_FASTPATH-#define DUK_USE_JSON_DEC_RECLIMIT 1000-#define DUK_USE_JSON_EATWHITE_FASTPATH-#define DUK_USE_JSON_ENC_RECLIMIT 1000-#define DUK_USE_JSON_QUOTESTRING_FASTPATH-#undef DUK_USE_JSON_STRINGIFY_FASTPATH-#define DUK_USE_JSON_SUPPORT-#define DUK_USE_JX-#define DUK_USE_LEXER_SLIDING_WINDOW-#undef DUK_USE_LIGHTFUNC_BUILTINS-#undef DUK_USE_MARKANDSWEEP_FINALIZER_TORTURE-#define DUK_USE_MARK_AND_SWEEP_RECLIMIT 256-#define DUK_USE_MATH_BUILTIN-#define DUK_USE_MS_STRINGTABLE_RESIZE-#define DUK_USE_NATIVE_CALL_RECLIMIT 1000-#define DUK_USE_NONSTD_ARRAY_CONCAT_TRAILER-#define DUK_USE_NONSTD_ARRAY_MAP_TRAILER-#define DUK_USE_NONSTD_ARRAY_SPLICE_DELCOUNT-#undef DUK_USE_NONSTD_FUNC_CALLER_PROPERTY-#undef DUK_USE_NONSTD_FUNC_SOURCE_PROPERTY-#define DUK_USE_NONSTD_FUNC_STMT-#define DUK_USE_NONSTD_GETTER_KEY_ARGUMENT-#define DUK_USE_NONSTD_JSON_ESC_U2028_U2029-#define DUK_USE_NONSTD_SETTER_KEY_ARGUMENT-#define DUK_USE_NONSTD_STRING_FROMCHARCODE_32BIT-#define DUK_USE_NUMBER_BUILTIN-#define DUK_USE_OBJECT_BUILTIN-#undef DUK_USE_OBJSIZES16-#undef DUK_USE_PARANOID_ERRORS-#define DUK_USE_PC2LINE-#undef DUK_USE_PREFER_SIZE-#define DUK_USE_PROVIDE_DEFAULT_ALLOC_FUNCTIONS-#undef DUK_USE_REFCOUNT16-#define DUK_USE_REFERENCE_COUNTING-#define DUK_USE_REFLECT_BUILTIN-#undef DUK_USE_REFZERO_FINALIZER_TORTURE-#undef DUK_USE_REGEXP_CANON_WORKAROUND-#define DUK_USE_REGEXP_COMPILER_RECLIMIT 10000-#define DUK_USE_REGEXP_EXECUTOR_RECLIMIT 10000-#define DUK_USE_REGEXP_SUPPORT-#undef DUK_USE_ROM_GLOBAL_CLONE-#undef DUK_USE_ROM_GLOBAL_INHERIT-#undef DUK_USE_ROM_OBJECTS-#define DUK_USE_ROM_PTRCOMP_FIRST 63488L-#undef DUK_USE_ROM_STRINGS-#define DUK_USE_SECTION_B-#undef DUK_USE_SELF_TESTS-#undef DUK_USE_SHUFFLE_TORTURE-#define DUK_USE_SOURCE_NONBMP-#undef DUK_USE_STRHASH16-#undef DUK_USE_STRHASH_DENSE-#define DUK_USE_STRHASH_SKIP_SHIFT 5-#define DUK_USE_STRICT_DECL-#undef DUK_USE_STRICT_UTF8_SOURCE-#define DUK_USE_STRING_BUILTIN-#undef DUK_USE_STRLEN16-#undef DUK_USE_STRTAB_CHAIN-#undef DUK_USE_STRTAB_CHAIN_SIZE-#define DUK_USE_STRTAB_PROBE-#undef DUK_USE_SYMBOL_BUILTIN-#define DUK_USE_TAILCALL-#define DUK_USE_TARGET_INFO "unknown"-#define DUK_USE_TRACEBACKS-#define DUK_USE_TRACEBACK_DEPTH 10-#define DUK_USE_USER_DECLARE() /* no user declarations */-#undef DUK_USE_VALSTACK_UNSAFE-#define DUK_USE_VERBOSE_ERRORS-#define DUK_USE_VERBOSE_EXECUTOR_ERRORS-#define DUK_USE_VOLUNTARY_GC-#define DUK_USE_ZERO_BUFFER_DATA--/*- *  You may add overriding #define/#undef directives below for- *  customization.  You of course cannot un-#include or un-typedef- *  anything; these require direct changes above.- */--/* __OVERRIDE_DEFINES__ */--/*- *  Date provider selection- *- *  User may define DUK_USE_DATE_GET_NOW() etc directly, in which case we'll- *  rely on an external provider.  If this is not done, revert to previous- *  behavior and use Unix/Windows built-in provider.- */--#if defined(DUK_COMPILING_DUKTAPE)--#if defined(DUK_USE_DATE_GET_NOW)-/* External provider already defined. */-#elif defined(DUK_USE_DATE_NOW_GETTIMEOFDAY)-#define DUK_USE_DATE_GET_NOW(ctx)            duk_bi_date_get_now_gettimeofday((ctx))-#elif defined(DUK_USE_DATE_NOW_TIME)-#define DUK_USE_DATE_GET_NOW(ctx)            duk_bi_date_get_now_time((ctx))-#elif defined(DUK_USE_DATE_NOW_WINDOWS)-#define DUK_USE_DATE_GET_NOW(ctx)            duk_bi_date_get_now_windows((ctx))-#else-#error no provider for DUK_USE_DATE_GET_NOW()-#endif--#if defined(DUK_USE_DATE_GET_LOCAL_TZOFFSET)-/* External provider already defined. */-#elif defined(DUK_USE_DATE_TZO_GMTIME_R) || defined(DUK_USE_DATE_TZO_GMTIME)-#define DUK_USE_DATE_GET_LOCAL_TZOFFSET(d)   duk_bi_date_get_local_tzoffset_gmtime((d))-#elif defined(DUK_USE_DATE_TZO_WINDOWS)-#define DUK_USE_DATE_GET_LOCAL_TZOFFSET(d)   duk_bi_date_get_local_tzoffset_windows((d))-#else-#error no provider for DUK_USE_DATE_GET_LOCAL_TZOFFSET()-#endif--#if defined(DUK_USE_DATE_PARSE_STRING)-/* External provider already defined. */-#elif defined(DUK_USE_DATE_PRS_STRPTIME)-#define DUK_USE_DATE_PARSE_STRING(ctx,str)   duk_bi_date_parse_string_strptime((ctx), (str))-#elif defined(DUK_USE_DATE_PRS_GETDATE)-#define DUK_USE_DATE_PARSE_STRING(ctx,str)   duk_bi_date_parse_string_getdate((ctx), (str))-#else-/* No provider for DUK_USE_DATE_PARSE_STRING(), fall back to ISO 8601 only. */-#endif--#if defined(DUK_USE_DATE_FORMAT_STRING)-/* External provider already defined. */-#elif defined(DUK_USE_DATE_FMT_STRFTIME)-#define DUK_USE_DATE_FORMAT_STRING(ctx,parts,tzoffset,flags) \-	duk_bi_date_format_parts_strftime((ctx), (parts), (tzoffset), (flags))-#else-/* No provider for DUK_USE_DATE_FORMAT_STRING(), fall back to ISO 8601 only. */-#endif--#endif  /* DUK_COMPILING_DUKTAPE */--/*- *  Checks for legacy feature options (DUK_OPT_xxx)- */--#if defined(DUK_OPT_ASSERTIONS)-#error unsupported legacy feature option DUK_OPT_ASSERTIONS used-#endif-#if defined(DUK_OPT_BUFFEROBJECT_SUPPORT)-#error unsupported legacy feature option DUK_OPT_BUFFEROBJECT_SUPPORT used-#endif-#if defined(DUK_OPT_BUFLEN16)-#error unsupported legacy feature option DUK_OPT_BUFLEN16 used-#endif-#if defined(DUK_OPT_DATAPTR16)-#error unsupported legacy feature option DUK_OPT_DATAPTR16 used-#endif-#if defined(DUK_OPT_DATAPTR_DEC16)-#error unsupported legacy feature option DUK_OPT_DATAPTR_DEC16 used-#endif-#if defined(DUK_OPT_DATAPTR_ENC16)-#error unsupported legacy feature option DUK_OPT_DATAPTR_ENC16 used-#endif-#if defined(DUK_OPT_DDDPRINT)-#error unsupported legacy feature option DUK_OPT_DDDPRINT used-#endif-#if defined(DUK_OPT_DDPRINT)-#error unsupported legacy feature option DUK_OPT_DDPRINT used-#endif-#if defined(DUK_OPT_DEBUG)-#error unsupported legacy feature option DUK_OPT_DEBUG used-#endif-#if defined(DUK_OPT_DEBUGGER_DUMPHEAP)-#error unsupported legacy feature option DUK_OPT_DEBUGGER_DUMPHEAP used-#endif-#if defined(DUK_OPT_DEBUGGER_FWD_LOGGING)-#error unsupported legacy feature option DUK_OPT_DEBUGGER_FWD_LOGGING used-#endif-#if defined(DUK_OPT_DEBUGGER_FWD_PRINTALERT)-#error unsupported legacy feature option DUK_OPT_DEBUGGER_FWD_PRINTALERT used-#endif-#if defined(DUK_OPT_DEBUGGER_SUPPORT)-#error unsupported legacy feature option DUK_OPT_DEBUGGER_SUPPORT used-#endif-#if defined(DUK_OPT_DEBUGGER_TRANSPORT_TORTURE)-#error unsupported legacy feature option DUK_OPT_DEBUGGER_TRANSPORT_TORTURE used-#endif-#if defined(DUK_OPT_DEBUG_BUFSIZE)-#error unsupported legacy feature option DUK_OPT_DEBUG_BUFSIZE used-#endif-#if defined(DUK_OPT_DECLARE)-#error unsupported legacy feature option DUK_OPT_DECLARE used-#endif-#if defined(DUK_OPT_DEEP_C_STACK)-#error unsupported legacy feature option DUK_OPT_DEEP_C_STACK used-#endif-#if defined(DUK_OPT_DLL_BUILD)-#error unsupported legacy feature option DUK_OPT_DLL_BUILD used-#endif-#if defined(DUK_OPT_DPRINT)-#error unsupported legacy feature option DUK_OPT_DPRINT used-#endif-#if defined(DUK_OPT_DPRINT_COLORS)-#error unsupported legacy feature option DUK_OPT_DPRINT_COLORS used-#endif-#if defined(DUK_OPT_DPRINT_RDTSC)-#error unsupported legacy feature option DUK_OPT_DPRINT_RDTSC used-#endif-#if defined(DUK_OPT_EXEC_TIMEOUT_CHECK)-#error unsupported legacy feature option DUK_OPT_EXEC_TIMEOUT_CHECK used-#endif-#if defined(DUK_OPT_EXTERNAL_STRINGS)-#error unsupported legacy feature option DUK_OPT_EXTERNAL_STRINGS used-#endif-#if defined(DUK_OPT_EXTSTR_FREE)-#error unsupported legacy feature option DUK_OPT_EXTSTR_FREE used-#endif-#if defined(DUK_OPT_EXTSTR_INTERN_CHECK)-#error unsupported legacy feature option DUK_OPT_EXTSTR_INTERN_CHECK used-#endif-#if defined(DUK_OPT_FASTINT)-#error unsupported legacy feature option DUK_OPT_FASTINT used-#endif-#if defined(DUK_OPT_FORCE_ALIGN)-#error unsupported legacy feature option DUK_OPT_FORCE_ALIGN used-#endif-#if defined(DUK_OPT_FORCE_BYTEORDER)-#error unsupported legacy feature option DUK_OPT_FORCE_BYTEORDER used-#endif-#if defined(DUK_OPT_FUNCPTR16)-#error unsupported legacy feature option DUK_OPT_FUNCPTR16 used-#endif-#if defined(DUK_OPT_FUNCPTR_DEC16)-#error unsupported legacy feature option DUK_OPT_FUNCPTR_DEC16 used-#endif-#if defined(DUK_OPT_FUNCPTR_ENC16)-#error unsupported legacy feature option DUK_OPT_FUNCPTR_ENC16 used-#endif-#if defined(DUK_OPT_FUNC_NONSTD_CALLER_PROPERTY)-#error unsupported legacy feature option DUK_OPT_FUNC_NONSTD_CALLER_PROPERTY used-#endif-#if defined(DUK_OPT_FUNC_NONSTD_SOURCE_PROPERTY)-#error unsupported legacy feature option DUK_OPT_FUNC_NONSTD_SOURCE_PROPERTY used-#endif-#if defined(DUK_OPT_GC_TORTURE)-#error unsupported legacy feature option DUK_OPT_GC_TORTURE used-#endif-#if defined(DUK_OPT_HAVE_CUSTOM_H)-#error unsupported legacy feature option DUK_OPT_HAVE_CUSTOM_H used-#endif-#if defined(DUK_OPT_HEAPPTR16)-#error unsupported legacy feature option DUK_OPT_HEAPPTR16 used-#endif-#if defined(DUK_OPT_HEAPPTR_DEC16)-#error unsupported legacy feature option DUK_OPT_HEAPPTR_DEC16 used-#endif-#if defined(DUK_OPT_HEAPPTR_ENC16)-#error unsupported legacy feature option DUK_OPT_HEAPPTR_ENC16 used-#endif-#if defined(DUK_OPT_INTERRUPT_COUNTER)-#error unsupported legacy feature option DUK_OPT_INTERRUPT_COUNTER used-#endif-#if defined(DUK_OPT_JSON_STRINGIFY_FASTPATH)-#error unsupported legacy feature option DUK_OPT_JSON_STRINGIFY_FASTPATH used-#endif-#if defined(DUK_OPT_LIGHTFUNC_BUILTINS)-#error unsupported legacy feature option DUK_OPT_LIGHTFUNC_BUILTINS used-#endif-#if defined(DUK_OPT_NONSTD_FUNC_CALLER_PROPERTY)-#error unsupported legacy feature option DUK_OPT_NONSTD_FUNC_CALLER_PROPERTY used-#endif-#if defined(DUK_OPT_NONSTD_FUNC_SOURCE_PROPERTY)-#error unsupported legacy feature option DUK_OPT_NONSTD_FUNC_SOURCE_PROPERTY used-#endif-#if defined(DUK_OPT_NO_ARRAY_SPLICE_NONSTD_DELCOUNT)-#error unsupported legacy feature option DUK_OPT_NO_ARRAY_SPLICE_NONSTD_DELCOUNT used-#endif-#if defined(DUK_OPT_NO_AUGMENT_ERRORS)-#error unsupported legacy feature option DUK_OPT_NO_AUGMENT_ERRORS used-#endif-#if defined(DUK_OPT_NO_BROWSER_LIKE)-#error unsupported legacy feature option DUK_OPT_NO_BROWSER_LIKE used-#endif-#if defined(DUK_OPT_NO_BUFFEROBJECT_SUPPORT)-#error unsupported legacy feature option DUK_OPT_NO_BUFFEROBJECT_SUPPORT used-#endif-#if defined(DUK_OPT_NO_BYTECODE_DUMP_SUPPORT)-#error unsupported legacy feature option DUK_OPT_NO_BYTECODE_DUMP_SUPPORT used-#endif-#if defined(DUK_OPT_NO_COMMONJS_MODULES)-#error unsupported legacy feature option DUK_OPT_NO_COMMONJS_MODULES used-#endif-#if defined(DUK_OPT_NO_ES6_OBJECT_PROTO_PROPERTY)-#error unsupported legacy feature option DUK_OPT_NO_ES6_OBJECT_PROTO_PROPERTY used-#endif-#if defined(DUK_OPT_NO_ES6_OBJECT_SETPROTOTYPEOF)-#error unsupported legacy feature option DUK_OPT_NO_ES6_OBJECT_SETPROTOTYPEOF used-#endif-#if defined(DUK_OPT_NO_ES6_PROXY)-#error unsupported legacy feature option DUK_OPT_NO_ES6_PROXY used-#endif-#if defined(DUK_OPT_NO_FILE_IO)-#error unsupported legacy feature option DUK_OPT_NO_FILE_IO used-#endif-#if defined(DUK_OPT_NO_FUNC_STMT)-#error unsupported legacy feature option DUK_OPT_NO_FUNC_STMT used-#endif-#if defined(DUK_OPT_NO_JC)-#error unsupported legacy feature option DUK_OPT_NO_JC used-#endif-#if defined(DUK_OPT_NO_JSONC)-#error unsupported legacy feature option DUK_OPT_NO_JSONC used-#endif-#if defined(DUK_OPT_NO_JSONX)-#error unsupported legacy feature option DUK_OPT_NO_JSONX used-#endif-#if defined(DUK_OPT_NO_JX)-#error unsupported legacy feature option DUK_OPT_NO_JX used-#endif-#if defined(DUK_OPT_NO_MARK_AND_SWEEP)-#error unsupported legacy feature option DUK_OPT_NO_MARK_AND_SWEEP used-#endif-#if defined(DUK_OPT_NO_MS_STRINGTABLE_RESIZE)-#error unsupported legacy feature option DUK_OPT_NO_MS_STRINGTABLE_RESIZE used-#endif-#if defined(DUK_OPT_NO_NONSTD_ACCESSOR_KEY_ARGUMENT)-#error unsupported legacy feature option DUK_OPT_NO_NONSTD_ACCESSOR_KEY_ARGUMENT used-#endif-#if defined(DUK_OPT_NO_NONSTD_ARRAY_CONCAT_TRAILER)-#error unsupported legacy feature option DUK_OPT_NO_NONSTD_ARRAY_CONCAT_TRAILER used-#endif-#if defined(DUK_OPT_NO_NONSTD_ARRAY_MAP_TRAILER)-#error unsupported legacy feature option DUK_OPT_NO_NONSTD_ARRAY_MAP_TRAILER used-#endif-#if defined(DUK_OPT_NO_NONSTD_ARRAY_SPLICE_DELCOUNT)-#error unsupported legacy feature option DUK_OPT_NO_NONSTD_ARRAY_SPLICE_DELCOUNT used-#endif-#if defined(DUK_OPT_NO_NONSTD_FUNC_STMT)-#error unsupported legacy feature option DUK_OPT_NO_NONSTD_FUNC_STMT used-#endif-#if defined(DUK_OPT_NO_NONSTD_JSON_ESC_U2028_U2029)-#error unsupported legacy feature option DUK_OPT_NO_NONSTD_JSON_ESC_U2028_U2029 used-#endif-#if defined(DUK_OPT_NO_NONSTD_STRING_FROMCHARCODE_32BIT)-#error unsupported legacy feature option DUK_OPT_NO_NONSTD_STRING_FROMCHARCODE_32BIT used-#endif-#if defined(DUK_OPT_NO_OBJECT_ES6_PROTO_PROPERTY)-#error unsupported legacy feature option DUK_OPT_NO_OBJECT_ES6_PROTO_PROPERTY used-#endif-#if defined(DUK_OPT_NO_OBJECT_ES6_SETPROTOTYPEOF)-#error unsupported legacy feature option DUK_OPT_NO_OBJECT_ES6_SETPROTOTYPEOF used-#endif-#if defined(DUK_OPT_NO_OCTAL_SUPPORT)-#error unsupported legacy feature option DUK_OPT_NO_OCTAL_SUPPORT used-#endif-#if defined(DUK_OPT_NO_PACKED_TVAL)-#error unsupported legacy feature option DUK_OPT_NO_PACKED_TVAL used-#endif-#if defined(DUK_OPT_NO_PC2LINE)-#error unsupported legacy feature option DUK_OPT_NO_PC2LINE used-#endif-#if defined(DUK_OPT_NO_REFERENCE_COUNTING)-#error unsupported legacy feature option DUK_OPT_NO_REFERENCE_COUNTING used-#endif-#if defined(DUK_OPT_NO_REGEXP_SUPPORT)-#error unsupported legacy feature option DUK_OPT_NO_REGEXP_SUPPORT used-#endif-#if defined(DUK_OPT_NO_SECTION_B)-#error unsupported legacy feature option DUK_OPT_NO_SECTION_B used-#endif-#if defined(DUK_OPT_NO_SOURCE_NONBMP)-#error unsupported legacy feature option DUK_OPT_NO_SOURCE_NONBMP used-#endif-#if defined(DUK_OPT_NO_STRICT_DECL)-#error unsupported legacy feature option DUK_OPT_NO_STRICT_DECL used-#endif-#if defined(DUK_OPT_NO_TRACEBACKS)-#error unsupported legacy feature option DUK_OPT_NO_TRACEBACKS used-#endif-#if defined(DUK_OPT_NO_VERBOSE_ERRORS)-#error unsupported legacy feature option DUK_OPT_NO_VERBOSE_ERRORS used-#endif-#if defined(DUK_OPT_NO_VOLUNTARY_GC)-#error unsupported legacy feature option DUK_OPT_NO_VOLUNTARY_GC used-#endif-#if defined(DUK_OPT_NO_ZERO_BUFFER_DATA)-#error unsupported legacy feature option DUK_OPT_NO_ZERO_BUFFER_DATA used-#endif-#if defined(DUK_OPT_OBJSIZES16)-#error unsupported legacy feature option DUK_OPT_OBJSIZES16 used-#endif-#if defined(DUK_OPT_PANIC_HANDLER)-#error unsupported legacy feature option DUK_OPT_PANIC_HANDLER used-#endif-#if defined(DUK_OPT_REFCOUNT16)-#error unsupported legacy feature option DUK_OPT_REFCOUNT16 used-#endif-#if defined(DUK_OPT_SEGFAULT_ON_PANIC)-#error unsupported legacy feature option DUK_OPT_SEGFAULT_ON_PANIC used-#endif-#if defined(DUK_OPT_SELF_TESTS)-#error unsupported legacy feature option DUK_OPT_SELF_TESTS used-#endif-#if defined(DUK_OPT_SETJMP)-#error unsupported legacy feature option DUK_OPT_SETJMP used-#endif-#if defined(DUK_OPT_SHUFFLE_TORTURE)-#error unsupported legacy feature option DUK_OPT_SHUFFLE_TORTURE used-#endif-#if defined(DUK_OPT_SIGSETJMP)-#error unsupported legacy feature option DUK_OPT_SIGSETJMP used-#endif-#if defined(DUK_OPT_STRHASH16)-#error unsupported legacy feature option DUK_OPT_STRHASH16 used-#endif-#if defined(DUK_OPT_STRICT_UTF8_SOURCE)-#error unsupported legacy feature option DUK_OPT_STRICT_UTF8_SOURCE used-#endif-#if defined(DUK_OPT_STRLEN16)-#error unsupported legacy feature option DUK_OPT_STRLEN16 used-#endif-#if defined(DUK_OPT_STRTAB_CHAIN)-#error unsupported legacy feature option DUK_OPT_STRTAB_CHAIN used-#endif-#if defined(DUK_OPT_STRTAB_CHAIN_SIZE)-#error unsupported legacy feature option DUK_OPT_STRTAB_CHAIN_SIZE used-#endif-#if defined(DUK_OPT_TARGET_INFO)-#error unsupported legacy feature option DUK_OPT_TARGET_INFO used-#endif-#if defined(DUK_OPT_TRACEBACK_DEPTH)-#error unsupported legacy feature option DUK_OPT_TRACEBACK_DEPTH used-#endif-#if defined(DUK_OPT_UNDERSCORE_SETJMP)-#error unsupported legacy feature option DUK_OPT_UNDERSCORE_SETJMP used-#endif-#if defined(DUK_OPT_USER_INITJS)-#error unsupported legacy feature option DUK_OPT_USER_INITJS used-#endif--/*- *  Checks for config option consistency (DUK_USE_xxx)- */--#if defined(DUK_USE_32BIT_PTRS)-#error unsupported config option used (option has been removed): DUK_USE_32BIT_PTRS-#endif-#if defined(DUK_USE_ALIGN_4)-#error unsupported config option used (option has been removed): DUK_USE_ALIGN_4-#endif-#if defined(DUK_USE_ALIGN_8)-#error unsupported config option used (option has been removed): DUK_USE_ALIGN_8-#endif-#if defined(DUK_USE_BROWSER_LIKE)-#error unsupported config option used (option has been removed): DUK_USE_BROWSER_LIKE-#endif-#if defined(DUK_USE_BUILTIN_INITJS)-#error unsupported config option used (option has been removed): DUK_USE_BUILTIN_INITJS-#endif-#if defined(DUK_USE_BYTEORDER_FORCED)-#error unsupported config option used (option has been removed): DUK_USE_BYTEORDER_FORCED-#endif-#if defined(DUK_USE_DATAPTR_DEC16) && !defined(DUK_USE_DATAPTR16)-#error config option DUK_USE_DATAPTR_DEC16 requires option DUK_USE_DATAPTR16 (which is missing)-#endif-#if defined(DUK_USE_DATAPTR_ENC16) && !defined(DUK_USE_DATAPTR16)-#error config option DUK_USE_DATAPTR_ENC16 requires option DUK_USE_DATAPTR16 (which is missing)-#endif-#if defined(DUK_USE_DDDPRINT)-#error unsupported config option used (option has been removed): DUK_USE_DDDPRINT-#endif-#if defined(DUK_USE_DDPRINT)-#error unsupported config option used (option has been removed): DUK_USE_DDPRINT-#endif-#if defined(DUK_USE_DEBUGGER_FWD_LOGGING)-#error unsupported config option used (option has been removed): DUK_USE_DEBUGGER_FWD_LOGGING-#endif-#if defined(DUK_USE_DEBUGGER_FWD_PRINTALERT)-#error unsupported config option used (option has been removed): DUK_USE_DEBUGGER_FWD_PRINTALERT-#endif-#if defined(DUK_USE_DEBUGGER_SUPPORT) && !defined(DUK_USE_INTERRUPT_COUNTER)-#error config option DUK_USE_DEBUGGER_SUPPORT requires option DUK_USE_INTERRUPT_COUNTER (which is missing)-#endif-#if defined(DUK_USE_DEEP_C_STACK)-#error unsupported config option used (option has been removed): DUK_USE_DEEP_C_STACK-#endif-#if defined(DUK_USE_DOUBLE_BE)-#error unsupported config option used (option has been removed): DUK_USE_DOUBLE_BE-#endif-#if defined(DUK_USE_DOUBLE_BE) && defined(DUK_USE_DOUBLE_LE)-#error config option DUK_USE_DOUBLE_BE conflicts with option DUK_USE_DOUBLE_LE (which is also defined)-#endif-#if defined(DUK_USE_DOUBLE_BE) && defined(DUK_USE_DOUBLE_ME)-#error config option DUK_USE_DOUBLE_BE conflicts with option DUK_USE_DOUBLE_ME (which is also defined)-#endif-#if defined(DUK_USE_DOUBLE_LE)-#error unsupported config option used (option has been removed): DUK_USE_DOUBLE_LE-#endif-#if defined(DUK_USE_DOUBLE_LE) && defined(DUK_USE_DOUBLE_BE)-#error config option DUK_USE_DOUBLE_LE conflicts with option DUK_USE_DOUBLE_BE (which is also defined)-#endif-#if defined(DUK_USE_DOUBLE_LE) && defined(DUK_USE_DOUBLE_ME)-#error config option DUK_USE_DOUBLE_LE conflicts with option DUK_USE_DOUBLE_ME (which is also defined)-#endif-#if defined(DUK_USE_DOUBLE_ME)-#error unsupported config option used (option has been removed): DUK_USE_DOUBLE_ME-#endif-#if defined(DUK_USE_DOUBLE_ME) && defined(DUK_USE_DOUBLE_LE)-#error config option DUK_USE_DOUBLE_ME conflicts with option DUK_USE_DOUBLE_LE (which is also defined)-#endif-#if defined(DUK_USE_DOUBLE_ME) && defined(DUK_USE_DOUBLE_BE)-#error config option DUK_USE_DOUBLE_ME conflicts with option DUK_USE_DOUBLE_BE (which is also defined)-#endif-#if defined(DUK_USE_DPRINT)-#error unsupported config option used (option has been removed): DUK_USE_DPRINT-#endif-#if defined(DUK_USE_DPRINT) && !defined(DUK_USE_DEBUG)-#error config option DUK_USE_DPRINT requires option DUK_USE_DEBUG (which is missing)-#endif-#if defined(DUK_USE_DPRINT_COLORS)-#error unsupported config option used (option has been removed): DUK_USE_DPRINT_COLORS-#endif-#if defined(DUK_USE_DPRINT_RDTSC)-#error unsupported config option used (option has been removed): DUK_USE_DPRINT_RDTSC-#endif-#if defined(DUK_USE_ES6_REGEXP_BRACES)-#error unsupported config option used (option has been removed): DUK_USE_ES6_REGEXP_BRACES-#endif-#if defined(DUK_USE_ESBC_MAX_BYTES) && !defined(DUK_USE_ESBC_LIMITS)-#error config option DUK_USE_ESBC_MAX_BYTES requires option DUK_USE_ESBC_LIMITS (which is missing)-#endif-#if defined(DUK_USE_ESBC_MAX_LINENUMBER) && !defined(DUK_USE_ESBC_LIMITS)-#error config option DUK_USE_ESBC_MAX_LINENUMBER requires option DUK_USE_ESBC_LIMITS (which is missing)-#endif-#if defined(DUK_USE_EXEC_TIMEOUT_CHECK) && !defined(DUK_USE_INTERRUPT_COUNTER)-#error config option DUK_USE_EXEC_TIMEOUT_CHECK requires option DUK_USE_INTERRUPT_COUNTER (which is missing)-#endif-#if defined(DUK_USE_EXTSTR_FREE) && !defined(DUK_USE_HSTRING_EXTDATA)-#error config option DUK_USE_EXTSTR_FREE requires option DUK_USE_HSTRING_EXTDATA (which is missing)-#endif-#if defined(DUK_USE_EXTSTR_INTERN_CHECK) && !defined(DUK_USE_HSTRING_EXTDATA)-#error config option DUK_USE_EXTSTR_INTERN_CHECK requires option DUK_USE_HSTRING_EXTDATA (which is missing)-#endif-#if defined(DUK_USE_FASTINT) && !defined(DUK_USE_64BIT_OPS)-#error config option DUK_USE_FASTINT requires option DUK_USE_64BIT_OPS (which is missing)-#endif-#if defined(DUK_USE_FILE_IO)-#error unsupported config option used (option has been removed): DUK_USE_FILE_IO-#endif-#if defined(DUK_USE_FULL_TVAL)-#error unsupported config option used (option has been removed): DUK_USE_FULL_TVAL-#endif-#if defined(DUK_USE_FUNCPTR_DEC16) && !defined(DUK_USE_FUNCPTR16)-#error config option DUK_USE_FUNCPTR_DEC16 requires option DUK_USE_FUNCPTR16 (which is missing)-#endif-#if defined(DUK_USE_FUNCPTR_ENC16) && !defined(DUK_USE_FUNCPTR16)-#error config option DUK_USE_FUNCPTR_ENC16 requires option DUK_USE_FUNCPTR16 (which is missing)-#endif-#if defined(DUK_USE_HASHBYTES_UNALIGNED_U32_ACCESS)-#error unsupported config option used (option has been removed): DUK_USE_HASHBYTES_UNALIGNED_U32_ACCESS-#endif-#if defined(DUK_USE_HEAPPTR16) && defined(DUK_USE_DEBUG)-#error config option DUK_USE_HEAPPTR16 conflicts with option DUK_USE_DEBUG (which is also defined)-#endif-#if defined(DUK_USE_HEAPPTR_DEC16) && !defined(DUK_USE_HEAPPTR16)-#error config option DUK_USE_HEAPPTR_DEC16 requires option DUK_USE_HEAPPTR16 (which is missing)-#endif-#if defined(DUK_USE_HEAPPTR_ENC16) && !defined(DUK_USE_HEAPPTR16)-#error config option DUK_USE_HEAPPTR_ENC16 requires option DUK_USE_HEAPPTR16 (which is missing)-#endif-#if defined(DUK_USE_INTEGER_BE)-#error unsupported config option used (option has been removed): DUK_USE_INTEGER_BE-#endif-#if defined(DUK_USE_INTEGER_BE) && defined(DUK_USE_INTEGER_LE)-#error config option DUK_USE_INTEGER_BE conflicts with option DUK_USE_INTEGER_LE (which is also defined)-#endif-#if defined(DUK_USE_INTEGER_BE) && defined(DUK_USE_INTEGER_ME)-#error config option DUK_USE_INTEGER_BE conflicts with option DUK_USE_INTEGER_ME (which is also defined)-#endif-#if defined(DUK_USE_INTEGER_LE)-#error unsupported config option used (option has been removed): DUK_USE_INTEGER_LE-#endif-#if defined(DUK_USE_INTEGER_LE) && defined(DUK_USE_INTEGER_BE)-#error config option DUK_USE_INTEGER_LE conflicts with option DUK_USE_INTEGER_BE (which is also defined)-#endif-#if defined(DUK_USE_INTEGER_LE) && defined(DUK_USE_INTEGER_ME)-#error config option DUK_USE_INTEGER_LE conflicts with option DUK_USE_INTEGER_ME (which is also defined)-#endif-#if defined(DUK_USE_INTEGER_ME)-#error unsupported config option used (option has been removed): DUK_USE_INTEGER_ME-#endif-#if defined(DUK_USE_INTEGER_ME) && defined(DUK_USE_INTEGER_LE)-#error config option DUK_USE_INTEGER_ME conflicts with option DUK_USE_INTEGER_LE (which is also defined)-#endif-#if defined(DUK_USE_INTEGER_ME) && defined(DUK_USE_INTEGER_BE)-#error config option DUK_USE_INTEGER_ME conflicts with option DUK_USE_INTEGER_BE (which is also defined)-#endif-#if defined(DUK_USE_MARK_AND_SWEEP)-#error unsupported config option used (option has been removed): DUK_USE_MARK_AND_SWEEP-#endif-#if defined(DUK_USE_MATH_FMAX)-#error unsupported config option used (option has been removed): DUK_USE_MATH_FMAX-#endif-#if defined(DUK_USE_MATH_FMIN)-#error unsupported config option used (option has been removed): DUK_USE_MATH_FMIN-#endif-#if defined(DUK_USE_MATH_ROUND)-#error unsupported config option used (option has been removed): DUK_USE_MATH_ROUND-#endif-#if defined(DUK_USE_NONSTD_REGEXP_DOLLAR_ESCAPE)-#error unsupported config option used (option has been removed): DUK_USE_NONSTD_REGEXP_DOLLAR_ESCAPE-#endif-#if defined(DUK_USE_NO_DOUBLE_ALIASING_SELFTEST)-#error unsupported config option used (option has been removed): DUK_USE_NO_DOUBLE_ALIASING_SELFTEST-#endif-#if defined(DUK_USE_OCTAL_SUPPORT)-#error unsupported config option used (option has been removed): DUK_USE_OCTAL_SUPPORT-#endif-#if defined(DUK_USE_PACKED_TVAL_POSSIBLE)-#error unsupported config option used (option has been removed): DUK_USE_PACKED_TVAL_POSSIBLE-#endif-#if defined(DUK_USE_PANIC_ABORT)-#error unsupported config option used (option has been removed): DUK_USE_PANIC_ABORT-#endif-#if defined(DUK_USE_PANIC_EXIT)-#error unsupported config option used (option has been removed): DUK_USE_PANIC_EXIT-#endif-#if defined(DUK_USE_PANIC_HANDLER)-#error unsupported config option used (option has been removed): DUK_USE_PANIC_HANDLER-#endif-#if defined(DUK_USE_PANIC_SEGFAULT)-#error unsupported config option used (option has been removed): DUK_USE_PANIC_SEGFAULT-#endif-#if defined(DUK_USE_POW_NETBSD_WORKAROUND)-#error unsupported config option used (option has been removed): DUK_USE_POW_NETBSD_WORKAROUND-#endif-#if defined(DUK_USE_RDTSC)-#error unsupported config option used (option has been removed): DUK_USE_RDTSC-#endif-#if defined(DUK_USE_ROM_GLOBAL_CLONE) && !defined(DUK_USE_ROM_STRINGS)-#error config option DUK_USE_ROM_GLOBAL_CLONE requires option DUK_USE_ROM_STRINGS (which is missing)-#endif-#if defined(DUK_USE_ROM_GLOBAL_CLONE) && !defined(DUK_USE_ROM_OBJECTS)-#error config option DUK_USE_ROM_GLOBAL_CLONE requires option DUK_USE_ROM_OBJECTS (which is missing)-#endif-#if defined(DUK_USE_ROM_GLOBAL_CLONE) && defined(DUK_USE_ROM_GLOBAL_INHERIT)-#error config option DUK_USE_ROM_GLOBAL_CLONE conflicts with option DUK_USE_ROM_GLOBAL_INHERIT (which is also defined)-#endif-#if defined(DUK_USE_ROM_GLOBAL_INHERIT) && !defined(DUK_USE_ROM_STRINGS)-#error config option DUK_USE_ROM_GLOBAL_INHERIT requires option DUK_USE_ROM_STRINGS (which is missing)-#endif-#if defined(DUK_USE_ROM_GLOBAL_INHERIT) && !defined(DUK_USE_ROM_OBJECTS)-#error config option DUK_USE_ROM_GLOBAL_INHERIT requires option DUK_USE_ROM_OBJECTS (which is missing)-#endif-#if defined(DUK_USE_ROM_GLOBAL_INHERIT) && defined(DUK_USE_ROM_GLOBAL_CLONE)-#error config option DUK_USE_ROM_GLOBAL_INHERIT conflicts with option DUK_USE_ROM_GLOBAL_CLONE (which is also defined)-#endif-#if defined(DUK_USE_ROM_OBJECTS) && !defined(DUK_USE_ROM_STRINGS)-#error config option DUK_USE_ROM_OBJECTS requires option DUK_USE_ROM_STRINGS (which is missing)-#endif-#if defined(DUK_USE_ROM_STRINGS) && !defined(DUK_USE_ROM_OBJECTS)-#error config option DUK_USE_ROM_STRINGS requires option DUK_USE_ROM_OBJECTS (which is missing)-#endif-#if defined(DUK_USE_SETJMP)-#error unsupported config option used (option has been removed): DUK_USE_SETJMP-#endif-#if defined(DUK_USE_SIGSETJMP)-#error unsupported config option used (option has been removed): DUK_USE_SIGSETJMP-#endif-#if defined(DUK_USE_STRTAB_CHAIN_SIZE) && !defined(DUK_USE_STRTAB_CHAIN)-#error config option DUK_USE_STRTAB_CHAIN_SIZE requires option DUK_USE_STRTAB_CHAIN (which is missing)-#endif-#if defined(DUK_USE_TAILCALL) && defined(DUK_USE_NONSTD_FUNC_CALLER_PROPERTY)-#error config option DUK_USE_TAILCALL conflicts with option DUK_USE_NONSTD_FUNC_CALLER_PROPERTY (which is also defined)-#endif-#if defined(DUK_USE_UNALIGNED_ACCESSES_POSSIBLE)-#error unsupported config option used (option has been removed): DUK_USE_UNALIGNED_ACCESSES_POSSIBLE-#endif-#if defined(DUK_USE_UNDERSCORE_SETJMP)-#error unsupported config option used (option has been removed): DUK_USE_UNDERSCORE_SETJMP-#endif-#if defined(DUK_USE_USER_INITJS)-#error unsupported config option used (option has been removed): DUK_USE_USER_INITJS-#endif--#if defined(DUK_USE_CPP_EXCEPTIONS) && !defined(__cplusplus)-#error DUK_USE_CPP_EXCEPTIONS enabled but not compiling with a C++ compiler-#endif--/*- *  Convert DUK_USE_BYTEORDER, from whatever source, into currently used- *  internal defines.  If detection failed, #error out.- */--#if defined(DUK_USE_BYTEORDER)-#if (DUK_USE_BYTEORDER == 1)-#define DUK_USE_INTEGER_LE-#define DUK_USE_DOUBLE_LE-#elif (DUK_USE_BYTEORDER == 2)-#define DUK_USE_INTEGER_LE  /* integer endianness is little on purpose */-#define DUK_USE_DOUBLE_ME-#elif (DUK_USE_BYTEORDER == 3)-#define DUK_USE_INTEGER_BE-#define DUK_USE_DOUBLE_BE-#else-#error unsupported: byte order invalid-#endif  /* byte order */-#else-#error unsupported: byte order detection failed-#endif  /* defined(DUK_USE_BYTEORDER) */--#endif  /* DUK_CONFIG_H_INCLUDED */
− duktape/src/duktape.c

file too large to diff

− duktape/src/duktape.h
@@ -1,1661 +0,0 @@-/*- *  Duktape public API for Duktape 2.0.1.- *- *  See the API reference for documentation on call semantics.- *  The exposed API is inside the DUK_API_PUBLIC_H_INCLUDED- *  include guard.  Other parts of the header are Duktape- *  internal and related to platform/compiler/feature detection.- *- *  Git commit 3f5e91704aff97c754f6ef5d44aedc5e529d1b16 (v2.0.1).- *  Git branch v2.0-maintenance.- *- *  See Duktape AUTHORS.rst and LICENSE.txt for copyright and- *  licensing information.- */--/* LICENSE.txt */-/*- *  ===============- *  Duktape license- *  ===============- *  - *  (http://opensource.org/licenses/MIT)- *  - *  Copyright (c) 2013-2017 by Duktape authors (see AUTHORS.rst)- *  - *  Permission is hereby granted, free of charge, to any person obtaining a copy- *  of this software and associated documentation files (the "Software"), to deal- *  in the Software without restriction, including without limitation the rights- *  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell- *  copies of the Software, and to permit persons to whom the Software is- *  furnished to do so, subject to the following conditions:- *  - *  The above copyright notice and this permission notice shall be included in- *  all copies or substantial portions of the Software.- *  - *  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR- *  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,- *  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE- *  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER- *  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,- *  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN- *  THE SOFTWARE.- */--/* AUTHORS.rst */-/*- *  ===============- *  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 <sami.vaarala@iki.fi>- *  * Niki Dobrev- *  * Andreas \u00d6man <andreas@lonelycoder.com>- *  * L\u00e1szl\u00f3 Lang\u00f3 <llango.u-szeged@partner.samsung.com>- *  * Legimet <legimet.calc@gmail.com>- *  * Karl Skomski <karl@skomski.com>- *  * Bruce Pascoe <fatcerberus1@gmail.com>- *  * Ren\u00e9 Hollander <rene@rene8888.at>- *  * Julien Hamaide (https://github.com/crazyjul)- *  * Sebastian G\u00f6tte (https://github.com/jaseg)- *  * Tomasz Magulski (https://github.com/magul)- *  * \D. Bohdan (https://github.com/dbohdan)- *  * Ond\u0159ej Jirman (https://github.com/megous)- *  * Sa\u00fal Ibarra Corretg\u00e9 <saghul@gmail.com>- *  * Jeremy HU <huxingyi@msn.com>- *  * Ole Andr\u00e9 Vadla Ravn\u00e5s (https://github.com/oleavr)- *  * Harold Brenes (https://github.com/harold-b)- *  * Oliver Crow (https://github.com/ocrow)- *  * Jakub Ch\u0142api\u0144ski (https://github.com/jchlapinski)- *  * Brett Vickers (https://github.com/beevik)- *  * Dominik Okwieka (https://github.com/okitec)- *  * Remko Tron\u00e7on (https://el-tramo.be)- *  - *  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\u00e9lien Bouilland- *  * Preet Desai (Pris Matic)- *  * judofyr (http://www.reddit.com/user/judofyr)- *  * Jason Woofenden- *  * Micha\u0142 Przyby\u015b- *  * Anthony Howe- *  * Conrad Pankoff- *  * Jim Schimpf- *  * Rajaran Gaunker (https://github.com/zimbabao)- *  * Andreas \u00d6man- *  * 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)- *  - *  If you are accidentally missing from this list, send me an e-mail- *  (``sami.vaarala@iki.fi``) and I'll fix the omission.- */--#if !defined(DUKTAPE_H_INCLUDED)-#define DUKTAPE_H_INCLUDED--#define DUK_SINGLE_FILE--/* External duk_config.h provides platform/compiler/OS dependent- * typedefs and macros, and DUK_USE_xxx config options so that- * the rest of Duktape doesn't need to do any feature detection.- */-#include "duk_config.h"--/*- *  BEGIN PUBLIC API- */--#if !defined(DUK_API_PUBLIC_H_INCLUDED)-#define DUK_API_PUBLIC_H_INCLUDED--/*- *  Avoid C++ name mangling- */--#if defined(__cplusplus)-extern "C" {-#endif--/*- *  Some defines forwarded from feature detection- */--#undef DUK_API_VARIADIC_MACROS-#if defined(DUK_USE_VARIADIC_MACROS)-#define DUK_API_VARIADIC_MACROS-#endif--#define DUK_API_NORETURN(decl) DUK_NORETURN(decl)--/*- *  Public API specific typedefs- *- *  Many types are wrapped by Duktape for portability to rare platforms- *  where e.g. 'int' is a 16-bit type.  See practical typing discussion- *  in Duktape web documentation.- */--struct duk_thread_state;-struct duk_memory_functions;-struct duk_function_list_entry;-struct duk_number_list_entry;-struct duk_time_components;--/* duk_context is now defined in duk_config.h because it may also be- * referenced there by prototypes.- */-typedef struct duk_thread_state duk_thread_state;-typedef struct duk_memory_functions duk_memory_functions;-typedef struct duk_function_list_entry duk_function_list_entry;-typedef struct duk_number_list_entry duk_number_list_entry;-typedef struct duk_time_components duk_time_components;--typedef duk_ret_t (*duk_c_function)(duk_context *ctx);-typedef void *(*duk_alloc_function) (void *udata, duk_size_t size);-typedef void *(*duk_realloc_function) (void *udata, void *ptr, duk_size_t size);-typedef void (*duk_free_function) (void *udata, void *ptr);-typedef void (*duk_fatal_function) (void *udata, const char *msg);-typedef void (*duk_decode_char_function) (void *udata, duk_codepoint_t codepoint);-typedef duk_codepoint_t (*duk_map_char_function) (void *udata, duk_codepoint_t codepoint);-typedef duk_ret_t (*duk_safe_call_function) (duk_context *ctx, void *udata);-typedef duk_size_t (*duk_debug_read_function) (void *udata, char *buffer, duk_size_t length);-typedef duk_size_t (*duk_debug_write_function) (void *udata, const char *buffer, duk_size_t length);-typedef duk_size_t (*duk_debug_peek_function) (void *udata);-typedef void (*duk_debug_read_flush_function) (void *udata);-typedef void (*duk_debug_write_flush_function) (void *udata);-typedef duk_idx_t (*duk_debug_request_function) (duk_context *ctx, void *udata, duk_idx_t nvalues);-typedef void (*duk_debug_detached_function) (duk_context *ctx, void *udata);--struct duk_thread_state {-	/* XXX: Enough space to hold internal suspend/resume structure.-	 * This is rather awkward and to be fixed when the internal-	 * structure is visible for the public API header.-	 */-	char data[128];-};--struct duk_memory_functions {-	duk_alloc_function alloc_func;-	duk_realloc_function realloc_func;-	duk_free_function free_func;-	void *udata;-};--struct duk_function_list_entry {-	const char *key;-	duk_c_function value;-	duk_idx_t nargs;-};--struct duk_number_list_entry {-	const char *key;-	duk_double_t value;-};--struct duk_time_components {-	duk_double_t year;          /* year, e.g. 2016, Ecmascript year range */-	duk_double_t month;         /* month: 1-12 */-	duk_double_t day;           /* day: 1-31 */-	duk_double_t hours;         /* hour: 0-59 */-	duk_double_t minutes;       /* minute: 0-59 */-	duk_double_t seconds;       /* second: 0-59 (in POSIX time no leap second) */-	duk_double_t milliseconds;  /* may contain sub-millisecond fractions */-	duk_double_t weekday;       /* weekday: 0-6, 0=Sunday, 1=Monday, ..., 6=Saturday */-};--/*- *  Constants- */--/* Duktape version, (major * 10000) + (minor * 100) + patch.  Allows C code- * to #if (DUK_VERSION >= NNN) against Duktape API version.  The same value- * is also available to Ecmascript code in Duktape.version.  Unofficial- * development snapshots have 99 for patch level (e.g. 0.10.99 would be a- * development version after 0.10.0 but before the next official release).- */-#define DUK_VERSION                       20001L--/* Git commit, describe, and branch for Duktape build.  Useful for- * non-official snapshot builds so that application code can easily log- * which Duktape snapshot was used.  Not available in the Ecmascript- * environment.- */-#define DUK_GIT_COMMIT                    "3f5e91704aff97c754f6ef5d44aedc5e529d1b16"-#define DUK_GIT_DESCRIBE                  "v2.0.1"-#define DUK_GIT_BRANCH                    "v2.0-maintenance"--/* Duktape debug protocol version used by this build. */-#define DUK_DEBUG_PROTOCOL_VERSION        2--/* Used to represent invalid index; if caller uses this without checking,- * this index will map to a non-existent stack entry.  Also used in some- * API calls as a marker to denote "no value".- */-#define DUK_INVALID_INDEX                 DUK_IDX_MIN--/* Indicates that a native function does not have a fixed number of args,- * and the argument stack should not be capped/extended at all.- */-#define DUK_VARARGS                       ((duk_int_t) (-1))--/* Number of value stack entries (in addition to actual call arguments)- * guaranteed to be allocated on entry to a Duktape/C function.- */-#define DUK_API_ENTRY_STACK               64--/* Value types, used by e.g. duk_get_type() */-#define DUK_TYPE_MIN                      0-#define DUK_TYPE_NONE                     0    /* no value, e.g. invalid index */-#define DUK_TYPE_UNDEFINED                1    /* Ecmascript undefined */-#define DUK_TYPE_NULL                     2    /* Ecmascript null */-#define DUK_TYPE_BOOLEAN                  3    /* Ecmascript boolean: 0 or 1 */-#define DUK_TYPE_NUMBER                   4    /* Ecmascript number: double */-#define DUK_TYPE_STRING                   5    /* Ecmascript string: CESU-8 / extended UTF-8 encoded */-#define DUK_TYPE_OBJECT                   6    /* Ecmascript object: includes objects, arrays, functions, threads */-#define DUK_TYPE_BUFFER                   7    /* fixed or dynamic, garbage collected byte buffer */-#define DUK_TYPE_POINTER                  8    /* raw void pointer */-#define DUK_TYPE_LIGHTFUNC                9    /* lightweight function pointer */-#define DUK_TYPE_MAX                      9--/* Value mask types, used by e.g. duk_get_type_mask() */-#define DUK_TYPE_MASK_NONE                (1 << DUK_TYPE_NONE)-#define DUK_TYPE_MASK_UNDEFINED           (1 << DUK_TYPE_UNDEFINED)-#define DUK_TYPE_MASK_NULL                (1 << DUK_TYPE_NULL)-#define DUK_TYPE_MASK_BOOLEAN             (1 << DUK_TYPE_BOOLEAN)-#define DUK_TYPE_MASK_NUMBER              (1 << DUK_TYPE_NUMBER)-#define DUK_TYPE_MASK_STRING              (1 << DUK_TYPE_STRING)-#define DUK_TYPE_MASK_OBJECT              (1 << DUK_TYPE_OBJECT)-#define DUK_TYPE_MASK_BUFFER              (1 << DUK_TYPE_BUFFER)-#define DUK_TYPE_MASK_POINTER             (1 << DUK_TYPE_POINTER)-#define DUK_TYPE_MASK_LIGHTFUNC           (1 << DUK_TYPE_LIGHTFUNC)-#define DUK_TYPE_MASK_THROW               (1 << 10)  /* internal flag value: throw if mask doesn't match */-#define DUK_TYPE_MASK_PROMOTE             (1 << 11)  /* internal flag value: promote to object if mask matches */--/* Coercion hints */-#define DUK_HINT_NONE                     0    /* prefer number, unless input is a Date, in which-                                                * case prefer string (E5 Section 8.12.8)-                                                */-#define DUK_HINT_STRING                   1    /* prefer string */-#define DUK_HINT_NUMBER                   2    /* prefer number */--/* Enumeration flags for duk_enum() */-#define DUK_ENUM_INCLUDE_NONENUMERABLE    (1 << 0)    /* enumerate non-numerable properties in addition to enumerable */-#define DUK_ENUM_INCLUDE_HIDDEN           (1 << 1)    /* enumerate hidden symbols too (in Duktape 1.x called internal properties) */-#define DUK_ENUM_INCLUDE_SYMBOLS          (1 << 2)    /* enumerate symbols */-#define DUK_ENUM_EXCLUDE_STRINGS          (1 << 3)    /* exclude strings */-#define DUK_ENUM_OWN_PROPERTIES_ONLY      (1 << 4)    /* don't walk prototype chain, only check own properties */-#define DUK_ENUM_ARRAY_INDICES_ONLY       (1 << 5)    /* only enumerate array indices */-#define DUK_ENUM_SORT_ARRAY_INDICES       (1 << 6)    /* sort array indices (applied to full enumeration result, including inherited array indices) */-#define DUK_ENUM_NO_PROXY_BEHAVIOR        (1 << 7)    /* enumerate a proxy object itself without invoking proxy behavior */--/* Compilation flags for duk_compile() and duk_eval() */-/* DUK_COMPILE_xxx bits 0-2 are reserved for an internal 'nargs' argument.- */-#define DUK_COMPILE_EVAL                  (1 << 3)    /* compile eval code (instead of global code) */-#define DUK_COMPILE_FUNCTION              (1 << 4)    /* compile function code (instead of global code) */-#define DUK_COMPILE_STRICT                (1 << 5)    /* use strict (outer) context for global, eval, or function code */-#define DUK_COMPILE_SAFE                  (1 << 6)    /* (internal) catch compilation errors */-#define DUK_COMPILE_NORESULT              (1 << 7)    /* (internal) omit eval result */-#define DUK_COMPILE_NOSOURCE              (1 << 8)    /* (internal) no source string on stack */-#define DUK_COMPILE_STRLEN                (1 << 9)    /* (internal) take strlen() of src_buffer (avoids double evaluation in macro) */-#define DUK_COMPILE_NOFILENAME            (1 << 10)    /* (internal) no filename on stack */--/* Flags for duk_def_prop() and its variants */-#define DUK_DEFPROP_WRITABLE              (1 << 0)    /* set writable (effective if DUK_DEFPROP_HAVE_WRITABLE set) */-#define DUK_DEFPROP_ENUMERABLE            (1 << 1)    /* set enumerable (effective if DUK_DEFPROP_HAVE_ENUMERABLE set) */-#define DUK_DEFPROP_CONFIGURABLE          (1 << 2)    /* set configurable (effective if DUK_DEFPROP_HAVE_CONFIGURABLE set) */-#define DUK_DEFPROP_HAVE_WRITABLE         (1 << 3)    /* set/clear writable */-#define DUK_DEFPROP_HAVE_ENUMERABLE       (1 << 4)    /* set/clear enumerable */-#define DUK_DEFPROP_HAVE_CONFIGURABLE     (1 << 5)    /* set/clear configurable */-#define DUK_DEFPROP_HAVE_VALUE            (1 << 6)    /* set value (given on value stack) */-#define DUK_DEFPROP_HAVE_GETTER           (1 << 7)    /* set getter (given on value stack) */-#define DUK_DEFPROP_HAVE_SETTER           (1 << 8)    /* set setter (given on value stack) */-#define DUK_DEFPROP_FORCE                 (1 << 9)    /* force change if possible, may still fail for e.g. virtual properties */-#define DUK_DEFPROP_SET_WRITABLE          (DUK_DEFPROP_HAVE_WRITABLE | DUK_DEFPROP_WRITABLE)-#define DUK_DEFPROP_CLEAR_WRITABLE        DUK_DEFPROP_HAVE_WRITABLE-#define DUK_DEFPROP_SET_ENUMERABLE        (DUK_DEFPROP_HAVE_ENUMERABLE | DUK_DEFPROP_ENUMERABLE)-#define DUK_DEFPROP_CLEAR_ENUMERABLE      DUK_DEFPROP_HAVE_ENUMERABLE-#define DUK_DEFPROP_SET_CONFIGURABLE      (DUK_DEFPROP_HAVE_CONFIGURABLE | DUK_DEFPROP_CONFIGURABLE)-#define DUK_DEFPROP_CLEAR_CONFIGURABLE    DUK_DEFPROP_HAVE_CONFIGURABLE--/* Flags for duk_push_thread_raw() */-#define DUK_THREAD_NEW_GLOBAL_ENV         (1 << 0)    /* create a new global environment */--/* Flags for duk_gc() */-#define DUK_GC_COMPACT                    (1 << 0)    /* compact heap objects */--/* Error codes (must be 8 bits at most, see duk_error.h) */-#define DUK_ERR_NONE                      0    /* no error (e.g. from duk_get_error_code()) */-#define DUK_ERR_ERROR                     1    /* Error */-#define DUK_ERR_EVAL_ERROR                2    /* EvalError */-#define DUK_ERR_RANGE_ERROR               3    /* RangeError */-#define DUK_ERR_REFERENCE_ERROR           4    /* ReferenceError */-#define DUK_ERR_SYNTAX_ERROR              5    /* SyntaxError */-#define DUK_ERR_TYPE_ERROR                6    /* TypeError */-#define DUK_ERR_URI_ERROR                 7    /* URIError */--/* Return codes for C functions (shortcut for throwing an error) */-#define DUK_RET_ERROR                     (-DUK_ERR_ERROR)-#define DUK_RET_EVAL_ERROR                (-DUK_ERR_EVAL_ERROR)-#define DUK_RET_RANGE_ERROR               (-DUK_ERR_RANGE_ERROR)-#define DUK_RET_REFERENCE_ERROR           (-DUK_ERR_REFERENCE_ERROR)-#define DUK_RET_SYNTAX_ERROR              (-DUK_ERR_SYNTAX_ERROR)-#define DUK_RET_TYPE_ERROR                (-DUK_ERR_TYPE_ERROR)-#define DUK_RET_URI_ERROR                 (-DUK_ERR_URI_ERROR)--/* Return codes for protected calls (duk_safe_call(), duk_pcall()) */-#define DUK_EXEC_SUCCESS                  0-#define DUK_EXEC_ERROR                    1--/* Debug levels for DUK_USE_DEBUG_WRITE(). */-#define DUK_LEVEL_DEBUG                   0-#define DUK_LEVEL_DDEBUG                  1-#define DUK_LEVEL_DDDEBUG                 2--/*- *  If no variadic macros, __FILE__ and __LINE__ are passed through globals- *  which is ugly and not thread safe.- */--#if !defined(DUK_API_VARIADIC_MACROS)-DUK_EXTERNAL_DECL const char *duk_api_global_filename;-DUK_EXTERNAL_DECL duk_int_t duk_api_global_line;-#endif--/*- *  Context management- */--DUK_EXTERNAL_DECL-duk_context *duk_create_heap(duk_alloc_function alloc_func,-                             duk_realloc_function realloc_func,-                             duk_free_function free_func,-                             void *heap_udata,-                             duk_fatal_function fatal_handler);-DUK_EXTERNAL_DECL void duk_destroy_heap(duk_context *ctx);--DUK_EXTERNAL_DECL void duk_suspend(duk_context *ctx, duk_thread_state *state);-DUK_EXTERNAL_DECL void duk_resume(duk_context *ctx, const duk_thread_state *state);--#define duk_create_heap_default() \-	duk_create_heap(NULL, NULL, NULL, NULL, NULL)--/*- *  Memory management- *- *  Raw functions have no side effects (cannot trigger GC).- */--DUK_EXTERNAL_DECL void *duk_alloc_raw(duk_context *ctx, duk_size_t size);-DUK_EXTERNAL_DECL void duk_free_raw(duk_context *ctx, void *ptr);-DUK_EXTERNAL_DECL void *duk_realloc_raw(duk_context *ctx, void *ptr, duk_size_t size);-DUK_EXTERNAL_DECL void *duk_alloc(duk_context *ctx, duk_size_t size);-DUK_EXTERNAL_DECL void duk_free(duk_context *ctx, void *ptr);-DUK_EXTERNAL_DECL void *duk_realloc(duk_context *ctx, void *ptr, duk_size_t size);-DUK_EXTERNAL_DECL void duk_get_memory_functions(duk_context *ctx, duk_memory_functions *out_funcs);-DUK_EXTERNAL_DECL void duk_gc(duk_context *ctx, duk_uint_t flags);--/*- *  Error handling- */--DUK_API_NORETURN(DUK_EXTERNAL_DECL void duk_throw_raw(duk_context *ctx));-#define duk_throw(ctx) \-	(duk_throw_raw((ctx)), (duk_ret_t) 0)-DUK_API_NORETURN(DUK_EXTERNAL_DECL void duk_fatal_raw(duk_context *ctx, const char *err_msg));-#define duk_fatal(ctx,err_msg) \-	(duk_fatal_raw((ctx), (err_msg)), (duk_ret_t) 0)--#if defined(DUK_API_VARIADIC_MACROS)-DUK_API_NORETURN(DUK_EXTERNAL_DECL void duk_error_raw(duk_context *ctx, duk_errcode_t err_code, const char *filename, duk_int_t line, const char *fmt, ...));-#define duk_error(ctx,err_code,...)  \-	(duk_error_raw((ctx), (duk_errcode_t) (err_code), (const char *) (DUK_FILE_MACRO), (duk_int_t) (DUK_LINE_MACRO), __VA_ARGS__), (duk_ret_t) 0)-#define duk_generic_error(ctx,...)  \-	(duk_error_raw((ctx), (duk_errcode_t) DUK_ERR_ERROR, (const char *) (DUK_FILE_MACRO), (duk_int_t) (DUK_LINE_MACRO), __VA_ARGS__), (duk_ret_t) 0)-#define duk_eval_error(ctx,...)  \-	(duk_error_raw((ctx), (duk_errcode_t) DUK_ERR_EVAL_ERROR, (const char *) (DUK_FILE_MACRO), (duk_int_t) (DUK_LINE_MACRO), __VA_ARGS__), (duk_ret_t) 0)-#define duk_range_error(ctx,...)  \-	(duk_error_raw((ctx), (duk_errcode_t) DUK_ERR_RANGE_ERROR, (const char *) (DUK_FILE_MACRO), (duk_int_t) (DUK_LINE_MACRO), __VA_ARGS__), (duk_ret_t) 0)-#define duk_reference_error(ctx,...)  \-	(duk_error_raw((ctx), (duk_errcode_t) DUK_ERR_REFERENCE_ERROR, (const char *) (DUK_FILE_MACRO), (duk_int_t) (DUK_LINE_MACRO), __VA_ARGS__), (duk_ret_t) 0)-#define duk_syntax_error(ctx,...)  \-	(duk_error_raw((ctx), (duk_errcode_t) DUK_ERR_SYNTAX_ERROR, (const char *) (DUK_FILE_MACRO), (duk_int_t) (DUK_LINE_MACRO), __VA_ARGS__), (duk_ret_t) 0)-#define duk_type_error(ctx,...)  \-	(duk_error_raw((ctx), (duk_errcode_t) DUK_ERR_TYPE_ERROR, (const char *) (DUK_FILE_MACRO), (duk_int_t) (DUK_LINE_MACRO), __VA_ARGS__), (duk_ret_t) 0)-#define duk_uri_error(ctx,...)  \-	(duk_error_raw((ctx), (duk_errcode_t) DUK_ERR_URI_ERROR, (const char *) (DUK_FILE_MACRO), (duk_int_t) (DUK_LINE_MACRO), __VA_ARGS__), (duk_ret_t) 0)-#else  /* DUK_API_VARIADIC_MACROS */-/* For legacy compilers without variadic macros a macro hack is used to allow- * variable arguments.  While the macro allows "return duk_error(...)", it- * will fail with e.g. "(void) duk_error(...)".  The calls are noreturn but- * with a return value to allow the "return duk_error(...)" idiom.  This may- * cause some compiler warnings, but without noreturn the generated code is- * often worse.  The same approach as with variadic macros (using- * "(duk_error(...), 0)") won't work due to the macro hack structure.- */-DUK_API_NORETURN(DUK_EXTERNAL_DECL duk_ret_t duk_error_stash(duk_context *ctx, duk_errcode_t err_code, const char *fmt, ...));-DUK_API_NORETURN(DUK_EXTERNAL_DECL duk_ret_t duk_generic_error_stash(duk_context *ctx, const char *fmt, ...));-DUK_API_NORETURN(DUK_EXTERNAL_DECL duk_ret_t duk_eval_error_stash(duk_context *ctx, const char *fmt, ...));-DUK_API_NORETURN(DUK_EXTERNAL_DECL duk_ret_t duk_range_error_stash(duk_context *ctx, const char *fmt, ...));-DUK_API_NORETURN(DUK_EXTERNAL_DECL duk_ret_t duk_reference_error_stash(duk_context *ctx, const char *fmt, ...));-DUK_API_NORETURN(DUK_EXTERNAL_DECL duk_ret_t duk_syntax_error_stash(duk_context *ctx, const char *fmt, ...));-DUK_API_NORETURN(DUK_EXTERNAL_DECL duk_ret_t duk_type_error_stash(duk_context *ctx, const char *fmt, ...));-DUK_API_NORETURN(DUK_EXTERNAL_DECL duk_ret_t duk_uri_error_stash(duk_context *ctx, const char *fmt, ...));-#define duk_error  \-	(duk_api_global_filename = (const char *) (DUK_FILE_MACRO), \-	 duk_api_global_line = (duk_int_t) (DUK_LINE_MACRO), \-	 duk_error_stash)  /* last value is func pointer, arguments follow in parens */-#define duk_generic_error  \-	(duk_api_global_filename = (const char *) (DUK_FILE_MACRO), \-	 duk_api_global_line = (duk_int_t) (DUK_LINE_MACRO), \-	 duk_generic_error_stash)-#define duk_eval_error  \-	(duk_api_global_filename = (const char *) (DUK_FILE_MACRO), \-	 duk_api_global_line = (duk_int_t) (DUK_LINE_MACRO), \-	 duk_eval_error_stash)-#define duk_range_error  \-	(duk_api_global_filename = (const char *) (DUK_FILE_MACRO), \-	 duk_api_global_line = (duk_int_t) (DUK_LINE_MACRO), \-	 duk_range_error_stash)-#define duk_reference_error  \-	(duk_api_global_filename = (const char *) (DUK_FILE_MACRO), \-	 duk_api_global_line = (duk_int_t) (DUK_LINE_MACRO), \-	 duk_reference_error_stash)-#define duk_syntax_error  \-	(duk_api_global_filename = (const char *) (DUK_FILE_MACRO), \-	 duk_api_global_line = (duk_int_t) (DUK_LINE_MACRO), \-	 duk_syntax_error_stash)-#define duk_type_error  \-	(duk_api_global_filename = (const char *) (DUK_FILE_MACRO), \-	 duk_api_global_line = (duk_int_t) (DUK_LINE_MACRO), \-	 duk_type_error_stash)-#define duk_uri_error  \-	(duk_api_global_filename = (const char *) (DUK_FILE_MACRO), \-	 duk_api_global_line = (duk_int_t) (DUK_LINE_MACRO), \-	 duk_uri_error_stash)-#endif  /* DUK_API_VARIADIC_MACROS */--DUK_API_NORETURN(DUK_EXTERNAL_DECL void duk_error_va_raw(duk_context *ctx, duk_errcode_t err_code, const char *filename, duk_int_t line, const char *fmt, va_list ap));-#define duk_error_va(ctx,err_code,fmt,ap)  \-	(duk_error_va_raw((ctx), (duk_errcode_t) (err_code), (const char *) (DUK_FILE_MACRO), (duk_int_t) (DUK_LINE_MACRO), (fmt), (ap)), (duk_ret_t) 0)-#define duk_generic_error_va(ctx,fmt,ap)  \-	(duk_error_va_raw((ctx), (duk_errcode_t) DUK_ERR_ERROR, (const char *) (DUK_FILE_MACRO), (duk_int_t) (DUK_LINE_MACRO), (fmt), (ap)), (duk_ret_t) 0)-#define duk_eval_error_va(ctx,fmt,ap)  \-	(duk_error_va_raw((ctx), (duk_errcode_t) DUK_ERR_EVAL_ERROR, (const char *) (DUK_FILE_MACRO), (duk_int_t) (DUK_LINE_MACRO), (fmt), (ap)), (duk_ret_t) 0)-#define duk_range_error_va(ctx,fmt,ap)  \-	(duk_error_va_raw((ctx), (duk_errcode_t) DUK_ERR_RANGE_ERROR, (const char *) (DUK_FILE_MACRO), (duk_int_t) (DUK_LINE_MACRO), (fmt), (ap)), (duk_ret_t) 0)-#define duk_reference_error_va(ctx,fmt,ap)  \-	(duk_error_va_raw((ctx), (duk_errcode_t) DUK_ERR_REFERENCE_ERROR, (const char *) (DUK_FILE_MACRO), (duk_int_t) (DUK_LINE_MACRO), (fmt), (ap)), (duk_ret_t) 0)-#define duk_syntax_error_va(ctx,fmt,ap)  \-	(duk_error_va_raw((ctx), (duk_errcode_t) DUK_ERR_SYNTAX_ERROR, (const char *) (DUK_FILE_MACRO), (duk_int_t) (DUK_LINE_MACRO), (fmt), (ap)), (duk_ret_t) 0)-#define duk_type_error_va(ctx,fmt,ap)  \-	(duk_error_va_raw((ctx), (duk_errcode_t) DUK_ERR_TYPE_ERROR, (const char *) (DUK_FILE_MACRO), (duk_int_t) (DUK_LINE_MACRO), (fmt), (ap)), (duk_ret_t) 0)-#define duk_uri_error_va(ctx,fmt,ap)  \-	(duk_error_va_raw((ctx), (duk_errcode_t) DUK_ERR_URI_ERROR, (const char *) (DUK_FILE_MACRO), (duk_int_t) (DUK_LINE_MACRO), (fmt), (ap)), (duk_ret_t) 0)--/*- *  Other state related functions- */--DUK_EXTERNAL_DECL duk_bool_t duk_is_strict_call(duk_context *ctx);-DUK_EXTERNAL_DECL duk_bool_t duk_is_constructor_call(duk_context *ctx);--/*- *  Stack management- */--DUK_EXTERNAL_DECL duk_idx_t duk_normalize_index(duk_context *ctx, duk_idx_t idx);-DUK_EXTERNAL_DECL duk_idx_t duk_require_normalize_index(duk_context *ctx, duk_idx_t idx);-DUK_EXTERNAL_DECL duk_bool_t duk_is_valid_index(duk_context *ctx, duk_idx_t idx);-DUK_EXTERNAL_DECL void duk_require_valid_index(duk_context *ctx, duk_idx_t idx);--DUK_EXTERNAL_DECL duk_idx_t duk_get_top(duk_context *ctx);-DUK_EXTERNAL_DECL void duk_set_top(duk_context *ctx, duk_idx_t idx);-DUK_EXTERNAL_DECL duk_idx_t duk_get_top_index(duk_context *ctx);-DUK_EXTERNAL_DECL duk_idx_t duk_require_top_index(duk_context *ctx);--/* Although extra/top could be an unsigned type here, using a signed type- * makes the API more robust to calling code calculation errors or corner- * cases (where caller might occasionally come up with negative values).- * Negative values are treated as zero, which is better than casting them- * to a large unsigned number.  (This principle is used elsewhere in the- * API too.)- */-DUK_EXTERNAL_DECL duk_bool_t duk_check_stack(duk_context *ctx, duk_idx_t extra);-DUK_EXTERNAL_DECL void duk_require_stack(duk_context *ctx, duk_idx_t extra);-DUK_EXTERNAL_DECL duk_bool_t duk_check_stack_top(duk_context *ctx, duk_idx_t top);-DUK_EXTERNAL_DECL void duk_require_stack_top(duk_context *ctx, duk_idx_t top);--/*- *  Stack manipulation (other than push/pop)- */--DUK_EXTERNAL_DECL void duk_swap(duk_context *ctx, duk_idx_t idx1, duk_idx_t idx2);-DUK_EXTERNAL_DECL void duk_swap_top(duk_context *ctx, duk_idx_t idx);-DUK_EXTERNAL_DECL void duk_dup(duk_context *ctx, duk_idx_t from_idx);-DUK_EXTERNAL_DECL void duk_dup_top(duk_context *ctx);-DUK_EXTERNAL_DECL void duk_insert(duk_context *ctx, duk_idx_t to_idx);-DUK_EXTERNAL_DECL void duk_replace(duk_context *ctx, duk_idx_t to_idx);-DUK_EXTERNAL_DECL void duk_copy(duk_context *ctx, duk_idx_t from_idx, duk_idx_t to_idx);-DUK_EXTERNAL_DECL void duk_remove(duk_context *ctx, duk_idx_t idx);-DUK_EXTERNAL_DECL void duk_xcopymove_raw(duk_context *to_ctx, duk_context *from_ctx, duk_idx_t count, duk_bool_t is_copy);--#define duk_xmove_top(to_ctx,from_ctx,count) \-	duk_xcopymove_raw((to_ctx), (from_ctx), (count), 0 /*is_copy*/)-#define duk_xcopy_top(to_ctx,from_ctx,count) \-	duk_xcopymove_raw((to_ctx), (from_ctx), (count), 1 /*is_copy*/)--/*- *  Push operations- *- *  Push functions return the absolute (relative to bottom of frame)- *  position of the pushed value for convenience.- *- *  Note: duk_dup() is technically a push.- */--DUK_EXTERNAL_DECL void duk_push_undefined(duk_context *ctx);-DUK_EXTERNAL_DECL void duk_push_null(duk_context *ctx);-DUK_EXTERNAL_DECL void duk_push_boolean(duk_context *ctx, duk_bool_t val);-DUK_EXTERNAL_DECL void duk_push_true(duk_context *ctx);-DUK_EXTERNAL_DECL void duk_push_false(duk_context *ctx);-DUK_EXTERNAL_DECL void duk_push_number(duk_context *ctx, duk_double_t val);-DUK_EXTERNAL_DECL void duk_push_nan(duk_context *ctx);-DUK_EXTERNAL_DECL void duk_push_int(duk_context *ctx, duk_int_t val);-DUK_EXTERNAL_DECL void duk_push_uint(duk_context *ctx, duk_uint_t val);-DUK_EXTERNAL_DECL const char *duk_push_string(duk_context *ctx, const char *str);-DUK_EXTERNAL_DECL const char *duk_push_lstring(duk_context *ctx, const char *str, duk_size_t len);-DUK_EXTERNAL_DECL void duk_push_pointer(duk_context *ctx, void *p);-DUK_EXTERNAL_DECL const char *duk_push_sprintf(duk_context *ctx, const char *fmt, ...);-DUK_EXTERNAL_DECL const char *duk_push_vsprintf(duk_context *ctx, const char *fmt, va_list ap);--DUK_EXTERNAL_DECL void duk_push_this(duk_context *ctx);-DUK_EXTERNAL_DECL void duk_push_current_function(duk_context *ctx);-DUK_EXTERNAL_DECL void duk_push_current_thread(duk_context *ctx);-DUK_EXTERNAL_DECL void duk_push_global_object(duk_context *ctx);-DUK_EXTERNAL_DECL void duk_push_heap_stash(duk_context *ctx);-DUK_EXTERNAL_DECL void duk_push_global_stash(duk_context *ctx);-DUK_EXTERNAL_DECL void duk_push_thread_stash(duk_context *ctx, duk_context *target_ctx);--DUK_EXTERNAL_DECL duk_idx_t duk_push_object(duk_context *ctx);-DUK_EXTERNAL_DECL duk_idx_t duk_push_bare_object(duk_context *ctx);-DUK_EXTERNAL_DECL duk_idx_t duk_push_array(duk_context *ctx);-DUK_EXTERNAL_DECL duk_idx_t duk_push_c_function(duk_context *ctx, duk_c_function func, duk_idx_t nargs);-DUK_EXTERNAL_DECL duk_idx_t duk_push_c_lightfunc(duk_context *ctx, duk_c_function func, duk_idx_t nargs, duk_idx_t length, duk_int_t magic);-DUK_EXTERNAL_DECL duk_idx_t duk_push_thread_raw(duk_context *ctx, duk_uint_t flags);--#define duk_push_thread(ctx) \-	duk_push_thread_raw((ctx), 0 /*flags*/)--#define duk_push_thread_new_globalenv(ctx) \-	duk_push_thread_raw((ctx), DUK_THREAD_NEW_GLOBAL_ENV /*flags*/)--DUK_EXTERNAL_DECL duk_idx_t duk_push_error_object_raw(duk_context *ctx, duk_errcode_t err_code, const char *filename, duk_int_t line, const char *fmt, ...);--#if defined(DUK_API_VARIADIC_MACROS)-#define duk_push_error_object(ctx,err_code,...)  \-	duk_push_error_object_raw((ctx), (err_code), (const char *) (DUK_FILE_MACRO), (duk_int_t) (DUK_LINE_MACRO), __VA_ARGS__)-#else-DUK_EXTERNAL_DECL duk_idx_t duk_push_error_object_stash(duk_context *ctx, duk_errcode_t err_code, const char *fmt, ...);-/* Note: parentheses are required so that the comma expression works in assignments. */-#define duk_push_error_object  \-	(duk_api_global_filename = (const char *) (DUK_FILE_MACRO), \-	 duk_api_global_line = (duk_int_t) (DUK_LINE_MACRO), \-	 duk_push_error_object_stash)  /* last value is func pointer, arguments follow in parens */-#endif--DUK_EXTERNAL_DECL duk_idx_t duk_push_error_object_va_raw(duk_context *ctx, duk_errcode_t err_code, const char *filename, duk_int_t line, const char *fmt, va_list ap);-#define duk_push_error_object_va(ctx,err_code,fmt,ap)  \-	duk_push_error_object_va_raw((ctx), (err_code), (const char *) (DUK_FILE_MACRO), (duk_int_t) (DUK_LINE_MACRO), (fmt), (ap))--#define DUK_BUF_FLAG_DYNAMIC   (1 << 0)    /* internal flag: dynamic buffer */-#define DUK_BUF_FLAG_EXTERNAL  (1 << 1)    /* internal flag: external buffer */-#define DUK_BUF_FLAG_NOZERO    (1 << 2)    /* internal flag: don't zero allocated buffer */--DUK_EXTERNAL_DECL void *duk_push_buffer_raw(duk_context *ctx, duk_size_t size, duk_small_uint_t flags);--#define duk_push_buffer(ctx,size,dynamic) \-	duk_push_buffer_raw((ctx), (size), (dynamic) ? DUK_BUF_FLAG_DYNAMIC : 0)-#define duk_push_fixed_buffer(ctx,size) \-	duk_push_buffer_raw((ctx), (size), 0 /*flags*/)-#define duk_push_dynamic_buffer(ctx,size) \-	duk_push_buffer_raw((ctx), (size), DUK_BUF_FLAG_DYNAMIC /*flags*/)-#define duk_push_external_buffer(ctx) \-	((void) duk_push_buffer_raw((ctx), 0, DUK_BUF_FLAG_DYNAMIC | DUK_BUF_FLAG_EXTERNAL))--#define DUK_BUFOBJ_CREATE_ARRBUF       (1 << 4)  /* internal flag: create backing ArrayBuffer; keep in one byte */-#define DUK_BUFOBJ_ARRAYBUFFER         0-#define DUK_BUFOBJ_NODEJS_BUFFER       (1 | DUK_BUFOBJ_CREATE_ARRBUF)-#define DUK_BUFOBJ_DATAVIEW            (2 | DUK_BUFOBJ_CREATE_ARRBUF)-#define DUK_BUFOBJ_INT8ARRAY           (3 | DUK_BUFOBJ_CREATE_ARRBUF)-#define DUK_BUFOBJ_UINT8ARRAY          (4 | DUK_BUFOBJ_CREATE_ARRBUF)-#define DUK_BUFOBJ_UINT8CLAMPEDARRAY   (5 | DUK_BUFOBJ_CREATE_ARRBUF)-#define DUK_BUFOBJ_INT16ARRAY          (6 | DUK_BUFOBJ_CREATE_ARRBUF)-#define DUK_BUFOBJ_UINT16ARRAY         (7 | DUK_BUFOBJ_CREATE_ARRBUF)-#define DUK_BUFOBJ_INT32ARRAY          (8 | DUK_BUFOBJ_CREATE_ARRBUF)-#define DUK_BUFOBJ_UINT32ARRAY         (9 | DUK_BUFOBJ_CREATE_ARRBUF)-#define DUK_BUFOBJ_FLOAT32ARRAY        (10 | DUK_BUFOBJ_CREATE_ARRBUF)-#define DUK_BUFOBJ_FLOAT64ARRAY        (11 | DUK_BUFOBJ_CREATE_ARRBUF)--DUK_EXTERNAL_DECL void duk_push_buffer_object(duk_context *ctx, duk_idx_t idx_buffer, duk_size_t byte_offset, duk_size_t byte_length, duk_uint_t flags);--DUK_EXTERNAL_DECL duk_idx_t duk_push_heapptr(duk_context *ctx, void *ptr);--/*- *  Pop operations- */--DUK_EXTERNAL_DECL void duk_pop(duk_context *ctx);-DUK_EXTERNAL_DECL void duk_pop_n(duk_context *ctx, duk_idx_t count);-DUK_EXTERNAL_DECL void duk_pop_2(duk_context *ctx);-DUK_EXTERNAL_DECL void duk_pop_3(duk_context *ctx);--/*- *  Type checks- *- *  duk_is_none(), which would indicate whether index it outside of stack,- *  is not needed; duk_is_valid_index() gives the same information.- */--DUK_EXTERNAL_DECL duk_int_t duk_get_type(duk_context *ctx, duk_idx_t idx);-DUK_EXTERNAL_DECL duk_bool_t duk_check_type(duk_context *ctx, duk_idx_t idx, duk_int_t type);-DUK_EXTERNAL_DECL duk_uint_t duk_get_type_mask(duk_context *ctx, duk_idx_t idx);-DUK_EXTERNAL_DECL duk_bool_t duk_check_type_mask(duk_context *ctx, duk_idx_t idx, duk_uint_t mask);--DUK_EXTERNAL_DECL duk_bool_t duk_is_undefined(duk_context *ctx, duk_idx_t idx);-DUK_EXTERNAL_DECL duk_bool_t duk_is_null(duk_context *ctx, duk_idx_t idx);-#define duk_is_null_or_undefined(ctx, idx) \-	((duk_get_type_mask((ctx), (idx)) & (DUK_TYPE_MASK_NULL | DUK_TYPE_MASK_UNDEFINED)) ? 1 : 0)--DUK_EXTERNAL_DECL duk_bool_t duk_is_boolean(duk_context *ctx, duk_idx_t idx);-DUK_EXTERNAL_DECL duk_bool_t duk_is_number(duk_context *ctx, duk_idx_t idx);-DUK_EXTERNAL_DECL duk_bool_t duk_is_nan(duk_context *ctx, duk_idx_t idx);-DUK_EXTERNAL_DECL duk_bool_t duk_is_string(duk_context *ctx, duk_idx_t idx);-DUK_EXTERNAL_DECL duk_bool_t duk_is_object(duk_context *ctx, duk_idx_t idx);-DUK_EXTERNAL_DECL duk_bool_t duk_is_buffer(duk_context *ctx, duk_idx_t idx);-DUK_EXTERNAL_DECL duk_bool_t duk_is_buffer_data(duk_context *ctx, duk_idx_t idx);-DUK_EXTERNAL_DECL duk_bool_t duk_is_pointer(duk_context *ctx, duk_idx_t idx);-DUK_EXTERNAL_DECL duk_bool_t duk_is_lightfunc(duk_context *ctx, duk_idx_t idx);--DUK_EXTERNAL_DECL duk_bool_t duk_is_symbol(duk_context *ctx, duk_idx_t idx);-DUK_EXTERNAL_DECL duk_bool_t duk_is_array(duk_context *ctx, duk_idx_t idx);-DUK_EXTERNAL_DECL duk_bool_t duk_is_function(duk_context *ctx, duk_idx_t idx);-DUK_EXTERNAL_DECL duk_bool_t duk_is_c_function(duk_context *ctx, duk_idx_t idx);-DUK_EXTERNAL_DECL duk_bool_t duk_is_ecmascript_function(duk_context *ctx, duk_idx_t idx);-DUK_EXTERNAL_DECL duk_bool_t duk_is_bound_function(duk_context *ctx, duk_idx_t idx);-DUK_EXTERNAL_DECL duk_bool_t duk_is_thread(duk_context *ctx, duk_idx_t idx);--#define duk_is_callable(ctx,idx) \-	duk_is_function((ctx), (idx))-DUK_EXTERNAL_DECL duk_bool_t duk_is_dynamic_buffer(duk_context *ctx, duk_idx_t idx);-DUK_EXTERNAL_DECL duk_bool_t duk_is_fixed_buffer(duk_context *ctx, duk_idx_t idx);-DUK_EXTERNAL_DECL duk_bool_t duk_is_external_buffer(duk_context *ctx, duk_idx_t idx);--/* Buffers and lightfuncs are not considered primitive because they mimic- * objects and e.g. duk_to_primitive() will coerce them instead of returning- * them as is.  Symbols are represented as strings internally.- */-#define duk_is_primitive(ctx,idx) \-	duk_check_type_mask((ctx), (idx), DUK_TYPE_MASK_UNDEFINED | \-	                                  DUK_TYPE_MASK_NULL | \-	                                  DUK_TYPE_MASK_BOOLEAN | \-	                                  DUK_TYPE_MASK_NUMBER | \-	                                  DUK_TYPE_MASK_STRING | \-	                                  DUK_TYPE_MASK_POINTER)--/* Symbols are object coercible, covered by DUK_TYPE_MASK_STRING. */-#define duk_is_object_coercible(ctx,idx) \-	duk_check_type_mask((ctx), (idx), DUK_TYPE_MASK_BOOLEAN | \-	                                  DUK_TYPE_MASK_NUMBER | \-	                                  DUK_TYPE_MASK_STRING | \-	                                  DUK_TYPE_MASK_OBJECT | \-	                                  DUK_TYPE_MASK_BUFFER | \-	                                  DUK_TYPE_MASK_POINTER | \-	                                  DUK_TYPE_MASK_LIGHTFUNC)--DUK_EXTERNAL_DECL duk_errcode_t duk_get_error_code(duk_context *ctx, duk_idx_t idx);-#define duk_is_error(ctx,idx) \-	(duk_get_error_code((ctx), (idx)) != 0)-#define duk_is_eval_error(ctx,idx) \-	(duk_get_error_code((ctx), (idx)) == DUK_ERR_EVAL_ERROR)-#define duk_is_range_error(ctx,idx) \-	(duk_get_error_code((ctx), (idx)) == DUK_ERR_RANGE_ERROR)-#define duk_is_reference_error(ctx,idx) \-	(duk_get_error_code((ctx), (idx)) == DUK_ERR_REFERENCE_ERROR)-#define duk_is_syntax_error(ctx,idx) \-	(duk_get_error_code((ctx), (idx)) == DUK_ERR_SYNTAX_ERROR)-#define duk_is_type_error(ctx,idx) \-	(duk_get_error_code((ctx), (idx)) == DUK_ERR_TYPE_ERROR)-#define duk_is_uri_error(ctx,idx) \-	(duk_get_error_code((ctx), (idx)) == DUK_ERR_URI_ERROR)--/*- *  Get operations: no coercion, returns default value for invalid- *  indices and invalid value types.- *- *  duk_get_undefined() and duk_get_null() would be pointless and- *  are not included.- */--DUK_EXTERNAL_DECL duk_bool_t duk_get_boolean(duk_context *ctx, duk_idx_t idx);-DUK_EXTERNAL_DECL duk_double_t duk_get_number(duk_context *ctx, duk_idx_t idx);-DUK_EXTERNAL_DECL duk_int_t duk_get_int(duk_context *ctx, duk_idx_t idx);-DUK_EXTERNAL_DECL duk_uint_t duk_get_uint(duk_context *ctx, duk_idx_t idx);-DUK_EXTERNAL_DECL const char *duk_get_string(duk_context *ctx, duk_idx_t idx);-DUK_EXTERNAL_DECL const char *duk_get_lstring(duk_context *ctx, duk_idx_t idx, duk_size_t *out_len);-DUK_EXTERNAL_DECL void *duk_get_buffer(duk_context *ctx, duk_idx_t idx, duk_size_t *out_size);-DUK_EXTERNAL_DECL void *duk_get_buffer_data(duk_context *ctx, duk_idx_t idx, duk_size_t *out_size);-DUK_EXTERNAL_DECL void *duk_get_pointer(duk_context *ctx, duk_idx_t idx);-DUK_EXTERNAL_DECL duk_c_function duk_get_c_function(duk_context *ctx, duk_idx_t idx);-DUK_EXTERNAL_DECL duk_context *duk_get_context(duk_context *ctx, duk_idx_t idx);-DUK_EXTERNAL_DECL void *duk_get_heapptr(duk_context *ctx, duk_idx_t idx);-DUK_EXTERNAL_DECL duk_size_t duk_get_length(duk_context *ctx, duk_idx_t idx);-DUK_EXTERNAL_DECL void duk_set_length(duk_context *ctx, duk_idx_t idx, duk_size_t len);--/*- *  Require operations: no coercion, throw error if index or type- *  is incorrect.  No defaulting.- */--#define duk_require_type_mask(ctx,idx,mask) \-	((void) duk_check_type_mask((ctx), (idx), (mask) | DUK_TYPE_MASK_THROW))--DUK_EXTERNAL_DECL void duk_require_undefined(duk_context *ctx, duk_idx_t idx);-DUK_EXTERNAL_DECL void duk_require_null(duk_context *ctx, duk_idx_t idx);-DUK_EXTERNAL_DECL duk_bool_t duk_require_boolean(duk_context *ctx, duk_idx_t idx);-DUK_EXTERNAL_DECL duk_double_t duk_require_number(duk_context *ctx, duk_idx_t idx);-DUK_EXTERNAL_DECL duk_int_t duk_require_int(duk_context *ctx, duk_idx_t idx);-DUK_EXTERNAL_DECL duk_uint_t duk_require_uint(duk_context *ctx, duk_idx_t idx);-DUK_EXTERNAL_DECL const char *duk_require_string(duk_context *ctx, duk_idx_t idx);-DUK_EXTERNAL_DECL const char *duk_require_lstring(duk_context *ctx, duk_idx_t idx, duk_size_t *out_len);-DUK_EXTERNAL_DECL void *duk_require_buffer(duk_context *ctx, duk_idx_t idx, duk_size_t *out_size);-DUK_EXTERNAL_DECL void *duk_require_buffer_data(duk_context *ctx, duk_idx_t idx, duk_size_t *out_size);-DUK_EXTERNAL_DECL void *duk_require_pointer(duk_context *ctx, duk_idx_t idx);-DUK_EXTERNAL_DECL duk_c_function duk_require_c_function(duk_context *ctx, duk_idx_t idx);-DUK_EXTERNAL_DECL duk_context *duk_require_context(duk_context *ctx, duk_idx_t idx);-DUK_EXTERNAL_DECL void duk_require_function(duk_context *ctx, duk_idx_t idx);-#define duk_require_callable(ctx,idx) \-	duk_require_function((ctx), (idx))-DUK_EXTERNAL_DECL void *duk_require_heapptr(duk_context *ctx, duk_idx_t idx);--/* Symbols are object coercible and covered by DUK_TYPE_MASK_STRING. */-#define duk_require_object_coercible(ctx,idx) \-	((void) duk_check_type_mask((ctx), (idx), DUK_TYPE_MASK_BOOLEAN | \-	                                            DUK_TYPE_MASK_NUMBER | \-	                                            DUK_TYPE_MASK_STRING | \-	                                            DUK_TYPE_MASK_OBJECT | \-	                                            DUK_TYPE_MASK_BUFFER | \-	                                            DUK_TYPE_MASK_POINTER | \-	                                            DUK_TYPE_MASK_LIGHTFUNC | \-	                                            DUK_TYPE_MASK_THROW))--/*- *  Coercion operations: in-place coercion, return coerced value where- *  applicable.  If index is invalid, throw error.  Some coercions may- *  throw an expected error (e.g. from a toString() or valueOf() call)- *  or an internal error (e.g. from out of memory).- */--DUK_EXTERNAL_DECL void duk_to_undefined(duk_context *ctx, duk_idx_t idx);-DUK_EXTERNAL_DECL void duk_to_null(duk_context *ctx, duk_idx_t idx);-DUK_EXTERNAL_DECL duk_bool_t duk_to_boolean(duk_context *ctx, duk_idx_t idx);-DUK_EXTERNAL_DECL duk_double_t duk_to_number(duk_context *ctx, duk_idx_t idx);-DUK_EXTERNAL_DECL duk_int_t duk_to_int(duk_context *ctx, duk_idx_t idx);-DUK_EXTERNAL_DECL duk_uint_t duk_to_uint(duk_context *ctx, duk_idx_t idx);-DUK_EXTERNAL_DECL duk_int32_t duk_to_int32(duk_context *ctx, duk_idx_t idx);-DUK_EXTERNAL_DECL duk_uint32_t duk_to_uint32(duk_context *ctx, duk_idx_t idx);-DUK_EXTERNAL_DECL duk_uint16_t duk_to_uint16(duk_context *ctx, duk_idx_t idx);-DUK_EXTERNAL_DECL const char *duk_to_string(duk_context *ctx, duk_idx_t idx);-DUK_EXTERNAL_DECL const char *duk_to_lstring(duk_context *ctx, duk_idx_t idx, duk_size_t *out_len);-DUK_EXTERNAL_DECL void *duk_to_buffer_raw(duk_context *ctx, duk_idx_t idx, duk_size_t *out_size, duk_uint_t flags);-DUK_EXTERNAL_DECL void *duk_to_pointer(duk_context *ctx, duk_idx_t idx);-DUK_EXTERNAL_DECL void duk_to_object(duk_context *ctx, duk_idx_t idx);-DUK_EXTERNAL_DECL void duk_to_primitive(duk_context *ctx, duk_idx_t idx, duk_int_t hint);--#define DUK_BUF_MODE_FIXED      0   /* internal: request fixed buffer result */-#define DUK_BUF_MODE_DYNAMIC    1   /* internal: request dynamic buffer result */-#define DUK_BUF_MODE_DONTCARE   2   /* internal: don't care about fixed/dynamic nature */--#define duk_to_buffer(ctx,idx,out_size) \-	duk_to_buffer_raw((ctx), (idx), (out_size), DUK_BUF_MODE_DONTCARE)-#define duk_to_fixed_buffer(ctx,idx,out_size) \-	duk_to_buffer_raw((ctx), (idx), (out_size), DUK_BUF_MODE_FIXED)-#define duk_to_dynamic_buffer(ctx,idx,out_size) \-	duk_to_buffer_raw((ctx), (idx), (out_size), DUK_BUF_MODE_DYNAMIC)--/* safe variants of a few coercion operations */-DUK_EXTERNAL_DECL const char *duk_safe_to_lstring(duk_context *ctx, duk_idx_t idx, duk_size_t *out_len);-#define duk_safe_to_string(ctx,idx) \-	duk_safe_to_lstring((ctx), (idx), NULL)--/*- *  Misc conversion- */--DUK_EXTERNAL_DECL const char *duk_base64_encode(duk_context *ctx, duk_idx_t idx);-DUK_EXTERNAL_DECL void duk_base64_decode(duk_context *ctx, duk_idx_t idx);-DUK_EXTERNAL_DECL const char *duk_hex_encode(duk_context *ctx, duk_idx_t idx);-DUK_EXTERNAL_DECL void duk_hex_decode(duk_context *ctx, duk_idx_t idx);-DUK_EXTERNAL_DECL const char *duk_json_encode(duk_context *ctx, duk_idx_t idx);-DUK_EXTERNAL_DECL void duk_json_decode(duk_context *ctx, duk_idx_t idx);--DUK_EXTERNAL_DECL const char *duk_buffer_to_string(duk_context *ctx, duk_idx_t idx);--/*- *  Buffer- */--DUK_EXTERNAL_DECL void *duk_resize_buffer(duk_context *ctx, duk_idx_t idx, duk_size_t new_size);-DUK_EXTERNAL_DECL void *duk_steal_buffer(duk_context *ctx, duk_idx_t idx, duk_size_t *out_size);-DUK_EXTERNAL_DECL void duk_config_buffer(duk_context *ctx, duk_idx_t idx, void *ptr, duk_size_t len);--/*- *  Property access- *- *  The basic function assumes key is on stack.  The _string variant takes- *  a C string as a property name, while the _index variant takes an array- *  index as a property name (e.g. 123 is equivalent to the key "123").- */--DUK_EXTERNAL_DECL duk_bool_t duk_get_prop(duk_context *ctx, duk_idx_t obj_idx);-DUK_EXTERNAL_DECL duk_bool_t duk_get_prop_string(duk_context *ctx, duk_idx_t obj_idx, const char *key);-DUK_EXTERNAL_DECL duk_bool_t duk_get_prop_lstring(duk_context *ctx, duk_idx_t obj_idx, const char *key, duk_size_t key_len);-DUK_EXTERNAL_DECL duk_bool_t duk_get_prop_index(duk_context *ctx, duk_idx_t obj_idx, duk_uarridx_t arr_idx);-DUK_EXTERNAL_DECL duk_bool_t duk_put_prop(duk_context *ctx, duk_idx_t obj_idx);-DUK_EXTERNAL_DECL duk_bool_t duk_put_prop_string(duk_context *ctx, duk_idx_t obj_idx, const char *key);-DUK_EXTERNAL_DECL duk_bool_t duk_put_prop_lstring(duk_context *ctx, duk_idx_t obj_idx, const char *key, duk_size_t key_len);-DUK_EXTERNAL_DECL duk_bool_t duk_put_prop_index(duk_context *ctx, duk_idx_t obj_idx, duk_uarridx_t arr_idx);-DUK_EXTERNAL_DECL duk_bool_t duk_del_prop(duk_context *ctx, duk_idx_t obj_idx);-DUK_EXTERNAL_DECL duk_bool_t duk_del_prop_string(duk_context *ctx, duk_idx_t obj_idx, const char *key);-DUK_EXTERNAL_DECL duk_bool_t duk_del_prop_lstring(duk_context *ctx, duk_idx_t obj_idx, const char *key, duk_size_t key_len);-DUK_EXTERNAL_DECL duk_bool_t duk_del_prop_index(duk_context *ctx, duk_idx_t obj_idx, duk_uarridx_t arr_idx);-DUK_EXTERNAL_DECL duk_bool_t duk_has_prop(duk_context *ctx, duk_idx_t obj_idx);-DUK_EXTERNAL_DECL duk_bool_t duk_has_prop_string(duk_context *ctx, duk_idx_t obj_idx, const char *key);-DUK_EXTERNAL_DECL duk_bool_t duk_has_prop_lstring(duk_context *ctx, duk_idx_t obj_idx, const char *key, duk_size_t key_len);-DUK_EXTERNAL_DECL duk_bool_t duk_has_prop_index(duk_context *ctx, duk_idx_t obj_idx, duk_uarridx_t arr_idx);--DUK_EXTERNAL_DECL void duk_get_prop_desc(duk_context *ctx, duk_idx_t obj_idx, duk_uint_t flags);-DUK_EXTERNAL_DECL void duk_def_prop(duk_context *ctx, duk_idx_t obj_idx, duk_uint_t flags);--DUK_EXTERNAL_DECL duk_bool_t duk_get_global_string(duk_context *ctx, const char *key);-DUK_EXTERNAL_DECL duk_bool_t duk_get_global_lstring(duk_context *ctx, const char *key, duk_size_t key_len);-DUK_EXTERNAL_DECL duk_bool_t duk_put_global_string(duk_context *ctx, const char *key);-DUK_EXTERNAL_DECL duk_bool_t duk_put_global_lstring(duk_context *ctx, const char *key, duk_size_t key_len);--/*- *  Inspection- */--DUK_EXTERNAL_DECL void duk_inspect_value(duk_context *ctx, duk_idx_t idx);-DUK_EXTERNAL_DECL void duk_inspect_callstack_entry(duk_context *ctx, duk_int_t level);--/*- *  Object prototype- */--DUK_EXTERNAL_DECL void duk_get_prototype(duk_context *ctx, duk_idx_t idx);-DUK_EXTERNAL_DECL void duk_set_prototype(duk_context *ctx, duk_idx_t idx);--/*- *  Object finalizer- */--DUK_EXTERNAL_DECL void duk_get_finalizer(duk_context *ctx, duk_idx_t idx);-DUK_EXTERNAL_DECL void duk_set_finalizer(duk_context *ctx, duk_idx_t idx);--/*- *  Global object- */--DUK_EXTERNAL_DECL void duk_set_global_object(duk_context *ctx);--/*- *  Duktape/C function magic value- */--DUK_EXTERNAL_DECL duk_int_t duk_get_magic(duk_context *ctx, duk_idx_t idx);-DUK_EXTERNAL_DECL void duk_set_magic(duk_context *ctx, duk_idx_t idx, duk_int_t magic);-DUK_EXTERNAL_DECL duk_int_t duk_get_current_magic(duk_context *ctx);--/*- *  Module helpers: put multiple function or constant properties- */--DUK_EXTERNAL_DECL void duk_put_function_list(duk_context *ctx, duk_idx_t obj_idx, const duk_function_list_entry *funcs);-DUK_EXTERNAL_DECL void duk_put_number_list(duk_context *ctx, duk_idx_t obj_idx, const duk_number_list_entry *numbers);--/*- *  Object operations- */--DUK_EXTERNAL_DECL void duk_compact(duk_context *ctx, duk_idx_t obj_idx);-DUK_EXTERNAL_DECL void duk_enum(duk_context *ctx, duk_idx_t obj_idx, duk_uint_t enum_flags);-DUK_EXTERNAL_DECL duk_bool_t duk_next(duk_context *ctx, duk_idx_t enum_idx, duk_bool_t get_value);--/*- *  String manipulation- */--DUK_EXTERNAL_DECL void duk_concat(duk_context *ctx, duk_idx_t count);-DUK_EXTERNAL_DECL void duk_join(duk_context *ctx, duk_idx_t count);-DUK_EXTERNAL_DECL void duk_decode_string(duk_context *ctx, duk_idx_t idx, duk_decode_char_function callback, void *udata);-DUK_EXTERNAL_DECL void duk_map_string(duk_context *ctx, duk_idx_t idx, duk_map_char_function callback, void *udata);-DUK_EXTERNAL_DECL void duk_substring(duk_context *ctx, duk_idx_t idx, duk_size_t start_char_offset, duk_size_t end_char_offset);-DUK_EXTERNAL_DECL void duk_trim(duk_context *ctx, duk_idx_t idx);-DUK_EXTERNAL_DECL duk_codepoint_t duk_char_code_at(duk_context *ctx, duk_idx_t idx, duk_size_t char_offset);--/*- *  Ecmascript operators- */--DUK_EXTERNAL_DECL duk_bool_t duk_equals(duk_context *ctx, duk_idx_t idx1, duk_idx_t idx2);-DUK_EXTERNAL_DECL duk_bool_t duk_strict_equals(duk_context *ctx, duk_idx_t idx1, duk_idx_t idx2);-DUK_EXTERNAL_DECL duk_bool_t duk_samevalue(duk_context *ctx, duk_idx_t idx1, duk_idx_t idx2);-DUK_EXTERNAL_DECL duk_bool_t duk_instanceof(duk_context *ctx, duk_idx_t idx1, duk_idx_t idx2);--/*- *  Function (method) calls- */--DUK_EXTERNAL_DECL void duk_call(duk_context *ctx, duk_idx_t nargs);-DUK_EXTERNAL_DECL void duk_call_method(duk_context *ctx, duk_idx_t nargs);-DUK_EXTERNAL_DECL void duk_call_prop(duk_context *ctx, duk_idx_t obj_idx, duk_idx_t nargs);-DUK_EXTERNAL_DECL duk_int_t duk_pcall(duk_context *ctx, duk_idx_t nargs);-DUK_EXTERNAL_DECL duk_int_t duk_pcall_method(duk_context *ctx, duk_idx_t nargs);-DUK_EXTERNAL_DECL duk_int_t duk_pcall_prop(duk_context *ctx, duk_idx_t obj_idx, duk_idx_t nargs);-DUK_EXTERNAL_DECL void duk_new(duk_context *ctx, duk_idx_t nargs);-DUK_EXTERNAL_DECL duk_int_t duk_pnew(duk_context *ctx, duk_idx_t nargs);-DUK_EXTERNAL_DECL duk_int_t duk_safe_call(duk_context *ctx, duk_safe_call_function func, void *udata, duk_idx_t nargs, duk_idx_t nrets);--/*- *  Thread management- */--/* There are currently no native functions to yield/resume, due to the internal- * limitations on coroutine handling.  These will be added later.- */--/*- *  Compilation and evaluation- */--DUK_EXTERNAL_DECL duk_int_t duk_eval_raw(duk_context *ctx, const char *src_buffer, duk_size_t src_length, duk_uint_t flags);-DUK_EXTERNAL_DECL duk_int_t duk_compile_raw(duk_context *ctx, const char *src_buffer, duk_size_t src_length, duk_uint_t flags);--/* plain */-#define duk_eval(ctx)  \-	((void) duk_eval_raw((ctx), NULL, 0, 1 /*args*/ | DUK_COMPILE_EVAL | DUK_COMPILE_NOFILENAME))--#define duk_eval_noresult(ctx)  \-	((void) duk_eval_raw((ctx), NULL, 0, 1 /*args*/ | DUK_COMPILE_EVAL | DUK_COMPILE_NORESULT | DUK_COMPILE_NOFILENAME))--#define duk_peval(ctx)  \-	(duk_eval_raw((ctx), NULL, 0, 1 /*args*/ | DUK_COMPILE_EVAL | DUK_COMPILE_SAFE | DUK_COMPILE_NOFILENAME))--#define duk_peval_noresult(ctx)  \-	(duk_eval_raw((ctx), NULL, 0, 1 /*args*/ | DUK_COMPILE_EVAL | DUK_COMPILE_SAFE | DUK_COMPILE_NORESULT | DUK_COMPILE_NOFILENAME))--#define duk_compile(ctx,flags)  \-	((void) duk_compile_raw((ctx), NULL, 0, 2 /*args*/ | (flags)))--#define duk_pcompile(ctx,flags)  \-	(duk_compile_raw((ctx), NULL, 0, 2 /*args*/ | (flags) | DUK_COMPILE_SAFE))--/* string */-#define duk_eval_string(ctx,src)  \-	((void) duk_eval_raw((ctx), (src), 0, 0 /*args*/ | DUK_COMPILE_EVAL | DUK_COMPILE_NOSOURCE | DUK_COMPILE_STRLEN | DUK_COMPILE_NOFILENAME))--#define duk_eval_string_noresult(ctx,src)  \-	((void) duk_eval_raw((ctx), (src), 0, 0 /*args*/ | DUK_COMPILE_EVAL | DUK_COMPILE_NOSOURCE | DUK_COMPILE_STRLEN | DUK_COMPILE_NORESULT | DUK_COMPILE_NOFILENAME))--#define duk_peval_string(ctx,src)  \-	(duk_eval_raw((ctx), (src), 0, 0 /*args*/ | DUK_COMPILE_EVAL | DUK_COMPILE_SAFE | DUK_COMPILE_NOSOURCE | DUK_COMPILE_STRLEN | DUK_COMPILE_NOFILENAME))--#define duk_peval_string_noresult(ctx,src)  \-	(duk_eval_raw((ctx), (src), 0, 0 /*args*/ | DUK_COMPILE_EVAL | DUK_COMPILE_SAFE | DUK_COMPILE_NOSOURCE | DUK_COMPILE_STRLEN | DUK_COMPILE_NORESULT | DUK_COMPILE_NOFILENAME))--#define duk_compile_string(ctx,flags,src)  \-	((void) duk_compile_raw((ctx), (src), 0, 0 /*args*/ | (flags) | DUK_COMPILE_NOSOURCE | DUK_COMPILE_STRLEN | DUK_COMPILE_NOFILENAME))--#define duk_compile_string_filename(ctx,flags,src)  \-	((void) duk_compile_raw((ctx), (src), 0, 1 /*args*/ | (flags) | DUK_COMPILE_NOSOURCE | DUK_COMPILE_STRLEN))--#define duk_pcompile_string(ctx,flags,src)  \-	(duk_compile_raw((ctx), (src), 0, 0 /*args*/ | (flags) | DUK_COMPILE_SAFE | DUK_COMPILE_NOSOURCE | DUK_COMPILE_STRLEN | DUK_COMPILE_NOFILENAME))--#define duk_pcompile_string_filename(ctx,flags,src)  \-	(duk_compile_raw((ctx), (src), 0, 1 /*args*/ | (flags) | DUK_COMPILE_SAFE | DUK_COMPILE_NOSOURCE | DUK_COMPILE_STRLEN))--/* lstring */-#define duk_eval_lstring(ctx,buf,len)  \-	((void) duk_eval_raw((ctx), buf, len, 0 /*args*/ | DUK_COMPILE_EVAL | DUK_COMPILE_NOSOURCE | DUK_COMPILE_NOFILENAME))--#define duk_eval_lstring_noresult(ctx,buf,len)  \-	((void) duk_eval_raw((ctx), buf, len, 0 /*args*/ | DUK_COMPILE_EVAL | DUK_COMPILE_NOSOURCE | DUK_COMPILE_NORESULT | DUK_COMPILE_NOFILENAME))--#define duk_peval_lstring(ctx,buf,len)  \-	(duk_eval_raw((ctx), buf, len, 0 /*args*/ | DUK_COMPILE_EVAL | DUK_COMPILE_NOSOURCE | DUK_COMPILE_SAFE | DUK_COMPILE_NOFILENAME))--#define duk_peval_lstring_noresult(ctx,buf,len)  \-	(duk_eval_raw((ctx), buf, len, 0 /*args*/ | DUK_COMPILE_EVAL | DUK_COMPILE_SAFE | DUK_COMPILE_NOSOURCE | DUK_COMPILE_NORESULT | DUK_COMPILE_NOFILENAME))--#define duk_compile_lstring(ctx,flags,buf,len)  \-	((void) duk_compile_raw((ctx), buf, len, 0 /*args*/ | (flags) | DUK_COMPILE_NOSOURCE | DUK_COMPILE_NOFILENAME))--#define duk_compile_lstring_filename(ctx,flags,buf,len)  \-	((void) duk_compile_raw((ctx), buf, len, 1 /*args*/ | (flags) | DUK_COMPILE_NOSOURCE))--#define duk_pcompile_lstring(ctx,flags,buf,len)  \-	(duk_compile_raw((ctx), buf, len, 0 /*args*/ | (flags) | DUK_COMPILE_SAFE | DUK_COMPILE_NOSOURCE | DUK_COMPILE_NOFILENAME))--#define duk_pcompile_lstring_filename(ctx,flags,buf,len)  \-	(duk_compile_raw((ctx), buf, len, 1 /*args*/ | (flags) | DUK_COMPILE_SAFE | DUK_COMPILE_NOSOURCE))--/*- *  Bytecode load/dump- */--DUK_EXTERNAL_DECL void duk_dump_function(duk_context *ctx);-DUK_EXTERNAL_DECL void duk_load_function(duk_context *ctx);--/*- *  Debugging- */--DUK_EXTERNAL_DECL void duk_push_context_dump(duk_context *ctx);--/*- *  Debugger (debug protocol)- */--DUK_EXTERNAL_DECL void duk_debugger_attach(duk_context *ctx,-                                           duk_debug_read_function read_cb,-                                           duk_debug_write_function write_cb,-                                           duk_debug_peek_function peek_cb,-                                           duk_debug_read_flush_function read_flush_cb,-                                           duk_debug_write_flush_function write_flush_cb,-                                           duk_debug_request_function request_cb,-                                           duk_debug_detached_function detached_cb,-                                           void *udata);-DUK_EXTERNAL_DECL void duk_debugger_detach(duk_context *ctx);-DUK_EXTERNAL_DECL void duk_debugger_cooperate(duk_context *ctx);-DUK_EXTERNAL_DECL duk_bool_t duk_debugger_notify(duk_context *ctx, duk_idx_t nvalues);-DUK_EXTERNAL_DECL void duk_debugger_pause(duk_context *ctx);--/*- *  Time handling- */--DUK_EXTERNAL_DECL duk_double_t duk_get_now(duk_context *ctx);-DUK_EXTERNAL_DECL void duk_time_to_components(duk_context *ctx, duk_double_t timeval, duk_time_components *comp);-DUK_EXTERNAL_DECL duk_double_t duk_components_to_time(duk_context *ctx, duk_time_components *comp);--/*- *  Date provider related constants- *- *  NOTE: These are "semi public" - you should only use these if you write- *  your own platform specific Date provider, see doc/datetime.rst.- */--/* Millisecond count constants. */-#define DUK_DATE_MSEC_SECOND          1000L-#define DUK_DATE_MSEC_MINUTE          (60L * 1000L)-#define DUK_DATE_MSEC_HOUR            (60L * 60L * 1000L)-#define DUK_DATE_MSEC_DAY             (24L * 60L * 60L * 1000L)--/* Ecmascript date range is 100 million days from Epoch:- * > 100e6 * 24 * 60 * 60 * 1000  // 100M days in millisecs- * 8640000000000000- * (= 8.64e15)- */-#define DUK_DATE_MSEC_100M_DAYS         (8.64e15)-#define DUK_DATE_MSEC_100M_DAYS_LEEWAY  (8.64e15 + 24 * 3600e3)--/* Ecmascript year range:- * > new Date(100e6 * 24 * 3600e3).toISOString()- * '+275760-09-13T00:00:00.000Z'- * > new Date(-100e6 * 24 * 3600e3).toISOString()- * '-271821-04-20T00:00:00.000Z'- */-#define DUK_DATE_MIN_ECMA_YEAR     (-271821L)-#define DUK_DATE_MAX_ECMA_YEAR     275760L--/* Part indices for internal breakdowns.  Part order from DUK_DATE_IDX_YEAR- * to DUK_DATE_IDX_MILLISECOND matches argument ordering of Ecmascript API- * calls (like Date constructor call).  Some functions in duk_bi_date.c- * depend on the specific ordering, so change with care.  16 bits are not- * enough for all parts (year, specifically).- *- * Must be in-sync with genbuiltins.py.- */-#define DUK_DATE_IDX_YEAR           0  /* year */-#define DUK_DATE_IDX_MONTH          1  /* month: 0 to 11 */-#define DUK_DATE_IDX_DAY            2  /* day within month: 0 to 30 */-#define DUK_DATE_IDX_HOUR           3-#define DUK_DATE_IDX_MINUTE         4-#define DUK_DATE_IDX_SECOND         5-#define DUK_DATE_IDX_MILLISECOND    6-#define DUK_DATE_IDX_WEEKDAY        7  /* weekday: 0 to 6, 0=sunday, 1=monday, etc */-#define DUK_DATE_IDX_NUM_PARTS      8--/* Internal API call flags, used for various functions in duk_bi_date.c.- * Certain flags are used by only certain functions, but since the flags- * don't overlap, a single flags value can be passed around to multiple- * functions.- *- * The unused top bits of the flags field are also used to pass values- * to helpers (duk__get_part_helper() and duk__set_part_helper()).- *- * Must be in-sync with genbuiltins.py.- */--/* NOTE: when writing a Date provider you only need a few specific- * flags from here, the rest are internal.  Avoid using anything you- * don't need.- */--#define DUK_DATE_FLAG_NAN_TO_ZERO          (1 << 0)  /* timeval breakdown: internal time value NaN -> zero */-#define DUK_DATE_FLAG_NAN_TO_RANGE_ERROR   (1 << 1)  /* timeval breakdown: internal time value NaN -> RangeError (toISOString) */-#define DUK_DATE_FLAG_ONEBASED             (1 << 2)  /* timeval breakdown: convert month and day-of-month parts to one-based (default is zero-based) */-#define DUK_DATE_FLAG_EQUIVYEAR            (1 << 3)  /* timeval breakdown: replace year with equivalent year in the [1971,2037] range for DST calculations */-#define DUK_DATE_FLAG_LOCALTIME            (1 << 4)  /* convert time value to local time */-#define DUK_DATE_FLAG_SUB1900              (1 << 5)  /* getter: subtract 1900 from year when getting year part */-#define DUK_DATE_FLAG_TOSTRING_DATE        (1 << 6)  /* include date part in string conversion result */-#define DUK_DATE_FLAG_TOSTRING_TIME        (1 << 7)  /* include time part in string conversion result */-#define DUK_DATE_FLAG_TOSTRING_LOCALE      (1 << 8)  /* use locale specific formatting if available */-#define DUK_DATE_FLAG_TIMESETTER           (1 << 9)  /* setter: call is a time setter (affects hour, min, sec, ms); otherwise date setter (affects year, month, day-in-month) */-#define DUK_DATE_FLAG_YEAR_FIXUP           (1 << 10) /* setter: perform 2-digit year fixup (00...99 -> 1900...1999) */-#define DUK_DATE_FLAG_SEP_T                (1 << 11) /* string conversion: use 'T' instead of ' ' as a separator */-#define DUK_DATE_FLAG_VALUE_SHIFT          12        /* additional values begin at bit 12 */--/*- *  ROM pointer compression- */--/* Support array for ROM pointer compression.  Only declared when ROM- * pointer compression is active.- */-#if defined(DUK_USE_ROM_OBJECTS) && defined(DUK_USE_HEAPPTR16)-DUK_EXTERNAL_DECL const void * const duk_rom_compressed_pointers[];-#endif--/*- *  C++ name mangling- */--#if defined(__cplusplus)-/* end 'extern "C"' wrapper */-}-#endif--#endif  /* DUK_API_PUBLIC_H_INCLUDED */--/*- *  END PUBLIC API- */--/*- *  Union to access IEEE double memory representation, indexes for double- *  memory representation, and some macros for double manipulation.- *- *  Also used by packed duk_tval.  Use a union for bit manipulation to- *  minimize aliasing issues in practice.  The C99 standard does not- *  guarantee that this should work, but it's a very widely supported- *  practice for low level manipulation.- *- *  IEEE double format summary:- *- *    seeeeeee eeeeffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff- *       A        B        C        D        E        F        G        H- *- *    s       sign bit- *    eee...  exponent field- *    fff...  fraction- *- *  See http://en.wikipedia.org/wiki/Double_precision_floating-point_format.- *- *  NaNs are represented as exponent 0x7ff and mantissa != 0.  The NaN is a- *  signaling NaN when the highest bit of the mantissa is zero, and a quiet- *  NaN when the highest bit is set.- *- *  At least three memory layouts are relevant here:- *- *    A B C D E F G H    Big endian (e.g. 68k)           DUK_USE_DOUBLE_BE- *    H G F E D C B A    Little endian (e.g. x86)        DUK_USE_DOUBLE_LE- *    D C B A H G F E    Mixed/cross endian (e.g. ARM)   DUK_USE_DOUBLE_ME- *- *  ARM is a special case: ARM double values are in mixed/cross endian- *  format while ARM duk_uint64_t values are in standard little endian- *  format (H G F E D C B A).  When a double is read as a duk_uint64_t- *  from memory, the register will contain the (logical) value- *  E F G H A B C D.  This requires some special handling below.- *- *  Indexes of various types (8-bit, 16-bit, 32-bit) in memory relative to- *  the logical (big endian) order:- *- *  byte order      duk_uint8_t    duk_uint16_t     duk_uint32_t- *    BE             01234567         0123               01- *    LE             76543210         3210               10- *    ME (ARM)       32107654         1032               01- *- *  Some processors may alter NaN values in a floating point load+store.- *  For instance, on X86 a FLD + FSTP may convert a signaling NaN to a- *  quiet one.  This is catastrophic when NaN space is used in packed- *  duk_tval values.  See: misc/clang_aliasing.c.- */--#if !defined(DUK_DBLUNION_H_INCLUDED)-#define DUK_DBLUNION_H_INCLUDED--/*- *  Union for accessing double parts, also serves as packed duk_tval- */--union duk_double_union {-	double d;-	float f[2];-#if defined(DUK_USE_64BIT_OPS)-	duk_uint64_t ull[1];-#endif-	duk_uint32_t ui[2];-	duk_uint16_t us[4];-	duk_uint8_t uc[8];-#if defined(DUK_USE_PACKED_TVAL)-	void *vp[2];  /* used by packed duk_tval, assumes sizeof(void *) == 4 */-#endif-};--typedef union duk_double_union duk_double_union;--/*- *  Indexes of various types with respect to big endian (logical) layout- */--#if defined(DUK_USE_DOUBLE_LE)-#if defined(DUK_USE_64BIT_OPS)-#define DUK_DBL_IDX_ULL0   0-#endif-#define DUK_DBL_IDX_UI0    1-#define DUK_DBL_IDX_UI1    0-#define DUK_DBL_IDX_US0    3-#define DUK_DBL_IDX_US1    2-#define DUK_DBL_IDX_US2    1-#define DUK_DBL_IDX_US3    0-#define DUK_DBL_IDX_UC0    7-#define DUK_DBL_IDX_UC1    6-#define DUK_DBL_IDX_UC2    5-#define DUK_DBL_IDX_UC3    4-#define DUK_DBL_IDX_UC4    3-#define DUK_DBL_IDX_UC5    2-#define DUK_DBL_IDX_UC6    1-#define DUK_DBL_IDX_UC7    0-#define DUK_DBL_IDX_VP0    DUK_DBL_IDX_UI0  /* packed tval */-#define DUK_DBL_IDX_VP1    DUK_DBL_IDX_UI1  /* packed tval */-#elif defined(DUK_USE_DOUBLE_BE)-#if defined(DUK_USE_64BIT_OPS)-#define DUK_DBL_IDX_ULL0   0-#endif-#define DUK_DBL_IDX_UI0    0-#define DUK_DBL_IDX_UI1    1-#define DUK_DBL_IDX_US0    0-#define DUK_DBL_IDX_US1    1-#define DUK_DBL_IDX_US2    2-#define DUK_DBL_IDX_US3    3-#define DUK_DBL_IDX_UC0    0-#define DUK_DBL_IDX_UC1    1-#define DUK_DBL_IDX_UC2    2-#define DUK_DBL_IDX_UC3    3-#define DUK_DBL_IDX_UC4    4-#define DUK_DBL_IDX_UC5    5-#define DUK_DBL_IDX_UC6    6-#define DUK_DBL_IDX_UC7    7-#define DUK_DBL_IDX_VP0    DUK_DBL_IDX_UI0  /* packed tval */-#define DUK_DBL_IDX_VP1    DUK_DBL_IDX_UI1  /* packed tval */-#elif defined(DUK_USE_DOUBLE_ME)-#if defined(DUK_USE_64BIT_OPS)-#define DUK_DBL_IDX_ULL0   0  /* not directly applicable, byte order differs from a double */-#endif-#define DUK_DBL_IDX_UI0    0-#define DUK_DBL_IDX_UI1    1-#define DUK_DBL_IDX_US0    1-#define DUK_DBL_IDX_US1    0-#define DUK_DBL_IDX_US2    3-#define DUK_DBL_IDX_US3    2-#define DUK_DBL_IDX_UC0    3-#define DUK_DBL_IDX_UC1    2-#define DUK_DBL_IDX_UC2    1-#define DUK_DBL_IDX_UC3    0-#define DUK_DBL_IDX_UC4    7-#define DUK_DBL_IDX_UC5    6-#define DUK_DBL_IDX_UC6    5-#define DUK_DBL_IDX_UC7    4-#define DUK_DBL_IDX_VP0    DUK_DBL_IDX_UI0  /* packed tval */-#define DUK_DBL_IDX_VP1    DUK_DBL_IDX_UI1  /* packed tval */-#else-#error internal error-#endif--/*- *  Helper macros for reading/writing memory representation parts, used- *  by duk_numconv.c and duk_tval.h.- */--#define DUK_DBLUNION_SET_DOUBLE(u,v)  do {  \-		(u)->d = (v); \-	} while (0)--#define DUK_DBLUNION_SET_HIGH32(u,v)  do {  \-		(u)->ui[DUK_DBL_IDX_UI0] = (duk_uint32_t) (v); \-	} while (0)--#if defined(DUK_USE_64BIT_OPS)-#if defined(DUK_USE_DOUBLE_ME)-#define DUK_DBLUNION_SET_HIGH32_ZERO_LOW32(u,v)  do { \-		(u)->ull[DUK_DBL_IDX_ULL0] = (duk_uint64_t) (v); \-	} while (0)-#else-#define DUK_DBLUNION_SET_HIGH32_ZERO_LOW32(u,v)  do { \-		(u)->ull[DUK_DBL_IDX_ULL0] = ((duk_uint64_t) (v)) << 32; \-	} while (0)-#endif-#else  /* DUK_USE_64BIT_OPS */-#define DUK_DBLUNION_SET_HIGH32_ZERO_LOW32(u,v)  do { \-		(u)->ui[DUK_DBL_IDX_UI0] = (duk_uint32_t) (v); \-		(u)->ui[DUK_DBL_IDX_UI1] = (duk_uint32_t) 0; \-	} while (0)-#endif  /* DUK_USE_64BIT_OPS */--#define DUK_DBLUNION_SET_LOW32(u,v)  do {  \-		(u)->ui[DUK_DBL_IDX_UI1] = (duk_uint32_t) (v); \-	} while (0)--#define DUK_DBLUNION_GET_DOUBLE(u)  ((u)->d)-#define DUK_DBLUNION_GET_HIGH32(u)  ((u)->ui[DUK_DBL_IDX_UI0])-#define DUK_DBLUNION_GET_LOW32(u)   ((u)->ui[DUK_DBL_IDX_UI1])--#if defined(DUK_USE_64BIT_OPS)-#if defined(DUK_USE_DOUBLE_ME)-#define DUK_DBLUNION_SET_UINT64(u,v)  do { \-		(u)->ui[DUK_DBL_IDX_UI0] = (duk_uint32_t) ((v) >> 32); \-		(u)->ui[DUK_DBL_IDX_UI1] = (duk_uint32_t) (v); \-	} while (0)-#define DUK_DBLUNION_GET_UINT64(u) \-	((((duk_uint64_t) (u)->ui[DUK_DBL_IDX_UI0]) << 32) | \-	 ((duk_uint64_t) (u)->ui[DUK_DBL_IDX_UI1]))-#else-#define DUK_DBLUNION_SET_UINT64(u,v)  do { \-		(u)->ull[DUK_DBL_IDX_ULL0] = (duk_uint64_t) (v); \-	} while (0)-#define DUK_DBLUNION_GET_UINT64(u)  ((u)->ull[DUK_DBL_IDX_ULL0])-#endif-#define DUK_DBLUNION_SET_INT64(u,v) DUK_DBLUNION_SET_UINT64((u), (duk_uint64_t) (v))-#define DUK_DBLUNION_GET_INT64(u)   ((duk_int64_t) DUK_DBLUNION_GET_UINT64((u)))-#endif  /* DUK_USE_64BIT_OPS */--/*- *  Double NaN manipulation macros related to NaN normalization needed when- *  using the packed duk_tval representation.  NaN normalization is necessary- *  to keep double values compatible with the duk_tval format.- *- *  When packed duk_tval is used, the NaN space is used to store pointers- *  and other tagged values in addition to NaNs.  Actual NaNs are normalized- *  to a specific quiet NaN.  The macros below are used by the implementation- *  to check and normalize NaN values when they might be created.  The macros- *  are essentially NOPs when the non-packed duk_tval representation is used.- *- *  A FULL check is exact and checks all bits.  A NOTFULL check is used by- *  the packed duk_tval and works correctly for all NaNs except those that- *  begin with 0x7ff0.  Since the 'normalized NaN' values used with packed- *  duk_tval begin with 0x7ff8, the partial check is reliable when packed- *  duk_tval is used.  The 0x7ff8 prefix means the normalized NaN will be a- *  quiet NaN regardless of its remaining lower bits.- *- *  The ME variant below is specifically for ARM byte order, which has the- *  feature that while doubles have a mixed byte order (32107654), unsigned- *  long long values has a little endian byte order (76543210).  When writing- *  a logical double value through a ULL pointer, the 32-bit words need to be- *  swapped; hence the #if defined()s below for ULL writes with DUK_USE_DOUBLE_ME.- *  This is not full ARM support but suffices for some environments.- */--#if defined(DUK_USE_64BIT_OPS)-#if defined(DUK_USE_DOUBLE_ME)-/* Macros for 64-bit ops + mixed endian doubles. */-#define DUK__DBLUNION_SET_NAN_FULL(u)  do { \-		(u)->ull[DUK_DBL_IDX_ULL0] = 0x000000007ff80000ULL; \-	} while (0)-#define DUK__DBLUNION_IS_NAN_FULL(u) \-	((((u)->ull[DUK_DBL_IDX_ULL0] & 0x000000007ff00000ULL) == 0x000000007ff00000ULL) && \-	 ((((u)->ull[DUK_DBL_IDX_ULL0]) & 0xffffffff000fffffULL) != 0))-#define DUK__DBLUNION_IS_NORMALIZED_NAN_FULL(u) \-	((u)->ull[DUK_DBL_IDX_ULL0] == 0x000000007ff80000ULL)-#define DUK__DBLUNION_IS_ANYINF(u) \-	(((u)->ull[DUK_DBL_IDX_ULL0] & 0xffffffff7fffffffULL) == 0x000000007ff00000ULL)-#define DUK__DBLUNION_IS_POSINF(u) \-	((u)->ull[DUK_DBL_IDX_ULL0] == 0x000000007ff00000ULL)-#define DUK__DBLUNION_IS_NEGINF(u) \-	((u)->ull[DUK_DBL_IDX_ULL0] == 0x00000000fff00000ULL)-#define DUK__DBLUNION_IS_ANYZERO(u) \-	(((u)->ull[DUK_DBL_IDX_ULL0] & 0xffffffff7fffffffULL) == 0x0000000000000000ULL)-#define DUK__DBLUNION_IS_POSZERO(u) \-	((u)->ull[DUK_DBL_IDX_ULL0] == 0x0000000000000000ULL)-#define DUK__DBLUNION_IS_NEGZERO(u) \-	((u)->ull[DUK_DBL_IDX_ULL0] == 0x0000000080000000ULL)-#else-/* Macros for 64-bit ops + big/little endian doubles. */-#define DUK__DBLUNION_SET_NAN_FULL(u)  do { \-		(u)->ull[DUK_DBL_IDX_ULL0] = 0x7ff8000000000000ULL; \-	} while (0)-#define DUK__DBLUNION_IS_NAN_FULL(u) \-	((((u)->ull[DUK_DBL_IDX_ULL0] & 0x7ff0000000000000ULL) == 0x7ff0000000000000UL) && \-	 ((((u)->ull[DUK_DBL_IDX_ULL0]) & 0x000fffffffffffffULL) != 0))-#define DUK__DBLUNION_IS_NORMALIZED_NAN_FULL(u) \-	((u)->ull[DUK_DBL_IDX_ULL0] == 0x7ff8000000000000ULL)-#define DUK__DBLUNION_IS_ANYINF(u) \-	(((u)->ull[DUK_DBL_IDX_ULL0] & 0x7fffffffffffffffULL) == 0x7ff0000000000000ULL)-#define DUK__DBLUNION_IS_POSINF(u) \-	((u)->ull[DUK_DBL_IDX_ULL0] == 0x7ff0000000000000ULL)-#define DUK__DBLUNION_IS_NEGINF(u) \-	((u)->ull[DUK_DBL_IDX_ULL0] == 0xfff0000000000000ULL)-#define DUK__DBLUNION_IS_ANYZERO(u) \-	(((u)->ull[DUK_DBL_IDX_ULL0] & 0x7fffffffffffffffULL) == 0x0000000000000000ULL)-#define DUK__DBLUNION_IS_POSZERO(u) \-	((u)->ull[DUK_DBL_IDX_ULL0] == 0x0000000000000000ULL)-#define DUK__DBLUNION_IS_NEGZERO(u) \-	((u)->ull[DUK_DBL_IDX_ULL0] == 0x8000000000000000ULL)-#endif-#else  /* DUK_USE_64BIT_OPS */-/* Macros for no 64-bit ops, any endianness. */-#define DUK__DBLUNION_SET_NAN_FULL(u)  do { \-		(u)->ui[DUK_DBL_IDX_UI0] = (duk_uint32_t) 0x7ff80000UL; \-		(u)->ui[DUK_DBL_IDX_UI1] = (duk_uint32_t) 0x00000000UL; \-	} while (0)-#define DUK__DBLUNION_IS_NAN_FULL(u) \-	((((u)->ui[DUK_DBL_IDX_UI0] & 0x7ff00000UL) == 0x7ff00000UL) && \-	 (((u)->ui[DUK_DBL_IDX_UI0] & 0x000fffffUL) != 0 || \-          (u)->ui[DUK_DBL_IDX_UI1] != 0))-#define DUK__DBLUNION_IS_NORMALIZED_NAN_FULL(u) \-	(((u)->ui[DUK_DBL_IDX_UI0] == 0x7ff80000UL) && \-	 ((u)->ui[DUK_DBL_IDX_UI1] == 0x00000000UL))-#define DUK__DBLUNION_IS_ANYINF(u) \-	((((u)->ui[DUK_DBL_IDX_UI0] & 0x7fffffffUL) == 0x7ff00000UL) && \-	 ((u)->ui[DUK_DBL_IDX_UI1] == 0x00000000UL))-#define DUK__DBLUNION_IS_POSINF(u) \-	(((u)->ui[DUK_DBL_IDX_UI0] == 0x7ff00000UL) && \-	 ((u)->ui[DUK_DBL_IDX_UI1] == 0x00000000UL))-#define DUK__DBLUNION_IS_NEGINF(u) \-	(((u)->ui[DUK_DBL_IDX_UI0] == 0xfff00000UL) && \-	 ((u)->ui[DUK_DBL_IDX_UI1] == 0x00000000UL))-#define DUK__DBLUNION_IS_ANYZERO(u) \-	((((u)->ui[DUK_DBL_IDX_UI0] & 0x7fffffffUL) == 0x00000000UL) && \-	 ((u)->ui[DUK_DBL_IDX_UI1] == 0x00000000UL))-#define DUK__DBLUNION_IS_POSZERO(u) \-	(((u)->ui[DUK_DBL_IDX_UI0] == 0x00000000UL) && \-	 ((u)->ui[DUK_DBL_IDX_UI1] == 0x00000000UL))-#define DUK__DBLUNION_IS_NEGZERO(u) \-	(((u)->ui[DUK_DBL_IDX_UI0] == 0x80000000UL) && \-	 ((u)->ui[DUK_DBL_IDX_UI1] == 0x00000000UL))-#endif  /* DUK_USE_64BIT_OPS */--#define DUK__DBLUNION_SET_NAN_NOTFULL(u)  do { \-		(u)->us[DUK_DBL_IDX_US0] = 0x7ff8UL; \-	} while (0)--#define DUK__DBLUNION_IS_NAN_NOTFULL(u) \-	/* E == 0x7ff, topmost four bits of F != 0 => assume NaN */ \-	((((u)->us[DUK_DBL_IDX_US0] & 0x7ff0UL) == 0x7ff0UL) && \-	 (((u)->us[DUK_DBL_IDX_US0] & 0x000fUL) != 0x0000UL))--#define DUK__DBLUNION_IS_NORMALIZED_NAN_NOTFULL(u) \-	/* E == 0x7ff, F == 8 => normalized NaN */ \-	((u)->us[DUK_DBL_IDX_US0] == 0x7ff8UL)--#define DUK__DBLUNION_NORMALIZE_NAN_CHECK_FULL(u)  do { \-		if (DUK__DBLUNION_IS_NAN_FULL((u))) { \-			DUK__DBLUNION_SET_NAN_FULL((u)); \-		} \-	} while (0)--#define DUK__DBLUNION_NORMALIZE_NAN_CHECK_NOTFULL(u)  do { \-		if (DUK__DBLUNION_IS_NAN_NOTFULL((u))) { \-			DUK__DBLUNION_SET_NAN_NOTFULL((u)); \-		} \-	} while (0)--/* Concrete macros for NaN handling used by the implementation internals.- * Chosen so that they match the duk_tval representation: with a packed- * duk_tval, ensure NaNs are properly normalized; with a non-packed duk_tval- * these are essentially NOPs.- */--#if defined(DUK_USE_PACKED_TVAL)-#if defined(DUK_USE_FULL_TVAL)-#define DUK_DBLUNION_NORMALIZE_NAN_CHECK(u)  DUK__DBLUNION_NORMALIZE_NAN_CHECK_FULL((u))-#define DUK_DBLUNION_IS_NAN(u)               DUK__DBLUNION_IS_NAN_FULL((u))-#define DUK_DBLUNION_IS_NORMALIZED_NAN(u)    DUK__DBLUNION_IS_NORMALIZED_NAN_FULL((u))-#define DUK_DBLUNION_SET_NAN(d)              DUK__DBLUNION_SET_NAN_FULL((d))-#else-#define DUK_DBLUNION_NORMALIZE_NAN_CHECK(u)  DUK__DBLUNION_NORMALIZE_NAN_CHECK_NOTFULL((u))-#define DUK_DBLUNION_IS_NAN(u)               DUK__DBLUNION_IS_NAN_NOTFULL((u))-#define DUK_DBLUNION_IS_NORMALIZED_NAN(u)    DUK__DBLUNION_IS_NORMALIZED_NAN_NOTFULL((u))-#define DUK_DBLUNION_SET_NAN(d)              DUK__DBLUNION_SET_NAN_NOTFULL((d))-#endif-#define DUK_DBLUNION_IS_NORMALIZED(u) \-	(!DUK_DBLUNION_IS_NAN((u)) ||  /* either not a NaN */ \-	 DUK_DBLUNION_IS_NORMALIZED_NAN((u)))  /* or is a normalized NaN */-#else  /* DUK_USE_PACKED_TVAL */-#define DUK_DBLUNION_NORMALIZE_NAN_CHECK(u)  /* nop: no need to normalize */-#define DUK_DBLUNION_IS_NAN(u)               DUK__DBLUNION_IS_NAN_FULL((u))  /* (DUK_ISNAN((u)->d)) */-#define DUK_DBLUNION_IS_NORMALIZED_NAN(u)    DUK__DBLUNION_IS_NAN_FULL((u))  /* (DUK_ISNAN((u)->d)) */-#define DUK_DBLUNION_IS_NORMALIZED(u)        1  /* all doubles are considered normalized */-#define DUK_DBLUNION_SET_NAN(u)  do { \-		/* in non-packed representation we don't care about which NaN is used */ \-		(u)->d = DUK_DOUBLE_NAN; \-	} while (0)-#endif  /* DUK_USE_PACKED_TVAL */--#define DUK_DBLUNION_IS_ANYINF(u) DUK__DBLUNION_IS_ANYINF((u))-#define DUK_DBLUNION_IS_POSINF(u) DUK__DBLUNION_IS_POSINF((u))-#define DUK_DBLUNION_IS_NEGINF(u) DUK__DBLUNION_IS_NEGINF((u))--#define DUK_DBLUNION_IS_ANYZERO(u) DUK__DBLUNION_IS_ANYZERO((u))-#define DUK_DBLUNION_IS_POSZERO(u) DUK__DBLUNION_IS_POSZERO((u))-#define DUK_DBLUNION_IS_NEGZERO(u) DUK__DBLUNION_IS_NEGZERO((u))--/* XXX: native 64-bit byteswaps when available */--/* 64-bit byteswap, same operation independent of target endianness. */-#define DUK_DBLUNION_BSWAP64(u) do { \-		duk_uint32_t duk__bswaptmp1, duk__bswaptmp2; \-		duk__bswaptmp1 = (u)->ui[0]; \-		duk__bswaptmp2 = (u)->ui[1]; \-		duk__bswaptmp1 = DUK_BSWAP32(duk__bswaptmp1); \-		duk__bswaptmp2 = DUK_BSWAP32(duk__bswaptmp2); \-		(u)->ui[0] = duk__bswaptmp2; \-		(u)->ui[1] = duk__bswaptmp1; \-	} while (0)--/* Byteswap an IEEE double in the duk_double_union from host to network- * order.  For a big endian target this is a no-op.- */-#if defined(DUK_USE_DOUBLE_LE)-#define DUK_DBLUNION_DOUBLE_HTON(u) do { \-		duk_uint32_t duk__bswaptmp1, duk__bswaptmp2; \-		duk__bswaptmp1 = (u)->ui[0]; \-		duk__bswaptmp2 = (u)->ui[1]; \-		duk__bswaptmp1 = DUK_BSWAP32(duk__bswaptmp1); \-		duk__bswaptmp2 = DUK_BSWAP32(duk__bswaptmp2); \-		(u)->ui[0] = duk__bswaptmp2; \-		(u)->ui[1] = duk__bswaptmp1; \-	} while (0)-#elif defined(DUK_USE_DOUBLE_ME)-#define DUK_DBLUNION_DOUBLE_HTON(u) do { \-		duk_uint32_t duk__bswaptmp1, duk__bswaptmp2; \-		duk__bswaptmp1 = (u)->ui[0]; \-		duk__bswaptmp2 = (u)->ui[1]; \-		duk__bswaptmp1 = DUK_BSWAP32(duk__bswaptmp1); \-		duk__bswaptmp2 = DUK_BSWAP32(duk__bswaptmp2); \-		(u)->ui[0] = duk__bswaptmp1; \-		(u)->ui[1] = duk__bswaptmp2; \-	} while (0)-#elif defined(DUK_USE_DOUBLE_BE)-#define DUK_DBLUNION_DOUBLE_HTON(u) do { } while (0)-#else-#error internal error, double endianness insane-#endif--/* Reverse operation is the same. */-#define DUK_DBLUNION_DOUBLE_NTOH(u) DUK_DBLUNION_DOUBLE_HTON((u))--/* Some sign bit helpers. */-#if defined(DUK_USE_64BIT_OPS)-#define DUK_DBLUNION_HAS_SIGNBIT(u) (((u)->ull[DUK_DBL_IDX_ULL0] & 0x8000000000000000ULL) != 0)-#define DUK_DBLUNION_GET_SIGNBIT(u) (((u)->ull[DUK_DBL_IDX_ULL0] >> 63U))-#else-#define DUK_DBLUNION_HAS_SIGNBIT(u) (((u)->ui[DUK_DBL_IDX_UI0] & 0x80000000UL) != 0)-#define DUK_DBLUNION_GET_SIGNBIT(u) (((u)->ui[DUK_DBL_IDX_UI0] >> 31U))-#endif--#endif  /* DUK_DBLUNION_H_INCLUDED */--#endif  /* DUKTAPE_H_INCLUDED */
hs-duktape.cabal view
@@ -1,27 +1,34 @@ name:            hs-duktape-version:         0.1.5+version:         1.0.0 synopsis:        Haskell bindings for a very compact embedded ECMAScript (JavaScript) engine. category:        Web homepage:        https://github.com/myfreeweb/hs-duktape author:          Greg V-copyright:       2015-2017 Greg V <greg@unrelenting.technology> / 2013-2017 Duktape authors (for Duktape)+copyright:       2015-2019 Greg V <greg@unrelenting.technology> / 2013-2019 Duktape authors (for Duktape) maintainer:      greg@unrelenting.technology license:         MIT license-file:    LICENSE-build-type:      Simple+build-type:      Custom cabal-version:   >= 1.10 extra-source-files:     README.md-    duktape/src/duktape.c-    duktape/src/duktape.h-    duktape/src/duk_config.h+    dukconfig/dist/duktape.c+    dukconfig/dist/duktape.h+    dukconfig/dist/duk_config.h tested-with:-    GHC == 8.0.2+    GHC == 8.6.3  source-repository head     type: git     location: git://github.com/myfreeweb/hs-duktape.git +custom-setup+    setup-depends:+        base+      , Cabal+      , directory+      , process+ library     build-depends:         base >= 4.3.0.0 && < 5@@ -37,11 +44,11 @@         Scripting.Duktape.Raw     ghc-options: -Wall     hs-source-dirs: library-    include-dirs: duktape/src-    c-sources: duktape/src/duktape.c+    include-dirs: dukconfig/dist+    c-sources: dukconfig/dist/duktape.c     includes: duktape.h     install-includes: duktape.h-    cc-options: -Wall -Wno-discarded-qualifiers -std=c99 -fstrict-aliasing -fomit-frame-pointer+    cc-options: -Wno-discarded-qualifiers -std=c99 -fstrict-aliasing -fomit-frame-pointer  test-suite tests     build-depends:@@ -55,8 +62,9 @@       , raw-strings-qq       , template-haskell       , hs-duktape+      , time     default-language: Haskell2010-    ghc-options: -threaded -Wall -fhpc+    ghc-options: -threaded -Wall     hs-source-dirs: test-suite     main-is: Spec.hs     other-modules:
library/Scripting/Duktape.hs view
@@ -15,10 +15,11 @@ ) where  import           Foreign.Ptr-import           Foreign.ForeignPtr+import           Foreign.ForeignPtr hiding (addForeignPtrFinalizer) import           Foreign.Storable import           Foreign.C.String import           Foreign.C.Types+import           Foreign.Concurrent (addForeignPtrFinalizer) import           Foreign.Marshal.Alloc import           Control.Monad.IO.Class import           Control.Concurrent.MVar (withMVar)@@ -30,6 +31,7 @@ import qualified Data.Vector as V import qualified Data.HashMap.Strict as HMS import           Data.Aeson+import           Data.Aeson.Types import           Data.Maybe (fromMaybe) import           Scripting.Duktape.Raw @@ -138,56 +140,24 @@          else pop ctxPtr $ Left $ "Nonexistent property of global object: " ++ show (fromMaybe "" oname)  class Duktapeable ξ where-  runInDuktape ∷ ξ → Ptr DuktapeHeap → IO CInt+  runInDuktape ∷ Int → ξ → Ptr DuktapeHeap → IO CInt   argCount ∷ ξ → Int  instance Duktapeable (IO ()) where-  runInDuktape f _ = f >> return 0+  runInDuktape _ f _ = f >> return 0   argCount _ = 0 -instance Duktapeable (IO Value) where+instance (ToJSON v) => Duktapeable (IO v) where+  runInDuktape _ f ctxPtr = f >>= pushValue ctxPtr . toJSON >> return 1   argCount _ = 0-  runInDuktape f ctxPtr = f >>= pushValue ctxPtr >> return 1 -instance Duktapeable (Value → IO Value) where-  argCount _ = 1-  runInDuktape f ctxPtr = do-    a0 ← getValueFromStack ctxPtr 0-    f (fromMaybe Null a0) >>= pushValue ctxPtr >> return 1--instance Duktapeable (Value → Value → IO Value) where-  argCount _ = 2-  runInDuktape f ctxPtr = do-    a0 ← getValueFromStack ctxPtr 0-    a1 ← getValueFromStack ctxPtr 1-    f (fromMaybe Null a0) (fromMaybe Null a1) >>= pushValue ctxPtr >> return 1--instance Duktapeable (Value → Value → Value → IO Value) where-  argCount _ = 3-  runInDuktape f ctxPtr = do-    a0 ← getValueFromStack ctxPtr 0-    a1 ← getValueFromStack ctxPtr 1-    a2 ← getValueFromStack ctxPtr 2-    f (fromMaybe Null a0) (fromMaybe Null a1) (fromMaybe Null a2) >>= pushValue ctxPtr >> return 1--instance Duktapeable (Value → Value → Value → Value → IO Value) where-  argCount _ = 4-  runInDuktape f ctxPtr = do-    a0 ← getValueFromStack ctxPtr 0-    a1 ← getValueFromStack ctxPtr 1-    a2 ← getValueFromStack ctxPtr 2-    a3 ← getValueFromStack ctxPtr 3-    f (fromMaybe Null a0) (fromMaybe Null a1) (fromMaybe Null a2) (fromMaybe Null a3) >>= pushValue ctxPtr >> return 1--instance Duktapeable (Value → Value → Value → Value → Value → IO Value) where-  argCount _ = 5-  runInDuktape f ctxPtr = do-    a0 ← getValueFromStack ctxPtr 0-    a1 ← getValueFromStack ctxPtr 1-    a2 ← getValueFromStack ctxPtr 2-    a3 ← getValueFromStack ctxPtr 3-    a4 ← getValueFromStack ctxPtr 4-    f (fromMaybe Null a0) (fromMaybe Null a1) (fromMaybe Null a2) (fromMaybe Null a3) (fromMaybe Null a4) >>= pushValue ctxPtr >> return 1+instance (Duktapeable ξ, FromJSON v) => Duktapeable (v -> ξ) where+  argCount f = 1 + argCount (f undefined)+  runInDuktape stackIdx f ctxPtr = do+    stackVal <- fromMaybe Null <$> getValueFromStack ctxPtr stackIdx+    case parseEither parseJSON stackVal of+      Left err -> pushValue ctxPtr (toJSON err) >> return c_DUK_RET_TYPE_ERROR+      Right val -> runInDuktape (stackIdx + 1) (f val) ctxPtr  -- | Makes a Haskell function available in ECMAScript. exposeFnDuktape ∷ (MonadIO μ, Duktapeable ξ)@@ -197,12 +167,13 @@                 → ξ -- ^ The function itself                 → μ (Either String ()) exposeFnDuktape ctx oname fname f =-  liftIO $ withCtx ctx $ \ctxPtr →+  liftIO $ withMVar ctx $ \fPtr → withForeignPtr fPtr $ \ctxPtr →     BS.useAsCString fname $ \fnameCstr → do       oVal ← pushObjectOrGlobal ctxPtr oname       if oVal          then do-           wrapped ← c_wrapper $ runInDuktape f+           wrapped ← c_wrapper $ runInDuktape 0 f+           addForeignPtrFinalizer fPtr (freeHaskellFunPtr wrapped)            void $ c_duk_push_c_function ctxPtr wrapped $ fromIntegral $ argCount f            void $ c_duk_put_prop_string ctxPtr (-2) fnameCstr            pop ctxPtr $ Right ()
library/Scripting/Duktape/Raw.hs view
@@ -3,12 +3,15 @@  module Scripting.Duktape.Raw where +import           Foreign(peek, poke, malloc, free) import           Foreign.C.Types import           Foreign.C.String import           Foreign.Ptr-import           Foreign.ForeignPtr-import           Control.Concurrent.MVar (newMVar, MVar)+import           Foreign.ForeignPtr hiding (newForeignPtr, addForeignPtrFinalizer)+import           Foreign.Concurrent (newForeignPtr, addForeignPtrFinalizer)+import           Control.Concurrent.MVar (withMVar, newMVar, MVar) + foreign import capi "duktape.h value DUK_TYPE_NONE"      c_DUK_TYPE_NONE ∷ CInt foreign import capi "duktape.h value DUK_TYPE_UNDEFINED" c_DUK_TYPE_UNDEFINED ∷ CInt foreign import capi "duktape.h value DUK_TYPE_NULL"      c_DUK_TYPE_NULL ∷ CInt@@ -20,6 +23,9 @@ foreign import capi "duktape.h value DUK_TYPE_POINTER"   c_DUK_TYPE_POINTER ∷ CInt foreign import capi "duktape.h value DUK_TYPE_LIGHTFUNC" c_DUK_TYPE_LIGHTFUNC ∷ CInt +-- Duktape return vals+foreign import capi "duktape.h value DUK_RET_TYPE_ERROR" c_DUK_RET_TYPE_ERROR ∷ CInt+ data DuktapeHeap  type DuktapeCtx = MVar (ForeignPtr DuktapeHeap)@@ -29,16 +35,46 @@ type DukFreeFunction = Ptr () → Ptr () → IO () type DukFatalFunction = Ptr DuktapeHeap → CInt → CString → IO () +type DukExecTimeoutCheckFunction = Ptr () → IO (CUInt)+type TimeoutCheck = IO Bool+type TimeoutCheckWrapped = FunPtr (IO Bool)+type CheckActionUData =  Ptr TimeoutCheckWrapped++newtype InternalUData = InternalUData { getInternalUData ∷ Ptr () }++-- Static callback+foreign export ccall "hsduk_exec_timeout_check" execTimeoutCheck ∷ DukExecTimeoutCheckFunction++-- | Will always be invoked regularly by duktape runtime but returns false (do not timeout)+-- unless it receives a TimeoutCheck through udata+execTimeoutCheck ∷ DukExecTimeoutCheckFunction+execTimeoutCheck udata = if udata == nullPtr then return 0 else invoke+  where+    checkAction ∷ CheckActionUData+    checkAction = castPtr udata+    invoke = do+      action ← peek checkAction+      result ← unwrapTimeoutCheck action+      return $ if result then 1 else 0++-- FunPtr wrappers / unwrappers+ foreign import ccall safe "wrapper"   c_wrapper ∷ (Ptr DuktapeHeap → IO CInt) → IO (FunPtr (Ptr DuktapeHeap → IO CInt)) +foreign import ccall "dynamic"+  unwrapTimeoutCheck ∷ TimeoutCheckWrapped → IO Bool++foreign import ccall safe "wrapper"+  wrapTimeoutCheck ∷ (IO Bool) → IO TimeoutCheckWrapped+ -- Heap lifecycle  foreign import capi safe "duktape.h duk_create_heap"   c_duk_create_heap ∷ FunPtr DukAllocFunction → FunPtr DukReallocFunction → FunPtr DukFreeFunction → Ptr () → FunPtr DukFatalFunction → IO (Ptr DuktapeHeap) -foreign import capi safe "duktape.h &duk_destroy_heap"-  c_duk_destroy_heap ∷ FunPtr(Ptr DuktapeHeap → IO ())+foreign import capi safe "duktape.h duk_destroy_heap"+  c_duk_destroy_heap ∷ Ptr DuktapeHeap → IO ()  -- Evaluation @@ -140,12 +176,37 @@  ------------------------------------------------------------------------------------------------------- -createHeap ∷ FunPtr DukAllocFunction → FunPtr DukReallocFunction → FunPtr DukFreeFunction → Ptr () → FunPtr DukFatalFunction → IO (Maybe DuktapeCtx)+nullUData ∷ InternalUData+nullUData = InternalUData nullPtr++createHeap ∷ FunPtr DukAllocFunction → FunPtr DukReallocFunction → FunPtr DukFreeFunction → InternalUData → FunPtr DukFatalFunction → IO (Maybe DuktapeCtx) createHeap allocf reallocf freef udata fatalf = do-  ptr ← c_duk_create_heap allocf reallocf freef udata fatalf+  ptr ← c_duk_create_heap allocf reallocf freef (getInternalUData udata) fatalf   if ptr /= nullPtr-     then newForeignPtr c_duk_destroy_heap ptr >>= newMVar >>= return . Just+     then newForeignPtr ptr (c_duk_destroy_heap ptr) >>= newMVar >>= return . Just      else return Nothing  createHeapF ∷ FunPtr DukFatalFunction → IO (Maybe DuktapeCtx)-createHeapF = createHeap nullFunPtr nullFunPtr nullFunPtr nullPtr+createHeapF = createHeap nullFunPtr nullFunPtr nullFunPtr nullUData++-- | A TimeoutCheck is an IO action that returns True when the current script evaluation+-- should timeout (interpreter throws RangeError).+createGovernedHeap ∷ FunPtr DukAllocFunction → FunPtr DukReallocFunction → FunPtr DukFreeFunction → TimeoutCheck → FunPtr DukFatalFunction → IO (Maybe DuktapeCtx)+createGovernedHeap allocf reallocf freef timeoutCheck fatalf = do+  (udata, release) ← wrapTimeoutCheckUData timeoutCheck+  mctx ← createHeap allocf reallocf freef udata fatalf+  case mctx of+    Just ctx → withMVar ctx $ \fptr → do+      addForeignPtrFinalizer fptr release+      return mctx+    Nothing → return Nothing+  where+  -- TimeoutCheck is wrapped to pass as void* udata in `createHeap` and will be provided (by duktape)+  -- back to `execTimeoutCheck` when the interpreter invokes that callback.+  wrapTimeoutCheckUData ∷ TimeoutCheck → IO (InternalUData, IO ())+  wrapTimeoutCheckUData check = do+    wrapped ← wrapTimeoutCheck check+    ptr ← malloc+    poke ptr wrapped+    let finalizers = free ptr >> freeHaskellFunPtr wrapped+    return (InternalUData $ castPtr ptr, finalizers)
test-suite/Scripting/DuktapeSpec.hs view
@@ -7,7 +7,10 @@ import           TestCommon import           Data.Maybe import           Data.Aeson hiding (json)+import           Data.Time.Clock import           Scripting.Duktape+import           Scripting.Duktape.Raw (createGovernedHeap)+import           Foreign (nullFunPtr)  spec ∷ Spec spec = do@@ -39,7 +42,7 @@ function throwsErr () { throw new Error('hi') } |]       rE ← callDuktape (fromJust ctx) Nothing "n0thing!" []-      rE `shouldBe` (Left "TypeError: undefined not callable")+      rE `shouldBe` (Left "TypeError: undefined not callable (property 'n0thing!' of [object global])")       rO ← callDuktape (fromJust ctx) Nothing "returnsObj" []       rO `shouldBe` (Right $ Just [json|{"hello": {"from": [1, 2, 3]}}|])       rT ← callDuktape (fromJust ctx) Nothing "throwsErr" []@@ -81,14 +84,33 @@     it "exposes Haskell functions to ECMAScript" $ do       ctx ← createDuktapeCtx       _ ← evalDuktape (fromJust ctx) "var X = {}"-      let dbl (Number x) = return $ Number $ x * 2 ∷ IO Value-          dbl _ = return $ String "wtf"-          cnst = return $ Number 123 ∷ IO Value+      let dbl x = return $ Number $ x * 2 ∷ IO Value+          add x y = return $ x + y ∷ IO Integer+          cnst = return $ 123 ∷ IO Integer       _ ← exposeFnDuktape (fromJust ctx) Nothing "double" dbl       _ ← exposeFnDuktape (fromJust ctx) (Just "X") "cnst" cnst-      rd ← evalDuktape (fromJust ctx) "double(7) + X.cnst()"-      rd `shouldBe` (Right $ Just $ Number 137)+      _ ← exposeFnDuktape (fromJust ctx) (Just "X") "add" add+      rd ← evalDuktape (fromJust ctx) "double(7) + X.cnst() + X.add(3,5)"+      rd `shouldBe` (Right $ Just $ Number 145)       rD ← callDuktape (fromJust ctx) Nothing "double" [Number 7]       rD `shouldBe` (Right $ Just $ Number 14)       rE ← callDuktape (fromJust ctx) Nothing "double" []-      rE `shouldBe` (Right $ Just $ String "wtf")+      rE `shouldBe` (Left "TypeError: error (rc -6)")+      rF ← evalDuktape (fromJust ctx) "try { X.add(undefined, \"wtf\") } catch (e) { 0; }"+      rF `shouldBe` (Right $ Just $ Number 0)++  describe "createGovernedHeap" $ do+    it "applies CheckTimeout to signal the runtime to terminate with RangeError" $ do+      guvnor ← allowQuarterSecond+      ctx ← createGovernedHeap nullFunPtr nullFunPtr nullFunPtr guvnor nullFunPtr+      rE ← evalDuktape (fromJust ctx) "while(true) {};"+      rE `shouldBe` Left "RangeError: execution timeout"+++allowQuarterSecond ∷ IO (IO Bool)+allowQuarterSecond = do+  initializedAt ← getCurrentTime+  return $ do+    now ← getCurrentTime+    let diff = diffUTCTime now initializedAt+    return $ diff > 0.25