aboutsummaryrefslogtreecommitdiffstats
path: root/text.py
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--text.py25
1 files changed, 13 insertions, 12 deletions
diff --git a/text.py b/text.py
index 5820473..109e8fd 100644
--- a/text.py
+++ b/text.py
@@ -11,14 +11,13 @@ class text():
autogen_warning = "// automatically generated by faultreiber\n"
last_comment = "// last line intentionally left blank\n\n"
read_func_sig = "int read_structured_file(char* path)"
- #c_read_elem_sig = "XXX ft_read_YYY(int _fd) {\n"
- #c_read_elem_sig = "void ft_read_YYY(int _fd, XXX* dummyZZZ) {\n"
- #c_read_elem_sig = "void ft_read_YYY(int _fd, XXX* dummy) {\n"
- #c_read_elem_sig_h = "void ft_read_YYY(int _fd, XXX* dummy);\n"
c_read_elem_sig = "void* ft_read_YYY(int _fd, XXX** dummy, void*** void_train, uint64_t* current_void_size, uint64_t* current_void_count) {\n"
c_read_elem_sig_h = "void* ft_read_YYY(int _fd, XXX** dummy, void*** void_train, uint64_t* current_void_size, uint64_t* current_void_count);\n"
- c_read_elem_sig_1 = "ft_read_XXX(_fd)"
+ c_read_elem_sig_c = "void* ft_read_YYY_c(int _fd, XXX** dummy, void*** void_train, uint64_t* current_void_size, uint64_t* current_void_count, uint64_t* agg_b_count) {\n"
+ c_read_elem_sig_h_c = "void* ft_read_YYY_c(int _fd, XXX** dummy, void*** void_train, uint64_t* current_void_size, uint64_t* current_void_count, uint64_t* agg_b_count);\n"
+ #c_read_elem_sig_1 = "ft_read_XXX(_fd)"
c_read_elem_sig_2 = "ft_read_XXX(_fd, YYY, ZZZ, current_void_size, current_void_count)"
+ c_read_elem_sig_2_c = "ft_read_XXX_c(_fd, YYY, ZZZ, current_void_size, current_void_count, &agg_b_count)"
c_open_file = "int ft_read_file = open(_ft_file_path, RDONLY);\n"
c_function_close = "}\n"
c_function_dummy_dec = "XXX dummy;\n"
@@ -38,21 +37,22 @@ class text():
c_assign_struct = "XXX.YYY = ZZZ;\n"
simple_loop = "for (int i = 0; i < XXX; ++i) {\nYYY}\n"
c_read_leb_u_def = """
-uint64_t read_leb_128_u(int _fd, int max_size) {
+uint64_t read_leb_128_u(int _fd, int max_size, uint64_t* b_count) {
uint8_t read_bytes = 0U;
uint8_t byte = 0;
uint64_t result = 0U;
uint32_t shift = 0U;
do {
- read(_fd, &byte, 1);read_bytes++;read_bytes++;
+ read(_fd, &byte, 1);read_bytes++;
result |= (byte & 0x7f) << shift;
shift += 7;
} while(((byte & 0x80) != 0) && (read_bytes < max_size));
+ *b_count = read_bytes;
return result;
}"""
c_read_leb_s_def = """
-int64_t read_leb_128_s(int _fd, int max_size) {
+int64_t read_leb_128_s(int _fd, int max_size, uint64_t* b_count) {
uint8_t byte;
uint8_t read_bytes = 0U;
uint8_t last_byte;
@@ -66,6 +66,7 @@ int64_t read_leb_128_s(int _fd, int max_size) {
shift += 7;
} while(((byte & 0x80) != 0) && read_bytes < max_size);
if ((last_byte & 0x40) != 0) result |= -(1 << shift);
+ *b_count = read_bytes;
return result;
}"""
@@ -99,8 +100,8 @@ void void_manager(void* ptr, void*** void_train, uint64_t* current_void_size, ui
(*current_void_count)++;
}"""
- c_read_leb_128_s_sig = "int64_t read_leb_128_s(int _fd, int max_size);\n"
- c_read_leb_128_u_sig = "uint64_t read_leb_128_u(int _fd, int max_size);\n"
+ c_read_leb_128_s_sig = "int64_t read_leb_128_s(int _fd, int max_size, uint64_t* b_count);\n"
+ c_read_leb_128_u_sig = "uint64_t read_leb_128_u(int _fd, int max_size, uint64_t* b_count);\n"
c_read_until_delimiter_sig = "int32_t read_until_delimiter(int _fd, uint8_t delimiter);\n"
c_read_until_delimiter_proto = "read_until_delimiter(_fd, XXX)"
c_void_manager_sig = "void void_manager(void* ptr, void*** void_train, uint64_t* current_void_size, uint64_t* current_void_count);\n"
@@ -120,8 +121,8 @@ void void_manager(void* ptr, void*** void_train, uint64_t* current_void_size, ui
c_read_leb_macro_varin1 = "READ_VAR_INT_1(XXX)"
c_read_leb_macro_varin7 = "READ_VAR_INT_7(XXX)"
c_read_leb_macro_varin32 = "READ_VAR_INT_32(XXX)"
- c_read_leb_128_u = "read_leb_128_u(_fd, 5);\n"
- c_read_leb_128_s = "read_leb_128_s(_fd, 5);\n"
+ c_read_leb_128_u = "read_leb_128_u(_fd, 5, &b_count);\n"
+ c_read_leb_128_s = "read_leb_128_s(_fd, 5, &b_count);\n"
c_define_str_buff_size = "#define STR_BUFF_SIZE XXX"
c_define_str_buff_grow_fact = "#define STR_BUFFER_GROW_FACTOR XXX"