Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
godot
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
community
godot
Commits
fd035c93
Commit
fd035c93
authored
Feb 25, 2020
by
Fabio Alessandrelli
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix Javascript platform after PoolVector removal.
Eval should be rechecked.
parent
7b22ca33
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
22 additions
and
42 deletions
+22
-42
emws_peer.cpp
modules/websocket/emws_peer.cpp
+2
-3
http_client.h.inc
platform/javascript/http_client.h.inc
+1
-1
http_client_javascript.cpp
platform/javascript/http_client_javascript.cpp
+6
-17
javascript_eval.cpp
platform/javascript/javascript_eval.cpp
+5
-5
os_javascript.cpp
platform/javascript/os_javascript.cpp
+8
-16
No files found.
modules/websocket/emws_peer.cpp
View file @
fd035c93
...
...
@@ -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
;
...
...
platform/javascript/http_client.h.inc
View file @
fd035c93
...
...
@@ -45,7 +45,7 @@ String password;
int
polled_response_code
;
String
polled_response_header
;
P
ool
ByteArray
polled_response
;
P
acked
ByteArray
polled_response
;
#ifdef DEBUG_ENABLED
bool
has_polled
;
...
...
platform/javascript/http_client_javascript.cpp
View file @
fd035c93
...
...
@@ -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
;
}
...
...
platform/javascript/javascript_eval.cpp
View file @
fd035c93
...
...
@@ -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
();
...
...
platform/javascript/os_javascript.cpp
View file @
fd035c93
...
...
@@ -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 */
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment