mirror of
https://github.com/godotengine/godot
synced 2024-09-05 07:08:32 +00:00
Fix Javascript platform after PoolVector removal.
Eval should be rechecked.
This commit is contained in:
parent
7b22ca339f
commit
fd035c931d
|
@ -90,12 +90,11 @@ Error EMWSPeer::get_packet(const uint8_t **r_buffer, int &r_buffer_size) {
|
|||
if (_in_buffer.packets_left() == 0)
|
||||
return ERR_UNAVAILABLE;
|
||||
|
||||
uint8_t *rw = _packet_buffer.ptrw();
|
||||
int read = 0;
|
||||
Error err = _in_buffer.read_packet(rw.ptr(), _packet_buffer.size(), &_is_string, read);
|
||||
Error err = _in_buffer.read_packet(_packet_buffer.ptrw(), _packet_buffer.size(), &_is_string, read);
|
||||
ERR_FAIL_COND_V(err != OK, err);
|
||||
|
||||
*r_buffer = rw.ptr();
|
||||
*r_buffer = _packet_buffer.ptr();
|
||||
r_buffer_size = read;
|
||||
|
||||
return OK;
|
||||
|
|
|
@ -45,7 +45,7 @@ String password;
|
|||
|
||||
int polled_response_code;
|
||||
String polled_response_header;
|
||||
PoolByteArray polled_response;
|
||||
PackedByteArray polled_response;
|
||||
|
||||
#ifdef DEBUG_ENABLED
|
||||
bool has_polled;
|
||||
|
|
|
@ -108,8 +108,7 @@ Error HTTPClient::request_raw(Method p_method, const String &p_url, const Vector
|
|||
Error err = prepare_request(p_method, p_url, p_headers);
|
||||
if (err != OK)
|
||||
return err;
|
||||
const uint8_t *read = p_body.ptr();
|
||||
godot_xhr_send_data(xhr_id, read.ptr(), p_body.size());
|
||||
godot_xhr_send_data(xhr_id, p_body.ptr(), p_body.size());
|
||||
return OK;
|
||||
}
|
||||
|
||||
|
@ -180,11 +179,7 @@ PackedByteArray HTTPClient::read_response_body_chunk() {
|
|||
int to_read = MIN(read_limit, polled_response.size() - response_read_offset);
|
||||
PackedByteArray chunk;
|
||||
chunk.resize(to_read);
|
||||
uint8_t *write = chunk.ptrw();
|
||||
const uint8_t *read = polled_response.ptr();
|
||||
memcpy(write.ptr(), read.ptr() + response_read_offset, to_read);
|
||||
write = uint8_t * ();
|
||||
read = const uint8_t * ();
|
||||
memcpy(chunk.ptrw(), polled_response.ptr() + response_read_offset, to_read);
|
||||
response_read_offset += to_read;
|
||||
|
||||
if (response_read_offset == polled_response.size()) {
|
||||
|
@ -267,19 +262,13 @@ Error HTTPClient::poll() {
|
|||
int len = godot_xhr_get_response_headers_length(xhr_id);
|
||||
bytes.resize(len + 1);
|
||||
|
||||
uint8_t *write = bytes.ptrw();
|
||||
godot_xhr_get_response_headers(xhr_id, reinterpret_cast<char *>(write.ptr()), len);
|
||||
write[len] = 0;
|
||||
write = uint8_t * ();
|
||||
godot_xhr_get_response_headers(xhr_id, reinterpret_cast<char *>(bytes.ptrw()), len);
|
||||
bytes.ptrw()[len] = 0;
|
||||
|
||||
const uint8_t *read = bytes.ptr();
|
||||
polled_response_header = String::utf8(reinterpret_cast<const char *>(read.ptr()));
|
||||
read = const uint8_t * ();
|
||||
polled_response_header = String::utf8(reinterpret_cast<const char *>(bytes.ptr()));
|
||||
|
||||
polled_response.resize(godot_xhr_get_response_length(xhr_id));
|
||||
write = polled_response.ptrw();
|
||||
godot_xhr_get_response(xhr_id, write.ptr(), polled_response.size());
|
||||
write = uint8_t * ();
|
||||
godot_xhr_get_response(xhr_id, polled_response.ptrw(), polled_response.size());
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
|
@ -33,11 +33,11 @@
|
|||
#include "api/javascript_eval.h"
|
||||
#include "emscripten.h"
|
||||
|
||||
extern "C" EMSCRIPTEN_KEEPALIVE uint8_t *resize_PackedByteArray_and_open_write(PackedByteArray *p_arr, uint8_t **r_write, int p_len) {
|
||||
extern "C" EMSCRIPTEN_KEEPALIVE uint8_t *resize_PackedByteArray_and_open_write(PackedByteArray *p_arr, VectorWriteProxy<uint8_t> *r_write, int p_len) {
|
||||
|
||||
p_arr->resize(p_len);
|
||||
*r_write = p_arr->write();
|
||||
return r_write->ptr();
|
||||
*r_write = p_arr->write;
|
||||
return p_arr->ptrw();
|
||||
}
|
||||
|
||||
Variant JavaScript::eval(const String &p_code, bool p_use_global_exec_context) {
|
||||
|
@ -49,7 +49,7 @@ Variant JavaScript::eval(const String &p_code, bool p_use_global_exec_context) {
|
|||
} js_data;
|
||||
|
||||
PackedByteArray arr;
|
||||
uint8_t *arr_write;
|
||||
VectorWriteProxy<uint8_t> arr_write;
|
||||
|
||||
/* clang-format off */
|
||||
Variant::Type return_type = static_cast<Variant::Type>(EM_ASM_INT({
|
||||
|
@ -138,7 +138,7 @@ Variant JavaScript::eval(const String &p_code, bool p_use_global_exec_context) {
|
|||
return str;
|
||||
}
|
||||
case Variant::PACKED_BYTE_ARRAY:
|
||||
arr_write = uint8_t * ();
|
||||
arr_write = VectorWriteProxy<uint8_t>();
|
||||
return arr;
|
||||
default:
|
||||
return Variant();
|
||||
|
|
|
@ -539,15 +539,11 @@ void OS_JavaScript::set_custom_mouse_cursor(const RES &p_cursor, CursorShape p_s
|
|||
|
||||
PackedByteArray png;
|
||||
size_t len;
|
||||
const uint8_t *r = image->get_data().ptr();
|
||||
ERR_FAIL_COND(!png_image_write_get_memory_size(png_meta, len, 0, r.ptr(), 0, NULL));
|
||||
PackedByteArray data = image->get_data();
|
||||
ERR_FAIL_COND(!png_image_write_get_memory_size(png_meta, len, 0, data.ptr(), 0, NULL));
|
||||
|
||||
png.resize(len);
|
||||
uint8_t *w = png.ptrw();
|
||||
ERR_FAIL_COND(!png_image_write_to_memory(&png_meta, w.ptr(), &len, 0, r.ptr(), 0, NULL));
|
||||
w = uint8_t * ();
|
||||
|
||||
r = png.ptr();
|
||||
ERR_FAIL_COND(!png_image_write_to_memory(&png_meta, png.ptrw(), &len, 0, data.ptr(), 0, NULL));
|
||||
|
||||
char *object_url;
|
||||
/* clang-format off */
|
||||
|
@ -562,9 +558,8 @@ void OS_JavaScript::set_custom_mouse_cursor(const RES &p_cursor, CursorShape p_s
|
|||
var string_on_wasm_heap = _malloc(length_bytes);
|
||||
setValue(PTR, string_on_wasm_heap, '*');
|
||||
stringToUTF8(url, string_on_wasm_heap, length_bytes);
|
||||
}, r.ptr(), len, &object_url);
|
||||
}, png.ptr(), len, &object_url);
|
||||
/* clang-format on */
|
||||
r = const uint8_t * ();
|
||||
|
||||
String url = String::utf8(object_url) + "?" + itos(p_hotspot.x) + " " + itos(p_hotspot.y);
|
||||
|
||||
|
@ -1181,15 +1176,12 @@ void OS_JavaScript::set_icon(const Ref<Image> &p_icon) {
|
|||
|
||||
PackedByteArray png;
|
||||
size_t len;
|
||||
const uint8_t *r = icon->get_data().ptr();
|
||||
ERR_FAIL_COND(!png_image_write_get_memory_size(png_meta, len, 0, r.ptr(), 0, NULL));
|
||||
PackedByteArray data = icon->get_data();
|
||||
ERR_FAIL_COND(!png_image_write_get_memory_size(png_meta, len, 0, data.ptr(), 0, NULL));
|
||||
|
||||
png.resize(len);
|
||||
uint8_t *w = png.ptrw();
|
||||
ERR_FAIL_COND(!png_image_write_to_memory(&png_meta, w.ptr(), &len, 0, r.ptr(), 0, NULL));
|
||||
w = uint8_t * ();
|
||||
ERR_FAIL_COND(!png_image_write_to_memory(&png_meta, png.ptrw(), &len, 0, data.ptr(), 0, NULL));
|
||||
|
||||
r = png.ptr();
|
||||
/* clang-format off */
|
||||
EM_ASM_ARGS({
|
||||
var PNG_PTR = $0;
|
||||
|
@ -1205,7 +1197,7 @@ void OS_JavaScript::set_icon(const Ref<Image> &p_icon) {
|
|||
document.head.appendChild(link);
|
||||
}
|
||||
link.href = url;
|
||||
}, r.ptr(), len);
|
||||
}, png.ptr(), len);
|
||||
/* clang-format on */
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue