meta: replace bluelib with fx

This commit is contained in:
2026-03-16 14:07:33 +00:00
parent d2abb6faa3
commit e5546f97c2
105 changed files with 1668 additions and 1668 deletions

View File

@@ -1,9 +1,9 @@
#include "../debug.h"
#include "cmd.h"
#include <blue/cmd.h>
#include <blue/ds/string.h>
#include <blue/term.h>
#include <fx/cmd.h>
#include <fx/ds/string.h>
#include <fx/term.h>
#include <errno.h>
#include <ivy/asm/assembler.h>
#include <ivy/asm/lex.h>
@@ -24,15 +24,15 @@ static int assemble_file(const char *in_path, const char *out_path)
struct ivy_file *src = NULL;
status = ivy_file_open(in_path, &src);
if (!src) {
b_err("cannot open source file '%s'", in_path);
b_i("reason: %s", ivy_status_to_string(status));
fx_err("cannot open source file '%s'", in_path);
fx_i("reason: %s", ivy_status_to_string(status));
return -1;
}
FILE *out = fopen(out_path, "w+b");
if (!out) {
b_err("cannot open output file '%s'", out_path);
b_i("reason: %s", strerror(errno));
fx_err("cannot open output file '%s'", out_path);
fx_i("reason: %s", strerror(errno));
return -1;
}
@@ -40,8 +40,8 @@ static int assemble_file(const char *in_path, const char *out_path)
status = ivy_assembler_create(out, &as);
if (status != IVY_OK) {
b_err("failed to initialise Ivy assembler");
b_i("reason: %s", ivy_status_to_string(status));
fx_err("failed to initialise Ivy assembler");
fx_i("reason: %s", ivy_status_to_string(status));
ivy_file_close(src);
fclose(out);
@@ -51,8 +51,8 @@ static int assemble_file(const char *in_path, const char *out_path)
struct ivy_asm_lexer *lex;
status = ivy_asm_lexer_create(&lex);
if (status != IVY_OK) {
b_err("failed to initialise Ivy assembly lexer");
b_i("reason: %s", ivy_status_to_string(status));
fx_err("failed to initialise Ivy assembly lexer");
fx_i("reason: %s", ivy_status_to_string(status));
ivy_file_close(src);
fclose(out);
@@ -63,8 +63,8 @@ static int assemble_file(const char *in_path, const char *out_path)
struct ivy_asm_parser *parser;
status = ivy_asm_parser_create(&parser);
if (status != IVY_OK) {
b_err("failed to initialise Ivy assembly parser");
b_i("reason: %s", ivy_status_to_string(status));
fx_err("failed to initialise Ivy assembly parser");
fx_i("reason: %s", ivy_status_to_string(status));
ivy_asm_lexer_destroy(lex);
ivy_file_close(src);
@@ -85,8 +85,8 @@ static int assemble_file(const char *in_path, const char *out_path)
}
if (status != IVY_OK) {
b_err("failed to parse '%s'", in_path);
b_i("reason: lex error (%s)",
fx_err("failed to parse '%s'", in_path);
fx_i("reason: lex error (%s)",
ivy_status_to_string(ivy_asm_lexer_get_status(lex)));
break;
}
@@ -95,8 +95,8 @@ static int assemble_file(const char *in_path, const char *out_path)
status = ivy_asm_parser_push_token(parser, tok);
if (status != IVY_OK) {
b_err("failed to parse '%s'", in_path);
b_i("reason: parse error (%s)",
fx_err("failed to parse '%s'", in_path);
fx_i("reason: parse error (%s)",
ivy_status_to_string(status));
break;
}
@@ -112,31 +112,31 @@ static int assemble_file(const char *in_path, const char *out_path)
return r;
}
static b_string *get_source_filename(const char *src_path)
static fx_string *get_source_filename(const char *src_path)
{
b_string *name = b_string_create();
fx_string *name = fx_string_create();
for (unsigned int i = 0; src_path[i]; i++) {
if (src_path[i] == '/' || src_path[i] == '\\') {
b_string_clear(name);
fx_string_clear(name);
continue;
}
char s[] = {src_path[i], 0};
b_string_append_cstr(name, s);
fx_string_append_cstr(name, s);
}
if (b_string_get_size(name, B_STRLEN_NORMAL) == 0) {
b_string_unref(name);
if (fx_string_get_size(name, FX_STRLEN_NORMAL) == 0) {
fx_string_unref(name);
name = NULL;
}
return name;
}
static b_string *generate_object_filename(const char *src_filename)
static fx_string *generate_object_filename(const char *src_filename)
{
b_string *name = b_string_create();
fx_string *name = fx_string_create();
for (unsigned int i = 0; src_filename[i]; i++) {
if (src_filename[i] == '.') {
@@ -144,53 +144,53 @@ static b_string *generate_object_filename(const char *src_filename)
}
char s[] = {src_filename[i], 0};
b_string_append_cstr(name, s);
fx_string_append_cstr(name, s);
}
if (b_string_get_size(name, B_STRLEN_NORMAL) == 0) {
b_string_append_cstr(name, "out");
if (fx_string_get_size(name, FX_STRLEN_NORMAL) == 0) {
fx_string_append_cstr(name, "out");
}
b_string_append_cstr(name, ".io");
fx_string_append_cstr(name, ".io");
return name;
}
static int assemble(const b_command *cmd, const b_arglist *args, const b_array *_)
static int assemble(const fx_command *cmd, const fx_arglist *args, const fx_array *_)
{
const char *in_path = NULL;
const char *out_path = NULL;
b_string *in_name = NULL;
b_string *out_name = NULL;
fx_string *in_name = NULL;
fx_string *out_name = NULL;
b_arglist_get_string(
args, B_COMMAND_INVALID_ID, ARG_SOURCE_FILE, 0, &in_path);
fx_arglist_get_string(
args, FX_COMMAND_INVALID_ID, ARG_SOURCE_FILE, 0, &in_path);
if (!in_path) {
b_err("no source file specified.");
fx_err("no source file specified.");
return -1;
}
in_name = get_source_filename(in_path);
if (!in_path) {
b_err("source filepath is not a file.");
fx_err("source filepath is not a file.");
return -1;
}
b_arglist_get_string(args, OPT_OUT_FILE, ARG_OUT_FILE, 0, &out_path);
fx_arglist_get_string(args, OPT_OUT_FILE, ARG_OUT_FILE, 0, &out_path);
if (!out_path) {
out_name = generate_object_filename(b_string_ptr(in_name));
out_path = b_string_ptr(out_name);
out_name = generate_object_filename(fx_string_ptr(in_name));
out_path = fx_string_ptr(out_name);
}
int r = assemble_file(in_path, out_path);
b_string_unref(in_name);
b_string_unref(out_name);
fx_string_unref(in_name);
fx_string_unref(out_name);
return r;
#if 0
const char *path = NULL;
b_arglist_get_string(args, OPT_OUT_FILE, ARG_OUT_FILE, 0, &path);
fx_arglist_get_string(args, OPT_OUT_FILE, ARG_OUT_FILE, 0, &path);
if (!path) {
printf("no output path specified.\n");
@@ -202,8 +202,8 @@ static int assemble(const b_command *cmd, const b_arglist *args, const b_array *
enum ivy_status status = ivy_assembler_create(out, &as);
if (status != IVY_OK) {
b_err("failed to initialise assembler");
b_i("reason: ", ivy_status_to_string(status));
fx_err("failed to initialise assembler");
fx_i("reason: ", ivy_status_to_string(status));
fclose(out);
return -1;
}
@@ -231,32 +231,32 @@ static int assemble(const b_command *cmd, const b_arglist *args, const b_array *
B_COMMAND(CMD_ASSEMBLE, CMD_ROOT)
{
B_COMMAND_NAME("assemble");
B_COMMAND_SHORT_NAME('A');
B_COMMAND_DESC(
FX_COMMAND_NAME("assemble");
FX_COMMAND_SHORT_NAME('A');
FX_COMMAND_DESC(
"assemble one or more Ivy assembly source files into Ivy "
"object files.");
B_COMMAND_FLAGS(B_COMMAND_SHOW_HELP_BY_DEFAULT);
B_COMMAND_FUNCTION(assemble);
FX_COMMAND_FLAGS(FX_COMMAND_SHOW_HELP_BY_DEFAULT);
FX_COMMAND_FUNCTION(assemble);
B_COMMAND_ARG(ARG_SOURCE_FILE)
FX_COMMAND_ARG(ARG_SOURCE_FILE)
{
B_ARG_NAME("source file");
B_ARG_DESC("the .iasm assembly file to compile.");
B_ARG_NR_VALUES(1);
FX_ARG_NAME("source file");
FX_ARG_DESC("the .iasm assembly file to compile.");
FX_ARG_NR_VALUES(1);
}
B_COMMAND_OPTION(OPT_OUT_FILE)
FX_COMMAND_OPTION(OPT_OUT_FILE)
{
B_OPTION_SHORT_NAME('o');
B_OPTION_LONG_NAME("out");
B_OPTION_DESC("the path to write the output binary file to.");
B_OPTION_ARG(ARG_OUT_FILE)
FX_OPTION_SHORT_NAME('o');
FX_OPTION_LONG_NAME("out");
FX_OPTION_DESC("the path to write the output binary file to.");
FX_OPTION_ARG(ARG_OUT_FILE)
{
B_ARG_NAME("path");
B_ARG_NR_VALUES(1);
FX_ARG_NAME("path");
FX_ARG_NR_VALUES(1);
}
}
B_COMMAND_HELP_OPTION();
FX_COMMAND_HELP_OPTION();
}