int_ptimitives template instantiation and vec,cvec templ instantiation split into many separarate files

This commit is contained in:
Андреев Григорий 2025-10-08 16:42:10 +03:00
parent 1d08e0408c
commit 122f3dba24
14 changed files with 66 additions and 91 deletions

View File

@ -133,9 +133,10 @@ NODISCARD VecU8 generate_texture_data_struct_and_necc_methods(SpanU8 tex, SpanU8
void generate_pixel_masses_header() {
GeneratedHeader res = begin_header(cstr("l1/pixel_masses.h"));
VecU8_append_span(&res.result, cstr("#include \"VecAndSpan_int_primitives.h\"\n"));
VecU8_append_span(&res.result, cstr("#include \"VecAndSpan_U8.h\"\n"));
VecU8_append_span(&res.result, cstr("#include \"../../src/l1/system/fileio.h\"\n"));
VecU8_append_span(&res.result, cstr("#include \"VecAndSpan_cvec.h\"\n\n"));
VecU8_append_span(&res.result, cstr("#include \"VecAndSpan_cvec3.h\"\n"));
VecU8_append_span(&res.result, cstr("#include \"VecAndSpan_cvec4.h\"\n\n"));
VecU8_append_vec(&res.result, generate_texture_data_struct_and_necc_methods(cstr("TextureDataR8"), cstr("U8")));
VecU8_append_vec(&res.result, generate_texture_data_struct_and_necc_methods(cstr("TextureDataR8G8B8"), cstr("cvec3")));
VecU8_append_vec(&res.result, generate_texture_data_struct_and_necc_methods(cstr("TextureDataR8G8B8A8"), cstr("cvec4")));

View File

@ -4,29 +4,10 @@
#include "../codegen/util_template_inst.h"
void generate_util_temp_geom_headers() {
{
GeneratedHeader head = begin_header(cstr("l1/VecAndSpan_cvec.h"));
VecU8_append_span(&head.result, cstr("#include \"geom.h\"\n"));
VecU8_append_span(&head.result, cstr("#include \"../../src/l1/core/util.h\"\n\n"));
SpanU8 T[] = {cstr("cvec3"), cstr("cvec4")};
for (size_t i = 0; i < ARRAY_SIZE(T); i++) {
VecU8_append_vec(&head.result, generate_util_templates_instantiation((util_templates_instantiation_options){
.T = T[i], .t_primitive = true, .vec = true, .span = true, .collab_vec_span = true,
}));
}
finish_header(head);
}
{
GeneratedHeader head = begin_header(cstr("l1/VecAndSpan_vec.h"));
VecU8_append_span(&head.result, cstr("#include \"geom.h\"\n"));
VecU8_append_span(&head.result, cstr("#include \"../../src/l1/core/util.h\"\n\n"));
SpanU8 T[] = {cstr("vec2"), cstr("vec3"), cstr("vec4")};
for (size_t i = 0; i < ARRAY_SIZE(T); i++) {
VecU8_append_vec(&head.result, generate_util_templates_instantiation((util_templates_instantiation_options){
.T = T[i], .t_primitive = true, .vec = true, .span = true, .collab_vec_span = true,
}));
}
finish_header(head);
SpanU8 T[] = {cstr("cvec3"), cstr("cvec4"), cstr("vec2"), cstr("vec3"), cstr("vec4")};
for (size_t i = 0; i < ARRAY_SIZE(T); i++) {
generate_guarded_span_company_for_primitive(cstr("l1"), cstr(""), T[i],
cstr("#include \"geom.h\"\n"), true, true);
}
}

View File

@ -7,54 +7,48 @@
/* These headers are guarded */
void generate_util_temp_very_base_headers() {
{
GeneratedHeader head = begin_header(cstr("l1/VecAndSpan_int_primitives.h"));
VecU8_append_span(&head.result, cstr("#include \"../../src/l1/core/util.h\"\n\n"));
SpanU8 T[] = {cstr("U8"), cstr("U16"), cstr("U32"), cstr("U64"), cstr("S64")};
for (size_t i = 0; i < ARRAY_SIZE(T); i++) {
VecU8_append_vec(&head.result, generate_util_templates_instantiation((util_templates_instantiation_options){
.T = T[i],
.t_integer = true, .t_primitive = true, .vec = true, .vec_extended = true,
.vec_equal = true, .span = true, .span_extended = true, .mut_span = true,
.collab_vec_span = true, .collab_vec_span_extended = true,
}));
}
finish_header(head);
SpanU8 l = cstr("l1"), ns = cstr("");
SpanU8 T_codegen_VecAndSpan[] = {cstr("U8"), cstr("U16"), cstr("U32"), cstr("U64"), cstr("S64")};
SpanU8 T_codegen_Option[] = {cstr("U8"), cstr("U16"), cstr("U32"), cstr("U64"), cstr("S64")};
SpanU8 T_codegen_VecAndSpan_of_Vec[] = {cstr("U8"), cstr("U16"), cstr("U32"), cstr("U64")};
SpanU8 T_codegen_VecAndSpan_of_Span[] = {cstr("U8"), cstr("U16"), cstr("U32"), cstr("U64")};
for (size_t i = 0; i < ARRAY_SIZE(T_codegen_VecAndSpan); i++) {
generate_util_templ_inst_guarded_header(l, ns,
cstr(""),
(util_templates_instantiation_options){
.T = T_codegen_VecAndSpan[i],
.t_integer = true, .t_primitive = true, .vec = true, .vec_extended = true,
.vec_equal = true, .span = true, .span_extended = true, .mut_span = true,
.collab_vec_span = true, .collab_vec_span_extended = true,
});
}
{
GeneratedHeader head = begin_header(cstr("l1/Option_int_primitives.h"));
VecU8_append_span(&head.result, cstr("#include \"../../src/l1/core/util.h\"\n\n"));
SpanU8 T[] = {cstr("U8"), cstr("U16"), cstr("U32"), cstr("U64"), cstr("S64")};
for (size_t i = 0; i < ARRAY_SIZE(T); i++) {
VecU8_append_vec(&head.result, generate_OptionT_struct_and_methods((option_template_instantiation_op){
.T = T[i], .t_integer = true, .t_primitive = true
}));
}
finish_header(head);
for (size_t i = 0; i < ARRAY_SIZE(T_codegen_Option); i++) {
generate_Option_templ_inst_guarded_header(l, ns,
cstr(""),
(option_template_instantiation_op){.T = T_codegen_Option[i], .t_integer = true});
}
{
GeneratedHeader head = begin_header(cstr("l1/VecAndSpan_Vec_int_primitives.h"));
VecU8_append_span(&head.result, cstr("#include \"VecAndSpan_int_primitives.h\"\n\n"));
SpanU8 T[] = {cstr("VecU8"), cstr("VecU16"), cstr("VecU32"), cstr("VecU64")};
for (size_t i = 0; i < ARRAY_SIZE(T); i++) {
VecU8_append_vec(&head.result, generate_util_templates_instantiation((util_templates_instantiation_options){
.T = T[i], .t_clonable = true, .vec = true, .vec_extended = true,
.span = true, .collab_vec_span = true, .vec_equal = true,
}));
}
VecU8_append_vec(&head.result, generate_VecT_new_of_size_method(cstr("VecU8")));
finish_header(head);
for (size_t i = 0; i < ARRAY_SIZE(T_codegen_VecAndSpan_of_Vec); i++) {
VecU8 VecT = VecU8_fmt("Vec%s", T_codegen_VecAndSpan_of_Vec[i]);
VecU8 dependency = VecU8_fmt("#include \"VecAndSpan_%s.h\"", T_codegen_VecAndSpan_of_Vec[i]);
generate_util_templ_inst_guarded_header(l, ns,
VecU8_to_span(&dependency),
(util_templates_instantiation_options){
.T = VecU8_to_span(&VecT), .t_clonable = true, .vec = true, .vec_extended = true,
.span = true, .collab_vec_span = true, .vec_equal = true, .vec_new_of_size = true
});
VecU8_drop(VecT);
VecU8_drop(dependency);
}
{
GeneratedHeader head = begin_header(cstr("l1/VecAndSpan_Span_int_primitives.h"));
VecU8_append_span(&head.result, cstr("#include \"VecAndSpan_int_primitives.h\"\n\n"));
SpanU8 T[1] = {cstr("SpanU8")};
for (size_t i = 0; i < ARRAY_SIZE(T); i++) {
VecU8_append_vec(&head.result, generate_util_templates_instantiation((util_templates_instantiation_options){
.T = T[i], .t_primitive = true, .vec = true, .span = true, .mut_span = true, .collab_vec_span = true,
}));
}
finish_header(head);
for (size_t i = 0; i < ARRAY_SIZE(T_codegen_VecAndSpan_of_Span); i++) {
VecU8 SpanT = VecU8_fmt("Span%s", T_codegen_VecAndSpan_of_Span[i]);
VecU8 dependency = VecU8_fmt("#include \"VecAndSpan_%s.h\"", T_codegen_VecAndSpan_of_Span[i]);
generate_util_templ_inst_guarded_header(l, ns,
VecU8_to_span(&dependency),
(util_templates_instantiation_options){
.T = VecU8_to_span(&SpanT), .t_primitive = true, .vec = true, .span = true, .mut_span = true, .collab_vec_span = true,
});
VecU8_drop(SpanT);
VecU8_drop(dependency);
}
generate_guarded_span_company_for_primitive(cstr("l1"), cstr(""),
cstr("CSTR"), cstr(""), true, false);

View File

@ -476,7 +476,6 @@ void generate_util_templ_inst_eve_header(SpanU8 layer, SpanU8 bonus_ns, util_tem
" * Do not include it in more than one place */\n\n");
VecU8_append_vec(&text, generate_util_templates_instantiation(op));
VecU8 filename = util_templates_instantiation_get_appropriate_filename(op);
// todo: add %v that takes a vector
VecU8 nt_path = VecU8_fmt("%s/eve/%s/%v%c", layer, bonus_ns, filename, 0);
write_whole_file_or_abort((const char*)nt_path.buf, VecU8_to_span(&text));
VecU8_drop(nt_path);

View File

@ -6,7 +6,7 @@
#ifdef PROTOTYPE1_L1_CODEGEN_BOOTSTRAP_USE_CHICKEN_VECU8
#include "chicken_VecU8.h"
#else
#include "../../../gen/l1/VecAndSpan_int_primitives.h"
#include "../../../gen/l1/VecAndSpan_U8.h"
#endif
VecU8 VecU8_from_cstr(const char* dc) {

View File

@ -1,4 +1,5 @@
#include "../../../gen/l1/VecAndSpan_int_primitives.h"
#include "../../../gen/l1/VecAndSpan_U8.h"
#include "../../../gen/l1/VecAndSpan_U32.h"
int main() {
VecU8 a = VecU8_new();

View File

@ -1,5 +1,5 @@
#include "../../../gen/l1/VecAndSpan_int_primitives.h"
#include "../../../gen/l1/VecAndSpan_Vec_int_primitives.h"
#include "../../../gen/l1/VecAndSpan_U64.h"
#include "../../../gen/l1/VecAndSpan_VecU64.h"
int main() {
VecU64 v = VecU64_new();

View File

@ -6,12 +6,10 @@
void generate_l1_5_template_instantiation_for_base_types(){
SpanU8 l = cstr("l1_5");
SpanU8 ns = cstr("");
SpanU8 dep = cstr(
"#include \"../l1/VecAndSpan_int_primitives.h\""
);
// todo: split VecAndSpan_int_primitives into multiple files (one file per integer type)
generate_rb_tree_Set_templ_inst_guarded_header(l, ns, dep, (set_instantiation_op){.T = cstr("U64"), .t_integer = true});
generate_rb_tree_Set_templ_inst_guarded_header(l, ns, dep, (set_instantiation_op){.T = cstr("S64"), .t_integer = true});
generate_rb_tree_Set_templ_inst_guarded_header(l, ns, cstr("#include \"../l1/VecAndSpan_U64.h\""),
(set_instantiation_op){.T = cstr("U64"), .t_integer = true});
generate_rb_tree_Set_templ_inst_guarded_header(l, ns, cstr("#include \"../l1/VecAndSpan_S64.h\""),
(set_instantiation_op){.T = cstr("S64"), .t_integer = true});
}
#endif

View File

@ -2,7 +2,7 @@
#define PROTOTYPE1_SRC_L1_CODEGEN_CLIPPING_H
#include "../../../l1/codegen/codegen.h"
#include "../../../../gen/l1/VecAndSpan_Span_int_primitives.h"
#include "../../../../gen/l1/VecAndSpan_SpanU8.h"
// todo: move all of this to marie namespace
// todo: instead of returning triangles, return points of convex polygon

View File

@ -1,9 +1,9 @@
#ifndef PROTOTYPE1_SRC_L1_5_CORE_STRINGOP_H
#define PROTOTYPE1_SRC_L1_5_CORE_STRINGOP_H
#include "../../../gen/l1/VecAndSpan_int_primitives.h"
#include "../../../gen/l1/VecAndSpan_Vec_int_primitives.h"
#include "../../../gen/l1/VecAndSpan_Span_int_primitives.h"
#include "../../../gen/l1/VecAndSpan_U8.h"
#include "../../../gen/l1/VecAndSpan_VecU8.h"
#include "../../../gen/l1/VecAndSpan_SpanU8.h"
#include "../../l1/core/VecU8_as_str.h"
U8 U8_to_lowercase(U8 ch) {

View File

@ -1,8 +1,8 @@
#ifndef PROTOTYPE1_SRC_L2_MARGARET_MARGARET_H
#define PROTOTYPE1_SRC_L2_MARGARET_MARGARET_H
#include "../../../gen/l1/Option_int_primitives.h"
#include "../../../gen/l1/VecAndSpan_Vec_int_primitives.h"
#include "../../../gen/l1/OptionU32.h"
#include "../../../gen/l1/VecAndSpan_VecU8.h"
#include "../../l1_5/core/stringop.h"
#include "../../l1/system/fileio.h"
#include "time_utils.h"

View File

@ -1,5 +1,5 @@
#include "../../../../gen/l1_5/BuffRBTree_SetS64.h"
#include "../../../../gen/l1/VecAndSpan_int_primitives.h"
#include "../../../../gen/l1/VecAndSpan_S64.h"
#include "../../../l1/core/VecU8_as_str.h"
#include "../../../l1/system/fileio.h"
#include "../../../l1/system/fsmanip.h"

View File

@ -2,10 +2,10 @@
#define SPLITTER_DRAFT_SRC_L2_TESTS_R0_ASSETS_H
#include "../../marie/graphics_geom.h"
#include "../../../../gen/l1/VecAndSpan_int_primitives.h"
#include "../../../../gen/l1/VecAndSpan_U32.h"
#include "../../../l1/system/fileio.h"
#include <math.h>
#include "../../../../gen/l1/VecAndSpan_vec.h"
#include "../../../../gen/l1/VecAndSpan_vec2.h"
#include "../../../../gen/l1/pixel_masses.h"
#include "../../marie/rasterization.h"

View File

@ -1,7 +1,8 @@
#ifndef PROTOTYPE1_SRC_L3_FUN_MACHINE_STATE_H
#define PROTOTYPE1_SRC_L3_FUN_MACHINE_STATE_H
#include "../../../gen/l1/VecAndSpan_int_primitives.h"
#include "../../../gen/l1/VecAndSpan_U8.h"
#include "../../../gen/l1/VecAndSpan_U16.h"
// todo: recheck this structure
const U8 FunMachine_LRU_states[24][4] ={