diff --git a/modules/gdnative/gdnative_api.json b/modules/gdnative/gdnative_api.json index bdcd51085ff..71e7eecd1d5 100644 --- a/modules/gdnative/gdnative_api.json +++ b/modules/gdnative/gdnative_api.json @@ -6419,6 +6419,41 @@ ] } ] + }, + { + "name": "net", + "type": "NET", + "version": { + "major": 3, + "minor": 1 + }, + "next": null, + "api": [ + { + "name": "godot_net_bind_stream_peer", + "return_type": "void", + "arguments": [ + ["godot_object *", "p_obj"], + ["const godot_net_stream_peer *", "p_interface"] + ] + }, + { + "name": "godot_net_bind_packet_peer", + "return_type": "void", + "arguments": [ + ["godot_object *", "p_obj"], + ["const godot_net_packet_peer *", "p_interface"] + ] + }, + { + "name": "godot_net_bind_multiplayer_peer", + "return_type": "void", + "arguments": [ + ["godot_object *", "p_obj"], + ["const godot_net_multiplayer_peer *", "p_interface"] + ] + } + ] } ] } diff --git a/modules/gdnative/gdnative_builders.py b/modules/gdnative/gdnative_builders.py index 5fd5971fd1b..7ab0e011087 100644 --- a/modules/gdnative/gdnative_builders.py +++ b/modules/gdnative/gdnative_builders.py @@ -45,6 +45,7 @@ def _build_gdnative_api_struct_header(api): '#include ', '#include ', '#include ', + '#include ', '#include ', '#include ', '', diff --git a/modules/gdnative/include/net/godot_net.h b/modules/gdnative/include/net/godot_net.h index 89e27719262..d7de04e725d 100644 --- a/modules/gdnative/include/net/godot_net.h +++ b/modules/gdnative/include/net/godot_net.h @@ -51,9 +51,9 @@ typedef struct { /* This is StreamPeer */ godot_error (*get_data)(void *user, uint8_t *p_buffer, int p_bytes); - godot_error (*get_partial_data)(void *user, uint8_t *p_buffer, int p_bytes, int &r_received); + godot_error (*get_partial_data)(void *user, uint8_t *p_buffer, int p_bytes, int *r_received); godot_error (*put_data)(void *user, const uint8_t *p_data, int p_bytes); - godot_error (*put_partial_data)(void *user, const uint8_t *p_data, int p_bytes, int &r_sent); + godot_error (*put_partial_data)(void *user, const uint8_t *p_data, int p_bytes, int *r_sent); int (*get_available_bytes)(const void *user); @@ -61,7 +61,7 @@ typedef struct { } godot_net_stream_peer; /* Binds a StreamPeerGDNative to the provided interface */ -void godot_net_bind_stream_peer(godot_object *p_obj, godot_net_stream_peer *p_interface); +void godot_net_bind_stream_peer(godot_object *p_obj, const godot_net_stream_peer *p_interface); typedef struct { godot_gdnative_api_version version; /* version of our API */ @@ -69,7 +69,7 @@ typedef struct { godot_object *data; /* User reference */ /* This is PacketPeer */ - godot_error (*get_packet)(void *, const uint8_t **, int &); + godot_error (*get_packet)(void *, const uint8_t **, int *); godot_error (*put_packet)(void *, const uint8_t *, int); godot_int (*get_available_packet_count)(const void *); godot_int (*get_max_packet_size)(const void *); @@ -86,7 +86,7 @@ typedef struct { godot_object *data; /* User reference */ /* This is PacketPeer */ - godot_error (*get_packet)(void *, const uint8_t **, int &); + godot_error (*get_packet)(void *, const uint8_t **, int *); godot_error (*put_packet)(void *, const uint8_t *, int); godot_int (*get_available_packet_count)(const void *); godot_int (*get_max_packet_size)(const void *); diff --git a/modules/gdnative/net/multiplayer_peer_gdnative.cpp b/modules/gdnative/net/multiplayer_peer_gdnative.cpp index 24668383574..bdeba149d2f 100644 --- a/modules/gdnative/net/multiplayer_peer_gdnative.cpp +++ b/modules/gdnative/net/multiplayer_peer_gdnative.cpp @@ -43,7 +43,7 @@ void MultiplayerPeerGDNative::set_native_multiplayer_peer(const godot_net_multip Error MultiplayerPeerGDNative::get_packet(const uint8_t **r_buffer, int &r_buffer_size) { ERR_FAIL_COND_V(interface == NULL, ERR_UNCONFIGURED); - return (Error)interface->get_packet(interface->data, r_buffer, r_buffer_size); + return (Error)interface->get_packet(interface->data, r_buffer, &r_buffer_size); } Error MultiplayerPeerGDNative::put_packet(const uint8_t *p_buffer, int p_buffer_size) { diff --git a/modules/gdnative/net/packet_peer_gdnative.cpp b/modules/gdnative/net/packet_peer_gdnative.cpp index 9adfd841b29..877baff9e22 100644 --- a/modules/gdnative/net/packet_peer_gdnative.cpp +++ b/modules/gdnative/net/packet_peer_gdnative.cpp @@ -46,7 +46,7 @@ void PacketPeerGDNative::_bind_methods() { Error PacketPeerGDNative::get_packet(const uint8_t **r_buffer, int &r_buffer_size) { ERR_FAIL_COND_V(interface == NULL, ERR_UNCONFIGURED); - return (Error)interface->get_packet(interface->data, r_buffer, r_buffer_size); + return (Error)interface->get_packet(interface->data, r_buffer, &r_buffer_size); } Error PacketPeerGDNative::put_packet(const uint8_t *p_buffer, int p_buffer_size) { diff --git a/modules/gdnative/net/stream_peer_gdnative.cpp b/modules/gdnative/net/stream_peer_gdnative.cpp index 1b141fa2e6f..8a4ea35f955 100644 --- a/modules/gdnative/net/stream_peer_gdnative.cpp +++ b/modules/gdnative/net/stream_peer_gdnative.cpp @@ -37,7 +37,7 @@ StreamPeerGDNative::StreamPeerGDNative() { StreamPeerGDNative::~StreamPeerGDNative() { } -void StreamPeerGDNative::set_native_stream_peer(godot_net_stream_peer *p_interface) { +void StreamPeerGDNative::set_native_stream_peer(const godot_net_stream_peer *p_interface) { interface = p_interface; } @@ -51,7 +51,7 @@ Error StreamPeerGDNative::put_data(const uint8_t *p_data, int p_bytes) { Error StreamPeerGDNative::put_partial_data(const uint8_t *p_data, int p_bytes, int &r_sent) { ERR_FAIL_COND_V(interface == NULL, ERR_UNCONFIGURED); - return (Error)(interface->put_partial_data(interface->data, p_data, p_bytes, r_sent)); + return (Error)(interface->put_partial_data(interface->data, p_data, p_bytes, &r_sent)); } Error StreamPeerGDNative::get_data(uint8_t *p_buffer, int p_bytes) { @@ -61,7 +61,7 @@ Error StreamPeerGDNative::get_data(uint8_t *p_buffer, int p_bytes) { Error StreamPeerGDNative::get_partial_data(uint8_t *p_buffer, int p_bytes, int &r_received) { ERR_FAIL_COND_V(interface == NULL, ERR_UNCONFIGURED); - return (Error)(interface->get_partial_data(interface->data, p_buffer, p_bytes, r_received)); + return (Error)(interface->get_partial_data(interface->data, p_buffer, p_bytes, &r_received)); } int StreamPeerGDNative::get_available_bytes() const { @@ -71,7 +71,7 @@ int StreamPeerGDNative::get_available_bytes() const { extern "C" { -void GDAPI godot_net_bind_stream_peer(godot_object *p_obj, godot_net_stream_peer *p_interface) { +void GDAPI godot_net_bind_stream_peer(godot_object *p_obj, const godot_net_stream_peer *p_interface) { ((StreamPeerGDNative *)p_obj)->set_native_stream_peer(p_interface); } } diff --git a/modules/gdnative/net/stream_peer_gdnative.h b/modules/gdnative/net/stream_peer_gdnative.h index f39fdbb1d3e..7859d57a4b8 100644 --- a/modules/gdnative/net/stream_peer_gdnative.h +++ b/modules/gdnative/net/stream_peer_gdnative.h @@ -41,14 +41,14 @@ class StreamPeerGDNative : public StreamPeer { protected: static void _bind_methods(); - godot_net_stream_peer *interface; + const godot_net_stream_peer *interface; public: StreamPeerGDNative(); ~StreamPeerGDNative(); /* Sets the interface implementation from GDNative */ - void set_native_stream_peer(godot_net_stream_peer *p_interface); + void set_native_stream_peer(const godot_net_stream_peer *p_interface); /* Specific to StreamPeer */ Error put_data(const uint8_t *p_data, int p_bytes);