diff options
Diffstat (limited to 'core')
-rw-r--r-- | core/bind/core_bind.cpp | 7 | ||||
-rw-r--r-- | core/bind/core_bind.h | 2 | ||||
-rw-r--r-- | core/io/http_client.cpp | 2 | ||||
-rw-r--r-- | core/io/ip.cpp | 2 | ||||
-rw-r--r-- | core/io/xml_parser.cpp | 4 | ||||
-rw-r--r-- | core/math/math_funcs.h | 6 | ||||
-rw-r--r-- | core/method_bind.cpp | 4 | ||||
-rw-r--r-- | core/object.cpp | 5 | ||||
-rw-r--r-- | core/object.h | 1 | ||||
-rw-r--r-- | core/object_type_db.cpp | 17 | ||||
-rw-r--r-- | core/object_type_db.h | 2 | ||||
-rw-r--r-- | core/register_core_types.cpp | 1 | ||||
-rw-r--r-- | core/script_language.h | 2 | ||||
-rw-r--r-- | core/variant.cpp | 126 | ||||
-rw-r--r-- | core/variant.h | 8 | ||||
-rw-r--r-- | core/variant_call.cpp | 6 |
16 files changed, 182 insertions, 13 deletions
diff --git a/core/bind/core_bind.cpp b/core/bind/core_bind.cpp index ef943b2f7a..54fa4214a4 100644 --- a/core/bind/core_bind.cpp +++ b/core/bind/core_bind.cpp @@ -12,9 +12,9 @@ Ref<ResourceInteractiveLoader> _ResourceLoader::load_interactive(const String& p return ResourceLoader::load_interactive(p_path,p_type_hint); } -RES _ResourceLoader::load(const String &p_path,const String& p_type_hint) { +RES _ResourceLoader::load(const String &p_path,const String& p_type_hint, bool p_no_cache) { - RES ret = ResourceLoader::load(p_path,p_type_hint); + RES ret = ResourceLoader::load(p_path,p_type_hint, p_no_cache); return ret; } @@ -59,7 +59,7 @@ void _ResourceLoader::_bind_methods() { ObjectTypeDB::bind_method(_MD("load_interactive:ResourceInteractiveLoader","path","type_hint"),&_ResourceLoader::load_interactive,DEFVAL("")); - ObjectTypeDB::bind_method(_MD("load:Resource","path","type_hint"),&_ResourceLoader::load,DEFVAL("")); + ObjectTypeDB::bind_method(_MD("load:Resource","path","type_hint", "p_no_cache"),&_ResourceLoader::load,DEFVAL(""), DEFVAL(false)); ObjectTypeDB::bind_method(_MD("get_recognized_extensions_for_type","type"),&_ResourceLoader::get_recognized_extensions_for_type); ObjectTypeDB::bind_method(_MD("set_abort_on_missing_resources","abort"),&_ResourceLoader::set_abort_on_missing_resources); ObjectTypeDB::bind_method(_MD("get_dependencies"),&_ResourceLoader::get_dependencies); @@ -1121,6 +1121,7 @@ String _File::get_as_text() const { text+=l+"\n"; l = get_line(); } + text+=l; return text; diff --git a/core/bind/core_bind.h b/core/bind/core_bind.h index a76b4aa81f..12a4ae86eb 100644 --- a/core/bind/core_bind.h +++ b/core/bind/core_bind.h @@ -21,7 +21,7 @@ public: static _ResourceLoader *get_singleton() { return singleton; } Ref<ResourceInteractiveLoader> load_interactive(const String& p_path,const String& p_type_hint=""); - RES load(const String &p_path,const String& p_type_hint=""); + RES load(const String &p_path,const String& p_type_hint="", bool p_no_cache = false); DVector<String> get_recognized_extensions_for_type(const String& p_type); void set_abort_on_missing_resources(bool p_abort); StringArray get_dependencies(const String& p_path); diff --git a/core/io/http_client.cpp b/core/io/http_client.cpp index 60a200af12..faead675d4 100644 --- a/core/io/http_client.cpp +++ b/core/io/http_client.cpp @@ -29,6 +29,8 @@ #include "http_client.h" #include "io/stream_peer_ssl.h" +VARIANT_ENUM_CAST(HTTPClient::Status); + Error HTTPClient::connect_url(const String& p_url) { return OK; diff --git a/core/io/ip.cpp b/core/io/ip.cpp index d2a685f6b0..6ef6b31188 100644 --- a/core/io/ip.cpp +++ b/core/io/ip.cpp @@ -31,7 +31,7 @@ #include "os/semaphore.h" #include "hash_map.h" - +VARIANT_ENUM_CAST(IP::ResolverStatus); /************* RESOLVER ******************/ diff --git a/core/io/xml_parser.cpp b/core/io/xml_parser.cpp index 5d3e4f61ad..1d69f8e5e7 100644 --- a/core/io/xml_parser.cpp +++ b/core/io/xml_parser.cpp @@ -30,9 +30,11 @@ #include "print_string.h" //#define DEBUG_XML +VARIANT_ENUM_CAST(XMLParser::NodeType); + static bool _equalsn(const CharType* str1, const CharType* str2, int len) { int i; - for(i=0; str1[i] && str2[i] && i < len; ++i) + for(i=0; i < len && str1[i] && str2[i] ; ++i) if (str1[i] != str2[i]) return false; diff --git a/core/math/math_funcs.h b/core/math/math_funcs.h index c98a088912..6d43ed8e64 100644 --- a/core/math/math_funcs.h +++ b/core/math/math_funcs.h @@ -136,7 +136,10 @@ public: static int b; -#if defined(_MSC_VER) && _MSC_VER < 1800 +#if (defined(_WIN32_WINNT) && _WIN32_WINNT >= 0x0603) || WINAPI_FAMILY == WINAPI_FAMILY_PHONE_APP // windows 8 phone? + b = (int)((a>0.0f) ? (a + 0.5f):(a -0.5f)); + +#elif defined(_MSC_VER) && _MSC_VER < 1800 __asm fld a __asm fistp b /*#elif defined( __GNUC__ ) && ( defined( __i386__ ) || defined( __x86_64__ ) ) @@ -147,6 +150,7 @@ public: "fistpl %0 \n\t" : "=m" (b) : "m" (a));*/ + #else b=lrintf(a); //assuming everything but msvc 2012 or earlier has lrint #endif diff --git a/core/method_bind.cpp b/core/method_bind.cpp index 739745f70f..6ee4882571 100644 --- a/core/method_bind.cpp +++ b/core/method_bind.cpp @@ -87,7 +87,9 @@ Vector<StringName> MethodBind::get_argument_names() const { void MethodBind::set_default_arguments(const Vector<Variant>& p_defargs) { - default_arguments=p_defargs; default_argument_count=default_arguments.size(); + default_arguments=p_defargs; + default_argument_count=default_arguments.size(); + } #ifdef DEBUG_METHODS_ENABLED diff --git a/core/object.cpp b/core/object.cpp index 42d570042f..82144ab4be 100644 --- a/core/object.cpp +++ b/core/object.cpp @@ -1694,6 +1694,11 @@ void ObjectDB::debug_objects(DebugFunc p_func) { } +void Object::get_argument_options(const StringName& p_function,int p_idx,List<String>*r_options) const { + + +} + int ObjectDB::get_object_count() { GLOBAL_LOCK_FUNCTION; diff --git a/core/object.h b/core/object.h index 7ce07869a6..97ca50cb1a 100644 --- a/core/object.h +++ b/core/object.h @@ -583,6 +583,7 @@ public: virtual void get_translatable_strings(List<String> *p_strings) const; + virtual void get_argument_options(const StringName& p_function,int p_idx,List<String>*r_options) const; StringName XL_MESSAGE(const StringName& p_message) const; //translate message (internationalization) StringName tr(const StringName& p_message) const; //translate message (alternative) diff --git a/core/object_type_db.cpp b/core/object_type_db.cpp index 62244cbd4f..efd92542ce 100644 --- a/core/object_type_db.cpp +++ b/core/object_type_db.cpp @@ -805,12 +805,25 @@ void ObjectTypeDB::add_virtual_method(const StringName& p_type,const MethodInfo& } -void ObjectTypeDB::get_virtual_methods(const StringName& p_type,List<MethodInfo> * p_methods ) { +void ObjectTypeDB::get_virtual_methods(const StringName& p_type, List<MethodInfo> * p_methods , bool p_no_inheritance) { ERR_FAIL_COND(!types.has(p_type)); #ifdef DEBUG_METHODS_ENABLED - *p_methods=types[p_type].virtual_methods; + + TypeInfo *type=types.getptr(p_type); + TypeInfo *check=type; + while(check) { + + for(List<MethodInfo>::Element *E=check->virtual_methods.front();E;E=E->next()) { + p_methods->push_back(E->get()); + } + + if (p_no_inheritance) + return; + check=check->inherits_ptr; + } + #endif } diff --git a/core/object_type_db.h b/core/object_type_db.h index ae0644f9b3..f2ff194e28 100644 --- a/core/object_type_db.h +++ b/core/object_type_db.h @@ -468,7 +468,7 @@ public: static MethodBind *get_method(StringName p_type, StringName p_name); static void add_virtual_method(const StringName& p_type,const MethodInfo& p_method ); - static void get_virtual_methods(const StringName& p_type,List<MethodInfo> * p_methods ); + static void get_virtual_methods(const StringName& p_type,List<MethodInfo> * p_methods,bool p_no_inheritance=false ); static void bind_integer_constant(const StringName& p_type, const StringName &p_name, int p_constant); static void get_integer_constant_list(const StringName& p_type, List<String> *p_constants, bool p_no_inheritance=false); diff --git a/core/register_core_types.cpp b/core/register_core_types.cpp index 2f16e31de6..4935136eeb 100644 --- a/core/register_core_types.cpp +++ b/core/register_core_types.cpp @@ -110,6 +110,7 @@ void register_core_types() { ObjectTypeDB::register_type<Reference>(); + ObjectTypeDB::register_type<WeakRef>(); ObjectTypeDB::register_type<ResourceImportMetadata>(); ObjectTypeDB::register_type<Resource>(); ObjectTypeDB::register_type<FuncRef>(); diff --git a/core/script_language.h b/core/script_language.h index d62e9849a1..802eff190a 100644 --- a/core/script_language.h +++ b/core/script_language.h @@ -144,7 +144,7 @@ public: virtual bool has_named_classes() const=0; virtual int find_function(const String& p_function,const String& p_code) const=0; virtual String make_function(const String& p_class,const String& p_name,const StringArray& p_args) const=0; - virtual Error complete_keyword(const String& p_code, int p_line, const String& p_base_path, const String& p_keyword, List<String>* r_options) { return ERR_UNAVAILABLE; } + virtual Error complete_code(const String& p_code, const String& p_base_path, Object*p_owner,List<String>* r_options,String& r_call_hint) { return ERR_UNAVAILABLE; } virtual void auto_indent_code(String& p_code,int p_from_line,int p_to_line) const=0; /* DEBUGGER FUNCTIONS */ diff --git a/core/variant.cpp b/core/variant.cpp index fdb14c0c0f..2f0eca9e91 100644 --- a/core/variant.cpp +++ b/core/variant.cpp @@ -2631,3 +2631,129 @@ Variant Variant::call(const StringName& p_method,VARIANT_ARG_DECLARE) { return ret; } + +String Variant::get_construct_string() const { + + switch( type ) { + + case NIL: return "null"; + case BOOL: return _data._bool ? "true" : "false"; + case INT: return String::num(_data._int); + case REAL: return String::num(_data._real); + case STRING: return "\""+*reinterpret_cast<const String*>(_data._mem)+"\""; + case VECTOR2: return "Vector2("+operator Vector2()+")"; + case RECT2: return "Rect2("+operator Rect2()+")"; + case MATRIX32: return "Matrix32("+operator Matrix32()+")"; + case VECTOR3: return "Vector3("+operator Vector3()+")"; + case PLANE: return "Plane("+operator Plane()+")"; + //case QUAT: + case _AABB: return "AABB("+operator AABB()+")"; + case QUAT: return "Quat("+operator Quat()+")"; + case MATRIX3: return "Matrix3("+operator Matrix3()+")"; + case TRANSFORM: return "Transform("+operator Transform()+")"; + case NODE_PATH: return "@\""+operator NodePath()+"\""; + case INPUT_EVENT: return "InputEvent()"; + case COLOR: return "Color("+String::num( operator Color().r)+","+String::num( operator Color().g)+","+String::num( operator Color().b)+","+String::num( operator Color().a)+")" ; + case DICTIONARY: { + + const Dictionary &d =*reinterpret_cast<const Dictionary*>(_data._mem); + //const String *K=NULL; + String str="{"; + List<Variant> keys; + d.get_key_list(&keys); + + Vector<_VariantStrPair> pairs; + + for(List<Variant>::Element *E=keys.front();E;E=E->next()) { + + _VariantStrPair sp; + sp.key=E->get().get_construct_string(); + sp.value=d[E->get()].get_construct_string(); + pairs.push_back(sp); + } + + pairs.sort(); + + for(int i=0;i<pairs.size();i++) { + if (i>0) + str+=", "; + str+="("+pairs[i].key+":"+pairs[i].value+")"; + } + str+="}"; + + return str; + } break; + case VECTOR3_ARRAY: { + + DVector<Vector3> vec = operator DVector<Vector3>(); + String str="["; + for(int i=0;i<vec.size();i++) { + + if (i>0) + str+=", "; + str+=Variant( vec[i] ).get_construct_string(); + } + return str+"]"; + } break; + case STRING_ARRAY: { + + DVector<String> vec = operator DVector<String>(); + String str="["; + for(int i=0;i<vec.size();i++) { + + if (i>0) + str+=", "; + str=str+=Variant( vec[i] ).get_construct_string(); + } + return str+"]"; + } break; + case INT_ARRAY: { + + DVector<int> vec = operator DVector<int>(); + String str="["; + for(int i=0;i<vec.size();i++) { + + if (i>0) + str+=", "; + str=str+itos(vec[i]); + } + return str+"]"; + } break; + case REAL_ARRAY: { + + DVector<real_t> vec = operator DVector<real_t>(); + String str="["; + for(int i=0;i<vec.size();i++) { + + if (i>0) + str+=", "; + str=str+rtos(vec[i]); + } + return str+"]"; + } break; + case ARRAY: { + + Array arr = operator Array(); + String str="["; + for (int i=0; i<arr.size(); i++) { + if (i) + str+=", "; + str += arr[i].get_construct_string(); + }; + return str+"]"; + + } break; + case OBJECT: { + + if (_get_obj().obj) + return _get_obj().obj->get_type()+".new()"; + else + return "null"; + + } break; + default: { + return "["+get_type_name(type)+"]"; + } + } + +} diff --git a/core/variant.h b/core/variant.h index 9109f4ad08..47fc3f43ac 100644 --- a/core/variant.h +++ b/core/variant.h @@ -167,14 +167,18 @@ public: static String get_type_name(Variant::Type p_type); static bool can_convert(Type p_type_from,Type p_type_to); + + template<class T> static Type get_type_for() { GetSimpleType<T> t; Variant v(t.type); - return v.get_type(); + Type r = v.get_type(); + return r; } + bool is_ref() const; _FORCE_INLINE_ bool is_num() const { return type==INT || type==REAL; }; _FORCE_INLINE_ bool is_array() const { return type>=ARRAY; }; @@ -415,6 +419,8 @@ public: static bool has_numeric_constant(Variant::Type p_type, const StringName& p_value); static int get_numeric_constant_value(Variant::Type p_type, const StringName& p_value); + String get_construct_string() const; + void operator=(const Variant& p_variant); // only this is enough for all the other types Variant(const Variant& p_variant); _FORCE_INLINE_ Variant() { type=NIL; } diff --git a/core/variant_call.cpp b/core/variant_call.cpp index 93a9e6475f..3f2800494d 100644 --- a/core/variant_call.cpp +++ b/core/variant_call.cpp @@ -757,6 +757,11 @@ static void _call_##m_type##_##m_method(Variant& r_ret,Variant& p_self,const Var r_ret=Quat(*p_args[0],*p_args[1],*p_args[2],*p_args[3]); } + static void Quat_init2(Variant& r_ret,const Variant** p_args) { + + r_ret=Quat(((Vector3)(*p_args[0])),((float)(*p_args[1]))); + } + static void Color_init1(Variant& r_ret,const Variant** p_args) { r_ret=Color(*p_args[0],*p_args[1],*p_args[2],*p_args[3]); @@ -1509,6 +1514,7 @@ _VariantCall::addfunc(Variant::m_vtype,Variant::m_ret,_SCS(#m_method),VCALL(m_cl _VariantCall::add_constructor(_VariantCall::Plane_init3,Variant::PLANE,"normal",Variant::VECTOR3,"d",Variant::REAL); _VariantCall::add_constructor(_VariantCall::Quat_init1,Variant::QUAT,"x",Variant::REAL,"y",Variant::REAL,"z",Variant::REAL,"w",Variant::REAL); + _VariantCall::add_constructor(_VariantCall::Quat_init2,Variant::QUAT,"axis",Variant::VECTOR3,"angle",Variant::REAL); _VariantCall::add_constructor(_VariantCall::Color_init1,Variant::COLOR,"r",Variant::REAL,"g",Variant::REAL,"b",Variant::REAL,"a",Variant::REAL); _VariantCall::add_constructor(_VariantCall::Color_init2,Variant::COLOR,"r",Variant::REAL,"g",Variant::REAL,"b",Variant::REAL); |