summaryrefslogtreecommitdiff
path: root/core
diff options
context:
space:
mode:
authorFabio Alessandrelli <fabio.alessandrelli@gmail.com>2016-12-01 06:34:05 +0100
committerFabio Alessandrelli <fabio.alessandrelli@gmail.com>2016-12-09 18:24:59 +0100
commitc18c5013f837ea7d4de2f022d36f84e0abce6439 (patch)
treef21627a04256241523f6ca10d848cf89fd5fd12b /core
parent4d90a4fcd5fcdca42df47062f94a1fa4e5635a94 (diff)
Migrate int.IP_TYPE_ constants to IP.TYPE_
Diffstat (limited to 'core')
-rw-r--r--core/io/http_client.cpp6
-rw-r--r--core/io/http_client.h2
-rw-r--r--core/io/ip.cpp17
-rw-r--r--core/io/ip.h18
-rw-r--r--core/io/packet_peer_udp.cpp4
-rw-r--r--core/io/packet_peer_udp.h3
-rw-r--r--core/io/stream_peer_tcp.cpp4
-rw-r--r--core/io/stream_peer_tcp.h2
-rw-r--r--core/io/tcp_server.cpp4
-rw-r--r--core/io/tcp_server.h2
-rw-r--r--core/variant_call.cpp4
11 files changed, 30 insertions, 36 deletions
diff --git a/core/io/http_client.cpp b/core/io/http_client.cpp
index e3289b452c..c9c674d4f0 100644
--- a/core/io/http_client.cpp
+++ b/core/io/http_client.cpp
@@ -29,9 +29,7 @@
#include "http_client.h"
#include "io/stream_peer_ssl.h"
-VARIANT_ENUM_CAST(IP_Address::AddrType);
-
-Error HTTPClient::connect(const String &p_host, int p_port, bool p_ssl,bool p_verify_host, IP_Address::AddrType p_addr_type){
+Error HTTPClient::connect(const String &p_host, int p_port, bool p_ssl,bool p_verify_host, IP::Type p_addr_type){
close();
conn_port=p_port;
@@ -636,7 +634,7 @@ Error HTTPClient::_get_http_data(uint8_t* p_buffer, int p_bytes,int &r_received)
void HTTPClient::_bind_methods() {
- ObjectTypeDB::bind_method(_MD("connect:Error","host","port","use_ssl","verify_host"),&HTTPClient::connect,DEFVAL(false),DEFVAL(true),DEFVAL(IP_Address::TYPE_ANY));
+ ObjectTypeDB::bind_method(_MD("connect:Error","host","port","use_ssl","verify_host"),&HTTPClient::connect,DEFVAL(false),DEFVAL(true),DEFVAL(IP::TYPE_ANY));
ObjectTypeDB::bind_method(_MD("set_connection","connection:StreamPeer"),&HTTPClient::set_connection);
ObjectTypeDB::bind_method(_MD("get_connection:StreamPeer"),&HTTPClient::get_connection);
ObjectTypeDB::bind_method(_MD("request_raw","method","url","headers","body"),&HTTPClient::request_raw);
diff --git a/core/io/http_client.h b/core/io/http_client.h
index ba464c34c7..34812616dd 100644
--- a/core/io/http_client.h
+++ b/core/io/http_client.h
@@ -165,7 +165,7 @@ public:
//Error connect_and_get(const String& p_url,bool p_verify_host=true); //connects to a full url and perform request
- Error connect(const String &p_host,int p_port,bool p_ssl=false,bool p_verify_host=true, IP_Address::AddrType p_addr_type = IP_Address::TYPE_ANY);
+ Error connect(const String &p_host,int p_port,bool p_ssl=false,bool p_verify_host=true, IP::Type p_addr_type = IP::TYPE_ANY);
void set_connection(const Ref<StreamPeer>& p_connection);
Ref<StreamPeer> get_connection() const;
diff --git a/core/io/ip.cpp b/core/io/ip.cpp
index f0f273af1a..00835c26d5 100644
--- a/core/io/ip.cpp
+++ b/core/io/ip.cpp
@@ -32,7 +32,6 @@
#include "hash_map.h"
VARIANT_ENUM_CAST(IP::ResolverStatus);
-VARIANT_ENUM_CAST(IP_Address::AddrType);
/************* RESOLVER ******************/
@@ -44,12 +43,12 @@ struct _IP_ResolverPrivate {
volatile IP::ResolverStatus status;
IP_Address response;
String hostname;
- IP_Address::AddrType type;
+ IP::Type type;
void clear() {
status = IP::RESOLVER_STATUS_NONE;
response = IP_Address();
- type = IP_Address::TYPE_NONE;
+ type = IP::TYPE_NONE;
hostname="";
};
@@ -112,7 +111,7 @@ struct _IP_ResolverPrivate {
-IP_Address IP::resolve_hostname(const String& p_hostname, IP_Address::AddrType p_type) {
+IP_Address IP::resolve_hostname(const String& p_hostname, IP::Type p_type) {
GLOBAL_LOCK_FUNCTION;
@@ -126,7 +125,7 @@ IP_Address IP::resolve_hostname(const String& p_hostname, IP_Address::AddrType p
return res;
}
-IP::ResolverID IP::resolve_hostname_queue_item(const String& p_hostname, IP_Address::AddrType p_type) {
+IP::ResolverID IP::resolve_hostname_queue_item(const String& p_hostname, IP::Type p_type) {
GLOBAL_LOCK_FUNCTION;
@@ -212,8 +211,8 @@ Array IP::_get_local_addresses() const {
void IP::_bind_methods() {
- ObjectTypeDB::bind_method(_MD("resolve_hostname","host","ip_type"),&IP::resolve_hostname,DEFVAL(IP_Address::TYPE_ANY));
- ObjectTypeDB::bind_method(_MD("resolve_hostname_queue_item","host","ip_type"),&IP::resolve_hostname_queue_item,DEFVAL(IP_Address::TYPE_ANY));
+ ObjectTypeDB::bind_method(_MD("resolve_hostname","host","ip_type"),&IP::resolve_hostname,DEFVAL(IP::TYPE_ANY));
+ ObjectTypeDB::bind_method(_MD("resolve_hostname_queue_item","host","ip_type"),&IP::resolve_hostname_queue_item,DEFVAL(IP::TYPE_ANY));
ObjectTypeDB::bind_method(_MD("get_resolve_item_status","id"),&IP::get_resolve_item_status);
ObjectTypeDB::bind_method(_MD("get_resolve_item_address","id"),&IP::get_resolve_item_address);
ObjectTypeDB::bind_method(_MD("erase_resolve_item","id"),&IP::erase_resolve_item);
@@ -228,6 +227,10 @@ void IP::_bind_methods() {
BIND_CONSTANT( RESOLVER_MAX_QUERIES );
BIND_CONSTANT( RESOLVER_INVALID_ID );
+ BIND_CONSTANT( TYPE_NONE );
+ BIND_CONSTANT( TYPE_IPV4 );
+ BIND_CONSTANT( TYPE_IPV6 );
+ BIND_CONSTANT( TYPE_ANY );
}
diff --git a/core/io/ip.h b/core/io/ip.h
index 742dd0e740..64360b9a76 100644
--- a/core/io/ip.h
+++ b/core/io/ip.h
@@ -48,12 +48,12 @@ public:
RESOLVER_STATUS_ERROR,
};
- enum AddressType {
+ enum Type {
- ADDRESS_IPV4 = 1,
- ADDRESS_IPV6 = 2,
-
- ADDRESS_ANY = 3,
+ TYPE_NONE = 0,
+ TYPE_IPV4 = 1,
+ TYPE_IPV6 = 2,
+ TYPE_ANY = 3,
};
enum {
@@ -73,7 +73,7 @@ protected:
static IP*singleton;
static void _bind_methods();
- virtual IP_Address _resolve_hostname(const String& p_hostname, IP_Address::AddrType p_type = IP_Address::TYPE_ANY)=0;
+ virtual IP_Address _resolve_hostname(const String& p_hostname, Type p_type = TYPE_ANY)=0;
Array _get_local_addresses() const;
static IP* (*_create)();
@@ -81,9 +81,9 @@ public:
- IP_Address resolve_hostname(const String& p_hostname, IP_Address::AddrType p_type = IP_Address::TYPE_ANY);
+ IP_Address resolve_hostname(const String& p_hostname, Type p_type = TYPE_ANY);
// async resolver hostname
- ResolverID resolve_hostname_queue_item(const String& p_hostname, IP_Address::AddrType p_type = IP_Address::TYPE_ANY);
+ ResolverID resolve_hostname_queue_item(const String& p_hostname, Type p_type = TYPE_ANY);
ResolverStatus get_resolve_item_status(ResolverID p_id) const;
IP_Address get_resolve_item_address(ResolverID p_id) const;
virtual void get_local_addresses(List<IP_Address> *r_addresses) const=0;
@@ -101,4 +101,6 @@ public:
};
+VARIANT_ENUM_CAST(IP::Type);
+
#endif // IP_H
diff --git a/core/io/packet_peer_udp.cpp b/core/io/packet_peer_udp.cpp
index 8106647910..dadef8a6f4 100644
--- a/core/io/packet_peer_udp.cpp
+++ b/core/io/packet_peer_udp.cpp
@@ -31,8 +31,6 @@
PacketPeerUDP* (*PacketPeerUDP::_create)()=NULL;
-VARIANT_ENUM_CAST(IP_Address::AddrType);
-
String PacketPeerUDP::_get_packet_ip() const {
return get_packet_address();
@@ -83,5 +81,5 @@ PacketPeerUDP* PacketPeerUDP::create() {
PacketPeerUDP::PacketPeerUDP()
{
- ip_type = IP_Address::TYPE_ANY;
+ ip_type = IP::TYPE_ANY;
}
diff --git a/core/io/packet_peer_udp.h b/core/io/packet_peer_udp.h
index 011e8dd9aa..821007a628 100644
--- a/core/io/packet_peer_udp.h
+++ b/core/io/packet_peer_udp.h
@@ -30,6 +30,7 @@
#define PACKET_PEER_UDP_H
+#include "io/ip.h"
#include "io/packet_peer.h"
class PacketPeerUDP : public PacketPeer {
@@ -37,7 +38,7 @@ class PacketPeerUDP : public PacketPeer {
protected:
- IP_Address::AddrType ip_type;
+ IP::Type ip_type;
static PacketPeerUDP* (*_create)();
static void _bind_methods();
diff --git a/core/io/stream_peer_tcp.cpp b/core/io/stream_peer_tcp.cpp
index b18bba4d2e..d374f54a8a 100644
--- a/core/io/stream_peer_tcp.cpp
+++ b/core/io/stream_peer_tcp.cpp
@@ -30,8 +30,6 @@
StreamPeerTCP* (*StreamPeerTCP::_create)()=NULL;
-VARIANT_ENUM_CAST(IP_Address::AddrType);
-
Error StreamPeerTCP::_connect(const String& p_address,int p_port) {
IP_Address ip;
@@ -79,7 +77,7 @@ StreamPeerTCP* StreamPeerTCP::create() {
StreamPeerTCP::StreamPeerTCP() {
- ip_type = IP_Address::TYPE_ANY;
+ ip_type = IP::TYPE_ANY;
}
StreamPeerTCP::~StreamPeerTCP() {
diff --git a/core/io/stream_peer_tcp.h b/core/io/stream_peer_tcp.h
index 10e061972b..f44784d2b5 100644
--- a/core/io/stream_peer_tcp.h
+++ b/core/io/stream_peer_tcp.h
@@ -51,7 +51,7 @@ public:
protected:
- IP_Address::AddrType ip_type;
+ IP::Type ip_type;
virtual Error _connect(const String& p_address, int p_port);
static StreamPeerTCP* (*_create)();
diff --git a/core/io/tcp_server.cpp b/core/io/tcp_server.cpp
index 29e8bd0c02..0dcec8001e 100644
--- a/core/io/tcp_server.cpp
+++ b/core/io/tcp_server.cpp
@@ -30,8 +30,6 @@
TCP_Server* (*TCP_Server::_create)()=NULL;
-VARIANT_ENUM_CAST(IP_Address::AddrType);
-
Ref<TCP_Server> TCP_Server::create_ref() {
if (!_create)
@@ -68,5 +66,5 @@ void TCP_Server::_bind_methods() {
TCP_Server::TCP_Server()
{
- ip_type = IP_Address::TYPE_ANY;
+ ip_type = IP::TYPE_ANY;
}
diff --git a/core/io/tcp_server.h b/core/io/tcp_server.h
index c380db52d0..aef62eb715 100644
--- a/core/io/tcp_server.h
+++ b/core/io/tcp_server.h
@@ -38,7 +38,7 @@ class TCP_Server : public Reference {
OBJ_TYPE( TCP_Server, Reference );
protected:
- IP_Address::AddrType ip_type;
+ IP::Type ip_type;
static TCP_Server* (*_create)();
diff --git a/core/variant_call.cpp b/core/variant_call.cpp
index 0379ae019b..99d5d1065e 100644
--- a/core/variant_call.cpp
+++ b/core/variant_call.cpp
@@ -1825,10 +1825,6 @@ _VariantCall::addfunc(Variant::m_vtype,Variant::m_ret,_SCS(#m_method),VCALL(m_cl
_VariantCall::add_constant(Variant::IMAGE,"INTERPOLATE_BILINEAR",Image::INTERPOLATE_BILINEAR);
_VariantCall::add_constant(Variant::IMAGE,"INTERPOLATE_CUBIC",Image::INTERPOLATE_CUBIC);
- _VariantCall::add_constant(Variant::INT, "IP_TYPE_NONE", IP_Address::TYPE_NONE);
- _VariantCall::add_constant(Variant::INT, "IP_TYPE_IPV4", IP_Address::TYPE_IPV4);
- _VariantCall::add_constant(Variant::INT, "IP_TYPE_IPV6", IP_Address::TYPE_IPV6);
- _VariantCall::add_constant(Variant::INT, "IP_TYPE_ANY", IP_Address::TYPE_ANY);
}
void unregister_variant_methods() {