runtime: move value formatting functionality to a dedicated api

This commit is contained in:
2026-06-13 13:46:29 +01:00
parent 4c04ca6de8
commit 73519eb7aa
6 changed files with 134 additions and 27 deletions
+14
View File
@@ -47,6 +47,12 @@ struct bshell_table_ctx {
fx_stream *ctx_out;
};
struct bshell_value_writer {
struct bshell_table_ctx w_table_ctx;
bool w_table_initialised;
fx_stream *w_dest;
};
extern enum bshell_status bshell_table_init(void);
extern const struct bshell_table *bshell_table_get_for_type(const fx_type *ty);
extern enum bshell_status format_object_table(
@@ -74,4 +80,12 @@ extern enum bshell_status bshell_table_ctx_print_record(
struct bshell_table_ctx *ctx,
const fx_value *record);
extern void bshell_value_writer_init(
struct bshell_value_writer *w,
fx_stream *dest);
extern void bshell_value_writer_write(
struct bshell_value_writer *w,
const fx_value *value);
extern void bshell_value_writer_cleanup(struct bshell_value_writer *w);
#endif
@@ -3,6 +3,7 @@
#include <bshell/command/command.h>
#include <bshell/command/function.h>
#include <bshell/format.h>
#include <bshell/runtime/script-block.h>
#include <bshell/runtime/var.h>
#include <fx/collections/hashtable.h>
@@ -15,6 +16,7 @@ struct bshell_runtime {
struct bshell_runtime_scope *rt_global;
fx_hashtable *rt_aliases;
fx_queue rt_scope;
struct bshell_value_writer rt_writer;
};
extern struct bshell_runtime *bshell_runtime_create(void);
@@ -53,4 +55,10 @@ extern struct bshell_runtime_scope *bshell_runtime_get_parent_scope(
struct bshell_runtime *rt,
struct bshell_runtime_scope *scope);
extern void bshell_runtime_begin_output(struct bshell_runtime *rt);
extern void bshell_runtime_output_value(
struct bshell_runtime *rt,
const fx_value *value);
extern void bshell_runtime_end_output(struct bshell_runtime *rt);
#endif