diff --git a/idl-compiler.py b/idl-compiler.py index 8dd6b4460e..4c64d65fcb 100755 --- a/idl-compiler.py +++ b/idl-compiler.py @@ -784,17 +784,29 @@ def add_view(hout, info): """)).substitute({'type' : cls["name"]})) skip = "" if is_final(cls) else "ser::skip(in, boost::type());" + local_names = {} for m in members: + name = get_member_name(m["name"]) + local_names[name] = "this->" + name + "()" full_type = param_view_type(m["type"]) + if "attribute" in m: + deflt = m["default"][0] if "default" in m else param_type(m["type"]) + "()" + if deflt in local_names: + deflt = local_names[deflt] + deser = Template("(in.size()>0) ? $func(in, boost::type<$typ>()) : $default").substitute( + {'func' : DESERIALIZER, 'typ' : full_type, 'default': deflt}) + else: + deser = Template("$func(in, boost::type<$typ>())").substitute({'func' : DESERIALIZER, 'typ' : full_type}) + fprintln(hout, Template(reindent(4, """ auto $name() const { - return seastar::with_serialized_stream(v, [] (auto& v) { + return seastar::with_serialized_stream(v, [this] (auto& v) { auto in = v; $skip - return deserialize(in, boost::type<$type>()); + return $deser; }); } - """)).substitute({'name' : get_member_name(m["name"]), 'type' : full_type, 'skip' : skip})) + """)).substitute({'name' : name, 'type' : full_type, 'skip' : skip, 'deser' : deser})) skip = skip + Template("\n ser::skip(in, boost::type<${type}>());").substitute({'type': full_type}) diff --git a/idl/query.idl.hh b/idl/query.idl.hh index c33b5812cc..b2aa14dbc8 100644 --- a/idl/query.idl.hh +++ b/idl/query.idl.hh @@ -7,7 +7,7 @@ class qr_cell stub [[writable]] { // Specified by CQL binary protocol, according to cql_serialization_format in read_command. bytes value; - std::experimental::optional ttl [[version 1.3]] = { }; // present when send_ttl option set in partition_slice + std::experimental::optional ttl [[version 1.3]]; // present when send_ttl option set in partition_slice }; class qr_row stub [[writable]] {