aboutsummaryrefslogtreecommitdiff
path: root/core/io
diff options
context:
space:
mode:
Diffstat (limited to 'core/io')
-rw-r--r--core/io/config_file.cpp6
-rw-r--r--core/io/file_access_pack.cpp7
-rw-r--r--core/io/http_client.cpp10
-rw-r--r--core/io/packet_peer.cpp40
-rw-r--r--core/io/packet_peer.h4
-rw-r--r--core/io/packet_peer_udp.cpp4
-rw-r--r--core/io/resource_import.h6
-rw-r--r--core/io/resource_loader.cpp2
-rw-r--r--core/io/stream_peer.cpp6
-rw-r--r--core/io/stream_peer_ssl.cpp4
-rw-r--r--core/io/tcp_server.cpp2
11 files changed, 50 insertions, 41 deletions
diff --git a/core/io/config_file.cpp b/core/io/config_file.cpp
index 406789906..edd090adf 100644
--- a/core/io/config_file.cpp
+++ b/core/io/config_file.cpp
@@ -205,7 +205,7 @@ Error ConfigFile::load(const String &p_path) {
void ConfigFile::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_value", "section", "key", "value"), &ConfigFile::set_value);
- ClassDB::bind_method(D_METHOD("get_value:Variant", "section", "key", "default"), &ConfigFile::get_value, DEFVAL(Variant()));
+ ClassDB::bind_method(D_METHOD("get_value", "section", "key", "default"), &ConfigFile::get_value, DEFVAL(Variant()));
ClassDB::bind_method(D_METHOD("has_section", "section"), &ConfigFile::has_section);
ClassDB::bind_method(D_METHOD("has_section_key", "section", "key"), &ConfigFile::has_section_key);
@@ -215,8 +215,8 @@ void ConfigFile::_bind_methods() {
ClassDB::bind_method(D_METHOD("erase_section", "section"), &ConfigFile::erase_section);
- ClassDB::bind_method(D_METHOD("load:Error", "path"), &ConfigFile::load);
- ClassDB::bind_method(D_METHOD("save:Error", "path"), &ConfigFile::save);
+ ClassDB::bind_method(D_METHOD("load", "path"), &ConfigFile::load);
+ ClassDB::bind_method(D_METHOD("save", "path"), &ConfigFile::save);
}
ConfigFile::ConfigFile() {
diff --git a/core/io/file_access_pack.cpp b/core/io/file_access_pack.cpp
index 79aa39521..c3bcfc840 100644
--- a/core/io/file_access_pack.cpp
+++ b/core/io/file_access_pack.cpp
@@ -308,10 +308,9 @@ bool FileAccessPack::file_exists(const String &p_name) {
return false;
}
-FileAccessPack::FileAccessPack(const String &p_path, const PackedData::PackedFile &p_file) {
-
- pf = p_file;
- f = FileAccess::open(pf.pack, FileAccess::READ);
+FileAccessPack::FileAccessPack(const String &p_path, const PackedData::PackedFile &p_file)
+ : pf(p_file),
+ f(FileAccess::open(pf.pack, FileAccess::READ)) {
if (!f) {
ERR_EXPLAIN("Can't open pack-referenced file: " + String(pf.pack));
ERR_FAIL_COND(!f);
diff --git a/core/io/http_client.cpp b/core/io/http_client.cpp
index 0c84a5213..4d5b88cfa 100644
--- a/core/io/http_client.cpp
+++ b/core/io/http_client.cpp
@@ -624,9 +624,9 @@ Error HTTPClient::_get_http_data(uint8_t *p_buffer, int p_bytes, int &r_received
void HTTPClient::_bind_methods() {
- ClassDB::bind_method(D_METHOD("connect_to_host:Error", "host", "port", "use_ssl", "verify_host"), &HTTPClient::connect_to_host, DEFVAL(false), DEFVAL(true));
- ClassDB::bind_method(D_METHOD("set_connection", "connection:StreamPeer"), &HTTPClient::set_connection);
- ClassDB::bind_method(D_METHOD("get_connection:StreamPeer"), &HTTPClient::get_connection);
+ ClassDB::bind_method(D_METHOD("connect_to_host", "host", "port", "use_ssl", "verify_host"), &HTTPClient::connect_to_host, DEFVAL(false), DEFVAL(true));
+ ClassDB::bind_method(D_METHOD("set_connection", "connection"), &HTTPClient::set_connection);
+ ClassDB::bind_method(D_METHOD("get_connection"), &HTTPClient::get_connection);
ClassDB::bind_method(D_METHOD("request_raw", "method", "url", "headers", "body"), &HTTPClient::request_raw);
ClassDB::bind_method(D_METHOD("request", "method", "url", "headers", "body"), &HTTPClient::request, DEFVAL(String()));
ClassDB::bind_method(D_METHOD("send_body_text", "body"), &HTTPClient::send_body_text);
@@ -646,9 +646,9 @@ void HTTPClient::_bind_methods() {
ClassDB::bind_method(D_METHOD("is_blocking_mode_enabled"), &HTTPClient::is_blocking_mode_enabled);
ClassDB::bind_method(D_METHOD("get_status"), &HTTPClient::get_status);
- ClassDB::bind_method(D_METHOD("poll:Error"), &HTTPClient::poll);
+ ClassDB::bind_method(D_METHOD("poll"), &HTTPClient::poll);
- ClassDB::bind_method(D_METHOD("query_string_from_dict:String", "fields"), &HTTPClient::query_string_from_dict);
+ ClassDB::bind_method(D_METHOD("query_string_from_dict", "fields"), &HTTPClient::query_string_from_dict);
BIND_CONSTANT(METHOD_GET);
BIND_CONSTANT(METHOD_HEAD);
diff --git a/core/io/packet_peer.cpp b/core/io/packet_peer.cpp
index a3d33593d..c028d7d19 100644
--- a/core/io/packet_peer.cpp
+++ b/core/io/packet_peer.cpp
@@ -120,11 +120,11 @@ Error PacketPeer::_get_packet_error() const {
void PacketPeer::_bind_methods() {
- ClassDB::bind_method(D_METHOD("get_var:Variant"), &PacketPeer::_bnd_get_var);
- ClassDB::bind_method(D_METHOD("put_var", "var:Variant"), &PacketPeer::put_var);
+ ClassDB::bind_method(D_METHOD("get_var"), &PacketPeer::_bnd_get_var);
+ ClassDB::bind_method(D_METHOD("put_var", "var"), &PacketPeer::put_var);
ClassDB::bind_method(D_METHOD("get_packet"), &PacketPeer::_get_packet);
- ClassDB::bind_method(D_METHOD("put_packet:Error", "buffer"), &PacketPeer::_put_packet);
- ClassDB::bind_method(D_METHOD("get_packet_error:Error"), &PacketPeer::_get_packet_error);
+ ClassDB::bind_method(D_METHOD("put_packet", "buffer"), &PacketPeer::_put_packet);
+ ClassDB::bind_method(D_METHOD("get_packet_error"), &PacketPeer::_get_packet_error);
ClassDB::bind_method(D_METHOD("get_available_packet_count"), &PacketPeer::get_available_packet_count);
};
@@ -138,7 +138,9 @@ void PacketPeerStream::_set_stream_peer(REF p_peer) {
void PacketPeerStream::_bind_methods() {
- ClassDB::bind_method(D_METHOD("set_stream_peer", "peer:StreamPeer"), &PacketPeerStream::_set_stream_peer);
+ ClassDB::bind_method(D_METHOD("set_stream_peer", "peer"), &PacketPeerStream::_set_stream_peer);
+ ClassDB::bind_method(D_METHOD("set_input_buffer_max_size", "max_size_bytes"), &PacketPeerStream::set_input_buffer_max_size);
+ ClassDB::bind_method(D_METHOD("set_output_buffer_max_size", "max_size_bytes"), &PacketPeerStream::set_output_buffer_max_size);
}
Error PacketPeerStream::_poll_buffer() const {
@@ -146,13 +148,13 @@ Error PacketPeerStream::_poll_buffer() const {
ERR_FAIL_COND_V(peer.is_null(), ERR_UNCONFIGURED);
int read = 0;
- Error err = peer->get_partial_data(&temp_buffer[0], ring_buffer.space_left(), read);
+ Error err = peer->get_partial_data(&input_buffer[0], ring_buffer.space_left(), read);
if (err)
return err;
if (read == 0)
return OK;
- int w = ring_buffer.write(&temp_buffer[0], read);
+ int w = ring_buffer.write(&input_buffer[0], read);
ERR_FAIL_COND_V(w != read, ERR_BUG);
return OK;
@@ -198,9 +200,9 @@ Error PacketPeerStream::get_packet(const uint8_t **r_buffer, int &r_buffer_size)
ERR_FAIL_COND_V(remaining < (int)len, ERR_UNAVAILABLE);
ring_buffer.read(lbuf, 4); //get rid of first 4 bytes
- ring_buffer.read(&temp_buffer[0], len); // read packet
+ ring_buffer.read(&input_buffer[0], len); // read packet
- *r_buffer = &temp_buffer[0];
+ *r_buffer = &input_buffer[0];
r_buffer_size = len;
return OK;
}
@@ -217,19 +219,19 @@ Error PacketPeerStream::put_packet(const uint8_t *p_buffer, int p_buffer_size) {
return OK;
ERR_FAIL_COND_V(p_buffer_size < 0, ERR_INVALID_PARAMETER);
- ERR_FAIL_COND_V(p_buffer_size + 4 > temp_buffer.size(), ERR_INVALID_PARAMETER);
+ ERR_FAIL_COND_V(p_buffer_size + 4 > output_buffer.size(), ERR_INVALID_PARAMETER);
- encode_uint32(p_buffer_size, &temp_buffer[0]);
- uint8_t *dst = &temp_buffer[4];
+ encode_uint32(p_buffer_size, &output_buffer[0]);
+ uint8_t *dst = &output_buffer[4];
for (int i = 0; i < p_buffer_size; i++)
dst[i] = p_buffer[i];
- return peer->put_data(&temp_buffer[0], p_buffer_size + 4);
+ return peer->put_data(&output_buffer[0], p_buffer_size + 4);
}
int PacketPeerStream::get_max_packet_size() const {
- return temp_buffer.size();
+ return output_buffer.size();
}
void PacketPeerStream::set_stream_peer(const Ref<StreamPeer> &p_peer) {
@@ -249,7 +251,12 @@ void PacketPeerStream::set_input_buffer_max_size(int p_max_size) {
ERR_EXPLAIN("Buffer in use, resizing would cause loss of data");
ERR_FAIL_COND(ring_buffer.data_left());
ring_buffer.resize(nearest_shift(p_max_size + 4));
- temp_buffer.resize(nearest_power_of_2(p_max_size + 4));
+ input_buffer.resize(nearest_power_of_2(p_max_size + 4));
+}
+
+void PacketPeerStream::set_output_buffer_max_size(int p_max_size) {
+
+ output_buffer.resize(nearest_power_of_2(p_max_size + 4));
}
PacketPeerStream::PacketPeerStream() {
@@ -257,5 +264,6 @@ PacketPeerStream::PacketPeerStream() {
int rbsize = GLOBAL_GET("network/limits/packet_peer_stream/max_buffer_po2");
ring_buffer.resize(rbsize);
- temp_buffer.resize(1 << rbsize);
+ input_buffer.resize(1 << rbsize);
+ output_buffer.resize(1 << rbsize);
}
diff --git a/core/io/packet_peer.h b/core/io/packet_peer.h
index 95806aa51..ed6b252d8 100644
--- a/core/io/packet_peer.h
+++ b/core/io/packet_peer.h
@@ -75,7 +75,8 @@ class PacketPeerStream : public PacketPeer {
mutable Ref<StreamPeer> peer;
mutable RingBuffer<uint8_t> ring_buffer;
- mutable Vector<uint8_t> temp_buffer;
+ mutable Vector<uint8_t> input_buffer;
+ mutable Vector<uint8_t> output_buffer;
Error _poll_buffer() const;
@@ -92,6 +93,7 @@ public:
void set_stream_peer(const Ref<StreamPeer> &p_peer);
void set_input_buffer_max_size(int p_max_size);
+ void set_output_buffer_max_size(int p_max_size);
PacketPeerStream();
};
diff --git a/core/io/packet_peer_udp.cpp b/core/io/packet_peer_udp.cpp
index 8bc3241cc..d1729819a 100644
--- a/core/io/packet_peer_udp.cpp
+++ b/core/io/packet_peer_udp.cpp
@@ -59,9 +59,9 @@ Error PacketPeerUDP::_set_dest_address(const String &p_address, int p_port) {
void PacketPeerUDP::_bind_methods() {
- ClassDB::bind_method(D_METHOD("listen:Error", "port", "bind_address", "recv_buf_size"), &PacketPeerUDP::listen, DEFVAL("*"), DEFVAL(65536));
+ ClassDB::bind_method(D_METHOD("listen", "port", "bind_address", "recv_buf_size"), &PacketPeerUDP::listen, DEFVAL("*"), DEFVAL(65536));
ClassDB::bind_method(D_METHOD("close"), &PacketPeerUDP::close);
- ClassDB::bind_method(D_METHOD("wait:Error"), &PacketPeerUDP::wait);
+ ClassDB::bind_method(D_METHOD("wait"), &PacketPeerUDP::wait);
ClassDB::bind_method(D_METHOD("is_listening"), &PacketPeerUDP::is_listening);
ClassDB::bind_method(D_METHOD("get_packet_ip"), &PacketPeerUDP::_get_packet_ip);
//ClassDB::bind_method(D_METHOD("get_packet_address"),&PacketPeerUDP::_get_packet_address);
diff --git a/core/io/resource_import.h b/core/io/resource_import.h
index 9d2a5180d..d3f98cbc0 100644
--- a/core/io/resource_import.h
+++ b/core/io/resource_import.h
@@ -85,9 +85,9 @@ public:
PropertyInfo option;
Variant default_value;
- ImportOption(const PropertyInfo &p_info, const Variant &p_default) {
- option = p_info;
- default_value = p_default;
+ ImportOption(const PropertyInfo &p_info, const Variant &p_default)
+ : option(p_info),
+ default_value(p_default) {
}
ImportOption() {}
};
diff --git a/core/io/resource_loader.cpp b/core/io/resource_loader.cpp
index 9b89fa339..5347cd6ee 100644
--- a/core/io/resource_loader.cpp
+++ b/core/io/resource_loader.cpp
@@ -84,7 +84,7 @@ void ResourceLoader::get_recognized_extensions_for_type(const String &p_type, Li
void ResourceInteractiveLoader::_bind_methods() {
- ClassDB::bind_method(D_METHOD("get_resource:Resource"), &ResourceInteractiveLoader::get_resource);
+ ClassDB::bind_method(D_METHOD("get_resource"), &ResourceInteractiveLoader::get_resource);
ClassDB::bind_method(D_METHOD("poll"), &ResourceInteractiveLoader::poll);
ClassDB::bind_method(D_METHOD("wait"), &ResourceInteractiveLoader::wait);
ClassDB::bind_method(D_METHOD("get_stage"), &ResourceInteractiveLoader::get_stage);
diff --git a/core/io/stream_peer.cpp b/core/io/stream_peer.cpp
index 0dbcb3cf5..fdad7c7bd 100644
--- a/core/io/stream_peer.cpp
+++ b/core/io/stream_peer.cpp
@@ -385,7 +385,7 @@ void StreamPeer::_bind_methods() {
ClassDB::bind_method(D_METHOD("put_float", "val"), &StreamPeer::put_float);
ClassDB::bind_method(D_METHOD("put_double", "val"), &StreamPeer::put_double);
ClassDB::bind_method(D_METHOD("put_utf8_string", "val"), &StreamPeer::put_utf8_string);
- ClassDB::bind_method(D_METHOD("put_var", "val:Variant"), &StreamPeer::put_var);
+ ClassDB::bind_method(D_METHOD("put_var", "val"), &StreamPeer::put_var);
ClassDB::bind_method(D_METHOD("get_8"), &StreamPeer::get_8);
ClassDB::bind_method(D_METHOD("get_u8"), &StreamPeer::get_u8);
@@ -399,7 +399,7 @@ void StreamPeer::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_double"), &StreamPeer::get_double);
ClassDB::bind_method(D_METHOD("get_string", "bytes"), &StreamPeer::get_string);
ClassDB::bind_method(D_METHOD("get_utf8_string", "bytes"), &StreamPeer::get_utf8_string);
- ClassDB::bind_method(D_METHOD("get_var:Variant"), &StreamPeer::get_var);
+ ClassDB::bind_method(D_METHOD("get_var"), &StreamPeer::get_var);
}
////////////////////////////////
@@ -412,7 +412,7 @@ void StreamPeerBuffer::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_data_array", "data"), &StreamPeerBuffer::set_data_array);
ClassDB::bind_method(D_METHOD("get_data_array"), &StreamPeerBuffer::get_data_array);
ClassDB::bind_method(D_METHOD("clear"), &StreamPeerBuffer::clear);
- ClassDB::bind_method(D_METHOD("duplicate:StreamPeerBuffer"), &StreamPeerBuffer::duplicate);
+ ClassDB::bind_method(D_METHOD("duplicate"), &StreamPeerBuffer::duplicate);
}
Error StreamPeerBuffer::put_data(const uint8_t *p_data, int p_bytes) {
diff --git a/core/io/stream_peer_ssl.cpp b/core/io/stream_peer_ssl.cpp
index 57cffd073..ef3c26437 100644
--- a/core/io/stream_peer_ssl.cpp
+++ b/core/io/stream_peer_ssl.cpp
@@ -51,8 +51,8 @@ bool StreamPeerSSL::is_available() {
void StreamPeerSSL::_bind_methods() {
- ClassDB::bind_method(D_METHOD("accept_stream:Error", "stream:StreamPeer"), &StreamPeerSSL::accept_stream);
- ClassDB::bind_method(D_METHOD("connect_to_stream:Error", "stream:StreamPeer", "validate_certs", "for_hostname"), &StreamPeerSSL::connect_to_stream, DEFVAL(false), DEFVAL(String()));
+ ClassDB::bind_method(D_METHOD("accept_stream", "stream"), &StreamPeerSSL::accept_stream);
+ ClassDB::bind_method(D_METHOD("connect_to_stream", "stream", "validate_certs", "for_hostname"), &StreamPeerSSL::connect_to_stream, DEFVAL(false), DEFVAL(String()));
ClassDB::bind_method(D_METHOD("get_status"), &StreamPeerSSL::get_status);
ClassDB::bind_method(D_METHOD("disconnect_from_stream"), &StreamPeerSSL::disconnect_from_stream);
BIND_CONSTANT(STATUS_DISCONNECTED);
diff --git a/core/io/tcp_server.cpp b/core/io/tcp_server.cpp
index 4c891188e..29a80ecc1 100644
--- a/core/io/tcp_server.cpp
+++ b/core/io/tcp_server.cpp
@@ -49,7 +49,7 @@ void TCP_Server::_bind_methods() {
ClassDB::bind_method(D_METHOD("listen", "port", "bind_address"), &TCP_Server::listen, DEFVAL("*"));
ClassDB::bind_method(D_METHOD("is_connection_available"), &TCP_Server::is_connection_available);
- ClassDB::bind_method(D_METHOD("take_connection:StreamPeerTCP"), &TCP_Server::take_connection);
+ ClassDB::bind_method(D_METHOD("take_connection"), &TCP_Server::take_connection);
ClassDB::bind_method(D_METHOD("stop"), &TCP_Server::stop);
}