enumerable C abased js
This commit is contained in:
parent
262cd50e1a
commit
7706aa8462
|
@ -1015,11 +1015,11 @@ typedef struct JSCFunctionListEntry {
|
||||||
#define JS_DEF_ALIAS 9
|
#define JS_DEF_ALIAS 9
|
||||||
|
|
||||||
/* Note: c++ does not like nested designators */
|
/* Note: c++ does not like nested designators */
|
||||||
#define JS_CFUNC_DEF(name, length, func1) { name, JS_PROP_WRITABLE | JS_PROP_CONFIGURABLE, JS_DEF_CFUNC, 0, .u = { .func = { length, JS_CFUNC_generic, { .generic = func1 } } } }
|
#define JS_CFUNC_DEF(name, length, func1) { name, JS_PROP_WRITABLE | JS_PROP_CONFIGURABLE | JS_PROP_ENUMERABLE, JS_DEF_CFUNC, 0, .u = { .func = { length, JS_CFUNC_generic, { .generic = func1 } } } }
|
||||||
#define JS_CFUNC_MAGIC_DEF(name, length, func1, magic) { name, JS_PROP_WRITABLE | JS_PROP_CONFIGURABLE, JS_DEF_CFUNC, magic, .u = { .func = { length, JS_CFUNC_generic_magic, { .generic_magic = func1 } } } }
|
#define JS_CFUNC_MAGIC_DEF(name, length, func1, magic) { name, JS_PROP_WRITABLE | JS_PROP_CONFIGURABLE, JS_DEF_CFUNC, magic, .u = { .func = { length, JS_CFUNC_generic_magic, { .generic_magic = func1 } } } }
|
||||||
#define JS_CFUNC_SPECIAL_DEF(name, length, cproto, func1) { name, JS_PROP_WRITABLE | JS_PROP_CONFIGURABLE, JS_DEF_CFUNC, 0, .u = { .func = { length, JS_CFUNC_ ## cproto, { .cproto = func1 } } } }
|
#define JS_CFUNC_SPECIAL_DEF(name, length, cproto, func1) { name, JS_PROP_WRITABLE | JS_PROP_CONFIGURABLE, JS_DEF_CFUNC, 0, .u = { .func = { length, JS_CFUNC_ ## cproto, { .cproto = func1 } } } }
|
||||||
#define JS_ITERATOR_NEXT_DEF(name, length, func1, magic) { name, JS_PROP_WRITABLE | JS_PROP_CONFIGURABLE, JS_DEF_CFUNC, magic, .u = { .func = { length, JS_CFUNC_iterator_next, { .iterator_next = func1 } } } }
|
#define JS_ITERATOR_NEXT_DEF(name, length, func1, magic) { name, JS_PROP_WRITABLE | JS_PROP_CONFIGURABLE, JS_DEF_CFUNC, magic, .u = { .func = { length, JS_CFUNC_iterator_next, { .iterator_next = func1 } } } }
|
||||||
#define JS_CGETSET_DEF(name, fgetter, fsetter) { name, JS_PROP_CONFIGURABLE, JS_DEF_CGETSET, 0, .u = { .getset = { .get = { .getter = fgetter }, .set = { .setter = fsetter } } } }
|
#define JS_CGETSET_DEF(name, fgetter, fsetter) { name, JS_PROP_ENUMERABLE | JS_PROP_CONFIGURABLE, JS_DEF_CGETSET, 0, .u = { .getset = { .get = { .getter = fgetter }, .set = { .setter = fsetter } } } }
|
||||||
#define JS_CGETSET_MAGIC_DEF(name, fgetter, fsetter, magic) { name, JS_PROP_CONFIGURABLE, JS_DEF_CGETSET_MAGIC, magic, .u = { .getset = { .get = { .getter_magic = fgetter }, .set = { .setter_magic = fsetter } } } }
|
#define JS_CGETSET_MAGIC_DEF(name, fgetter, fsetter, magic) { name, JS_PROP_CONFIGURABLE, JS_DEF_CGETSET_MAGIC, magic, .u = { .getset = { .get = { .getter_magic = fgetter }, .set = { .setter_magic = fsetter } } } }
|
||||||
#define JS_PROP_STRING_DEF(name, cstr, prop_flags) { name, prop_flags, JS_DEF_PROP_STRING, 0, .u = { .str = cstr } }
|
#define JS_PROP_STRING_DEF(name, cstr, prop_flags) { name, prop_flags, JS_DEF_PROP_STRING, 0, .u = { .str = cstr } }
|
||||||
#define JS_PROP_INT32_DEF(name, val, prop_flags) { name, prop_flags, JS_DEF_PROP_INT32, 0, .u = { .i32 = val } }
|
#define JS_PROP_INT32_DEF(name, val, prop_flags) { name, prop_flags, JS_DEF_PROP_INT32, 0, .u = { .i32 = val } }
|
||||||
|
|
|
@ -9,7 +9,7 @@ var Sound = {
|
||||||
}
|
}
|
||||||
var src = DSP.source(file);
|
var src = DSP.source(file);
|
||||||
bus ??= Sound.bus.master;
|
bus ??= Sound.bus.master;
|
||||||
src.plugin(bus);
|
// src.plugin(bus);
|
||||||
return src;
|
return src;
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
|
@ -326,7 +326,7 @@ void debugdraw_init()
|
||||||
void draw_line(HMM_Vec2 *points, int n, struct rgba color, float seg_len, float seg_speed)
|
void draw_line(HMM_Vec2 *points, int n, struct rgba color, float seg_len, float seg_speed)
|
||||||
{
|
{
|
||||||
if (n < 2) return;
|
if (n < 2) return;
|
||||||
|
|
||||||
seg_speed = 1;
|
seg_speed = 1;
|
||||||
|
|
||||||
struct line_vert v[n];
|
struct line_vert v[n];
|
||||||
|
|
|
@ -189,7 +189,6 @@ JSValue strarr2js(char **c)
|
||||||
}
|
}
|
||||||
|
|
||||||
double js2number(JSValue v) {
|
double js2number(JSValue v) {
|
||||||
return JS_VALUE_GET_FLOAT64(v);
|
|
||||||
double g;
|
double g;
|
||||||
JS_ToFloat64(js, &g, v);
|
JS_ToFloat64(js, &g, v);
|
||||||
return g;
|
return g;
|
||||||
|
@ -420,7 +419,6 @@ cpBitmask js2bitmask(JSValue v) {
|
||||||
return mask;
|
return mask;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Does not need to be freed by returning; but not reentrant */
|
|
||||||
HMM_Vec2 *js2cpvec2arr(JSValue v) {
|
HMM_Vec2 *js2cpvec2arr(JSValue v) {
|
||||||
HMM_Vec2 *arr = NULL;
|
HMM_Vec2 *arr = NULL;
|
||||||
int n = js_arrlen(v);
|
int n = js_arrlen(v);
|
||||||
|
@ -1439,21 +1437,13 @@ JSValue duk_cmd(JSContext *js, JSValueConst this, int argc, JSValueConst *argv)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (str)
|
if (str) JS_FreeCString(js, str);
|
||||||
JS_FreeCString(js, str);
|
if (str2) JS_FreeCString(js, str2);
|
||||||
|
|
||||||
if (str2)
|
|
||||||
JS_FreeCString(js, str2);
|
|
||||||
|
|
||||||
if (d1) free(d1);
|
if (d1) free(d1);
|
||||||
if (d2) free(d2);
|
if (d2) free(d2);
|
||||||
|
|
||||||
if (v1) arrfree(v1);
|
if (v1) arrfree(v1);
|
||||||
|
|
||||||
if (!JS_IsNull(ret)) {
|
if (!JS_IsNull(ret)) return ret;
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
return JS_UNDEFINED;
|
return JS_UNDEFINED;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2122,7 +2112,6 @@ void ffi_load() {
|
||||||
sound_proto = JS_NewObject(js);
|
sound_proto = JS_NewObject(js);
|
||||||
JS_SetPropertyFunctionList(js, sound_proto, js_sound_funcs, countof(js_sound_funcs));
|
JS_SetPropertyFunctionList(js, sound_proto, js_sound_funcs, countof(js_sound_funcs));
|
||||||
JS_SetPrototype(js, sound_proto, dsp_node_proto);
|
JS_SetPrototype(js, sound_proto, dsp_node_proto);
|
||||||
JS_FreeValue(js, sound_proto);
|
|
||||||
|
|
||||||
QJSCLASSPREP_FUNCS(emitter);
|
QJSCLASSPREP_FUNCS(emitter);
|
||||||
QJSCLASSPREP_FUNCS(warp_gravity);
|
QJSCLASSPREP_FUNCS(warp_gravity);
|
||||||
|
@ -2130,3 +2119,8 @@ void ffi_load() {
|
||||||
|
|
||||||
QJSCLASSPREP_FUNCS(constraint);
|
QJSCLASSPREP_FUNCS(constraint);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ffi_stop()
|
||||||
|
{
|
||||||
|
JS_FreeValue(js, sound_proto);
|
||||||
|
}
|
||||||
|
|
|
@ -6,6 +6,7 @@
|
||||||
#include "dsp.h"
|
#include "dsp.h"
|
||||||
|
|
||||||
void ffi_load();
|
void ffi_load();
|
||||||
|
void ffi_stop();
|
||||||
|
|
||||||
JSValue vec2js(HMM_Vec2 v);
|
JSValue vec2js(HMM_Vec2 v);
|
||||||
HMM_Vec2 js2vec2(JSValue v);
|
HMM_Vec2 js2vec2(JSValue v);
|
||||||
|
|
|
@ -73,6 +73,7 @@ void script_stop()
|
||||||
{
|
{
|
||||||
script_evalf("Event.notify('quit');");
|
script_evalf("Event.notify('quit');");
|
||||||
send_signal("quit",0,NULL);
|
send_signal("quit",0,NULL);
|
||||||
|
ffi_stop();
|
||||||
for (int i = 0; i < shlen(jsstrs); i++)
|
for (int i = 0; i < shlen(jsstrs); i++)
|
||||||
JS_FreeValue(js,jsstrs[i].value);
|
JS_FreeValue(js,jsstrs[i].value);
|
||||||
JS_FreeContext(js);
|
JS_FreeContext(js);
|
||||||
|
|
|
@ -17,7 +17,7 @@
|
||||||
#include "sprite.sglsl.h"
|
#include "sprite.sglsl.h"
|
||||||
#include "9slice.sglsl.h"
|
#include "9slice.sglsl.h"
|
||||||
|
|
||||||
struct TextureOptions TEX_SPRITE = {1, 0, 0};
|
struct TextureOptions TEX_SPRITE = {1};
|
||||||
|
|
||||||
static struct sprite *sprites = NULL;
|
static struct sprite *sprites = NULL;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue