• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2021-2023 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 RENDER_SERVICE_CLIENT_CORE_COMMON_RS_MACROS_H
16 #define RENDER_SERVICE_CLIENT_CORE_COMMON_RS_MACROS_H
17 
18 namespace OHOS {
19 namespace Rosen {
20 /** about export template (most at _WIN32 platform)
21  *  Sometimes other module maybe use instantiated template classes or instantiate their own template class.
22  *  for example: arkui will use RSRenderAnimatableProperty<float> and instantiate the template
23  *      with type "NG::ColorBlend", so we need export instantiated template classes but cannot export
24  *      template itself. Because if you RSB_EXPORT the template, arkui will think the symbol
25  *      RSRenderAnimatableProperty<NG::ColorBlend> is importing from other module,
26  *      linker then raise a link problem.
27  *
28  *  So we should use RSB_EXPORT_TMP and use extern template & template to tell arkui that there are many
29  *      instantiated template classes, you don't need instantiate again.
30  *
31  *  correct way:
32  *      base view:
33  *          EXPORT RSRenderAnimatableProperty<T>
34  *          extern template class RSRenderAnimatableProperty<float>;
35  *          (in cpp) template class RSRenderAnimatableProperty<float>;
36  *      arkui view:
37  *                 RSRenderAnimatableProperty<T>
38  *          extern template class RSRenderAnimatableProperty<float>;
39  */
40 
41 #ifdef _WIN32
42 #define RS_EXPORT __attribute__((dllexport))
43 #define RS_IMPORT __attribute__((dllimport))
44 #else
45 #define RS_EXPORT __attribute__((visibility("default")))
46 #define RS_IMPORT __attribute__((visibility("default")))
47 #endif
48 
49 #ifdef MODULE_RSB
50 #define RSB_EXPORT      RS_EXPORT
51 #define RSB_EXPORT_TMP  RS_EXPORT
52 #else
53 #define RSB_EXPORT      RS_IMPORT
54 #define RSB_EXPORT_TMP
55 #endif
56 
57 #ifdef MODULE_RSC
58 #define RSC_EXPORT      RS_EXPORT
59 #define RSC_EXPORT_TMP  RS_EXPORT
60 #else
61 #define RSC_EXPORT      RS_IMPORT
62 #define RSC_EXPORT_TMP
63 #endif
64 
65 #ifdef __gnu_linux__
66 #define __libcpp_erase_if_container __detail::__erase_nodes_if
67 #endif
68 } // namespace Rosen
69 } // namespace OHOS
70 #endif // RENDER_SERVICE_CLIENT_CORE_COMMON_RS_MACROS_H
71