浏览代码

Merge pull request #43854 from akien-mga/ptrcall-always-on

Core: Always enable ptrcall, remove PTRCALL_ENABLED define
Rémi Verschelde 4 年之前
父节点
当前提交
c5451468cf

+ 0 - 3
SConstruct

@@ -67,7 +67,6 @@ if "TERM" in os.environ:
 env_base.AppendENVPath("PATH", os.getenv("PATH"))
 env_base.AppendENVPath("PATH", os.getenv("PATH"))
 env_base.AppendENVPath("PKG_CONFIG_PATH", os.getenv("PKG_CONFIG_PATH"))
 env_base.AppendENVPath("PKG_CONFIG_PATH", os.getenv("PKG_CONFIG_PATH"))
 env_base.disabled_modules = []
 env_base.disabled_modules = []
-env_base.use_ptrcall = False
 env_base.module_version_string = ""
 env_base.module_version_string = ""
 env_base.msvc = False
 env_base.msvc = False
 
 
@@ -561,8 +560,6 @@ if selected_platform in platform_list:
     env["LIBSUFFIX"] = suffix + env["LIBSUFFIX"]
     env["LIBSUFFIX"] = suffix + env["LIBSUFFIX"]
     env["SHLIBSUFFIX"] = suffix + env["SHLIBSUFFIX"]
     env["SHLIBSUFFIX"] = suffix + env["SHLIBSUFFIX"]
 
 
-    if env.use_ptrcall:
-        env.Append(CPPDEFINES=["PTRCALL_ENABLED"])
     if env["tools"]:
     if env["tools"]:
         env.Append(CPPDEFINES=["TOOLS_ENABLED"])
         env.Append(CPPDEFINES=["TOOLS_ENABLED"])
     if env["disable_3d"]:
     if env["disable_3d"]:

+ 2 - 15
core/object/method_bind.h

@@ -123,10 +123,7 @@ public:
 	_FORCE_INLINE_ int get_argument_count() const { return argument_count; };
 	_FORCE_INLINE_ int get_argument_count() const { return argument_count; };
 
 
 	virtual Variant call(Object *p_object, const Variant **p_args, int p_arg_count, Callable::CallError &r_error) = 0;
 	virtual Variant call(Object *p_object, const Variant **p_args, int p_arg_count, Callable::CallError &r_error) = 0;
-
-#ifdef PTRCALL_ENABLED
 	virtual void ptrcall(Object *p_object, const void **p_args, void *r_ret) = 0;
 	virtual void ptrcall(Object *p_object, const void **p_args, void *r_ret) = 0;
-#endif
 
 
 	StringName get_name() const;
 	StringName get_name() const;
 	void set_name(const StringName &p_name);
 	void set_name(const StringName &p_name);
@@ -205,11 +202,9 @@ public:
 #endif
 #endif
 	}
 	}
 
 
-#ifdef PTRCALL_ENABLED
 	virtual void ptrcall(Object *p_object, const void **p_args, void *r_ret) {
 	virtual void ptrcall(Object *p_object, const void **p_args, void *r_ret) {
-		ERR_FAIL(); //can't call
-	} //todo
-#endif
+		ERR_FAIL(); // Can't call.
+	}
 
 
 	void set_method(NativeCall p_method) { call_method = p_method; }
 	void set_method(NativeCall p_method) { call_method = p_method; }
 	virtual bool is_const() const { return false; }
 	virtual bool is_const() const { return false; }
@@ -289,7 +284,6 @@ public:
 		return Variant();
 		return Variant();
 	}
 	}
 
 
-#ifdef PTRCALL_ENABLED
 	virtual void ptrcall(Object *p_object, const void **p_args, void *r_ret) {
 	virtual void ptrcall(Object *p_object, const void **p_args, void *r_ret) {
 #ifdef TYPED_METHOD_BIND
 #ifdef TYPED_METHOD_BIND
 		call_with_ptr_args<T, P...>(static_cast<T *>(p_object), method, p_args);
 		call_with_ptr_args<T, P...>(static_cast<T *>(p_object), method, p_args);
@@ -297,7 +291,6 @@ public:
 		call_with_ptr_args<MB_T, P...>((MB_T *)(p_object), method, p_args);
 		call_with_ptr_args<MB_T, P...>((MB_T *)(p_object), method, p_args);
 #endif
 #endif
 	}
 	}
-#endif
 
 
 	MethodBindT(void (MB_T::*p_method)(P...)) {
 	MethodBindT(void (MB_T::*p_method)(P...)) {
 		method = p_method;
 		method = p_method;
@@ -370,7 +363,6 @@ public:
 		return Variant();
 		return Variant();
 	}
 	}
 
 
-#ifdef PTRCALL_ENABLED
 	virtual void ptrcall(Object *p_object, const void **p_args, void *r_ret) {
 	virtual void ptrcall(Object *p_object, const void **p_args, void *r_ret) {
 #ifdef TYPED_METHOD_BIND
 #ifdef TYPED_METHOD_BIND
 		call_with_ptr_argsc<T, P...>(static_cast<T *>(p_object), method, p_args);
 		call_with_ptr_argsc<T, P...>(static_cast<T *>(p_object), method, p_args);
@@ -378,7 +370,6 @@ public:
 		call_with_ptr_argsc<MB_T, P...>((MB_T *)(p_object), method, p_args);
 		call_with_ptr_argsc<MB_T, P...>((MB_T *)(p_object), method, p_args);
 #endif
 #endif
 	}
 	}
-#endif
 
 
 	MethodBindTC(void (MB_T::*p_method)(P...) const) {
 	MethodBindTC(void (MB_T::*p_method)(P...) const) {
 		method = p_method;
 		method = p_method;
@@ -462,7 +453,6 @@ public:
 		return ret;
 		return ret;
 	}
 	}
 
 
-#ifdef PTRCALL_ENABLED
 	virtual void ptrcall(Object *p_object, const void **p_args, void *r_ret) {
 	virtual void ptrcall(Object *p_object, const void **p_args, void *r_ret) {
 #ifdef TYPED_METHOD_BIND
 #ifdef TYPED_METHOD_BIND
 		call_with_ptr_args_ret<T, R, P...>(static_cast<T *>(p_object), method, p_args, r_ret);
 		call_with_ptr_args_ret<T, R, P...>(static_cast<T *>(p_object), method, p_args, r_ret);
@@ -470,7 +460,6 @@ public:
 		call_with_ptr_args_ret<MB_T, R, P...>((MB_T *)(p_object), method, p_args, r_ret);
 		call_with_ptr_args_ret<MB_T, R, P...>((MB_T *)(p_object), method, p_args, r_ret);
 #endif
 #endif
 	}
 	}
-#endif
 
 
 	MethodBindTR(R (MB_T::*p_method)(P...)) {
 	MethodBindTR(R (MB_T::*p_method)(P...)) {
 		method = p_method;
 		method = p_method;
@@ -555,7 +544,6 @@ public:
 		return ret;
 		return ret;
 	}
 	}
 
 
-#ifdef PTRCALL_ENABLED
 	virtual void ptrcall(Object *p_object, const void **p_args, void *r_ret) {
 	virtual void ptrcall(Object *p_object, const void **p_args, void *r_ret) {
 #ifdef TYPED_METHOD_BIND
 #ifdef TYPED_METHOD_BIND
 		call_with_ptr_args_retc<T, R, P...>(static_cast<T *>(p_object), method, p_args, r_ret);
 		call_with_ptr_args_retc<T, R, P...>(static_cast<T *>(p_object), method, p_args, r_ret);
@@ -563,7 +551,6 @@ public:
 		call_with_ptr_args_retc<MB_T, R, P...>((MB_T *)(p_object), method, p_args, r_ret);
 		call_with_ptr_args_retc<MB_T, R, P...>((MB_T *)(p_object), method, p_args, r_ret);
 #endif
 #endif
 	}
 	}
-#endif
 
 
 	MethodBindTRC(R (MB_T::*p_method)(P...) const) {
 	MethodBindTRC(R (MB_T::*p_method)(P...) const) {
 		method = p_method;
 		method = p_method;

+ 0 - 4
core/object/reference.h

@@ -252,8 +252,6 @@ public:
 	WeakRef() {}
 	WeakRef() {}
 };
 };
 
 
-#ifdef PTRCALL_ENABLED
-
 template <class T>
 template <class T>
 struct PtrToArg<Ref<T>> {
 struct PtrToArg<Ref<T>> {
 	_FORCE_INLINE_ static Ref<T> convert(const void *p_ptr) {
 	_FORCE_INLINE_ static Ref<T> convert(const void *p_ptr) {
@@ -272,8 +270,6 @@ struct PtrToArg<const Ref<T> &> {
 	}
 	}
 };
 };
 
 
-#endif // PTRCALL_ENABLED
-
 #ifdef DEBUG_METHODS_ENABLED
 #ifdef DEBUG_METHODS_ENABLED
 
 
 template <class T>
 template <class T>

+ 1 - 25
core/variant/binder_common.h

@@ -63,8 +63,6 @@ struct VariantCaster<const T &> {
 	}
 	}
 };
 };
 
 
-#ifdef PTRCALL_ENABLED
-
 #define VARIANT_ENUM_CAST(m_enum)                                            \
 #define VARIANT_ENUM_CAST(m_enum)                                            \
 	MAKE_ENUM_TYPE_INFO(m_enum)                                              \
 	MAKE_ENUM_TYPE_INFO(m_enum)                                              \
 	template <>                                                              \
 	template <>                                                              \
@@ -83,19 +81,6 @@ struct VariantCaster<const T &> {
 		}                                                                    \
 		}                                                                    \
 	};
 	};
 
 
-#else
-
-#define VARIANT_ENUM_CAST(m_enum)                                     \
-	MAKE_ENUM_TYPE_INFO(m_enum)                                       \
-	template <>                                                       \
-	struct VariantCaster<m_enum> {                                    \
-		static _FORCE_INLINE_ m_enum cast(const Variant &p_variant) { \
-			return (m_enum)p_variant.operator int();                  \
-		}                                                             \
-	};
-
-#endif
-
 // Object enum casts must go here
 // Object enum casts must go here
 VARIANT_ENUM_CAST(Object::ConnectFlags);
 VARIANT_ENUM_CAST(Object::ConnectFlags);
 
 
@@ -118,7 +103,7 @@ struct VariantCaster<char32_t> {
 		return (char32_t)p_variant.operator int();
 		return (char32_t)p_variant.operator int();
 	}
 	}
 };
 };
-#ifdef PTRCALL_ENABLED
+
 template <>
 template <>
 struct PtrToArg<char32_t> {
 struct PtrToArg<char32_t> {
 	_FORCE_INLINE_ static char32_t convert(const void *p_ptr) {
 	_FORCE_INLINE_ static char32_t convert(const void *p_ptr) {
@@ -128,7 +113,6 @@ struct PtrToArg<char32_t> {
 		*(int *)p_ptr = p_val;
 		*(int *)p_ptr = p_val;
 	}
 	}
 };
 };
-#endif
 
 
 template <typename T>
 template <typename T>
 struct VariantObjectClassChecker {
 struct VariantObjectClassChecker {
@@ -228,8 +212,6 @@ void call_with_variant_argsc_helper(T *p_instance, void (T::*p_method)(P...) con
 	(void)(p_args); //avoid warning
 	(void)(p_args); //avoid warning
 }
 }
 
 
-#ifdef PTRCALL_ENABLED
-
 template <class T, class... P, size_t... Is>
 template <class T, class... P, size_t... Is>
 void call_with_ptr_args_helper(T *p_instance, void (T::*p_method)(P...), const void **p_args, IndexSequence<Is...>) {
 void call_with_ptr_args_helper(T *p_instance, void (T::*p_method)(P...), const void **p_args, IndexSequence<Is...>) {
 	(p_instance->*p_method)(PtrToArg<P>::convert(p_args[Is])...);
 	(p_instance->*p_method)(PtrToArg<P>::convert(p_args[Is])...);
@@ -255,8 +237,6 @@ void call_with_ptr_args_static_retc_helper(T *p_instance, R (*p_method)(T *, P..
 	PtrToArg<R>::encode(p_method(p_instance, PtrToArg<P>::convert(p_args[Is])...), r_ret);
 	PtrToArg<R>::encode(p_method(p_instance, PtrToArg<P>::convert(p_args[Is])...), r_ret);
 }
 }
 
 
-#endif // PTRCALL_ENABLED
-
 template <class T, class... P, size_t... Is>
 template <class T, class... P, size_t... Is>
 void call_with_validated_variant_args_helper(T *p_instance, void (T::*p_method)(P...), const Variant **p_args, IndexSequence<Is...>) {
 void call_with_validated_variant_args_helper(T *p_instance, void (T::*p_method)(P...), const Variant **p_args, IndexSequence<Is...>) {
 	(p_instance->*p_method)((VariantInternalAccessor<typename GetSimpleTypeT<P>::type_t>::get(p_args[Is]))...);
 	(p_instance->*p_method)((VariantInternalAccessor<typename GetSimpleTypeT<P>::type_t>::get(p_args[Is]))...);
@@ -450,8 +430,6 @@ void call_with_variant_args_retc_dv(T *p_instance, R (T::*p_method)(P...) const,
 	call_with_variant_args_retc_helper(p_instance, p_method, args, r_ret, r_error, BuildIndexSequence<sizeof...(P)>{});
 	call_with_variant_args_retc_helper(p_instance, p_method, args, r_ret, r_error, BuildIndexSequence<sizeof...(P)>{});
 }
 }
 
 
-#ifdef PTRCALL_ENABLED
-
 template <class T, class... P>
 template <class T, class... P>
 void call_with_ptr_args(T *p_instance, void (T::*p_method)(P...), const void **p_args) {
 void call_with_ptr_args(T *p_instance, void (T::*p_method)(P...), const void **p_args) {
 	call_with_ptr_args_helper<T, P...>(p_instance, p_method, p_args, BuildIndexSequence<sizeof...(P)>{});
 	call_with_ptr_args_helper<T, P...>(p_instance, p_method, p_args, BuildIndexSequence<sizeof...(P)>{});
@@ -477,8 +455,6 @@ void call_with_ptr_args_static_retc(T *p_instance, R (*p_method)(T *, P...), con
 	call_with_ptr_args_static_retc_helper<T, R, P...>(p_instance, p_method, p_args, r_ret, BuildIndexSequence<sizeof...(P)>{});
 	call_with_ptr_args_static_retc_helper<T, R, P...>(p_instance, p_method, p_args, r_ret, BuildIndexSequence<sizeof...(P)>{});
 }
 }
 
 
-#endif // PTRCALL_ENABLED
-
 template <class T, class... P>
 template <class T, class... P>
 void call_with_validated_variant_args(Variant *base, void (T::*p_method)(P...), const Variant **p_args) {
 void call_with_validated_variant_args(Variant *base, void (T::*p_method)(P...), const Variant **p_args) {
 	call_with_validated_variant_args_helper<T, P...>(VariantGetInternalPtr<T>::get_ptr(base), p_method, p_args, BuildIndexSequence<sizeof...(P)>{});
 	call_with_validated_variant_args_helper<T, P...>(VariantGetInternalPtr<T>::get_ptr(base), p_method, p_args, BuildIndexSequence<sizeof...(P)>{});

+ 8 - 18
core/variant/method_ptrcall.h

@@ -36,11 +36,8 @@
 #include "core/typedefs.h"
 #include "core/typedefs.h"
 #include "core/variant/variant.h"
 #include "core/variant/variant.h"
 
 
-#ifdef PTRCALL_ENABLED
-
 template <class T>
 template <class T>
-struct PtrToArg {
-};
+struct PtrToArg {};
 
 
 #define MAKE_PTRARG(m_type)                                            \
 #define MAKE_PTRARG(m_type)                                            \
 	template <>                                                        \
 	template <>                                                        \
@@ -146,7 +143,7 @@ MAKE_PTRARG(PackedVector3Array);
 MAKE_PTRARG(PackedColorArray);
 MAKE_PTRARG(PackedColorArray);
 MAKE_PTRARG_BY_REFERENCE(Variant);
 MAKE_PTRARG_BY_REFERENCE(Variant);
 
 
-//this is for Object
+// This is for Object.
 
 
 template <class T>
 template <class T>
 struct PtrToArg<T *> {
 struct PtrToArg<T *> {
@@ -170,7 +167,7 @@ struct PtrToArg<const T *> {
 	}
 	}
 };
 };
 
 
-//this is for ObjectID
+// This is for ObjectID.
 
 
 template <>
 template <>
 struct PtrToArg<ObjectID> {
 struct PtrToArg<ObjectID> {
@@ -183,7 +180,7 @@ struct PtrToArg<ObjectID> {
 	}
 	}
 };
 };
 
 
-//this is for the special cases used by Variant
+// This is for the special cases used by Variant.
 
 
 #define MAKE_VECARG(m_type)                                                              \
 #define MAKE_VECARG(m_type)                                                              \
 	template <>                                                                          \
 	template <>                                                                          \
@@ -274,18 +271,11 @@ struct PtrToArg<ObjectID> {
 			return ret;                                                                  \
 			return ret;                                                                  \
 		}                                                                                \
 		}                                                                                \
 	}
 	}
-/*
-MAKE_VECARG(String);
-MAKE_VECARG(uint8_t);
-MAKE_VECARG(int);
-MAKE_VECARG(float);
-MAKE_VECARG(Vector2);
-MAKE_VECARG(Vector3);
-MAKE_VECARG(Color);
-*/
+
 MAKE_VECARG_ALT(String, StringName);
 MAKE_VECARG_ALT(String, StringName);
 
 
-//for stuff that gets converted to Array vectors
+// For stuff that gets converted to Array vectors.
+
 #define MAKE_VECARR(m_type)                                                    \
 #define MAKE_VECARR(m_type)                                                    \
 	template <>                                                                \
 	template <>                                                                \
 	struct PtrToArg<Vector<m_type>> {                                          \
 	struct PtrToArg<Vector<m_type>> {                                          \
@@ -429,6 +419,7 @@ struct PtrToArg<Vector<Face3>> {
 		}
 		}
 	}
 	}
 };
 };
+
 template <>
 template <>
 struct PtrToArg<const Vector<Face3> &> {
 struct PtrToArg<const Vector<Face3> &> {
 	_FORCE_INLINE_ static Vector<Face3> convert(const void *p_ptr) {
 	_FORCE_INLINE_ static Vector<Face3> convert(const void *p_ptr) {
@@ -450,4 +441,3 @@ struct PtrToArg<const Vector<Face3> &> {
 };
 };
 
 
 #endif // METHOD_PTRCALL_H
 #endif // METHOD_PTRCALL_H
-#endif

+ 0 - 4
core/variant/typed_array.h

@@ -120,8 +120,6 @@ MAKE_TYPED_ARRAY(Vector<Vector2>, Variant::PACKED_VECTOR2_ARRAY)
 MAKE_TYPED_ARRAY(Vector<Vector3>, Variant::PACKED_VECTOR3_ARRAY)
 MAKE_TYPED_ARRAY(Vector<Vector3>, Variant::PACKED_VECTOR3_ARRAY)
 MAKE_TYPED_ARRAY(Vector<Color>, Variant::PACKED_COLOR_ARRAY)
 MAKE_TYPED_ARRAY(Vector<Color>, Variant::PACKED_COLOR_ARRAY)
 
 
-#ifdef PTRCALL_ENABLED
-
 template <class T>
 template <class T>
 struct PtrToArg<TypedArray<T>> {
 struct PtrToArg<TypedArray<T>> {
 	_FORCE_INLINE_ static TypedArray<T> convert(const void *p_ptr) {
 	_FORCE_INLINE_ static TypedArray<T> convert(const void *p_ptr) {
@@ -140,8 +138,6 @@ struct PtrToArg<const TypedArray<T> &> {
 	}
 	}
 };
 };
 
 
-#endif // PTRCALL_ENABLED
-
 #ifdef DEBUG_METHODS_ENABLED
 #ifdef DEBUG_METHODS_ENABLED
 
 
 template <class T>
 template <class T>

+ 0 - 3
core/variant/variant.h

@@ -370,7 +370,6 @@ public:
 #ifdef NEED_LONG_INT
 #ifdef NEED_LONG_INT
 	Variant(signed long p_long); // real one
 	Variant(signed long p_long); // real one
 	Variant(unsigned long p_long);
 	Variant(unsigned long p_long);
-//Variant(long unsigned int p_long);
 #endif
 #endif
 	Variant(signed short p_short); // real one
 	Variant(signed short p_short); // real one
 	Variant(unsigned short p_short);
 	Variant(unsigned short p_short);
@@ -471,10 +470,8 @@ public:
 	static Variant::Type get_operator_return_type(Operator p_operator, Type p_type_a, Type p_type_b);
 	static Variant::Type get_operator_return_type(Operator p_operator, Type p_type_a, Type p_type_b);
 	typedef void (*ValidatedOperatorEvaluator)(const Variant *left, const Variant *right, Variant *r_ret);
 	typedef void (*ValidatedOperatorEvaluator)(const Variant *left, const Variant *right, Variant *r_ret);
 	static ValidatedOperatorEvaluator get_validated_operator_evaluator(Operator p_operator, Type p_type_a, Type p_type_b);
 	static ValidatedOperatorEvaluator get_validated_operator_evaluator(Operator p_operator, Type p_type_a, Type p_type_b);
-#ifdef PTRCALL_ENABLED
 	typedef void (*PTROperatorEvaluator)(const void *left, const void *right, void *r_ret);
 	typedef void (*PTROperatorEvaluator)(const void *left, const void *right, void *r_ret);
 	static PTROperatorEvaluator get_ptr_operator_evaluator(Operator p_operator, Type p_type_a, Type p_type_b);
 	static PTROperatorEvaluator get_ptr_operator_evaluator(Operator p_operator, Type p_type_a, Type p_type_b);
-#endif
 
 
 	void zero();
 	void zero();
 	Variant duplicate(bool deep = false) const;
 	Variant duplicate(bool deep = false) const;

文件差异内容过多而无法显示
+ 19 - 193
core/variant/variant_op.cpp


+ 0 - 2
modules/gdnative/SCsub

@@ -30,5 +30,3 @@ _, gensource = env_gdnative.CommandNoCache(
     env.Run(gdnative_builders.build_gdnative_api_struct, "Generating GDNative API."),
     env.Run(gdnative_builders.build_gdnative_api_struct, "Generating GDNative API."),
 )
 )
 env_gdnative.add_source_files(env.modules_sources, [gensource])
 env_gdnative.add_source_files(env.modules_sources, [gensource])
-
-env.use_ptrcall = True

+ 1 - 1
modules/gdnative/config.py

@@ -3,7 +3,7 @@ def can_build(env, platform):
 
 
 
 
 def configure(env):
 def configure(env):
-    env.use_ptrcall = True
+    pass
 
 
 
 
 def get_doc_classes():
 def get_doc_classes():

+ 0 - 1
modules/mono/config.py

@@ -11,7 +11,6 @@ def configure(env):
     if platform not in supported_platforms:
     if platform not in supported_platforms:
         raise RuntimeError("This module does not currently support building for this platform")
         raise RuntimeError("This module does not currently support building for this platform")
 
 
-    env.use_ptrcall = True
     env.add_module_version_string("mono")
     env.add_module_version_string("mono")
 
 
     from SCons.Script import BoolVariable, PathVariable, Variables, Help
     from SCons.Script import BoolVariable, PathVariable, Variables, Help

部分文件因为文件数量过多而无法显示