@@ -360,22 +360,32 @@ std::string CommsVariantField::commsDefReadFuncBodyImpl() const
360360 static const std::string Templ =
361361 " case #^#VAL#$#:\n "
362362 " {\n "
363+ " #^#ADJUST_ITER#$#\n "
364+ " #^#ADJUST_LEN#$#\n "
363365 " auto& field_#^#BUNDLE_NAME#$# = initField_#^#BUNDLE_NAME#$#();\n "
364366 " COMMS_ASSERT(field_#^#BUNDLE_NAME#$#.field_#^#KEY_NAME#$#().getValue() == commonKeyField.getValue());\n "
365367 " #^#VERSION_ASSIGN#$#\n "
366- " return field_#^#BUNDLE_NAME#$#.template readFrom<1> (iter, len);\n "
368+ " return field_#^#BUNDLE_NAME#$#.#^#READ#$# (iter, len);\n "
367369 " }" ;
368370
369371 util::GenReplacementMap repl = {
370372 {" VAL" , std::move (valStr)},
371373 {" BUNDLE_NAME" , bundleAccName},
372374 {" KEY_NAME" , keyAccName},
375+ {" READ" , " template readFrom<1>" },
373376 };
374377
375378 if (m->commsIsVersionDependent ()) {
376379 auto assignStr = " field_" + bundleAccName + " .setVersion(Base::getVersion());" ;
377380 repl[" VERSION_ASSIGN" ] = std::move (assignStr);
378381 }
382+
383+ if (m->commsHasCustomRead ()) {
384+ repl[" ADJUST_ITER" ] = " iter = origIter;" ;
385+ repl[" ADJUST_LEN" ] = " len += consumedLen;" ;
386+ repl[" READ" ] = " read" ;
387+ }
388+
379389 cases.push_back (util::genProcessTemplate (Templ, repl));
380390 continue ;
381391 }
@@ -385,20 +395,29 @@ std::string CommsVariantField::commsDefReadFuncBodyImpl() const
385395
386396 static const std::string Templ =
387397 " default:\n "
398+ " #^#ADJUST_ITER#$#\n "
399+ " #^#ADJUST_LEN#$#\n "
388400 " initField_#^#BUNDLE_NAME#$#().field_#^#KEY_NAME#$#().setValue(commonKeyField.getValue());\n "
389401 " #^#VERSION_ASSIGN#$#\n "
390- " return accessField_#^#BUNDLE_NAME#$#().template readFrom<1> (iter, len);" ;
402+ " return accessField_#^#BUNDLE_NAME#$#().#^#READ#$# (iter, len);" ;
391403
392404 util::GenReplacementMap repl = {
393405 {" BUNDLE_NAME" , bundleAccName},
394406 {" KEY_NAME" , keyAccName},
407+ {" READ" , " template readFrom<1>" },
395408 };
396409
397410 if (m->commsIsVersionDependent ()) {
398411 auto assignStr = " field_" + bundleAccName + " .setVersion(Base::getVersion());" ;
399412 repl[" VERSION_ASSIGN" ] = std::move (assignStr);
400413 }
401414
415+ if (m->commsHasCustomRead ()) {
416+ repl[" ADJUST_ITER" ] = " iter = origIter;" ;
417+ repl[" ADJUST_LEN" ] = " len += consumedLen;" ;
418+ repl[" READ" ] = " read" ;
419+ }
420+
402421 cases.push_back (util::genProcessTemplate (Templ, repl));
403422 hasDefault = true ;
404423 }
0 commit comments