diff options
Diffstat (limited to 'core')
-rw-r--r-- | core/dictionary.cpp | 10 | ||||
-rw-r--r-- | core/dictionary.h | 2 | ||||
-rw-r--r-- | core/global_constants.cpp | 1 | ||||
-rw-r--r-- | core/io/http_client.cpp | 7 | ||||
-rw-r--r-- | core/io/http_client.h | 1 | ||||
-rw-r--r-- | core/make_binders.py | 48 | ||||
-rw-r--r-- | core/os/file_access.cpp | 4 | ||||
-rw-r--r-- | core/variant_call.cpp | 4 | ||||
-rw-r--r-- | core/vector.h | 5 |
9 files changed, 54 insertions, 28 deletions
diff --git a/core/dictionary.cpp b/core/dictionary.cpp index a013c21b29..75c8531251 100644 --- a/core/dictionary.cpp +++ b/core/dictionary.cpp @@ -110,6 +110,16 @@ bool Dictionary::has(const Variant& p_key) const { return _p->variant_map.has(p_key); } + +bool Dictionary::has_all(const Array& p_keys) const { + for (int i=0;i<p_keys.size();i++) { + if( !has(p_keys[i]) ) { + return false; + } + } + return true; +} + void Dictionary::erase(const Variant& p_key) { _copy_on_write(); _p->variant_map.erase(p_key); diff --git a/core/dictionary.h b/core/dictionary.h index 145e7e5c84..c854e95ee6 100644 --- a/core/dictionary.h +++ b/core/dictionary.h @@ -69,6 +69,8 @@ public: bool is_shared() const; bool has(const Variant& p_key) const; + bool has_all(const Array& p_keys) const; + void erase(const Variant& p_key); bool operator==(const Dictionary& p_dictionary) const; diff --git a/core/global_constants.cpp b/core/global_constants.cpp index 130fca1b2a..3cf4ff8f83 100644 --- a/core/global_constants.cpp +++ b/core/global_constants.cpp @@ -476,7 +476,6 @@ static _GlobalConstant _global_constants[]={ BIND_GLOBAL_CONSTANT( PROPERTY_USAGE_STORAGE ), - BIND_GLOBAL_CONSTANT( PROPERTY_USAGE_STORAGE ), BIND_GLOBAL_CONSTANT( PROPERTY_USAGE_EDITOR ), BIND_GLOBAL_CONSTANT( PROPERTY_USAGE_NETWORK ), BIND_GLOBAL_CONSTANT( PROPERTY_USAGE_DEFAULT ), diff --git a/core/io/http_client.cpp b/core/io/http_client.cpp index e0c01c9422..8c58e0ba5e 100644 --- a/core/io/http_client.cpp +++ b/core/io/http_client.cpp @@ -81,6 +81,12 @@ void HTTPClient::set_connection(const Ref<StreamPeer>& p_connection){ } +Ref<StreamPeer> HTTPClient::get_connection() const { + + return connection; +} + + Error HTTPClient::request( Method p_method, const String& p_url, const Vector<String>& p_headers,const String& p_body) { ERR_FAIL_INDEX_V(p_method,METHOD_MAX,ERR_INVALID_PARAMETER); @@ -578,6 +584,7 @@ void HTTPClient::_bind_methods() { ObjectTypeDB::bind_method(_MD("connect:Error","host","port","use_ssl","verify_host"),&HTTPClient::connect,DEFVAL(false),DEFVAL(true)); 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","method","url","headers","body"),&HTTPClient::request,DEFVAL(String())); ObjectTypeDB::bind_method(_MD("send_body_text","body"),&HTTPClient::send_body_text); ObjectTypeDB::bind_method(_MD("send_body_data","body"),&HTTPClient::send_body_data); diff --git a/core/io/http_client.h b/core/io/http_client.h index e795646c70..defde08524 100644 --- a/core/io/http_client.h +++ b/core/io/http_client.h @@ -168,6 +168,7 @@ public: Error connect(const String &p_host,int p_port,bool p_ssl=false,bool p_verify_host=true); void set_connection(const Ref<StreamPeer>& p_connection); + Ref<StreamPeer> get_connection() const; Error request( Method p_method, const String& p_url, const Vector<String>& p_headers,const String& p_body=String()); Error send_body_text(const String& p_body); diff --git a/core/make_binders.py b/core/make_binders.py index ebd48777b6..93371dc0a3 100644 --- a/core/make_binders.py +++ b/core/make_binders.py @@ -6,7 +6,7 @@ template_typed=""" template<class T $ifret ,class R$ $ifargs ,$ $arg, class P@$> class MethodBind$argc$$ifret R$$ifconst C$ : public MethodBind { public: - + $ifret R$ $ifnoret void$ (T::*method)($arg, P@$) $ifconst const$; #ifdef DEBUG_METHODS_ENABLED virtual Variant::Type _gen_argument_type(int p_arg) const { return _get_argument_type(p_arg); } @@ -16,13 +16,13 @@ public: $ return Variant::NIL; } -#endif +#endif virtual String get_instance_type() const { return T::get_type_static(); } virtual Variant call(Object* p_object,const Variant** p_args,int p_arg_count, Variant::CallError& r_error) { - + T *instance=p_object->cast_to<T>(); r_error.error=Variant::CallError::CALL_OK; #ifdef DEBUG_METHODS_ENABLED @@ -47,7 +47,7 @@ public: $ifret return Variant(ret);$ $ifnoret return Variant();$ } - + MethodBind$argc$$ifret R$$ifconst C$ () { #ifdef DEBUG_METHODS_ENABLED @@ -55,14 +55,14 @@ public: _generate_argument_types($argc$); #else set_argument_count($argc$); -#endif +#endif }; }; template<class T $ifret ,class R$ $ifargs ,$ $arg, class P@$> MethodBind* create_method_bind($ifret R$ $ifnoret void$ (T::*p_method)($arg, P@$) $ifconst const$ ) { - MethodBind$argc$$ifret R$$ifconst C$<T $ifret ,R$ $ifargs ,$ $arg, P@$> * a = memnew( (MethodBind$argc$$ifret R$$ifconst C$<T $ifret ,R$ $ifargs ,$ $arg, P@$>) ); + MethodBind$argc$$ifret R$$ifconst C$<T $ifret ,R$ $ifargs ,$ $arg, P@$> * a = memnew( (MethodBind$argc$$ifret R$$ifconst C$<T $ifret ,R$ $ifargs ,$ $arg, P@$>) ); a->method=p_method; return a; } @@ -88,7 +88,7 @@ public: $ return Variant::NIL; } -#endif +#endif virtual String get_instance_type() const { return type_name; } @@ -105,15 +105,15 @@ public: r_error.error=Variant::CallError::CALL_ERROR_TOO_MANY_ARGUMENTS; r_error.argument=get_argument_count(); return Variant(); - } - + } + if (p_arg_count<(get_argument_count()-get_default_argument_count())) { r_error.error=Variant::CallError::CALL_ERROR_TOO_FEW_ARGUMENTS; r_error.argument=get_argument_count()-get_default_argument_count(); return Variant(); } - + $arg CHECK_ARG(@); $ #endif @@ -128,7 +128,7 @@ public: _generate_argument_types($argc$); #else set_argument_count($argc$); -#endif +#endif }; }; @@ -151,12 +151,12 @@ MethodBind* create_method_bind($ifret R$ $ifnoret void$ (T::*p_method)($arg, P@$ def make_version(template,nargs,argmax,const,ret): - + intext=template from_pos=0 outtext="" - - while(True): + + while(True): to_pos=intext.find("$",from_pos) if (to_pos==-1): outtext+=intext[from_pos:] @@ -169,13 +169,13 @@ def make_version(template,nargs,argmax,const,ret): macro=intext[to_pos+1:end] cmd="" data="" - + if (macro.find(" ")!=-1): cmd=macro[0:macro.find(" ")] data=macro[macro.find(" ")+1:] else: cmd=macro - + if (cmd=="argc"): outtext+=str(nargs) if (cmd=="ifret" and ret): @@ -206,11 +206,11 @@ def make_version(template,nargs,argmax,const,ret): elif (cmd=="noarg"): for i in range(nargs+1,argmax+1): outtext+=data.replace("@",str(i)) - + from_pos=end+1 - + return outtext - + def run(target, source, env): @@ -244,9 +244,9 @@ def run(target, source, env): f.write(text_ext) f.close() - - - - - + + + + + diff --git a/core/os/file_access.cpp b/core/os/file_access.cpp index 0846ef3eb0..a3ee9395de 100644 --- a/core/os/file_access.cpp +++ b/core/os/file_access.cpp @@ -284,7 +284,7 @@ Vector<String> FileAccess::get_csv_line(String delim) const { String l; int qc=0; do { - l+=get_line(); + l+=get_line()+"\n"; qc=0; for(int i=0;i<l.length();i++) { @@ -295,6 +295,8 @@ Vector<String> FileAccess::get_csv_line(String delim) const { } while (qc%2); + l=l.substr(0, l.length()-1); + Vector<String> strings; bool in_quote=false; diff --git a/core/variant_call.cpp b/core/variant_call.cpp index 78814c83e2..f3bf8f9e47 100644 --- a/core/variant_call.cpp +++ b/core/variant_call.cpp @@ -246,6 +246,7 @@ static void _call_##m_type##_##m_method(Variant& r_ret,Variant& p_self,const Var VCALL_LOCALMEM1R(String,match); VCALL_LOCALMEM1R(String,matchn); VCALL_LOCALMEM1R(String,begins_with); + VCALL_LOCALMEM1R(String,ends_with); VCALL_LOCALMEM2R(String,replace); VCALL_LOCALMEM2R(String,replacen); VCALL_LOCALMEM2R(String,insert); @@ -440,6 +441,7 @@ static void _call_##m_type##_##m_method(Variant& r_ret,Variant& p_self,const Var VCALL_LOCALMEM0R(Dictionary,empty); VCALL_LOCALMEM0(Dictionary,clear); VCALL_LOCALMEM1R(Dictionary,has); + VCALL_LOCALMEM1R(Dictionary,has_all); VCALL_LOCALMEM1(Dictionary,erase); VCALL_LOCALMEM0R(Dictionary,hash); VCALL_LOCALMEM0R(Dictionary,keys); @@ -1260,6 +1262,7 @@ _VariantCall::addfunc(Variant::m_vtype,Variant::m_ret,_SCS(#m_method),VCALL(m_cl ADDFUNC1(STRING,BOOL,String,match,STRING,"expr",varray()); ADDFUNC1(STRING,BOOL,String,matchn,STRING,"expr",varray()); ADDFUNC1(STRING,BOOL,String,begins_with,STRING,"text",varray()); + ADDFUNC1(STRING,BOOL,String,ends_with,STRING,"text",varray()); ADDFUNC2(STRING,STRING,String,replace,STRING,"what",STRING,"forwhat",varray()); ADDFUNC2(STRING,STRING,String,replacen,STRING,"what",STRING,"forwhat",varray()); @@ -1423,6 +1426,7 @@ _VariantCall::addfunc(Variant::m_vtype,Variant::m_ret,_SCS(#m_method),VCALL(m_cl ADDFUNC0(DICTIONARY,BOOL,Dictionary,empty,varray()); ADDFUNC0(DICTIONARY,NIL,Dictionary,clear,varray()); ADDFUNC1(DICTIONARY,BOOL,Dictionary,has,NIL,"value",varray()); + ADDFUNC1(DICTIONARY,BOOL,Dictionary,has_all,ARRAY,"values",varray()); ADDFUNC1(DICTIONARY,NIL,Dictionary,erase,NIL,"value",varray()); ADDFUNC0(DICTIONARY,INT,Dictionary,hash,varray()); ADDFUNC0(DICTIONARY,ARRAY,Dictionary,keys,varray()); diff --git a/core/vector.h b/core/vector.h index 16a09c1ddd..87248ccf68 100644 --- a/core/vector.h +++ b/core/vector.h @@ -70,7 +70,8 @@ class Vector { } _FORCE_INLINE_ size_t _get_alloc_size(size_t p_elements) const { - return nearest_power_of_2_templated(p_elements*sizeof(T)+sizeof(SafeRefCount)+sizeof(int)); + //return nearest_power_of_2_templated(p_elements*sizeof(T)+sizeof(SafeRefCount)+sizeof(int)); + return nearest_power_of_2(p_elements*sizeof(T)+sizeof(SafeRefCount)+sizeof(int)); } _FORCE_INLINE_ bool _get_alloc_size_checked(size_t p_elements, size_t *out) const { @@ -79,7 +80,7 @@ class Vector { size_t p; if (_mul_overflow(p_elements, sizeof(T), &o)) return false; if (_add_overflow(o, sizeof(SafeRefCount)+sizeof(int), &p)) return false; - *out = nearest_power_of_2_templated(p); + *out = nearest_power_of_2(p); return true; #else // Speed is more important than correctness here, do the operations unchecked |