Skip to content

Commit 0c26dc1

Browse files
committed
refactor: streamline Result handling by consolidating return type assignments and excluding void type
1 parent ba4e909 commit 0c26dc1

1 file changed

Lines changed: 5 additions & 8 deletions

File tree

ci/generate_checked_functions.py

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -65,14 +65,8 @@ def generate_checked_function(func):
6565
new_func.append(f" Result res;")
6666
new_func.append(f" if (original_result == 0) {{")
6767
new_func.append(f" res.error_code = 0;")
68-
if return_type == "bool":
69-
new_func.append(f" res.value.bool_value = original_result;")
70-
elif return_type == "void*":
71-
new_func.append(f" res.value.ptr_value = original_result;")
72-
elif return_type == "uint32_t":
73-
new_func.append(f" res.value.int_value = original_result;")
74-
else:
75-
new_func.append(f" res.value.{return_type}_value = original_result;")
68+
69+
new_func.append(f" res.value.{return_type}_value = original_result;")
7670
new_func.append(f" }} else {{")
7771
new_func.append(f" res.error_code = -2;")
7872
new_func.append(f" }}")
@@ -141,6 +135,9 @@ def process_header():
141135

142136
# Update the Result struct with all return types
143137
for return_type in return_types:
138+
if return_type == "void":
139+
continue # No need to add void type
140+
144141
RESULT_STRUCT = RESULT_STRUCT.replace(
145142
"// Add other types as needed",
146143
f" {return_type} {return_type}_value;\n // Add other types as needed",

0 commit comments

Comments
 (0)