Skip to content

Commit 87f5fb0

Browse files
committed
Enforce template syntax typename over class
1 parent cc1217a commit 87f5fb0

38 files changed

+228
-228
lines changed

binding_generator.py

+7-7
Original file line numberDiff line numberDiff line change
@@ -687,7 +687,7 @@ def generate_builtin_class_header(builtin_api, size, used_classes, fully_used_cl
687687

688688
vararg = method["is_vararg"]
689689
if vararg:
690-
result.append("\ttemplate<class... Args>")
690+
result.append("\ttemplate<typename... Args>")
691691

692692
method_signature = "\t"
693693
if "is_static" in method and method["is_static"]:
@@ -786,7 +786,7 @@ def generate_builtin_class_header(builtin_api, size, used_classes, fully_used_cl
786786
result.append("\tchar32_t *ptrw();")
787787

788788
if class_name == "Array":
789-
result.append("\ttemplate <class... Args>")
789+
result.append("\ttemplate <typename... Args>")
790790
result.append("\tstatic Array make(Args... args) {")
791791
result.append("\t\treturn helpers::append_all(Array(), args...);")
792792
result.append("\t}")
@@ -1527,7 +1527,7 @@ def generate_engine_class_header(class_api, used_classes, fully_used_classes, us
15271527
result.append("protected:")
15281528
# T is the custom class we want to register (from which the call initiates, going up the inheritance chain),
15291529
# B is its base class (can be a custom class too, that's why we pass it).
1530-
result.append("\ttemplate <class T, class B>")
1530+
result.append("\ttemplate <typename T, typename B>")
15311531
result.append("\tstatic void register_virtuals() {")
15321532
if class_name != "Object":
15331533
result.append(f"\t\t{inherits}::register_virtuals<T, B>();")
@@ -1573,16 +1573,16 @@ def generate_engine_class_header(class_api, used_classes, fully_used_classes, us
15731573
if class_name == "Object":
15741574
result.append("")
15751575

1576-
result.append("\ttemplate<class T>")
1576+
result.append("\ttemplate<typename T>")
15771577
result.append("\tstatic T *cast_to(Object *p_object);")
15781578

1579-
result.append("\ttemplate<class T>")
1579+
result.append("\ttemplate<typename T>")
15801580
result.append("\tstatic const T *cast_to(const Object *p_object);")
15811581

15821582
result.append("\tvirtual ~Object() = default;")
15831583

15841584
elif use_template_get_node and class_name == "Node":
1585-
result.append("\ttemplate<class T>")
1585+
result.append("\ttemplate<typename T>")
15861586
result.append(
15871587
"\tT *get_node(const NodePath &p_path) const { return Object::cast_to<T>(get_node_internal(p_path)); }"
15881588
)
@@ -2216,7 +2216,7 @@ def make_varargs_template(
22162216
if with_public_declare:
22172217
function_signature = "public: "
22182218

2219-
function_signature += "template<class... Args> "
2219+
function_signature += "template<typename... Args> "
22202220

22212221
if static:
22222222
function_signature += "static "

include/godot_cpp/classes/editor_plugin_registration.hpp

+2-2
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

+8-8
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

+4-4
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)