Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit ce6a76c

Browse files
committed
Add (un)register_class hooks in src/_pythonscript_extension_class_script.pxi & src/_pythonscript_extension_class_language.pxi
1 parent 1cef6ed commit ce6a76c

File tree

2 files changed

+36
-8
lines changed

2 files changed

+36
-8
lines changed

src/_pythonscript_extension_class_language.pxi

+18-4
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
from godot.classes cimport ScriptLanguageExtensionProfilingInfo
22

33

4-
cdef StringName gdname_scriptlanguageextension = StringName("ScriptLanguageExtension")
5-
cdef StringName gdname_pythonscriptlanguage = StringName("PythonScriptLanguage")
4+
cdef gd_string_name_t gdname_scriptlanguageextension
5+
cdef gd_string_name_t gdname_pythonscriptlanguage
66

77

88
debug_spy = False
@@ -17,8 +17,22 @@ cdef class PythonScriptLanguage:
1717
cdef gd_object_t _gd_ptr
1818

1919
def __cinit__(self):
20-
self._gd_ptr = pythonscript_gdextension.classdb_construct_object(&gdname_scriptlanguageextension._gd_data)
21-
pythonscript_gdextension.object_set_instance(self._gd_ptr, &gdname_pythonscriptlanguage._gd_data, <PyObject*>self)
20+
self._gd_ptr = pythonscript_gdextension.classdb_construct_object(&gdname_scriptlanguageextension)
21+
pythonscript_gdextension.object_set_instance(self._gd_ptr, &gdname_pythonscriptlanguage, <PyObject*>self)
22+
23+
# godot_extension: register_class_hook()
24+
@staticmethod
25+
cdef inline void _register_class_hook():
26+
global gdname_scriptlanguageextension, gdname_pythonscriptlanguage
27+
gdname_scriptlanguageextension = gd_string_name_from_unchecked_pystr("ScriptLanguageExtension")
28+
gdname_pythonscriptlanguage = gd_string_name_from_unchecked_pystr("PythonScriptLanguage")
29+
30+
# godot_extension: unregister_class_hook()
31+
@staticmethod
32+
cdef inline void _unregister_class_hook():
33+
global gdname_scriptlanguageextension, gdname_pythonscriptlanguage
34+
gd_string_name_del(&gdname_scriptlanguageextension)
35+
gd_string_name_del(&gdname_pythonscriptlanguage)
2236

2337
# godot_extension: generate_code()
2438

src/_pythonscript_extension_class_script.pxi

+18-4
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,28 @@
1-
cdef StringName gdname_scriptextension = StringName("ScriptExtension")
2-
cdef StringName gdname_pythonscript = StringName("PythonScript")
1+
cdef gd_string_name_t gdname_scriptextension
2+
cdef gd_string_name_t gdname_pythonscript
33

44
# godot_extension: class(parent="ScriptExtension")
55
@cython.final
66
cdef class PythonScript:
77
cdef gd_object_t _gd_ptr
88

99
def __cinit__(self):
10-
self._gd_ptr = pythonscript_gdextension.classdb_construct_object(&gdname_scriptextension._gd_data)
11-
pythonscript_gdextension.object_set_instance(self._gd_ptr, &gdname_pythonscript._gd_data, <PyObject*>self)
10+
self._gd_ptr = pythonscript_gdextension.classdb_construct_object(&gdname_scriptextension)
11+
pythonscript_gdextension.object_set_instance(self._gd_ptr, &gdname_pythonscript, <PyObject*>self)
12+
13+
# godot_extension: register_class_hook()
14+
@staticmethod
15+
cdef inline void _register_class_hook():
16+
global gdname_scriptextension, gdname_pythonscript
17+
gdname_scriptextension = gd_string_name_from_unchecked_pystr("ScriptExtension")
18+
gdname_pythonscript = gd_string_name_from_unchecked_pystr("PythonScript")
19+
20+
# godot_extension: unregister_class_hook()
21+
@staticmethod
22+
cdef inline void _unregister_class_hook():
23+
global gdname_scriptextension, gdname_pythonscript
24+
gd_string_name_del(&gdname_scriptextension)
25+
gd_string_name_del(&gdname_pythonscript)
1226

1327
# godot_extension: generate_code()
1428

0 commit comments

Comments
 (0)