toolchain: xpcg: replace bluelib with fx

This commit is contained in:
2026-03-21 10:33:39 +00:00
parent 68ae449731
commit ffc2ed735e
15 changed files with 524 additions and 538 deletions

View File

@@ -6,9 +6,9 @@
#include "msg.h"
#include "parse.h"
#include <blue/cmd.h>
#include <blue/io/file.h>
#include <blue/io/path.h>
#include <fx/cmd.h>
#include <fx/io/file.h>
#include <fx/io/path.h>
#define CMD_ID 0
@@ -20,71 +20,71 @@ enum {
int main(int argc, const char **argv)
{
return b_command_dispatch(CMD_ID, argc, argv);
return fx_command_dispatch(CMD_ID, argc, argv);
}
static void print_msg(struct msg_definition *msg)
{
printf(" msg: %s\n", msg->msg_name);
b_queue_entry *entry = b_queue_first(&msg->msg_params);
fx_queue_entry *entry = fx_queue_first(&msg->msg_params);
while (entry) {
struct msg_parameter *param
= b_unbox(struct msg_parameter, entry, p_entry);
= fx_unbox(struct msg_parameter, entry, p_entry);
printf(" param:");
type_print(param->p_type);
printf(" %s\n", param->p_name);
entry = b_queue_next(entry);
entry = fx_queue_next(entry);
}
entry = b_queue_first(&msg->msg_results);
entry = fx_queue_first(&msg->msg_results);
while (entry) {
struct msg_parameter *param
= b_unbox(struct msg_parameter, entry, p_entry);
= fx_unbox(struct msg_parameter, entry, p_entry);
printf(" result:");
type_print(param->p_type);
printf(" %s\n", param->p_name);
entry = b_queue_next(entry);
entry = fx_queue_next(entry);
}
}
static void print_interface(struct interface_definition *iface)
{
printf("interface: %s\n", iface->if_name);
b_queue_entry *entry = b_queue_first(&iface->if_msg);
fx_queue_entry *entry = fx_queue_first(&iface->if_msg);
while (entry) {
struct msg_definition *msg
= b_unbox(struct msg_definition, entry, msg_entry);
= fx_unbox(struct msg_definition, entry, msg_entry);
print_msg(msg);
entry = b_queue_next(entry);
entry = fx_queue_next(entry);
}
}
static int xpcg(
const b_command *self,
const b_arglist *opt,
const b_array *args)
const fx_command *self,
const fx_arglist *opt,
const fx_array *args)
{
const char *path = NULL;
b_arglist_get_string(opt, B_COMMAND_INVALID_ID, ARG_SRCPATH, 0, &path);
fx_arglist_get_string(opt, FX_COMMAND_INVALID_ID, ARG_SRCPATH, 0, &path);
if (!path) {
b_arglist_report_missing_args(
fx_arglist_report_missing_args(
opt,
B_COMMAND_INVALID_ID,
FX_COMMAND_INVALID_ID,
ARG_SRCPATH,
0);
return -1;
}
b_file *file = NULL;
b_result result
= b_file_open(NULL, B_RV_PATH(path), B_FILE_READ_ONLY, &file);
if (b_result_is_error(result)) {
b_throw(result);
fx_file *file = NULL;
fx_result result
= fx_file_open(NULL, FX_RV_PATH(path), FX_FILE_READ_ONLY, &file);
if (fx_result_is_error(result)) {
fx_throw(result);
return -1;
}
@@ -133,37 +133,37 @@ static int xpcg(
return err;
}
B_COMMAND(CMD_ID, B_COMMAND_INVALID_ID)
FX_COMMAND(CMD_ID, FX_COMMAND_INVALID_ID)
{
B_COMMAND_NAME("xpcg");
B_COMMAND_DESC("xpc interface generator.");
B_COMMAND_FLAGS(B_COMMAND_SHOW_HELP_BY_DEFAULT);
B_COMMAND_FUNCTION(xpcg);
B_COMMAND_HELP_OPTION();
FX_COMMAND_NAME("xpcg");
FX_COMMAND_DESC("xpc interface generator.");
FX_COMMAND_FLAGS(FX_COMMAND_SHOW_HELP_BY_DEFAULT);
FX_COMMAND_FUNCTION(xpcg);
FX_COMMAND_HELP_OPTION();
B_COMMAND_ARG(ARG_SRCPATH)
FX_COMMAND_ARG(ARG_SRCPATH)
{
B_ARG_NAME("source-file");
B_ARG_DESC("the interface file to compile.");
B_ARG_NR_VALUES(1);
FX_ARG_NAME("source-file");
FX_ARG_DESC("the interface file to compile.");
FX_ARG_NR_VALUES(1);
}
B_COMMAND_OPTION(OPT_BACKEND)
FX_COMMAND_OPTION(OPT_BACKEND)
{
B_OPTION_LONG_NAME("backend");
B_OPTION_SHORT_NAME('b');
B_OPTION_DESC("which backend to use.");
B_OPTION_ARG(OPT_BACKEND_ARG_NAME)
FX_OPTION_LONG_NAME("backend");
FX_OPTION_SHORT_NAME('b');
FX_OPTION_DESC("which backend to use.");
FX_OPTION_ARG(OPT_BACKEND_ARG_NAME)
{
B_ARG_NAME("backend-name");
B_ARG_NR_VALUES(1);
B_ARG_ALLOWED_VALUES("c-mpc");
FX_ARG_NAME("backend-name");
FX_ARG_NR_VALUES(1);
FX_ARG_ALLOWED_VALUES("c-mpc");
}
}
B_COMMAND_USAGE()
FX_COMMAND_USAGE()
{
B_COMMAND_USAGE_ARG(ARG_SRCPATH);
B_COMMAND_USAGE_OPT(OPT_BACKEND);
FX_COMMAND_USAGE_ARG(ARG_SRCPATH);
FX_COMMAND_USAGE_OPT(OPT_BACKEND);
}
}