Fixing C compatiblity for GDNative NET module
Also add net interfaces to gdnative_api.json
This commit is contained in:
parent
61b41d6001
commit
f112f5785b
7 changed files with 49 additions and 13 deletions
|
@ -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"]
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
|
|
|
@ -45,6 +45,7 @@ def _build_gdnative_api_struct_header(api):
|
|||
'#include <android/godot_android.h>',
|
||||
'#include <arvr/godot_arvr.h>',
|
||||
'#include <nativescript/godot_nativescript.h>',
|
||||
'#include <net/godot_net.h>',
|
||||
'#include <pluginscript/godot_pluginscript.h>',
|
||||
'#include <videodecoder/godot_videodecoder.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 *);
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Reference in a new issue