working cpp codegen
This commit is contained in:
parent
043892cdd1
commit
44e88f7fd0
2 changed files with 31 additions and 38 deletions
|
|
@ -46,6 +46,9 @@ main :: proc() {
|
||||||
|
|
||||||
rl.ExportImage(atlas, EXPORT_PATH)
|
rl.ExportImage(atlas, EXPORT_PATH)
|
||||||
|
|
||||||
|
// something : string = "hello"
|
||||||
|
// fmt.printf("{1} {2} else", something, 10)
|
||||||
|
|
||||||
// TestStruct :: struct {
|
// TestStruct :: struct {
|
||||||
// something: struct {
|
// something: struct {
|
||||||
// name: string,
|
// name: string,
|
||||||
|
|
|
||||||
|
|
@ -302,26 +302,26 @@ odin_source_generator_metadata := SourceCodeGeneratorMetadata {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// cpp_source_generator_metadata := SourceCodeGeneratorMetadata {
|
cpp_source_generator_metadata := SourceCodeGeneratorMetadata {
|
||||||
// file_defines = {top = "package atlas_bindings\n\n", bottom = ""},
|
file_defines = {top = "#include <iostream>\n\n", bottom = ""},
|
||||||
// custom_data_type = {
|
custom_data_type = {
|
||||||
// name = "AtlasRect",
|
name = "AtlasRect",
|
||||||
// type_declaration = "%v :: struct {{ x, y, w, h: i32 }}\n\n",
|
type_declaration = "struct %v {{\n\tint x;\n\tint y;\n\tint w;\n\tint h;\n}};\n\n",
|
||||||
// },
|
},
|
||||||
// enum_data = {
|
enum_data = {
|
||||||
// name = "AtlasEnum",
|
name = "AtlasEnum",
|
||||||
// begin_line = "%v :: enum {{\n",
|
begin_line = "enum %v {{\n",
|
||||||
// entry_line = "\t%s,\n",
|
entry_line = "\t%s,\n",
|
||||||
// end_line = "}\n\n",
|
end_line = "\n\tCOUNT\n}\n\n",
|
||||||
// },
|
},
|
||||||
// array_data = {
|
array_data = {
|
||||||
// name = "ATLAS_SPRITES",
|
name = "ATLAS_SPRITES",
|
||||||
// type = "[]AtlasRect",
|
type = "AtlasRect[size_t(AtlasEnum::COUNT)-1]",
|
||||||
// begin_line = "%v := %v {{\n",
|
begin_line = "{1} {0} = {{\n",
|
||||||
// entry_line = "\t.%v = {{ x = %v, y = %v, w = %v, h = %v }},\n",
|
entry_line = "\t{{ {1}, {2}, {3}, {4} }},\n",
|
||||||
// end_line = "}\n\n",
|
end_line = "}\n\n",
|
||||||
// },
|
},
|
||||||
// }
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Generates a barebones file with the package name "atlas_bindings",
|
Generates a barebones file with the package name "atlas_bindings",
|
||||||
|
|
@ -419,24 +419,14 @@ metadata_source_code_generate :: proc(
|
||||||
{
|
{
|
||||||
entry: string
|
entry: string
|
||||||
for cell in metadata {
|
for cell in metadata {
|
||||||
if codegen.lanugage_settings.first_class_enum_arrays {
|
entry = fmt.aprintf(
|
||||||
entry = fmt.aprintf(
|
codegen.array_data.entry_line, // "\t.%v = {{ x = %v, y = %v, w = %v, h = %v }},\n",
|
||||||
codegen.array_data.entry_line, // "\t.%v = {{ x = %v, y = %v, w = %v, h = %v }},\n",
|
cell.name,
|
||||||
cell.name,
|
cell.location.x,
|
||||||
cell.location.x,
|
cell.location.y,
|
||||||
cell.location.y,
|
cell.size.x,
|
||||||
cell.size.x,
|
cell.size.y,
|
||||||
cell.size.y,
|
)
|
||||||
)
|
|
||||||
} else {
|
|
||||||
entry = fmt.aprintf(
|
|
||||||
codegen.array_data.entry_line, // "\t{{ x = %v, y = %v, w = %v, h = %v }},\n",
|
|
||||||
cell.location.x,
|
|
||||||
cell.location.y,
|
|
||||||
cell.size.x,
|
|
||||||
cell.size.y,
|
|
||||||
)
|
|
||||||
}
|
|
||||||
strings.write_string(&sb, entry)
|
strings.write_string(&sb, entry)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue