diff examples/js-font/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-font/main.cpp	Sat Oct 20 21:58:32 2018 +0200
+++ b/examples/js-font/main.cpp	Wed Oct 24 21:13:12 2018 +0200
@@ -20,19 +20,23 @@
 #include <iostream>
 #include <thread>
 
+#include <malikania/locator.hpp>
+
+#include <malikania/client/loader.hpp>
+
 #include <malikania/js_client_resources_loader.hpp>
 #include <malikania/js_font.hpp>
 #include <malikania/js_window.hpp>
-#include <malikania/locator.hpp>
 
 using namespace std::chrono_literals;
 
 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();"
 		"f = new Malikania.Font('DejaVuSans.ttf', 10);"
 		"w.setDrawingColor('lightskyblue');"
@@ -45,7 +49,7 @@
 	);
 
 	if (ret != 0)
-		throw dukx_get_exception(ctx, -1);
+		throw get_stack(ctx, -1);
 
 	std::this_thread::sleep_for(3s);
 }
@@ -53,16 +57,16 @@
 int main()
 {
 	try {
-		mlk::directory_locator locator(CMAKE_CURRENT_SOURCE_DIR "/resources");
-		mlk::client::loader loader(locator);
-		dukx_context ctx;
+		directory_locator locator(CMAKE_CURRENT_SOURCE_DIR "/resources");
+		client::loader loader(locator);
+		context ctx;
 
 		duk_push_object(ctx);
 		duk_put_global_string(ctx, "Malikania");
-		dukx_put_client_loader(ctx, loader);
-		dukx_load_font(ctx);
-		dukx_load_window(ctx);
 
+		load_font_api(ctx);
+		load_window_api(ctx);
+		put(ctx, loader);
 		basic(ctx);
 	} catch (const std::exception& ex) {
 		std::cerr << ex.what() << std::endl;