[examples] get type info final program fully building

This commit is contained in:
Allen Webster
2021-09-25 17:44:23 -07:00
parent 3f5d4a96a9
commit 35f7d3daf1
3 changed files with 21 additions and 4 deletions
@@ -20,12 +20,12 @@ F32 r;
U32 count;
V2F32 *p;
};
enum Shape
typedef enum Shape
{
Shape_Circle = 1,
Shape_Segment = 2,
Shape_Polygon = 3,
};
} Shape;
TypeInfo* type_info_from_shape(Shape v);
U32 max_slot_from_shape(Shape v);
#endif // META_TYEPS_H
@@ -6,9 +6,26 @@
**
*/
//~ setup base types //////////////////////////////////////////////////////////
#include <stdint.h>
typedef uint32_t U32;
typedef float F32;
typedef struct V2F32 V2F32;
struct V2F32
{
F32 x;
F32 y;
};
//~ include types for type info ///////////////////////////////////////////////
#include "type_info.h"
//~ include generated type info ///////////////////////////////////////////////
#include "generated/meta_types.h"
#include "generated/meta_types.c"
//~ main //////////////////////////////////////////////////////////////////////
#include <stdio.h>
int
+2 -2
View File
@@ -126,7 +126,7 @@ generate_type_definitions(FILE *out, TypeInfo *first_type)
case TypeKind_Enum:
{
MD_String8 enum_name = type->node->string;
fprintf(out, "enum %.*s\n", MD_S8VArg(enum_name));
fprintf(out, "typedef enum %.*s\n", MD_S8VArg(enum_name));
fprintf(out, "{\n");
for (TypeEnumerant *enumerant = type->first_enumerant;
enumerant != 0;
@@ -136,7 +136,7 @@ generate_type_definitions(FILE *out, TypeInfo *first_type)
fprintf(out, "%.*s_%.*s = %d,\n",
MD_S8VArg(enum_name), MD_S8VArg(member_name), enumerant->value);
}
fprintf(out, "};\n");
fprintf(out, "} %.*s;\n", MD_S8VArg(enum_name));
}break;
}
}