Skip to content

Commit 44d78ec

Browse files
authored
Merge pull request #1409 from Repiteo/class-to-typename
Enforce template syntax `typename` over `class`
2 parents a62f633 + 87f5fb0 commit 44d78ec

38 files changed

+228
-228
lines changed

binding_generator.py

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

697697
vararg = method["is_vararg"]
698698
if vararg:
699-
result.append("\ttemplate<class... Args>")
699+
result.append("\ttemplate<typename... Args>")
700700

701701
method_signature = "\t"
702702
if "is_static" in method and method["is_static"]:
@@ -795,7 +795,7 @@ def generate_builtin_class_header(builtin_api, size, used_classes, fully_used_cl
795795
result.append("\tchar32_t *ptrw();")
796796

797797
if class_name == "Array":
798-
result.append("\ttemplate <class... Args>")
798+
result.append("\ttemplate <typename... Args>")
799799
result.append("\tstatic Array make(Args... args) {")
800800
result.append("\t\treturn helpers::append_all(Array(), args...);")
801801
result.append("\t}")
@@ -1556,7 +1556,7 @@ def generate_engine_class_header(class_api, used_classes, fully_used_classes, us
15561556
result.append("protected:")
15571557
# T is the custom class we want to register (from which the call initiates, going up the inheritance chain),
15581558
# B is its base class (can be a custom class too, that's why we pass it).
1559-
result.append("\ttemplate <class T, class B>")
1559+
result.append("\ttemplate <typename T, typename B>")
15601560
result.append("\tstatic void register_virtuals() {")
15611561
if class_name != "Object":
15621562
result.append(f"\t\t{inherits}::register_virtuals<T, B>();")
@@ -1602,16 +1602,16 @@ def generate_engine_class_header(class_api, used_classes, fully_used_classes, us
16021602
if class_name == "Object":
16031603
result.append("")
16041604

1605-
result.append("\ttemplate<class T>")
1605+
result.append("\ttemplate<typename T>")
16061606
result.append("\tstatic T *cast_to(Object *p_object);")
16071607

1608-
result.append("\ttemplate<class T>")
1608+
result.append("\ttemplate<typename T>")
16091609
result.append("\tstatic const T *cast_to(const Object *p_object);")
16101610

16111611
result.append("\tvirtual ~Object() = default;")
16121612

16131613
elif use_template_get_node and class_name == "Node":
1614-
result.append("\ttemplate<class T>")
1614+
result.append("\ttemplate<typename T>")
16151615
result.append(
16161616
"\tT *get_node(const NodePath &p_path) const { return Object::cast_to<T>(get_node_internal(p_path)); }"
16171617
)
@@ -2245,7 +2245,7 @@ def make_varargs_template(
22452245
if with_public_declare:
22462246
function_signature = "public: "
22472247

2248-
function_signature += "template<class... Args> "
2248+
function_signature += "template<typename... Args> "
22492249

22502250
if static:
22512251
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: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -115,13 +115,13 @@ _FORCE_INLINE_ void snarray_add_str(Vector<StringName> &arr, const StringName &p
115115
arr.push_back(p_str);
116116
}
117117

118-
template <class... P>
118+
template <typename... P>
119119
_FORCE_INLINE_ void snarray_add_str(Vector<StringName> &arr, const StringName &p_str, P... p_args) {
120120
arr.push_back(p_str);
121121
snarray_add_str(arr, p_args...);
122122
}
123123

124-
template <class... P>
124+
template <typename... P>
125125
_FORCE_INLINE_ Vector<StringName> snarray(P... p_args) {
126126
Vector<StringName> arr;
127127
snarray_add_str(arr, p_args...);
@@ -138,7 +138,7 @@ void add_engine_class_registration_callback(EngineClassRegistrationCallback p_ca
138138
void register_engine_class(const StringName &p_name, const GDExtensionInstanceBindingCallbacks *p_callbacks);
139139
void register_engine_classes();
140140

141-
template <class T>
141+
template <typename T>
142142
struct EngineClassRegistration {
143143
EngineClassRegistration() {
144144
add_engine_class_registration_callback(&EngineClassRegistration<T>::callback);
@@ -207,7 +207,7 @@ protected:
207207
return (::godot::String(::godot::Wrapped::*)() const) & m_class::_to_string; \
208208
} \
209209
\
210-
template <class T, class B> \
210+
template <typename T, typename B> \
211211
static void register_virtuals() { \
212212
m_inherits::register_virtuals<T, B>(); \
213213
} \

0 commit comments

Comments
 (0)