edbrowse-dev - development list for edbrowse
 help / color / mirror / Atom feed
* [edbrowse-dev] [PATCH] rudimentary js_hello_quick.c
@ 2021-02-14 13:38 Kevin Carhart
  0 siblings, 0 replies; only message in thread
From: Kevin Carhart @ 2021-02-14 13:38 UTC (permalink / raw)
  To: Edbrowse-dev; +Cc: kevin

From 5713fcab3ee3c980f6365ee84a49f9c1213b2c89 Mon Sep 17 00:00:00 2001
From: Kevin Carhart <kevin@carhart.net>
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



^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2021-02-14 13:39 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-02-14 13:38 [edbrowse-dev] [PATCH] rudimentary js_hello_quick.c Kevin Carhart

edbrowse-dev - development list for edbrowse

This inbox may be cloned and mirrored by anyone:

	git clone --mirror http://inbox.vuxu.org/edbrowse-dev

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V1 edbrowse-dev edbrowse-dev/ http://inbox.vuxu.org/edbrowse-dev \
		edbrowse-dev@edbrowse.org
	public-inbox-index edbrowse-dev

Example config snippet for mirrors.
Newsgroup available over NNTP:
	nntp://inbox.vuxu.org/vuxu.archive.edbrowse.dev


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git