Mercurial > malikania
diff examples/js-window/main.cpp @ 188:0cecdadfb5c4
Misc: rework javascript bindings, closes #916
While here, create new test libraries for future unit tests.
author | David Demelier <markand@malikania.fr> |
---|---|
date | Wed, 24 Oct 2018 21:13:12 +0200 |
parents | 3107ce017c3a |
children | f28cb6d04731 |
line wrap: on
line diff
--- a/examples/js-window/main.cpp Sat Oct 20 21:58:32 2018 +0200 +++ b/examples/js-window/main.cpp Wed Oct 24 21:13:12 2018 +0200 @@ -26,26 +26,26 @@ using namespace mlk; using namespace mlk::client; +using namespace mlk::duk; -void basic(dukx_context& ctx) +void basic(duk_context* ctx) { - auto ret = duk_peval_string(ctx, + const auto ret = duk_peval_string(ctx, "w = new Malikania.Window();" "w.setDrawingColor('lightskyblue');" "w.clear();" "w.present();" ); - if (ret != 0) { - throw dukx_get_exception(ctx, -1); - } + if (ret != 0) + throw get_stack(ctx, -1); std::this_thread::sleep_for(3s); } -void rect(dukx_context& ctx) +void rect(duk_context* ctx) { - auto ret = duk_peval_string(ctx, + const auto ret = duk_peval_string(ctx, "w = new Malikania.Window();" "w.setDrawingColor('lightskyblue');" "w.clear();" @@ -54,9 +54,8 @@ "w.present();" ); - if (ret != 0) { - throw dukx_get_exception(ctx, -1); - } + if (ret != 0) + throw get_stack(ctx, -1); std::this_thread::sleep_for(3s); } @@ -64,12 +63,12 @@ int main() { try { - dukx_context ctx; + context ctx; duk_push_object(ctx); duk_put_global_string(ctx, "Malikania"); - dukx_load_window(ctx); + load_window_api(ctx); basic(ctx); rect(ctx); } catch (const std::exception& ex) {