fix blob get
This commit is contained in:
@@ -32,7 +32,7 @@ grid.prototype = {
|
||||
remove(entity, pos) {
|
||||
def c = this.cell(pos.x, pos.y);
|
||||
def i = c.indexOf(entity);
|
||||
if (i !== -1) c.splice(i, 1);
|
||||
if (i != -1) c.splice(i, 1);
|
||||
},
|
||||
|
||||
// bounds check
|
||||
@@ -62,7 +62,7 @@ grid.prototype = {
|
||||
for (let x = 0; x < this.width; x++) {
|
||||
out += this.cells[y][x].length;
|
||||
}
|
||||
if (y !== this.height - 1) out += "\n";
|
||||
if (y != this.height - 1) out += "\n";
|
||||
}
|
||||
return out;
|
||||
}
|
||||
|
||||
@@ -298,8 +298,8 @@ JSC_CCALL(convert_audio_samples,
|
||||
SDL_AudioSpec dst_spec = js2SDL_AudioSpec(js, argv[1]);
|
||||
size_t src_len;
|
||||
void *src_data = js_get_blob_data(js, &src_len, argv[2]);
|
||||
if (src_data == -1)
|
||||
ret = JS_EXCEPTION;
|
||||
if (src_data == -1) {
|
||||
ret = JS_EXCEPTION;
|
||||
} else {
|
||||
Uint8 *dst_data = NULL;
|
||||
int dst_len = 0;
|
||||
|
||||
@@ -711,9 +711,14 @@ static SDL_Surface* image_to_surface(JSContext *js, JSValue img_obj)
|
||||
// Get pixels
|
||||
JSValue pixels_val = JS_GetPropertyStr(js, img_obj, "pixels");
|
||||
size_t pixel_len;
|
||||
void *pixel_data = js_get_blob_data(js, &pixel_len, pixels_val, &pixel_data);
|
||||
void *pixel_data = js_get_blob_data(js, &pixel_len, pixels_val);
|
||||
|
||||
if (pixel_data == -1) {
|
||||
JS_FreeValue(js, pixels_val);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (blob_result == -1 || blob_result == 0 || !pixel_data) {
|
||||
if (!pixel_data) {
|
||||
JS_FreeValue(js, pixels_val);
|
||||
return NULL;
|
||||
}
|
||||
@@ -947,19 +952,13 @@ JSC_CCALL(surface_convert_generic,
|
||||
// Get source pixels
|
||||
JSValue src_pixels_val = JS_GetPropertyStr(js, argv[0], "pixels");
|
||||
size_t src_len;
|
||||
void *src_pixels;
|
||||
int blob_result = js_get_blob_data(js, &src_len, src_pixels_val, &src_pixels);
|
||||
void *src_pixels = js_get_blob_data(js, &src_len, src_pixels_val);
|
||||
|
||||
if (blob_result == -1) {
|
||||
if (src_pixels == -1) {
|
||||
JS_FreeValue(js, src_pixels_val);
|
||||
return JS_EXCEPTION;
|
||||
}
|
||||
|
||||
if (blob_result == 0 || !src_pixels) {
|
||||
JS_FreeValue(js, src_pixels_val);
|
||||
return JS_ThrowTypeError(js, "source pixels must be an ArrayBuffer");
|
||||
}
|
||||
|
||||
// Get source pitch (optional, calculate if not provided)
|
||||
int src_pitch;
|
||||
JSValue src_pitch_val = JS_GetPropertyStr(js, argv[0], "pitch");
|
||||
|
||||
Reference in New Issue
Block a user