feat: updated engine
This commit is contained in:
parent
cbe99774ff
commit
f4cf6b3999
6607 changed files with 910135 additions and 430025 deletions
|
|
@ -31,6 +31,7 @@
|
|||
#include "stream_peer.h"
|
||||
|
||||
#include "core/io/marshalls.h"
|
||||
#include "core/object/class_db.h"
|
||||
|
||||
Error StreamPeer::_put_data(const Vector<uint8_t> &p_data) {
|
||||
int len = p_data.size();
|
||||
|
|
@ -125,90 +126,54 @@ void StreamPeer::put_8(int8_t p_val) {
|
|||
}
|
||||
|
||||
void StreamPeer::put_u16(uint16_t p_val) {
|
||||
#ifdef BIG_ENDIAN_ENABLED
|
||||
if (!big_endian) {
|
||||
p_val = BSWAP16(p_val);
|
||||
}
|
||||
#else
|
||||
if (big_endian) {
|
||||
p_val = BSWAP16(p_val);
|
||||
}
|
||||
#endif
|
||||
uint8_t buf[2];
|
||||
encode_uint16(p_val, buf);
|
||||
put_data(buf, 2);
|
||||
}
|
||||
|
||||
void StreamPeer::put_16(int16_t p_val) {
|
||||
#ifdef BIG_ENDIAN_ENABLED
|
||||
if (!big_endian) {
|
||||
p_val = BSWAP16(p_val);
|
||||
}
|
||||
#else
|
||||
if (big_endian) {
|
||||
p_val = BSWAP16(p_val);
|
||||
}
|
||||
#endif
|
||||
uint8_t buf[2];
|
||||
encode_uint16(p_val, buf);
|
||||
put_data(buf, 2);
|
||||
}
|
||||
|
||||
void StreamPeer::put_u32(uint32_t p_val) {
|
||||
#ifdef BIG_ENDIAN_ENABLED
|
||||
if (!big_endian) {
|
||||
p_val = BSWAP32(p_val);
|
||||
}
|
||||
#else
|
||||
if (big_endian) {
|
||||
p_val = BSWAP32(p_val);
|
||||
}
|
||||
#endif
|
||||
uint8_t buf[4];
|
||||
encode_uint32(p_val, buf);
|
||||
put_data(buf, 4);
|
||||
}
|
||||
|
||||
void StreamPeer::put_32(int32_t p_val) {
|
||||
#ifdef BIG_ENDIAN_ENABLED
|
||||
if (!big_endian) {
|
||||
p_val = BSWAP32(p_val);
|
||||
}
|
||||
#else
|
||||
if (big_endian) {
|
||||
p_val = BSWAP32(p_val);
|
||||
}
|
||||
#endif
|
||||
uint8_t buf[4];
|
||||
encode_uint32(p_val, buf);
|
||||
put_data(buf, 4);
|
||||
}
|
||||
|
||||
void StreamPeer::put_u64(uint64_t p_val) {
|
||||
#ifdef BIG_ENDIAN_ENABLED
|
||||
if (!big_endian) {
|
||||
p_val = BSWAP64(p_val);
|
||||
}
|
||||
#else
|
||||
if (big_endian) {
|
||||
p_val = BSWAP64(p_val);
|
||||
}
|
||||
#endif
|
||||
uint8_t buf[8];
|
||||
encode_uint64(p_val, buf);
|
||||
put_data(buf, 8);
|
||||
}
|
||||
|
||||
void StreamPeer::put_64(int64_t p_val) {
|
||||
#ifdef BIG_ENDIAN_ENABLED
|
||||
if (!big_endian) {
|
||||
p_val = BSWAP64(p_val);
|
||||
}
|
||||
#else
|
||||
if (big_endian) {
|
||||
p_val = BSWAP64(p_val);
|
||||
}
|
||||
#endif
|
||||
uint8_t buf[8];
|
||||
encode_uint64(p_val, buf);
|
||||
put_data(buf, 8);
|
||||
|
|
@ -219,15 +184,9 @@ void StreamPeer::put_half(float p_val) {
|
|||
|
||||
encode_half(p_val, buf);
|
||||
uint16_t *p16 = (uint16_t *)buf;
|
||||
#ifdef BIG_ENDIAN_ENABLED
|
||||
if (!big_endian) {
|
||||
*p16 = BSWAP16(*p16);
|
||||
}
|
||||
#else
|
||||
if (big_endian) {
|
||||
*p16 = BSWAP16(*p16);
|
||||
}
|
||||
#endif
|
||||
|
||||
put_data(buf, 2);
|
||||
}
|
||||
|
|
@ -236,17 +195,10 @@ void StreamPeer::put_float(float p_val) {
|
|||
uint8_t buf[4];
|
||||
|
||||
encode_float(p_val, buf);
|
||||
#ifdef BIG_ENDIAN_ENABLED
|
||||
if (!big_endian) {
|
||||
uint32_t *p32 = (uint32_t *)buf;
|
||||
*p32 = BSWAP32(*p32);
|
||||
}
|
||||
#else
|
||||
if (big_endian) {
|
||||
uint32_t *p32 = (uint32_t *)buf;
|
||||
*p32 = BSWAP32(*p32);
|
||||
}
|
||||
#endif
|
||||
|
||||
put_data(buf, 4);
|
||||
}
|
||||
|
|
@ -255,17 +207,10 @@ void StreamPeer::put_double(double p_val) {
|
|||
uint8_t buf[8];
|
||||
|
||||
encode_double(p_val, buf);
|
||||
#ifdef BIG_ENDIAN_ENABLED
|
||||
if (!big_endian) {
|
||||
uint64_t *p64 = (uint64_t *)buf;
|
||||
*p64 = BSWAP64(*p64);
|
||||
}
|
||||
#else
|
||||
if (big_endian) {
|
||||
uint64_t *p64 = (uint64_t *)buf;
|
||||
*p64 = BSWAP64(*p64);
|
||||
}
|
||||
#endif
|
||||
|
||||
put_data(buf, 8);
|
||||
}
|
||||
|
|
@ -309,15 +254,9 @@ uint16_t StreamPeer::get_u16() {
|
|||
get_data(buf, 2);
|
||||
|
||||
uint16_t r = decode_uint16(buf);
|
||||
#ifdef BIG_ENDIAN_ENABLED
|
||||
if (!big_endian) {
|
||||
r = BSWAP16(r);
|
||||
}
|
||||
#else
|
||||
if (big_endian) {
|
||||
r = BSWAP16(r);
|
||||
}
|
||||
#endif
|
||||
|
||||
return r;
|
||||
}
|
||||
|
|
@ -327,15 +266,9 @@ int16_t StreamPeer::get_16() {
|
|||
get_data(buf, 2);
|
||||
|
||||
uint16_t r = decode_uint16(buf);
|
||||
#ifdef BIG_ENDIAN_ENABLED
|
||||
if (!big_endian) {
|
||||
r = BSWAP16(r);
|
||||
}
|
||||
#else
|
||||
if (big_endian) {
|
||||
r = BSWAP16(r);
|
||||
}
|
||||
#endif
|
||||
|
||||
return int16_t(r);
|
||||
}
|
||||
|
|
@ -345,15 +278,9 @@ uint32_t StreamPeer::get_u32() {
|
|||
get_data(buf, 4);
|
||||
|
||||
uint32_t r = decode_uint32(buf);
|
||||
#ifdef BIG_ENDIAN_ENABLED
|
||||
if (!big_endian) {
|
||||
r = BSWAP32(r);
|
||||
}
|
||||
#else
|
||||
if (big_endian) {
|
||||
r = BSWAP32(r);
|
||||
}
|
||||
#endif
|
||||
|
||||
return r;
|
||||
}
|
||||
|
|
@ -363,15 +290,9 @@ int32_t StreamPeer::get_32() {
|
|||
get_data(buf, 4);
|
||||
|
||||
uint32_t r = decode_uint32(buf);
|
||||
#ifdef BIG_ENDIAN_ENABLED
|
||||
if (!big_endian) {
|
||||
r = BSWAP32(r);
|
||||
}
|
||||
#else
|
||||
if (big_endian) {
|
||||
r = BSWAP32(r);
|
||||
}
|
||||
#endif
|
||||
|
||||
return int32_t(r);
|
||||
}
|
||||
|
|
@ -381,15 +302,9 @@ uint64_t StreamPeer::get_u64() {
|
|||
get_data(buf, 8);
|
||||
|
||||
uint64_t r = decode_uint64(buf);
|
||||
#ifdef BIG_ENDIAN_ENABLED
|
||||
if (!big_endian) {
|
||||
r = BSWAP64(r);
|
||||
}
|
||||
#else
|
||||
if (big_endian) {
|
||||
r = BSWAP64(r);
|
||||
}
|
||||
#endif
|
||||
|
||||
return r;
|
||||
}
|
||||
|
|
@ -399,15 +314,9 @@ int64_t StreamPeer::get_64() {
|
|||
get_data(buf, 8);
|
||||
|
||||
uint64_t r = decode_uint64(buf);
|
||||
#ifdef BIG_ENDIAN_ENABLED
|
||||
if (!big_endian) {
|
||||
r = BSWAP64(r);
|
||||
}
|
||||
#else
|
||||
if (big_endian) {
|
||||
r = BSWAP64(r);
|
||||
}
|
||||
#endif
|
||||
|
||||
return int64_t(r);
|
||||
}
|
||||
|
|
@ -416,17 +325,10 @@ float StreamPeer::get_half() {
|
|||
uint8_t buf[2];
|
||||
get_data(buf, 2);
|
||||
|
||||
#ifdef BIG_ENDIAN_ENABLED
|
||||
if (!big_endian) {
|
||||
uint16_t *p16 = (uint16_t *)buf;
|
||||
*p16 = BSWAP16(*p16);
|
||||
}
|
||||
#else
|
||||
if (big_endian) {
|
||||
uint16_t *p16 = (uint16_t *)buf;
|
||||
*p16 = BSWAP16(*p16);
|
||||
}
|
||||
#endif
|
||||
|
||||
return decode_half(buf);
|
||||
}
|
||||
|
|
@ -435,17 +337,10 @@ float StreamPeer::get_float() {
|
|||
uint8_t buf[4];
|
||||
get_data(buf, 4);
|
||||
|
||||
#ifdef BIG_ENDIAN_ENABLED
|
||||
if (!big_endian) {
|
||||
uint32_t *p32 = (uint32_t *)buf;
|
||||
*p32 = BSWAP32(*p32);
|
||||
}
|
||||
#else
|
||||
if (big_endian) {
|
||||
uint32_t *p32 = (uint32_t *)buf;
|
||||
*p32 = BSWAP32(*p32);
|
||||
}
|
||||
#endif
|
||||
|
||||
return decode_float(buf);
|
||||
}
|
||||
|
|
@ -454,17 +349,10 @@ double StreamPeer::get_double() {
|
|||
uint8_t buf[8];
|
||||
get_data(buf, 8);
|
||||
|
||||
#ifdef BIG_ENDIAN_ENABLED
|
||||
if (!big_endian) {
|
||||
uint64_t *p64 = (uint64_t *)buf;
|
||||
*p64 = BSWAP64(*p64);
|
||||
}
|
||||
#else
|
||||
if (big_endian) {
|
||||
uint64_t *p64 = (uint64_t *)buf;
|
||||
*p64 = BSWAP64(*p64);
|
||||
}
|
||||
#endif
|
||||
|
||||
return decode_double(buf);
|
||||
}
|
||||
|
|
@ -602,8 +490,8 @@ Error StreamPeerExtension::put_partial_data(const uint8_t *p_data, int p_bytes,
|
|||
void StreamPeerExtension::_bind_methods() {
|
||||
GDVIRTUAL_BIND(_get_data, "r_buffer", "r_bytes", "r_received");
|
||||
GDVIRTUAL_BIND(_get_partial_data, "r_buffer", "r_bytes", "r_received");
|
||||
GDVIRTUAL_BIND(_put_data, "p_data", "p_bytes", "r_sent");
|
||||
GDVIRTUAL_BIND(_put_partial_data, "p_data", "p_bytes", "r_sent");
|
||||
GDVIRTUAL_BIND(_put_data, "data", "bytes", "r_sent");
|
||||
GDVIRTUAL_BIND(_put_partial_data, "data", "bytes", "r_sent");
|
||||
GDVIRTUAL_BIND(_get_available_bytes);
|
||||
}
|
||||
|
||||
|
|
@ -705,7 +593,7 @@ void StreamPeerBuffer::set_data_array(const Vector<uint8_t> &p_data) {
|
|||
pointer = 0;
|
||||
}
|
||||
|
||||
Vector<uint8_t> StreamPeerBuffer::get_data_array() const {
|
||||
const Vector<uint8_t> &StreamPeerBuffer::get_data_array() const {
|
||||
return data;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue