1414} Result;
1515"""
1616
17- # Input and output file paths
18- INPUT_HEADER = "core/iwasm/include/wasm_export.h"
19- OUTPUT_HEADER = "core/iwasm/include/wasm_export_checked.h"
20-
2117
2218# Helper function to determine if a parameter is a pointer
2319def is_pointer (param ):
@@ -99,9 +95,7 @@ def generate_checked_function(func):
9995 elif return_type == "uint32_t" :
10096 new_func .append (f" res.value.int_value = original_result;" )
10197 else :
102- new_func .append (
103- f" res.value.{ return_type } _value = original_result;"
104- )
98+ new_func .append (f" res.value.{ return_type } _value = original_result;" )
10599 new_func .append (f" }} else {{" )
106100 new_func .append (f" res.error_code = -2;" )
107101 new_func .append (f" }}" )
@@ -114,12 +108,19 @@ def generate_checked_function(func):
114108
115109# Updated process_header to scan all return types and create a proper Result type
116110
111+
117112def process_header ():
118113 global RESULT_STRUCT # Access the global Result definition
119114
115+ # Based on current file location, adjust the path to the header file
116+ input_header = os .path .join (
117+ os .path .dirname (__file__ ), "../core/iwasm/include/wasm_export.h"
118+ )
119+ output_header = input_header .replace ("wasm_export.h" , "wasm_export_checked.h" )
120+
120121 # Parse the header file with preprocessing
121122 ast = parse_file (
122- INPUT_HEADER ,
123+ input_header ,
123124 use_cpp = True ,
124125 cpp_path = "gcc" ,
125126 cpp_args = [
@@ -162,7 +163,7 @@ def process_header():
162163 )
163164
164165 # Generate the new header file
165- with open (OUTPUT_HEADER , "w" ) as f :
166+ with open (output_header , "w" ) as f :
166167 f .write ("#ifndef WASM_EXPORT_CHECKED_H\n #define WASM_EXPORT_CHECKED_H\n \n " )
167168
168169 # Write the updated Result struct
0 commit comments