1 #ifndef DALI_ENUM_HELPER_H
2 #define DALI_ENUM_HELPER_H
5 * Copyright (c) 2018 Samsung Electronics Co., Ltd.
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
11 * http://www.apache.org/licenses/LICENSE-2.0
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.
22 #include <dali/devel-api/scripting/scripting.h>
28 * Macros for creating value, typically enumerations, to string tables.
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 )
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] );
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.
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 },
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 )
54 #define DALI_ENUM_TO_STRING_WITH_SCOPE( className, enumName ) { #enumName, className::enumName },
58 #endif // DALI_ENUM_HELPER_H