toolchain: xpcg: update libfx usage
This commit is contained in:
@@ -4,7 +4,7 @@
|
||||
#include "../../msg.h"
|
||||
#include "../../type.h"
|
||||
|
||||
#include <fx/core/hash.h>
|
||||
#include <fx/hash.h>
|
||||
#include <fx/io/file.h>
|
||||
#include <fx/io/path.h>
|
||||
#include <stdarg.h>
|
||||
@@ -55,12 +55,12 @@ static int emit_header_guard_start(
|
||||
{
|
||||
fx_string *header_guard = fx_string_create();
|
||||
fx_string_append_cstrf(header_guard, "%s_H_", iface->if_name);
|
||||
fx_string_toupper(header_guard);
|
||||
fx_string_transform_uppercase(header_guard);
|
||||
|
||||
emit(ctx,
|
||||
"#ifndef %s\n#define %s\n\n",
|
||||
fx_string_ptr(header_guard),
|
||||
fx_string_ptr(header_guard));
|
||||
fx_string_get_cstr(header_guard),
|
||||
fx_string_get_cstr(header_guard));
|
||||
fx_string_unref(header_guard);
|
||||
return 0;
|
||||
}
|
||||
@@ -115,14 +115,14 @@ static int emit_interface_id_macros(
|
||||
{
|
||||
fx_string *iface_define_name = fx_string_create();
|
||||
fx_string_append_cstr(iface_define_name, iface->if_name);
|
||||
fx_string_toupper(iface_define_name);
|
||||
fx_string_transform_uppercase(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,
|
||||
fx_string_ptr(iface_define_name),
|
||||
fx_string_get_cstr(iface_define_name),
|
||||
protocol_id);
|
||||
fx_string_unref(iface_define_name);
|
||||
|
||||
@@ -138,7 +138,9 @@ static int emit_interface_id_macros(
|
||||
iface->if_name,
|
||||
msg->msg_name);
|
||||
|
||||
emit(ctx, "/* %s message ID */\n", fx_string_ptr(msg_name));
|
||||
emit(ctx,
|
||||
"/* %s message ID */\n",
|
||||
fx_string_get_cstr(msg_name));
|
||||
uint16_t msg_id = msg->msg_id;
|
||||
|
||||
fx_string_clear(msg_name);
|
||||
@@ -147,10 +149,10 @@ static int emit_interface_id_macros(
|
||||
"%s_%s",
|
||||
iface->if_name,
|
||||
msg->msg_name);
|
||||
fx_string_toupper(msg_name);
|
||||
fx_string_transform_uppercase(msg_name);
|
||||
emit(ctx,
|
||||
"#define MSG_%s 0x%04xU\n",
|
||||
fx_string_ptr(msg_name),
|
||||
fx_string_get_cstr(msg_name),
|
||||
msg_id);
|
||||
|
||||
entry = fx_queue_next(entry);
|
||||
@@ -316,9 +318,9 @@ static int emit_interface_msg_function_send_impl(
|
||||
const struct msg_definition *msg)
|
||||
{
|
||||
fx_string *iface_ucase = fx_string_create_from_cstr(iface->if_name);
|
||||
fx_string_toupper(iface_ucase);
|
||||
fx_string_transform_uppercase(iface_ucase);
|
||||
fx_string *msg_ucase = fx_string_create_from_cstr(msg->msg_name);
|
||||
fx_string_toupper(msg_ucase);
|
||||
fx_string_transform_uppercase(msg_ucase);
|
||||
|
||||
emit(ctx,
|
||||
"struct %s_%s_msg msg_data = {0};\n",
|
||||
@@ -327,9 +329,9 @@ static int emit_interface_msg_function_send_impl(
|
||||
emit(ctx,
|
||||
"xpc_msg_header_init(&msg_data.msg_header, INTERFACE_%s, "
|
||||
"MSG_%s_%s);\n",
|
||||
fx_string_ptr(iface_ucase),
|
||||
fx_string_ptr(iface_ucase),
|
||||
fx_string_ptr(msg_ucase));
|
||||
fx_string_get_cstr(iface_ucase),
|
||||
fx_string_get_cstr(iface_ucase),
|
||||
fx_string_get_cstr(msg_ucase));
|
||||
|
||||
fx_string_unref(iface_ucase);
|
||||
fx_string_unref(msg_ucase);
|
||||
@@ -896,13 +898,13 @@ static int emit_interface_dispatcher_impl(
|
||||
const struct interface_definition *iface)
|
||||
{
|
||||
fx_string *iface_ucase = fx_string_create_from_cstr(iface->if_name);
|
||||
fx_string_toupper(iface_ucase);
|
||||
fx_string_transform_uppercase(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",
|
||||
fx_string_ptr(iface_ucase));
|
||||
fx_string_get_cstr(iface_ucase));
|
||||
|
||||
emit(ctx, "kern_status_t status = KERN_OK;\n");
|
||||
emit(ctx, "switch (msg->msg_header.hdr_func) {\n");
|
||||
@@ -914,12 +916,12 @@ static int emit_interface_dispatcher_impl(
|
||||
|
||||
fx_string_clear(msg_ucase);
|
||||
fx_string_append_cstr(msg_ucase, msg->msg_name);
|
||||
fx_string_toupper(msg_ucase);
|
||||
fx_string_transform_uppercase(msg_ucase);
|
||||
|
||||
emit(ctx,
|
||||
"case MSG_%s_%s: {\n",
|
||||
fx_string_ptr(iface_ucase),
|
||||
fx_string_ptr(msg_ucase));
|
||||
fx_string_get_cstr(iface_ucase),
|
||||
fx_string_get_cstr(msg_ucase));
|
||||
emit_indent(ctx);
|
||||
emit_interface_dispatcher_impl_msg(ctx, iface, msg);
|
||||
emit(ctx, "break;\n");
|
||||
@@ -1121,8 +1123,8 @@ static int emit_header(
|
||||
emit_include(ctx, "xpc/string.h", true);
|
||||
emit_include(ctx, "xpc/buffer.h", true);
|
||||
emit_include(ctx, "xpc/context.h", true);
|
||||
emit_include(ctx, "mango/msg.h", true);
|
||||
emit_include(ctx, "mango/types.h", true);
|
||||
emit_include(ctx, "magenta/msg.h", true);
|
||||
emit_include(ctx, "magenta/types.h", true);
|
||||
emit(ctx, "\n");
|
||||
|
||||
emit_interface_id_macros(ctx, iface);
|
||||
|
||||
Reference in New Issue
Block a user