allow null methods and bodies

This commit is contained in:
psyc://psyced.org/~lynX 2011-04-27 00:19:55 +02:00
parent aaece680c7
commit f7dcb2eb89
2 changed files with 23 additions and 5 deletions

View File

@ -42,14 +42,17 @@ f_psyc_render(svalue_t *sp) {
vector_t *v;
psycPacket packet;
string_t *out;
char *meth, *body;
int mlen, blen;
// unless (sp->type == T_POINTER) return sp;
v = sp->u.vec;
if ((i = (mp_int)VEC_SIZE(v)) != 4) {
if ((i = (mp_int)VEC_SIZE(v)) != 1+PSYC_BODY) {
errorf("Wrong number of elements (%"PRIdMPINT") in array argument to psyc_render()\n", i);
/* NOTREACHED */
return sp;
}
#if 0
if (v->item[PSYC_METHOD].type != T_STRING) {
errorf("Wrong type for PSYC_METHOD element in PSYC packet.\n");
/* NOTREACHED */
@ -60,11 +63,26 @@ f_psyc_render(svalue_t *sp) {
/* NOTREACHED */
return sp;
}
#else
if (v->item[PSYC_METHOD].type == T_STRING) {
meth = get_txt(v->item[PSYC_METHOD].u.str);
mlen = mstrsize(v->item[PSYC_METHOD].u.str);
} else {
meth = NULL;
mlen = 0;
}
if (v->item[PSYC_BODY].type == T_STRING) {
body = get_txt(v->item[PSYC_BODY].u.str);
blen = mstrsize(v->item[PSYC_BODY].u.str);
} else {
body = NULL;
blen = 0;
}
#endif
// TODO: handle _lists
// FIXME: handle mappings
packet = psyc_newPacket2(NULL, 0, NULL, 0,
get_txt(v->item[PSYC_METHOD].u.str), mstrsize(v->item[PSYC_METHOD].u.str),
// this should be an int* when "binary".. TODO
get_txt(v->item[PSYC_BODY].u.str), mstrsize(v->item[PSYC_BODY].u.str),
meth, mlen, body, blen,
PSYC_PACKET_CHECK_LENGTH);
printf("rendering... packet.length = %d\n", packet.length);

View File

@ -17,7 +17,7 @@ version_longtype="stable"
# A timestamp, to be used by bumpversion and other scripts.
# It can be used, for example, to 'touch' this file on every build, thus
# forcing revision control systems to add it on every checkin automatically.
version_stamp="Tue Apr 26 22:00:17 CEST 2011"
version_stamp="Wed Apr 27 00:18:40 CEST 2011"
# Okay, LDMUD is using 3.x.x so to avoid conflicts let's just use 4.x.x
version_major=4