diff options
Diffstat (limited to 'core')
-rw-r--r-- | core/class_db.cpp | 8 | ||||
-rw-r--r-- | core/class_db.h | 23 | ||||
-rw-r--r-- | core/io/resource_import.cpp | 24 | ||||
-rw-r--r-- | core/io/resource_import.h | 3 | ||||
-rw-r--r-- | core/io/resource_loader.cpp | 25 | ||||
-rw-r--r-- | core/io/resource_loader.h | 2 | ||||
-rw-r--r-- | core/math/matrix3.cpp | 33 | ||||
-rw-r--r-- | core/math/matrix3.h | 4 | ||||
-rw-r--r-- | core/method_bind.h | 1 | ||||
-rw-r--r-- | core/object.cpp | 59 | ||||
-rw-r--r-- | core/object.h | 6 | ||||
-rw-r--r-- | core/script_language.cpp | 6 | ||||
-rw-r--r-- | core/type_info.h | 53 | ||||
-rw-r--r-- | core/variant_call.cpp | 6 |
14 files changed, 152 insertions, 101 deletions
diff --git a/core/class_db.cpp b/core/class_db.cpp index 4b0e1b31f0..1cb287a143 100644 --- a/core/class_db.cpp +++ b/core/class_db.cpp @@ -46,11 +46,6 @@ #ifdef DEBUG_METHODS_ENABLED -ParamDef::ParamDef(const Variant &p_variant) - : used(true), - val(p_variant) { -} - MethodDefinition D_METHOD(const char *p_name) { MethodDefinition md; @@ -539,8 +534,9 @@ void ClassDB::get_method_list(StringName p_class, List<MethodInfo> *p_methods, b } minfo.return_val = method->get_return_info(); - minfo.flags = method->get_hint_flags(); + minfo.default_arguments = method->get_default_arguments(); + p_methods->push_back(minfo); } diff --git a/core/class_db.h b/core/class_db.h index 25a5000572..f6b97748b0 100644 --- a/core/class_db.h +++ b/core/class_db.h @@ -38,29 +38,6 @@ @author Juan Linietsky <reduzio@gmail.com> */ -struct ParamHint { - - String name; - PropertyHint hint; - String hint_text; - Variant default_val; - - ParamHint(const String &p_name = "", PropertyHint p_hint = PROPERTY_HINT_NONE, const String &p_hint_text = "", const Variant &p_default_val = Variant()) - : name(p_name), - hint(p_hint), - hint_text(p_hint_text), - default_val(p_default_val) { - } -}; - -struct ParamDef { - bool used; - Variant val; - _FORCE_INLINE_ ParamDef() { used = false; } - ParamDef(const Variant &p_variant); -}; - -//#define DEFVAL( m_defval ) ParamDef(m_defval) #define DEFVAL(m_defval) (m_defval) //#define SIMPLE_METHODDEF diff --git a/core/io/resource_import.cpp b/core/io/resource_import.cpp index 5a4f29fe67..69ff791a3a 100644 --- a/core/io/resource_import.cpp +++ b/core/io/resource_import.cpp @@ -32,13 +32,17 @@ #include "os/os.h" #include "variant_parser.h" -Error ResourceFormatImporter::_get_path_and_type(const String &p_path, PathAndType &r_path_and_type) const { +Error ResourceFormatImporter::_get_path_and_type(const String &p_path, PathAndType &r_path_and_type, bool *r_valid) const { Error err; FileAccess *f = FileAccess::open(p_path + ".import", FileAccess::READ, &err); - if (!f) + if (!f) { + if (r_valid) { + *r_valid = false; + } return err; + } VariantParser::StreamFile stream; stream.f = f; @@ -47,6 +51,10 @@ Error ResourceFormatImporter::_get_path_and_type(const String &p_path, PathAndTy Variant value; VariantParser::Tag next_tag; + if (r_valid) { + *r_valid = true; + } + int lines = 0; String error_text; bool path_found = false; //first match must have priority @@ -79,6 +87,10 @@ Error ResourceFormatImporter::_get_path_and_type(const String &p_path, PathAndTy path_found = true; //first match must have priority } else if (assign == "type") { r_path_and_type.type = value; + } else if (assign == "valid") { + if (r_valid) { + *r_valid = value; + } } } else if (next_tag.name != "remap") { @@ -245,6 +257,14 @@ void ResourceFormatImporter::get_internal_resource_path_list(const String &p_pat memdelete(f); } +bool ResourceFormatImporter::is_import_valid(const String &p_path) const { + + bool valid = true; + PathAndType pat; + _get_path_and_type(p_path, pat, &valid); + return valid; +} + String ResourceFormatImporter::get_resource_type(const String &p_path) const { PathAndType pat; diff --git a/core/io/resource_import.h b/core/io/resource_import.h index bf0bf3987a..b10255fbab 100644 --- a/core/io/resource_import.h +++ b/core/io/resource_import.h @@ -40,7 +40,7 @@ class ResourceFormatImporter : public ResourceFormatLoader { String type; }; - Error _get_path_and_type(const String &p_path, PathAndType &r_path_and_type) const; + Error _get_path_and_type(const String &p_path, PathAndType &r_path_and_type, bool *r_valid = NULL) const; static ResourceFormatImporter *singleton; @@ -54,6 +54,7 @@ public: virtual bool recognize_path(const String &p_path, const String &p_for_type = String()) const; virtual bool handles_type(const String &p_type) const; virtual String get_resource_type(const String &p_path) const; + virtual bool is_import_valid(const String &p_path) const; virtual void get_dependencies(const String &p_path, List<String> *p_dependencies, bool p_add_types = false); virtual bool can_be_imported(const String &p_path) const; diff --git a/core/io/resource_loader.cpp b/core/io/resource_loader.cpp index f0e804e2fa..30ae9f5681 100644 --- a/core/io/resource_loader.cpp +++ b/core/io/resource_loader.cpp @@ -296,6 +296,31 @@ void ResourceLoader::add_resource_format_loader(ResourceFormatLoader *p_format_l } } +bool ResourceLoader::is_import_valid(const String &p_path) { + + String path = _path_remap(p_path); + + String local_path; + if (path.is_rel_path()) + local_path = "res://" + path; + else + local_path = ProjectSettings::get_singleton()->localize_path(path); + + for (int i = 0; i < loader_count; i++) { + + if (!loader[i]->recognize_path(local_path)) + continue; + /* + if (p_type_hint!="" && !loader[i]->handles_type(p_type_hint)) + continue; + */ + + return loader[i]->is_import_valid(p_path); + } + + return false; //not found +} + void ResourceLoader::get_dependencies(const String &p_path, List<String> *p_dependencies, bool p_add_types) { String path = _path_remap(p_path); diff --git a/core/io/resource_loader.h b/core/io/resource_loader.h index 9e059c2977..91f0c939bf 100644 --- a/core/io/resource_loader.h +++ b/core/io/resource_loader.h @@ -66,6 +66,7 @@ public: virtual String get_resource_type(const String &p_path) const = 0; virtual void get_dependencies(const String &p_path, List<String> *p_dependencies, bool p_add_types = false); virtual Error rename_dependencies(const String &p_path, const Map<String, String> &p_map) { return OK; } + virtual bool is_import_valid(const String &p_path) const { return true; } virtual ~ResourceFormatLoader() {} }; @@ -104,6 +105,7 @@ public: static String get_resource_type(const String &p_path); static void get_dependencies(const String &p_path, List<String> *p_dependencies, bool p_add_types = false); static Error rename_dependencies(const String &p_path, const Map<String, String> &p_map); + static bool is_import_valid(const String &p_path); static void set_timestamp_on_load(bool p_timestamp) { timestamp_on_load = p_timestamp; } diff --git a/core/math/matrix3.cpp b/core/math/matrix3.cpp index c7e2a8f307..57555bbb2a 100644 --- a/core/math/matrix3.cpp +++ b/core/math/matrix3.cpp @@ -254,17 +254,6 @@ Vector3 Basis::get_scale() const { Vector3(elements[0][2], elements[1][2], elements[2][2]).length()); } -// Sets scaling while preserving rotation. -// This requires some care when working with matrices with negative determinant, -// since we're using a particular convention for "polar" decomposition in get_scale and get_rotation. -// For details, see the explanation in get_scale. -void Basis::set_scale(const Vector3 &p_scale) { - Vector3 e = get_euler(); - Basis(); // reset to identity - scale(p_scale); - rotate(e); -} - // Multiplies the matrix from left by the rotation matrix: M -> R.M // Note that this does *not* rotate the matrix itself. // @@ -316,28 +305,6 @@ void Basis::get_rotation_axis_angle(Vector3 &p_axis, real_t &p_angle) const { m.get_axis_angle(p_axis, p_angle); } -// Sets rotation while preserving scaling. -// This requires some care when working with matrices with negative determinant, -// since we're using a particular convention for "polar" decomposition in get_scale and get_rotation. -// For details, see the explanation in get_scale. -void Basis::set_rotation_euler(const Vector3 &p_euler) { - Vector3 s = get_scale(); - Basis(); // reset to identity - scale(s); - rotate(p_euler); -} - -// Sets rotation while preserving scaling. -// This requires some care when working with matrices with negative determinant, -// since we're using a particular convention for "polar" decomposition in get_scale and get_rotation. -// For details, see the explanation in get_scale. -void Basis::set_rotation_axis_angle(const Vector3 &p_axis, real_t p_angle) { - Vector3 s = get_scale(); - Basis(); // reset to identity - scale(s); - rotate(p_axis, p_angle); -} - // get_euler_xyz returns a vector containing the Euler angles in the format // (a1,a2,a3), where a3 is the angle of the first rotation, and a1 is the last // (following the convention they are commonly defined in the literature). diff --git a/core/math/matrix3.h b/core/math/matrix3.h index be85c244bd..be8de2e1c4 100644 --- a/core/math/matrix3.h +++ b/core/math/matrix3.h @@ -81,9 +81,6 @@ public: Vector3 get_rotation() const; void get_rotation_axis_angle(Vector3 &p_axis, real_t &p_angle) const; - void set_rotation_euler(const Vector3 &p_euler); - void set_rotation_axis_angle(const Vector3 &p_axis, real_t p_angle); - Vector3 get_euler_xyz() const; void set_euler_xyz(const Vector3 &p_euler); Vector3 get_euler_yxz() const; @@ -99,7 +96,6 @@ public: Basis scaled(const Vector3 &p_scale) const; Vector3 get_scale() const; - void set_scale(const Vector3 &p_scale); // transposed dot products _FORCE_INLINE_ real_t tdotx(const Vector3 &v) const { diff --git a/core/method_bind.h b/core/method_bind.h index f6cae6f34d..75f09b2cd9 100644 --- a/core/method_bind.h +++ b/core/method_bind.h @@ -334,6 +334,7 @@ public: } argument_types = at; arguments = p_info; + arguments.return_val.usage |= PROPERTY_USAGE_NIL_IS_VARIANT; #endif } diff --git a/core/object.cpp b/core/object.cpp index b220dc0563..23e32a214a 100644 --- a/core/object.cpp +++ b/core/object.cpp @@ -274,6 +274,63 @@ MethodInfo::MethodInfo(Variant::Type ret, const String &p_name, const PropertyIn arguments.push_back(p_param5); } +MethodInfo::MethodInfo(const PropertyInfo &p_ret, const String &p_name) + : name(p_name), + flags(METHOD_FLAG_NORMAL), + id(0) { + return_val = p_ret; +} + +MethodInfo::MethodInfo(const PropertyInfo &p_ret, const String &p_name, const PropertyInfo &p_param1) + : name(p_name), + flags(METHOD_FLAG_NORMAL), + id(0) { + return_val = p_ret; + arguments.push_back(p_param1); +} + +MethodInfo::MethodInfo(const PropertyInfo &p_ret, const String &p_name, const PropertyInfo &p_param1, const PropertyInfo &p_param2) + : name(p_name), + flags(METHOD_FLAG_NORMAL), + id(0) { + return_val = p_ret; + arguments.push_back(p_param1); + arguments.push_back(p_param2); +} + +MethodInfo::MethodInfo(const PropertyInfo &p_ret, const String &p_name, const PropertyInfo &p_param1, const PropertyInfo &p_param2, const PropertyInfo &p_param3) + : name(p_name), + flags(METHOD_FLAG_NORMAL), + id(0) { + return_val = p_ret; + arguments.push_back(p_param1); + arguments.push_back(p_param2); + arguments.push_back(p_param3); +} + +MethodInfo::MethodInfo(const PropertyInfo &p_ret, const String &p_name, const PropertyInfo &p_param1, const PropertyInfo &p_param2, const PropertyInfo &p_param3, const PropertyInfo &p_param4) + : name(p_name), + flags(METHOD_FLAG_NORMAL), + id(0) { + return_val = p_ret; + arguments.push_back(p_param1); + arguments.push_back(p_param2); + arguments.push_back(p_param3); + arguments.push_back(p_param4); +} + +MethodInfo::MethodInfo(const PropertyInfo &p_ret, const String &p_name, const PropertyInfo &p_param1, const PropertyInfo &p_param2, const PropertyInfo &p_param3, const PropertyInfo &p_param4, const PropertyInfo &p_param5) + : name(p_name), + flags(METHOD_FLAG_NORMAL), + id(0) { + return_val = p_ret; + arguments.push_back(p_param1); + arguments.push_back(p_param2); + arguments.push_back(p_param3); + arguments.push_back(p_param4); + arguments.push_back(p_param5); +} + Object::Connection::operator Variant() const { Dictionary d; @@ -1529,7 +1586,7 @@ void Object::_bind_methods() { ADD_SIGNAL(MethodInfo("script_changed")); BIND_VMETHOD(MethodInfo("_notification", PropertyInfo(Variant::INT, "what"))); - BIND_VMETHOD(MethodInfo("_set:bool", PropertyInfo(Variant::STRING, "property"), PropertyInfo(Variant::NIL, "value"))); + BIND_VMETHOD(MethodInfo(Variant::BOOL, "_set", PropertyInfo(Variant::STRING, "property"), PropertyInfo(Variant::NIL, "value"))); #ifdef TOOLS_ENABLED MethodInfo miget("_get", PropertyInfo(Variant::STRING, "property")); miget.return_val.name = "Variant"; diff --git a/core/object.h b/core/object.h index 8b13477480..6e1ed4308e 100644 --- a/core/object.h +++ b/core/object.h @@ -205,6 +205,12 @@ struct MethodInfo { MethodInfo(Variant::Type ret, const String &p_name, const PropertyInfo &p_param1, const PropertyInfo &p_param2, const PropertyInfo &p_param3); MethodInfo(Variant::Type ret, const String &p_name, const PropertyInfo &p_param1, const PropertyInfo &p_param2, const PropertyInfo &p_param3, const PropertyInfo &p_param4); MethodInfo(Variant::Type ret, const String &p_name, const PropertyInfo &p_param1, const PropertyInfo &p_param2, const PropertyInfo &p_param3, const PropertyInfo &p_param4, const PropertyInfo &p_param5); + MethodInfo(const PropertyInfo &p_ret, const String &p_name); + MethodInfo(const PropertyInfo &p_ret, const String &p_name, const PropertyInfo &p_param1); + MethodInfo(const PropertyInfo &p_ret, const String &p_name, const PropertyInfo &p_param1, const PropertyInfo &p_param2); + MethodInfo(const PropertyInfo &p_ret, const String &p_name, const PropertyInfo &p_param1, const PropertyInfo &p_param2, const PropertyInfo &p_param3); + MethodInfo(const PropertyInfo &p_ret, const String &p_name, const PropertyInfo &p_param1, const PropertyInfo &p_param2, const PropertyInfo &p_param3, const PropertyInfo &p_param4); + MethodInfo(const PropertyInfo &p_ret, const String &p_name, const PropertyInfo &p_param1, const PropertyInfo &p_param2, const PropertyInfo &p_param3, const PropertyInfo &p_param4, const PropertyInfo &p_param5); }; // old cast_to diff --git a/core/script_language.cpp b/core/script_language.cpp index 9a891f9e52..f2be15897e 100644 --- a/core/script_language.cpp +++ b/core/script_language.cpp @@ -54,6 +54,12 @@ void Script::_bind_methods() { ClassDB::bind_method(D_METHOD("get_source_code"), &Script::get_source_code); ClassDB::bind_method(D_METHOD("set_source_code", "source"), &Script::set_source_code); ClassDB::bind_method(D_METHOD("reload", "keep_state"), &Script::reload, DEFVAL(false)); + + ClassDB::bind_method(D_METHOD("has_method", "method_name"), &Script::has_method); + ClassDB::bind_method(D_METHOD("has_script_signal", "signal_name"), &Script::has_script_signal); + + ClassDB::bind_method(D_METHOD("is_tool"), &Script::is_tool); + ClassDB::bind_method(D_METHOD("get_node_type"), &Script::get_node_type); } void ScriptServer::set_scripting_enabled(bool p_enabled) { diff --git a/core/type_info.h b/core/type_info.h index a7d3fa20c8..da6047450c 100644 --- a/core/type_info.h +++ b/core/type_info.h @@ -51,15 +51,15 @@ struct GetTypeInfo { template <> \ struct GetTypeInfo<m_type> { \ enum { VARIANT_TYPE = m_var_type }; \ - static inline PropertyInfo get_class_info() { \ - return PropertyInfo((Variant::Type)VARIANT_TYPE,String()); \ + static inline PropertyInfo get_class_info() { \ + return PropertyInfo((Variant::Type)VARIANT_TYPE, String()); \ } \ }; \ template <> \ struct GetTypeInfo<const m_type &> { \ enum { VARIANT_TYPE = m_var_type }; \ - static inline PropertyInfo get_class_info() { \ - return PropertyInfo((Variant::Type)VARIANT_TYPE,String()); \ + static inline PropertyInfo get_class_info() { \ + return PropertyInfo((Variant::Type)VARIANT_TYPE, String()); \ } \ }; @@ -110,49 +110,47 @@ template <> struct GetTypeInfo<RefPtr> { enum { VARIANT_TYPE = Variant::OBJECT }; static inline PropertyInfo get_class_info() { - return PropertyInfo(Variant::OBJECT,String(),PROPERTY_HINT_RESOURCE_TYPE,"Reference"); + return PropertyInfo(Variant::OBJECT, String(), PROPERTY_HINT_RESOURCE_TYPE, "Reference"); } }; template <> struct GetTypeInfo<const RefPtr &> { enum { VARIANT_TYPE = Variant::OBJECT }; static inline PropertyInfo get_class_info() { - return PropertyInfo(Variant::OBJECT,String(),PROPERTY_HINT_RESOURCE_TYPE,"Reference"); + return PropertyInfo(Variant::OBJECT, String(), PROPERTY_HINT_RESOURCE_TYPE, "Reference"); } }; - //for variant -template<> +template <> struct GetTypeInfo<Variant> { enum { VARIANT_TYPE = Variant::NIL }; static inline PropertyInfo get_class_info() { - return PropertyInfo(Variant::NIL,String(),PROPERTY_HINT_NONE,String(),PROPERTY_USAGE_DEFAULT|PROPERTY_USAGE_NIL_IS_VARIANT); + return PropertyInfo(Variant::NIL, String(), PROPERTY_HINT_NONE, String(), PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_NIL_IS_VARIANT); } }; -template<> -struct GetTypeInfo<const Variant&> { +template <> +struct GetTypeInfo<const Variant &> { enum { VARIANT_TYPE = Variant::NIL }; static inline PropertyInfo get_class_info() { - return PropertyInfo(Variant::NIL,String(),PROPERTY_HINT_NONE,String(),PROPERTY_USAGE_DEFAULT|PROPERTY_USAGE_NIL_IS_VARIANT); + return PropertyInfo(Variant::NIL, String(), PROPERTY_HINT_NONE, String(), PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_NIL_IS_VARIANT); } }; - #define MAKE_TEMPLATE_TYPE_INFO(m_template, m_type, m_var_type) \ template <> \ struct GetTypeInfo<m_template<m_type> > { \ enum { VARIANT_TYPE = m_var_type }; \ - static inline PropertyInfo get_class_info() { \ - return PropertyInfo((Variant::Type)VARIANT_TYPE,String()); \ + static inline PropertyInfo get_class_info() { \ + return PropertyInfo((Variant::Type)VARIANT_TYPE, String()); \ } \ }; \ template <> \ struct GetTypeInfo<const m_template<m_type> &> { \ enum { VARIANT_TYPE = m_var_type }; \ - static inline PropertyInfo get_class_info() { \ - return PropertyInfo((Variant::Type)VARIANT_TYPE,String()); \ + static inline PropertyInfo get_class_info() { \ + return PropertyInfo((Variant::Type)VARIANT_TYPE, String()); \ } \ }; @@ -178,7 +176,6 @@ struct GetTypeInfo<T *, typename EnableIf<TypeInherits<Object, T>::value>::type> static inline PropertyInfo get_class_info() { return PropertyInfo(StringName(T::get_class_static())); } - }; template <typename T> @@ -190,13 +187,13 @@ struct GetTypeInfo<const T *, typename EnableIf<TypeInherits<Object, T>::value>: } }; -#define TEMPL_MAKE_ENUM_TYPE_INFO(m_enum, m_impl) \ - template <> \ - struct GetTypeInfo<m_impl> { \ - enum { VARIANT_TYPE = Variant::INT }; \ - static inline PropertyInfo get_class_info() { \ - return PropertyInfo(Variant::INT,String(),PROPERTY_HINT_NONE,String(),PROPERTY_USAGE_DEFAULT|PROPERTY_USAGE_CLASS_IS_ENUM,String(#m_enum).replace("::",".")); \ - } \ +#define TEMPL_MAKE_ENUM_TYPE_INFO(m_enum, m_impl) \ + template <> \ + struct GetTypeInfo<m_impl> { \ + enum { VARIANT_TYPE = Variant::INT }; \ + static inline PropertyInfo get_class_info() { \ + return PropertyInfo(Variant::INT, String(), PROPERTY_HINT_NONE, String(), PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_CLASS_IS_ENUM, String(#m_enum).replace("::", ".")); \ + } \ }; #define MAKE_ENUM_TYPE_INFO(m_enum) \ @@ -212,9 +209,15 @@ inline StringName __constant_get_enum_name(T param, const String &p_constant) { return GetTypeInfo<T>::get_class_info().class_name; } +#define CLASS_INFO(m_type) \ + (GetTypeInfo<m_type *>::VARIANT_TYPE != Variant::NIL ? \ + GetTypeInfo<m_type *>::get_class_info() : \ + GetTypeInfo<m_type>::get_class_info()) + #else #define MAKE_ENUM_TYPE_INFO(m_enum) +#define CLASS_INFO(m_type) #endif // DEBUG_METHODS_ENABLED diff --git a/core/variant_call.cpp b/core/variant_call.cpp index 77372d1e60..ad15f8f5cb 100644 --- a/core/variant_call.cpp +++ b/core/variant_call.cpp @@ -729,9 +729,6 @@ struct _VariantCall { VCALL_PTR1R(Basis, scaled); VCALL_PTR0R(Basis, get_scale); VCALL_PTR0R(Basis, get_euler); - VCALL_PTR1(Basis, set_scale); - VCALL_PTR1(Basis, set_rotation_euler); - VCALL_PTR2(Basis, set_rotation_axis_angle); VCALL_PTR1R(Basis, tdotx); VCALL_PTR1R(Basis, tdoty); VCALL_PTR1R(Basis, tdotz); @@ -1700,9 +1697,6 @@ void register_variant_methods() { ADDFUNC0(BASIS, REAL, Basis, determinant, varray()); ADDFUNC2(BASIS, BASIS, Basis, rotated, VECTOR3, "axis", REAL, "phi", varray()); ADDFUNC1(BASIS, BASIS, Basis, scaled, VECTOR3, "scale", varray()); - ADDFUNC1(BASIS, NIL, Basis, set_scale, VECTOR3, "scale", varray()); - ADDFUNC1(BASIS, NIL, Basis, set_rotation_euler, VECTOR3, "euler", varray()); - ADDFUNC2(BASIS, NIL, Basis, set_rotation_axis_angle, VECTOR3, "axis", REAL, "angle", varray()); ADDFUNC0(BASIS, VECTOR3, Basis, get_scale, varray()); ADDFUNC0(BASIS, VECTOR3, Basis, get_euler, varray()); ADDFUNC1(BASIS, REAL, Basis, tdotx, VECTOR3, "with", varray()); |