From ffc2ed735ef4c414a50e1a0e1b7a005240a06929 Mon Sep 17 00:00:00 2001 From: Max Wash Date: Sat, 21 Mar 2026 10:33:39 +0000 Subject: [PATCH] toolchain: xpcg: replace bluelib with fx --- toolchain/CMakeLists.txt | 2 +- toolchain/cmake/FindBluelib.cmake | 212 ------------------- toolchain/cmake/FindFX.cmake | 189 +++++++++++++++++ toolchain/xpcg/CMakeLists.txt | 2 +- toolchain/xpcg/backend/c-mpc/backend.c | 281 +++++++++++++------------ toolchain/xpcg/interface.c | 18 +- toolchain/xpcg/interface.h | 4 +- toolchain/xpcg/lex.c | 120 +++++------ toolchain/xpcg/lex.h | 16 +- toolchain/xpcg/line-source.c | 56 ++--- toolchain/xpcg/line-source.h | 22 +- toolchain/xpcg/main.c | 90 ++++---- toolchain/xpcg/msg.c | 36 ++-- toolchain/xpcg/msg.h | 10 +- toolchain/xpcg/token.h | 4 +- 15 files changed, 524 insertions(+), 538 deletions(-) delete mode 100644 toolchain/cmake/FindBluelib.cmake create mode 100644 toolchain/cmake/FindFX.cmake diff --git a/toolchain/CMakeLists.txt b/toolchain/CMakeLists.txt index 3318416..5d691fb 100644 --- a/toolchain/CMakeLists.txt +++ b/toolchain/CMakeLists.txt @@ -8,7 +8,7 @@ set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/bin) set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/lib) set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/lib) -find_package(Bluelib REQUIRED COMPONENTS Core Ds Term Cmd Io) +find_package(FX REQUIRED COMPONENTS Core Ds Term Cmd Io) add_subdirectory( ../kernel/tools diff --git a/toolchain/cmake/FindBluelib.cmake b/toolchain/cmake/FindBluelib.cmake deleted file mode 100644 index 22f453f..0000000 --- a/toolchain/cmake/FindBluelib.cmake +++ /dev/null @@ -1,212 +0,0 @@ -#[=======================================================================[.rst: -FindBluelib ------------- - -Find the Bluelib library and header directories - -Imported Targets -^^^^^^^^^^^^^^^^ - -This module defines the following :prop_tgt:`IMPORTED` target: - -``Bluelib::Bluelib`` -The Bluelib library, if found - -Result Variables -^^^^^^^^^^^^^^^^ - -This module will set the following variables in your project: - -``Bluelib_FOUND`` -true if the Bluelib C headers and libraries were found -``Bluelib_INCLUDE_DIR`` -directories containing the Bluelib C headers. - -``Bluelib_LIBRARY`` -the C library to link against - -Hints -^^^^^ - -The user may set the environment variable ``Bluelib_PREFIX`` to the root -directory of a Bluelib library installation. -#]=======================================================================] - -set (Bluelib_SEARCH_PATHS - ~/Library/Frameworks - /Library/Frameworks - /usr/local - /usr/local/share - /usr - /sw # Fink - /opt/local # DarwinPorts - /opt/csw # Blastwave - /opt - ${Bluelib_PREFIX} - $ENV{Bluelib_PREFIX}) - -if (Bluelib_STATIC) - set(_lib_suffix "-s") -endif () - -set(supported_components - Core Ds Term Cmd Io Serial Compress - Core-MM) -set(components ${Bluelib_FIND_COMPONENTS}) -string(REPLACE ";" ", " supported_components_string_list "${supported_components}") - -if (NOT components) - set(components ${supported_components}) -endif () - -set(required_vars) - -foreach (component ${components}) - if (NOT "${component}" IN_LIST supported_components) - message(FATAL_ERROR "'${component}' is not a valid Bluelib module.\nSupported modules: ${supported_components_string_list}") - endif () - - string(TOLOWER ${component} header_name) - string(REPLACE "-mm" "" header_name "${header_name}") - - string(TOLOWER ${component} lib_name) - set(lib_name ${lib_name}${_lib_suffix}) - - set(cmake_lib_name ${component}) - string(REPLACE "-" "_" cmake_lib_name "${cmake_lib_name}") - - if (NOT Bluelib_${cmake_lib_dir}_INCLUDE_DIR) - find_path(Bluelib_${cmake_lib_name}_INCLUDE_DIR - NAMES blue/${header_name}.h blue/${header_name}.hpp - ${Bluelib_FIND_ARGS} - PATH_SUFFIXES include - PATHS ${Bluelib_SEARCH_PATHS}) - endif () - - if (NOT Bluelib_${cmake_lib_dir}_LIBRARY) - find_library(Bluelib_${cmake_lib_name}_LIBRARY - NAMES blue-${lib_name} ${Bluelib_FIND_ARGS} - PATH_SUFFIXES lib - PATHS ${Bluelib_SEARCH_PATHS}) - else () - # on Windows, ensure paths are in canonical format (forward slahes): - file(TO_CMAKE_PATH "${Bluelib_${cmake_lib_name}_LIBRARY}" Bluelib_${cmake_lib_name}_LIBRARY) - endif() - - list(APPEND required_vars Bluelib_${cmake_lib_name}_INCLUDE_DIR Bluelib_${cmake_lib_name}_LIBRARY) -endforeach (component) - -unset(Bluelib_FIND_ARGS) - -include(FindPackageHandleStandardArgs) - -find_package_handle_standard_args(Bluelib - REQUIRED_VARS ${required_vars}) - -if (Bluelib_FOUND) - set(created_targets) - foreach (component ${components}) - string(TOLOWER ${component} header_name) - string(REPLACE "-mm" "" header_name "${header_name}") - - string(TOLOWER ${component} lib_name) - set(lib_name ${lib_name}${_lib_suffix}) - - set(cmake_lib_name ${component}) - string(REPLACE "-" "_" cmake_lib_name "${cmake_lib_name}") - - if(NOT TARGET Bluelib::${component}) - add_library(Bluelib::${component} UNKNOWN IMPORTED) - set_target_properties(Bluelib::${component} PROPERTIES - INTERFACE_INCLUDE_DIRECTORIES "${Bluelib_${cmake_lib_name}_INCLUDE_DIR}") - target_compile_definitions(Bluelib::${component} INTERFACE _CRT_SECURE_NO_WARNINGS=1) - - if (Bluelib_STATIC) - target_compile_definitions(Bluelib::${component} INTERFACE BLUELIB_STATIC=1) - endif () - - set_target_properties(Bluelib::${component} PROPERTIES - IMPORTED_LINK_INTERFACE_LANGUAGES "C" - IMPORTED_LOCATION "${Bluelib_${cmake_lib_name}_LIBRARY}") - set(created_targets ${created_targets} ${component}) - endif () - endforeach (component) - - foreach (component ${created_targets}) - if ("${component}" STREQUAL "Ds") - if (NOT TARGET Bluelib::Core) - message(FATAL_ERROR "Bluelib: Module 'Ds' depends on 'Core', which was not specified in find_package()") - endif () - - target_link_libraries(Bluelib::Ds INTERFACE Bluelib::Core) - endif () - - if ("${component}" STREQUAL "Term") - if (NOT TARGET Bluelib::Core) - message(FATAL_ERROR "Bluelib: Module 'Term' depends on 'Core', which was not specified in find_package()") - endif () - - if (NOT TARGET Bluelib::Ds) - message(FATAL_ERROR "Bluelib: Module 'Term' depends on 'Ds', which was not specified in find_package()") - endif () - - target_link_libraries(Bluelib::Term INTERFACE Bluelib::Core Bluelib::Ds) - endif () - - if ("${component}" STREQUAL "Serial") - if (NOT TARGET Bluelib::Core) - message(FATAL_ERROR "Bluelib: Module 'Serial' depends on 'Core', which was not specified in find_package()") - endif () - - if (NOT TARGET Bluelib::Ds) - message(FATAL_ERROR "Bluelib: Module 'Serial' depends on 'Ds', which was not specified in find_package()") - endif () - - target_link_libraries(Bluelib::Serial INTERFACE Bluelib::Core Bluelib::Ds) - endif () - - if ("${component}" STREQUAL "Cmd") - if (NOT TARGET Bluelib::Core) - message(FATAL_ERROR "Bluelib: Module 'Cmd' depends on 'Core', which was not specified in find_package()") - endif () - - if (NOT TARGET Bluelib::Ds) - message(FATAL_ERROR "Bluelib: Module 'Cmd' depends on 'Ds', which was not specified in find_package()") - endif () - - if (NOT TARGET Bluelib::Term) - message(FATAL_ERROR "Bluelib: Module 'Cmd' depends on 'Term', which was not specified in find_package()") - endif () - - target_link_libraries(Bluelib::Cmd INTERFACE Bluelib::Core Bluelib::Ds Bluelib::Term) - endif () - - if ("${component}" STREQUAL "Io") - if (NOT TARGET Bluelib::Core) - message(FATAL_ERROR "Bluelib: Module 'Io' depends on 'Core', which was not specified in find_package()") - endif () - - if (NOT TARGET Bluelib::Ds) - message(FATAL_ERROR "Bluelib: Module 'Io' depends on 'Ds', which was not specified in find_package()") - endif () - - target_link_libraries(Bluelib::Io INTERFACE Bluelib::Core Bluelib::Ds) - endif () - - if ("${component}" STREQUAL "Compress") - if (NOT TARGET Bluelib::Core) - message(FATAL_ERROR "Bluelib: Module 'Compress' depends on 'Core', which was not specified in find_package()") - endif () - - target_link_libraries(Bluelib::Compress INTERFACE Bluelib::Core Bluelib::Ds) - endif () - - if ("${component}" STREQUAL "Core-MM") - if (NOT TARGET Bluelib::Core) - message(FATAL_ERROR "Bluelib: Module 'Core-MM' depends on 'Core', which was not specified in find_package()") - endif () - - target_link_libraries(Bluelib::Core-MM INTERFACE Bluelib::Core) - endif () - endforeach (component) -endif() diff --git a/toolchain/cmake/FindFX.cmake b/toolchain/cmake/FindFX.cmake new file mode 100644 index 0000000..735ae13 --- /dev/null +++ b/toolchain/cmake/FindFX.cmake @@ -0,0 +1,189 @@ +#[=======================================================================[.rst: +FindFX +------------ + +Find the FX library and header directories + +Imported Targets +^^^^^^^^^^^^^^^^ + +This module defines the following :prop_tgt:`IMPORTED` target: + +``FX::FX`` +The FX library, if found + +Result Variables +^^^^^^^^^^^^^^^^ + +This module will set the following variables in your project: + +``FX_FOUND`` +true if the FX C headers and libraries were found +``FX_INCLUDE_DIR`` +directories containing the FX C headers. + +``FX_LIBRARY`` +the C library to link against + +Hints +^^^^^ + +The user may set the environment variable ``FX_PREFIX`` to the root +directory of a FX library installation. +#]=======================================================================] + +set (FX_SEARCH_PATHS + ~/Library/Frameworks + /Library/Frameworks + /usr/local + /usr/local/share + /usr + /sw # Fink + /opt/local # DarwinPorts + /opt/csw # Blastwave + /opt + ${FX_PREFIX} + $ENV{FX_PREFIX}) + +if (FX_STATIC) + set(_lib_suffix "-s") +endif () + +set(supported_components Core Ds Term Cmd Io Serial Compress) +set(components ${FX_FIND_COMPONENTS}) +string(REPLACE ";" ", " supported_components_string_list "${supported_components}") + +if (NOT components) + set(components ${supported_components}) +endif () + +set(required_vars) + +foreach (component ${components}) + if (NOT "${component}" IN_LIST supported_components) + message(FATAL_ERROR "'${component}' is not a valid FX module.\nSupported modules: ${supported_components_string_list}") + endif () + + string(TOLOWER ${component} header_name) + set(lib_name ${header_name}${_lib_suffix}) + + if (NOT FX_${component}_INCLUDE_DIR) + find_path(FX_${component}_INCLUDE_DIR + NAMES fx/${header_name}.h ${FX_FIND_ARGS} + PATH_SUFFIXES include + PATHS ${FX_SEARCH_PATHS}) + endif () + + if (NOT FX_${component}_LIBRARY) + find_library(FX_${component}_LIBRARY + NAMES fx-${lib_name} ${FX_FIND_ARGS} + PATH_SUFFIXES lib + PATHS ${FX_SEARCH_PATHS}) + else () + # on Windows, ensure paths are in canonical format (forward slahes): + file(TO_CMAKE_PATH "${FX_${component}_LIBRARY}" FX_${component}_LIBRARY) + endif() + + list(APPEND required_vars FX_${component}_INCLUDE_DIR FX_${component}_LIBRARY) +endforeach (component) + +unset(FX_FIND_ARGS) + +include(FindPackageHandleStandardArgs) + +find_package_handle_standard_args(FX + REQUIRED_VARS ${required_vars}) + +if (FX_FOUND) + set(created_targets) + foreach (component ${components}) + string(TOLOWER ${component} header_name) + set(lib_name ${header_name}${_lib_suffix}) + + if(NOT TARGET FX::${component}) + add_library(FX::${component} UNKNOWN IMPORTED) + set_target_properties(FX::${component} PROPERTIES + INTERFACE_INCLUDE_DIRECTORIES "${FX_${component}_INCLUDE_DIR}") + target_compile_definitions(FX::${component} INTERFACE _CRT_SECURE_NO_WARNINGS=1) + + if (FX_STATIC) + target_compile_definitions(FX::${component} INTERFACE FX_STATIC=1) + endif () + + set_target_properties(FX::${component} PROPERTIES + IMPORTED_LINK_INTERFACE_LANGUAGES "C" + IMPORTED_LOCATION "${FX_${component}_LIBRARY}") + set(created_targets ${created_targets} ${component}) + endif () + endforeach (component) + + foreach (component ${created_targets}) + if ("${component}" STREQUAL "Ds") + if (NOT TARGET FX::Core) + message(FATAL_ERROR "FX: Module 'Ds' depends on 'Core', which was not specified in find_package()") + endif () + + target_link_libraries(FX::Ds INTERFACE FX::Core) + endif () + + if ("${component}" STREQUAL "Term") + if (NOT TARGET FX::Core) + message(FATAL_ERROR "FX: Module 'Term' depends on 'Core', which was not specified in find_package()") + endif () + + if (NOT TARGET FX::Ds) + message(FATAL_ERROR "FX: Module 'Term' depends on 'Ds', which was not specified in find_package()") + endif () + + target_link_libraries(FX::Term INTERFACE FX::Core FX::Ds) + endif () + + if ("${component}" STREQUAL "Serial") + if (NOT TARGET FX::Core) + message(FATAL_ERROR "FX: Module 'Serial' depends on 'Core', which was not specified in find_package()") + endif () + + if (NOT TARGET FX::Ds) + message(FATAL_ERROR "FX: Module 'Serial' depends on 'Ds', which was not specified in find_package()") + endif () + + target_link_libraries(FX::Serial INTERFACE FX::Core FX::Ds) + endif () + + if ("${component}" STREQUAL "Cmd") + if (NOT TARGET FX::Core) + message(FATAL_ERROR "FX: Module 'Cmd' depends on 'Core', which was not specified in find_package()") + endif () + + if (NOT TARGET FX::Ds) + message(FATAL_ERROR "FX: Module 'Cmd' depends on 'Ds', which was not specified in find_package()") + endif () + + if (NOT TARGET FX::Term) + message(FATAL_ERROR "FX: Module 'Cmd' depends on 'Term', which was not specified in find_package()") + endif () + + target_link_libraries(FX::Cmd INTERFACE FX::Core FX::Ds FX::Term) + endif () + + if ("${component}" STREQUAL "Io") + if (NOT TARGET FX::Core) + message(FATAL_ERROR "FX: Module 'Io' depends on 'Core', which was not specified in find_package()") + endif () + + if (NOT TARGET FX::Ds) + message(FATAL_ERROR "FX: Module 'Io' depends on 'Ds', which was not specified in find_package()") + endif () + + target_link_libraries(FX::Io INTERFACE FX::Core FX::Ds) + endif () + + if ("${component}" STREQUAL "Compress") + if (NOT TARGET FX::Core) + message(FATAL_ERROR "FX: Module 'Compress' depends on 'Core', which was not specified in find_package()") + endif () + + target_link_libraries(FX::Compress INTERFACE FX::Core FX::Ds) + endif () + endforeach (component) +endif() diff --git a/toolchain/xpcg/CMakeLists.txt b/toolchain/xpcg/CMakeLists.txt index 3e0d24e..a2ce36a 100644 --- a/toolchain/xpcg/CMakeLists.txt +++ b/toolchain/xpcg/CMakeLists.txt @@ -4,4 +4,4 @@ file(GLOB sources add_executable(xpcg ${sources}) -target_link_libraries(xpcg Bluelib::Core Bluelib::Ds Bluelib::Cmd Bluelib::Io) +target_link_libraries(xpcg FX::Core FX::Ds FX::Cmd FX::Io) diff --git a/toolchain/xpcg/backend/c-mpc/backend.c b/toolchain/xpcg/backend/c-mpc/backend.c index 5cd32e6..a245f54 100644 --- a/toolchain/xpcg/backend/c-mpc/backend.c +++ b/toolchain/xpcg/backend/c-mpc/backend.c @@ -4,14 +4,14 @@ #include "../../msg.h" #include "../../type.h" -#include -#include -#include +#include +#include +#include #include #include struct emit_ctx { - b_stream *ctx_out; + fx_stream *ctx_out; size_t ctx_max_handle_params; }; @@ -19,23 +19,23 @@ static void emit(struct emit_ctx *ctx, const char *format, ...) { va_list arg; va_start(arg, format); - b_stream_write_vfmt(ctx->ctx_out, NULL, format, arg); + fx_stream_write_vfmt(ctx->ctx_out, NULL, format, arg); va_end(arg); } static void emit_indent(struct emit_ctx *ctx) { - b_stream_push_indent(ctx->ctx_out, 4); + fx_stream_push_indent(ctx->ctx_out, 4); } static void emit_indent_zero(struct emit_ctx *ctx) { - b_stream_push_indent(ctx->ctx_out, -100); + fx_stream_push_indent(ctx->ctx_out, -100); } static void emit_unindent(struct emit_ctx *ctx) { - b_stream_pop_indent(ctx->ctx_out); + fx_stream_pop_indent(ctx->ctx_out); } static int emit_include(struct emit_ctx *ctx, const char *path, bool system) @@ -53,15 +53,15 @@ static int emit_header_guard_start( struct emit_ctx *ctx, const struct interface_definition *iface) { - b_string *header_guard = b_string_create(); - b_string_append_cstrf(header_guard, "%s_H_", iface->if_name); - b_string_toupper(header_guard); + fx_string *header_guard = fx_string_create(); + fx_string_append_cstrf(header_guard, "%s_H_", iface->if_name); + fx_string_toupper(header_guard); emit(ctx, "#ifndef %s\n#define %s\n\n", - b_string_ptr(header_guard), - b_string_ptr(header_guard)); - b_string_unref(header_guard); + fx_string_ptr(header_guard), + fx_string_ptr(header_guard)); + fx_string_unref(header_guard); return 0; } @@ -76,15 +76,15 @@ static int emit_header_guard_end( static size_t get_msg_handle_params(const struct msg_definition *msg) { size_t count = 0; - b_queue_entry *entry = b_queue_first(&msg->msg_params); + fx_queue_entry *entry = fx_queue_first(&msg->msg_params); while (entry) { const struct msg_parameter *param - = b_unbox(struct msg_parameter, entry, p_entry); + = fx_unbox(struct msg_parameter, entry, p_entry); if (param->p_type->ty_id == TYPE_HANDLE) { count++; } - entry = b_queue_next(entry); + entry = fx_queue_next(entry); } return count; @@ -93,17 +93,17 @@ static size_t get_msg_handle_params(const struct msg_definition *msg) static size_t get_max_handle_params(const struct interface_definition *iface) { size_t count = 0; - b_queue_entry *entry = b_queue_first(&iface->if_msg); + fx_queue_entry *entry = fx_queue_first(&iface->if_msg); while (entry) { const struct msg_definition *msg - = b_unbox(struct msg_definition, entry, msg_entry); + = fx_unbox(struct msg_definition, entry, msg_entry); size_t msg_count = get_msg_handle_params(msg); if (msg_count > count) { count = msg_count; } - entry = b_queue_next(entry); + entry = fx_queue_next(entry); } return count; @@ -113,51 +113,51 @@ static int emit_interface_id_macros( struct emit_ctx *ctx, const struct interface_definition *iface) { - b_string *iface_define_name = b_string_create(); - b_string_append_cstr(iface_define_name, iface->if_name); - b_string_toupper(iface_define_name); + fx_string *iface_define_name = fx_string_create(); + fx_string_append_cstr(iface_define_name, iface->if_name); + fx_string_toupper(iface_define_name); uint32_t protocol_id = iface->if_id; emit(ctx, "/* %s protocol ID */\n#define INTERFACE_%s 0x%08xU\n\n", iface->if_name, - b_string_ptr(iface_define_name), + fx_string_ptr(iface_define_name), protocol_id); - b_string_unref(iface_define_name); + fx_string_unref(iface_define_name); - b_string *msg_name = b_string_create(); - b_queue_entry *entry = b_queue_first(&iface->if_msg); + fx_string *msg_name = fx_string_create(); + fx_queue_entry *entry = fx_queue_first(&iface->if_msg); while (entry) { const struct msg_definition *msg - = b_unbox(struct msg_definition, entry, msg_entry); - b_string_clear(msg_name); - b_string_append_cstrf( + = fx_unbox(struct msg_definition, entry, msg_entry); + fx_string_clear(msg_name); + fx_string_append_cstrf( msg_name, "%s.%s", iface->if_name, msg->msg_name); - emit(ctx, "/* %s message ID */\n", b_string_ptr(msg_name)); + emit(ctx, "/* %s message ID */\n", fx_string_ptr(msg_name)); uint16_t msg_id = msg->msg_id; - b_string_clear(msg_name); - b_string_append_cstrf( + fx_string_clear(msg_name); + fx_string_append_cstrf( msg_name, "%s_%s", iface->if_name, msg->msg_name); - b_string_toupper(msg_name); + fx_string_toupper(msg_name); emit(ctx, "#define MSG_%s 0x%04xU\n", - b_string_ptr(msg_name), + fx_string_ptr(msg_name), msg_id); - entry = b_queue_next(entry); + entry = fx_queue_next(entry); } emit(ctx, "\n"); - b_string_unref(msg_name); + fx_string_unref(msg_name); return 0; } @@ -181,8 +181,7 @@ static int emit_msg_struct_member( break; case TYPE_STRING: case TYPE_BUFFER: - emit(ctx, "uint16_t %s_offset;\n", param->p_name); - emit(ctx, "uint16_t %s_len;\n", param->p_name); + emit(ctx, "uint32_t %s_len;\n", param->p_name); break; default: break; @@ -195,33 +194,41 @@ static int emit_msg_struct_params( struct emit_ctx *ctx, const struct msg_definition *msg) { - b_queue_entry *entry = b_queue_first(&msg->msg_params); + fx_queue_entry *entry = fx_queue_first(&msg->msg_params); while (entry) { const struct msg_parameter *param - = b_unbox(struct msg_parameter, entry, p_entry); + = fx_unbox(struct msg_parameter, entry, p_entry); + switch (param->p_type->ty_id) { + case TYPE_STRING: + case TYPE_BUFFER: + emit(ctx, "uint32_t %s_offset;\n", param->p_name); + break; + default: + break; + } emit_msg_struct_member(ctx, param); - 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) { const struct msg_parameter *param - = b_unbox(struct msg_parameter, entry, p_entry); + = fx_unbox(struct msg_parameter, entry, p_entry); switch (param->p_type->ty_id) { case TYPE_STRING: - emit(ctx, "uint16_t %s_offset;\n", param->p_name); - emit(ctx, "uint16_t %s_max;\n", param->p_name); + emit(ctx, "uint32_t %s_offset;\n", param->p_name); + emit(ctx, "uint32_t %s_max;\n", param->p_name); break; case TYPE_BUFFER: - emit(ctx, "uint16_t %s_offset;\n", param->p_name); + emit(ctx, "uint32_t %s_offset;\n", param->p_name); emit(ctx, "uint32_t %s_max;\n", param->p_name); break; default: break; } - entry = b_queue_next(entry); + entry = fx_queue_next(entry); } return 0; @@ -231,12 +238,13 @@ static int emit_msg_struct_results( struct emit_ctx *ctx, const struct msg_definition *msg) { - b_queue_entry *entry = b_queue_first(&msg->msg_results); + fx_queue_entry *entry = fx_queue_first(&msg->msg_results); while (entry) { const struct msg_parameter *param - = b_unbox(struct msg_parameter, entry, p_entry); + = fx_unbox(struct msg_parameter, entry, p_entry); + emit_msg_struct_member(ctx, param); - entry = b_queue_next(entry); + entry = fx_queue_next(entry); } return 0; @@ -247,7 +255,7 @@ static int emit_interface_msg_struct( const struct interface_definition *iface, const struct msg_definition *msg) { - b_string *tmp = b_string_create(); + fx_string *tmp = fx_string_create(); emit(ctx, "struct %s_%s_msg {\n", iface->if_name, msg->msg_name); emit_indent(ctx); @@ -280,7 +288,7 @@ static int emit_interface_msg_struct( emit_unindent(ctx); emit(ctx, "};\n"); - b_string_unref(tmp); + fx_string_unref(tmp); return 0; } @@ -288,14 +296,14 @@ static int emit_interface_msg_structs( struct emit_ctx *ctx, const struct interface_definition *iface) { - b_queue_entry *entry = b_queue_first(&iface->if_msg); + fx_queue_entry *entry = fx_queue_first(&iface->if_msg); while (entry) { const struct msg_definition *msg - = b_unbox(struct msg_definition, entry, msg_entry); + = fx_unbox(struct msg_definition, entry, msg_entry); emit_interface_msg_struct(ctx, iface, msg); - entry = b_queue_next(entry); + entry = fx_queue_next(entry); } emit(ctx, "\n"); @@ -307,10 +315,10 @@ static int emit_interface_msg_function_send_impl( const struct interface_definition *iface, const struct msg_definition *msg) { - b_string *iface_ucase = b_string_create_from_cstr(iface->if_name); - b_string_toupper(iface_ucase); - b_string *msg_ucase = b_string_create_from_cstr(msg->msg_name); - b_string_toupper(msg_ucase); + fx_string *iface_ucase = fx_string_create_from_cstr(iface->if_name); + fx_string_toupper(iface_ucase); + fx_string *msg_ucase = fx_string_create_from_cstr(msg->msg_name); + fx_string_toupper(msg_ucase); emit(ctx, "struct %s_%s_msg msg_data = {0};\n", @@ -319,12 +327,12 @@ static int emit_interface_msg_function_send_impl( emit(ctx, "xpc_msg_header_init(&msg_data.msg_header, INTERFACE_%s, " "MSG_%s_%s);\n", - b_string_ptr(iface_ucase), - b_string_ptr(iface_ucase), - b_string_ptr(msg_ucase)); + fx_string_ptr(iface_ucase), + fx_string_ptr(iface_ucase), + fx_string_ptr(msg_ucase)); - b_string_unref(iface_ucase); - b_string_unref(msg_ucase); + fx_string_unref(iface_ucase); + fx_string_unref(msg_ucase); emit(ctx, "uint32_t in_offset = sizeof msg_data;\n\n"); emit(ctx, "uint32_t out_offset = sizeof msg_data;\n\n"); @@ -332,10 +340,10 @@ static int emit_interface_msg_function_send_impl( size_t nr_req_handles = 0; size_t nr_resp_handles = 0; - 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); switch (param->p_type->ty_id) { case TYPE_INT: case TYPE_SIZE: @@ -380,13 +388,13 @@ static int emit_interface_msg_function_send_impl( break; } - 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); switch (param->p_type->ty_id) { case TYPE_STRING: case TYPE_BUFFER: @@ -407,7 +415,7 @@ static int emit_interface_msg_function_send_impl( break; } - entry = b_queue_next(entry); + entry = fx_queue_next(entry); } emit(ctx, "kern_iovec_t req_iov[] = {\n"); @@ -415,10 +423,10 @@ static int emit_interface_msg_function_send_impl( emit(ctx, "IOVEC(&msg_data, sizeof msg_data),\n"); size_t nr_req_iov = 1; - entry = b_queue_first(&msg->msg_params); + 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); switch (param->p_type->ty_id) { case TYPE_STRING: @@ -433,7 +441,7 @@ static int emit_interface_msg_function_send_impl( break; } - entry = b_queue_next(entry); + entry = fx_queue_next(entry); } emit_unindent(ctx); @@ -450,10 +458,10 @@ static int emit_interface_msg_function_send_impl( emit(ctx, "IOVEC(&msg_data, sizeof msg_data),\n"); size_t nr_resp_iov = 1; - 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); switch (param->p_type->ty_id) { case TYPE_STRING: @@ -468,7 +476,7 @@ static int emit_interface_msg_function_send_impl( break; } - entry = b_queue_next(entry); + entry = fx_queue_next(entry); } emit_unindent(ctx); @@ -515,10 +523,10 @@ static int emit_interface_msg_function_send_impl( "if (msg_data.msg_header.hdr_status != KERN_OK) return " "msg_data.msg_header.hdr_status;\n\n"); - 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); switch (param->p_type->ty_id) { case TYPE_HANDLE: emit(ctx, "*out_%s = ", param->p_name); @@ -544,7 +552,7 @@ static int emit_interface_msg_function_send_impl( break; } - entry = b_queue_next(entry); + entry = fx_queue_next(entry); } emit(ctx, "return status;\n"); @@ -567,10 +575,10 @@ static int emit_interface_msg_function_send( emit(ctx, "kern_handle_t port"); - 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); emit(ctx, ",\n"); switch (param->p_type->ty_id) { case TYPE_INT: @@ -596,13 +604,13 @@ static int emit_interface_msg_function_send( default: break; } - 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); emit(ctx, ",\n"); switch (param->p_type->ty_id) { case TYPE_INT: @@ -632,7 +640,7 @@ static int emit_interface_msg_function_send( default: break; } - entry = b_queue_next(entry); + entry = fx_queue_next(entry); } emit(ctx, ")"); @@ -673,10 +681,10 @@ static int emit_interface_dispatcher_impl_msg( "status = xpc_msg_read(msg, 0, &" MSG_STRUCT_NAME ", sizeof " MSG_STRUCT_NAME ");\n"); - 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); switch (param->p_type->ty_id) { case TYPE_INT: emit(ctx, @@ -721,13 +729,13 @@ static int emit_interface_dispatcher_impl_msg( break; } - 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); switch (param->p_type->ty_id) { case TYPE_INT: emit(ctx, "int %s = 0;\n", param->p_name); @@ -767,16 +775,16 @@ static int emit_interface_dispatcher_impl_msg( break; } - entry = b_queue_next(entry); + entry = fx_queue_next(entry); } emit(ctx, "status = vtable->%s(\n", msg->msg_name); emit_indent(ctx); emit(ctx, "ctx,\n&msg->msg_sender"); - entry = b_queue_first(&msg->msg_params); + 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); switch (param->p_type->ty_id) { case TYPE_STRING: @@ -788,15 +796,15 @@ static int emit_interface_dispatcher_impl_msg( break; } - 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); emit(ctx, ",\n&%s", param->p_name); - entry = b_queue_next(entry); + entry = fx_queue_next(entry); } emit(ctx, ",\narg);\n"); @@ -808,12 +816,13 @@ static int emit_interface_dispatcher_impl_msg( emit(ctx, MSG_STRUCT_NAME ".msg_header.hdr_status = 0;\n"); size_t handle_index = 0; - 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); switch (param->p_type->ty_id) { case TYPE_INT: + case TYPE_SIZE: case TYPE_OFFSET: emit(ctx, MSG_STRUCT_NAME ".msg_response.%s = %s;\n", @@ -831,7 +840,7 @@ static int emit_interface_dispatcher_impl_msg( break; } - entry = b_queue_next(entry); + entry = fx_queue_next(entry); } emit(ctx, @@ -840,10 +849,10 @@ static int emit_interface_dispatcher_impl_msg( emit(ctx, "kern_msg_handle_t out_handles[] = {\n"); emit_indent(ctx); - 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); switch (param->p_type->ty_id) { case TYPE_HANDLE: emit(ctx, @@ -854,7 +863,7 @@ static int emit_interface_dispatcher_impl_msg( break; } - entry = b_queue_next(entry); + entry = fx_queue_next(entry); } emit_unindent(ctx); emit(ctx, "};\n"); @@ -870,41 +879,41 @@ static int emit_interface_dispatcher_impl( struct emit_ctx *ctx, const struct interface_definition *iface) { - b_string *iface_ucase = b_string_create_from_cstr(iface->if_name); - b_string_toupper(iface_ucase); - b_string *msg_ucase = b_string_create(); + fx_string *iface_ucase = fx_string_create_from_cstr(iface->if_name); + fx_string_toupper(iface_ucase); + fx_string *msg_ucase = fx_string_create(); emit(ctx, "if (msg->msg_header.hdr_interface != INTERFACE_%s) return " "KERN_INVALID_ARGUMENT;\n\n", - b_string_ptr(iface_ucase)); + fx_string_ptr(iface_ucase)); emit(ctx, "kern_status_t status = KERN_OK;\n"); emit(ctx, "switch (msg->msg_header.hdr_func) {\n"); - b_queue_entry *entry = b_queue_first(&iface->if_msg); + fx_queue_entry *entry = fx_queue_first(&iface->if_msg); while (entry) { const struct msg_definition *msg - = b_unbox(struct msg_definition, entry, msg_entry); + = fx_unbox(struct msg_definition, entry, msg_entry); - b_string_clear(msg_ucase); - b_string_append_cstr(msg_ucase, msg->msg_name); - b_string_toupper(msg_ucase); + fx_string_clear(msg_ucase); + fx_string_append_cstr(msg_ucase, msg->msg_name); + fx_string_toupper(msg_ucase); emit(ctx, "case MSG_%s_%s: {\n", - b_string_ptr(iface_ucase), - b_string_ptr(msg_ucase)); + fx_string_ptr(iface_ucase), + fx_string_ptr(msg_ucase)); emit_indent(ctx); emit_interface_dispatcher_impl_msg(ctx, iface, msg); emit(ctx, "break;\n"); emit_unindent(ctx); emit(ctx, "}\n"); - entry = b_queue_next(entry); + entry = fx_queue_next(entry); } - b_string_unref(iface_ucase); + fx_string_unref(iface_ucase); emit(ctx, "default:\n"); emit_indent(ctx); @@ -953,10 +962,10 @@ static int emit_interface_functions( const struct interface_definition *iface, bool prototype_only) { - b_queue_entry *entry = b_queue_first(&iface->if_msg); + fx_queue_entry *entry = fx_queue_first(&iface->if_msg); while (entry) { const struct msg_definition *msg - = b_unbox(struct msg_definition, entry, msg_entry); + = fx_unbox(struct msg_definition, entry, msg_entry); emit_interface_msg_function_send( ctx, @@ -964,7 +973,7 @@ static int emit_interface_functions( msg, prototype_only); - entry = b_queue_next(entry); + entry = fx_queue_next(entry); } emit_interface_dispatcher(ctx, iface, prototype_only); @@ -983,10 +992,10 @@ static int emit_interface_vtable_entry( emit(ctx, "const xpc_endpoint_t *sender"); size_t i = 0; - 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); emit(ctx, ",\n"); switch (param->p_type->ty_id) { @@ -1013,13 +1022,13 @@ static int emit_interface_vtable_entry( } i++; - 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); emit(ctx, ",\n"); switch (param->p_type->ty_id) { @@ -1046,7 +1055,7 @@ static int emit_interface_vtable_entry( } i++; - entry = b_queue_next(entry); + entry = fx_queue_next(entry); } if (i > 0) { @@ -1068,14 +1077,14 @@ static int emit_interface_vtable( emit(ctx, "struct %s_vtable {\n", iface->if_name); emit_indent(ctx); - b_queue_entry *entry = b_queue_first(&iface->if_msg); + fx_queue_entry *entry = fx_queue_first(&iface->if_msg); while (entry) { const struct msg_definition *msg - = b_unbox(struct msg_definition, entry, msg_entry); + = fx_unbox(struct msg_definition, entry, msg_entry); emit_interface_vtable_entry(ctx, iface, msg); - entry = b_queue_next(entry); + entry = fx_queue_next(entry); } emit_unindent(ctx); @@ -1118,16 +1127,16 @@ static int emit_header( static int emit_interface(const struct interface_definition *iface) { char path[4096]; - b_file *file = NULL; + fx_file *file = NULL; snprintf(path, sizeof path, "%s.h", iface->if_name); - b_result result = b_file_open( + fx_result result = fx_file_open( NULL, - B_RV_PATH(path), - B_FILE_WRITE_ONLY | B_FILE_CREATE | B_FILE_TRUNCATE, + FX_RV_PATH(path), + FX_FILE_WRITE_ONLY | FX_FILE_CREATE | FX_FILE_TRUNCATE, &file); - if (b_result_is_error(result)) { - b_throw(result); + if (fx_result_is_error(result)) { + fx_throw(result); fprintf(stderr, "cannot create C header file %s\n", path); return -1; } @@ -1138,7 +1147,7 @@ static int emit_interface(const struct interface_definition *iface) }; int err = emit_header(&ctx, iface); - b_file_unref(file); + fx_file_unref(file); return err; } diff --git a/toolchain/xpcg/interface.c b/toolchain/xpcg/interface.c index 8db9cc3..a721b12 100644 --- a/toolchain/xpcg/interface.c +++ b/toolchain/xpcg/interface.c @@ -2,7 +2,7 @@ #include "msg.h" -#include +#include #include #include @@ -17,7 +17,7 @@ struct interface_definition *interface_definition_create( memset(out, 0x0, sizeof *out); - out->if_name = b_strdup(name); + out->if_name = fx_strdup(name); out->if_id = id; return out; @@ -25,12 +25,12 @@ struct interface_definition *interface_definition_create( void interface_definition_destroy(struct interface_definition *iface) { - b_queue_entry *entry = b_queue_pop_front(&iface->if_msg); + fx_queue_entry *entry = fx_queue_pop_front(&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); msg_definition_destroy(msg); - entry = b_queue_pop_front(&iface->if_msg); + entry = fx_queue_pop_front(&iface->if_msg); } free(iface->if_name); @@ -41,15 +41,15 @@ bool interface_definition_has_msg( const struct interface_definition *iface, const char *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); if (!strcmp(msg->msg_name, name)) { return true; } - entry = b_queue_next(entry); + entry = fx_queue_next(entry); } return false; @@ -59,5 +59,5 @@ void interface_definition_add_msg( struct interface_definition *iface, struct msg_definition *msg) { - b_queue_push_back(&iface->if_msg, &msg->msg_entry); + fx_queue_push_back(&iface->if_msg, &msg->msg_entry); } diff --git a/toolchain/xpcg/interface.h b/toolchain/xpcg/interface.h index 8692a94..3601760 100644 --- a/toolchain/xpcg/interface.h +++ b/toolchain/xpcg/interface.h @@ -1,14 +1,14 @@ #ifndef XPCG_INTERFACE_H_ #define XPCG_INTERFACE_H_ -#include +#include struct msg_definition; struct interface_definition { char *if_name; long long if_id; - b_queue if_msg; + fx_queue if_msg; }; extern struct interface_definition *interface_definition_create( diff --git a/toolchain/xpcg/lex.c b/toolchain/xpcg/lex.c index fb781cf..e4be86d 100644 --- a/toolchain/xpcg/lex.c +++ b/toolchain/xpcg/lex.c @@ -3,12 +3,12 @@ #include "line-source.h" #include "token.h" -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include #include #include #include @@ -21,10 +21,10 @@ #define LEX_TOKEN_DEF(i, n) {.id = (i), .name = (n)} #define IS_VALID_IDENT_CHAR(c) \ - (b_wchar_is_alnum(c) || c == '.' || c == '-' || c == '_') + (fx_wchar_is_alnum(c) || c == '.' || c == '-' || c == '_') #define IS_VALID_IDENT_START_CHAR(c) \ - (b_wchar_is_alpha(c) || c == '.' || c == '_') -#define IS_VALID_REG_START_CHAR(c) (b_wchar_is_alnum(c) || c == '.' || c == '_') + (fx_wchar_is_alpha(c) || c == '.' || c == '_') +#define IS_VALID_REG_START_CHAR(c) (fx_wchar_is_alnum(c) || c == '.' || c == '_') static struct lex_token_def symbols[] = { LEX_TOKEN_DEF(SYM_COMMA, ","), @@ -51,27 +51,27 @@ static struct lex_symbol_node *get_symbol_node( struct lex_symbol_node *node, char c) { - b_queue_entry *entry = b_queue_first(&node->s_children); + fx_queue_entry *entry = fx_queue_first(&node->s_children); while (entry) { struct lex_symbol_node *child - = b_unbox(struct lex_symbol_node, entry, s_entry); + = fx_unbox(struct lex_symbol_node, entry, s_entry); if (child->s_char == c) { return child; } - entry = b_queue_next(entry); + entry = fx_queue_next(entry); } return NULL; } -static b_string *get_temp_string(struct lex *lex) +static fx_string *get_temp_string(struct lex *lex) { if (!lex->lex_temp) { - lex->lex_temp = b_string_create(); + lex->lex_temp = fx_string_create(); } - b_string_clear(lex->lex_temp); + fx_string_clear(lex->lex_temp); return lex->lex_temp; } @@ -97,7 +97,7 @@ static enum status put_symbol( child->s_def = NULL; child->s_char = c; - b_queue_push_back(&tree->s_children, &child->s_entry); + fx_queue_push_back(&tree->s_children, &child->s_entry); tree = child; } @@ -107,12 +107,12 @@ static enum status put_symbol( static void destroy_symbol_tree(struct lex_symbol_node *tree) { - b_queue_entry *entry = b_queue_first(&tree->s_children); + fx_queue_entry *entry = fx_queue_first(&tree->s_children); while (entry) { struct lex_symbol_node *node - = b_unbox(struct lex_symbol_node, entry, s_entry); - b_queue_entry *next = b_queue_next(entry); - b_queue_delete(&tree->s_children, entry); + = fx_unbox(struct lex_symbol_node, entry, s_entry); + fx_queue_entry *next = fx_queue_next(entry); + fx_queue_delete(&tree->s_children, entry); destroy_symbol_tree(node); @@ -168,12 +168,12 @@ struct lex *lex_create(struct line_source *src) void lex_destroy(struct lex *lex) { - b_queue_entry *entry = b_queue_first(&lex->lex_queue); + fx_queue_entry *entry = fx_queue_first(&lex->lex_queue); while (entry) { - struct token *tok = b_unbox(struct token, entry, tok_entry); - b_queue_entry *next = b_queue_next(entry); - b_queue_delete(&lex->lex_queue, entry); + struct token *tok = fx_unbox(struct token, entry, tok_entry); + fx_queue_entry *next = fx_queue_next(entry); + fx_queue_delete(&lex->lex_queue, entry); token_destroy(tok); @@ -185,7 +185,7 @@ void lex_destroy(struct lex *lex) } if (lex->lex_temp) { - b_string_unref(lex->lex_temp); + fx_string_unref(lex->lex_temp); } free(lex); @@ -245,7 +245,7 @@ static enum status push_token(struct lex *lex, struct token *tok) tok->tok_location.s_start = lex->lex_token_start; tok->tok_location.s_end = lex->lex_token_end; - b_queue_push_back(&lex->lex_queue, &tok->tok_entry); + fx_queue_push_back(&lex->lex_queue, &tok->tok_entry); return SUCCESS; } @@ -326,7 +326,7 @@ static enum status push_int(struct lex *lex, unsigned long long v) static enum status read_line_comment(struct lex *lex) { while (true) { - b_wchar c = line_source_getc(lex->lex_source); + fx_wchar c = line_source_getc(lex->lex_source); if (c == -ERR_EOF || c == '\n') { break; @@ -345,14 +345,14 @@ static enum status read_number(struct lex *lex, bool negate) int token_len = 0; int base = 10; int dots = 0; - b_string *str = get_temp_string(lex); + fx_string *str = get_temp_string(lex); if (!negate) { set_token_start(lex); } while (true) { - b_wchar c = line_source_peekc(lex->lex_source); + fx_wchar c = line_source_peekc(lex->lex_source); if (c == -ERR_EOF) { break; } @@ -372,7 +372,7 @@ static enum status read_number(struct lex *lex, bool negate) return ERR_BAD_SYNTAX; } - if (b_wchar_is_space(c) || b_wchar_is_punct(c)) { + if (fx_wchar_is_space(c) || fx_wchar_is_punct(c)) { break; } @@ -404,7 +404,7 @@ static enum status read_number(struct lex *lex, bool negate) return ERR_BAD_SYNTAX; } - b_string_append_wc(str, c); + fx_string_append_wc(str, c); set_token_end(lex); line_source_getc(lex->lex_source); token_len++; @@ -414,7 +414,7 @@ static enum status read_number(struct lex *lex, bool negate) return push_int(lex, 0); } - const char *s = b_string_ptr(str); + const char *s = fx_string_ptr(str); char *ep = NULL; /* negative numbers will be lexed as a hyphen followed by a positive @@ -447,15 +447,15 @@ static enum token_keyword find_keyword(const char *s) static enum status read_ident(struct lex *lex, enum token_type type) { int dots = 0; - b_string *str = get_temp_string(lex); - b_wchar prev = 0; + fx_string *str = get_temp_string(lex); + fx_wchar prev = 0; if (type == TOK_NONE) { set_token_start(lex); } while (1) { - b_wchar c = line_source_peekc(lex->lex_source); + fx_wchar c = line_source_peekc(lex->lex_source); if ((c == '.' || c == '-') && prev == c) { return ERR_BAD_SYNTAX; @@ -470,7 +470,7 @@ static enum status read_ident(struct lex *lex, enum token_type type) } prev = c; - b_string_append_wc(str, c); + fx_string_append_wc(str, c); set_token_end(lex); line_source_getc(lex->lex_source); } @@ -479,7 +479,7 @@ static enum status read_ident(struct lex *lex, enum token_type type) type = dots > 0 ? TOK_NAME : TOK_WORD; } - char *s = b_string_steal(str); + char *s = fx_string_steal(str); enum token_keyword kw = find_keyword(s); if (kw != KW_NONE) { free(s); @@ -491,9 +491,9 @@ static enum status read_ident(struct lex *lex, enum token_type type) static enum status read_string(struct lex *lex) { - b_string *str = get_temp_string(lex); + fx_string *str = get_temp_string(lex); - b_wchar c = line_source_peekc(lex->lex_source); + fx_wchar c = line_source_peekc(lex->lex_source); bool esc = false; if (c != '"') { @@ -503,13 +503,13 @@ static enum status read_string(struct lex *lex) line_source_getc(lex->lex_source); while (1) { - b_wchar c = line_source_peekc(lex->lex_source); + fx_wchar c = line_source_peekc(lex->lex_source); if (esc) { switch (c) { case '\\': case '"': - b_string_append_wc(str, c); + fx_string_append_wc(str, c); break; default: return ERR_BAD_SYNTAX; @@ -531,11 +531,11 @@ static enum status read_string(struct lex *lex) break; } - b_string_append_wc(str, c); + fx_string_append_wc(str, c); line_source_getc(lex->lex_source); } - char *s = b_string_steal(str); + char *s = fx_string_steal(str); return push_string_token(lex, TOK_STRING, s); } @@ -543,10 +543,10 @@ static enum status read_symbol(struct lex *lex) { struct lex_symbol_node *node = lex->lex_sym_tree; set_token_start(lex); - b_wchar prev = 0; + fx_wchar prev = 0; while (true) { - b_wchar c = line_source_peekc(lex->lex_source); + fx_wchar c = line_source_peekc(lex->lex_source); if (c < 0) { break; } @@ -576,17 +576,17 @@ static enum status read_symbol(struct lex *lex) static void skip_whitespace(struct lex *lex) { - b_wchar c = line_source_peekc(lex->lex_source); + fx_wchar c = line_source_peekc(lex->lex_source); - while (b_wchar_is_space(c)) { + while (fx_wchar_is_space(c)) { line_source_getc(lex->lex_source); c = line_source_peekc(lex->lex_source); } } -static bool should_skip(b_wchar c, bool skip_linefeeds) +static bool should_skip(fx_wchar c, bool skip_linefeeds) { - bool skip = b_wchar_is_space(c); + bool skip = fx_wchar_is_space(c); if (!skip_linefeeds) { skip = (skip && c != '\n'); @@ -597,7 +597,7 @@ static bool should_skip(b_wchar c, bool skip_linefeeds) static void skip_ignored_chars(struct lex *lex, bool include_linefeeds) { - b_wchar c = line_source_peekc(lex->lex_source); + fx_wchar c = line_source_peekc(lex->lex_source); while (1) { while (should_skip(c, include_linefeeds)) { @@ -624,14 +624,14 @@ static void skip_ignored_chars(struct lex *lex, bool include_linefeeds) static enum status pump_tokens(struct lex *lex) { - b_wchar c = line_source_peekc(lex->lex_source); + fx_wchar c = line_source_peekc(lex->lex_source); if (c < 0) { return -c; } while (1) { - if (c == '#' || (b_wchar_is_space(c) && c != '\n')) { + if (c == '#' || (fx_wchar_is_space(c) && c != '\n')) { skip_ignored_chars(lex, false); } else { break; @@ -667,7 +667,7 @@ static enum status pump_tokens(struct lex *lex) return SUCCESS; } - while (b_wchar_is_space(c) && c != '\n') { + while (fx_wchar_is_space(c) && c != '\n') { line_source_getc(lex->lex_source); c = line_source_peekc(lex->lex_source); } @@ -695,7 +695,7 @@ struct token *lex_peek(struct lex *lex) { enum status status = SUCCESS; - while (b_queue_empty(&lex->lex_queue)) { + while (fx_queue_empty(&lex->lex_queue)) { status = pump_tokens(lex); if (status != SUCCESS) { @@ -706,8 +706,8 @@ struct token *lex_peek(struct lex *lex) lex->lex_status = status; - b_queue_entry *entry = b_queue_first(&lex->lex_queue); - struct token *tok = b_unbox(struct token, entry, tok_entry); + fx_queue_entry *entry = fx_queue_first(&lex->lex_queue); + struct token *tok = fx_unbox(struct token, entry, tok_entry); return tok; } @@ -715,7 +715,7 @@ void lex_advance(struct lex *lex) { enum status status = SUCCESS; - while (b_queue_empty(&lex->lex_queue)) { + while (fx_queue_empty(&lex->lex_queue)) { status = pump_tokens(lex); if (status != SUCCESS) { @@ -724,14 +724,14 @@ void lex_advance(struct lex *lex) } } - b_queue_entry *entry = b_queue_pop_front(&lex->lex_queue); - struct token *tok = b_unbox(struct token, entry, tok_entry); + fx_queue_entry *entry = fx_queue_pop_front(&lex->lex_queue); + struct token *tok = fx_unbox(struct token, entry, tok_entry); token_destroy(tok); } bool lex_tokens_available(struct lex *lex) { - if (!b_queue_empty(&lex->lex_queue)) { + if (!fx_queue_empty(&lex->lex_queue)) { return true; } diff --git a/toolchain/xpcg/lex.h b/toolchain/xpcg/lex.h index 7a0ad82..53cca1a 100644 --- a/toolchain/xpcg/lex.h +++ b/toolchain/xpcg/lex.h @@ -4,9 +4,9 @@ #include "status.h" #include "token.h" -#include -#include -#include +#include +#include +#include #include struct lex { @@ -14,10 +14,10 @@ struct lex { struct line_source *lex_source; enum status lex_status; - b_queue lex_queue; + fx_queue lex_queue; - b_string *lex_temp; - b_queue lex_state; + fx_string *lex_temp; + fx_queue lex_state; unsigned int lex_brace_depth; struct file_cell lex_token_start, lex_token_end; @@ -27,8 +27,8 @@ struct lex_symbol_node { char s_char; struct lex_token_def *s_def; - b_queue_entry s_entry; - b_queue s_children; + fx_queue_entry s_entry; + fx_queue s_children; }; struct lex_token_def { diff --git a/toolchain/xpcg/line-source.c b/toolchain/xpcg/line-source.c index 865bc39..9e13f4b 100644 --- a/toolchain/xpcg/line-source.c +++ b/toolchain/xpcg/line-source.c @@ -3,11 +3,11 @@ enum status line_source_init( struct line_source *src, const char *path, - b_stream *stream) + fx_stream *stream) { memset(src, 0x0, sizeof *src); - src->s_lines = b_array_create(); + src->s_lines = fx_array_create(); if (!src->s_lines) { return ERR_NO_MEMORY; @@ -24,11 +24,11 @@ enum status line_source_init( void line_source_cleanup(struct line_source *src) { if (src->s_linebuf_ptr) { - b_iterator_unref(src->s_linebuf_ptr); + fx_iterator_unref(src->s_linebuf_ptr); } if (src->s_lines) { - b_array_unref(src->s_lines); + fx_array_unref(src->s_lines); } memset(src, 0x0, sizeof *src); @@ -51,31 +51,31 @@ static enum status refill_linebuf(struct line_source *src) } if (src->s_linebuf_ptr) { - b_iterator_unref(src->s_linebuf_ptr); + fx_iterator_unref(src->s_linebuf_ptr); src->s_linebuf_ptr = NULL; } - b_stringstream *s = b_stringstream_create(); + fx_stringstream *s = fx_stringstream_create(); - b_status status = b_stream_read_line_s(src->s_stream, s); + fx_status status = fx_stream_read_line_s(src->s_stream, s); - if (status == B_ERR_NO_DATA) { + if (status == FX_ERR_NO_DATA) { return ERR_EOF; } - if (!B_OK(status)) { + if (!FX_OK(status)) { return ERR_INTERNAL_FAILURE; } - b_string *line = b_string_create(); - b_string_replace_all_with_stringstream(line, s); - b_stringstream_unref(s); + fx_string *line = fx_string_create(); + fx_string_replace_all_with_stringstream(line, s); + fx_stringstream_unref(s); - b_array_append(src->s_lines, line); - b_string_unref(line); + fx_array_append(src->s_lines, line); + fx_string_unref(line); src->s_linebuf = line; - src->s_linebuf_ptr = b_iterator_begin(src->s_linebuf); + src->s_linebuf_ptr = fx_iterator_begin(src->s_linebuf); return SUCCESS; } @@ -84,7 +84,7 @@ static int peek(struct line_source *src) { enum status status = SUCCESS; - if (!src->s_linebuf_ptr || !b_iterator_is_valid(src->s_linebuf_ptr)) { + if (!src->s_linebuf_ptr || !fx_iterator_is_valid(src->s_linebuf_ptr)) { status = refill_linebuf(src); } @@ -92,11 +92,11 @@ static int peek(struct line_source *src) return -status; } - if (b_string_get_size(src->s_linebuf, B_STRLEN_NORMAL) == 0) { + if (fx_string_get_size(src->s_linebuf, FX_STRLEN_NORMAL) == 0) { return -ERR_EOF; } - b_wchar c = b_iterator_get_value(src->s_linebuf_ptr).v_int; + fx_wchar c = fx_iterator_get_value(src->s_linebuf_ptr).v_int; return c; } @@ -104,7 +104,7 @@ static int advance(struct line_source *src) { enum status status = SUCCESS; - if (!b_iterator_is_valid(src->s_linebuf_ptr)) { + if (!fx_iterator_is_valid(src->s_linebuf_ptr)) { status = refill_linebuf(src); } @@ -112,12 +112,12 @@ static int advance(struct line_source *src) return -status; } - if (b_string_get_size(src->s_linebuf, B_STRLEN_NORMAL) == 0) { + if (fx_string_get_size(src->s_linebuf, FX_STRLEN_NORMAL) == 0) { return -ERR_EOF; } - b_wchar c = b_iterator_get_value(src->s_linebuf_ptr).v_int; - b_iterator_move_next(src->s_linebuf_ptr); + fx_wchar c = fx_iterator_get_value(src->s_linebuf_ptr).v_int; + fx_iterator_move_next(src->s_linebuf_ptr); src->s_cursor.c_col++; if (c == '\n') { @@ -127,12 +127,12 @@ static int advance(struct line_source *src) return c; } -b_wchar line_source_peekc(struct line_source *src) +fx_wchar line_source_peekc(struct line_source *src) { return peek(src); } -b_wchar line_source_getc(struct line_source *src) +fx_wchar line_source_getc(struct line_source *src) { return advance(src); } @@ -140,7 +140,7 @@ b_wchar line_source_getc(struct line_source *src) enum status line_source_get_row( struct line_source *src, size_t row, - const b_string **out) + const fx_string **out) { if (row == 0) { return ERR_INVALID_ARGUMENT; @@ -148,11 +148,11 @@ enum status line_source_get_row( row--; - if (row >= b_array_size(src->s_lines)) { + if (row >= fx_array_size(src->s_lines)) { return ERR_EOF; } - b_string *line = b_array_at(src->s_lines, row); + fx_string *line = fx_array_at(src->s_lines, row); *out = line; return SUCCESS; @@ -160,5 +160,5 @@ enum status line_source_get_row( bool line_source_input_available(struct line_source *src) { - return src->s_linebuf_ptr && b_iterator_is_valid(src->s_linebuf_ptr); + return src->s_linebuf_ptr && fx_iterator_is_valid(src->s_linebuf_ptr); } diff --git a/toolchain/xpcg/line-source.h b/toolchain/xpcg/line-source.h index d0f9fc7..9202b1f 100644 --- a/toolchain/xpcg/line-source.h +++ b/toolchain/xpcg/line-source.h @@ -4,16 +4,16 @@ #include "file-span.h" #include "status.h" -#include -#include -#include +#include +#include +#include struct line_source { - b_stream *s_stream; + fx_stream *s_stream; const char *s_path; - b_string *s_linebuf; - b_iterator *s_linebuf_ptr; - b_array *s_lines; + fx_string *s_linebuf; + fx_iterator *s_linebuf_ptr; + fx_array *s_lines; struct file_cell s_cursor; }; @@ -21,18 +21,18 @@ struct line_source { extern enum status line_source_init( struct line_source *src, const char *path, - b_stream *stream); + fx_stream *stream); extern void line_source_cleanup(struct line_source *src); extern const char *line_source_get_path(const struct line_source *src); extern const struct file_cell *line_source_get_cursor( const struct line_source *src); -extern b_wchar line_source_peekc(struct line_source *src); -extern b_wchar line_source_getc(struct line_source *src); +extern fx_wchar line_source_peekc(struct line_source *src); +extern fx_wchar line_source_getc(struct line_source *src); extern enum status line_source_get_row( struct line_source *src, size_t row, - const b_string **out); + const fx_string **out); extern bool line_source_input_available(struct line_source *src); diff --git a/toolchain/xpcg/main.c b/toolchain/xpcg/main.c index 461fa8d..29f8276 100644 --- a/toolchain/xpcg/main.c +++ b/toolchain/xpcg/main.c @@ -6,9 +6,9 @@ #include "msg.h" #include "parse.h" -#include -#include -#include +#include +#include +#include #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); } } diff --git a/toolchain/xpcg/msg.c b/toolchain/xpcg/msg.c index 3366a75..73332c5 100644 --- a/toolchain/xpcg/msg.c +++ b/toolchain/xpcg/msg.c @@ -1,6 +1,6 @@ #include "msg.h" -#include +#include #include #include @@ -13,7 +13,7 @@ struct msg_definition *msg_definition_create(const char *name, long long id) memset(out, 0x0, sizeof *out); - out->msg_name = b_strdup(name); + out->msg_name = fx_strdup(name); out->msg_id = id; return out; @@ -21,22 +21,22 @@ struct msg_definition *msg_definition_create(const char *name, long long id) void msg_definition_destroy(struct msg_definition *msg) { - b_queue_entry *entry = b_queue_pop_front(&msg->msg_params); + fx_queue_entry *entry = fx_queue_pop_front(&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); free(param->p_name); free(param); - entry = b_queue_pop_front(&msg->msg_params); + entry = fx_queue_pop_front(&msg->msg_params); } - entry = b_queue_pop_front(&msg->msg_results); + entry = fx_queue_pop_front(&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); free(param->p_name); free(param); - entry = b_queue_pop_front(&msg->msg_results); + entry = fx_queue_pop_front(&msg->msg_results); } free(msg->msg_name); @@ -45,15 +45,15 @@ void msg_definition_destroy(struct msg_definition *msg) bool msg_definition_has_param(struct msg_definition *msg, const char *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); if (!strcmp(param->p_name, name)) { return true; } - entry = b_queue_next(entry); + entry = fx_queue_next(entry); } return false; @@ -61,15 +61,15 @@ bool msg_definition_has_param(struct msg_definition *msg, const char *name) bool msg_definition_has_result(struct msg_definition *msg, const char *name) { - b_queue_entry *entry = b_queue_first(&msg->msg_results); + fx_queue_entry *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); if (!strcmp(param->p_name, name)) { return true; } - entry = b_queue_next(entry); + entry = fx_queue_next(entry); } return false; @@ -88,9 +88,9 @@ int msg_definition_add_param( memset(param, 0x0, sizeof *param); param->p_type = type; - param->p_name = b_strdup(name); + param->p_name = fx_strdup(name); - b_queue_push_back(&msg->msg_params, ¶m->p_entry); + fx_queue_push_back(&msg->msg_params, ¶m->p_entry); return 0; } @@ -107,8 +107,8 @@ int msg_definition_add_result( memset(param, 0x0, sizeof *param); param->p_type = type; - param->p_name = b_strdup(name); + param->p_name = fx_strdup(name); - b_queue_push_back(&msg->msg_results, ¶m->p_entry); + fx_queue_push_back(&msg->msg_results, ¶m->p_entry); return 0; } diff --git a/toolchain/xpcg/msg.h b/toolchain/xpcg/msg.h index a33d2c5..79af374 100644 --- a/toolchain/xpcg/msg.h +++ b/toolchain/xpcg/msg.h @@ -1,23 +1,23 @@ #ifndef XPCG_MSG_H_ #define XPCG_MSG_H_ -#include +#include struct type; struct msg_parameter { char *p_name; const struct type *p_type; - b_queue_entry p_entry; + fx_queue_entry p_entry; }; struct msg_definition { char *msg_name; long long msg_id; - b_queue_entry msg_entry; + fx_queue_entry msg_entry; - b_queue msg_params; - b_queue msg_results; + fx_queue msg_params; + fx_queue msg_results; }; extern struct msg_definition *msg_definition_create( diff --git a/toolchain/xpcg/token.h b/toolchain/xpcg/token.h index 3a661fd..5713718 100644 --- a/toolchain/xpcg/token.h +++ b/toolchain/xpcg/token.h @@ -3,7 +3,7 @@ #include "file-span.h" -#include +#include #define TOKEN_TYPE(tok) ((tok) ? (tok)->tok_type : TOK_NONE) #define TOKEN_IS(tok, type) ((tok) && ((tok)->tok_type & (type)) != 0) @@ -55,7 +55,7 @@ struct token { struct file_span tok_location; enum token_type tok_type; enum token_value_type tok_value_type; - b_queue_entry tok_entry; + fx_queue_entry tok_entry; union { char *tok_str;