Skip to content

Commit 6650594

Browse files
committed
Remove invalid destruction of parameters by the callee in extensions methods
1 parent 3dc71cb commit 6650594

File tree

4 files changed

+2
-52
lines changed

4 files changed

+2
-52
lines changed

src/godot/_lang_resource_format_loader.pxi

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ cdef class PythonResourceFormatLoader:
1717
cdef inline gd_packed_string_array_t _get_dependencies(self, gd_string_t path, gd_bool_t add_types):
1818
cdef gd_packed_string_array_t dependencies = gd_packed_string_array_new()
1919
cdef object py_path = gdapi.gd_string_to_pystr(&path)
20-
gd_string_del(&path)
2120

2221
spy_log(f"CALLED PythonResourceFormatLoader::_get_dependencies(path={py_path}, add_types={add_types})")
2322

@@ -67,7 +66,6 @@ cdef class PythonResourceFormatLoader:
6766
ret = gd_string_name_op_equal_string(&type, &candidate)
6867
gd_string_del(&candidate)
6968

70-
gd_string_name_del(&type)
7169
return ret
7270

7371
# godot_extension: method(virtual=True, const=True)
@@ -76,7 +74,6 @@ cdef class PythonResourceFormatLoader:
7674
cdef object py_extension
7775

7876
py_path = gdapi.gd_string_to_pystr(&path)
79-
gd_string_del(&path)
8077

8178
spy_log(f"CALLED PythonResourceFormatLoader::_get_resource_type(path={py_path!r})")
8279

@@ -91,8 +88,6 @@ cdef class PythonResourceFormatLoader:
9188
cdef gd_variant_t ret = gd_variant_new()
9289
cdef str py_path = gdapi.gd_string_to_pystr(&path)
9390
cdef str py_original_path = gdapi.gd_string_to_pystr(&original_path)
94-
gd_string_del(&path)
95-
gd_string_del(&original_path)
9691
spy_log(f"CALLED PythonResourceFormatLoader::_load(path={py_path!r}, original_path={py_original_path!r}, use_sub_threads={use_sub_threads}, cache_mode={cache_mode})")
9792

9893
# 1) Check path and convert it to Python format (e.g. `res://foo/bar.py` -> `foo.bar`)

src/godot/_lang_resource_format_saver.pxi

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,6 @@ cdef class PythonResourceFormatSaver:
6060

6161
# Convert the path to a Python string
6262
cdef object py_path = gdapi.gd_string_to_pystr(&path)
63-
gd_string_del(&path)
6463

6564
spy_log("CALLED PythonResourceFormatSaver::_save(resource=<resource>, path={py_path!r}, flags={flags})")
6665

src/godot/_lang_script.pxi

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -68,10 +68,7 @@ cdef class PythonScript:
6868
spy_log(f"CALLED PythonScript::_get_member_line(member={gdapi.gd_string_name_to_pystr(&member)!r})")
6969

7070
# Convert string name to string, then to Python string
71-
cdef gd_string_t member_str = gdapi.gd_string_new_from_string_name(&member)
72-
cdef object py_member = gdapi.gd_string_to_pystr(&member_str)
73-
gd_string_del(&member_str)
74-
gd_string_name_del(&member)
71+
cdef object py_member = gdapi.gd_string_name_to_pystr(&member)
7572

7673
# Find the line where the member is defined
7774
if not self._source_code:
@@ -99,15 +96,13 @@ cdef class PythonScript:
9996
spy_log(f"CALLED PythonScript::_get_method_info(method={gdapi.gd_string_name_to_pystr(&method)!r})")
10097
# TODO
10198
cdef gd_dictionary_t ret = gd_dictionary_new()
102-
gd_string_name_del(&method)
10399
return ret
104100

105101
# godot_extension: method(virtual=True, const=True)
106102
cdef inline gd_variant_t _get_property_default_value(self, gd_string_name_t property):
107103
spy_log(f"CALLED PythonScript::_get_property_default_value(property={gdapi.gd_string_name_to_pystr(&property)!r})")
108104
# TODO
109105
cdef gd_variant_t ret = gd_variant_new()
110-
gd_string_name_del(&property)
111106
return ret
112107

113108
# godot_extension: method(virtual=True, const=True)
@@ -153,10 +148,7 @@ cdef class PythonScript:
153148
cdef inline gd_bool_t _has_method(self, gd_string_name_t method):
154149
spy_log(f"CALLED PythonScript::_has_method(method={gdapi.gd_string_name_to_pystr(&method)!r})")
155150
# Convert string name to string, then to Python string
156-
cdef gd_string_t method_str = gdapi.gd_string_new_from_string_name(&method)
157-
cdef object py_method = gdapi.gd_string_to_pystr(&method_str)
158-
gd_string_del(&method_str)
159-
gd_string_name_del(&method)
151+
cdef object py_method = gdapi.gd_string_name_to_pystr(&method)
160152

161153
# Check if method exists in the Python source code
162154
if not self._source_code:
@@ -175,14 +167,12 @@ cdef class PythonScript:
175167
cdef inline gd_bool_t _has_property_default_value(self, gd_string_name_t property):
176168
spy_log(f"CALLED PythonScript::_has_property_default_value(property={gdapi.gd_string_name_to_pystr(&property)!r})")
177169
# TODO
178-
gd_string_name_del(&property)
179170
return False
180171

181172
# godot_extension: method(virtual=True, const=True)
182173
cdef inline gd_bool_t _has_script_signal(self, gd_string_name_t signal):
183174
spy_log(f"CALLED PythonScript::_has_script_signal(signal={gdapi.gd_string_name_to_pystr(&signal)!r})")
184175
# TODO
185-
gd_string_name_del(&signal)
186176
return False
187177

188178
# godot_extension: method(virtual=True, const=True)
@@ -194,7 +184,6 @@ cdef class PythonScript:
194184
cdef inline gd_bool_t _inherits_script(self, gd_object_t script):
195185
spy_log(f"CALLED PythonScript::_inherits_script(script=<object 0x{<size_t>script:x}>)")
196186
# TODO
197-
# `gd_object_t` doesn't need to be be deleted (is it just a raw pointer)
198187
return False
199188

200189
# godot_extension: method(virtual=True, const=True)
@@ -218,7 +207,6 @@ cdef class PythonScript:
218207
spy_log(f"CALLED PythonScript::_instance_has(object=<object 0x{<size_t>object:x}>)")
219208
# Check if the given object is an instance of this script
220209
# For now return False as we don't track instances yet
221-
# `gd_object_t` doesn't need to be be deleted (is it just a raw pointer)
222210
return False
223211

224212
# godot_extension: method(virtual=True, const=True)
@@ -258,7 +246,6 @@ cdef class PythonScript:
258246
cdef inline void* _placeholder_instance_create(self, gd_object_t for_object):
259247
spy_log(f"CALLED PythonScript::_placeholder_instance_create(for_object=<object 0x{<size_t>for_object:x}>)")
260248
# Create a placeholder instance for when the script is not ready
261-
# `gd_object_t` doesn't need to be be deleted (is it just a raw pointer)
262249
return NULL
263250

264251
# godot_extension: method(virtual=True)
@@ -274,7 +261,6 @@ cdef class PythonScript:
274261
cdef inline void _set_source_code(self, gd_string_t code):
275262
self._source_code = gdapi.gd_string_to_pystr(&code)
276263
spy_log(f"CALLED PythonScript::_set_source_code(code={self._source_code!r})")
277-
gd_string_del(&code)
278264

279265
# godot_extension: method(virtual=True)
280266
cdef inline void _update_exports(self):

src/godot/_lang_script_language.pxi

Lines changed: 0 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,11 @@ cdef class PythonScriptLanguage:
1616
cdef inline void _add_global_constant(self, gd_string_name_t name, gd_variant_t value):
1717
# TODO
1818
spy_log(f"CALLED PythonScriptLanguage::_add_global_constant(name={gdapi.gd_string_name_to_pystr(&name)!r}, value={value!r})")
19-
gd_string_name_del(&name)
20-
gd_variant_del(&value)
2119

2220
# godot_extension: method(virtual=True)
2321
cdef inline void _add_named_global_constant(self, gd_string_name_t name, gd_variant_t value):
2422
# TODO
2523
spy_log(f"CALLED PythonScriptLanguage::_add_named_global_constant(name={gdapi.gd_string_name_to_pystr(&name)!r}, value={value!r})")
26-
gd_string_name_del(&name)
27-
gd_variant_del(&value)
2824

2925
# godot_extension: method(virtual=True, const=True)
3026
cdef inline gd_string_t _auto_indent_code(self, gd_string_t code, gd_int_t from_line, gd_int_t to_line):
@@ -48,9 +44,6 @@ cdef class PythonScriptLanguage:
4844
# TODO
4945
spy_log(f"CALLED PythonScriptLanguage::_complete_code(code={gdapi.gd_string_to_pystr(&code)!r}, path={gdapi.gd_string_to_pystr(&path)!r}, owner=<object 0x{<size_t>owner:x}>)")
5046
cdef gd_dictionary_t ret = gd_dictionary_new()
51-
gd_string_del(&code)
52-
gd_string_del(&path)
53-
# `gd_object_t` doesn't need to be be deleted (is it just a raw pointer)
5447
return ret
5548

5649
# godot_extension: method(virtual=True, const=True)
@@ -133,8 +126,6 @@ cdef class PythonScriptLanguage:
133126
spy_log(f"CALLED PythonScriptLanguage::_find_function(function={gdapi.gd_string_to_pystr(&function)!r}, code={gdapi.gd_string_to_pystr(&code)!r})")
134127
cdef object py_function = gdapi.gd_string_to_pystr(&function)
135128
cdef object py_code = gdapi.gd_string_to_pystr(&code)
136-
gd_string_del(&function)
137-
gd_string_del(&code)
138129

139130
# Simple search for function definition
140131
try:
@@ -164,7 +155,6 @@ cdef class PythonScriptLanguage:
164155
cdef inline gd_array_t _get_built_in_templates(self, gd_string_name_t object):
165156
# TODO
166157
spy_log(f"CALLED PythonScriptLanguage::(object={gdapi.gd_string_name_to_pystr(&object)!r})")
167-
gd_string_name_del(&object)
168158
cdef gd_array_t ret = gd_array_new()
169159
return ret
170160

@@ -203,7 +193,6 @@ cdef class PythonScriptLanguage:
203193
cdef inline gd_dictionary_t _get_global_class_name(self, gd_string_t path):
204194
# TODO
205195
spy_log(f"CALLED PythonScriptLanguage::_get_global(path={gdapi.gd_string_to_pystr(&path)!r})")
206-
gd_string_del(&path)
207196
cdef gd_dictionary_t ret = gd_dictionary_new()
208197
return ret
209198

@@ -316,7 +305,6 @@ cdef class PythonScriptLanguage:
316305
spy_log(f"CALLED PythonScriptLanguage::_handles_global_class_type(type={gdapi.gd_string_to_pystr(&type)!r})")
317306
# TODO: would be more efficient to precompute the type into a `gd_string_t`
318307
cdef gd_bool_t result = gdapi.gd_string_to_pystr(&type) == "Python"
319-
gd_string_del(&type)
320308
return result
321309

322310
# godot_extension: method(virtual=True, const=True)
@@ -349,7 +337,6 @@ cdef class PythonScriptLanguage:
349337
"when",
350338
"while",
351339
)
352-
gd_string_del(&keyword)
353340
return result
354341

355342
# godot_extension: method(virtual=True)
@@ -361,10 +348,6 @@ cdef class PythonScriptLanguage:
361348
cdef inline gd_dictionary_t _lookup_code(self, gd_string_t code, gd_string_t symbol, gd_string_t path, gd_object_t owner):
362349
# TODO
363350
spy_log(f"CALLED PythonScriptLanguage::_lookup_code(code={gdapi.gd_string_to_pystr(&code)!r}, symbol={gdapi.gd_string_to_pystr(&symbol)!r}, path={gdapi.gd_string_to_pystr(&path)!r}, owner=<object 0x{<size_t>owner:x}>)")
364-
gd_string_del(&code)
365-
gd_string_del(&symbol)
366-
gd_string_del(&path)
367-
# `gd_object_t` doesn't need to be be deleted (is it just a raw pointer)
368351
cdef gd_dictionary_t ret = gd_dictionary_new()
369352
return ret
370353

@@ -373,8 +356,6 @@ cdef class PythonScriptLanguage:
373356
spy_log(f"CALLED PythonScriptLanguage::_make_function(class_name={gdapi.gd_string_to_pystr(&class_name)!r}, function_name={gdapi.gd_string_to_pystr(&function_name)!r}, function_args={function_args!r})")
374357
cdef object py_class_name = gdapi.gd_string_to_pystr(&class_name)
375358
cdef object py_function_name = gdapi.gd_string_to_pystr(&function_name)
376-
gd_string_del(&class_name)
377-
gd_string_del(&function_name)
378359

379360
# Convert function arguments
380361
cdef object args = []
@@ -385,7 +366,6 @@ cdef class PythonScriptLanguage:
385366
arg_str = gd_packed_string_array_indexed_getter(&function_args, i)
386367
args.append(gdapi.gd_string_to_pystr(&arg_str))
387368
gd_string_del(&arg_str)
388-
gd_packed_string_array_del(&function_args)
389369

390370
# Create function signature
391371
cdef object arg_list = ', '.join(['self'] + args) if args else 'self'
@@ -399,9 +379,6 @@ cdef class PythonScriptLanguage:
399379
cdef object py_template = gdapi.gd_string_to_pystr(&template)
400380
cdef object py_class_name = gdapi.gd_string_to_pystr(&class_name)
401381
cdef object py_base_class_name = gdapi.gd_string_to_pystr(&base_class_name)
402-
gd_string_del(&template)
403-
gd_string_del(&class_name)
404-
gd_string_del(&base_class_name)
405382

406383
# Create a basic Python script template
407384
cdef object source_template = f'''extends {py_base_class_name}
@@ -427,7 +404,6 @@ class {py_class_name}({py_base_class_name}):
427404
cdef inline gd_int_t _open_in_external_editor(self, gd_object_t script, gd_int_t line, gd_int_t column):
428405
# TODO
429406
spy_log(f"CALLED PythonScriptLanguage::_open_in_external_editor(script=<object 0x{<size_t>script:x}>, line={line}, column={column})")
430-
# `gd_object_t` doesn't need to be be deleted (is it just a raw pointer)
431407
return Error.ERR_UNAVAILABLE
432408

433409
# godot_extension: method(virtual=True)
@@ -479,19 +455,16 @@ class {py_class_name}({py_base_class_name}):
479455
cdef inline void _reload_scripts(self, gd_array_t scripts, gd_bool_t soft_reload):
480456
# TODO
481457
spy_log(f"CALLED PythonScriptLanguage::_reload_scripts(scripts={scripts!r}, soft_reload={soft_reload})")
482-
gd_array_del(&scripts)
483458

484459
# godot_extension: method(virtual=True)
485460
cdef inline void _reload_tool_script(self, gd_object_t script, gd_bool_t soft_reload):
486461
# TODO
487462
spy_log(f"CALLED PythonScriptLanguage::_reload_tool_script(script=<object 0x{<size_t>script:x}>, soft_reload={soft_reload})")
488-
# `gd_object_t` doesn't need to be be deleted (is it just a raw pointer)
489463

490464
# godot_extension: method(virtual=True)
491465
cdef inline void _remove_named_global_constant(self, gd_string_name_t name):
492466
# TODO
493467
spy_log(f"CALLED PythonScriptLanguage::_remove_named_global_constant(name={gdapi.gd_string_name_to_pystr(&name)!r})")
494-
gd_string_name_del(&name)
495468

496469
# godot_extension: method(virtual=True, const=True)
497470
cdef inline gd_bool_t _supports_builtin_mode(self):
@@ -519,16 +492,13 @@ class {py_class_name}({py_base_class_name}):
519492
# TODO
520493
spy_log(f"CALLED PythonScriptLanguage::_validate(script={gdapi.gd_string_to_pystr(&script)!r}, path={gdapi.gd_string_to_pystr(&path)!r}, validate_functions={validate_functions}, validate_errors={validate_errors}, validate_warnings={validate_warnings}, validate_safe_lines={validate_safe_lines})")
521494
cdef gd_dictionary_t ret = gd_dictionary_new()
522-
gd_string_del(&script)
523-
gd_string_del(&path)
524495
return ret
525496

526497
# godot_extension: method(virtual=True, const=True)
527498
cdef inline gd_string_t _validate_path(self, gd_string_t path):
528499
# TODO
529500
spy_log(f"CALLED PythonScriptLanguage::_validate_path(path={gdapi.gd_string_to_pystr(&path)!r})")
530501
cdef gd_string_t ret = gd_string_from_pybytes(b"")
531-
gd_string_del(&path)
532502
return ret
533503

534504
# godot_extension: generate_class_code()

0 commit comments

Comments
 (0)