started writing l1_5/codegen thing. too bad the learning year has begun :(
This commit is contained in:
parent
8a1f8dbfdb
commit
872381e686
@ -10,6 +10,7 @@
|
||||
#include "margaret/vulkan_utils.h"
|
||||
#include "marie/graphics_geom.h"
|
||||
#include "liza.h"
|
||||
#include "codegen_from_l1_5.h"
|
||||
|
||||
int main() {
|
||||
mkdir_nofail("l1");
|
||||
@ -23,6 +24,7 @@ int main() {
|
||||
generate_margaret_eve_for_vulkan_utils();
|
||||
generate_marie_headers_for_graphics_geom();
|
||||
generate_liza_l1_headers();
|
||||
generate_l1_headers_for_l1_5();
|
||||
finish_layer(cstr("l1"));
|
||||
return 0;
|
||||
}
|
||||
|
||||
15
src/l1/anne/codegen_from_l1_5.h
Normal file
15
src/l1/anne/codegen_from_l1_5.h
Normal file
@ -0,0 +1,15 @@
|
||||
#ifndef PROTOTYPE1_SRC_L1_ANNE_CODEGEN_FROM_L1_5_H
|
||||
#define PROTOTYPE1_SRC_L1_ANNE_CODEGEN_FROM_L1_5_H
|
||||
|
||||
#include "../codegen/util_template_inst.h"
|
||||
|
||||
/* ambassador of next level */
|
||||
void generate_l1_headers_for_l1_5() {
|
||||
mkdir_nofail("l1/eve/embassy_l1_5");
|
||||
SpanU8 l = cstr("l1");
|
||||
SpanU8 ns = cstr("embassy_l1_5");
|
||||
generate_eve_span_company_for_primitive(l, ns, cstr("NamedVariableRecordRef"), false, true);
|
||||
generate_eve_span_company_for_primitive(l, ns, cstr("NamedMethodSignatureRecordRef"), false, true);
|
||||
}
|
||||
|
||||
#endif
|
||||
@ -530,7 +530,7 @@ NODISCARD VecU8 util_templates_instantiation_get_appropriate_filename(
|
||||
}
|
||||
|
||||
void generate_util_templ_inst_eve_header(SpanU8 layer, SpanU8 bonus_ns, SpanU8 T, util_templates_instantiation_options op) {
|
||||
VecU8 text = vcstr("/* Automatically generated file. Do not edit it.\n"
|
||||
VecU8 text = VecU8_from_cstr("/* Automatically generated file. Do not edit it.\n"
|
||||
" * Do not include it in more than one place */\n\n");
|
||||
VecU8_append_vec(&text, generate_util_templates_instantiation(T, op));
|
||||
VecU8 filename = util_templates_instantiation_get_appropriate_filename(T, op);
|
||||
|
||||
@ -15,7 +15,6 @@ VecU8 VecU8_from_cstr(const char* dc) {
|
||||
memcpy(res.buf, dc, n);
|
||||
return res;
|
||||
}
|
||||
#define vcstr(dc) VecU8_from_cstr(dc)
|
||||
|
||||
SpanU8 SpanU8_from_cstr(const char* dc) {
|
||||
return (SpanU8){.data = (const U8*)dc, .len = strlen(dc)};
|
||||
|
||||
@ -1,11 +1,13 @@
|
||||
#include "../../l1/system/fsmanip.h"
|
||||
|
||||
#include "marie/clipping.h"
|
||||
#include "liza.h"
|
||||
|
||||
int main() {
|
||||
mkdir_nofail("l1_5");
|
||||
mkdir_nofail("l1_5/marie");
|
||||
generate_marie_clipping_header();
|
||||
generate_l1_5_liza_headers();
|
||||
finish_layer(cstr("l1_5"));
|
||||
return 0;
|
||||
}
|
||||
|
||||
11
src/l1_5/anne/liza.h
Normal file
11
src/l1_5/anne/liza.h
Normal file
@ -0,0 +1,11 @@
|
||||
#ifndef PROTOTYPE1_SRC_L1_5_ANNE_LIZA_H
|
||||
#define PROTOTYPE1_SRC_L1_5_ANNE_LIZA_H
|
||||
|
||||
#include "../codegen/trait_wrap_boil.h"
|
||||
|
||||
void generate_l1_5_liza_headers() {
|
||||
mkdir_nofail("l1_5/liza");
|
||||
// todo: use#include "../codegen/trait_wrap_boil.h"
|
||||
}
|
||||
|
||||
#endif
|
||||
56
src/l1_5/codegen/trait_wrap_boil.h
Normal file
56
src/l1_5/codegen/trait_wrap_boil.h
Normal file
@ -0,0 +1,56 @@
|
||||
#ifndef PROTOTYPE1_SRC_L1_5_CODEGEN_TRAIT_BOX_AND_REF_H
|
||||
#define PROTOTYPE1_SRC_L1_5_CODEGEN_TRAIT_BOX_AND_REF_H
|
||||
|
||||
#include "../../l1/codegen/codegen.h"
|
||||
|
||||
typedef struct {
|
||||
SpanU8 type;
|
||||
SpanU8 name;
|
||||
} NamedVariableRecordRef;
|
||||
|
||||
#include "../../../gen/l1/eve/embassy_l1_5/SpanNamedVariableRecordRef.h"
|
||||
|
||||
typedef struct {
|
||||
SpanNamedVariableRecordRef params;
|
||||
SpanU8 return_type;
|
||||
SpanU8 name;
|
||||
} NamedMethodSignatureRecordRef;
|
||||
|
||||
#include "../../../gen/l1/eve/embassy_l1_5/SpanNamedMethodSignatureRecordRef.h"
|
||||
|
||||
typedef struct {
|
||||
SpanNamedMethodSignatureRecordRef methods;
|
||||
SpanU8 name;
|
||||
} NamedTraitDefRecordRef;
|
||||
|
||||
NODISCARD VecU8 generate_trait_table_structure(NamedTraitDefRecordRef trait){
|
||||
VecU8 res = VecU8_from_cstr("typedef struct {");
|
||||
// todo: add iteration macro
|
||||
for (size_t i = 0; i < trait.methods.len; i++) {
|
||||
NamedMethodSignatureRecordRef method = *SpanNamedMethodSignatureRecordRef_at(trait.methods, i);
|
||||
VecU8_append_vec(&res, VecU8_fmt(SPACE4 "%s (*%s)(", method.return_type, method.name));
|
||||
for (size_t p = 0; p < method.params.len; p++) {
|
||||
NamedVariableRecordRef param = *SpanNamedVariableRecordRef_at(method.params, p);
|
||||
if (p)
|
||||
VecU8_append_span(&res, cstr(", "));
|
||||
VecU8_append_span(&res, param.type);
|
||||
}
|
||||
VecU8_append_span(&res, cstr(");\n"));
|
||||
}
|
||||
VecU8_append_vec(&res, VecU8_fmt("} %s;\n\n", trait.name));
|
||||
return res;
|
||||
}
|
||||
|
||||
typedef struct {
|
||||
bool box;
|
||||
bool ref;
|
||||
bool mut_ref;
|
||||
} trait_wrapper_boil_options;
|
||||
|
||||
NODISCARD VecU8 generate_trait_wrapper_boilerplate(NamedTraitDefRecordRef trait, trait_wrapper_boil_options op) {
|
||||
VecU8 res = VecU8_new();
|
||||
// todo: write it
|
||||
return res;
|
||||
}
|
||||
|
||||
#endif
|
||||
@ -198,7 +198,7 @@ VecVecU8 margaret_get_extensions_of_physical_device(VkPhysicalDevice physical_de
|
||||
for (size_t i = 0; i < extensions_count; i++) {
|
||||
// Previous value here was default (_new). It can be safely discarded
|
||||
// ->extensionName is some null-terminated string, we need to acquire a copy
|
||||
*VecVecU8_mat(&res, i) = vcstr(VecVkExtensionProperties_at(&extensions, i)->extensionName);
|
||||
*VecVecU8_mat(&res, i) = VecU8_from_cstr(VecVkExtensionProperties_at(&extensions, i)->extensionName);
|
||||
}
|
||||
VecVkExtensionProperties_drop(extensions);
|
||||
return res;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user