2021-10-17 12:17:48 -04:00
|
|
|
#ifndef EL__ECMASCRIPT_QUICKJS_H
|
|
|
|
#define EL__ECMASCRIPT_QUICKJS_H
|
|
|
|
|
|
|
|
#include <quickjs/quickjs.h>
|
|
|
|
|
2021-11-20 11:29:00 -05:00
|
|
|
#ifdef ECMASCRIPT_DEBUG
|
|
|
|
|
|
|
|
#define RETURN_JS(obj) \
|
|
|
|
fprintf(stderr, "%s:%d obj=%p\n", __FILE__, __LINE__, JS_VALUE_GET_PTR(obj)); \
|
2021-11-29 13:28:38 -05:00
|
|
|
if (JS_VALUE_HAS_REF_COUNT(obj)) { \
|
|
|
|
JSRefCountHeader *p = (JSRefCountHeader *)JS_VALUE_GET_PTR(obj); \
|
|
|
|
fprintf(stderr, "ref_count=%d\n", p->ref_count); \
|
|
|
|
} \
|
2021-11-20 11:29:00 -05:00
|
|
|
return obj
|
|
|
|
|
|
|
|
#else
|
|
|
|
|
|
|
|
#define RETURN_JS(obj) return obj
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
2021-10-17 12:17:48 -04:00
|
|
|
struct ecmascript_interpreter;
|
|
|
|
struct form_view;
|
|
|
|
struct form_state;
|
|
|
|
struct string;
|
|
|
|
|
|
|
|
void *quickjs_get_interpreter(struct ecmascript_interpreter *interpreter);
|
|
|
|
void quickjs_put_interpreter(struct ecmascript_interpreter *interpreter);
|
|
|
|
|
|
|
|
void quickjs_detach_form_view(struct form_view *fv);
|
|
|
|
void quickjs_detach_form_state(struct form_state *fs);
|
|
|
|
void quickjs_moved_form_state(struct form_state *fs);
|
|
|
|
|
|
|
|
void quickjs_eval(struct ecmascript_interpreter *interpreter, struct string *code, struct string *ret);
|
|
|
|
char *quickjs_eval_stringback(struct ecmascript_interpreter *interpreter, struct string *code);
|
|
|
|
int quickjs_eval_boolback(struct ecmascript_interpreter *interpreter, struct string *code);
|
|
|
|
|
2021-11-12 15:53:31 -05:00
|
|
|
void quickjs_call_function(struct ecmascript_interpreter *interpreter, JSValueConst fun, struct string *ret);
|
2021-10-17 12:17:48 -04:00
|
|
|
|
2021-11-22 04:41:33 -05:00
|
|
|
#ifndef JS_NAN_BOXING
|
2021-11-15 11:13:51 -05:00
|
|
|
inline int operator<(JSValueConst a, JSValueConst b)
|
|
|
|
{
|
|
|
|
return JS_VALUE_GET_PTR(a) < JS_VALUE_GET_PTR(b);
|
|
|
|
}
|
2021-11-22 04:41:33 -05:00
|
|
|
#endif
|
2021-11-15 11:13:51 -05:00
|
|
|
|
2021-10-17 12:17:48 -04:00
|
|
|
extern struct module quickjs_module;
|
|
|
|
#endif
|