Skip to content

Commit 7473b98

Browse files
Repiteodsnopek
authored andcommitted
Enforce template syntax typename over class
(cherry picked from commit 87f5fb0)
1 parent 98ad839 commit 7473b98

38 files changed

+224
-224
lines changed

binding_generator.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -567,7 +567,7 @@ def generate_builtin_class_header(builtin_api, size, used_classes, fully_used_cl
567567

568568
vararg = method["is_vararg"]
569569
if vararg:
570-
result.append("\ttemplate<class... Args>")
570+
result.append("\ttemplate<typename... Args>")
571571

572572
method_signature = "\t"
573573
if "is_static" in method and method["is_static"]:
@@ -666,7 +666,7 @@ def generate_builtin_class_header(builtin_api, size, used_classes, fully_used_cl
666666
result.append("\tchar32_t *ptrw();")
667667

668668
if class_name == "Array":
669-
result.append("\ttemplate <class... Args>")
669+
result.append("\ttemplate <typename... Args>")
670670
result.append("\tstatic Array make(Args... args) {")
671671
result.append("\t\treturn helpers::append_all(Array(), args...);")
672672
result.append("\t}")
@@ -1427,7 +1427,7 @@ def generate_engine_class_header(class_api, used_classes, fully_used_classes, us
14271427
result.append("protected:")
14281428
# T is the custom class we want to register (from which the call initiates, going up the inheritance chain),
14291429
# B is its base class (can be a custom class too, that's why we pass it).
1430-
result.append("\ttemplate <class T, class B>")
1430+
result.append("\ttemplate <typename T, typename B>")
14311431
result.append("\tstatic void register_virtuals() {")
14321432
if class_name != "Object":
14331433
result.append(f"\t\t{inherits}::register_virtuals<T, B>();")
@@ -1473,16 +1473,16 @@ def generate_engine_class_header(class_api, used_classes, fully_used_classes, us
14731473
if class_name == "Object":
14741474
result.append("")
14751475

1476-
result.append("\ttemplate<class T>")
1476+
result.append("\ttemplate<typename T>")
14771477
result.append("\tstatic T *cast_to(Object *p_object);")
14781478

1479-
result.append("\ttemplate<class T>")
1479+
result.append("\ttemplate<typename T>")
14801480
result.append("\tstatic const T *cast_to(const Object *p_object);")
14811481

14821482
result.append("\tvirtual ~Object() = default;")
14831483

14841484
elif use_template_get_node and class_name == "Node":
1485-
result.append("\ttemplate<class T>")
1485+
result.append("\ttemplate<typename T>")
14861486
result.append(
14871487
"\tT *get_node(const NodePath &p_path) const { return Object::cast_to<T>(get_node_internal(p_path)); }"
14881488
)
@@ -2116,7 +2116,7 @@ def make_varargs_template(
21162116
if with_public_declare:
21172117
function_signature = "public: "
21182118

2119-
function_signature += "template<class... Args> "
2119+
function_signature += "template<typename... Args> "
21202120

21212121
if static:
21222122
function_signature += "static "

include/godot_cpp/classes/editor_plugin_registration.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,11 +47,11 @@ class EditorPlugins {
4747
static void remove_plugin_class(const StringName &p_class_name);
4848
static void deinitialize(GDExtensionInitializationLevel p_level);
4949

50-
template <class T>
50+
template <typename T>
5151
static void add_by_type() {
5252
add_plugin_class(T::get_class_static());
5353
}
54-
template <class T>
54+
template <typename T>
5555
static void remove_by_type() {
5656
remove_plugin_class(T::get_class_static());
5757
}

include/godot_cpp/classes/ref.hpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ namespace godot {
4545

4646
class RefCounted;
4747

48-
template <class T>
48+
template <typename T>
4949
class Ref {
5050
T *reference = nullptr;
5151

@@ -108,7 +108,7 @@ class Ref {
108108
ref(p_from);
109109
}
110110

111-
template <class T_Other>
111+
template <typename T_Other>
112112
void operator=(const Ref<T_Other> &p_from) {
113113
RefCounted *refb = const_cast<RefCounted *>(static_cast<const RefCounted *>(p_from.ptr()));
114114
if (!refb) {
@@ -144,7 +144,7 @@ class Ref {
144144
}
145145
}
146146

147-
template <class T_Other>
147+
template <typename T_Other>
148148
void reference_ptr(T_Other *p_ptr) {
149149
if (reference == p_ptr) {
150150
return;
@@ -161,7 +161,7 @@ class Ref {
161161
ref(p_from);
162162
}
163163

164-
template <class T_Other>
164+
template <typename T_Other>
165165
Ref(const Ref<T_Other> &p_from) {
166166
RefCounted *refb = const_cast<RefCounted *>(static_cast<const RefCounted *>(p_from.ptr()));
167167
if (!refb) {
@@ -226,7 +226,7 @@ class Ref {
226226
}
227227
};
228228

229-
template <class T>
229+
template <typename T>
230230
struct PtrToArg<Ref<T>> {
231231
_FORCE_INLINE_ static Ref<T> convert(const void *p_ptr) {
232232
GDExtensionRefPtr ref = (GDExtensionRefPtr)p_ptr;
@@ -248,7 +248,7 @@ struct PtrToArg<Ref<T>> {
248248
}
249249
};
250250

251-
template <class T>
251+
template <typename T>
252252
struct PtrToArg<const Ref<T> &> {
253253
typedef Ref<T> EncodeT;
254254

@@ -259,7 +259,7 @@ struct PtrToArg<const Ref<T> &> {
259259
}
260260
};
261261

262-
template <class T>
262+
template <typename T>
263263
struct GetTypeInfo<Ref<T>, typename EnableIf<TypeInherits<RefCounted, T>::value>::type> {
264264
static const GDExtensionVariantType VARIANT_TYPE = GDEXTENSION_VARIANT_TYPE_OBJECT;
265265
static const GDExtensionClassMethodArgumentMetadata METADATA = GDEXTENSION_METHOD_ARGUMENT_METADATA_NONE;
@@ -269,7 +269,7 @@ struct GetTypeInfo<Ref<T>, typename EnableIf<TypeInherits<RefCounted, T>::value>
269269
}
270270
};
271271

272-
template <class T>
272+
template <typename T>
273273
struct GetTypeInfo<const Ref<T> &, typename EnableIf<TypeInherits<RefCounted, T>::value>::type> {
274274
static const GDExtensionVariantType VARIANT_TYPE = GDEXTENSION_VARIANT_TYPE_OBJECT;
275275
static const GDExtensionClassMethodArgumentMetadata METADATA = GDEXTENSION_METHOD_ARGUMENT_METADATA_NONE;

include/godot_cpp/classes/wrapped.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ void add_engine_class_registration_callback(EngineClassRegistrationCallback p_ca
117117
void register_engine_class(const StringName &p_name, const GDExtensionInstanceBindingCallbacks *p_callbacks);
118118
void register_engine_classes();
119119

120-
template <class T>
120+
template <typename T>
121121
struct EngineClassRegistration {
122122
EngineClassRegistration() {
123123
add_engine_class_registration_callback(&EngineClassRegistration<T>::callback);
@@ -186,7 +186,7 @@ protected:
186186
return (::godot::String(::godot::Wrapped::*)() const) & m_class::_to_string; \
187187
} \
188188
\
189-
template <class T, class B> \
189+
template <typename T, typename B> \
190190
static void register_virtuals() { \
191191
m_inherits::register_virtuals<T, B>(); \
192192
} \

0 commit comments

Comments
 (0)