mirror of
https://github.com/janet-lang/janet
synced 2025-06-20 23:44:13 +00:00
fix incompatibilities with upstream/master changes in marsh.c
This commit is contained in:
parent
4d3c655058
commit
db64a682be
@ -291,19 +291,18 @@ void janet_marshal_janet(JanetMarshalContext *ctx, Janet x) {
|
|||||||
janet_table_put(&st->seen, x, janet_wrap_integer(st->nextid++))
|
janet_table_put(&st->seen, x, janet_wrap_integer(st->nextid++))
|
||||||
|
|
||||||
|
|
||||||
static int marshal_one_abstract(MarshalState *st, Janet x, int flags) {
|
static void marshal_one_abstract(MarshalState *st, Janet x, int flags) {
|
||||||
const JanetAbstractType *at = janet_abstract_type(janet_unwrap_abstract(x));
|
const JanetAbstractType *at = janet_abstract_type(janet_unwrap_abstract(x));
|
||||||
const JanetAbstractTypeInfo *info = janet_get_abstract_type_info_byname(at->name);
|
const JanetAbstractTypeInfo *info = janet_get_abstract_type_info_byname(at->name);
|
||||||
if (! info) return 1 ; /* unregistered type skip marshalling*/
|
if (info && info->marshal) {
|
||||||
if (info->marshal) {
|
|
||||||
MARK_SEEN();
|
MARK_SEEN();
|
||||||
JanetMarshalContext context = {st, NULL, flags, NULL};
|
JanetMarshalContext context = {st, NULL, flags, NULL};
|
||||||
pushbyte(st, LB_ABSTRACT);
|
pushbyte(st, LB_ABSTRACT);
|
||||||
pushint(st, info->tag);
|
pushint(st, info->tag);
|
||||||
info->marshal(janet_unwrap_abstract(x), &context);
|
info->marshal(janet_unwrap_abstract(x), &context);
|
||||||
return 1;
|
} else {
|
||||||
|
janet_panicf("try to marshal unregistered absttact type, cannot marshal %p", x);
|
||||||
}
|
}
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -463,10 +462,9 @@ static void marshal_one(MarshalState *st, Janet x, int flags) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
case JANET_ABSTRACT: {
|
case JANET_ABSTRACT: {
|
||||||
if (marshal_one_abstract(st, x, flags)) {
|
marshal_one_abstract(st, x, flags);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
case JANET_FUNCTION: {
|
case JANET_FUNCTION: {
|
||||||
pushbyte(st, LB_FUNCTION);
|
pushbyte(st, LB_FUNCTION);
|
||||||
JanetFunction *func = janet_unwrap_function(x);
|
JanetFunction *func = janet_unwrap_function(x);
|
||||||
@ -520,41 +518,10 @@ typedef struct {
|
|||||||
const uint8_t *end;
|
const uint8_t *end;
|
||||||
} UnmarshalState;
|
} UnmarshalState;
|
||||||
|
|
||||||
<<<<<<< HEAD
|
|
||||||
enum {
|
|
||||||
UMR_OK,
|
|
||||||
UMR_STACKOVERFLOW,
|
|
||||||
UMR_EOS,
|
|
||||||
UMR_UNKNOWN,
|
|
||||||
UMR_EXPECTED_INTEGER,
|
|
||||||
UMR_EXPECTED_TABLE,
|
|
||||||
UMR_EXPECTED_FIBER,
|
|
||||||
UMR_EXPECTED_STRING,
|
|
||||||
UMR_INVALID_REFERENCE,
|
|
||||||
UMR_INVALID_BYTECODE,
|
|
||||||
UMR_INVALID_FIBER,
|
|
||||||
UMR_INVALID_ABSTRACT
|
|
||||||
} UnmarshalResult;
|
|
||||||
|
|
||||||
const char *umr_strings[] = {
|
|
||||||
"",
|
|
||||||
"stack overflow",
|
|
||||||
"unexpected end of source",
|
|
||||||
"unmarshal error",
|
|
||||||
"expected integer",
|
|
||||||
"expected table",
|
|
||||||
"expected fiber",
|
|
||||||
"expected string",
|
|
||||||
"invalid reference",
|
|
||||||
"invalid bytecode",
|
|
||||||
"invalid fiber",
|
|
||||||
"invalid abstract",
|
|
||||||
};
|
|
||||||
=======
|
|
||||||
#define MARSH_EOS(st, data) do { \
|
#define MARSH_EOS(st, data) do { \
|
||||||
if ((data) >= (st)->end) janet_panic("unexpected end of source");\
|
if ((data) >= (st)->end) janet_panic("unexpected end of source");\
|
||||||
} while (0)
|
} while (0)
|
||||||
>>>>>>> upstream/master
|
|
||||||
|
|
||||||
/* Helper to read a 32 bit integer from an unmarshal state */
|
/* Helper to read a 32 bit integer from an unmarshal state */
|
||||||
static int32_t readint(UnmarshalState *st, const uint8_t **atdata) {
|
static int32_t readint(UnmarshalState *st, const uint8_t **atdata) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user