2021-11-30 21:29:18 -06:00
|
|
|
#ifndef SCRIPT_H
|
|
|
|
#define SCRIPT_H
|
|
|
|
|
2023-04-18 14:49:17 -05:00
|
|
|
#include "quickjs/quickjs.h"
|
2022-12-28 16:50:54 -06:00
|
|
|
#include <chipmunk/chipmunk.h>
|
2023-04-18 14:49:17 -05:00
|
|
|
#include <time.h>
|
2022-08-07 01:43:45 -05:00
|
|
|
|
2023-04-18 17:58:44 -05:00
|
|
|
extern JSContext *js;
|
2023-01-11 16:57:34 -06:00
|
|
|
|
|
|
|
struct callee {
|
2023-04-18 14:49:17 -05:00
|
|
|
JSValue fn;
|
|
|
|
JSValue obj;
|
2023-01-11 16:57:34 -06:00
|
|
|
};
|
|
|
|
|
2023-12-11 08:36:45 -06:00
|
|
|
struct phys_cbs {
|
|
|
|
struct callee begin;
|
|
|
|
struct callee separate;
|
|
|
|
};
|
|
|
|
|
2023-04-28 12:49:18 -05:00
|
|
|
extern struct callee stacktrace_callee;
|
|
|
|
extern JSValue num_cache[100];
|
|
|
|
|
2023-10-16 09:40:43 -05:00
|
|
|
JSValue jstr(const char *str);
|
2023-11-27 17:04:04 -06:00
|
|
|
void call_stack();
|
2023-04-28 20:55:24 -05:00
|
|
|
void js_stacktrace();
|
2023-04-22 14:07:37 -05:00
|
|
|
void script_startup();
|
2023-10-04 08:18:09 -05:00
|
|
|
void script_stop();
|
2023-05-29 10:47:30 -05:00
|
|
|
void script_run(const char *script, const char *file);
|
2023-06-28 11:35:41 -05:00
|
|
|
void script_evalf(const char *format, ...);
|
2022-11-20 15:50:14 -06:00
|
|
|
int script_dofile(const char *file);
|
2023-09-18 07:36:07 -05:00
|
|
|
time_t jso_file(const char *file);
|
2023-06-08 17:27:37 -05:00
|
|
|
JSValue script_runfile(const char *file);
|
2022-08-07 01:43:45 -05:00
|
|
|
void script_update(double dt);
|
2022-08-03 17:00:00 -05:00
|
|
|
void script_draw();
|
2023-11-27 14:29:55 -06:00
|
|
|
void free_callee(struct callee c);
|
2023-02-02 17:52:15 -06:00
|
|
|
|
2023-02-23 17:03:58 -06:00
|
|
|
void duk_run_err();
|
2023-04-24 17:22:18 -05:00
|
|
|
void js_dump_stack();
|
2023-02-23 17:03:58 -06:00
|
|
|
|
2023-10-03 17:16:38 -05:00
|
|
|
void out_memusage(const char *f);
|
|
|
|
|
2022-08-03 20:49:56 -05:00
|
|
|
void script_editor();
|
2022-08-05 14:23:39 -05:00
|
|
|
void script_call(const char *f);
|
2023-04-18 17:58:44 -05:00
|
|
|
void script_call_sym(JSValue sym);
|
2023-01-18 17:15:36 -06:00
|
|
|
void call_callee(struct callee *c);
|
2023-04-19 15:16:35 -05:00
|
|
|
void script_callee(struct callee c, int argc, JSValue *argv);
|
2023-01-10 14:02:24 -06:00
|
|
|
int script_has_sym(void *sym);
|
2023-09-07 16:46:35 -05:00
|
|
|
void script_eval_w_env(const char *s, JSValue env, const char *file);
|
2023-11-27 14:29:55 -06:00
|
|
|
void call_env(JSValue env, const char *eval);
|
2023-08-29 09:41:40 -05:00
|
|
|
void file_eval_env(const char *file, JSValue env);
|
2023-02-02 17:52:15 -06:00
|
|
|
|
2023-01-13 13:07:44 -06:00
|
|
|
time_t file_mod_secs(const char *file);
|
2021-11-30 21:29:18 -06:00
|
|
|
|
2023-01-11 16:57:34 -06:00
|
|
|
void register_update(struct callee c);
|
2022-12-22 16:58:06 -06:00
|
|
|
void call_updates(double dt);
|
2023-03-17 10:25:35 -05:00
|
|
|
void call_debugs();
|
2022-12-19 09:12:34 -06:00
|
|
|
|
2023-02-28 17:03:28 -06:00
|
|
|
void unregister_gui(struct callee c);
|
2023-01-11 16:57:34 -06:00
|
|
|
void register_gui(struct callee c);
|
2023-03-17 10:25:35 -05:00
|
|
|
void register_debug(struct callee c);
|
2023-01-19 13:06:32 -06:00
|
|
|
void register_nk_gui(struct callee c);
|
2022-12-20 19:34:22 -06:00
|
|
|
void call_gui();
|
2023-01-19 13:06:32 -06:00
|
|
|
void call_nk_gui();
|
2023-04-18 14:49:17 -05:00
|
|
|
void unregister_obj(JSValue obj);
|
2022-12-20 19:34:22 -06:00
|
|
|
|
2023-06-06 15:49:55 -05:00
|
|
|
void send_signal(const char *signal, int argc, JSValue *argv);
|
|
|
|
|
2023-01-11 16:57:34 -06:00
|
|
|
void register_physics(struct callee c);
|
2022-12-22 16:58:06 -06:00
|
|
|
void call_physics(double dt);
|
2022-12-20 19:34:22 -06:00
|
|
|
|
2023-05-24 20:45:50 -05:00
|
|
|
void register_draw(struct callee c);
|
|
|
|
void call_draw();
|
2023-09-18 07:36:07 -05:00
|
|
|
uint8_t *compile_script(const char *file, size_t *len);
|
2023-05-24 20:45:50 -05:00
|
|
|
|
2022-02-06 10:14:57 -06:00
|
|
|
#endif
|