5757 } Result;
5858"""
5959
60+ COPYRIGHT = """
61+ /*
62+ * Copyright (C) 2025 Intel Corporation. All rights reserved.
63+ * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
64+ */
65+ """
66+
6067INCLUDE_HEADERS = ["<stdbool.h>" , "<stdint.h>" , "<stdlib.h>" ]
6168
6269
@@ -69,24 +76,39 @@ def generate_result_struct(return_types):
6976 """Generate the Result struct based on return types."""
7077 result_struct = RESULT_STRUCT_TEMPLATE
7178 for return_type in return_types :
72- if return_type != "void" :
73- result_struct = result_struct .replace (
74- "// Add other types as needed" ,
75- f" { return_type } { return_type } _value;\n // Add other types as needed" ,
76- )
79+ if return_type == "void" :
80+ continue
81+
82+ result_struct = result_struct .replace (
83+ "// Add other types as needed" ,
84+ f" { return_type } { return_type } _value;\n // Add other types as needed" ,
85+ )
7786 return result_struct
7887
7988
8089def write_checked_header (output_path , result_struct , functions , typedefs ):
8190 """Write the checked header file."""
91+
8292 with open (output_path , "w" ) as f :
83- f .write ("#ifndef WASM_EXPORT_CHECKED_H\n #define WASM_EXPORT_CHECKED_H\n \n " )
93+ # copyright
94+ f .write (COPYRIGHT )
95+ f .write ("\n " )
96+
97+ f .write ("/*\n " )
98+ f .write (" * THIS FILE IS GENERATED AUTOMATICALLY, DO NOT EDIT!\n " )
99+ f .write (" */\n " )
100+
101+ # include guard
102+ f .write (
103+ f"#ifndef { output_path .stem .upper ()} _H\n #define { output_path .stem .upper ()} _H\n \n "
104+ )
84105
85106 for header in INCLUDE_HEADERS :
86107 f .write (f"#include { header } \n " )
87108 f .write ("\n " )
88- f .write ('#include "wasm_export.h"\n ' )
89- f .write ('#include "lib_export.h"\n ' )
109+ # include original header
110+ original_header = output_path .stem .replace ("_checked" , "" ) + ".h"
111+ f .write (f'#include "{ original_header } "\n ' )
90112 f .write ("\n " )
91113
92114 f .write (result_struct + "\n " )
@@ -95,7 +117,7 @@ def write_checked_header(output_path, result_struct, functions, typedefs):
95117 new_func = generate_checked_function (func , typedefs )
96118 f .write (new_func + "\n \n " )
97119
98- f .write ("#endif // WASM_EXPORT_CHECKED_H \n " )
120+ f .write (f "#endif // { output_path . stem . upper () } _H \n " )
99121
100122
101123def resolve_typedef (typedefs , type_name ):
0 commit comments