@@ -44,50 +44,33 @@ const kGlobalAttributes = [
4444 0xfffd , // FeatureMap
4545] ;
4646
47+ let configData = undefined ;
48+ function getConfigData ( global ) {
49+ if ( configData === undefined ) {
50+ let f = global . resource ( 'config-data' ) ;
51+ // NOTE: This has to be sync, so we can use this data in if conditions.
52+ let rawData = fs . readFileSync ( f , { encoding : 'utf8' , flag : 'r' } ) ;
53+ configData = YAML . parse ( rawData ) ;
54+ }
55+ return configData ;
56+ }
57+
58+ function isInConfigList ( string , listName )
59+ {
60+ const data = getConfigData ( this . global ) ;
61+ return data [ listName ] . includes ( string ) ;
62+ }
63+
4764// Endpoint-config specific helpers
4865// these helpers are a Hot fix for the "GENERATED_FUNCTIONS" problem
4966// They should be removed or replace once issue #4369 is resolved
5067// These helpers only works within the endpoint_config iterator
5168
52- // List of all cluster with generated functions
53- const endpointClusterWithInit = [
54- 'Basic' ,
55- 'Color Control' ,
56- 'Groups' ,
57- 'Identify' ,
58- 'Level Control' ,
59- 'Localization Configuration' ,
60- 'Occupancy Sensing' ,
61- 'On/Off' ,
62- 'Pump Configuration and Control' ,
63- 'Scenes' ,
64- 'Time Format Localization' ,
65- 'Thermostat' ,
66- 'Mode Select' ,
67- ] ;
68- const endpointClusterWithAttributeChanged = [
69- 'Bridged Device Basic' ,
70- 'Door Lock' ,
71- 'Identify' ,
72- 'Pump Configuration and Control' ,
73- 'Window Covering' ,
74- 'Fan Control' ,
75- ] ;
76- const endpointClusterWithPreAttribute = [
77- 'Door Lock' ,
78- 'Pump Configuration and Control' ,
79- 'Thermostat User Interface Configuration' ,
80- 'Time Format Localization' ,
81- 'Localization Configuration' ,
82- 'Mode Select' ,
83- 'Fan Control' ,
84- 'Thermostat' ,
85- ] ;
86-
8769/**
8870 * Populate the GENERATED_FUNCTIONS field
8971 */
9072function chip_endpoint_generated_functions ( ) {
73+ const configData = getConfigData ( this . global ) ;
9174 let alreadySetCluster = [ ] ;
9275 let ret = '\\\n' ;
9376 this . clusterList . forEach ( ( c ) => {
@@ -99,7 +82,7 @@ function chip_endpoint_generated_functions() {
9982 }
10083 if ( c . comment . includes ( 'server' ) ) {
10184 let hasFunctionArray = false ;
102- if ( endpointClusterWithInit . includes ( clusterName ) ) {
85+ if ( configData . ClustersWithInitFunctions . includes ( clusterName ) ) {
10386 hasFunctionArray = true ;
10487 functionList = functionList . concat (
10588 ` (EmberAfGenericClusterFunction) emberAf${ cHelper . asCamelCased (
@@ -109,7 +92,7 @@ function chip_endpoint_generated_functions() {
10992 ) ;
11093 }
11194
112- if ( endpointClusterWithAttributeChanged . includes ( clusterName ) ) {
95+ if ( configData . ClustersWithAttributeChangedFunctions . includes ( clusterName ) ) {
11396 functionList = functionList . concat (
11497 ` (EmberAfGenericClusterFunction) Matter${ cHelper . asCamelCased (
11598 clusterName ,
@@ -119,7 +102,7 @@ function chip_endpoint_generated_functions() {
119102 hasFunctionArray = true ;
120103 }
121104
122- if ( endpointClusterWithPreAttribute . includes ( clusterName ) ) {
105+ if ( configData . ClustersWithPreAttributeChangeFunctions . includes ( clusterName ) ) {
123106 functionList = functionList . concat (
124107 ` (EmberAfGenericClusterFunction) Matter${ cHelper . asCamelCased (
125108 clusterName ,
@@ -216,6 +199,7 @@ function chip_endpoint_generated_event_list(options) {
216199 * includes the GENERATED_FUNCTIONS array
217200 */
218201function chip_endpoint_cluster_list ( ) {
202+ const configData = getConfigData ( this . global ) ;
219203 let ret = '{ \\\n' ;
220204 let totalCommands = 0 ;
221205 this . clusterList . forEach ( ( c ) => {
@@ -225,17 +209,17 @@ function chip_endpoint_cluster_list() {
225209
226210 if ( c . comment . includes ( 'server' ) ) {
227211 let hasFunctionArray = false ;
228- if ( endpointClusterWithInit . includes ( clusterName ) ) {
212+ if ( configData . ClustersWithInitFunctions . includes ( clusterName ) ) {
229213 c . mask . push ( 'INIT_FUNCTION' ) ;
230214 hasFunctionArray = true ;
231215 }
232216
233- if ( endpointClusterWithAttributeChanged . includes ( clusterName ) ) {
217+ if ( configData . ClustersWithAttributeChangedFunctions . includes ( clusterName ) ) {
234218 c . mask . push ( 'ATTRIBUTE_CHANGED_FUNCTION' ) ;
235219 hasFunctionArray = true ;
236220 }
237221
238- if ( endpointClusterWithPreAttribute . includes ( clusterName ) ) {
222+ if ( configData . ClustersWithPreAttributeChangeFunctions . includes ( clusterName ) ) {
239223 c . mask . push ( 'PRE_ATTRIBUTE_CHANGED_FUNCTION' ) ;
240224 hasFunctionArray = true ;
241225 }
@@ -829,30 +813,6 @@ function getPythonFieldDefault(type, options) {
829813 return _getPythonFieldDefault . call ( this , type , options ) ;
830814}
831815
832- // Allow-list of enums that we generate as enums, not enum classes. The goal is
833- // to drive this down to 0.
834- let weakEnumList = undefined ;
835- function isWeaklyTypedEnum ( label ) {
836- if ( weakEnumList === undefined ) {
837- let f = this . global . resource ( 'weak-enum-list' ) ;
838- // NOTE: This has to be sync, so we can use this data in if conditions.
839- let rawData = fs . readFileSync ( f , { encoding : 'utf8' , flag : 'r' } ) ;
840- weakEnumList = YAML . parse ( rawData ) ;
841- }
842- return weakEnumList . includes ( label ) ;
843- }
844-
845- let legacyStructList = undefined ;
846- function isLegacyStruct ( label ) {
847- if ( legacyStructList === undefined ) {
848- let f = this . global . resource ( 'legacy-struct-list' ) ;
849- // NOTE: This has to be sync, so we can use this data in if conditions.
850- let rawData = fs . readFileSync ( f , { encoding : 'utf8' , flag : 'r' } ) ;
851- legacyStructList = YAML . parse ( rawData ) ;
852- }
853- return legacyStructList . includes ( label ) ;
854- }
855-
856816function incrementDepth ( depth ) {
857817 return depth + 1 ;
858818}
@@ -966,8 +926,7 @@ exports.zapTypeToEncodableClusterObjectType =
966926exports . zapTypeToDecodableClusterObjectType =
967927 zapTypeToDecodableClusterObjectType ;
968928exports . zapTypeToPythonClusterObjectType = zapTypeToPythonClusterObjectType ;
969- exports . isWeaklyTypedEnum = isWeaklyTypedEnum ;
970- exports . isLegacyStruct = isLegacyStruct ;
929+ exports . isInConfigList = isInConfigList ;
971930exports . getPythonFieldDefault = getPythonFieldDefault ;
972931exports . incrementDepth = incrementDepth ;
973932exports . zcl_events_fields_by_event_name = zcl_events_fields_by_event_name ;
0 commit comments