prosperon/source/engine/jsffi.h

73 lines
1.5 KiB
C
Raw Normal View History

2023-01-10 07:13:00 -06:00
#ifndef FFI_H
#define FFI_H
2024-05-21 18:50:53 -05:00
#ifdef __cplusplus
extern "C" {
#endif
2023-04-18 14:49:17 -05:00
#include "quickjs/quickjs.h"
#include "HandmadeMath.h"
#include <stdarg.h>
#include <chipmunk/chipmunk.h>
2024-10-29 12:41:17 -05:00
#include "qjs_macros.h"
2024-08-06 14:23:21 -05:00
void script_report_gc_time(double t, double startmem, double mem);
2024-08-15 12:26:37 -05:00
int JS_Is(JSValue v);
extern JSValue cpShape2js(cpShape *s);
2023-01-10 07:13:00 -06:00
void ffi_load();
JSValue vec22js(HMM_Vec2 v);
2023-11-14 09:20:09 -06:00
HMM_Vec2 js2vec2(JSValue v);
2024-09-14 23:42:46 -05:00
HMM_Vec4 js2vec4(JSValue v);
2024-05-21 18:50:53 -05:00
const char *js2str(JSValue v);
char *js2strdup(JSValue v);
2023-04-18 14:49:17 -05:00
JSValue bitmask2js(cpBitmask mask);
cpBitmask js2bitmask(JSValue v);
2023-10-10 17:37:58 -05:00
int js_print_exception(JSValue v);
2023-05-16 01:31:13 -05:00
struct rgba js2color(JSValue v);
2024-09-14 23:42:46 -05:00
2023-04-19 15:16:35 -05:00
double js2number(JSValue v);
2024-01-14 10:24:31 -06:00
JSValue number2js(double g);
2024-05-21 18:50:53 -05:00
uint64_t js2uint64(JSValue v);
JSValue str2js(const char *c, ...);
2023-04-18 17:58:44 -05:00
2024-08-25 15:29:35 -05:00
struct texture;
struct texture *js2texture(JSValue v);
2024-01-14 12:56:52 -06:00
void nota_int(char *blob);
2024-09-14 09:36:40 -05:00
void js_setprop_num(JSValue a, uint32_t n, JSValue v);
2024-04-30 10:32:27 -05:00
JSValue js_getpropidx(JSValue v, uint32_t i);
JSValue js_getpropstr(JSValue v, const char *str);
void jsfreestr(const char *str);
2024-05-06 21:59:22 -05:00
int js_arrlen(JSValue v);
2024-05-21 18:50:53 -05:00
void js_setpropstr(JSValue v, const char *str, JSValue p);
2024-09-04 07:41:48 -05:00
void js2floatarr(JSValue v, int n, float *a);
JSValue floatarr2js(int n, float *a);
2024-05-21 18:50:53 -05:00
2024-09-14 09:36:40 -05:00
float *js2newfloatarr(JSValue v);
2024-05-21 18:50:53 -05:00
int js2boolean(JSValue v);
JSValue boolean2js(int b);
2024-09-04 13:23:20 -05:00
char **js2strarr(JSValue v);
2024-05-21 18:50:53 -05:00
#define PREP_PARENT(TYPE, PARENT) \
TYPE##_proto = JS_NewObject(js); \
JS_SetPropertyFunctionList(js, TYPE##_proto, js_##TYPE##_funcs, countof(js_##TYPE##_funcs)); \
JS_SetPrototype(js, TYPE##_proto, PARENT##_proto); \
#ifdef __cplusplus
}
#endif
2024-04-30 10:32:27 -05:00
#endif