Change script for apply upstream code
[platform/upstream/connectedhomeip.git] / src / app / zap-templates / helper-chip.js
1 /*
2  *
3  *    Copyright (c) 2020 Project CHIP Authors
4  *
5  *    Licensed under the Apache License, Version 2.0 (the "License");
6  *    you may not use this file except in compliance with the License.
7  *    You may obtain a copy of the License at
8  *
9  *        http://www.apache.org/licenses/LICENSE-2.0
10  *
11  *    Unless required by applicable law or agreed to in writing, software
12  *    distributed under the License is distributed on an "AS IS" BASIS,
13  *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  *    See the License for the specific language governing permissions and
15  *    limitations under the License.
16  */
17
18 /**
19  * This module contains the API for templating. For more detailed instructions, read {@tutorial template-tutorial}
20  *
21  * @module Templating API: toplevel utility helpers
22  */
23
24 // Import Zcl helper from zap core
25 const helperZcl = require('../../../third_party/zap/repo/src-electron/generator/helper-zcl.js')
26
27 /**
28  * Dummy helper that add a string to the templates showing
29  * if the strings matches. Use to demonstrate the use
30  * of ZAP helper within the chip-helper environment
31  *
32  * @param {*} str1 : First string to compare
33  * @param {*} str2 : Second string to comapre
34  */
35 function example_helper(str1, str2) {
36   if (helperZcl.isStrEqual(str1, str2)) {
37     return 'The two strings are identical'
38   } else {
39     return 'The two strings are different'
40   }
41 }
42
43 /**
44  * Produces the top-of-the-file header for a C file.
45  *
46  * @returns The header content
47  */
48 function chip_header() {
49   return `
50   /*
51   *
52   *    Copyright (c) 2020 Project CHIP Authors
53   *
54   *    Licensed under the Apache License, Version 2.0 (the "License");
55   *    you may not use this file except in compliance with the License.
56   *    You may obtain a copy of the License at
57   *
58   *        http://www.apache.org/licenses/LICENSE-2.0
59   *
60   *    Unless required by applicable law or agreed to in writing, software
61   *    distributed under the License is distributed on an "AS IS" BASIS,
62   *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
63   *    See the License for the specific language governing permissions and
64   *    limitations under the License.
65   */`;
66 }
67
68 // WARNING! WARNING! WARNING! WARNING! WARNING! WARNING!
69 //
70 // Note: these exports are public API. Templates that might have been created in the past and are
71 // available in the wild might depend on these names.
72 // If you rename the functions, you need to still maintain old exports list.
73 exports.chip_header = chip_header;
74 exports.example_helper = example_helper;