|
|
@ -17,6 +17,8 @@
|
|
17
|
17
|
#define CONSOLE_LOG_BUF_SIZE 1000
|
|
18
|
18
|
char console_log_buf[CONSOLE_LOG_BUF_SIZE];
|
|
19
|
19
|
|
|
|
20
|
int exit_value = 0;
|
|
|
21
|
|
|
20
|
22
|
JSStringRef to_string(JSContextRef ctx, JSValueRef val);
|
|
21
|
23
|
JSValueRef evaluate_script(JSContextRef ctx, char *script, char *source);
|
|
22
|
24
|
|
|
|
@ -258,6 +260,14 @@ JSValueRef function_print_err_fn(JSContextRef ctx, JSObjectRef function, JSObjec
|
|
258
|
260
|
return JSValueMakeNull(ctx);
|
|
259
|
261
|
}
|
|
260
|
262
|
|
|
|
263
|
JSValueRef function_set_exit_value(JSContextRef ctx, JSObjectRef function, JSObjectRef thisObject,
|
|
|
264
|
size_t argc, const JSValueRef args[], JSValueRef* exception) {
|
|
|
265
|
if (argc == 1 && JSValueGetType (ctx, args[0]) == kJSTypeNumber) {
|
|
|
266
|
exit_value = JSValueToNumber(ctx, args[0], NULL);
|
|
|
267
|
}
|
|
|
268
|
return JSValueMakeNull(ctx);
|
|
|
269
|
}
|
|
|
270
|
|
|
261
|
271
|
JSValueRef function_import_script(JSContextRef ctx, JSObjectRef function, JSObjectRef thisObject,
|
|
262
|
272
|
size_t argc, const JSValueRef args[], JSValueRef* exception) {
|
|
263
|
273
|
if (argc == 1 && JSValueGetType(ctx, args[0]) == kJSTypeString) {
|
|
|
@ -352,7 +362,6 @@ int main(int argc, char **argv) {
|
|
352
|
362
|
javascript = true;
|
|
353
|
363
|
break;
|
|
354
|
364
|
case 'e':
|
|
355
|
|
printf("should eval '%s'\n", optarg);
|
|
356
|
365
|
num_eval_args += 1;
|
|
357
|
366
|
eval_args = realloc(eval_args, num_eval_args * sizeof(char*));
|
|
358
|
367
|
eval_args[num_eval_args - 1] = argv[optind - 1];
|
|
|
@ -376,7 +385,7 @@ int main(int argc, char **argv) {
|
|
376
|
385
|
}
|
|
377
|
386
|
}
|
|
378
|
387
|
|
|
379
|
|
if (num_rest_args == 0) {
|
|
|
388
|
if (num_rest_args == 0 && num_eval_args == 0) {
|
|
380
|
389
|
repl = true;
|
|
381
|
390
|
}
|
|
382
|
391
|
|
|
|
@ -416,6 +425,8 @@ int main(int argc, char **argv) {
|
|
416
|
425
|
register_global_function(ctx, "PLANCK_PRINT_FN", function_print_fn);
|
|
417
|
426
|
register_global_function(ctx, "PLANCK_PRINT_ERR_FN", function_print_err_fn);
|
|
418
|
427
|
|
|
|
428
|
register_global_function(ctx, "PLANCK_SET_EXIT_VALUE", function_set_exit_value);
|
|
|
429
|
|
|
419
|
430
|
evaluate_script(ctx, "cljs.core.set_print_fn_BANG_.call(null,PLANCK_PRINT_FN);", "<init>");
|
|
420
|
431
|
evaluate_script(ctx, "cljs.core.set_print_err_fn_BANG_.call(null,PLANCK_PRINT_ERR_FN);", "<init>");
|
|
421
|
432
|
|
|
|
@ -465,6 +476,8 @@ int main(int argc, char **argv) {
|
|
465
|
476
|
print_value("", ctx, res);
|
|
466
|
477
|
}
|
|
467
|
478
|
}
|
|
|
479
|
|
|
|
480
|
return exit_value;
|
|
468
|
481
|
}
|
|
469
|
482
|
|
|
470
|
483
|
JSStringRef to_string(JSContextRef ctx, JSValueRef val) {
|