@@ -682,7 +682,8 @@ generate_entity_properties(
682
682
683
683
const char * opt = is_optional (decl ) ? "true" : "false" ;
684
684
if (idl_is_struct (type_spec )
685
- || idl_is_union (type_spec )) {
685
+ || idl_is_union (type_spec )
686
+ || idl_is_enum (type_spec )) {
686
687
char * type = NULL ;
687
688
if (IDL_PRINTA (& type , get_cpp11_fully_scoped_name , type_spec , streams -> generator ) < 0 )
688
689
return IDL_RETCODE_NO_MEMORY ;
@@ -762,20 +763,6 @@ generate_entity_properties(
762
763
IDL_ANY:
763
764
IDL_LDOUBLE:*/
764
765
}
765
- } else if (idl_is_enum (type_spec )) {
766
- const idl_enum_t * en = type_spec ;
767
- bb = "bb_32_bits" ;
768
- if (en -> bit_bound .annotation ) {
769
- if (en -> bit_bound .value > 32 ) {
770
- bb = "bb_64_bits" ;
771
- } else if (en -> bit_bound .value > 16 ) {
772
- bb = "bb_32_bits" ;
773
- } else if (en -> bit_bound .value > 8 ) {
774
- bb = "bb_16_bits" ;
775
- } else {
776
- bb = "bb_8_bits" ;
777
- }
778
- }
779
766
} else if (idl_is_bitmask (type_spec )) {
780
767
const idl_bitmask_t * bm = type_spec ;
781
768
bb = "bb_32_bits" ;
@@ -1102,10 +1089,10 @@ print_constructed_type_open(struct streams *streams, const idl_node_t *node)
1102
1089
" {\n"
1103
1090
" static std::mutex mtx;\n"
1104
1091
" static entity_properties_t props;\n"
1105
- " static bool initialized = false;\n\n"
1092
+ " static bool initialized = false;\n"
1093
+ " std::lock_guard<std::mutex> lock(mtx);\n\n"
1106
1094
" if (initialized)\n"
1107
1095
" return props;\n\n"
1108
- " std::lock_guard<std::mutex> lock(mtx);\n"
1109
1096
" props.clear();\n"
1110
1097
" key_endpoint keylist;\n\n" ;
1111
1098
static const char * sfmt =
@@ -1489,11 +1476,21 @@ process_enum(
1489
1476
if (IDL_PRINTA (& fullname , get_cpp11_fully_scoped_name , _enum , gen ) < 0 )
1490
1477
return IDL_RETCODE_NO_MEMORY ;
1491
1478
1492
- static const char * fmt = "template<>\n" \
1493
- "%s enum_conversion<%s>(uint32_t in)%s" ;
1494
-
1495
- if (putf (& str -> props , fmt , fullname , fullname , " {\n switch (in) {\n" )
1496
- || idl_fprintf (gen -> header .handle , fmt , fullname , fullname , ";\n\n" ) < 0 )
1479
+ static const char * conv_func = "template<>\n" \
1480
+ "%s enum_conversion<%s>(uint32_t in)%s" ,
1481
+ * prop_func = "template<>\n" \
1482
+ "entity_properties_t get_type_props<%s>()%s" ,
1483
+ * prop_func_contents = " {\n"
1484
+ "entity_properties_t props;\n" ,
1485
+ * prop_func_close =
1486
+ " props.m_members_by_seq.push_back(final_entry());\n"
1487
+ " props.m_members_by_id.push_back(final_entry());\n"
1488
+ " props.m_keys.push_back(final_entry());\n"
1489
+ " return props;\n"
1490
+ "}\n\n" ;
1491
+
1492
+ if (putf (& str -> props , conv_func , fullname , fullname , " {\n switch (in) {\n" )
1493
+ || idl_fprintf (gen -> header .handle , conv_func , fullname , fullname , ";\n\n" ) < 0 )
1497
1494
return IDL_RETCODE_NO_MEMORY ;
1498
1495
1499
1496
/*count the number of enumerators*/
@@ -1533,16 +1530,34 @@ process_enum(
1533
1530
}
1534
1531
}
1535
1532
1533
+ //generate entity properties function for enums
1534
+ uint16_t bb = 32 ;
1535
+ if (_enum -> bit_bound .annotation ) {
1536
+ if (_enum -> bit_bound .value > 32 )
1537
+ bb = 64 ;
1538
+ else if (_enum -> bit_bound .value > 16 )
1539
+ bb = 32 ;
1540
+ else if (_enum -> bit_bound .value > 8 )
1541
+ bb = 16 ;
1542
+ else
1543
+ bb = 8 ;
1544
+ }
1545
+
1546
+ if (putf (& str -> props ," }\n}\n\n" ) ||
1547
+ putf (& str -> props , prop_func , fullname , prop_func_contents ) ||
1548
+ idl_fprintf (gen -> header .handle , prop_func , fullname , ";\n\n" ) < 0 ||
1549
+ (_enum -> extensibility .value != IDL_FINAL &&
1550
+ putf (& str -> props , " props.e_ext = extensibility::%s;\n props.xtypes_necessary = true;\n" , _enum -> extensibility .value == IDL_APPENDABLE ? "ext_appendable" : "ext_mutable" )) ||
1551
+ putf (& str -> props , " props.e_bb = bb_%" PRIu16 "_bits;\n" , bb ) ||
1552
+ putf (& str -> props , prop_func_close )) {
1553
+ ret = IDL_RETCODE_NO_MEMORY ;
1554
+ }
1555
+
1536
1556
/*cleanup*/
1537
1557
if (already_encountered )
1538
1558
free (already_encountered );
1539
- if (ret )
1540
- return ret ;
1541
1559
1542
- if (putf (& str -> props ," }\n}\n\n" ))
1543
- return IDL_RETCODE_NO_MEMORY ;
1544
-
1545
- return IDL_RETCODE_OK ;
1560
+ return ret ;
1546
1561
}
1547
1562
1548
1563
idl_retcode_t
0 commit comments