Skip to content

Commit

Permalink
Basic proof-of-concept for embedding QuickJS
Browse files Browse the repository at this point in the history
  • Loading branch information
KevinCarhart authored and arthompson committed Feb 14, 2021
1 parent 28e0952 commit d7cd398
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions src/js_hello_quick.c
Original file line number Diff line number Diff line change
@@ -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)));
}


0 comments on commit d7cd398

Please sign in to comment.