diff --git a/ridlbe/c++11/templates/cli/hdr/struct_idl_traits_def.erb b/ridlbe/c++11/templates/cli/hdr/struct_idl_traits_def.erb index 4892e0fc..87a27231 100644 --- a/ridlbe/c++11/templates/cli/hdr/struct_idl_traits_def.erb +++ b/ridlbe/c++11/templates/cli/hdr/struct_idl_traits_def.erb @@ -34,11 +34,12 @@ struct formatter<<%= scoped_cxxtype %>, OStrm_> << "object}" % end % else -% unless _m.optional? || _m.external? - << "<%= _sep %><%= _m.cxxname %>=" << IDL::traits<<%= _m.scoped_cxxtype %>>::write(val_.<%= _m.cxxname %> ()) -% else +% if _m.optional? + << "<%= _sep %><%= _m.cxxname %>="; if (val_.<%= _m.cxxname() %> ().has_value ()) { os_ << IDL::traits<<%= _m.scoped_cxxtype %>>::write(val_.<%= _m.cxxname %> ().value ()); } else { os_ << "std::nullopt"; } os_ +% elsif _m.external? %# TODO -%# << "<%= _sep %><%= _m.cxxname %>=" << (val_.<%= _m.cxxname() %> ().has_value () ? IDL::traits<<%= _m.scoped_cxxtype %>>::write(val_.<%= _m.cxxname %> ().value ()) : "") +% else + << "<%= _sep %><%= _m.cxxname %>=" << IDL::traits<<%= _m.scoped_cxxtype %>>::write(val_.<%= _m.cxxname %> ()) % end % end % _sep = ',' unless _sep diff --git a/tests/idl4/optional/client.cpp b/tests/idl4/optional/client.cpp index 71c79c4c..6638c975 100644 --- a/tests/idl4/optional/client.cpp +++ b/tests/idl4/optional/client.cpp @@ -16,5 +16,8 @@ int main (int /*argc*/, char* /*argv*/[]) bar mybar; TAOX11_TEST_INFO << "mybar: " << mybar << std::endl; + mybar.z(6); + TAOX11_TEST_INFO << "mybar: " << mybar << std::endl; + return retval; } diff --git a/tests/idl4/optional/test.idl b/tests/idl4/optional/test.idl index e47e3521..d24815a0 100644 --- a/tests/idl4/optional/test.idl +++ b/tests/idl4/optional/test.idl @@ -8,8 +8,9 @@ struct bar { short x; - string y; @optional short z; + long z_long; @optional short a; @optional string opt_string; + string y; };