meta: replace bluelib with fx
This commit is contained in:
@@ -12,4 +12,4 @@ endif ()
|
||||
|
||||
target_include_directories(ivy-common PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/include/)
|
||||
target_compile_definitions(ivy-common PRIVATE IVY_EXPORT=1 IVY_STATIC=${IVY_STATIC})
|
||||
target_link_libraries(ivy-common Bluelib::Core Bluelib::Ds)
|
||||
target_link_libraries(ivy-common FX::Core FX::Ds)
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#include <blue/ds/array.h>
|
||||
#include <blue/ds/string.h>
|
||||
#include <fx/ds/array.h>
|
||||
#include <fx/ds/string.h>
|
||||
#include <errno.h>
|
||||
#include <ivy/file.h>
|
||||
#include <stdlib.h>
|
||||
@@ -18,17 +18,17 @@ static enum ivy_status get_row(
|
||||
size_t *nr_read)
|
||||
{
|
||||
struct ivy_file *f = (struct ivy_file *)src;
|
||||
size_t nr_rows = b_array_size(f->f_lines);
|
||||
size_t nr_rows = fx_array_size(f->f_lines);
|
||||
|
||||
if (row > nr_rows) {
|
||||
return IVY_ERR_EOF;
|
||||
}
|
||||
|
||||
b_string *line = b_array_at(f->f_lines, row - 1);
|
||||
fx_string *line = fx_array_at(f->f_lines, row - 1);
|
||||
|
||||
const char *line_str = b_string_ptr(line);
|
||||
size_t line_len = b_string_get_size(line, B_STRLEN_NORMAL);
|
||||
size_t copy_len = b_min(ulong, count, line_len);
|
||||
const char *line_str = fx_string_ptr(line);
|
||||
size_t line_len = fx_string_get_size(line, FX_STRLEN_NORMAL);
|
||||
size_t copy_len = fx_min(ulong, count, line_len);
|
||||
|
||||
memcpy(buf, line_str, copy_len);
|
||||
buf[copy_len] = 0;
|
||||
@@ -52,9 +52,9 @@ static enum ivy_status readline(
|
||||
return feof(f->f_fp) ? IVY_ERR_EOF : IVY_ERR_IO_FAILURE;
|
||||
}
|
||||
|
||||
b_string *line_str = b_string_create_from_cstr(buf);
|
||||
b_array_append(f->f_lines, B_OBJECT(line_str));
|
||||
b_string_unref(line_str);
|
||||
fx_string *line_str = fx_string_create_from_cstr(buf);
|
||||
fx_array_append(f->f_lines, FX_OBJECT(line_str));
|
||||
fx_string_unref(line_str);
|
||||
|
||||
*nr_read = strlen(buf);
|
||||
return IVY_OK;
|
||||
@@ -79,8 +79,8 @@ enum ivy_status ivy_file_open(const char *path, struct ivy_file **out)
|
||||
file->f_base.s_get_row = get_row;
|
||||
file->f_base.s_readline = readline;
|
||||
file->f_fp = fp;
|
||||
file->f_path = b_strdup(path);
|
||||
file->f_lines = b_array_create();
|
||||
file->f_path = fx_strdup(path);
|
||||
file->f_lines = fx_array_create();
|
||||
|
||||
*out = file;
|
||||
|
||||
@@ -89,7 +89,7 @@ enum ivy_status ivy_file_open(const char *path, struct ivy_file **out)
|
||||
|
||||
void ivy_file_close(struct ivy_file *file)
|
||||
{
|
||||
b_array_unref(file->f_lines);
|
||||
fx_array_unref(file->f_lines);
|
||||
free(file->f_path);
|
||||
fclose(file->f_fp);
|
||||
free(file);
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#include <blue/core/queue.h>
|
||||
#include <blue/core/stringstream.h>
|
||||
#include <blue/ds/string.h>
|
||||
#include <fx/core/queue.h>
|
||||
#include <fx/core/stringstream.h>
|
||||
#include <fx/ds/string.h>
|
||||
#include <ivy/ident.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
@@ -20,12 +20,12 @@ struct ivy_ident *ivy_ident_create(void)
|
||||
|
||||
void ivy_ident_destroy(struct ivy_ident *ident)
|
||||
{
|
||||
b_queue_entry *entry = b_queue_first(&ident->id_parts);
|
||||
fx_queue_entry *entry = fx_queue_first(&ident->id_parts);
|
||||
while (entry) {
|
||||
struct ivy_ident_part *part
|
||||
= b_unbox(struct ivy_ident_part, entry, p_entry);
|
||||
b_queue_entry *next = b_queue_next(entry);
|
||||
b_queue_delete(&ident->id_parts, entry);
|
||||
= fx_unbox(struct ivy_ident_part, entry, p_entry);
|
||||
fx_queue_entry *next = fx_queue_next(entry);
|
||||
fx_queue_delete(&ident->id_parts, entry);
|
||||
|
||||
free(part->p_str);
|
||||
free(part);
|
||||
@@ -45,25 +45,25 @@ void ivy_ident_add_part(struct ivy_ident *ident, const char *s)
|
||||
|
||||
memset(part, 0x0, sizeof *part);
|
||||
|
||||
part->p_str = b_strdup(s);
|
||||
part->p_str = fx_strdup(s);
|
||||
|
||||
b_queue_push_back(&ident->id_parts, &part->p_entry);
|
||||
fx_queue_push_back(&ident->id_parts, &part->p_entry);
|
||||
}
|
||||
|
||||
size_t ivy_ident_to_string(const struct ivy_ident *ident, char *out, size_t max)
|
||||
{
|
||||
b_stringstream *strv = b_stringstream_create_with_buffer(out, max);
|
||||
fx_stringstream *strv = fx_stringstream_create_with_buffer(out, max);
|
||||
|
||||
int i = 0;
|
||||
b_queue_entry *entry = b_queue_first(&ident->id_parts);
|
||||
fx_queue_entry *entry = fx_queue_first(&ident->id_parts);
|
||||
while (entry) {
|
||||
if (i > 0) {
|
||||
b_stream_write_char(strv, '.');
|
||||
fx_stream_write_char(strv, '.');
|
||||
}
|
||||
|
||||
struct ivy_ident_part *part
|
||||
= b_unbox(struct ivy_ident_part, entry, p_entry);
|
||||
b_stream_write_string(strv, part->p_str, NULL);
|
||||
= fx_unbox(struct ivy_ident_part, entry, p_entry);
|
||||
fx_stream_write_string(strv, part->p_str, NULL);
|
||||
i++;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
#ifndef IVY_COMMON_FILE_H_
|
||||
#define IVY_COMMON_FILE_H_
|
||||
|
||||
#include <blue/ds/array.h>
|
||||
#include <fx/ds/array.h>
|
||||
#include <ivy/line-source.h>
|
||||
#include <ivy/misc.h>
|
||||
#include <stdio.h>
|
||||
|
||||
struct ivy_file {
|
||||
struct ivy_line_source f_base;
|
||||
b_array *f_lines;
|
||||
fx_array *f_lines;
|
||||
char *f_path;
|
||||
FILE *f_fp;
|
||||
};
|
||||
|
||||
@@ -1,17 +1,17 @@
|
||||
#ifndef IVY_IDENT_H_
|
||||
#define IVY_IDENT_H_
|
||||
|
||||
#include <blue/core/queue.h>
|
||||
#include <fx/core/queue.h>
|
||||
#include <ivy/misc.h>
|
||||
#include <stddef.h>
|
||||
|
||||
struct ivy_ident_part {
|
||||
char *p_str;
|
||||
b_queue_entry p_entry;
|
||||
fx_queue_entry p_entry;
|
||||
};
|
||||
|
||||
struct ivy_ident {
|
||||
b_queue id_parts;
|
||||
fx_queue id_parts;
|
||||
};
|
||||
|
||||
IVY_API struct ivy_ident *ivy_ident_create(void);
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#ifndef IVY_SELECTOR_H_
|
||||
#define IVY_SELECTOR_H_
|
||||
|
||||
#include <blue/core/queue.h>
|
||||
#include <fx/core/queue.h>
|
||||
#include <ivy/status.h>
|
||||
|
||||
enum ivy_selector_recipient {
|
||||
@@ -13,13 +13,13 @@ enum ivy_selector_recipient {
|
||||
struct ivy_selector {
|
||||
enum ivy_selector_recipient sel_recipient;
|
||||
char *sel_name;
|
||||
b_queue sel_args;
|
||||
fx_queue sel_args;
|
||||
};
|
||||
|
||||
struct ivy_selector_arg {
|
||||
char *arg_label;
|
||||
char *arg_name;
|
||||
b_queue_entry arg_entry;
|
||||
fx_queue_entry arg_entry;
|
||||
};
|
||||
|
||||
IVY_API enum ivy_status ivy_selector_create(struct ivy_selector **sel);
|
||||
|
||||
@@ -5,9 +5,9 @@
|
||||
|
||||
#define IVY_ERROR_VENDOR (ivy_error_vendor())
|
||||
|
||||
enum b_status;
|
||||
enum fx_status;
|
||||
|
||||
struct b_error_vendor;
|
||||
struct fx_error_vendor;
|
||||
|
||||
enum ivy_status {
|
||||
IVY_OK = 0,
|
||||
@@ -28,8 +28,8 @@ enum ivy_status {
|
||||
};
|
||||
|
||||
IVY_API const char *ivy_status_to_string(enum ivy_status status);
|
||||
IVY_API const struct b_error_vendor *ivy_error_vendor(void);
|
||||
IVY_API enum ivy_status ivy_status_from_b_status(enum b_status status);
|
||||
IVY_API const struct fx_error_vendor *ivy_error_vendor(void);
|
||||
IVY_API enum ivy_status ivy_status_from_b_status(enum fx_status status);
|
||||
IVY_API enum ivy_status ivy_status_from_errno(int err);
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#include <blue/core/queue.h>
|
||||
#include <blue/core/stringstream.h>
|
||||
#include <blue/ds/string.h>
|
||||
#include <fx/core/queue.h>
|
||||
#include <fx/core/stringstream.h>
|
||||
#include <fx/ds/string.h>
|
||||
#include <ivy/selector.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
@@ -25,12 +25,12 @@ void ivy_selector_destroy(struct ivy_selector *sel)
|
||||
free(sel->sel_name);
|
||||
}
|
||||
|
||||
b_queue_entry *entry = b_queue_first(&sel->sel_args);
|
||||
fx_queue_entry *entry = fx_queue_first(&sel->sel_args);
|
||||
while (entry) {
|
||||
struct ivy_selector_arg *arg
|
||||
= b_unbox(struct ivy_selector_arg, entry, arg_entry);
|
||||
b_queue_entry *next = b_queue_next(entry);
|
||||
b_queue_delete(&sel->sel_args, entry);
|
||||
= fx_unbox(struct ivy_selector_arg, entry, arg_entry);
|
||||
fx_queue_entry *next = fx_queue_next(entry);
|
||||
fx_queue_delete(&sel->sel_args, entry);
|
||||
|
||||
if (arg->arg_label) {
|
||||
free(arg->arg_label);
|
||||
@@ -56,7 +56,7 @@ void ivy_selector_set_recipient(
|
||||
|
||||
enum ivy_status ivy_selector_set_name(struct ivy_selector *sel, const char *name)
|
||||
{
|
||||
sel->sel_name = b_strdup(name);
|
||||
sel->sel_name = fx_strdup(name);
|
||||
return sel->sel_name ? IVY_OK : IVY_ERR_NO_MEMORY;
|
||||
}
|
||||
|
||||
@@ -71,7 +71,7 @@ enum ivy_status ivy_selector_add_arg(
|
||||
memset(arg, 0x0, sizeof *arg);
|
||||
|
||||
if (label) {
|
||||
arg->arg_label = b_strdup(label);
|
||||
arg->arg_label = fx_strdup(label);
|
||||
|
||||
if (!arg->arg_label) {
|
||||
free(arg);
|
||||
@@ -80,7 +80,7 @@ enum ivy_status ivy_selector_add_arg(
|
||||
}
|
||||
|
||||
if (name) {
|
||||
arg->arg_name = b_strdup(name);
|
||||
arg->arg_name = fx_strdup(name);
|
||||
|
||||
if (!arg->arg_name) {
|
||||
free(arg->arg_label);
|
||||
@@ -89,49 +89,49 @@ enum ivy_status ivy_selector_add_arg(
|
||||
}
|
||||
}
|
||||
|
||||
b_queue_push_back(&sel->sel_args, &arg->arg_entry);
|
||||
fx_queue_push_back(&sel->sel_args, &arg->arg_entry);
|
||||
return IVY_OK;
|
||||
}
|
||||
|
||||
size_t ivy_selector_to_string(const struct ivy_selector *sel, char *out, size_t max)
|
||||
{
|
||||
b_stringstream *str = b_stringstream_create_with_buffer(out, max);
|
||||
fx_stringstream *str = fx_stringstream_create_with_buffer(out, max);
|
||||
|
||||
switch (sel->sel_recipient) {
|
||||
case IVY_SEL_OBJECT:
|
||||
b_stream_write_char(str, '-');
|
||||
fx_stream_write_char(str, '-');
|
||||
break;
|
||||
case IVY_SEL_CLASS:
|
||||
b_stream_write_char(str, '+');
|
||||
fx_stream_write_char(str, '+');
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
if (sel->sel_name) {
|
||||
b_stream_write_string(str, sel->sel_name, NULL);
|
||||
fx_stream_write_string(str, sel->sel_name, NULL);
|
||||
}
|
||||
|
||||
if (sel->sel_name && !b_queue_empty(&sel->sel_args)) {
|
||||
b_stream_write_char(str, '(');
|
||||
if (sel->sel_name && !fx_queue_empty(&sel->sel_args)) {
|
||||
fx_stream_write_char(str, '(');
|
||||
}
|
||||
|
||||
b_queue_entry *entry = b_queue_first(&sel->sel_args);
|
||||
fx_queue_entry *entry = fx_queue_first(&sel->sel_args);
|
||||
while (entry) {
|
||||
struct ivy_selector_arg *arg
|
||||
= b_unbox(struct ivy_selector_arg, entry, arg_entry);
|
||||
b_stream_write_fmt(
|
||||
= fx_unbox(struct ivy_selector_arg, entry, arg_entry);
|
||||
fx_stream_write_fmt(
|
||||
str, NULL, "%s:", arg->arg_label ? arg->arg_label : "_");
|
||||
|
||||
entry = b_queue_next(entry);
|
||||
entry = fx_queue_next(entry);
|
||||
}
|
||||
|
||||
if (sel->sel_name && !b_queue_empty(&sel->sel_args)) {
|
||||
b_stream_write_char(str, ')');
|
||||
if (sel->sel_name && !fx_queue_empty(&sel->sel_args)) {
|
||||
fx_stream_write_char(str, ')');
|
||||
}
|
||||
|
||||
size_t len = b_stringstream_get_length(str);
|
||||
b_stringstream_unref(str);
|
||||
size_t len = fx_stringstream_get_length(str);
|
||||
fx_stringstream_unref(str);
|
||||
|
||||
return len;
|
||||
}
|
||||
|
||||
@@ -1,34 +1,34 @@
|
||||
#include <blue/core/error.h>
|
||||
#include <fx/core/error.h>
|
||||
#include <errno.h>
|
||||
#include <ivy/status.h>
|
||||
|
||||
static const b_error_definition error_defs[] = {
|
||||
B_ERROR_DEFINITION(IVY_OK, "OK", "Success"),
|
||||
B_ERROR_DEFINITION(IVY_ERR_EOF, "EOF", "Unexpected end of file"),
|
||||
B_ERROR_DEFINITION(IVY_ERR_IO_FAILURE, "IO_FAILURE", "I/O failure"),
|
||||
B_ERROR_DEFINITION(IVY_ERR_BAD_SYNTAX, "BAD_SYNTAX", "Invalid syntax"),
|
||||
B_ERROR_DEFINITION(IVY_ERR_NO_MEMORY, "NO_MEMORY", "Out of memory"),
|
||||
B_ERROR_DEFINITION(
|
||||
static const fx_error_definition error_defs[] = {
|
||||
FX_ERROR_DEFINITION(IVY_OK, "OK", "Success"),
|
||||
FX_ERROR_DEFINITION(IVY_ERR_EOF, "EOF", "Unexpected end of file"),
|
||||
FX_ERROR_DEFINITION(IVY_ERR_IO_FAILURE, "IO_FAILURE", "I/O failure"),
|
||||
FX_ERROR_DEFINITION(IVY_ERR_BAD_SYNTAX, "BAD_SYNTAX", "Invalid syntax"),
|
||||
FX_ERROR_DEFINITION(IVY_ERR_NO_MEMORY, "NO_MEMORY", "Out of memory"),
|
||||
FX_ERROR_DEFINITION(
|
||||
IVY_ERR_NOT_SUPPORTED, "NOT_SUPPORTED",
|
||||
"Operation not supported"),
|
||||
B_ERROR_DEFINITION(
|
||||
FX_ERROR_DEFINITION(
|
||||
IVY_ERR_INTERNAL_FAILURE, "INTERNAL_FAILURE",
|
||||
"Internal failure"),
|
||||
B_ERROR_DEFINITION(IVY_ERR_BAD_STATE, "BAD_STATE", "Bad state"),
|
||||
B_ERROR_DEFINITION(
|
||||
FX_ERROR_DEFINITION(IVY_ERR_BAD_STATE, "BAD_STATE", "Bad state"),
|
||||
FX_ERROR_DEFINITION(
|
||||
IVY_ERR_INVALID_VALUE, "INVALID_VALUE", "Invalid value"),
|
||||
B_ERROR_DEFINITION(IVY_ERR_NO_ENTRY, "NO_ENTRY", "Name does not exist"),
|
||||
B_ERROR_DEFINITION(
|
||||
FX_ERROR_DEFINITION(IVY_ERR_NO_ENTRY, "NO_ENTRY", "Name does not exist"),
|
||||
FX_ERROR_DEFINITION(
|
||||
IVY_ERR_NAME_EXISTS, "NAME_EXISTS", "Name already exists"),
|
||||
B_ERROR_DEFINITION(IVY_ERR_BAD_FORMAT, "BAD_FORMAT", "Bad format"),
|
||||
B_ERROR_DEFINITION(
|
||||
FX_ERROR_DEFINITION(IVY_ERR_BAD_FORMAT, "BAD_FORMAT", "Bad format"),
|
||||
FX_ERROR_DEFINITION(
|
||||
IVY_ERR_PARSE_FAILURE, "PARSE_FAILURE", "Parse failure"),
|
||||
B_ERROR_DEFINITION(
|
||||
FX_ERROR_DEFINITION(
|
||||
IVY_ERR_CODEGEN_FAILURE, "CODEGEN_FAILURE",
|
||||
"Code generation failure"),
|
||||
};
|
||||
|
||||
static const b_error_vendor error_vendor = {
|
||||
static const fx_error_vendor error_vendor = {
|
||||
.v_name = "Ivy",
|
||||
.v_error_definitions = error_defs,
|
||||
.v_error_definitions_length = sizeof error_defs,
|
||||
@@ -39,7 +39,7 @@ const char *ivy_status_to_string(enum ivy_status status)
|
||||
return error_defs[status].err_message;
|
||||
}
|
||||
|
||||
const struct b_error_vendor *ivy_error_vendor(void)
|
||||
const struct fx_error_vendor *ivy_error_vendor(void)
|
||||
{
|
||||
return &error_vendor;
|
||||
}
|
||||
@@ -48,12 +48,12 @@ const struct b_error_vendor *ivy_error_vendor(void)
|
||||
case (from): \
|
||||
return (to)
|
||||
|
||||
enum ivy_status ivy_status_from_b_status(enum b_status status)
|
||||
enum ivy_status ivy_status_from_b_status(enum fx_status status)
|
||||
{
|
||||
switch (status) {
|
||||
ENUM_CONVERT(B_SUCCESS, IVY_OK);
|
||||
ENUM_CONVERT(B_ERR_NAME_EXISTS, IVY_ERR_NAME_EXISTS);
|
||||
ENUM_CONVERT(B_ERR_NO_MEMORY, IVY_ERR_NO_MEMORY);
|
||||
ENUM_CONVERT(FX_SUCCESS, IVY_OK);
|
||||
ENUM_CONVERT(FX_ERR_NAME_EXISTS, IVY_ERR_NAME_EXISTS);
|
||||
ENUM_CONVERT(FX_ERR_NO_MEMORY, IVY_ERR_NO_MEMORY);
|
||||
default:
|
||||
return IVY_ERR_INTERNAL_FAILURE;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user