@@ -401,42 +401,68 @@ bool ts_generator::generate_ts(AST_Decl* node, UTL_ScopedName* name)
401
401
" }\n "
402
402
" #else\n "
403
403
" ACE_UNUSED_ARG(in);\n "
404
- " ACE_UNUSED_ARG(out);\n "
405
404
" ACE_UNUSED_ARG(format);\n "
406
405
" #endif\n "
406
+ " out = \"\" ;\n "
407
407
" return ::DDS::RETCODE_UNSUPPORTED;\n "
408
408
" }\n\n "
409
409
" ::DDS::ReturnCode_t " << ts_short_name << " TypeSupportImpl::encode_to_bytes(const " << short_name << " & in, ::DDS::OctetSeq_out out, OpenDDS::DCPS::RepresentationFormat* format)\n "
410
410
" {\n "
411
+ " #if OPENDDS_HAS_JSON_VALUE_WRITER\n "
412
+ " OpenDDS::DCPS::JsonRepresentationFormat_var jrf = OpenDDS::DCPS::JsonRepresentationFormat::_narrow(format);\n "
413
+ " if (jrf) {\n "
414
+ " CORBA::String_var buffer;\n "
415
+ " const ::DDS::ReturnCode_t ret = encode_to_string(in, buffer, format);\n "
416
+ " const ::DDS::UInt32 len = static_cast< ::DDS::UInt32>(std::strlen(buffer));\n "
417
+ " out = new ::DDS::OctetSeq(len);\n "
418
+ " out->length(len);\n "
419
+ " std::memcpy(out->get_buffer(), buffer, len);\n "
420
+ " return ::DDS::RETCODE_OK;\n "
421
+ " }\n "
422
+ " #else\n "
411
423
" ACE_UNUSED_ARG(in);\n "
412
- " ACE_UNUSED_ARG(out);\n "
413
424
" ACE_UNUSED_ARG(format);\n "
425
+ " #endif\n "
426
+ " out = new ::DDS::OctetSeq();\n "
414
427
" return ::DDS::RETCODE_UNSUPPORTED;\n "
415
428
" }\n\n "
416
429
" ::DDS::ReturnCode_t " << ts_short_name << " TypeSupportImpl::decode_from_string(const char* in, " << short_name << " _out " <<
417
430
(alloc_out ? " out" : " param" ) << " , OpenDDS::DCPS::RepresentationFormat* format)\n "
418
- " {\n "
431
+ " {\n " ;
432
+
433
+ if (alloc_out) {
434
+ be_global->impl_ << " out = new " << short_name << " ;\n " ;
435
+ } else {
436
+ be_global->impl_ << " " << short_name << " * out = ¶m;\n " ;
437
+ }
438
+
439
+ be_global->impl_ <<
440
+ " OpenDDS::DCPS::set_default(*out);\n "
419
441
" #if OPENDDS_HAS_JSON_VALUE_READER\n "
420
442
" OpenDDS::DCPS::JsonRepresentationFormat_var jrf = OpenDDS::DCPS::JsonRepresentationFormat::_narrow(format);\n "
421
443
" if (jrf) {\n "
422
444
" rapidjson::StringStream buffer(in);\n "
423
445
" OpenDDS::DCPS::JsonValueReader<> jvr(buffer);\n " <<
424
- (alloc_out ? " out = new " + short_name + " ;\n " : " " + short_name + " * out = ¶m;\n " ) <<
425
- " OpenDDS::DCPS::set_default(*out);\n "
426
446
" return vread(jvr, *out) ? ::DDS::RETCODE_OK : ::DDS::RETCODE_ERROR;\n "
427
447
" }\n "
428
448
" #else\n "
429
449
" ACE_UNUSED_ARG(in);\n "
430
- " ACE_UNUSED_ARG(" << (alloc_out ? " out" : " param" ) << " );\n "
431
450
" ACE_UNUSED_ARG(format);\n "
432
451
" #endif\n "
433
452
" return ::DDS::RETCODE_UNSUPPORTED;\n "
434
453
" }\n\n "
435
454
" ::DDS::ReturnCode_t " << ts_short_name << " TypeSupportImpl::decode_from_bytes(const ::DDS::OctetSeq& in, " << short_name << " _out out, OpenDDS::DCPS::RepresentationFormat* format)\n "
436
455
" {\n "
456
+ " #if OPENDDS_HAS_JSON_VALUE_READER\n "
457
+ " OpenDDS::DCPS::JsonRepresentationFormat_var jrf = OpenDDS::DCPS::JsonRepresentationFormat::_narrow(format);\n "
458
+ " if (jrf) {\n "
459
+ " return decode_from_string(reinterpret_cast<const char*>(in.get_buffer()), out, format);\n "
460
+ " }\n "
461
+ " #else\n "
437
462
" ACE_UNUSED_ARG(in);\n "
438
- " ACE_UNUSED_ARG(out);\n "
439
463
" ACE_UNUSED_ARG(format);\n "
464
+ " #endif\n "
465
+ " out = " << (alloc_out ? " new " : " " ) << short_name << " ();\n "
440
466
" return ::DDS::RETCODE_UNSUPPORTED;\n "
441
467
" }\n\n "
442
468
<< ts_short_name << " TypeSupport::_ptr_type " << ts_short_name << " TypeSupportImpl::_narrow(CORBA::Object_ptr obj)\n "
0 commit comments