Commit 0588dbf1 authored by Jonathan Michalon's avatar Jonathan Michalon
Browse files

libovcc: drop variantmessage's class fields and use return value & args

now build_variant and parse_variant use respectively return value and argument
to communicate with the code in the abstract class.
parent fe8e2dd4
......@@ -45,16 +45,16 @@ public class OVCC.Network.LoginMessage : VariantMessage
Object (login: login, password: password);
}
protected override void build_variant ()
protected override Variant build_variant ()
{
variant = new Variant ("(iss)", status, login, password);
return new Variant ("(iss)", status, login, password);
}
protected override void parse_variant ()
protected override void parse_variant (uint8[] data)
{
State s;
string l;
string p;
parse ("(iss)", out s, out l, out p);
parse_data (data, "(iss)", out s, out l, out p);
status = s;
login = l;
password = p;
......
......@@ -23,20 +23,17 @@
*/
public abstract class OVCC.Network.VariantMessage : Message
{
protected Variant variant = null;
private uint8[] data = null;
protected abstract void build_variant ();
protected abstract void parse_variant ();
protected abstract Variant build_variant ();
protected abstract void parse_variant (uint8[] data);
public override bool serialize (DataOutputStream stream,
Cancellable? cancel = null)
throws Error
{
build_variant ();
var v = build_variant ();
var data = new uint8[v.get_size()];
var data = new uint8[variant.get_size()];
variant.store (data);
v.store (data);
return write_buffer (stream, data, cancel);
}
......@@ -45,22 +42,20 @@ public abstract class OVCC.Network.VariantMessage : Message
Cancellable? cancel = null)
throws Error
{
data = read_buffer (stream, cancel);
var data = read_buffer (stream, cancel);
parse_variant ();
parse_variant (data);
return true;
}
protected void parse (string format,
...)
protected void parse_data (uint8[] data,
string format,
...)
{
var ap = va_list ();
variant = Variant.new_from_data<Object> (new VariantType(format), data, false, this);
variant.get_va (format, null, &ap);
var v = Variant.new_from_data<Object> (new VariantType(format), data, false, this);
variant = null;
data = null;
v.get_va (format, null, &ap);
}
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment