Motr
M0
|
#include "lib/bob.h"
#include "lib/misc.h"
#include "lib/errno.h"
#include "lib/assert.h"
#include "lib/memory.h"
#include "lib/string.h"
#include "lib/arith.h"
#include "xcode/xcode.h"
#include "lib/trace.h"
#include "xcode/cursor.c"
Go to the source code of this file.
Data Structures | |
struct | flags_data |
Macros | |
#define | M0_TRACE_SUBSYSTEM M0_TRACE_SUBSYS_XCODE |
Enumerations | |
enum | xcode_op { XO_ENC, XO_DEC, XO_LEN, XO_NR } |
Functions | |
static bool | is_pointer (const struct m0_xcode_type *xt, const struct m0_xcode_field *field) |
static unsigned | alignment_mask (const struct m0_xcode_field *field) |
static bool | field_invariant (const struct m0_xcode_type *xt, const struct m0_xcode_field *field) |
bool | m0_xcode_type_invariant (const struct m0_xcode_type *xt) |
static bool | at_array (const struct m0_xcode_cursor *it, const struct m0_xcode_cursor_frame *prev, const struct m0_xcode_obj *par) |
static void ** | allocp (struct m0_xcode_cursor *it, size_t *out) |
M0_INTERNAL void | m0_xcode_free_obj (struct m0_xcode_obj *obj) |
static int | ctx_walk (struct m0_xcode_ctx *ctx, enum xcode_op op) |
static void | __xcode_free (struct m0_xcode_cursor *it) |
M0_INTERNAL void | m0_xcode_free (struct m0_xcode_ctx *ctx) |
M0_INTERNAL int | m0_xcode_dup (struct m0_xcode_ctx *dest, struct m0_xcode_ctx *src) |
M0_INTERNAL int | m0_xcode_cmp (const struct m0_xcode_obj *o0, const struct m0_xcode_obj *o1) |
M0_INTERNAL void * | m0_xcode_addr (const struct m0_xcode_obj *obj, int fileno, uint64_t elno) |
M0_INTERNAL int | m0_xcode_subobj (struct m0_xcode_obj *subobj, const struct m0_xcode_obj *obj, int fieldno, uint64_t elno) |
M0_INTERNAL uint64_t | m0_xcode_atom (const struct m0_xcode_obj *obj) |
M0_INTERNAL uint64_t | m0_xcode_tag (const struct m0_xcode_obj *obj) |
M0_INTERNAL int | m0_xcode_find (struct m0_xcode_obj *obj, const struct m0_xcode_type *xt, void **place) |
M0_INTERNAL void | m0_xcode_bob_type_init (struct m0_bob_type *bt, const struct m0_xcode_type *xt, size_t magix_field, uint64_t magix) |
M0_INTERNAL void * | m0_xcode_ctx_top (const struct m0_xcode_ctx *ctx) |
M0_INTERNAL void | m0_xcode_union_init (struct m0_xcode_type *un, const char *name, const char *discriminator, size_t maxbranches) |
M0_INTERNAL void | m0_xcode_union_fini (struct m0_xcode_type *un) |
M0_INTERNAL void | m0_xcode_union_add (struct m0_xcode_type *un, const char *name, const struct m0_xcode_type *xt, uint64_t tag) |
M0_INTERNAL void | m0_xcode_union_close (struct m0_xcode_type *un) |
static void | xcode_flags_check (struct m0_xcode_type *xt, struct flags_data *fd) |
M0_INTERNAL bool | m0_xcode_type_flags (struct m0_xcode_type *xt, uint32_t on, uint32_t off, uint64_t aggr_umask) |
void | m0_xc_u8_init (void) |
void | m0_xc_u16_init (void) |
void | m0_xc_u32_init (void) |
void | m0_xc_u64_init (void) |
void | m0_xc_void_init (void) |
void | m0_xc_opaque_init (void) |
xcoding. | |
Encoding-decoding (collectively xcoding) support is implemented on top of introspection facilities provided by the xcode module. xcoding provides 3 operations: - sizing (m0_xcode_length()): returns the size of a buffer sufficient to hold serialized object representation; - encoding (m0_xcode_encode()): constructs a serialized object representation in a given buffer; - decoding (m0_xcode_decode()): constructs an in-memory object, given its serialized representation. xcoding traverses the tree of sub-objects, starting from the topmost object to be xcoded. For each visited object, if a method, corresponding to the xcoding operation (encode, decode, length) is not NULL in object's type m0_xcode_type_ops vector, this method is called and no further processing of this object is done. Otherwise, "standard xcoding" takes place. Standard xcoding is non-trivial only for leaves in the sub-object tree (i.e., for objects of ATOM aggregation type): - for encoding, place object's value into the buffer, convert it to desired endianness and advance buffer position; - for decoding, extract value from the buffer, convert it, store in the in-memory object and advance buffer position; - for sizing, increment required buffer size by the size of atomic type. In addition, decoding allocates memory as necessary. | |
M0_INTERNAL bool | m0_xcode_is_byte_array (const struct m0_xcode_type *xt) |
M0_EXTERN ssize_t | m0_xcode_alloc_obj (struct m0_xcode_cursor *it, void *(*alloc)(struct m0_xcode_cursor *, size_t)) |
M0_INTERNAL void | m0_xcode_ctx_init (struct m0_xcode_ctx *ctx, const struct m0_xcode_obj *obj) |
M0_INTERNAL int | m0_xcode_decode (struct m0_xcode_ctx *ctx) |
M0_INTERNAL int | m0_xcode_encode (struct m0_xcode_ctx *ctx) |
M0_INTERNAL int | m0_xcode_length (struct m0_xcode_ctx *ctx) |
M0_INTERNAL void | m0_xcode_type_iterate (struct m0_xcode_type *xt, void(*t)(struct m0_xcode_type *, void *), void(*f)(struct m0_xcode_type *, struct m0_xcode_field *, void *), void *datum) |
M0_INTERNAL int | m0_xcode_encdec (struct m0_xcode_obj *obj, struct m0_bufvec_cursor *cur, enum m0_xcode_what what) |
M0_INTERNAL int | m0_xcode_data_size (struct m0_xcode_ctx *ctx, const struct m0_xcode_obj *obj) |
M0_INTERNAL void * | m0_xcode_alloc (struct m0_xcode_cursor *it, size_t nob) |
M0_INTERNAL int | m0_xcode_obj_enc_to_buf (struct m0_xcode_obj *obj, void **buf, m0_bcount_t *len) |
M0_INTERNAL int | m0_xcode_obj_dec_from_buf (struct m0_xcode_obj *obj, void *buf, m0_bcount_t len) |
Variables | |
const struct m0_xcode_type | M0_XT_VOID |
const struct m0_xcode_type | M0_XT_U8 |
const struct m0_xcode_type | M0_XT_U32 |
const struct m0_xcode_type | M0_XT_U64 |
const struct m0_xcode_type | M0_XT_OPAQUE |
const char * | m0_xcode_aggr_name [M0_XA_NR] |
const char * | m0_xcode_atom_type_name [M0_XAT_NR] |
const char * | m0_xcode_endianness_name [M0_XEND_NR] |
const char * | m0_xcode_cursor_flag_name [M0_XCODE_CURSOR_NR] |