changeset 63:96ba0c5cf893

Misc: update duktape.hpp to new style
author David Demelier <markand@malikania.fr>
date Fri, 16 Dec 2016 16:11:24 +0100
parents a0081be977b5
children f8cb71805a4b
files client/main.cpp libclient-js/malikania/js_animation.cpp libclient-js/malikania/js_animator.cpp libclient-js/malikania/js_client_resources_loader.cpp libclient-js/malikania/js_color.cpp libclient-js/malikania/js_font.cpp libclient-js/malikania/js_image.cpp libclient-js/malikania/js_line.cpp libclient-js/malikania/js_point.cpp libclient-js/malikania/js_rectangle.cpp libclient-js/malikania/js_size.cpp libclient-js/malikania/js_sprite.cpp libclient-js/malikania/js_window.cpp libcommon-js/malikania/js_elapsed_timer.cpp libcommon-js/malikania/js_resources_loader.cpp libcommon/malikania/duktape.hpp tests/libclient/js-animation/main.cpp tests/libclient/js-color/main.cpp tests/libclient/js-font/main.cpp tests/libclient/js-image/main.cpp tests/libclient/js-line/main.cpp tests/libclient/js-point/main.cpp tests/libclient/js-rectangle/main.cpp tests/libclient/js-size/main.cpp tests/libclient/js-sprite/main.cpp tests/libclient/js-window/main.cpp tests/libcommon/js-elapsed-timer/main.cpp
diffstat 27 files changed, 192 insertions(+), 354 deletions(-) [+]
line wrap: on
line diff
--- a/client/main.cpp	Fri Dec 16 15:38:45 2016 +0100
+++ b/client/main.cpp	Fri Dec 16 16:11:24 2016 +0100
@@ -16,6 +16,8 @@
  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  */
 
+#include <malikania/duktape.hpp>
+
 #include <chrono>
 #include <thread>
 
--- a/libclient-js/malikania/js_animation.cpp	Fri Dec 16 15:38:45 2016 +0100
+++ b/libclient-js/malikania/js_animation.cpp	Fri Dec 16 16:11:24 2016 +0100
@@ -64,7 +64,7 @@
 {
     assert(ctx);
 
-    StackAssert sa(ctx);
+    dukx_stack_assert sa(ctx);
 
     duk_push_this(ctx);
     duk_push_pointer(ctx, new animation(std::move(anim)));
@@ -76,7 +76,7 @@
 {
     assert(ctx);
 
-    StackAssert sa(ctx);
+    dukx_stack_assert sa(ctx);
 
     duk_get_prop_string(ctx, index, signature.c_str());
     auto ptr = duk_to_pointer(ctx, -1);
@@ -93,7 +93,7 @@
 {
     assert(ctx);
 
-    StackAssert sa(ctx);
+    dukx_stack_assert sa(ctx);
 
     duk_get_global_string(ctx, "Malikania");
     duk_push_c_function(ctx, constructor, 1);
--- a/libclient-js/malikania/js_animator.cpp	Fri Dec 16 15:38:45 2016 +0100
+++ b/libclient-js/malikania/js_animator.cpp	Fri Dec 16 16:11:24 2016 +0100
@@ -32,7 +32,7 @@
 
 animator& self(duk_context* ctx)
 {
-    StackAssert sa(ctx);
+    dukx_stack_assert sa(ctx);
 
     duk_push_this(ctx);
     duk_get_prop_string(ctx, -1, signature.c_str());
@@ -106,7 +106,7 @@
 {
     assert(ctx);
 
-    StackAssert sa(ctx);
+    dukx_stack_assert sa(ctx);
 
     duk_push_this(ctx);
     duk_push_pointer(ctx, new animator);
@@ -120,7 +120,7 @@
 {
     assert(ctx);
 
-    StackAssert sa(ctx);
+    dukx_stack_assert sa(ctx);
 
     duk_get_prop_string(ctx, index, signature.c_str());
     auto ptr = duk_to_pointer(ctx, -1);
@@ -137,7 +137,7 @@
 {
     assert(ctx);
 
-    StackAssert sa(ctx);
+    dukx_stack_assert sa(ctx);
 
     duk_get_global_string(ctx, "Malikania");
     duk_push_c_function(ctx, constructor, 1);
--- a/libclient-js/malikania/js_client_resources_loader.cpp	Fri Dec 16 15:38:45 2016 +0100
+++ b/libclient-js/malikania/js_client_resources_loader.cpp	Fri Dec 16 16:11:24 2016 +0100
@@ -36,7 +36,7 @@
     // Also store as parent.
     dukx_put_loader(ctx, loader);
 
-    StackAssert sa(ctx);
+    dukx_stack_assert sa(ctx);
 
     duk_push_pointer(ctx, &loader);
     duk_put_global_string(ctx, variable.c_str());
@@ -46,7 +46,7 @@
 {
     assert(ctx);
 
-    StackAssert sa(ctx);
+    dukx_stack_assert sa(ctx);
 
     duk_get_global_string(ctx, variable.c_str());
     auto ptr = static_cast<client_resources_loader*>(duk_to_pointer(ctx, -1));
--- a/libclient-js/malikania/js_color.cpp	Fri Dec 16 15:38:45 2016 +0100
+++ b/libclient-js/malikania/js_color.cpp	Fri Dec 16 16:11:24 2016 +0100
@@ -161,7 +161,7 @@
 
 void dukx_push_color(duk_context* ctx, const color& color)
 {
-    StackAssert sa(ctx, 1);
+    dukx_stack_assert sa(ctx, 1);
 
     duk_push_object(ctx);
     dukx_put_color(ctx, color);
@@ -171,7 +171,7 @@
 {
     assert(duk_is_object(ctx, -1));
 
-    StackAssert sa(ctx, 0);
+    dukx_stack_assert sa(ctx, 0);
 
     duk_push_uint(ctx, color.red());
     duk_put_prop_string(ctx, -2, "red");
@@ -185,7 +185,7 @@
 
 void dukx_load_color(duk_context* ctx)
 {
-    StackAssert sa(ctx, 0);
+    dukx_stack_assert sa(ctx, 0);
 
     duk_get_global_string(ctx, "Malikania");
     duk_push_c_function(ctx, constructor, DUK_VARARGS);
--- a/libclient-js/malikania/js_font.cpp	Fri Dec 16 15:38:45 2016 +0100
+++ b/libclient-js/malikania/js_font.cpp	Fri Dec 16 16:11:24 2016 +0100
@@ -30,7 +30,7 @@
 
 font& self(duk_context* ctx)
 {
-    StackAssert sa(ctx);
+    dukx_stack_assert sa(ctx);
 
     duk_push_this(ctx);
     duk_get_prop_string(ctx, -1, signature.c_str());
@@ -46,7 +46,7 @@
 
 duk_ret_t constructor(duk_context* ctx)
 {
-    StackAssert sa(ctx);
+    dukx_stack_assert sa(ctx);
 
     if (!duk_is_constructor_call(ctx)) {
         duk_error(ctx, DUK_ERR_ERROR, "font must be new-constructed");
@@ -97,7 +97,7 @@
     assert(ctx);
     assert(font);
 
-    StackAssert sa(ctx);
+    dukx_stack_assert sa(ctx);
 
     duk_push_this(ctx);
     duk_push_pointer(ctx, font);
@@ -111,7 +111,7 @@
 {
     assert(ctx);
 
-    StackAssert sa(ctx);
+    dukx_stack_assert sa(ctx);
 
     duk_get_prop_string(ctx, index, signature.c_str());
     auto ptr = duk_to_pointer(ctx, -1);
@@ -126,7 +126,7 @@
 
 void dukx_load_font(duk_context* ctx)
 {
-    StackAssert sa(ctx);
+    dukx_stack_assert sa(ctx);
 
     duk_get_global_string(ctx, "Malikania");
     duk_push_c_function(ctx, constructor, 2);
--- a/libclient-js/malikania/js_image.cpp	Fri Dec 16 15:38:45 2016 +0100
+++ b/libclient-js/malikania/js_image.cpp	Fri Dec 16 16:11:24 2016 +0100
@@ -31,7 +31,7 @@
 
 image& self(duk_context* ctx)
 {
-    StackAssert sa(ctx);
+    dukx_stack_assert sa(ctx);
 
     duk_push_this(ctx);
     duk_get_prop_string(ctx, -1, signature.c_str());
@@ -111,7 +111,7 @@
     assert(ctx);
     assert(image);
 
-    StackAssert sa(ctx);
+    dukx_stack_assert sa(ctx);
 
     duk_push_this(ctx);
     duk_push_pointer(ctx, image);
@@ -121,7 +121,7 @@
 
 void dukx_load_image(duk_context* ctx)
 {
-    StackAssert sa(ctx);
+    dukx_stack_assert sa(ctx);
 
     duk_get_global_string(ctx, "Malikania");
     duk_push_c_function(ctx, constructor, 1);
--- a/libclient-js/malikania/js_line.cpp	Fri Dec 16 15:38:45 2016 +0100
+++ b/libclient-js/malikania/js_line.cpp	Fri Dec 16 16:11:24 2016 +0100
@@ -59,7 +59,7 @@
 line dukx_get_line(duk_context* ctx, duk_idx_t index)
 {
     auto get = [&] (auto name) {
-        StackAssert sa(ctx);
+        dukx_stack_assert sa(ctx);
 
         duk_get_prop_string(ctx, index, name);
         auto v = duk_get_int(ctx, -1);
@@ -101,7 +101,7 @@
 
 void dukx_push_line(duk_context* ctx, const line& line)
 {
-    StackAssert sa(ctx, 1);
+    dukx_stack_assert sa(ctx, 1);
 
     duk_push_object(ctx);
     dukx_put_line(ctx, line);
@@ -111,7 +111,7 @@
 {
     assert(duk_is_object(ctx, -1));
 
-    StackAssert sa(ctx);
+    dukx_stack_assert sa(ctx);
 
     duk_push_int(ctx, line.x1());
     duk_put_prop_string(ctx, -2, "x1");
@@ -125,7 +125,7 @@
 
 void dukx_load_line(duk_context* ctx)
 {
-    StackAssert sa(ctx, 0);
+    dukx_stack_assert sa(ctx, 0);
 
     duk_get_global_string(ctx, "Malikania");
     duk_push_c_function(ctx, constructor, DUK_VARARGS);
--- a/libclient-js/malikania/js_point.cpp	Fri Dec 16 15:38:45 2016 +0100
+++ b/libclient-js/malikania/js_point.cpp	Fri Dec 16 16:11:24 2016 +0100
@@ -26,7 +26,7 @@
 
 point parse(duk_context* ctx, duk_idx_t index, bool required, point ret = {})
 {
-    StackAssert sa(ctx);
+    dukx_stack_assert sa(ctx);
 
     if (duk_is_object(ctx, index)) {
         if (required && !duk_has_prop_string(ctx, index, "x")) {
@@ -99,7 +99,7 @@
 
 void dukx_push_point(duk_context* ctx, const point &point)
 {
-    StackAssert sa(ctx, 1);
+    dukx_stack_assert sa(ctx, 1);
 
     duk_push_object(ctx);
     dukx_put_point(ctx, point);
@@ -109,7 +109,7 @@
 {
     assert(duk_is_object(ctx, -1));
 
-    StackAssert sa(ctx);
+    dukx_stack_assert sa(ctx);
 
     duk_push_int(ctx, point.x());
     duk_put_prop_string(ctx, -2, "x");
@@ -119,7 +119,7 @@
 
 void dukx_load_point(duk_context* ctx)
 {
-    StackAssert sa(ctx, 0);
+    dukx_stack_assert sa(ctx, 0);
 
     duk_get_global_string(ctx, "Malikania");
     duk_push_c_function(ctx, constructor, DUK_VARARGS);
--- a/libclient-js/malikania/js_rectangle.cpp	Fri Dec 16 15:38:45 2016 +0100
+++ b/libclient-js/malikania/js_rectangle.cpp	Fri Dec 16 16:11:24 2016 +0100
@@ -38,7 +38,7 @@
 
 rectangle parse(duk_context* ctx, duk_idx_t index, bool required, rectangle rect = {})
 {
-    StackAssert sa(ctx);
+    dukx_stack_assert sa(ctx);
 
     if (duk_is_object(ctx, index)) {
         auto get = [&] (auto prop) {
@@ -116,7 +116,7 @@
 
 void dukx_push_rect(duk_context* ctx, const rectangle& rect)
 {
-    StackAssert sa(ctx, 1);
+    dukx_stack_assert sa(ctx, 1);
 
     duk_push_object(ctx);
     dukx_put_rect(ctx, rect);
@@ -126,7 +126,7 @@
 {
     assert(duk_is_object(ctx, -1));
 
-    StackAssert sa(ctx);
+    dukx_stack_assert sa(ctx);
 
     duk_push_int(ctx, rect.x());
     duk_put_prop_string(ctx, -2, "x");
@@ -140,7 +140,7 @@
 
 void dukx_load_rect(duk_context* ctx)
 {
-    StackAssert sa(ctx, 0);
+    dukx_stack_assert sa(ctx, 0);
 
     duk_get_global_string(ctx, "Malikania");
     duk_push_c_function(ctx, constructor, DUK_VARARGS);
--- a/libclient-js/malikania/js_size.cpp	Fri Dec 16 15:38:45 2016 +0100
+++ b/libclient-js/malikania/js_size.cpp	Fri Dec 16 16:11:24 2016 +0100
@@ -26,7 +26,7 @@
 
 size parse(duk_context* ctx, duk_idx_t index, bool required, size ret = {})
 {
-    StackAssert sa(ctx);
+    dukx_stack_assert sa(ctx);
 
     if (duk_is_object(ctx, index)) {
         if (required && !duk_has_prop_string(ctx, index, "width")) {
@@ -115,7 +115,7 @@
 
 void dukx_push_size(duk_context* ctx, const size& size)
 {
-    StackAssert sa(ctx, 1);
+    dukx_stack_assert sa(ctx, 1);
 
     duk_push_object(ctx);
     dukx_put_size(ctx, size);
@@ -125,7 +125,7 @@
 {
     assert(duk_is_object(ctx, -1));
 
-    StackAssert sa(ctx, 0);
+    dukx_stack_assert sa(ctx, 0);
 
     duk_push_uint(ctx, size.width());
     duk_put_prop_string(ctx, -2, "width");
@@ -135,7 +135,7 @@
 
 void dukx_load_size(duk_context* ctx)
 {
-    StackAssert sa(ctx, 0);
+    dukx_stack_assert sa(ctx, 0);
 
     duk_get_global_string(ctx, "Malikania");
     duk_push_c_function(ctx, constructor, DUK_VARARGS);
--- a/libclient-js/malikania/js_sprite.cpp	Fri Dec 16 15:38:45 2016 +0100
+++ b/libclient-js/malikania/js_sprite.cpp	Fri Dec 16 16:11:24 2016 +0100
@@ -30,7 +30,7 @@
 
 sprite& self(duk_context *ctx)
 {
-    StackAssert sa(ctx);
+    dukx_stack_assert sa(ctx);
 
     duk_push_this(ctx);
     duk_get_prop_string(ctx, -1, signature.c_str());
@@ -155,7 +155,7 @@
 
 void dukx_load_sprite(duk_context *ctx)
 {
-    StackAssert sa(ctx);
+    dukx_stack_assert sa(ctx);
 
     duk_get_global_string(ctx, "Malikania");
     duk_push_c_function(ctx, constructor, 1);
--- a/libclient-js/malikania/js_window.cpp	Fri Dec 16 15:38:45 2016 +0100
+++ b/libclient-js/malikania/js_window.cpp	Fri Dec 16 16:11:24 2016 +0100
@@ -34,7 +34,7 @@
 
 window& self(duk_context* ctx)
 {
-    StackAssert sa(ctx);
+    dukx_stack_assert sa(ctx);
 
     duk_push_this(ctx);
     duk_get_prop_string(ctx, -1, signature.c_str());
@@ -50,7 +50,7 @@
 
 duk_ret_t constructor(duk_context* ctx)
 {
-    StackAssert sa(ctx);
+    dukx_stack_assert sa(ctx);
 
     if (!duk_is_constructor_call(ctx)) {
         duk_error(ctx, DUK_ERR_ERROR, "window must be new-constructed");
@@ -247,7 +247,7 @@
     assert(ctx);
     assert(window);
 
-    StackAssert sa(ctx);
+    dukx_stack_assert sa(ctx);
 
     duk_push_this(ctx);
     duk_push_pointer(ctx, window);
@@ -261,7 +261,7 @@
 {
     assert(ctx);
 
-    StackAssert sa(ctx);
+    dukx_stack_assert sa(ctx);
 
     duk_get_prop_string(ctx, index, signature.c_str());
     auto ptr = duk_to_pointer(ctx, -1);
@@ -276,7 +276,7 @@
 
 void dukx_load_window(duk_context* ctx)
 {
-    StackAssert sa(ctx);
+    dukx_stack_assert sa(ctx);
 
     duk_get_global_string(ctx, "Malikania");
     duk_push_c_function(ctx, constructor, 0);
--- a/libcommon-js/malikania/js_elapsed_timer.cpp	Fri Dec 16 15:38:45 2016 +0100
+++ b/libcommon-js/malikania/js_elapsed_timer.cpp	Fri Dec 16 16:11:24 2016 +0100
@@ -31,7 +31,7 @@
 
 boost::timer::cpu_timer& self(duk_context* ctx)
 {
-    StackAssert sa(ctx);
+    dukx_stack_assert sa(ctx);
 
     duk_push_this(ctx);
     duk_get_prop_string(ctx, -1, signature.c_str());
@@ -144,7 +144,7 @@
 
 void dukx_load_elapsedtimer(duk_context* ctx) noexcept
 {
-    StackAssert sa(ctx);
+    dukx_stack_assert sa(ctx);
 
     duk_get_global_string(ctx, "Malikania");
     duk_push_c_function(ctx, constructor, 0);
--- a/libcommon-js/malikania/js_resources_loader.cpp	Fri Dec 16 15:38:45 2016 +0100
+++ b/libcommon-js/malikania/js_resources_loader.cpp	Fri Dec 16 16:11:24 2016 +0100
@@ -32,7 +32,7 @@
 {
     assert(ctx);
 
-    StackAssert sa(ctx);
+    dukx_stack_assert sa(ctx);
 
     duk_push_pointer(ctx, &loader);
     duk_put_global_string(ctx, variable.c_str());
@@ -42,7 +42,7 @@
 {
     assert(ctx);
 
-    StackAssert sa(ctx);
+    dukx_stack_assert sa(ctx);
 
     duk_get_global_string(ctx, variable.c_str());
     auto ptr = static_cast<resources_loader*>(duk_to_pointer(ctx, -1));
--- a/libcommon/malikania/duktape.hpp	Fri Dec 16 15:38:45 2016 +0100
+++ b/libcommon/malikania/duktape.hpp	Fri Dec 16 16:11:24 2016 +0100
@@ -16,8 +16,8 @@
  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  */
 
-#ifndef DUKTAPE_HPP
-#define DUKTAPE_HPP
+#ifndef MALIKANIA_COMMON_DUKTAPE_HPP
+#define MALIKANIA_COMMON_DUKTAPE_HPP
 
 /**
  * \file duktape.hpp
@@ -36,7 +36,6 @@
 #include <duktape.h>
 
 /**
- * \class StackAssert
  * \brief Stack sanity checker.
  *
  * Instanciate this class where you need to manipulate the Duktape stack outside
@@ -47,12 +46,12 @@
  *
  * To use it, just declare an lvalue at the beginning of your function.
  */
-class StackAssert {
+class dukx_stack_assert {
 #if !defined(NDEBUG)
 private:
-    duk_context *m_context;
+    duk_context* m_context;
     unsigned m_expected;
-    unsigned m_begin;
+    int m_at_start;
 #endif
 
 public:
@@ -64,11 +63,11 @@
      * \param ctx the context
      * \param expected the size expected relative to the already existing values
      */
-    inline StackAssert(duk_context *ctx, unsigned expected = 0) noexcept
+    inline dukx_stack_assert(duk_context *ctx, unsigned expected = 0) noexcept
 #if !defined(NDEBUG)
         : m_context(ctx)
         , m_expected(expected)
-        , m_begin(static_cast<unsigned>(duk_get_top(ctx)))
+        , m_at_start(duk_get_top(ctx))
 #endif
     {
 #if defined(NDEBUG)
@@ -82,16 +81,18 @@
      *
      * No-op if NDEBUG is set.
      */
-    inline ~StackAssert() noexcept
+    inline ~dukx_stack_assert() noexcept
     {
 #if !defined(NDEBUG)
-        if (static_cast<unsigned>(duk_get_top(m_context)) - m_begin != m_expected) {
-            std::fprintf(stderr, "Corrupt stack detection in StackAssert:\n");
-            std::fprintf(stderr, "  Size at start:            %u\n", m_begin);
-            std::fprintf(stderr, "  Size at end:              %d\n", duk_get_top(m_context));
-            std::fprintf(stderr, "  Expected (user):          %u\n", m_expected);
-            std::fprintf(stderr, "  Expected (adjusted):      %u\n", m_expected + m_begin);
-            std::fprintf(stderr, "  Number of stale values:   %u\n", duk_get_top(m_context) - m_begin - m_expected);
+        auto result = duk_get_top(m_context) - m_at_start;
+
+        if (result != static_cast<int>(m_expected)) {
+            std::fprintf(stderr, "Corrupt stack detection in dukx_stack_assert:\n");
+            std::fprintf(stderr, "  Size at start:           %d\n", m_at_start);
+            std::fprintf(stderr, "  Size at end:             %d\n", duk_get_top(m_context));
+            std::fprintf(stderr, "  Expected (user):         %u\n", m_expected);
+            std::fprintf(stderr, "  Expected (adjusted):     %u\n", m_expected + m_at_start);
+            std::fprintf(stderr, "  Difference count:       %+d\n", result - m_expected);
             std::abort();
         }
 #endif
@@ -99,18 +100,17 @@
 };
 
 /**
- * \class Exception
  * \brief Error description.
  *
  * This class fills the fields got in an Error object.
  */
-class Exception : public std::exception {
+class dukx_exception : public std::exception {
 public:
-    std::string name;       //!< name of error
-    std::string message;    //!< error message
-    std::string stack;      //!< stack if available
-    std::string fileName;   //!< filename if applicable
-    int lineNumber{0};      //!< line number if applicable
+    std::string name;               //!< name of error
+    std::string message;            //!< error message
+    std::string stack;              //!< stack if available
+    std::string fileName;           //!< filename if applicable
+    int lineNumber{0};              //!< line number if applicable
 
     /**
      * Get the error message. This effectively returns message field.
@@ -128,21 +128,18 @@
  *
  * This class is implicitly convertible to duk_context for convenience.
  */
-class UniqueContext {
+class dukx_context {
 private:
-    using Deleter = void (*)(duk_context *);
-    using Handle = std::unique_ptr<duk_context, Deleter>;
+    std::unique_ptr<duk_context, void (*)(duk_context*)> m_handle;
 
-    Handle m_handle;
-
-    UniqueContext(const UniqueContext &) = delete;
-    UniqueContext &operator=(const UniqueContext &) = delete;
+    dukx_context(const dukx_context&) = delete;
+    dukx_context &operator=(const dukx_context&) = delete;
 
 public:
     /**
      * Create default context.
      */
-    inline UniqueContext()
+    inline dukx_context() noexcept
         : m_handle(duk_create_heap_default(), duk_destroy_heap)
     {
     }
@@ -150,14 +147,14 @@
     /**
      * Default move constructor.
      */
-    UniqueContext(UniqueContext &&) noexcept = default;
+    dukx_context(dukx_context&&) noexcept = default;
 
     /**
      * Convert the context to the native Duktape/C type.
      *
      * \return the duk_context
      */
-    inline operator duk_context *() noexcept
+    inline operator duk_context*() noexcept
     {
         return m_handle.get();
     }
@@ -167,7 +164,7 @@
      *
      * \return the duk_context
      */
-    inline operator duk_context *() const noexcept
+    inline operator duk_context*() const noexcept
     {
         return m_handle.get();
     }
@@ -177,156 +174,7 @@
      *
      * \return this
      */
-    UniqueContext &operator=(UniqueContext &&) noexcept = delete;
-};
-
-/**
- * \class Error
- * \brief Base ECMAScript error class.
- * \warning Override the function create for your own exceptions
- */
-class Error {
-private:
-    int m_type{DUK_ERR_ERROR};
-    std::string m_message;
-
-protected:
-    /**
-     * Constructor with a type of error specified, specially designed for
-     * derived errors.
-     *
-     * \param type of error (e.g. DUK_ERR_ERROR)
-     * \param message the message
-     */
-    inline Error(int type, std::string message) noexcept
-        : m_type(type)
-        , m_message(std::move(message))
-    {
-    }
-
-public:
-    /**
-     * Constructor with a message.
-     *
-     * \param message the message
-     */
-    inline Error(std::string message) noexcept
-        : m_message(std::move(message))
-    {
-    }
-
-    /**
-     * Create the exception on the stack.
-     *
-     * \note the default implementation search for the global variables
-     * \param ctx the context
-     */
-    virtual void raise(duk_context *ctx) const
-    {
-        duk_error(ctx, m_type, "%s", m_message.c_str());
-    }
-};
-
-/**
- * \class EvalError
- * \brief Error in eval() function.
- */
-class EvalError : public Error {
-public:
-    /**
-     * Construct an EvalError.
-     *
-     * \param message the message
-     */
-    inline EvalError(std::string message) noexcept
-        : Error(DUK_ERR_EVAL_ERROR, std::move(message))
-    {
-    }
-};
-
-/**
- * \class RangeError
- * \brief Value is out of range.
- */
-class RangeError : public Error {
-public:
-    /**
-     * Construct an RangeError.
-     *
-     * \param message the message
-     */
-    inline RangeError(std::string message) noexcept
-        : Error(DUK_ERR_RANGE_ERROR, std::move(message))
-    {
-    }
-};
-
-/**
- * \class ReferenceError
- * \brief Trying to use a variable that does not exist.
- */
-class ReferenceError : public Error {
-public:
-    /**
-     * Construct an ReferenceError.
-     *
-     * \param message the message
-     */
-    inline ReferenceError(std::string message) noexcept
-        : Error(DUK_ERR_REFERENCE_ERROR, std::move(message))
-    {
-    }
-};
-
-/**
- * \class SyntaxError
- * \brief Syntax error in the script.
- */
-class SyntaxError : public Error {
-public:
-    /**
-     * Construct an SyntaxError.
-     *
-     * \param message the message
-     */
-    inline SyntaxError(std::string message) noexcept
-        : Error(DUK_ERR_SYNTAX_ERROR, std::move(message))
-    {
-    }
-};
-
-/**
- * \class TypeError
- * \brief Invalid type given.
- */
-class TypeError : public Error {
-public:
-    /**
-     * Construct an TypeError.
-     *
-     * \param message the message
-     */
-    inline TypeError(std::string message) noexcept
-        : Error(DUK_ERR_TYPE_ERROR, std::move(message))
-    {
-    }
-};
-
-/**
- * \class URIError
- * \brief URI manipulation failure.
- */
-class URIError : public Error {
-public:
-    /**
-     * Construct an URIError.
-     *
-     * \param message the message
-     */
-    inline URIError(std::string message) noexcept
-        : Error(DUK_ERR_URI_ERROR, std::move(message))
-    {
-    }
+    dukx_context& operator=(dukx_context&&) noexcept = delete;
 };
 
 /**
@@ -338,9 +186,9 @@
  * \param pop if true, also remove the exception from the stack
  * \return the information
  */
-inline Exception dukx_exception(duk_context *ctx, int index, bool pop = true)
+inline dukx_exception dukx_get_exception(duk_context* ctx, int index, bool pop = true)
 {
-    Exception ex;
+    dukx_exception ex;
 
     index = duk_normalize_index(ctx, index);
 
@@ -364,28 +212,16 @@
 }
 
 /**
- * Throw an ECMAScript exception.
- *
- * \param ctx the context
- * \param ex the exception
- */
-template <typename Exception>
-void dukx_throw(duk_context *ctx, const Exception &ex)
-{
-    ex.raise(ctx);
-}
-
-/**
  * Get a string, return 0 if not a string.
  *
  * \param ctx the context
  * \param index the index
  * \return the string
  */
-inline std::string dukx_get_std_string(duk_context *ctx, int index)
+inline std::string dukx_get_std_string(duk_context* ctx, int index)
 {
     duk_size_t size;
-    const char *text = duk_get_lstring(ctx, index, &size);
+    const char* text = duk_get_lstring(ctx, index, &size);
 
     return std::string(text, size);
 }
@@ -397,10 +233,10 @@
  * \param index the index
  * \return the string
  */
-inline std::string dukx_require_std_string(duk_context *ctx, int index)
+inline std::string dukx_require_std_string(duk_context* ctx, int index)
 {
     duk_size_t size;
-    const char *text = duk_require_lstring(ctx, index, &size);
+    const char* text = duk_require_lstring(ctx, index, &size);
 
     return std::string(text, size);
 }
@@ -411,7 +247,7 @@
  * \param ctx the context
  * \param str the string
  */
-inline void dukx_push_std_string(duk_context *ctx, const std::string &str)
+inline void dukx_push_std_string(duk_context* ctx, const std::string& str)
 {
     duk_push_lstring(ctx, str.data(), str.length());
 }
@@ -424,7 +260,7 @@
  * \param get the conversion function (e.g. duk_get_int)
  */
 template <typename Getter>
-auto dukx_get_array(duk_context *ctx, duk_idx_t index, Getter &&get)
+auto dukx_get_array(duk_context* ctx, duk_idx_t index, Getter&& get)
 {
     using T = decltype(get(ctx, 0));
 
@@ -448,7 +284,7 @@
  * \param push the function to push values
  */
 template <typename T, typename Pusher>
-void dukx_push_array(duk_context *ctx, const std::vector<T> &values, Pusher &&push)
+void dukx_push_array(duk_context* ctx, const std::vector<T>& values, Pusher&& push)
 {
     duk_push_array(ctx);
 
@@ -467,7 +303,7 @@
  * \param get the conversion function (e.g. duk_get_int)
  */
 template <typename Getter>
-auto dukx_get_object(duk_context *ctx, duk_idx_t index, Getter &&get)
+auto dukx_get_object(duk_context* ctx, duk_idx_t index, Getter&& get)
 {
     using T = decltype(get(ctx, 0));
 
@@ -493,14 +329,14 @@
  * \param push the function to push values
  */
 template <typename T, typename Pusher>
-void dukx_push_object(duk_context *ctx, const std::unordered_map<std::string, T> &values, Pusher &&push)
+void dukx_push_object(duk_context* ctx, const std::unordered_map<std::string, T>& values, Pusher&& push)
 {
     duk_push_object(ctx);
 
-    for (const auto &pair : values) {
+    for (const auto& pair : values) {
         push(ctx, pair.second);
         duk_put_prop_string(ctx, -2, pair.first.c_str());
     }
 }
 
-#endif // !DUKTAPE_HPP
+#endif // !MALIKANIA_COMMON_DUKTAPE_HPP
--- a/tests/libclient/js-animation/main.cpp	Fri Dec 16 15:38:45 2016 +0100
+++ b/tests/libclient/js-animation/main.cpp	Fri Dec 16 16:11:24 2016 +0100
@@ -34,7 +34,7 @@
 protected:
     mlk::directory_resources_locator m_locator;
     mlk::client_resources_loader m_loader;
-    UniqueContext m_ctx;
+    dukx_context m_ctx;
 
 public:
     test_animation()
@@ -62,7 +62,7 @@
         );
 
         if (ret != 0) {
-            throw dukx_exception(m_ctx, -1);
+            throw dukx_get_exception(m_ctx, -1);
         }
 
         boost::timer::cpu_timer timer;
@@ -77,7 +77,7 @@
             );
 
             if (ret != 0) {
-                throw dukx_exception(m_ctx, -1);
+                throw dukx_get_exception(m_ctx, -1);
             }
         }
 
--- a/tests/libclient/js-color/main.cpp	Fri Dec 16 15:38:45 2016 +0100
+++ b/tests/libclient/js-color/main.cpp	Fri Dec 16 16:11:24 2016 +0100
@@ -23,7 +23,7 @@
 
 class test_color {
 protected:
-    UniqueContext m_ctx;
+    dukx_context m_ctx;
 
 public:
     test_color()
@@ -64,7 +64,7 @@
         );
 
         if (ret != 0) {
-            throw dukx_exception(m_ctx, -1);
+            throw dukx_get_exception(m_ctx, -1);
         }
 
         BOOST_REQUIRE_EQUAL(0, component("r"));
@@ -88,7 +88,7 @@
         );
 
         if (ret != 0) {
-            throw dukx_exception(m_ctx, -1);
+            throw dukx_get_exception(m_ctx, -1);
         }
 
         BOOST_REQUIRE_EQUAL(255, component("r"));
@@ -112,7 +112,7 @@
         );
 
         if (ret != 0) {
-            throw dukx_exception(m_ctx, -1);
+            throw dukx_get_exception(m_ctx, -1);
         }
 
         BOOST_REQUIRE_EQUAL(0, component("r"));
@@ -136,7 +136,7 @@
         );
 
         if (ret != 0) {
-            throw dukx_exception(m_ctx, -1);
+            throw dukx_get_exception(m_ctx, -1);
         }
 
         BOOST_REQUIRE_EQUAL(10, component("r"));
@@ -160,7 +160,7 @@
         );
 
         if (ret != 0) {
-            throw dukx_exception(m_ctx, -1);
+            throw dukx_get_exception(m_ctx, -1);
         }
 
         BOOST_REQUIRE_EQUAL(10, component("r"));
@@ -184,7 +184,7 @@
         );
 
         if (ret != 0) {
-            throw dukx_exception(m_ctx, -1);
+            throw dukx_get_exception(m_ctx, -1);
         }
 
         BOOST_REQUIRE_EQUAL(10, component("r"));
@@ -208,7 +208,7 @@
         );
 
         if (ret != 0) {
-            throw dukx_exception(m_ctx, -1);
+            throw dukx_get_exception(m_ctx, -1);
         }
 
         BOOST_REQUIRE_EQUAL(10, component("r"));
@@ -235,7 +235,7 @@
         );
 
         if (ret != 0) {
-            throw dukx_exception(m_ctx, -1);
+            throw dukx_get_exception(m_ctx, -1);
         }
 
         BOOST_REQUIRE_EQUAL(10, component("r"));
@@ -269,7 +269,7 @@
         );
 
         if (ret != 0) {
-            throw dukx_exception(m_ctx, -1);
+            throw dukx_get_exception(m_ctx, -1);
         }
 
         duk_get_global_string(m_ctx, "name");
@@ -296,7 +296,7 @@
         );
 
         if (ret != 0) {
-            throw dukx_exception(m_ctx, -1);
+            throw dukx_get_exception(m_ctx, -1);
         }
 
         duk_get_global_string(m_ctx, "name");
@@ -323,7 +323,7 @@
         );
 
         if (ret != 0) {
-            throw dukx_exception(m_ctx, -1);
+            throw dukx_get_exception(m_ctx, -1);
         }
 
         duk_get_global_string(m_ctx, "name");
@@ -350,7 +350,7 @@
         );
 
         if (ret != 0) {
-            throw dukx_exception(m_ctx, -1);
+            throw dukx_get_exception(m_ctx, -1);
         }
 
         duk_get_global_string(m_ctx, "name");
@@ -377,7 +377,7 @@
         );
 
         if (ret != 0) {
-            throw dukx_exception(m_ctx, -1);
+            throw dukx_get_exception(m_ctx, -1);
         }
 
         duk_get_global_string(m_ctx, "name");
@@ -404,7 +404,7 @@
         );
 
         if (ret != 0) {
-            throw dukx_exception(m_ctx, -1);
+            throw dukx_get_exception(m_ctx, -1);
         }
 
         duk_get_global_string(m_ctx, "name");
@@ -431,7 +431,7 @@
         );
 
         if (ret != 0) {
-            throw dukx_exception(m_ctx, -1);
+            throw dukx_get_exception(m_ctx, -1);
         }
 
         duk_get_global_string(m_ctx, "name");
@@ -458,7 +458,7 @@
         );
 
         if (ret != 0) {
-            throw dukx_exception(m_ctx, -1);
+            throw dukx_get_exception(m_ctx, -1);
         }
 
         duk_get_global_string(m_ctx, "name");
@@ -485,7 +485,7 @@
         );
 
         if (ret != 0) {
-            throw dukx_exception(m_ctx, -1);
+            throw dukx_get_exception(m_ctx, -1);
         }
 
         duk_get_global_string(m_ctx, "name");
@@ -533,7 +533,7 @@
         auto ret = duk_peval_string(m_ctx, "draw('#ff0000');");
 
         if (ret != 0) {
-            throw dukx_exception(m_ctx, -1);
+            throw dukx_get_exception(m_ctx, -1);
         }
 
         duk_get_global_string(m_ctx, "r");
@@ -573,7 +573,7 @@
         );
 
         if (ret != 0) {
-            throw dukx_exception(m_ctx, -1);
+            throw dukx_get_exception(m_ctx, -1);
         }
 
         duk_get_global_string(m_ctx, "name");
@@ -607,7 +607,7 @@
         );
 
         if (ret != 0) {
-            throw dukx_exception(m_ctx, -1);
+            throw dukx_get_exception(m_ctx, -1);
         }
 
         duk_get_global_string(m_ctx, "name");
@@ -654,7 +654,7 @@
         auto ret = duk_peval_string(m_ctx, "draw('#ff0000');");
 
         if (ret != 0) {
-            throw dukx_exception(m_ctx, -1);
+            throw dukx_get_exception(m_ctx, -1);
         }
 
         duk_get_global_string(m_ctx, "r");
@@ -696,7 +696,7 @@
         auto ret = duk_peval_string(m_ctx, "draw('#ghijkl');");
 
         if (ret != 0) {
-            throw dukx_exception(m_ctx, -1);
+            throw dukx_get_exception(m_ctx, -1);
         }
 
         duk_get_global_string(m_ctx, "r");
@@ -738,7 +738,7 @@
         auto ret = duk_peval_string(m_ctx, "draw({ red: -1, green: 256, blue: 100, alpha: 800 });");
 
         if (ret != 0) {
-            throw dukx_exception(m_ctx, -1);
+            throw dukx_get_exception(m_ctx, -1);
         }
 
         duk_get_global_string(m_ctx, "r");
@@ -780,7 +780,7 @@
         auto ret = duk_peval_string(m_ctx, "draw(null);");
 
         if (ret != 0) {
-            throw dukx_exception(m_ctx, -1);
+            throw dukx_get_exception(m_ctx, -1);
         }
 
         duk_get_global_string(m_ctx, "r");
--- a/tests/libclient/js-font/main.cpp	Fri Dec 16 15:38:45 2016 +0100
+++ b/tests/libclient/js-font/main.cpp	Fri Dec 16 16:11:24 2016 +0100
@@ -33,7 +33,7 @@
 protected:
     mlk::directory_resources_locator m_locator;
     mlk::client_resources_loader m_loader;
-    UniqueContext m_ctx;
+    dukx_context m_ctx;
 
 public:
     test_font()
@@ -66,7 +66,7 @@
         );
 
         if (ret != 0) {
-            throw dukx_exception(m_ctx, -1);
+            throw dukx_get_exception(m_ctx, -1);
         }
 
         std::this_thread::sleep_for(3s);
--- a/tests/libclient/js-image/main.cpp	Fri Dec 16 15:38:45 2016 +0100
+++ b/tests/libclient/js-image/main.cpp	Fri Dec 16 16:11:24 2016 +0100
@@ -33,7 +33,7 @@
 protected:
     mlk::directory_resources_locator m_locator;
     mlk::client_resources_loader m_loader;
-    UniqueContext m_ctx;
+    dukx_context m_ctx;
 
 public:
     test_image()
@@ -60,7 +60,7 @@
         );
 
         if (ret != 0) {
-            throw dukx_exception(m_ctx, -1);
+            throw dukx_get_exception(m_ctx, -1);
         }
 
         duk_get_global_string(m_ctx, "w");
@@ -87,7 +87,7 @@
         );
 
         if (ret != 0) {
-            throw dukx_exception(m_ctx, -1);
+            throw dukx_get_exception(m_ctx, -1);
         }
 
         std::this_thread::sleep_for(3s);
@@ -109,7 +109,7 @@
         );
 
         if (ret != 0) {
-            throw dukx_exception(m_ctx, -1);
+            throw dukx_get_exception(m_ctx, -1);
         }
 
         std::this_thread::sleep_for(3s);
--- a/tests/libclient/js-line/main.cpp	Fri Dec 16 15:38:45 2016 +0100
+++ b/tests/libclient/js-line/main.cpp	Fri Dec 16 16:11:24 2016 +0100
@@ -23,7 +23,7 @@
 
 class test_line {
 protected:
-    UniqueContext m_ctx;
+    dukx_context m_ctx;
 
 public:
     test_line()
@@ -55,7 +55,7 @@
         );
 
         if (ret != 0) {
-            throw dukx_exception(m_ctx, -1);
+            throw dukx_get_exception(m_ctx, -1);
         }
 
         duk_get_global_string(m_ctx, "x1");
@@ -87,7 +87,7 @@
         );
 
         if (ret != 0) {
-            throw dukx_exception(m_ctx, -1);
+            throw dukx_get_exception(m_ctx, -1);
         }
 
         duk_get_global_string(m_ctx, "x1");
@@ -119,7 +119,7 @@
         );
 
         if (ret != 0) {
-            throw dukx_exception(m_ctx, -1);
+            throw dukx_get_exception(m_ctx, -1);
         }
 
         duk_get_global_string(m_ctx, "x1");
@@ -151,7 +151,7 @@
         );
 
         if (ret != 0) {
-            throw dukx_exception(m_ctx, -1);
+            throw dukx_get_exception(m_ctx, -1);
         }
 
         duk_get_global_string(m_ctx, "x1");
@@ -193,7 +193,7 @@
         );
 
         if (ret != 0) {
-            throw dukx_exception(m_ctx, -1);
+            throw dukx_get_exception(m_ctx, -1);
         }
 
         duk_get_global_string(m_ctx, "name");
@@ -238,7 +238,7 @@
         auto ret = duk_peval_string(m_ctx, "build({ x1: 50, y1: 80, x2: 100, y2: 200 });");
 
         if (ret != 0) {
-            throw dukx_exception(m_ctx, -1);
+            throw dukx_get_exception(m_ctx, -1);
         }
 
         duk_get_global_string(m_ctx, "x1");
@@ -278,7 +278,7 @@
         );
 
         if (ret != 0) {
-            throw dukx_exception(m_ctx, -1);
+            throw dukx_get_exception(m_ctx, -1);
         }
 
         duk_get_global_string(m_ctx, "name");
@@ -323,7 +323,7 @@
         auto ret = duk_peval_string(m_ctx, "build({});");
 
         if (ret != 0) {
-            throw dukx_exception(m_ctx, -1);
+            throw dukx_get_exception(m_ctx, -1);
         }
 
         duk_get_global_string(m_ctx, "x1");
--- a/tests/libclient/js-point/main.cpp	Fri Dec 16 15:38:45 2016 +0100
+++ b/tests/libclient/js-point/main.cpp	Fri Dec 16 16:11:24 2016 +0100
@@ -23,7 +23,7 @@
 
 class test_point {
 protected:
-    UniqueContext m_ctx;
+    dukx_context m_ctx;
 
 public:
     test_point()
@@ -53,7 +53,7 @@
         );
 
         if (ret != 0) {
-            throw dukx_exception(m_ctx, -1);
+            throw dukx_get_exception(m_ctx, -1);
         }
 
         duk_get_global_string(m_ctx, "x");
@@ -77,7 +77,7 @@
         );
 
         if (ret != 0) {
-            throw dukx_exception(m_ctx, -1);
+            throw dukx_get_exception(m_ctx, -1);
         }
 
         duk_get_global_string(m_ctx, "x");
@@ -101,7 +101,7 @@
         );
 
         if (ret != 0) {
-            throw dukx_exception(m_ctx, -1);
+            throw dukx_get_exception(m_ctx, -1);
         }
 
         duk_get_global_string(m_ctx, "x");
@@ -125,7 +125,7 @@
         );
 
         if (ret != 0) {
-            throw dukx_exception(m_ctx, -1);
+            throw dukx_get_exception(m_ctx, -1);
         }
 
         duk_get_global_string(m_ctx, "x");
@@ -161,7 +161,7 @@
         );
 
         if (ret != 0) {
-            throw dukx_exception(m_ctx, -1);
+            throw dukx_get_exception(m_ctx, -1);
         }
 
         duk_get_global_string(m_ctx, "name");
@@ -202,7 +202,7 @@
         auto ret = duk_peval_string(m_ctx, "build({ x: 100, y: 200 });");
 
         if (ret != 0) {
-            throw dukx_exception(m_ctx, -1);
+            throw dukx_get_exception(m_ctx, -1);
         }
 
         duk_get_global_string(m_ctx, "x");
@@ -236,7 +236,7 @@
         );
 
         if (ret != 0) {
-            throw dukx_exception(m_ctx, -1);
+            throw dukx_get_exception(m_ctx, -1);
         }
 
         duk_get_global_string(m_ctx, "name");
@@ -277,7 +277,7 @@
         auto ret = duk_peval_string(m_ctx, "build({});");
 
         if (ret != 0) {
-            throw dukx_exception(m_ctx, -1);
+            throw dukx_get_exception(m_ctx, -1);
         }
 
         duk_get_global_string(m_ctx, "x");
--- a/tests/libclient/js-rectangle/main.cpp	Fri Dec 16 15:38:45 2016 +0100
+++ b/tests/libclient/js-rectangle/main.cpp	Fri Dec 16 16:11:24 2016 +0100
@@ -23,7 +23,7 @@
 
 class test_rectangle {
 protected:
-    UniqueContext m_ctx;
+    dukx_context m_ctx;
 
 public:
     test_rectangle()
@@ -55,7 +55,7 @@
         );
 
         if (ret != 0) {
-            throw dukx_exception(m_ctx, -1);
+            throw dukx_get_exception(m_ctx, -1);
         }
 
         duk_get_global_string(m_ctx, "x");
@@ -87,7 +87,7 @@
         );
 
         if (ret != 0) {
-            throw dukx_exception(m_ctx, -1);
+            throw dukx_get_exception(m_ctx, -1);
         }
 
         duk_get_global_string(m_ctx, "x");
@@ -119,7 +119,7 @@
         );
 
         if (ret != 0) {
-            throw dukx_exception(m_ctx, -1);
+            throw dukx_get_exception(m_ctx, -1);
         }
 
         duk_get_global_string(m_ctx, "x");
@@ -151,7 +151,7 @@
         );
 
         if (ret != 0) {
-            throw dukx_exception(m_ctx, -1);
+            throw dukx_get_exception(m_ctx, -1);
         }
 
         duk_get_global_string(m_ctx, "x");
@@ -193,7 +193,7 @@
         );
 
         if (ret != 0) {
-            throw dukx_exception(m_ctx, -1);
+            throw dukx_get_exception(m_ctx, -1);
         }
 
         duk_get_global_string(m_ctx, "name");
@@ -220,7 +220,7 @@
         );
 
         if (ret != 0) {
-            throw dukx_exception(m_ctx, -1);
+            throw dukx_get_exception(m_ctx, -1);
         }
 
         duk_get_global_string(m_ctx, "name");
@@ -265,7 +265,7 @@
         auto ret = duk_peval_string(m_ctx, "build({ x: 50, y: 80, width: 100, height: 200 });");
 
         if (ret != 0) {
-            throw dukx_exception(m_ctx, -1);
+            throw dukx_get_exception(m_ctx, -1);
         }
 
         duk_get_global_string(m_ctx, "x");
@@ -305,7 +305,7 @@
         );
 
         if (ret != 0) {
-            throw dukx_exception(m_ctx, -1);
+            throw dukx_get_exception(m_ctx, -1);
         }
 
         duk_get_global_string(m_ctx, "name");
@@ -349,7 +349,7 @@
         auto ret = duk_peval_string(m_ctx, "build({});");
 
         if (ret != 0) {
-            throw dukx_exception(m_ctx, -1);
+            throw dukx_get_exception(m_ctx, -1);
         }
 
         duk_get_global_string(m_ctx, "x");
--- a/tests/libclient/js-size/main.cpp	Fri Dec 16 15:38:45 2016 +0100
+++ b/tests/libclient/js-size/main.cpp	Fri Dec 16 16:11:24 2016 +0100
@@ -25,7 +25,7 @@
 
 class test_size {
 protected:
-    UniqueContext m_ctx;
+    dukx_context m_ctx;
 
 public:
     test_size()
@@ -55,7 +55,7 @@
         );
 
         if (ret != 0) {
-            throw dukx_exception(m_ctx, -1);
+            throw dukx_get_exception(m_ctx, -1);
         }
 
         duk_get_global_string(m_ctx, "w");
@@ -79,7 +79,7 @@
         );
 
         if (ret != 0) {
-            throw dukx_exception(m_ctx, -1);
+            throw dukx_get_exception(m_ctx, -1);
         }
 
         duk_get_global_string(m_ctx, "w");
@@ -103,7 +103,7 @@
         );
 
         if (ret != 0) {
-            throw dukx_exception(m_ctx, -1);
+            throw dukx_get_exception(m_ctx, -1);
         }
 
         duk_get_global_string(m_ctx, "w");
@@ -127,7 +127,7 @@
         );
 
         if (ret != 0) {
-            throw dukx_exception(m_ctx, -1);
+            throw dukx_get_exception(m_ctx, -1);
         }
 
         duk_get_global_string(m_ctx, "w");
@@ -163,7 +163,7 @@
         );
 
         if (ret != 0) {
-            throw dukx_exception(m_ctx, -1);
+            throw dukx_get_exception(m_ctx, -1);
         }
 
         duk_get_global_string(m_ctx, "name");
@@ -190,7 +190,7 @@
         );
 
         if (ret != 0) {
-            throw dukx_exception(m_ctx, -1);
+            throw dukx_get_exception(m_ctx, -1);
         }
 
         duk_get_global_string(m_ctx, "name");
@@ -217,7 +217,7 @@
         );
 
         if (ret != 0) {
-            throw dukx_exception(m_ctx, -1);
+            throw dukx_get_exception(m_ctx, -1);
         }
 
         duk_get_global_string(m_ctx, "name");
@@ -244,7 +244,7 @@
         );
 
         if (ret != 0) {
-            throw dukx_exception(m_ctx, -1);
+            throw dukx_get_exception(m_ctx, -1);
         }
 
         duk_get_global_string(m_ctx, "name");
@@ -271,7 +271,7 @@
         );
 
         if (ret != 0) {
-            throw dukx_exception(m_ctx, -1);
+            throw dukx_get_exception(m_ctx, -1);
         }
 
         duk_get_global_string(m_ctx, "name");
@@ -312,7 +312,7 @@
         auto ret = duk_peval_string(m_ctx, "build({ width: 100, height: 200 });");
 
         if (ret != 0) {
-            throw dukx_exception(m_ctx, -1);
+            throw dukx_get_exception(m_ctx, -1);
         }
 
         duk_get_global_string(m_ctx, "w");
@@ -346,7 +346,7 @@
         );
 
         if (ret != 0) {
-            throw dukx_exception(m_ctx, -1);
+            throw dukx_get_exception(m_ctx, -1);
         }
 
         duk_get_global_string(m_ctx, "name");
@@ -387,7 +387,7 @@
         auto ret = duk_peval_string(m_ctx, "build({});");
 
         if (ret != 0) {
-            throw dukx_exception(m_ctx, -1);
+            throw dukx_get_exception(m_ctx, -1);
         }
 
         duk_get_global_string(m_ctx, "w");
--- a/tests/libclient/js-sprite/main.cpp	Fri Dec 16 15:38:45 2016 +0100
+++ b/tests/libclient/js-sprite/main.cpp	Fri Dec 16 16:11:24 2016 +0100
@@ -36,7 +36,7 @@
 protected:
     directory_resources_locator m_locator;
     client_resources_loader m_loader;
-    UniqueContext m_ctx;
+    dukx_context m_ctx;
 
 public:
     test_sprite()
@@ -64,7 +64,7 @@
         );
 
         if (ret != 0) {
-            throw dukx_exception(m_ctx, -1);
+            throw dukx_get_exception(m_ctx, -1);
         }
 
         duk_get_global_string(m_ctx, "w");
@@ -87,7 +87,7 @@
         );
 
         if (ret != 0) {
-            throw dukx_exception(m_ctx, -1);
+            throw dukx_get_exception(m_ctx, -1);
         }
 
         duk_get_global_string(m_ctx, "n");
@@ -108,7 +108,7 @@
         );
 
         if (ret != 0) {
-            throw dukx_exception(m_ctx, -1);
+            throw dukx_get_exception(m_ctx, -1);
         }
 
         duk_get_global_string(m_ctx, "w");
@@ -131,7 +131,7 @@
         );
 
         if (ret != 0) {
-            throw dukx_exception(m_ctx, -1);
+            throw dukx_get_exception(m_ctx, -1);
         }
 
         duk_get_global_string(m_ctx, "n");
@@ -152,7 +152,7 @@
         );
 
         if (ret != 0) {
-            throw dukx_exception(m_ctx, -1);
+            throw dukx_get_exception(m_ctx, -1);
         }
 
         duk_get_global_string(m_ctx, "w");
@@ -176,7 +176,7 @@
         );
 
         if (ret != 0) {
-            throw dukx_exception(m_ctx, -1);
+            throw dukx_get_exception(m_ctx, -1);
         }
 
         for (unsigned c = 0; c < 12; ++c) {
@@ -188,7 +188,7 @@
             );
 
             if (ret != 0) {
-                throw dukx_exception(m_ctx, -1);
+                throw dukx_get_exception(m_ctx, -1);
             }
 
             std::this_thread::sleep_for(1s);
--- a/tests/libclient/js-window/main.cpp	Fri Dec 16 15:38:45 2016 +0100
+++ b/tests/libclient/js-window/main.cpp	Fri Dec 16 16:11:24 2016 +0100
@@ -29,7 +29,7 @@
 
 class test_window {
 protected:
-    UniqueContext m_ctx;
+    dukx_context m_ctx;
 
 public:
     test_window()
@@ -53,7 +53,7 @@
         );
 
         if (ret != 0) {
-            throw dukx_exception(m_ctx, -1);
+            throw dukx_get_exception(m_ctx, -1);
         }
 
         std::this_thread::sleep_for(3s);
@@ -75,7 +75,7 @@
         );
 
         if (ret != 0) {
-            throw dukx_exception(m_ctx, -1);
+            throw dukx_get_exception(m_ctx, -1);
         }
 
         std::this_thread::sleep_for(3s);
--- a/tests/libcommon/js-elapsed-timer/main.cpp	Fri Dec 16 15:38:45 2016 +0100
+++ b/tests/libcommon/js-elapsed-timer/main.cpp	Fri Dec 16 16:11:24 2016 +0100
@@ -37,7 +37,7 @@
 
 class test_elapsed_timer {
 protected:
-    UniqueContext m_ctx;
+    dukx_context m_ctx;
 
     test_elapsed_timer()
     {
@@ -61,13 +61,13 @@
 {
     try {
         if (duk_peval_string(m_ctx, "timer = new Malikania.ElapsedTimer();") != 0) {
-            throw dukx_exception(m_ctx, -1);
+            throw dukx_get_exception(m_ctx, -1);
         }
 
         std::this_thread::sleep_for(300ms);
 
         if (duk_peval_string(m_ctx, "result = timer.elapsed();") != 0) {
-            throw dukx_exception(m_ctx, -1);
+            throw dukx_get_exception(m_ctx, -1);
         }
 
         duk_get_global_string(m_ctx, "result");
@@ -82,13 +82,13 @@
 {
     try {
         if (duk_peval_string(m_ctx, "timer = new Malikania.ElapsedTimer();") != 0) {
-            throw dukx_exception(m_ctx, -1);
+            throw dukx_get_exception(m_ctx, -1);
         }
 
         std::this_thread::sleep_for(300ms);
 
         if (duk_peval_string(m_ctx, "timer.reset(); result = timer.elapsed();") != 0) {
-            throw dukx_exception(m_ctx, -1);
+            throw dukx_get_exception(m_ctx, -1);
         }
 
         duk_get_global_string(m_ctx, "result");
@@ -103,7 +103,7 @@
 {
     try {
         if (duk_peval_string(m_ctx, "timer = new Malikania.ElapsedTimer();") != 0) {
-            throw dukx_exception(m_ctx, -1);
+            throw dukx_get_exception(m_ctx, -1);
         }
 
         /*
@@ -117,19 +117,19 @@
         std::this_thread::sleep_for(10ms);
 
         if (duk_peval_string(m_ctx, "timer.pause();") != 0) {
-            throw dukx_exception(m_ctx, -1);
+            throw dukx_get_exception(m_ctx, -1);
         }
 
         std::this_thread::sleep_for(5ms);
 
         if (duk_peval_string(m_ctx, "timer.restart();") != 0) {
-            throw dukx_exception(m_ctx, -1);
+            throw dukx_get_exception(m_ctx, -1);
         }
 
         std::this_thread::sleep_for(6ms);
 
         if (duk_peval_string(m_ctx, "result = timer.elapsed()") != 0) {
-            throw dukx_exception(m_ctx, -1);
+            throw dukx_get_exception(m_ctx, -1);
         }
 
         duk_get_global_string(m_ctx, "result");
@@ -144,19 +144,19 @@
 {
     try {
         if (duk_peval_string(m_ctx, "timer = new Malikania.ElapsedTimer();") != 0) {
-            throw dukx_exception(m_ctx, -1);
+            throw dukx_get_exception(m_ctx, -1);
         }
 
         std::this_thread::sleep_for(50ms);
 
         if (duk_peval_string(m_ctx, "result = timer.elapsed()") != 0) {
-            throw dukx_exception(m_ctx, -1);
+            throw dukx_get_exception(m_ctx, -1);
         }
 
         std::this_thread::sleep_for(50ms);
 
         if (duk_peval_string(m_ctx, "result = timer.elapsed()") != 0) {
-            throw dukx_exception(m_ctx, -1);
+            throw dukx_get_exception(m_ctx, -1);
         }
 
         duk_get_global_string(m_ctx, "result");