fix syntax
This commit is contained in:
32
geometry.c
32
geometry.c
@@ -615,7 +615,7 @@ JSC_CCALL(geometry_tilemap_to_data,
|
||||
JS_FreeValue(js, pos_y_val);
|
||||
|
||||
JSValue tiles_array = JS_GetPropertyStr(js, tilemap_obj, "tiles");
|
||||
if (!JS_IsArray(js, tiles_array)) {
|
||||
if (!JS_IsArray(tiles_array)) {
|
||||
JS_FreeValue(js, tiles_array);
|
||||
return JS_ThrowTypeError(js, "tilemap.tiles must be an array");
|
||||
}
|
||||
@@ -624,11 +624,11 @@ JSC_CCALL(geometry_tilemap_to_data,
|
||||
int tile_count = 0;
|
||||
int tiles_len = JS_ArrayLength(js, tiles_array);
|
||||
for (int x = 0; x < tiles_len; x++) {
|
||||
JSValue col = JS_GetPropertyUint32(js, tiles_array, x);
|
||||
if (JS_IsArray(js, col)) {
|
||||
JSValue col = JS_GetPropertyNumber(js, tiles_array, x);
|
||||
if (JS_IsArray(col)) {
|
||||
int col_len = JS_ArrayLength(js, col);
|
||||
for (int y = 0; y < col_len; y++) {
|
||||
JSValue tile = JS_GetPropertyUint32(js, col, y);
|
||||
JSValue tile = JS_GetPropertyNumber(js, col, y);
|
||||
if (!JS_IsNull(tile) && !JS_IsNull(tile)) {
|
||||
tile_count++;
|
||||
}
|
||||
@@ -657,11 +657,11 @@ JSC_CCALL(geometry_tilemap_to_data,
|
||||
int index_idx = 0;
|
||||
|
||||
for (int x = 0; x < tiles_len; x++) {
|
||||
JSValue col = JS_GetPropertyUint32(js, tiles_array, x);
|
||||
if (JS_IsArray(js, col)) {
|
||||
JSValue col = JS_GetPropertyNumber(js, tiles_array, x);
|
||||
if (JS_IsArray(col)) {
|
||||
int col_len = JS_ArrayLength(js, col);
|
||||
for (int y = 0; y < col_len; y++) {
|
||||
JSValue tile = JS_GetPropertyUint32(js, col, y);
|
||||
JSValue tile = JS_GetPropertyNumber(js, col, y);
|
||||
if (!JS_IsNull(tile) && !JS_IsNull(tile)) {
|
||||
// Calculate world position
|
||||
// x and y are array indices, need to convert to logical coordinates
|
||||
@@ -781,7 +781,7 @@ static void print_buffers(float *xy_data, float *uv_data, SDL_FColor *color_data
|
||||
|
||||
JSC_CCALL(geometry_sprites_to_data,
|
||||
JSValue sprites_array = argv[0];
|
||||
if (!JS_IsArray(js, sprites_array)) {
|
||||
if (!JS_IsArray(sprites_array)) {
|
||||
return JS_ThrowTypeError(js, "sprites must be an array");
|
||||
}
|
||||
|
||||
@@ -804,7 +804,7 @@ JSC_CCALL(geometry_sprites_to_data,
|
||||
int index_idx = 0;
|
||||
|
||||
for (int i = 0; i < sprite_count; i++) {
|
||||
JSValue sprite = JS_GetPropertyUint32(js, sprites_array, i);
|
||||
JSValue sprite = JS_GetPropertyNumber(js, sprites_array, i);
|
||||
|
||||
// Get sprite properties
|
||||
JSValue pos_val = JS_GetPropertyStr(js, sprite, "pos");
|
||||
@@ -989,16 +989,16 @@ JSC_CCALL(geometry_transform_xy_blob,
|
||||
}
|
||||
|
||||
JSValue camera_params = argv[1];
|
||||
if (!JS_IsArray(js, camera_params) || JS_ArrayLength(js, camera_params) != 4) {
|
||||
if (!JS_IsArray(camera_params) || JS_ArrayLength(js, camera_params) != 4) {
|
||||
return JS_ThrowTypeError(js, "Second argument must be an array of 4 camera transform parameters [a, c, e, f]");
|
||||
}
|
||||
|
||||
// Get camera transform parameters
|
||||
double a, c, e, f;
|
||||
JSValue a_val = JS_GetPropertyUint32(js, camera_params, 0);
|
||||
JSValue c_val = JS_GetPropertyUint32(js, camera_params, 1);
|
||||
JSValue e_val = JS_GetPropertyUint32(js, camera_params, 2);
|
||||
JSValue f_val = JS_GetPropertyUint32(js, camera_params, 3);
|
||||
JSValue a_val = JS_GetPropertyNumber(js, camera_params, 0);
|
||||
JSValue c_val = JS_GetPropertyNumber(js, camera_params, 1);
|
||||
JSValue e_val = JS_GetPropertyNumber(js, camera_params, 2);
|
||||
JSValue f_val = JS_GetPropertyNumber(js, camera_params, 3);
|
||||
|
||||
JS_ToFloat64(js, &a, a_val);
|
||||
JS_ToFloat64(js, &c, c_val);
|
||||
@@ -1058,7 +1058,7 @@ JSC_CCALL(geometry_array_blob,
|
||||
size_t len = JS_ArrayLength(js,arr);
|
||||
float data[len];
|
||||
for (int i = 0; i < len; i++) {
|
||||
JSValue val = JS_GetPropertyUint32(js,arr,i);
|
||||
JSValue val = JS_GetPropertyNumber(js,arr,i);
|
||||
data[i] = js2number(js, val);
|
||||
JS_FreeValue(js,val);
|
||||
}
|
||||
@@ -1168,7 +1168,7 @@ JSC_CCALL(geometry_weave,
|
||||
int num_elements = -1;
|
||||
|
||||
for (uint32_t i = 0; i < stream_count; i++) {
|
||||
JSValue stream_obj = JS_GetPropertyUint32(js, argv[0], i);
|
||||
JSValue stream_obj = JS_GetPropertyNumber(js, argv[0], i);
|
||||
JSValue data_blob = JS_GetPropertyStr(js, stream_obj, "data");
|
||||
JSValue stride_val = JS_GetPropertyStr(js, stream_obj, "stride");
|
||||
|
||||
|
||||
Reference in New Issue
Block a user