Serialize the direction of each argument
This omits the type of AMCD_OUT arguments at the moment.
This commit is contained in:
parent
bf8ab98365
commit
92c72c9631
|
@ -270,7 +270,8 @@ static AppMessage * _new_deserialize_call(AppMessage * message,
|
||||||
size_t s;
|
size_t s;
|
||||||
Variable * v;
|
Variable * v;
|
||||||
size_t i;
|
size_t i;
|
||||||
AppMessageCallArgument * p;
|
uint8_t direction;
|
||||||
|
AppMessageCallArgument * arg;
|
||||||
|
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
fprintf(stderr, "DEBUG: %s()\n", __func__);
|
fprintf(stderr, "DEBUG: %s()\n", __func__);
|
||||||
|
@ -294,36 +295,57 @@ static AppMessage * _new_deserialize_call(AppMessage * message,
|
||||||
variable_get_as(v, VT_STRING, &message->t.call.method);
|
variable_get_as(v, VT_STRING, &message->t.call.method);
|
||||||
variable_delete(v);
|
variable_delete(v);
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
fprintf(stderr, "DEBUG: %s() \"%s\"\n", __func__,
|
fprintf(stderr, "DEBUG: %s() method=\"%s\"\n", __func__,
|
||||||
message->t.call.method);
|
message->t.call.method);
|
||||||
#endif
|
#endif
|
||||||
/* deserialize the arguments */
|
/* deserialize the arguments */
|
||||||
for(i = 0; pos < size; i++)
|
for(i = 0; pos < size; i++)
|
||||||
{
|
{
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
fprintf(stderr, "DEBUG: %s() %lu\n", __func__, i);
|
fprintf(stderr, "DEBUG: %s() arg=%zu\n", __func__, i);
|
||||||
#endif
|
#endif
|
||||||
if((p = realloc(message->t.call.args, sizeof(*p) * (i + 1)))
|
if((arg = realloc(message->t.call.args, sizeof(*arg) * (i + 1)))
|
||||||
== NULL)
|
== NULL)
|
||||||
{
|
{
|
||||||
error_set_code(-errno, "%s", strerror(errno));
|
error_set_code(-errno, "%s", strerror(errno));
|
||||||
appmessage_delete(message);
|
appmessage_delete(message);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
message->t.call.args = p;
|
message->t.call.args = arg;
|
||||||
|
arg = &message->t.call.args[i];
|
||||||
s = size - pos;
|
s = size - pos;
|
||||||
if((v = variable_new_deserialize(&s, &data[pos])) == NULL)
|
if((v = variable_new_deserialize_type(VT_UINT8, &s, &data[pos]))
|
||||||
|
== NULL)
|
||||||
{
|
{
|
||||||
appmessage_delete(message);
|
appmessage_delete(message);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
variable_get_as(v, VT_UINT8, &direction);
|
||||||
|
variable_delete(v);
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
fprintf(stderr, "DEBUG: %s() %lu (%u)\n", __func__, i,
|
fprintf(stderr, "DEBUG: %s() arg=%zu direction=%u\n", __func__,
|
||||||
variable_get_type(v));
|
i, direction);
|
||||||
#endif
|
#endif
|
||||||
pos += s;
|
pos += s;
|
||||||
message->t.call.args[i].direction = AMCD_IN; /* XXX */
|
s = size - pos;
|
||||||
message->t.call.args[i].arg = v;
|
if(direction != AMCD_OUT)
|
||||||
|
{
|
||||||
|
if((v = variable_new_deserialize(&s, &data[pos]))
|
||||||
|
== NULL)
|
||||||
|
{
|
||||||
|
appmessage_delete(message);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
#ifdef DEBUG
|
||||||
|
fprintf(stderr, "DEBUG: %s() arg=%zu type=%u\n",
|
||||||
|
__func__, i, variable_get_type(v));
|
||||||
|
#endif
|
||||||
|
pos += s;
|
||||||
|
arg->arg = v;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
arg->arg = NULL;
|
||||||
|
arg->direction = direction;
|
||||||
message->t.call.args_cnt = i + 1;
|
message->t.call.args_cnt = i + 1;
|
||||||
}
|
}
|
||||||
return message;
|
return message;
|
||||||
|
@ -465,6 +487,7 @@ static int _serialize_call(AppMessage * message, Buffer * buffer, Buffer * b)
|
||||||
int ret;
|
int ret;
|
||||||
Variable * v;
|
Variable * v;
|
||||||
size_t i;
|
size_t i;
|
||||||
|
AppMessageCallArgument * arg;
|
||||||
|
|
||||||
if(_serialize_id(message, buffer, b) != 0)
|
if(_serialize_id(message, buffer, b) != 0)
|
||||||
return -1;
|
return -1;
|
||||||
|
@ -477,9 +500,23 @@ static int _serialize_call(AppMessage * message, Buffer * buffer, Buffer * b)
|
||||||
return ret;
|
return ret;
|
||||||
for(i = 0; i < message->t.call.args_cnt; i++)
|
for(i = 0; i < message->t.call.args_cnt; i++)
|
||||||
{
|
{
|
||||||
if(message->t.call.args[i].direction == AMCD_OUT)
|
arg = &message->t.call.args[i];
|
||||||
|
#ifdef DEBUG
|
||||||
|
fprintf(stderr, "DEBUG: %s() arg=%zu direction=%u\n", __func__,
|
||||||
|
i, arg->direction);
|
||||||
|
#endif
|
||||||
|
if((v = variable_new(VT_UINT8, arg->direction)) == NULL)
|
||||||
|
break;
|
||||||
|
if(variable_serialize(v, b, false) != 0
|
||||||
|
|| _serialize_append(buffer, b) != 0)
|
||||||
|
{
|
||||||
|
variable_delete(v);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
variable_delete(v);
|
||||||
|
if(arg->direction == AMCD_OUT)
|
||||||
continue;
|
continue;
|
||||||
if(variable_serialize(message->t.call.args[i].arg, b, 1) != 0
|
if(variable_serialize(arg->arg, b, true) != 0
|
||||||
|| _serialize_append(buffer, b) != 0)
|
|| _serialize_append(buffer, b) != 0)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user