serial: convert b_serial_ctx to a b_object interface
This commit is contained in:
@@ -1,13 +1,13 @@
|
||||
#include "blue/core/stringstream.h"
|
||||
#include "serial.h"
|
||||
|
||||
#include <blue/core/status.h>
|
||||
#include <blue/core/stringstream.h>
|
||||
#include <blue/ds/array.h>
|
||||
#include <blue/ds/datetime.h>
|
||||
#include <blue/ds/dict.h>
|
||||
#include <blue/ds/hashmap.h>
|
||||
#include <blue/ds/number.h>
|
||||
#include <blue/ds/string.h>
|
||||
#include <blue/serial/ctx.h>
|
||||
#include <blue/serial/toml.h>
|
||||
#include <stdbool.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
@@ -1543,10 +1543,10 @@ static enum b_status ctx_init(struct ctx *ctx)
|
||||
}
|
||||
|
||||
static enum b_status toml_serialise(
|
||||
struct b_serial_ctx *serial, b_object *src, b_stream *dest,
|
||||
b_serial_ctx *serial, b_object *src, b_stream *dest,
|
||||
enum b_serial_flags flags)
|
||||
{
|
||||
return B_SUCCESS;
|
||||
return B_ERR_NOT_SUPPORTED;
|
||||
}
|
||||
|
||||
static void print_token(struct token *tok)
|
||||
@@ -2221,7 +2221,7 @@ static enum b_status parse_root(struct ctx *ctx, b_dict **result)
|
||||
}
|
||||
|
||||
static enum b_status toml_deserialise(
|
||||
struct b_serial_ctx *serial, b_stream *src, b_object **dest,
|
||||
b_serial_ctx *serial, b_stream *src, b_object **dest,
|
||||
enum b_serial_flags flags)
|
||||
{
|
||||
struct ctx ctx = {0};
|
||||
@@ -2266,7 +2266,33 @@ static enum b_status toml_deserialise(
|
||||
return B_SUCCESS;
|
||||
}
|
||||
|
||||
const struct b_serial_format_ops z__b_toml_format_ops = {
|
||||
.fmt_serialise = toml_serialise,
|
||||
.fmt_deserialise = toml_deserialise,
|
||||
};
|
||||
/*** VIRTUAL FUNCTIONS ********************************************************/
|
||||
|
||||
static void toml_serial_ctx_init(b_object *obj, void *priv)
|
||||
{
|
||||
}
|
||||
|
||||
static void toml_serial_ctx_fini(b_object *obj, void *priv)
|
||||
{
|
||||
}
|
||||
|
||||
/*** CLASS DEFINITION *********************************************************/
|
||||
|
||||
B_TYPE_CLASS_DEFINITION_BEGIN(b_toml_serial_ctx)
|
||||
B_TYPE_CLASS_INTERFACE_BEGIN(b_object, B_TYPE_OBJECT)
|
||||
B_INTERFACE_ENTRY(to_string) = NULL;
|
||||
B_TYPE_CLASS_INTERFACE_END(b_object, B_TYPE_OBJECT)
|
||||
|
||||
B_TYPE_CLASS_INTERFACE_BEGIN(b_serial_ctx, B_TYPE_SERIAL_CTX)
|
||||
B_INTERFACE_ENTRY(s_serialise) = toml_serialise;
|
||||
B_INTERFACE_ENTRY(s_deserialise) = toml_deserialise;
|
||||
B_TYPE_CLASS_INTERFACE_END(b_serial_ctx, B_TYPE_SERIAL_CTX)
|
||||
B_TYPE_CLASS_DEFINITION_END(b_toml_serial_ctx)
|
||||
|
||||
B_TYPE_DEFINITION_BEGIN(b_toml_serial_ctx)
|
||||
B_TYPE_ID(0xaec8dca0, 0x131a, 0x4217, 0x916b, 0xaed15756601c);
|
||||
B_TYPE_CLASS(b_toml_serial_ctx_class);
|
||||
B_TYPE_EXTENDS(B_TYPE_SERIAL_CTX);
|
||||
B_TYPE_INSTANCE_INIT(toml_serial_ctx_init);
|
||||
B_TYPE_INSTANCE_FINI(toml_serial_ctx_fini);
|
||||
B_TYPE_DEFINITION_END(b_toml_serial_ctx)
|
||||
|
||||
Reference in New Issue
Block a user