edbrowse-dev - development list for edbrowse
 help / color / mirror / Atom feed
From: Kevin Carhart <kevin@carhart.net>
To: Edbrowse-dev@lists.the-brannons.com
Cc: kevin@carhart.net
Subject: [edbrowse-dev] [PATCH] rudimentary js_hello_quick.c
Date: Sun, 14 Feb 2021 05:38:29 -0800	[thread overview]
Message-ID: <20210114053829.kevin@carhart.net > (raw)

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



                 reply	other threads:[~2021-02-14 13:39 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='20210114053829.kevin@carhart.net ' \
    --to=kevin@carhart.net \
    --cc=Edbrowse-dev@lists.the-brannons.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).