protected int write(ref zdll.args arg, byte[] src) { if (src.Length > arg.buffsz) { return(zdll.OOM); } Marshal.Copy(src, 0, arg.buff, src.Length); return(src.Length); }
protected int read(ref zdll.args arg, out int val) { val = 0; if (arg.buffsz < sizeof(int)) { return(zdll.ERROR); } val = BitConverter.ToInt32(read(ref arg), 0); return(arg.buffsz); }
protected int read(ref zdll.args arg, out bool val) { val = false; if (arg.buffsz < 1) { return(zdll.ERROR); } val = BitConverter.ToBoolean(read(ref arg), 0); return(arg.buffsz); }
protected int read(ref zdll.args arg, out float val) { val = 0.0f; if (arg.buffsz < sizeof(float)) { return(zdll.ERROR); } val = BitConverter.ToSingle(read(ref arg), 0); return(arg.buffsz); }
protected int write(ref zdll.args arg, string val) { byte[] src = Encoding.ASCII.GetBytes(val); return(write(ref arg, src)); }
protected abstract int _decode_field(ref zdll.args arg);
protected int read(ref zdll.args arg, out string val) { val = Encoding.Default.GetString(read(ref arg)); return(arg.buffsz); }
protected int read(ref zdll.args arg, out byte[] val) { val = read(ref arg); return(arg.buffsz); }
private static int decode_cb(ref zdll.args arg) { wire obj = uds[arg.ud]; return(obj._decode_field(ref arg)); }
protected int read(ref zdll.args arg, out ulong val) { val = BitConverter.ToUInt64(read(ref arg), 0); return(arg.buffsz); }
protected int read(ref zdll.args arg, out byte val) { val = (byte)read(ref arg)[0]; return(arg.buffsz); }
protected int read(ref zdll.args arg, out int val) { val = BitConverter.ToInt32(read(ref arg), 0); return(arg.buffsz); }
protected int read(ref zdll.args arg, out bool val) { val = BitConverter.ToBoolean(read(ref arg), 0); return(arg.buffsz); }
private byte[] read(ref zdll.args arg) { byte[] ret = new byte[arg.buffsz]; Marshal.Copy(arg.buff, ret, 0, ret.Length); return(ret); }
protected int write(ref zdll.args arg, byte val) { byte[] src = new byte[1]; src[0] = (byte)val; return(write(ref arg, src)); }
protected int write(ref zdll.args arg, ushort val) { byte[] src = BitConverter.GetBytes(val); return(write(ref arg, src)); }
protected int read(ref zdll.args arg, out float val) { val = BitConverter.ToSingle(read(ref arg), 0); return(arg.buffsz); }