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