diff options
Diffstat (limited to 'core')
| -rw-r--r-- | core/SCsub | 4 | ||||
| -rw-r--r-- | core/class_db.cpp | 10 | ||||
| -rw-r--r-- | core/class_db.h | 23 | ||||
| -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 |
8 files changed, 104 insertions, 58 deletions
diff --git a/core/SCsub b/core/SCsub index 4c541d7269..c1e57f6840 100644 --- a/core/SCsub +++ b/core/SCsub @@ -18,7 +18,7 @@ gd_cpp = '#include "project_settings.h"\n' gd_cpp += gd_inc gd_cpp += "void ProjectSettings::register_global_defaults() {\n" + gd_call + "\n}\n" -f = open("global_defaults.gen.cpp", "wb") +f = open("global_defaults.gen.cpp", "w") f.write(gd_cpp) f.close() @@ -47,7 +47,7 @@ if ("SCRIPT_AES256_ENCRYPTION_KEY" in os.environ): txt = "0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0" print("Invalid AES256 encryption key, not 64 bits hex: " + e) -f = open("script_encryption_key.gen.cpp", "wb") +f = open("script_encryption_key.gen.cpp", "w") f.write("#include \"project_settings.h\"\nuint8_t script_encryption_key[32]={" + txt + "};\n") f.close() diff --git a/core/class_db.cpp b/core/class_db.cpp index 0d6c72afa8..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); } @@ -864,7 +860,7 @@ void ClassDB::add_property(StringName p_class, const PropertyInfo &p_pinfo, cons MethodBind *mb_get = NULL; if (p_getter) { - MethodBind *mb_get = get_method(p_class, p_getter); + mb_get = get_method(p_class, p_getter); #ifdef DEBUG_METHODS_ENABLED if (!mb_get) { 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/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 |