1 #ifndef DALI_ENUM_HELPER_H
2 #define DALI_ENUM_HELPER_H
5 * Copyright (c) 2020 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>
27 * Macros for creating value, typically enumerations, to string tables.
30 * DALI_ENUM_TO_STRING_TABLE_BEGIN( SIZE_MODE )
31 * DALI_ENUM_TO_STRING( USE_OWN_SIZE )
32 * DALI_ENUM_TO_STRING( SIZE_EQUAL_TO_PARENT )
33 * DALI_ENUM_TO_STRING_TABLE_END( SIZE_MODE )
36 * const Scripting::StringEnum< SizeMode > SIZE_MODE_TABLE[] = {
37 * { "USE_OWN_SIZE", USE_OWN_SIZE },
38 * { "SIZE_EQUAL_TO_PARENT", SIZE_EQUAL_TO_PARENT },
39 * }; const unsigned int SIZE_MODE_TABLE_COUNT = sizeof( SIZE_MODE_TABLE ) / sizeof( SIZE_MODE_TABLE[0] );
41 * By default, Dali::Scripting::StringEnum is used as the type for the table, however, a different type can be specified by using
42 * DALI_ENUM_TO_STRING_TABLE_BEGIN_WITH_TYPE.
44 #define DALI_ENUM_TO_STRING_TABLE_BEGIN_WITH_TYPE(type, t) const type t##_TABLE[] = {
45 #define DALI_ENUM_TO_STRING_TABLE_BEGIN(t) DALI_ENUM_TO_STRING_TABLE_BEGIN_WITH_TYPE(Dali::Scripting::StringEnum, t)
46 #define DALI_ENUM_TO_STRING_TABLE_END(t) \
49 const uint32_t t##_TABLE_COUNT = static_cast<uint32_t>(sizeof(t##_TABLE) / sizeof(t##_TABLE[0]));
50 #define DALI_ENUM_TO_STRING(s) {#s, s},
53 * Adds a value, typically an enum, to the table within a scope but without the scope name
54 * Example converts ( Layer, LAYER_UI ) to ( "LAYER_UI", Layer::LayerUI )
56 #define DALI_ENUM_TO_STRING_WITH_SCOPE(className, enumName) {#enumName, className::enumName},
60 #endif // DALI_ENUM_HELPER_H