Skip to content

Commit

Permalink
Merge pull request #56 from jessedoyle/duk-2.5.0
Browse files Browse the repository at this point in the history
v0.19.0 - Dukatpe 2.5.0
  • Loading branch information
jessedoyle committed Jan 18, 2020
2 parents 603d75d + 76f8110 commit f0e0420
Show file tree
Hide file tree
Showing 10 changed files with 3,418 additions and 1,318 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
@@ -1,3 +1,9 @@
# v0.19.0 - Jan 17, 2020

- Update Duktape version to `2.5.0`.
- See the [release notes](https://github.com/svaarala/duktape/blob/1fd2171840a88cc89e7a86b84d4d051940b1c654/doc/release-notes-v2-5.rst) for more info.
- Add bindings for the `pull` API function.

# v0.18.1 - Sept 24, 2019

- Update for Crystal v0.31.0 support.
Expand Down
2 changes: 1 addition & 1 deletion README.md
Expand Up @@ -18,7 +18,7 @@ version: 1.0.0 # your project's version
dependencies:
duktape:
github: jessedoyle/duktape.cr
version: ~> 0.18.1
version: ~> 0.19.0
```

then execute:
Expand Down
49 changes: 43 additions & 6 deletions ext/duk_config.h
@@ -1,8 +1,8 @@
/*
* duk_config.h configuration header generated by genconfig.py.
*
* Git commit: d4f2cff1c592d70f58bab8e1bd85705174c02a58
* Git describe: v2.4.0
* Git commit: 6001888049cb42656f8649db020e804bcdeca6a7
* Git describe: v2.5.0
* Git branch: HEAD
*
* Supported platforms:
Expand Down Expand Up @@ -40,6 +40,8 @@
* - PowerPC 64-bit
* - SPARC 32-bit
* - SPARC 64-bit
* - RISC-V 32-bit
* - RISC-V 64-bit
* - SuperH
* - Motorola 68k
* - Emscripten
Expand Down Expand Up @@ -285,6 +287,22 @@
#endif
#endif

/* RISC-V, https://github.com/riscv/riscv-toolchain-conventions#cc-preprocessor-definitions */
#if defined(__riscv)
#define DUK_F_RISCV
#if defined(__riscv_xlen)
#if (__riscv_xlen == 32)
#define DUK_F_RISCV32
#elif (__riscv_xlen == 64)
#define DUK_F_RISCV64
#else
#error __riscv_xlen has unsupported value (not 32 or 64)
#endif
#else
#error __riscv defined without __riscv_xlen
#endif
#endif /* __riscv */

/* SuperH */
#if defined(__sh__) || \
defined(__sh1__) || defined(__SH1__) || \
Expand Down Expand Up @@ -751,7 +769,7 @@
#define DUK_USE_BYTEORDER 3
#endif
#else /* DUK_F_OLD_SOLARIS */
#include <ast/endian.h>
#include <sys/param.h>
#endif /* DUK_F_OLD_SOLARIS */

#include <sys/param.h>
Expand Down Expand Up @@ -963,6 +981,18 @@
/* SPARC byte order varies so rely on autodetection. */
#undef DUK_USE_PACKED_TVAL
#define DUK_F_PACKED_TVAL_PROVIDED
#elif defined(DUK_F_RISCV32)
/* --- RISC-V 32-bit --- */
#define DUK_USE_ARCH_STRING "riscv32"
#define DUK_USE_BYTEORDER 1
#define DUK_USE_PACKED_TVAL
#define DUK_F_PACKED_TVAL_PROVIDED
#elif defined(DUK_F_RISCV64)
/* --- RISC-V 64-bit --- */
#define DUK_USE_ARCH_STRING "riscv64"
#define DUK_USE_BYTEORDER 1
#undef DUK_USE_PACKED_TVAL
#define DUK_F_PACKED_TVAL_PROVIDED
#elif defined(DUK_F_SUPERH)
/* --- SuperH --- */
#define DUK_USE_ARCH_STRING "sh"
Expand Down Expand Up @@ -1103,7 +1133,7 @@
#define DUK_USE_FLEX_ZEROSIZE
#endif

#undef DUK_USE_GCC_PRAGMAS
#define DUK_USE_CLANG_PRAGMAS
#define DUK_USE_PACK_CLANG_ATTR

#if defined(__clang__) && defined(__has_builtin)
Expand Down Expand Up @@ -1243,6 +1273,7 @@
#define DUK_USE_FLEX_ZEROSIZE
#endif

/* Since 4.6 one can '#pragma GCC diagnostic push/pop'. */
#if defined(DUK_F_GCC_VERSION) && (DUK_F_GCC_VERSION >= 40600)
#define DUK_USE_GCC_PRAGMAS
#else
Expand Down Expand Up @@ -2648,12 +2679,15 @@ typedef struct duk_hthread duk_context;
#define DUK_WO_NORETURN(stmt) do { stmt } while (0)
#endif

#if !defined(DUK_UNREACHABLE)
#if defined(DUK_UNREACHABLE)
#define DUK_WO_UNREACHABLE(stmt) do { } while (0)
#else
/* 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)
#define DUK_WO_UNREACHABLE(stmt) do { stmt } while (0)
#endif

#if !defined(DUK_LOSE_CONST)
Expand Down Expand Up @@ -2899,6 +2933,8 @@ typedef struct duk_hthread duk_context;
#define DUK_USE_CACHE_ACTIVATION
#define DUK_USE_CACHE_CATCHER
#define DUK_USE_CALLSTACK_LIMIT 10000
#define DUK_USE_CBOR_BUILTIN
#define DUK_USE_CBOR_SUPPORT
#define DUK_USE_COMPILER_RECLIMIT 2500
#define DUK_USE_COROUTINE_SUPPORT
#undef DUK_USE_CPP_EXCEPTIONS
Expand Down Expand Up @@ -2959,14 +2995,15 @@ typedef struct duk_hthread duk_context;
#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_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_ABANDON_MINSIZE 257
#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
Expand Down
4,626 changes: 3,324 additions & 1,302 deletions ext/duktape.c

Large diffs are not rendered by default.

19 changes: 14 additions & 5 deletions ext/duktape.h
@@ -1,12 +1,12 @@
/*
* Duktape public API for Duktape 2.4.0.
* Duktape public API for Duktape 2.5.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 d4f2cff1c592d70f58bab8e1bd85705174c02a58 (v2.4.0).
* Git commit 6001888049cb42656f8649db020e804bcdeca6a7 (v2.5.0).
* Git branch HEAD.
*
* See Duktape AUTHORS.rst and LICENSE.txt for copyright and
Expand Down Expand Up @@ -109,6 +109,7 @@
* * James Swift (https://github.com/phraemer)
* * Luis de Bethencourt (https://github.com/luisbg)
* * Ian Whyman (https://github.com/v00d00)
* * Rick Sayre (https://github.com/whorfin)
*
* Other contributions
* ===================
Expand Down Expand Up @@ -175,15 +176,15 @@
* 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 20400L
#define DUK_VERSION 20500L

/* 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 "d4f2cff1c592d70f58bab8e1bd85705174c02a58"
#define DUK_GIT_DESCRIBE "v2.4.0"
#define DUK_GIT_COMMIT "6001888049cb42656f8649db020e804bcdeca6a7"
#define DUK_GIT_DESCRIBE "v2.5.0"
#define DUK_GIT_BRANCH "HEAD"

/* External duk_config.h provides platform/compiler/OS dependent
Expand Down Expand Up @@ -394,30 +395,35 @@ struct duk_time_components {
#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_EC (DUK_DEFPROP_ENUMERABLE | 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_EC (DUK_DEFPROP_HAVE_ENUMERABLE | 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_EC (DUK_DEFPROP_SET_ENUMERABLE | 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_EC (DUK_DEFPROP_CLEAR_ENUMERABLE | 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_EC (DUK_DEFPROP_HAVE_WEC | DUK_DEFPROP_EC)
#define DUK_DEFPROP_ATTR_WEC (DUK_DEFPROP_HAVE_WEC | DUK_DEFPROP_WEC)

/* Flags for duk_push_thread_raw() */
Expand Down Expand Up @@ -661,6 +667,7 @@ 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_pull(duk_context *ctx, duk_idx_t from_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);
Expand Down Expand Up @@ -1032,6 +1039,8 @@ 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 void duk_cbor_encode(duk_context *ctx, duk_idx_t idx, duk_uint_t encode_flags);
DUK_EXTERNAL_DECL void duk_cbor_decode(duk_context *ctx, duk_idx_t idx, duk_uint_t decode_flags);

DUK_EXTERNAL_DECL const char *duk_buffer_to_string(duk_context *ctx, duk_idx_t idx);

Expand Down
2 changes: 1 addition & 1 deletion shard.yml
@@ -1,5 +1,5 @@
name: duktape
version: 0.18.1
version: 0.19.0

authors:
- Jesse Doyle <jdoyle@ualberta.ca>
Expand Down
20 changes: 20 additions & 0 deletions spec/duktape/api/stack_spec.cr
Expand Up @@ -223,6 +223,26 @@ describe Duktape::API::Stack do
end
end

describe "pull" do
it "should raise when the index is invalid" do
ctx = Duktape::Context.new

expect_raises Duktape::StackError, /invalid index/ do
ctx.pull -1
end
end

it "removes the value from the index and pushes to stack top" do
ctx = Duktape::Context.new
ctx << 0
ctx << 1
ctx << 2
ctx.pull(-3)

ctx.require_int(-1).should eq(0)
end
end

describe "remove" do
it "should remove the value at index" do
ctx = Duktape::Context.new
Expand Down
5 changes: 5 additions & 0 deletions src/duktape/api/stack.cr
Expand Up @@ -60,6 +60,11 @@ module Duktape
LibDUK.normalize_index ctx, index
end

def pull(from : LibDUK::Index)
require_valid_index from
LibDUK.pull ctx, from
end

def remove(index : LibDUK::Index)
require_valid_index index
LibDUK.remove ctx, index
Expand Down
6 changes: 3 additions & 3 deletions src/duktape/version.cr
Expand Up @@ -15,13 +15,13 @@ module Duktape

module VERSION
MAJOR = 0
MINOR = 18
TINY = 1
MINOR = 19
TINY = 0
PRE = nil

STRING = [MAJOR, MINOR, TINY, PRE].compact.join "."

# Internal Duktape Version
API = [2, 4, 0].join "."
API = [2, 5, 0].join "."
end
end
1 change: 1 addition & 0 deletions src/lib_duktape.cr
Expand Up @@ -249,6 +249,7 @@ lib LibDUK
fun dup = duk_dup(ctx : Context, from_index : Index)
fun dup_top = duk_dup_top(ctx : Context)
fun insert = duk_insert(ctx : Context, to_index : Index)
fun pull = duk_pull(ctx : Context, from_index : Index)
fun replace = duk_replace(ctx : Context, to_index : Index)
fun copy = duk_copy(ctx : Context, from_index : Index, to_index : Index)
fun remove = duk_remove(ctx : Context, index : Index)
Expand Down

0 comments on commit f0e0420

Please sign in to comment.