>From 5713fcab3ee3c980f6365ee84a49f9c1213b2c89 Mon Sep 17 00:00:00 2001
From: Kevin Carhart <[email protected]>
Date: Sun, 14 Feb 2021 05:27:06 -0800
Subject: [PATCH] Basic proof-of-concept for embedding QuickJS

---
 src/js_hello_quick.c | 25 +++++++++++++++++++++++++
 1 file changed, 25 insertions(+)
 create mode 100644 src/js_hello_quick.c

diff --git a/src/js_hello_quick.c b/src/js_hello_quick.c
new file mode 100644
index 0000000..739bfbc
--- /dev/null
+++ b/src/js_hello_quick.c
@@ -0,0 +1,25 @@
+#include <stdio.h>
+#include <string.h>
+#include "quickjs-libc.h"
+#include "quickjs.h"
+
+// gcc js_hello_quick.c -o js_hello_quick quickjs.c libregexp.c libunicode.c 
cutils.c -lm -ldl -lpthread
+
+int main(int argc, char **argv)
+{
+
+JSRuntime *rt;
+JSContext *ctx;
+int flags;
+rt = JS_NewRuntime();
+ctx = JS_NewContext(rt);
+JSValue val;
+const char *filename;
+
+char *x = "'hello world, the answer is ' + 6*7;";
+
+val = JS_Eval(ctx, x, strlen(x), filename, JS_EVAL_TYPE_GLOBAL);
+printf("%s\n",JS_AtomToCString(ctx,JS_ValueToAtom(ctx,val)));
+}
+
+
-- 
1.8.3.2


Reply via email to