• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2021-2022 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 #ifndef DEFINE_MULTIMODAL_H
16 #define DEFINE_MULTIMODAL_H
17 
18 #include "mmi_log.h"
19 
20 #ifndef RET_OK
21     #define RET_OK (0)
22 #endif
23 
24 #ifndef RET_ERR
25     #define RET_ERR (-1)
26 #endif
27 
28 #ifndef LINEINFO
29 #define LINEINFO __FILE__, __LINE__
30 #endif
31 
32 #if defined(__GNUC__) && __GNUC__ >= 4
33     #define WL_EXPORT __attribute__ ((visibility("default")))
34 #else
35     #define WL_EXPORT
36 #endif
37 
38 #ifdef DEBUG_CODE_TEST
39 #define CHKPL(cond, ...) \
40     do { \
41         if ((cond) == nullptr) { \
42             MMI_LOGE("%{public}s, (%{public}d), CHKPL(%{public}s) is null, do nothing", \
43                 __FILE__, __LINE__, #cond); \
44         } \
45     } while (0)
46 
47 #define CHKPV(cond) \
48     do { \
49         if ((cond) == nullptr) { \
50             MMI_LOGE("%{public}s, (%{public}d), CHKPV(%{public}s) is null", \
51                 __FILE__, __LINE__, #cond); \
52             return; \
53         } \
54     } while (0)
55 
56 #define CHKPF(cond) \
57     do { \
58         if ((cond) == nullptr) { \
59             MMI_LOGE("%{public}s, (%{public}d), CHKPF(%{public}s) is null", \
60                 __FILE__, __LINE__, #cond); \
61             return false; \
62         } \
63     } while (0)
64 
65 #define CHKPC(cond) \
66     { \
67         if ((cond) == nullptr) { \
68             MMI_LOGE("%{public}s, (%{public}d), CHKPC(%{public}s) is null, skip then continue", \
69                 __FILE__, __LINE__, #cond); \
70             continue; \
71         } \
72     }
73 
74 #define CHKPB(cond) \
75     { \
76         if ((cond) == nullptr) { \
77             MMI_LOGE("%{public}s, (%{public}d), CHKPC(%{public}s) is null, skip then break", \
78                 __FILE__, __LINE__, #cond); \
79             break; \
80         } \
81     }
82 
83 #define CHKPR(cond, r) \
84     do { \
85         if ((cond) == nullptr) { \
86             MMI_LOGE("%{public}s, (%{public}d), CHKPR(%{public}s) is null, return value is %{public}d", \
87                 __FILE__, __LINE__, #cond, r); \
88             return r; \
89         } \
90     } while (0)
91 
92 #define CHKPP(cond) \
93     do { \
94         if ((cond) == nullptr) { \
95             MMI_LOGE("%{public}s, (%{public}d), CHKPP(%{public}s) is null, return value is null", \
96                 __FILE__, __LINE__, #cond); \
97             return nullptr; \
98         } \
99     } while (0)
100 
101 #define CK(cond, ec) \
102     do { \
103         if (!(cond)) { \
104             MMI_LOGE("%{public}s, (%{public}d), CK(%{public}s), errCode:%{public}d", \
105                 __FILE__, __LINE__, #cond, ec); \
106         } \
107     } while (0)
108 
109 #define CHK(cond, ec) \
110     do { \
111         if (!(cond)) { \
112             MMI_LOGE("%{public}s, (%{public}d), CHK(%{public}s), errCode:%{public}d", \
113                 __FILE__, __LINE__, #cond, ec); \
114             return; \
115         } \
116     } while (0)
117 
118 #define CHKF(cond, ec) \
119     do { \
120         if (!(cond)) { \
121             MMI_LOGE("%{public}s, (%{public}d), CHKF(%{public}s), errCode:%{public}d", \
122                 __FILE__, __LINE__, #cond, ec); \
123             return false; \
124         } \
125     } while (0)
126 
127 #define CHKC(cond, ec) \
128     { \
129         if (!(cond)) { \
130             MMI_LOGE("%{public}s, (%{public}d), CHKC(%{public}s), errCode:%{public}d", \
131                 __FILE__, __LINE__, #cond, ec); \
132             continue; \
133         } \
134     }
135 
136 #define CHKR(cond, ec, r) \
137     do { \
138         if (!(cond)) { \
139             MMI_LOGE("%{public}s, (%{public}d), CHKR(%{public}s), errCode:%{public}d", \
140                 __FILE__, __LINE__, #cond, ec); \
141             return r; \
142         } \
143     } while (0)
144 
145 #else // DEBUG_CODE_TEST
146 #define CHKPL(cond) \
147     do { \
148         if ((cond) == nullptr) { \
149             MMI_LOGE("CHKPL(%{public}s) is null, do nothing", #cond); \
150         } \
151     } while (0)
152 
153 #define CHKPV(cond) \
154     do { \
155         if ((cond) == nullptr) { \
156             MMI_LOGE("CHKPV(%{public}s) is null", #cond); \
157             return; \
158         } \
159     } while (0)
160 
161 #define CHKPF(cond) \
162     do { \
163         if ((cond) == nullptr) { \
164             MMI_LOGE("CHKPF(%{public}s) is null", #cond); \
165             return false; \
166         } \
167     } while (0)
168 
169 #define CHKPC(cond) \
170     { \
171         if ((cond) == nullptr) { \
172             MMI_LOGE("CHKPC(%{public}s) is null, skip then continue", #cond); \
173             continue; \
174         } \
175     }
176 
177 #define CHKPB(cond) \
178     { \
179         if ((cond) == nullptr) { \
180             MMI_LOGE("CHKPC(%{public}s) is null, skip then break", #cond); \
181             break; \
182         } \
183     }
184 
185 #define CHKPR(cond, r) \
186     do { \
187         if ((cond) == nullptr) { \
188             MMI_LOGE("CHKPR(%{public}s) is null, return value is %{public}d", #cond, r); \
189             return r; \
190         } \
191     } while (0)
192 
193 #define CHKPP(cond) \
194     do { \
195         if ((cond) == nullptr) { \
196             MMI_LOGE("CHKPP(%{public}s) is null, return value is null", #cond); \
197             return nullptr; \
198         } \
199     } while (0)
200 
201 #define CK(cond, ec) \
202     do { \
203         if (!(cond)) { \
204             MMI_LOGE("CK(%{public}s), errCode:%{public}d", #cond, ec); \
205         } \
206     } while (0)
207 
208 #define CHK(cond, ec) \
209     do { \
210         if (!(cond)) { \
211             MMI_LOGE("CHK(%{public}s), errCode:%{public}d", #cond, ec); \
212             return; \
213         } \
214     } while (0)
215 
216 #define CHKF(cond, ec) \
217     do { \
218         if (!(cond)) { \
219             MMI_LOGE("CHKF(%{public}s), errCode:%{public}d", #cond, ec); \
220             return 0; \
221         } \
222     } while (0)
223 
224 #define CHKC(cond, ec) \
225     { \
226         if (!(cond)) { \
227             MMI_LOGE("CHKC(%{public}s), errCode:%{public}d", #cond, ec); \
228             continue; \
229         } \
230     }
231 
232 #define CHKR(cond, ec, r) \
233     do { \
234         if (!(cond)) { \
235             MMI_LOGE("CHKR(%{public}s), errCode:%{public}d", #cond, ec); \
236             return r; \
237         } \
238     } while (0)
239 
240 #endif
241 #endif // DEFINE_MULTIMODAL_H