Merge pull request #19629 from karalabe/duktape-2.3.0

vendor: update go-duktape to v2.3.0
This commit is contained in:
Péter Szilágyi 2019-05-27 17:32:01 +03:00 committed by GitHub
commit f8a4e37968
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
17 changed files with 4248 additions and 2408 deletions

View File

@ -247,16 +247,16 @@ func (d *Context) CompileFile(flags uint, path string) {
} }
// See: http://duktape.org/api.html#duk_compile_lstring // See: http://duktape.org/api.html#duk_compile_lstring
func (d *Context) CompileLstring(flags uint, src string, len int) { func (d *Context) CompileLstring(flags uint, src string, lenght int) {
__src__ := C.CString(src) __src__ := C.CString(src)
C._duk_compile_lstring(d.duk_context, C.duk_uint_t(flags), __src__, C.duk_size_t(len)) C._duk_compile_lstring(d.duk_context, C.duk_uint_t(flags), __src__, C.duk_size_t(lenght))
C.free(unsafe.Pointer(__src__)) C.free(unsafe.Pointer(__src__))
} }
// See: http://duktape.org/api.html#duk_compile_lstring_filename // See: http://duktape.org/api.html#duk_compile_lstring_filename
func (d *Context) CompileLstringFilename(flags uint, src string, len int) { func (d *Context) CompileLstringFilename(flags uint, src string, lenght int) {
__src__ := C.CString(src) __src__ := C.CString(src)
C._duk_compile_lstring_filename(d.duk_context, C.duk_uint_t(flags), __src__, C.duk_size_t(len)) C._duk_compile_lstring_filename(d.duk_context, C.duk_uint_t(flags), __src__, C.duk_size_t(lenght))
C.free(unsafe.Pointer(__src__)) C.free(unsafe.Pointer(__src__))
} }
@ -395,16 +395,16 @@ func (d *Context) EvalFileNoresult(path string) {
} }
// See: http://duktape.org/api.html#duk_eval_lstring // See: http://duktape.org/api.html#duk_eval_lstring
func (d *Context) EvalLstring(src string, len int) { func (d *Context) EvalLstring(src string, lenght int) {
__src__ := C.CString(src) __src__ := C.CString(src)
C._duk_eval_lstring(d.duk_context, __src__, C.duk_size_t(len)) C._duk_eval_lstring(d.duk_context, __src__, C.duk_size_t(lenght))
C.free(unsafe.Pointer(__src__)) C.free(unsafe.Pointer(__src__))
} }
// See: http://duktape.org/api.html#duk_eval_lstring_noresult // See: http://duktape.org/api.html#duk_eval_lstring_noresult
func (d *Context) EvalLstringNoresult(src string, len int) { func (d *Context) EvalLstringNoresult(src string, lenght int) {
__src__ := C.CString(src) __src__ := C.CString(src)
C._duk_eval_lstring_noresult(d.duk_context, __src__, C.duk_size_t(len)) C._duk_eval_lstring_noresult(d.duk_context, __src__, C.duk_size_t(lenght))
C.free(unsafe.Pointer(__src__)) C.free(unsafe.Pointer(__src__))
} }
@ -801,17 +801,17 @@ func (d *Context) PcompileFile(flags uint, path string) error {
} }
// See: http://duktape.org/api.html#duk_pcompile_lstring // See: http://duktape.org/api.html#duk_pcompile_lstring
func (d *Context) PcompileLstring(flags uint, src string, len int) error { func (d *Context) PcompileLstring(flags uint, src string, lenght int) error {
__src__ := C.CString(src) __src__ := C.CString(src)
result := int(C._duk_pcompile_lstring(d.duk_context, C.duk_uint_t(flags), __src__, C.duk_size_t(len))) result := int(C._duk_pcompile_lstring(d.duk_context, C.duk_uint_t(flags), __src__, C.duk_size_t(lenght)))
C.free(unsafe.Pointer(__src__)) C.free(unsafe.Pointer(__src__))
return d.castStringToError(result) return d.castStringToError(result)
} }
// See: http://duktape.org/api.html#duk_pcompile_lstring_filename // See: http://duktape.org/api.html#duk_pcompile_lstring_filename
func (d *Context) PcompileLstringFilename(flags uint, src string, len int) error { func (d *Context) PcompileLstringFilename(flags uint, src string, lenght int) error {
__src__ := C.CString(src) __src__ := C.CString(src)
result := int(C._duk_pcompile_lstring_filename(d.duk_context, C.duk_uint_t(flags), __src__, C.duk_size_t(len))) result := int(C._duk_pcompile_lstring_filename(d.duk_context, C.duk_uint_t(flags), __src__, C.duk_size_t(lenght)))
C.free(unsafe.Pointer(__src__)) C.free(unsafe.Pointer(__src__))
return d.castStringToError(result) return d.castStringToError(result)
} }
@ -821,8 +821,7 @@ func (d *Context) PcompileString(flags uint, src string) error {
__src__ := C.CString(src) __src__ := C.CString(src)
result := int(C._duk_pcompile_string(d.duk_context, C.duk_uint_t(flags), __src__)) result := int(C._duk_pcompile_string(d.duk_context, C.duk_uint_t(flags), __src__))
C.free(unsafe.Pointer(__src__)) C.free(unsafe.Pointer(__src__))
fmt.Println("result herhehreh", result) return d.castStringToError(result)
return nil //d.castStringToError(result)
} }
// See: http://duktape.org/api.html#duk_pcompile_string_filename // See: http://duktape.org/api.html#duk_pcompile_string_filename
@ -856,18 +855,18 @@ func (d *Context) PevalFileNoresult(path string) int {
} }
// See: http://duktape.org/api.html#duk_peval_lstring // See: http://duktape.org/api.html#duk_peval_lstring
func (d *Context) PevalLstring(src string, len int) error { func (d *Context) PevalLstring(src string, lenght int) error {
__src__ := C.CString(src) __src__ := C.CString(src)
result := int(C._duk_peval_lstring(d.duk_context, __src__, C.duk_size_t(len))) result := int(C._duk_peval_lstring(d.duk_context, __src__, C.duk_size_t(lenght)))
C.free(unsafe.Pointer(__src__)) C.free(unsafe.Pointer(__src__))
return d.castStringToError(result) return d.castStringToError(result)
} }
// See: http://duktape.org/api.html#duk_peval_lstring_noresult // See: http://duktape.org/api.html#duk_peval_lstring_noresult
func (d *Context) PevalLstringNoresult(src string, len int) int { func (d *Context) PevalLstringNoresult(src string, lenght int) int {
__src__ := C.CString(src) __src__ := C.CString(src)
result := int(C._duk_peval_lstring_noresult(d.duk_context, __src__, C.duk_size_t(len))) result := int(C._duk_peval_lstring_noresult(d.duk_context, __src__, C.duk_size_t(lenght)))
C.free(unsafe.Pointer(__src__)) C.free(unsafe.Pointer(__src__))
return result return result
} }
@ -1040,10 +1039,10 @@ func (d *Context) PushInt(val int) {
} }
// See: http://duktape.org/api.html#duk_push_lstring // See: http://duktape.org/api.html#duk_push_lstring
func (d *Context) PushLstring(str string, len int) string { func (d *Context) PushLstring(str string, lenght int) string {
__str__ := C.CString(str) __str__ := C.CString(str)
var result string var result string
if s := C.duk_push_lstring(d.duk_context, __str__, C.duk_size_t(len)); s != nil { if s := C.duk_push_lstring(d.duk_context, __str__, C.duk_size_t(lenght)); s != nil {
result = C.GoString(s) result = C.GoString(s)
} }
C.free(unsafe.Pointer(__str__)) C.free(unsafe.Pointer(__str__))
@ -1590,6 +1589,16 @@ func (d *Context) PushExternalBuffer() {
C._duk_push_external_buffer(d.duk_context) C._duk_push_external_buffer(d.duk_context)
} }
// See: http://duktape.org/api.html#duk_config_buffer
func (d *Context) ConfigBuffer(bufferIdx int, buffer []byte) {
C.duk_config_buffer(
d.duk_context,
C.duk_idx_t(bufferIdx),
unsafe.Pointer(&buffer[0]),
C.duk_size_t(len(buffer)),
)
}
/** /**
* Unimplemented. * Unimplemented.
* *
@ -1608,7 +1617,6 @@ func (d *Context) PushExternalBuffer() {
* Realloc see: http://duktape.org/api.html#duk_realloc * Realloc see: http://duktape.org/api.html#duk_realloc
* ReallocRaw see: http://duktape.org/api.html#duk_realloc_raw * ReallocRaw see: http://duktape.org/api.html#duk_realloc_raw
* RequireCFunction see: http://duktape.org/api.html#duk_require_c_function * RequireCFunction see: http://duktape.org/api.html#duk_require_c_function
* ConfigBuffer see: http://duktape.org/api.html#duk_config_buffer
* GetBufferData see: http://duktape.org/api.html#duk_get_buffer_data * GetBufferData see: http://duktape.org/api.html#duk_get_buffer_data
* StealBuffer see: http://duktape.org/api.html#duk_steal_buffer * StealBuffer see: http://duktape.org/api.html#duk_steal_buffer
* RequireBufferData see: http://duktape.org/api.html#duk_require_buffer_data * RequireBufferData see: http://duktape.org/api.html#duk_require_buffer_data

View File

@ -1,72 +1,75 @@
package duktape package duktape
/*
#cgo !windows CFLAGS: -std=c99 -O3 -Wall -Wno-unused-value -fomit-frame-pointer -fstrict-aliasing
#cgo windows CFLAGS: -O3 -Wall -Wno-unused-value -fomit-frame-pointer -fstrict-aliasing
#include "duktape.h"
*/
import "C"
const ( const (
CompileEval uint = 1 << iota CompileEval uint = C.DUK_COMPILE_EVAL
CompileFunction CompileFunction uint = C.DUK_COMPILE_FUNCTION
CompileStrict CompileStrict uint = C.DUK_COMPILE_STRICT
CompileSafe CompileShebang uint = C.DUK_COMPILE_SHEBANG
CompileNoResult CompileSafe uint = C.DUK_COMPILE_SAFE
CompileNoSource CompileNoResult uint = C.DUK_COMPILE_NORESULT
CompileStrlen CompileNoSource uint = C.DUK_COMPILE_NOSOURCE
CompileStrlen uint = C.DUK_COMPILE_STRLEN
CompileNoFileName uint = C.DUK_COMPILE_NOFILENAME
CompileFuncExpr uint = C.DUK_COMPILE_FUNCEXPR
) )
const ( const (
TypeNone Type = iota TypeNone Type = C.DUK_TYPE_NONE
TypeUndefined TypeUndefined Type = C.DUK_TYPE_UNDEFINED
TypeNull TypeNull Type = C.DUK_TYPE_NULL
TypeBoolean TypeBoolean Type = C.DUK_TYPE_BOOLEAN
TypeNumber TypeNumber Type = C.DUK_TYPE_NUMBER
TypeString TypeString Type = C.DUK_TYPE_STRING
TypeObject TypeObject Type = C.DUK_TYPE_OBJECT
TypeBuffer TypeBuffer Type = C.DUK_TYPE_BUFFER
TypePointer TypePointer Type = C.DUK_TYPE_POINTER
TypeLightFunc TypeLightFunc Type = C.DUK_TYPE_LIGHTFUNC
) )
const ( const (
TypeMaskNone uint = 1 << iota TypeMaskNone uint = C.DUK_TYPE_MASK_NONE
TypeMaskUndefined TypeMaskUndefined uint = C.DUK_TYPE_MASK_UNDEFINED
TypeMaskNull TypeMaskNull uint = C.DUK_TYPE_MASK_NULL
TypeMaskBoolean TypeMaskBoolean uint = C.DUK_TYPE_MASK_BOOLEAN
TypeMaskNumber TypeMaskNumber uint = C.DUK_TYPE_MASK_NUMBER
TypeMaskString TypeMaskString uint = C.DUK_TYPE_MASK_STRING
TypeMaskObject TypeMaskObject uint = C.DUK_TYPE_MASK_OBJECT
TypeMaskBuffer TypeMaskBuffer uint = C.DUK_TYPE_MASK_BUFFER
TypeMaskPointer TypeMaskPointer uint = C.DUK_TYPE_MASK_POINTER
TypeMaskLightFunc TypeMaskLightFunc uint = C.DUK_TYPE_MASK_LIGHTFUNC
) )
const ( const (
EnumIncludeNonenumerable uint = 1 << iota EnumIncludeNonenumerable uint = C.DUK_ENUM_INCLUDE_NONENUMERABLE
EnumIncludeInternal EnumIncludeHidden uint = C.DUK_ENUM_INCLUDE_HIDDEN
EnumOwnPropertiesOnly EnumIncludeSymbols uint = C.DUK_ENUM_INCLUDE_SYMBOLS
EnumArrayIndicesOnly EnumExcludeStrings uint = C.DUK_ENUM_EXCLUDE_STRINGS
EnumSortArrayIndices EnumOwnPropertiesOnly uint = C.DUK_ENUM_OWN_PROPERTIES_ONLY
NoProxyBehavior EnumArrayIndicesOnly uint = C.DUK_ENUM_ARRAY_INDICES_ONLY
EnumSortArrayIndices uint = C.DUK_ENUM_SORT_ARRAY_INDICES
NoProxyBehavior uint = C.DUK_ENUM_NO_PROXY_BEHAVIOR
) )
const ( const (
ErrNone int = 0
// Internal to Duktape
ErrUnimplemented int = 50 + iota ErrUnimplemented int = 50 + iota
ErrUnsupported ErrUnsupported
ErrInternal
ErrAlloc
ErrAssertion
ErrAPI
ErrUncaughtError
)
const ( ErrNone int = C.DUK_ERR_NONE
// Common prototypes ErrError int = C.DUK_ERR_ERROR
ErrError int = 1 + iota ErrEval int = C.DUK_ERR_EVAL_ERROR
ErrEval ErrRange int = C.DUK_ERR_RANGE_ERROR
ErrRange ErrReference int = C.DUK_ERR_REFERENCE_ERROR
ErrReference ErrSyntax int = C.DUK_ERR_SYNTAX_ERROR
ErrSyntax ErrType int = C.DUK_ERR_TYPE_ERROR
ErrType ErrURI int = C.DUK_ERR_URI_ERROR
ErrURI
) )
const ( const (
@ -81,18 +84,18 @@ const (
) )
const ( const (
ErrRetError int = -(ErrError + iota) ErrRetError int = -(ErrError)
ErrRetEval ErrRetEval int = -(ErrEval)
ErrRetRange ErrRetRange int = -(ErrRange)
ErrRetReference ErrRetReference int = -(ErrReference)
ErrRetSyntax ErrRetSyntax int = -(ErrSyntax)
ErrRetType ErrRetType int = -(ErrType)
ErrRetURI ErrRetURI int = -(ErrURI)
) )
const ( const (
ExecSuccess = iota ExecSuccess int = C.DUK_EXEC_SUCCESS
ExecError ExecError int = C.DUK_EXEC_ERROR
) )
const ( const (
@ -105,17 +108,16 @@ const (
) )
const ( const (
BufobjDuktapeAuffer = 0 BufObjArrayBuffer int = C.DUK_BUFOBJ_ARRAYBUFFER
BufobjNodejsAuffer = 1 BufObjNodejsBuffer int = C.DUK_BUFOBJ_NODEJS_BUFFER
BufobjArraybuffer = 2 BufObjDataView int = C.DUK_BUFOBJ_DATAVIEW
BufobjDataview = 3 BufobjInt8Array int = C.DUK_BUFOBJ_INT8ARRAY
BufobjInt8array = 4 BufobjUint8Array int = C.DUK_BUFOBJ_UINT8ARRAY
BufobjUint8array = 5 BufobjUint8ClampedArray int = C.DUK_BUFOBJ_UINT8CLAMPEDARRAY
BufobjUint8clampedarray = 6 BufObjInt16Array int = C.DUK_BUFOBJ_INT16ARRAY
BufobjInt16array = 7 BufObjUint16Array int = C.DUK_BUFOBJ_UINT16ARRAY
BufobjUint16array = 8 BufObjInt32Array int = C.DUK_BUFOBJ_INT32ARRAY
BufobjInt32array = 9 BufObjUint32Array int = C.DUK_BUFOBJ_UINT32ARRAY
BufobjUint32array = 10 BufObjFloat32Array int = C.DUK_BUFOBJ_FLOAT32ARRAY
BufobjFloat32array = 11 BufObjFloat64Array int = C.DUK_BUFOBJ_FLOAT64ARRAY
BufobjFloat64array = 12
) )

View File

@ -3,6 +3,10 @@
#include "duktape.h" #include "duktape.h"
#if defined(__cplusplus)
extern "C" {
#endif
/* 32-bit (big endian) marker used at the end of pool entries so that wasted /* 32-bit (big endian) marker used at the end of pool entries so that wasted
* space can be detected. Waste tracking must be enabled explicitly. * space can be detected. Waste tracking must be enabled explicitly.
*/ */
@ -220,4 +224,8 @@ static DUK__ALLOC_POOL_ALWAYS_INLINE void *duk_alloc_pool_dec16(duk_uint16_t val
} }
#endif #endif
#if defined(__cplusplus)
}
#endif /* end 'extern "C"' wrapper */
#endif /* DUK_ALLOC_POOL_H_INCLUDED */ #endif /* DUK_ALLOC_POOL_H_INCLUDED */

View File

@ -1,8 +1,8 @@
/* /*
* duk_config.h configuration header generated by genconfig.py. * duk_config.h configuration header generated by genconfig.py.
* *
* Git commit: a459cf3c9bd1779fc01b435d69302b742675a08f * Git commit: d7fdb67f18561a50e06bafd196c6b423af9ad6fe
* Git describe: v2.2.0 * Git describe: v2.3.0
* Git branch: master * Git branch: master
* *
* Supported platforms: * Supported platforms:
@ -218,12 +218,6 @@
#define DUK_F_UNIX #define DUK_F_UNIX
#endif #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), /* 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. * define only one of DUK_F_X86, DUK_F_X64, DUK_F_X32.
* https://sites.google.com/site/x32abi/ * https://sites.google.com/site/x32abi/
@ -301,6 +295,12 @@
#define DUK_F_CLANG #define DUK_F_CLANG
#endif #endif
/* C++ */
#undef DUK_F_CPP
#if defined(__cplusplus)
#define DUK_F_CPP
#endif
/* C99 or above */ /* C99 or above */
#undef DUK_F_C99 #undef DUK_F_C99
#if defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L) #if defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L)
@ -836,9 +836,7 @@
#include <stdint.h> #include <stdint.h>
#endif #endif
#if defined(DUK_F_CPP) /* <exception> is only included if needed, based on DUK_USE_xxx flags. */
#include <exception> /* std::exception */
#endif
/* /*
* Architecture autodetection * Architecture autodetection
@ -850,13 +848,16 @@
#if !defined(DUK_USE_BYTEORDER) #if !defined(DUK_USE_BYTEORDER)
#define DUK_USE_BYTEORDER 1 #define DUK_USE_BYTEORDER 1
#endif #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_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 #define DUK_F_PACKED_TVAL_PROVIDED
#elif defined(DUK_F_X64) #elif defined(DUK_F_X64)
/* --- x64 --- */ /* --- x64 --- */
@ -864,12 +865,6 @@
#if !defined(DUK_USE_BYTEORDER) #if !defined(DUK_USE_BYTEORDER)
#define DUK_USE_BYTEORDER 1 #define DUK_USE_BYTEORDER 1
#endif #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 #undef DUK_USE_PACKED_TVAL
#define DUK_F_PACKED_TVAL_PROVIDED #define DUK_F_PACKED_TVAL_PROVIDED
#elif defined(DUK_F_X32) #elif defined(DUK_F_X32)
@ -878,48 +873,30 @@
#if !defined(DUK_USE_BYTEORDER) #if !defined(DUK_USE_BYTEORDER)
#define DUK_USE_BYTEORDER 1 #define DUK_USE_BYTEORDER 1
#endif #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_USE_PACKED_TVAL
#define DUK_F_PACKED_TVAL_PROVIDED #define DUK_F_PACKED_TVAL_PROVIDED
#elif defined(DUK_F_ARM32) #elif defined(DUK_F_ARM32)
/* --- ARM 32-bit --- */ /* --- ARM 32-bit --- */
#define DUK_USE_ARCH_STRING "arm32" #define DUK_USE_ARCH_STRING "arm32"
/* Byte order varies, so rely on autodetect. */ /* 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_USE_PACKED_TVAL
#define DUK_F_PACKED_TVAL_PROVIDED #define DUK_F_PACKED_TVAL_PROVIDED
#elif defined(DUK_F_ARM64) #elif defined(DUK_F_ARM64)
/* --- ARM 64-bit --- */ /* --- ARM 64-bit --- */
#define DUK_USE_ARCH_STRING "arm64" #define DUK_USE_ARCH_STRING "arm64"
/* Byte order varies, so rely on autodetect. */ /* 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 #undef DUK_USE_PACKED_TVAL
#define DUK_F_PACKED_TVAL_PROVIDED #define DUK_F_PACKED_TVAL_PROVIDED
#elif defined(DUK_F_MIPS32) #elif defined(DUK_F_MIPS32)
/* --- MIPS 32-bit --- */ /* --- MIPS 32-bit --- */
#define DUK_USE_ARCH_STRING "mips32" #define DUK_USE_ARCH_STRING "mips32"
/* MIPS byte order varies so rely on autodetection. */ /* MIPS 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_USE_PACKED_TVAL
#define DUK_F_PACKED_TVAL_PROVIDED #define DUK_F_PACKED_TVAL_PROVIDED
#elif defined(DUK_F_MIPS64) #elif defined(DUK_F_MIPS64)
/* --- MIPS 64-bit --- */ /* --- MIPS 64-bit --- */
#define DUK_USE_ARCH_STRING "mips64" #define DUK_USE_ARCH_STRING "mips64"
/* MIPS byte order varies so rely on autodetection. */ /* MIPS 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 #undef DUK_USE_PACKED_TVAL
#define DUK_F_PACKED_TVAL_PROVIDED #define DUK_F_PACKED_TVAL_PROVIDED
#elif defined(DUK_F_PPC32) #elif defined(DUK_F_PPC32)
@ -928,9 +905,6 @@
#if !defined(DUK_USE_BYTEORDER) #if !defined(DUK_USE_BYTEORDER)
#define DUK_USE_BYTEORDER 3 #define DUK_USE_BYTEORDER 3
#endif #endif
#if !defined(DUK_USE_ALIGN_BY)
#define DUK_USE_ALIGN_BY 8
#endif
#define DUK_USE_PACKED_TVAL #define DUK_USE_PACKED_TVAL
#define DUK_F_PACKED_TVAL_PROVIDED #define DUK_F_PACKED_TVAL_PROVIDED
#elif defined(DUK_F_PPC64) #elif defined(DUK_F_PPC64)
@ -939,39 +913,24 @@
#if !defined(DUK_USE_BYTEORDER) #if !defined(DUK_USE_BYTEORDER)
#define DUK_USE_BYTEORDER 3 #define DUK_USE_BYTEORDER 3
#endif #endif
#if !defined(DUK_USE_ALIGN_BY)
#define DUK_USE_ALIGN_BY 8
#endif
#undef DUK_USE_PACKED_TVAL #undef DUK_USE_PACKED_TVAL
#define DUK_F_PACKED_TVAL_PROVIDED #define DUK_F_PACKED_TVAL_PROVIDED
#elif defined(DUK_F_SPARC32) #elif defined(DUK_F_SPARC32)
/* --- SPARC 32-bit --- */ /* --- SPARC 32-bit --- */
#define DUK_USE_ARCH_STRING "sparc32" #define DUK_USE_ARCH_STRING "sparc32"
/* SPARC byte order varies so rely on autodetection. */ /* 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_USE_PACKED_TVAL
#define DUK_F_PACKED_TVAL_PROVIDED #define DUK_F_PACKED_TVAL_PROVIDED
#elif defined(DUK_F_SPARC64) #elif defined(DUK_F_SPARC64)
/* --- SPARC 64-bit --- */ /* --- SPARC 64-bit --- */
#define DUK_USE_ARCH_STRING "sparc64" #define DUK_USE_ARCH_STRING "sparc64"
/* SPARC byte order varies so rely on autodetection. */ /* 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 #undef DUK_USE_PACKED_TVAL
#define DUK_F_PACKED_TVAL_PROVIDED #define DUK_F_PACKED_TVAL_PROVIDED
#elif defined(DUK_F_SUPERH) #elif defined(DUK_F_SUPERH)
/* --- SuperH --- */ /* --- SuperH --- */
#define DUK_USE_ARCH_STRING "sh" #define DUK_USE_ARCH_STRING "sh"
/* Byte order varies, rely on autodetection. */ /* 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_USE_PACKED_TVAL
#define DUK_F_PACKED_TVAL_PROVIDED #define DUK_F_PACKED_TVAL_PROVIDED
#elif defined(DUK_F_M68K) #elif defined(DUK_F_M68K)
@ -980,9 +939,6 @@
#if !defined(DUK_USE_BYTEORDER) #if !defined(DUK_USE_BYTEORDER)
#define DUK_USE_BYTEORDER 3 #define DUK_USE_BYTEORDER 3
#endif #endif
#if !defined(DUK_USE_ALIGN_BY)
#define DUK_USE_ALIGN_BY 8
#endif
#define DUK_USE_PACKED_TVAL #define DUK_USE_PACKED_TVAL
#define DUK_F_PACKED_TVAL_PROVIDED #define DUK_F_PACKED_TVAL_PROVIDED
#elif defined(DUK_F_EMSCRIPTEN) #elif defined(DUK_F_EMSCRIPTEN)
@ -991,9 +947,6 @@
#if !defined(DUK_USE_BYTEORDER) #if !defined(DUK_USE_BYTEORDER)
#define DUK_USE_BYTEORDER 1 #define DUK_USE_BYTEORDER 1
#endif #endif
#if !defined(DUK_USE_ALIGN_BY)
#define DUK_USE_ALIGN_BY 8
#endif
#undef DUK_USE_PACKED_TVAL #undef DUK_USE_PACKED_TVAL
#define DUK_F_PACKED_TVAL_PROVIDED #define DUK_F_PACKED_TVAL_PROVIDED
#else #else
@ -2005,8 +1958,8 @@ typedef duk_uint_fast16_t duk_small_uint_fast_t;
/* Boolean values are represented with the platform 'unsigned int'. */ /* Boolean values are represented with the platform 'unsigned int'. */
typedef duk_small_uint_t duk_bool_t; typedef duk_small_uint_t duk_bool_t;
#define DUK_BOOL_MIN DUK_SMALL_INT_MIN #define DUK_BOOL_MIN DUK_SMALL_UINT_MIN
#define DUK_BOOL_MAX DUK_SMALL_INT_MAX #define DUK_BOOL_MAX DUK_SMALL_UINT_MAX
/* Index values must have at least 32-bit signed range. */ /* Index values must have at least 32-bit signed range. */
typedef duk_int_t duk_idx_t; typedef duk_int_t duk_idx_t;
@ -2540,10 +2493,13 @@ typedef struct duk_hthread duk_context;
* *
* Assume unaligned accesses are not supported unless specifically allowed * Assume unaligned accesses are not supported unless specifically allowed
* in the target platform. Some platforms may support unaligned accesses * in the target platform. Some platforms may support unaligned accesses
* but alignment to 4 or 8 may still be desirable. * 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 provided, use safe default for alignment. */ /* If not forced, use safe default for alignment. */
#if !defined(DUK_USE_ALIGN_BY) #if !defined(DUK_USE_ALIGN_BY)
#define DUK_USE_ALIGN_BY 8 #define DUK_USE_ALIGN_BY 8
#endif #endif
@ -2595,6 +2551,7 @@ typedef struct duk_hthread duk_context;
*/ */
#define DUK_CAUSE_SEGFAULT() do { *((volatile duk_uint32_t *) NULL) = (duk_uint32_t) 0xdeadbeefUL; } while (0) #define DUK_CAUSE_SEGFAULT() do { *((volatile duk_uint32_t *) NULL) = (duk_uint32_t) 0xdeadbeefUL; } while (0)
#endif #endif
#if !defined(DUK_UNREF) #if !defined(DUK_UNREF)
/* Macro for suppressing warnings for potentially unreferenced variables. /* Macro for suppressing warnings for potentially unreferenced variables.
* The variables can be actually unreferenced or unreferenced in some * The variables can be actually unreferenced or unreferenced in some
@ -2604,9 +2561,24 @@ typedef struct duk_hthread duk_context;
*/ */
#define DUK_UNREF(x) do { (void) (x); } while (0) #define DUK_UNREF(x) do { (void) (x); } while (0)
#endif #endif
#if !defined(DUK_NORETURN)
/* 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_NORETURN(decl) decl
#define DUK_WO_NORETURN(stmt) do { stmt } while (0)
#endif #endif
#if !defined(DUK_UNREACHABLE) #if !defined(DUK_UNREACHABLE)
/* Don't know how to declare unreachable point, so don't do it; this /* Don't know how to declare unreachable point, so don't do it; this
* may cause some spurious compilation warnings (e.g. "variable used * may cause some spurious compilation warnings (e.g. "variable used
@ -2614,6 +2586,7 @@ typedef struct duk_hthread duk_context;
*/ */
#define DUK_UNREACHABLE() do { } while (0) #define DUK_UNREACHABLE() do { } while (0)
#endif #endif
#if !defined(DUK_LOSE_CONST) #if !defined(DUK_LOSE_CONST)
/* Convert any input pointer into a "void *", losing a const qualifier. /* Convert any input pointer into a "void *", losing a const qualifier.
* This is not fully portable because casting through duk_uintptr_t may * This is not fully portable because casting through duk_uintptr_t may
@ -2781,8 +2754,8 @@ typedef struct duk_hthread duk_context;
#if defined(DUK_F_PACKED_TVAL_POSSIBLE) #if defined(DUK_F_PACKED_TVAL_POSSIBLE)
#define DUK_USE_PACKED_TVAL #define DUK_USE_PACKED_TVAL
#endif #endif
#undef DUK_F_PACKED_TVAL_POSSIBLE #undef DUK_F_PACKED_TVAL_POSSIBLE
#endif /* DUK_F_PACKED_TVAL_PROVIDED */ #endif /* DUK_F_PACKED_TVAL_PROVIDED */
/* Object property allocation layout has implications for memory and code /* Object property allocation layout has implications for memory and code
* footprint and generated code size/speed. The best layout also depends * footprint and generated code size/speed. The best layout also depends
@ -2817,6 +2790,7 @@ typedef struct duk_hthread duk_context;
* Autogenerated defaults * Autogenerated defaults
*/ */
#undef DUK_USE_ALLOW_UNDEFINED_BEHAVIOR
#define DUK_USE_ARRAY_BUILTIN #define DUK_USE_ARRAY_BUILTIN
#define DUK_USE_ARRAY_FASTPATH #define DUK_USE_ARRAY_FASTPATH
#define DUK_USE_ARRAY_PROP_FASTPATH #define DUK_USE_ARRAY_PROP_FASTPATH
@ -2825,6 +2799,7 @@ typedef struct duk_hthread duk_context;
#define DUK_USE_AUGMENT_ERROR_THROW #define DUK_USE_AUGMENT_ERROR_THROW
#define DUK_USE_AVOID_PLATFORM_FUNCPTRS #define DUK_USE_AVOID_PLATFORM_FUNCPTRS
#define DUK_USE_BASE64_FASTPATH #define DUK_USE_BASE64_FASTPATH
#define DUK_USE_BASE64_SUPPORT
#define DUK_USE_BOOLEAN_BUILTIN #define DUK_USE_BOOLEAN_BUILTIN
#define DUK_USE_BUFFEROBJECT_SUPPORT #define DUK_USE_BUFFEROBJECT_SUPPORT
#undef DUK_USE_BUFLEN16 #undef DUK_USE_BUFLEN16
@ -2902,6 +2877,7 @@ typedef struct duk_hthread duk_context;
#undef DUK_USE_HEAPPTR_DEC16 #undef DUK_USE_HEAPPTR_DEC16
#undef DUK_USE_HEAPPTR_ENC16 #undef DUK_USE_HEAPPTR_ENC16
#define DUK_USE_HEX_FASTPATH #define DUK_USE_HEX_FASTPATH
#define DUK_USE_HEX_SUPPORT
#define DUK_USE_HOBJECT_ARRAY_ABANDON_LIMIT 2 #define DUK_USE_HOBJECT_ARRAY_ABANDON_LIMIT 2
#define DUK_USE_HOBJECT_ARRAY_FAST_RESIZE_LIMIT 9 #define DUK_USE_HOBJECT_ARRAY_FAST_RESIZE_LIMIT 9
#define DUK_USE_HOBJECT_ARRAY_MINGROW_ADD 16 #define DUK_USE_HOBJECT_ARRAY_MINGROW_ADD 16
@ -2932,11 +2908,10 @@ typedef struct duk_hthread duk_context;
#define DUK_USE_JX #define DUK_USE_JX
#define DUK_USE_LEXER_SLIDING_WINDOW #define DUK_USE_LEXER_SLIDING_WINDOW
#undef DUK_USE_LIGHTFUNC_BUILTINS #undef DUK_USE_LIGHTFUNC_BUILTINS
#define DUK_USE_LITCACHE_SIZE 256
#define DUK_USE_MARK_AND_SWEEP_RECLIMIT 256 #define DUK_USE_MARK_AND_SWEEP_RECLIMIT 256
#define DUK_USE_MATH_BUILTIN #define DUK_USE_MATH_BUILTIN
#define DUK_USE_NATIVE_CALL_RECLIMIT 1000 #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 #define DUK_USE_NONSTD_ARRAY_SPLICE_DELCOUNT
#undef DUK_USE_NONSTD_FUNC_CALLER_PROPERTY #undef DUK_USE_NONSTD_FUNC_CALLER_PROPERTY
#undef DUK_USE_NONSTD_FUNC_SOURCE_PROPERTY #undef DUK_USE_NONSTD_FUNC_SOURCE_PROPERTY
@ -3011,6 +2986,15 @@ typedef struct duk_hthread duk_context;
/* __OVERRIDE_DEFINES__ */ /* __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 * Date provider selection
* *
@ -3552,6 +3536,12 @@ typedef struct duk_hthread duk_context;
#if defined(DUK_USE_MS_STRINGTABLE_RESIZE) #if defined(DUK_USE_MS_STRINGTABLE_RESIZE)
#error unsupported config option used (option has been removed): DUK_USE_MS_STRINGTABLE_RESIZE #error unsupported config option used (option has been removed): DUK_USE_MS_STRINGTABLE_RESIZE
#endif #endif
#if defined(DUK_USE_NONSTD_ARRAY_CONCAT_TRAILER)
#error unsupported config option used (option has been removed): DUK_USE_NONSTD_ARRAY_CONCAT_TRAILER
#endif
#if defined(DUK_USE_NONSTD_ARRAY_MAP_TRAILER)
#error unsupported config option used (option has been removed): DUK_USE_NONSTD_ARRAY_MAP_TRAILER
#endif
#if defined(DUK_USE_NONSTD_REGEXP_DOLLAR_ESCAPE) #if defined(DUK_USE_NONSTD_REGEXP_DOLLAR_ESCAPE)
#error unsupported config option used (option has been removed): DUK_USE_NONSTD_REGEXP_DOLLAR_ESCAPE #error unsupported config option used (option has been removed): DUK_USE_NONSTD_REGEXP_DOLLAR_ESCAPE
#endif #endif

View File

@ -13,10 +13,6 @@
/* XXX: Add some form of log level filtering. */ /* XXX: Add some form of log level filtering. */
/* XXX: For now logs everything to stdout, V8/Node.js logs debug/info level
* to stdout, warn and above to stderr. Should this extra do the same?
*/
/* XXX: Should all output be written via e.g. console.write(formattedMsg)? /* XXX: Should all output be written via e.g. console.write(formattedMsg)?
* This would make it easier for user code to redirect all console output * This would make it easier for user code to redirect all console output
* to a custom backend. * to a custom backend.
@ -25,12 +21,10 @@
/* XXX: Init console object using duk_def_prop() when that call is available. */ /* XXX: Init console object using duk_def_prop() when that call is available. */
static duk_ret_t duk__console_log_helper(duk_context *ctx, const char *error_name) { static duk_ret_t duk__console_log_helper(duk_context *ctx, const char *error_name) {
duk_idx_t i, n; duk_uint_t flags = (duk_uint_t) duk_get_current_magic(ctx);
duk_uint_t flags; FILE *output = (flags & DUK_CONSOLE_STDOUT_ONLY) ? stdout : stderr;
duk_idx_t n = duk_get_top(ctx);
flags = (duk_uint_t) duk_get_current_magic(ctx); duk_idx_t i;
n = duk_get_top(ctx);
duk_get_global_string(ctx, "console"); duk_get_global_string(ctx, "console");
duk_get_prop_string(ctx, -1, "format"); duk_get_prop_string(ctx, -1, "format");
@ -59,9 +53,9 @@ static duk_ret_t duk__console_log_helper(duk_context *ctx, const char *error_nam
duk_get_prop_string(ctx, -1, "stack"); duk_get_prop_string(ctx, -1, "stack");
} }
fprintf(stdout, "%s\n", duk_to_string(ctx, -1)); fprintf(output, "%s\n", duk_to_string(ctx, -1));
if (flags & DUK_CONSOLE_FLUSH) { if (flags & DUK_CONSOLE_FLUSH) {
fflush(stdout); fflush(output);
} }
return 0; return 0;
} }
@ -110,6 +104,17 @@ static void duk__console_reg_vararg_func(duk_context *ctx, duk_c_function func,
} }
void duk_console_init(duk_context *ctx, duk_uint_t flags) { void duk_console_init(duk_context *ctx, duk_uint_t flags) {
duk_uint_t flags_orig;
/* If both DUK_CONSOLE_STDOUT_ONLY and DUK_CONSOLE_STDERR_ONLY where specified,
* just turn off DUK_CONSOLE_STDOUT_ONLY and keep DUK_CONSOLE_STDERR_ONLY.
*/
if ((flags & DUK_CONSOLE_STDOUT_ONLY) && (flags & DUK_CONSOLE_STDERR_ONLY)) {
flags &= ~DUK_CONSOLE_STDOUT_ONLY;
}
/* Remember the (possibly corrected) flags we received. */
flags_orig = flags;
duk_push_object(ctx); duk_push_object(ctx);
/* Custom function to format objects; user can replace. /* Custom function to format objects; user can replace.
@ -128,11 +133,22 @@ void duk_console_init(duk_context *ctx, duk_uint_t flags) {
"})(Duktape.enc)"); "})(Duktape.enc)");
duk_put_prop_string(ctx, -2, "format"); duk_put_prop_string(ctx, -2, "format");
flags = flags_orig;
if (!(flags & DUK_CONSOLE_STDOUT_ONLY) && !(flags & DUK_CONSOLE_STDERR_ONLY)) {
/* No output indicators were specified; these levels go to stdout. */
flags |= DUK_CONSOLE_STDOUT_ONLY;
}
duk__console_reg_vararg_func(ctx, duk__console_assert, "assert", flags); duk__console_reg_vararg_func(ctx, duk__console_assert, "assert", flags);
duk__console_reg_vararg_func(ctx, duk__console_log, "log", flags); duk__console_reg_vararg_func(ctx, duk__console_log, "log", flags);
duk__console_reg_vararg_func(ctx, duk__console_log, "debug", flags); /* alias to console.log */ duk__console_reg_vararg_func(ctx, duk__console_log, "debug", flags); /* alias to console.log */
duk__console_reg_vararg_func(ctx, duk__console_trace, "trace", flags); duk__console_reg_vararg_func(ctx, duk__console_trace, "trace", flags);
duk__console_reg_vararg_func(ctx, duk__console_info, "info", flags); duk__console_reg_vararg_func(ctx, duk__console_info, "info", flags);
flags = flags_orig;
if (!(flags & DUK_CONSOLE_STDOUT_ONLY) && !(flags & DUK_CONSOLE_STDERR_ONLY)) {
/* No output indicators were specified; these levels go to stderr. */
flags |= DUK_CONSOLE_STDERR_ONLY;
}
duk__console_reg_vararg_func(ctx, duk__console_warn, "warn", flags); duk__console_reg_vararg_func(ctx, duk__console_warn, "warn", flags);
duk__console_reg_vararg_func(ctx, duk__console_error, "error", flags); duk__console_reg_vararg_func(ctx, duk__console_error, "error", flags);
duk__console_reg_vararg_func(ctx, duk__console_error, "exception", flags); /* alias to console.error */ duk__console_reg_vararg_func(ctx, duk__console_error, "exception", flags); /* alias to console.error */

View File

@ -3,12 +3,27 @@
#include "duktape.h" #include "duktape.h"
#if defined(__cplusplus)
extern "C" {
#endif
/* Use a proxy wrapper to make undefined methods (console.foo()) no-ops. */ /* Use a proxy wrapper to make undefined methods (console.foo()) no-ops. */
#define DUK_CONSOLE_PROXY_WRAPPER (1 << 0) #define DUK_CONSOLE_PROXY_WRAPPER (1U << 0)
/* Flush output after every call. */ /* Flush output after every call. */
#define DUK_CONSOLE_FLUSH (1 << 1) #define DUK_CONSOLE_FLUSH (1U << 1)
/* Send output to stdout only (default is mixed stdout/stderr). */
#define DUK_CONSOLE_STDOUT_ONLY (1U << 2)
/* Send output to stderr only (default is mixed stdout/stderr). */
#define DUK_CONSOLE_STDERR_ONLY (1U << 3)
/* Initialize the console system */
extern void duk_console_init(duk_context *ctx, duk_uint_t flags); extern void duk_console_init(duk_context *ctx, duk_uint_t flags);
#if defined(__cplusplus)
}
#endif /* end 'extern "C"' wrapper */
#endif /* DUK_CONSOLE_H_INCLUDED */ #endif /* DUK_CONSOLE_H_INCLUDED */

View File

@ -3,7 +3,11 @@
#include "duktape.h" #include "duktape.h"
/* Log levels */ #if defined(__cplusplus)
extern "C" {
#endif
/* Log levels. */
#define DUK_LOG_TRACE 0 #define DUK_LOG_TRACE 0
#define DUK_LOG_DEBUG 1 #define DUK_LOG_DEBUG 1
#define DUK_LOG_INFO 2 #define DUK_LOG_INFO 2
@ -17,4 +21,8 @@ extern void duk_logging_init(duk_context *ctx, duk_uint_t flags);
extern void duk_log_va(duk_context *ctx, duk_int_t level, const char *fmt, va_list ap); extern void duk_log_va(duk_context *ctx, duk_int_t level, const char *fmt, va_list ap);
extern void duk_log(duk_context *ctx, duk_int_t level, const char *fmt, ...); extern void duk_log(duk_context *ctx, duk_int_t level, const char *fmt, ...);
#if defined(__cplusplus)
}
#endif /* end 'extern "C"' wrapper */
#endif /* DUK_LOGGING_H_INCLUDED */ #endif /* DUK_LOGGING_H_INCLUDED */

View File

@ -4,9 +4,17 @@
#include <stdarg.h> /* va_list etc */ #include <stdarg.h> /* va_list etc */
#include <stddef.h> /* size_t */ #include <stddef.h> /* size_t */
#if defined(__cplusplus)
extern "C" {
#endif
extern int duk_minimal_sprintf(char *str, const char *format, ...); extern int duk_minimal_sprintf(char *str, const char *format, ...);
extern int duk_minimal_snprintf(char *str, size_t size, const char *format, ...); extern int duk_minimal_snprintf(char *str, size_t size, const char *format, ...);
extern int duk_minimal_vsnprintf(char *str, size_t size, const char *format, va_list ap); extern int duk_minimal_vsnprintf(char *str, size_t size, const char *format, va_list ap);
extern int duk_minimal_sscanf(const char *str, const char *format, ...); extern int duk_minimal_sscanf(const char *str, const char *format, ...);
#if defined(__cplusplus)
}
#endif /* end 'extern "C"' wrapper */
#endif /* DUK_MINIMAL_PRINTF_H_INCLUDED */ #endif /* DUK_MINIMAL_PRINTF_H_INCLUDED */

View File

@ -263,7 +263,7 @@ static duk_ret_t duk__require(duk_context *ctx) {
* done with Object.defineProperty(). * done with Object.defineProperty().
* *
* XXX: require.id could also be just made non-configurable, as there * XXX: require.id could also be just made non-configurable, as there
* is no practical reason to touch it (at least from Ecmascript code). * is no practical reason to touch it (at least from ECMAScript code).
*/ */
duk_push_c_function(ctx, duk__require, 1 /*nargs*/); duk_push_c_function(ctx, duk__require, 1 /*nargs*/);
duk_push_string(ctx, "name"); duk_push_string(ctx, "name");
@ -307,7 +307,7 @@ static duk_ret_t duk__require(duk_context *ctx) {
* Call user provided module search function and build the wrapped * Call user provided module search function and build the wrapped
* module source code (if necessary). The module search function * module source code (if necessary). The module search function
* can be used to implement pure Ecmacsript, pure C, and mixed * can be used to implement pure Ecmacsript, pure C, and mixed
* Ecmascript/C modules. * ECMAScript/C modules.
* *
* The module search function can operate on the exports table directly * The module search function can operate on the exports table directly
* (e.g. DLL code can register values to it). It can also return a * (e.g. DLL code can register values to it). It can also return a

View File

@ -3,6 +3,10 @@
#include "duktape.h" #include "duktape.h"
#if defined(__cplusplus)
extern "C" {
#endif
/* Maximum length of CommonJS module identifier to resolve. Length includes /* Maximum length of CommonJS module identifier to resolve. Length includes
* both current module ID, requested (possibly relative) module ID, and a * both current module ID, requested (possibly relative) module ID, and a
* slash in between. * slash in between.
@ -11,4 +15,8 @@
extern void duk_module_duktape_init(duk_context *ctx); extern void duk_module_duktape_init(duk_context *ctx);
#if defined(__cplusplus)
}
#endif /* end 'extern "C"' wrapper */
#endif /* DUK_MODULE_DUKTAPE_H_INCLUDED */ #endif /* DUK_MODULE_DUKTAPE_H_INCLUDED */

View File

@ -3,7 +3,15 @@
#include "duktape.h" #include "duktape.h"
#if defined(__cplusplus)
extern "C" {
#endif
extern duk_ret_t duk_module_node_peval_main(duk_context *ctx, const char *path); extern duk_ret_t duk_module_node_peval_main(duk_context *ctx, const char *path);
extern void duk_module_node_init(duk_context *ctx); extern void duk_module_node_init(duk_context *ctx);
#if defined(__cplusplus)
}
#endif /* end 'extern "C"' wrapper */
#endif /* DUK_MODULE_NODE_H_INCLUDED */ #endif /* DUK_MODULE_NODE_H_INCLUDED */

View File

@ -3,8 +3,16 @@
#include "duktape.h" #include "duktape.h"
#if defined(__cplusplus)
extern "C" {
#endif
/* No flags at the moment. */ /* No flags at the moment. */
extern void duk_print_alert_init(duk_context *ctx, duk_uint_t flags); extern void duk_print_alert_init(duk_context *ctx, duk_uint_t flags);
#if defined(__cplusplus)
}
#endif /* end 'extern "C"' wrapper */
#endif /* DUK_PRINT_ALERT_H_INCLUDED */ #endif /* DUK_PRINT_ALERT_H_INCLUDED */

View File

@ -3,6 +3,10 @@
#include "duktape.h" #include "duktape.h"
#if defined(__cplusplus)
extern "C" {
#endif
/* Straight flag rename */ /* Straight flag rename */
#if !defined(DUK_ENUM_INCLUDE_INTERNAL) #if !defined(DUK_ENUM_INCLUDE_INTERNAL)
#define DUK_ENUM_INCLUDE_INTERNAL DUK_ENUM_INCLUDE_HIDDEN #define DUK_ENUM_INCLUDE_INTERNAL DUK_ENUM_INCLUDE_HIDDEN
@ -25,4 +29,8 @@ extern void duk_to_defaultvalue(duk_context *ctx, duk_idx_t idx, duk_int_t hint)
#define duk_push_string_file(ctx,path) \ #define duk_push_string_file(ctx,path) \
duk_push_string_file_raw((ctx), (path), 0) duk_push_string_file_raw((ctx), (path), 0)
#if defined(__cplusplus)
}
#endif /* end 'extern "C"' wrapper */
#endif /* DUK_V1_COMPAT_INCLUDED */ #endif /* DUK_V1_COMPAT_INCLUDED */

File diff suppressed because it is too large Load Diff

View File

@ -199,7 +199,7 @@ func (e *Error) Error() string {
return fmt.Sprintf("%s: %s", e.Type, e.Message) return fmt.Sprintf("%s: %s", e.Type, e.Message)
} }
type Type int type Type uint
func (t Type) IsNone() bool { return t == TypeNone } func (t Type) IsNone() bool { return t == TypeNone }
func (t Type) IsUndefined() bool { return t == TypeUndefined } func (t Type) IsUndefined() bool { return t == TypeUndefined }

View File

@ -1,12 +1,12 @@
/* /*
* Duktape public API for Duktape 2.2.0. * Duktape public API for Duktape 2.3.0.
* *
* See the API reference for documentation on call semantics. The exposed, * See the API reference for documentation on call semantics. The exposed,
* supported API is between the "BEGIN PUBLIC API" and "END PUBLIC API" * supported API is between the "BEGIN PUBLIC API" and "END PUBLIC API"
* comments. Other parts of the header are Duktape internal and related to * comments. Other parts of the header are Duktape internal and related to
* e.g. platform/compiler/feature detection. * e.g. platform/compiler/feature detection.
* *
* Git commit a459cf3c9bd1779fc01b435d69302b742675a08f (v2.2.0). * Git commit d7fdb67f18561a50e06bafd196c6b423af9ad6fe (v2.3.0).
* Git branch master. * Git branch master.
* *
* See Duktape AUTHORS.rst and LICENSE.txt for copyright and * See Duktape AUTHORS.rst and LICENSE.txt for copyright and
@ -21,7 +21,7 @@
* *
* (http://opensource.org/licenses/MIT) * (http://opensource.org/licenses/MIT)
* *
* Copyright (c) 2013-2017 by Duktape authors (see AUTHORS.rst) * Copyright (c) 2013-2018 by Duktape authors (see AUTHORS.rst)
* *
* Permission is hereby granted, free of charge, to any person obtaining a copy * Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal * of this software and associated documentation files (the "Software"), to deal
@ -92,6 +92,14 @@
* * Steven Don (https://github.com/shdon) * * Steven Don (https://github.com/shdon)
* * Simon Stone (https://github.com/sstone1) * * Simon Stone (https://github.com/sstone1)
* * \J. McC. (https://github.com/jmhmccr) * * \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 * Other contributions
* =================== * ===================
@ -130,6 +138,8 @@
* * https://github.com/chris-y * * https://github.com/chris-y
* * Laurent Zubiaur (https://github.com/lzubiaur) * * Laurent Zubiaur (https://github.com/lzubiaur)
* * Neil Kolban (https://github.com/nkolban) * * 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 * If you are accidentally missing from this list, send me an e-mail
* (``sami.vaarala@iki.fi``) and I'll fix the omission. * (``sami.vaarala@iki.fi``) and I'll fix the omission.
@ -150,19 +160,19 @@
/* Duktape version, (major * 10000) + (minor * 100) + patch. Allows C code /* Duktape version, (major * 10000) + (minor * 100) + patch. Allows C code
* to #if (DUK_VERSION >= NNN) against Duktape API version. The same value * to #if (DUK_VERSION >= NNN) against Duktape API version. The same value
* is also available to Ecmascript code in Duktape.version. Unofficial * 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 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). * development version after 0.10.0 but before the next official release).
*/ */
#define DUK_VERSION 20200L #define DUK_VERSION 20300L
/* Git commit, describe, and branch for Duktape build. Useful for /* Git commit, describe, and branch for Duktape build. Useful for
* non-official snapshot builds so that application code can easily log * non-official snapshot builds so that application code can easily log
* which Duktape snapshot was used. Not available in the Ecmascript * which Duktape snapshot was used. Not available in the ECMAScript
* environment. * environment.
*/ */
#define DUK_GIT_COMMIT "a459cf3c9bd1779fc01b435d69302b742675a08f" #define DUK_GIT_COMMIT "d7fdb67f18561a50e06bafd196c6b423af9ad6fe"
#define DUK_GIT_DESCRIBE "v2.2.0" #define DUK_GIT_DESCRIBE "v2.3.0"
#define DUK_GIT_BRANCH "master" #define DUK_GIT_BRANCH "master"
/* External duk_config.h provides platform/compiler/OS dependent /* External duk_config.h provides platform/compiler/OS dependent
@ -258,7 +268,7 @@ struct duk_number_list_entry {
}; };
struct duk_time_components { struct duk_time_components {
duk_double_t year; /* year, e.g. 2016, Ecmascript year range */ duk_double_t year; /* year, e.g. 2016, ECMAScript year range */
duk_double_t month; /* month: 1-12 */ duk_double_t month; /* month: 1-12 */
duk_double_t day; /* day: 1-31 */ duk_double_t day; /* day: 1-31 */
duk_double_t hours; /* hour: 0-59 */ duk_double_t hours; /* hour: 0-59 */
@ -294,12 +304,12 @@ struct duk_time_components {
/* Value types, used by e.g. duk_get_type() */ /* Value types, used by e.g. duk_get_type() */
#define DUK_TYPE_MIN 0U #define DUK_TYPE_MIN 0U
#define DUK_TYPE_NONE 0U /* no value, e.g. invalid index */ #define DUK_TYPE_NONE 0U /* no value, e.g. invalid index */
#define DUK_TYPE_UNDEFINED 1U /* Ecmascript undefined */ #define DUK_TYPE_UNDEFINED 1U /* ECMAScript undefined */
#define DUK_TYPE_NULL 2U /* Ecmascript null */ #define DUK_TYPE_NULL 2U /* ECMAScript null */
#define DUK_TYPE_BOOLEAN 3U /* Ecmascript boolean: 0 or 1 */ #define DUK_TYPE_BOOLEAN 3U /* ECMAScript boolean: 0 or 1 */
#define DUK_TYPE_NUMBER 4U /* Ecmascript number: double */ #define DUK_TYPE_NUMBER 4U /* ECMAScript number: double */
#define DUK_TYPE_STRING 5U /* Ecmascript string: CESU-8 / extended UTF-8 encoded */ #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_OBJECT 6U /* ECMAScript object: includes objects, arrays, functions, threads */
#define DUK_TYPE_BUFFER 7U /* fixed or dynamic, garbage collected byte buffer */ #define DUK_TYPE_BUFFER 7U /* fixed or dynamic, garbage collected byte buffer */
#define DUK_TYPE_POINTER 8U /* raw void pointer */ #define DUK_TYPE_POINTER 8U /* raw void pointer */
#define DUK_TYPE_LIGHTFUNC 9U /* lightweight function pointer */ #define DUK_TYPE_LIGHTFUNC 9U /* lightweight function pointer */
@ -668,7 +678,21 @@ 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_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 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_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_function(duk_context *ctx);
DUK_EXTERNAL_DECL void duk_push_current_thread(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_global_object(duk_context *ctx);
@ -1000,29 +1024,55 @@ DUK_EXTERNAL_DECL void duk_config_buffer(duk_context *ctx, duk_idx_t idx, void *
/* /*
* Property access * Property access
* *
* The basic function assumes key is on stack. The _string variant takes * The basic function assumes key is on stack. The _(l)string variant takes
* a C string as a property name, while the _index variant takes an array * a C string as a property name; the _literal variant takes a C literal.
* index as a property name (e.g. 123 is equivalent to the key "123"). * 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(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_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_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_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_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(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_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_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_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_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(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_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_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_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_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(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_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_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_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 duk_bool_t duk_has_prop_heapptr(duk_context *ctx, duk_idx_t obj_idx, void *ptr);
@ -1031,8 +1081,22 @@ DUK_EXTERNAL_DECL void duk_def_prop(duk_context *ctx, duk_idx_t obj_idx, duk_uin
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_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_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_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); 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 * Inspection
@ -1099,7 +1163,7 @@ 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); DUK_EXTERNAL_DECL duk_codepoint_t duk_char_code_at(duk_context *ctx, duk_idx_t idx, duk_size_t char_offset);
/* /*
* Ecmascript operators * 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_equals(duk_context *ctx, duk_idx_t idx1, duk_idx_t idx2);
@ -1107,6 +1171,12 @@ DUK_EXTERNAL_DECL duk_bool_t duk_strict_equals(duk_context *ctx, duk_idx_t idx1,
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_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); 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 * Function (method) calls
*/ */
@ -1257,7 +1327,7 @@ DUK_EXTERNAL_DECL duk_double_t duk_components_to_time(duk_context *ctx, duk_time
#define DUK_DATE_MSEC_HOUR (60L * 60L * 1000L) #define DUK_DATE_MSEC_HOUR (60L * 60L * 1000L)
#define DUK_DATE_MSEC_DAY (24L * 60L * 60L * 1000L) #define DUK_DATE_MSEC_DAY (24L * 60L * 60L * 1000L)
/* Ecmascript date range is 100 million days from Epoch: /* ECMAScript date range is 100 million days from Epoch:
* > 100e6 * 24 * 60 * 60 * 1000 // 100M days in millisecs * > 100e6 * 24 * 60 * 60 * 1000 // 100M days in millisecs
* 8640000000000000 * 8640000000000000
* (= 8.64e15) * (= 8.64e15)
@ -1265,7 +1335,7 @@ DUK_EXTERNAL_DECL duk_double_t duk_components_to_time(duk_context *ctx, duk_time
#define DUK_DATE_MSEC_100M_DAYS (8.64e15) #define DUK_DATE_MSEC_100M_DAYS (8.64e15)
#define DUK_DATE_MSEC_100M_DAYS_LEEWAY (8.64e15 + 24 * 3600e3) #define DUK_DATE_MSEC_100M_DAYS_LEEWAY (8.64e15 + 24 * 3600e3)
/* Ecmascript year range: /* ECMAScript year range:
* > new Date(100e6 * 24 * 3600e3).toISOString() * > new Date(100e6 * 24 * 3600e3).toISOString()
* '+275760-09-13T00:00:00.000Z' * '+275760-09-13T00:00:00.000Z'
* > new Date(-100e6 * 24 * 3600e3).toISOString() * > new Date(-100e6 * 24 * 3600e3).toISOString()
@ -1275,7 +1345,7 @@ DUK_EXTERNAL_DECL duk_double_t duk_components_to_time(duk_context *ctx, duk_time
#define DUK_DATE_MAX_ECMA_YEAR 275760L #define DUK_DATE_MAX_ECMA_YEAR 275760L
/* Part indices for internal breakdowns. Part order from DUK_DATE_IDX_YEAR /* Part indices for internal breakdowns. Part order from DUK_DATE_IDX_YEAR
* to DUK_DATE_IDX_MILLISECOND matches argument ordering of Ecmascript API * to DUK_DATE_IDX_MILLISECOND matches argument ordering of ECMAScript API
* calls (like Date constructor call). Some functions in duk_bi_date.c * 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 * depend on the specific ordering, so change with care. 16 bits are not
* enough for all parts (year, specifically). * enough for all parts (year, specifically).

6
vendor/vendor.json vendored
View File

@ -941,10 +941,10 @@
"revisionTime": "2016-06-21T03:49:01Z" "revisionTime": "2016-06-21T03:49:01Z"
}, },
{ {
"checksumSHA1": "vndxs5Tv09/8S+Dr2PBAiM557lI=", "checksumSHA1": "h+m6mYCZIKnMQI24faKak5o19es=",
"path": "gopkg.in/olebedev/go-duktape.v3", "path": "gopkg.in/olebedev/go-duktape.v3",
"revision": "abf0ba0be5d5d36b1f9266463cc320b9a5ab224e", "revision": "ec84240a7772c7a122b1c58a13398210659f7c40",
"revisionTime": "2018-03-02T12:15:09Z" "revisionTime": "2019-02-13T23:42:57Z"
}, },
{ {
"checksumSHA1": "4BwmmgQUhWtizsR2soXND0nqZ1I=", "checksumSHA1": "4BwmmgQUhWtizsR2soXND0nqZ1I=",