From 70e075d2f6d4bcd48d34299d626069422b1d090d Mon Sep 17 00:00:00 2001 From: Abdelrahman Said Date: Sun, 2 Mar 2025 13:42:23 +0000 Subject: [PATCH] Add message at top of codegen files to avoid overwriting them --- codegen/datatypes.py | 29 ++++++++++++++++++++++++++--- src/core/strings/str8/str8_list.c | 4 ++++ src/core/strings/str8/str8_list.h | 4 ++++ 3 files changed, 34 insertions(+), 3 deletions(-) diff --git a/codegen/datatypes.py b/codegen/datatypes.py index 836d736..fab1b9d 100644 --- a/codegen/datatypes.py +++ b/codegen/datatypes.py @@ -202,7 +202,12 @@ class CFile: outfile.write(str(self)) def __str__(self) -> str: - return "" + return """\ +/** + * THIS FILE IS AUTOMATICALLY GENERATED. ANY MODIFICATIONS TO IT WILL BE OVERWRITTEN + */ + +""" @dataclass @@ -237,7 +242,17 @@ class CHeader(CFile): for func in self.funcs: funcs += func.declare() - return header_guard_open + includes + c_linkage_open + forward_declarations + types + funcs + c_linkage_close + header_guard_close + return ( + super().__str__() + + header_guard_open + + includes + + c_linkage_open + + forward_declarations + + types + + funcs + + c_linkage_close + + header_guard_close + ) @dataclass @@ -274,7 +289,15 @@ class CSource(CFile): for func in self.funcs: funcs += func.define() - return includes + forward_declarations + types + internal_funcs_decl + funcs + internal_funcs_def + return ( + super().__str__() + + includes + + forward_declarations + + types + + internal_funcs_decl + + funcs + + internal_funcs_def + ) def get_datatype_string(_type: CDataType) -> str: diff --git a/src/core/strings/str8/str8_list.c b/src/core/strings/str8/str8_list.c index 34f7926..a3cebbe 100644 --- a/src/core/strings/str8/str8_list.c +++ b/src/core/strings/str8/str8_list.c @@ -1,3 +1,7 @@ +/** + * THIS FILE IS AUTOMATICALLY GENERATED. ANY MODIFICATIONS TO IT WILL BE OVERWRITTEN + */ + #include "./str8_list.h" #include "../../../common/aliases/aliases.h" #include "./str8.h" diff --git a/src/core/strings/str8/str8_list.h b/src/core/strings/str8/str8_list.h index 62db6d6..2476871 100644 --- a/src/core/strings/str8/str8_list.h +++ b/src/core/strings/str8/str8_list.h @@ -1,3 +1,7 @@ +/** + * THIS FILE IS AUTOMATICALLY GENERATED. ANY MODIFICATIONS TO IT WILL BE OVERWRITTEN + */ + #ifndef STR8_LIST_H #define STR8_LIST_H