1
0
mirror of https://github.com/janet-lang/janet synced 2024-11-29 11:29:54 +00:00

added marshal/unmarshal

This commit is contained in:
J.-F. Cap 2019-03-14 02:01:15 +01:00 committed by Calvin Rose
parent 319575c864
commit 090c6ac975

View File

@ -42,14 +42,38 @@ typedef uint64_t bi_uint64;
static Janet int64_get(void *p, Janet key); static Janet int64_get(void *p, Janet key);
static Janet uint64_get(void *p, Janet key); static Janet uint64_get(void *p, Janet key);
static void int64_marshal(void *p, JanetMarshalContext *ctx) {
bi_int64 *box=(bi_int64 *)p;
janet_marshal_size(ctx,(size_t)(*box));
}
static void uint64_marshal(void *p, JanetMarshalContext *ctx) {
bi_uint64 *box=(bi_uint64 *)p;
janet_marshal_size(ctx,(size_t)(*box));
}
static void int64_unmarshal(void *p, JanetMarshalContext *ctx) {
bi_int64 *box=(bi_int64 *)p;
janet_unmarshal_size(ctx,(size_t *)box);
}
static void uint64_unmarshal(void *p, JanetMarshalContext *ctx) {
bi_uint64 *box=(bi_uint64 *)p;
janet_unmarshal_size(ctx,(size_t *)box);
}
static const JanetAbstractType bi_int64_type = { static const JanetAbstractType bi_int64_type = {
"core/int64", "core/int64",
NULL, NULL,
NULL, NULL,
int64_get, int64_get,
NULL, NULL,
NULL, int64_marshal,
NULL int64_unmarshal
}; };
static const JanetAbstractType bi_uint64_type = { static const JanetAbstractType bi_uint64_type = {
@ -58,8 +82,8 @@ static const JanetAbstractType bi_uint64_type = {
NULL, NULL,
uint64_get, uint64_get,
NULL, NULL,
NULL, uint64_marshal,
NULL uint64_unmarshal
}; };
static int parse_int64(const char *str, bi_int64 *box) { static int parse_int64(const char *str, bi_int64 *box) {