Skip to content

Commit d35fb0e

Browse files
committed
Allow unicode class names
1 parent d477589 commit d35fb0e

File tree

5 files changed

+24
-1
lines changed

5 files changed

+24
-1
lines changed

include/godot_cpp/classes/wrapped.hpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,7 @@ public:
250250
} \
251251
\
252252
static const ::godot::StringName &get_class_static() { \
253-
static const ::godot::StringName string_name = ::godot::StringName(#m_class); \
253+
static const ::godot::StringName string_name = ::godot::StringName(U## #m_class); \
254254
return string_name; \
255255
} \
256256
\

test/project/main.gd

+4
Original file line numberDiff line numberDiff line change
@@ -276,6 +276,10 @@ func _ready():
276276
assert_equal(library_path, ProjectSettings.globalize_path(library_path))
277277
assert_equal(FileAccess.file_exists(library_path), true)
278278

279+
# Test a class with a unicode name.
280+
var przykład = ExamplePrzykład.new()
281+
assert_equal(przykład.get_the_word(), "słowo to przykład")
282+
279283
exit_with_status()
280284

281285
func _on_Example_custom_signal(signal_name, value):

test/src/example.cpp

+8
Original file line numberDiff line numberDiff line change
@@ -736,3 +736,11 @@ ExampleRuntime::ExampleRuntime() {
736736

737737
ExampleRuntime::~ExampleRuntime() {
738738
}
739+
740+
void ExamplePrzykład::_bind_methods() {
741+
ClassDB::bind_method(D_METHOD("get_the_word"), &ExamplePrzykład::get_the_word);
742+
}
743+
744+
String ExamplePrzykład::get_the_word() const {
745+
return U"słowo to przykład";
746+
}

test/src/example.h

+10
Original file line numberDiff line numberDiff line change
@@ -273,4 +273,14 @@ class ExampleRuntime : public Node {
273273
~ExampleRuntime();
274274
};
275275

276+
class ExamplePrzykład : public RefCounted {
277+
GDCLASS(ExamplePrzykład, RefCounted);
278+
279+
protected:
280+
static void _bind_methods();
281+
282+
public:
283+
String get_the_word() const;
284+
};
285+
276286
#endif // EXAMPLE_CLASS_H

test/src/register_types.cpp

+1
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ void initialize_example_module(ModuleInitializationLevel p_level) {
3030
GDREGISTER_CLASS(ExampleBase);
3131
GDREGISTER_CLASS(ExampleChild);
3232
GDREGISTER_RUNTIME_CLASS(ExampleRuntime);
33+
GDREGISTER_CLASS(ExamplePrzykład);
3334
}
3435

3536
void uninitialize_example_module(ModuleInitializationLevel p_level) {

0 commit comments

Comments
 (0)