toolchain: replace ifc interface compiler with xpcg

xpcg is used to generate xpc interfaces
This commit is contained in:
2026-03-10 19:12:14 +00:00
parent 3a06c18e10
commit 26a49162e6
24 changed files with 427 additions and 878 deletions

64
toolchain/xpcg/ctx.c Normal file
View File

@@ -0,0 +1,64 @@
#include "ctx.h"
#include <stdlib.h>
#include <string.h>
static void init_builtin_types(struct ctx *ctx)
{
for (size_t i = 0; i < TYPE_OTHER; i++) {
ctx->ctx_builtin_types[i].ty_id = i;
}
}
struct ctx *ctx_create(void)
{
struct ctx *out = malloc(sizeof *out);
if (!out) {
return NULL;
}
memset(out, 0x0, sizeof *out);
init_builtin_types(out);
return out;
}
void ctx_destroy(struct ctx *ctx)
{
free(ctx);
}
const struct type *ctx_get_type(struct ctx *ctx, const char *name)
{
if (!strcmp(name, "string")) {
return ctx_get_builtin_type(ctx, TYPE_STRING);
}
if (!strcmp(name, "int")) {
return ctx_get_builtin_type(ctx, TYPE_INT);
}
if (!strcmp(name, "handle")) {
return ctx_get_builtin_type(ctx, TYPE_HANDLE);
}
if (!strcmp(name, "size")) {
return ctx_get_builtin_type(ctx, TYPE_SIZE);
}
if (!strcmp(name, "buffer")) {
return ctx_get_builtin_type(ctx, TYPE_BUFFER);
}
return NULL;
}
const struct type *ctx_get_builtin_type(struct ctx *ctx, enum type_id id)
{
if (id >= TYPE_OTHER) {
return NULL;
}
return &ctx->ctx_builtin_types[id];
}