5353namespace Regex = mstflint::common::regex;
5454namespace Algorithm = mstflint::common::algorithm;
5555
56- string addPathSuffixForArraySupport (string path)
57- {
58- if (path[path.length () - 1 ] == ' ]' )
59- { // Won't add suffix if leaf is in Array
60- return " " ;
61- }
62- size_t pos = 0 ;
63- string suffix = " " ;
64- while ((pos = path.find (" [" )) != std::string::npos)
65- { // Add array index number in path to suffix.
66- size_t end_pos = path.find (" ]" );
67- size_t len = end_pos - pos - 1 ;
68- suffix = suffix + " _" + path.substr (pos + 1 , len);
69- path.erase (0 , end_pos + 1 );
70- }
71- return suffix;
72- }
73-
7456template <bool e, typename T_OFFSET>
7557_AdbInstance_impl<e, T_OFFSET>::_AdbInstance_impl(AdbField* i_fieldDesc,
7658 AdbNode* i_nodeDesc,
@@ -366,6 +348,28 @@ string _AdbInstance_impl<e, O>::evalExpr(string expr, AttrsMap* vars)
366348 return expr;
367349}
368350
351+ /* *
352+ * Function: _AdbInstance_impl::addPathSuffixForArraySupport
353+ **/
354+ template <bool e, typename O>
355+ string _AdbInstance_impl<e, O>::addPathSuffixForArraySupport(string path)
356+ {
357+ if (path[path.length () - 1 ] == ' ]' )
358+ { // Won't add suffix if leaf is in Array
359+ return " " ;
360+ }
361+ size_t pos = 0 ;
362+ string suffix = " " ;
363+ while ((pos = path.find (" [" )) != std::string::npos)
364+ { // Add array index number in path to suffix.
365+ size_t end_pos = path.find (" ]" );
366+ size_t len = end_pos - pos - 1 ;
367+ suffix = suffix + " _" + path.substr (pos + 1 , len);
368+ path.erase (0 , end_pos + 1 );
369+ }
370+ return suffix;
371+ }
372+
369373/* *
370374 * Function: _AdbInstance_impl::_AdbInstance_impl
371375 **/
@@ -541,6 +545,37 @@ void _AdbInstance_impl<e, O>::init_props(unsigned char adabe_version) // logic o
541545 {
542546 return ;
543547 }
548+
549+ if (parent)
550+ {
551+ if (!parent->inst_props .valid_array_index )
552+ {
553+ inst_props.valid_array_index = 0 ;
554+ }
555+
556+ if (!inst_props.valid_array_index )
557+ {
558+ inst_props.access_r = 1 ;
559+ inst_props.access_w = 1 ;
560+ inst_props.is_semaphore = 0 ;
561+ }
562+ else
563+ {
564+ if (!parent->inst_props .access_w )
565+ {
566+ inst_props.access_w = 0 ;
567+ }
568+ if (!parent->inst_props .access_r )
569+ {
570+ inst_props.access_r = 0 ;
571+ }
572+ if (parent->inst_props .is_semaphore )
573+ {
574+ inst_props.is_semaphore = 1 ;
575+ }
576+ }
577+ }
578+
544579 if (isPartOfArray ())
545580 {
546581 string fiVal = getInstanceAttr (" valid_first_index" );
@@ -579,17 +614,28 @@ void _AdbInstance_impl<e, O>::init_props(unsigned char adabe_version) // logic o
579614 {
580615 sem = getInstanceAttr (" sem" );
581616 access_type = getInstanceAttr (" rw" );
617+ if (access_type.empty ())
618+ {
619+ access_type = getInstanceAttr (" access" );
620+ }
582621 if (!sem.empty ())
583622 {
584623 inst_props.is_semaphore = stoi (sem) > 0 ;
585624 }
586625 if (access_type == " WO" )
587626 {
588627 inst_props.access_r = 0 ;
628+ inst_props.access_w = 1 ;
589629 }
590630 else if (access_type == " RO" )
591631 {
592632 inst_props.access_w = 0 ;
633+ inst_props.access_r = 1 ;
634+ }
635+ else if (access_type == " RW" )
636+ {
637+ inst_props.access_r = 1 ;
638+ inst_props.access_w = 1 ;
593639 }
594640 }
595641
@@ -598,36 +644,6 @@ void _AdbInstance_impl<e, O>::init_props(unsigned char adabe_version) // logic o
598644 {
599645 inst_props.is_semaphore = stoi (sem) > 0 ;
600646 }
601-
602- if (parent)
603- {
604- if (!parent->inst_props .valid_array_index )
605- {
606- inst_props.valid_array_index = 0 ;
607- }
608-
609- if (!inst_props.valid_array_index )
610- {
611- inst_props.access_r = 1 ;
612- inst_props.access_w = 1 ;
613- inst_props.is_semaphore = 0 ;
614- }
615- else
616- {
617- // if (parent->inst_ops.access_r && !parent->inst_ops.access_w)
618- // {
619- // inst_ops.access_w = 0;
620- // }
621- // if (!parent->inst_ops.access_r && parent->inst_ops.access_w)
622- // {
623- // inst_ops.access_r = 0;
624- // }
625- if (parent->inst_props .is_semaphore )
626- {
627- inst_props.is_semaphore = 1 ;
628- }
629- }
630- }
631647}
632648
633649/* *
@@ -1046,7 +1062,7 @@ template<bool eval_expr, typename O>
10461062template <bool U>
10471063typename enable_if<U, _AdbCondition_impl<O>*>::type _AdbInstance_impl<eval_expr, O>::getCondition()
10481064{
1049- return &(inst_ops_props.condition );
1065+ return inst_ops_props. condition . get_condition (). empty () ? nullptr : &(inst_ops_props.condition );
10501066}
10511067
10521068template <bool eval_expr, typename O>
@@ -1056,6 +1072,20 @@ typename enable_if<!U, _AdbCondition_impl<O>*>::type _AdbInstance_impl<eval_expr
10561072 return nullptr ;
10571073}
10581074
1075+ template <bool eval_expr, typename O>
1076+ template <bool U>
1077+ typename enable_if<U, _AdbCondition_impl<O>*>::type _AdbInstance_impl<eval_expr, O>::getArraySizeCondition()
1078+ {
1079+ return inst_ops_props.conditionalSize .get_condition ().empty () ? nullptr : &(inst_ops_props.conditionalSize );
1080+ }
1081+
1082+ template <bool eval_expr, typename O>
1083+ template <bool U>
1084+ typename enable_if<!U, _AdbCondition_impl<O>*>::type _AdbInstance_impl<eval_expr, O>::getArraySizeCondition()
1085+ {
1086+ return nullptr ;
1087+ }
1088+
10591089/* *
10601090 * Function: _AdbInstance_impl::isEnumExists
10611091 **/
@@ -1290,7 +1320,7 @@ _AdbInstance_impl<e, O>* _AdbInstance_impl<e, O>::getUnionSelectedNodeName(const
12901320 }
12911321
12921322 throw AdbException (" Union selector field (" + unionSelector->layout_item_name +
1293- " ) doesn't define selector value (" + to_string (selectorVal));
1323+ " ) doesn't define selector value (" + to_string (selectorVal) + " ) " );
12941324}
12951325
12961326/* *
@@ -1347,6 +1377,30 @@ bool _AdbInstance_impl<e, O>::isConditionalNode()
13471377 return false ;
13481378}
13491379
1380+ /* *
1381+ * Function: _AdbInstance_impl::containsDynamicArray
1382+ **/
1383+ template <bool e, typename O>
1384+ bool _AdbInstance_impl<e, O>::containsDynamicArray()
1385+ {
1386+ if (!isNode ())
1387+ {
1388+ return false ;
1389+ }
1390+
1391+ _AdbInstance_impl<e, O>* last = nullptr ;
1392+ last = subItems.back ();
1393+ while (last)
1394+ {
1395+ if (last->fieldDesc ->array_type >= AdbField_impl<O>::ArrayType::unlimited)
1396+ {
1397+ return true ;
1398+ }
1399+ last = last->isNode () ? last->subItems .back () : nullptr ;
1400+ }
1401+ return false ;
1402+ }
1403+
13501404/* *
13511405 * Function: _AdbInstance_impl::isConditionValid
13521406 * Throws exception: AdbException
@@ -1420,7 +1474,8 @@ vector<_AdbInstance_impl<e, O>*> _AdbInstance_impl<e, O>::getLeafFields(bool ext
14201474 }
14211475 else
14221476 {
1423- subItems[i]->layout_item_name += addPathSuffixForArraySupport (subItems[i]->fullName ());
1477+ subItems[i]->layout_item_name +=
1478+ _AdbInstance_impl<e, O>::addPathSuffixForArraySupport (subItems[i]->fullName ());
14241479 }
14251480 subItems[i]->inst_props .is_name_extended = true ;
14261481 }
@@ -1504,6 +1559,22 @@ template typename enable_if<true, _AdbCondition_impl<uint32_t>*>::type
15041559 _AdbInstance_impl<true , uint32_t >::getCondition<true >();
15051560template typename enable_if<true , _AdbCondition_impl<uint64_t >*>::type
15061561 _AdbInstance_impl<true , uint64_t >::getCondition<true >();
1562+
1563+ template typename enable_if<!false , _AdbCondition_impl<uint32_t >*>::type
1564+ _AdbInstance_impl<false , uint32_t >::getCondition<false >();
1565+ template typename enable_if<!false , _AdbCondition_impl<uint64_t >*>::type
1566+ _AdbInstance_impl<false , uint64_t >::getCondition<false >();
1567+
1568+ template typename enable_if<true , _AdbCondition_impl<uint32_t >*>::type
1569+ _AdbInstance_impl<true , uint32_t >::getArraySizeCondition<true >();
1570+ template typename enable_if<true , _AdbCondition_impl<uint64_t >*>::type
1571+ _AdbInstance_impl<true , uint64_t >::getArraySizeCondition<true >();
1572+
1573+ template typename enable_if<!false , _AdbCondition_impl<uint32_t >*>::type
1574+ _AdbInstance_impl<false , uint32_t >::getArraySizeCondition<false >();
1575+ template typename enable_if<!false , _AdbCondition_impl<uint64_t >*>::type
1576+ _AdbInstance_impl<false , uint64_t >::getArraySizeCondition<false >();
1577+
15071578LayoutItemAttrsMap::LayoutItemAttrsMap (AttrsMap& field_desc_attrs) : _field_desc_attrs(field_desc_attrs) {}
15081579
15091580LayoutItemAttrsMap& LayoutItemAttrsMap::operator =(const LayoutItemAttrsMap& other)
0 commit comments