From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on inbox.vuxu.org X-Spam-Level: *** X-Spam-Status: No, score=3.6 required=5.0 tests=HDRS_MISSP,INVALID_MSGID autolearn=no autolearn_force=no version=3.4.4 Received: (qmail 27566 invoked from network); 14 Feb 2021 13:39:11 -0000 Received: from hurricane.the-brannons.com (216.252.162.32) by inbox.vuxu.org with ESMTPUTF8; 14 Feb 2021 13:39:11 -0000 Received: from localhost.localdomain (localhost [127.0.0.1]) by hurricane.the-brannons.com (OpenSMTPD) with ESMTP id 845c2b73 for ; Sun, 14 Feb 2021 05:38:59 -0800 (PST) Received: from out.smtp-auth.no-ip.com (smtp-auth.no-ip.com [8.23.224.60]) by hurricane.the-brannons.com (OpenSMTPD) with ESMTPS id d15b677d (TLSv1:AES256-SHA:256:NO) for ; Sun, 14 Feb 2021 05:38:39 -0800 (PST) X-No-IP: carhart.net@noip-smtp X-Report-Spam-To: abuse@no-ip.com Received: from phoenix.carhart.net (unknown [99.57.137.251]) (Authenticated sender: carhart.net@noip-smtp) by smtp-auth.no-ip.com (Postfix) with ESMTPA id 43EFA37FAD8 for ; Sun, 14 Feb 2021 05:38:37 -0800 (PST) Received: from unknown (carhart.net [127.0.0.1]) by phoenix.carhart.net (8.15.2/8.15.2) with ESMTP id 11EDcTvZ007925; Sun, 14 Feb 2021 05:38:29 -0800 To:Edbrowse-dev@lists.the-brannons.com CC:kevin@carhart.net From: Kevin Carhart Reply-to: Kevin Carhart User-Agent: edbrowse/3.7.2 Subject: [edbrowse-dev] [PATCH] rudimentary js_hello_quick.c Date: Sun, 14 Feb 2021 05:38:29 -0800 Message-ID: <20210114053829.kevin@carhart.net > X-BeenThere: edbrowse-dev@edbrowse.org List-Id: Edbrowse Development List Mime-Version: 1.0 Content-Type: text/plain Content-Transfer-Encoding: 7bit >From 5713fcab3ee3c980f6365ee84a49f9c1213b2c89 Mon Sep 17 00:00:00 2001 From: Kevin Carhart 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 +#include +#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