Remove deprecated APIs in Tizen 3.0
[platform/core/uifw/dali-core.git] / dali / devel-api / scripting / enum-helper.h
1 #ifndef DALI_ENUM_HELPER_H
2 #define DALI_ENUM_HELPER_H
3
4 /*
5  * Copyright (c) 2018 Samsung Electronics Co., Ltd.
6  *
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  *
11  * http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  *
19  */
20
21 // INTERNAL INCLUDES
22 #include <dali/devel-api/scripting/scripting.h>
23
24 namespace Dali
25 {
26
27 /**
28  * Macros for creating value, typically enumerations, to string tables.
29  * Example:
30  *
31  * DALI_ENUM_TO_STRING_TABLE_BEGIN( SIZE_MODE )
32  * DALI_ENUM_TO_STRING( USE_OWN_SIZE )
33  * DALI_ENUM_TO_STRING( SIZE_EQUAL_TO_PARENT )
34  * DALI_ENUM_TO_STRING_TABLE_END( SIZE_MODE )
35  *
36  * Creates:
37  * const Scripting::StringEnum< SizeMode > SIZE_MODE_TABLE[] = {
38  * { "USE_OWN_SIZE", USE_OWN_SIZE },
39  * { "SIZE_EQUAL_TO_PARENT", SIZE_EQUAL_TO_PARENT },
40  * }; const unsigned int SIZE_MODE_TABLE_COUNT = sizeof( SIZE_MODE_TABLE ) / sizeof( SIZE_MODE_TABLE[0] );
41  *
42  * By default, Dali::Scripting::StringEnum is used as the type for the table, however, a different type can be specified by using
43  * DALI_ENUM_TO_STRING_TABLE_BEGIN_WITH_TYPE.
44  */
45 #define DALI_ENUM_TO_STRING_TABLE_BEGIN_WITH_TYPE( type, t ) const type t##_TABLE[] = {
46 #define DALI_ENUM_TO_STRING_TABLE_BEGIN( t ) DALI_ENUM_TO_STRING_TABLE_BEGIN_WITH_TYPE( Dali::Scripting::StringEnum, t )
47 #define DALI_ENUM_TO_STRING_TABLE_END( t )   }; const uint32_t t##_TABLE_COUNT = static_cast<uint32_t>( sizeof( t##_TABLE ) / sizeof( t##_TABLE[0] ) );
48 #define DALI_ENUM_TO_STRING( s ) { #s, s },
49
50 /**
51  * Adds a value, typically an enum, to the table within a scope but without the scope name
52  * Example converts ( Layer, LAYER_UI ) to ( "LAYER_UI", Layer::LayerUI )
53  */
54 #define DALI_ENUM_TO_STRING_WITH_SCOPE( className, enumName ) { #enumName, className::enumName },
55
56 } // namespace Dali
57
58 #endif // DALI_ENUM_HELPER_H