Commit 752d89a8 authored by Ronan's avatar Ronan

feat(Enums): provide useful macros to share enums between C/C++

parent 93c17c21
......@@ -19,17 +19,12 @@
#ifndef _C_TYPES_H_
#define _C_TYPES_H_
// Do not move this define.
// Enable C enums.
#define L_USE_C_ENUM
// TODO: Remove me in the future.
#include "linphone/types.h"
#include "linphone/utils/enum-generator.h"
#include "linphone/enums/event-log-enums.h"
#define L_DECLARE_C_ENUM(CLASS, ENUM, VALUES) enum Linphone ## CLASS ## ENUM { VALUES }
// =============================================================================
#ifdef __cplusplus
......@@ -105,7 +100,7 @@ typedef struct _LinphoneParticipant LinphoneParticipant;
// C Enums.
// =============================================================================
L_DECLARE_C_ENUM(EventLog, Type, L_ENUM_VALUES_EVENT_LOG_TYPE);
L_DECLARE_C_ENUM(EventLogType, L_ENUM_VALUES_EVENT_LOG_TYPE);
#ifdef __cplusplus
}
......
......@@ -19,22 +19,18 @@
#ifndef _EVENT_LOG_ENUMS_H_
#define _EVENT_LOG_ENUMS_H_
#include "linphone/utils/enum-generator.h"
// =============================================================================
#define L_ENUM_VALUES_EVENT_LOG_TYPE \
L_DECLARE_ENUM_VALUES(EventLog, Type, \
None, \
Message, \
CallStart, \
CallEnd, \
ConferenceCreated, \
ConferenceDestroyed, \
ConferenceParticipantAdded, \
ConferenceParticipantRemoved, \
ConferenceParticipantSetAdmin, \
ConferenceParticipantUnsetAdmin \
)
#define L_ENUM_VALUES_EVENT_LOG_TYPE(F) \
F(None) \
F(Message) \
F(CallStart) \
F(CallEnd) \
F(ConferenceCreated) \
F(ConferenceDestroyed) \
F(ConferenceParticipantAdded) \
F(ConferenceParticipantRemoved) \
F(ConferenceParticipantSetAdmin) \
F(ConferenceParticipantUnsetAdmin)
#endif // ifndef _EVENT_LOG_ENUMS_H_
......@@ -25,15 +25,37 @@
LINPHONE_BEGIN_NAMESPACE
#define L_ENUM_VALUE(C, VALUE) C ## VALUE
#ifndef L_USE_C_ENUM
#define L_DECLARE_ENUM_VALUES(CLASS_NAME, ENUM_NAME, ...) \
MM_APPLY_COMMA(L_ENUM_VALUE, ENUM_NAME, __VA_ARGS__)
#else
#define L_DECLARE_ENUM_VALUES(CLASS_NAME, ENUM_NAME, ...) \
MM_APPLY_COMMA(L_ENUM_VALUE, Linphone ## CLASS_NAME ## ENUM_NAME, __VA_ARGS__)
#endif // ifndef L_USE_C_ENUM
// -----------------------------------------------------------------------------
// Low-level, do not call.
// -----------------------------------------------------------------------------
// Declare one enum value. `value` is optional, it can be generated.
// It's useful to force value in the case of mask.
#define L_DECLARE_ENUM_VALUE_1_ARGS(NAME) NAME,
#define L_DECLARE_ENUM_VALUE_2_ARGS(NAME, VALUE) NAME = VALUE,
// Call the right macro. (With or without value.)
#define L_DECLARE_ENUM_MACRO_CHOOSER(...) \
L_GET_ARG_3(__VA_ARGS__, L_DECLARE_ENUM_VALUE_2_ARGS, L_DECLARE_ENUM_VALUE_1_ARGS)
// Enum value declaration.
#define L_DECLARE_ENUM_VALUE(...) L_DECLARE_ENUM_MACRO_CHOOSER(__VA_ARGS__)(__VA_ARGS__)
// -----------------------------------------------------------------------------
// Public API.
// -----------------------------------------------------------------------------
#define L_DECLARE_ENUM(NAME, VALUES) \
enum class NAME { \
VALUES(L_DECLARE_ENUM_VALUE) \
};
#define L_C_ENUM_PREFIX Linphone
#define L_DECLARE_C_ENUM(NAME, VALUES) \
enum L_CONCAT(L_C_ENUM_PREFIX, NAME) { \
L_APPLY(L_CONCAT, L_CONCAT(L_C_ENUM_PREFIX, NAME), L_GET_HEAP(VALUES(L_DECLARE_ENUM_VALUE))) \
};
LINPHONE_END_NAMESPACE
......
......@@ -21,220 +21,145 @@
#include "linphone/utils/general.h"
// =============================================================================
// Original header.
// Source: https://github.com/facebookresearch/ELF/blob/master/elf/pybind_helper.h
// =============================================================================
/**
* Copyright (c) 2017-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*/
// File: macros.h
// Author: Yuxin Wu <ppwwyyxxc@gmail.com>
// =============================================================================
LINPHONE_BEGIN_NAMESPACE
#define MM_CONCAT__(A, B) A ## B
#define MM_CONCAT_(A, B) MM_CONCAT__(A, B)
#define MM_CONCAT(A, B) MM_CONCAT_(A, B)
#define MM_INVOKE(MACRO, ARGS) MACRO ARGS
#define MM_INVOKE_B(MACRO, ARGS) MACRO ARGS
#define MM_APPLY_1(MACRONAME, C, A1) \
MM_INVOKE_B(MACRONAME, (C, A1))
#define MM_APPLY_2(MACRONAME, C, A1, A2) \
MM_INVOKE_B(MACRONAME, (C, A1)) \
MM_APPLY_1(MACRONAME, C, A2)
#define MM_APPLY_3(MACRONAME, C, A1, A2, A3) \
MM_INVOKE_B(MACRONAME, (C, A1)) \
MM_APPLY_2(MACRONAME, C, A2, A3)
#define MM_APPLY_4(MACRONAME, C, A1, A2, A3, A4) \
MM_INVOKE_B(MACRONAME, (C, A1)) \
MM_APPLY_3(MACRONAME, C, A2, A3, A4)
#define MM_APPLY_5(MACRONAME, C, A1, A2, A3, A4, A5) \
MM_INVOKE_B(MACRONAME, (C, A1)) \
MM_APPLY_4(MACRONAME, C, A2, A3, A4, A5)
#define MM_APPLY_6(MACRONAME, C, A1, A2, A3, A4, A5, A6) \
MM_INVOKE_B(MACRONAME, (C, A1)) \
MM_APPLY_5(MACRONAME, C, A2, A3, A4, A5, A6)
#define MM_APPLY_7(MACRONAME, C, A1, A2, A3, A4, A5, A6, A7) \
MM_INVOKE_B(MACRONAME, (C, A1)) \
MM_APPLY_6(MACRONAME, C, A2, A3, A4, A5, A6, A7)
#define MM_APPLY_8(MACRONAME, C, A1, A2, A3, A4, A5, A6, A7, A8) \
MM_INVOKE_B(MACRONAME, (C, A1)) \
MM_APPLY_7(MACRONAME, C, A2, A3, A4, A5, A6, A7, A8)
#define MM_APPLY_9(MACRONAME, C, A1, A2, A3, A4, A5, A6, A7, A8, A9) \
MM_INVOKE_B(MACRONAME, (C, A1)) \
MM_APPLY_8(MACRONAME, C, A2, A3, A4, A5, A6, A7, A8, A9)
#define MM_APPLY_10(MACRONAME, C, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10) \
MM_INVOKE_B(MACRONAME, (C, A1)) \
MM_APPLY_9(MACRONAME, C, A2, A3, A4, A5, A6, A7, A8, A9, A10)
#define MM_APPLY_11(MACRONAME, C, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11) \
MM_INVOKE_B(MACRONAME, (C, A1)) \
MM_APPLY_10(MACRONAME, C, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11)
#define MM_APPLY_12(MACRONAME, C, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12) \
MM_INVOKE_B(MACRONAME, (C, A1)) \
MM_APPLY_11(MACRONAME, C, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12)
#define MM_APPLY_13(MACRONAME, C, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13) \
MM_INVOKE_B(MACRONAME, (C, A1)) \
MM_APPLY_12(MACRONAME, C, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13)
#define MM_APPLY_14(MACRONAME, C, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14) \
MM_INVOKE_B(MACRONAME, (C, A1)) \
MM_APPLY_13(MACRONAME, C, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14)
#define MM_APPLY_15(MACRONAME, C, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, A15) \
MM_INVOKE_B(MACRONAME, (C, A1)) \
MM_APPLY_14(MACRONAME, C, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, A15)
#define MM_APPLY_16(MACRONAME, C, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, A15, A16) \
MM_INVOKE_B(MACRONAME, (C, A1)) \
MM_APPLY_15(MACRONAME, C, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, A15, A16)
#define MM_APPLY_17(MACRONAME, C, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, A15, A16, A17) \
MM_INVOKE_B(MACRONAME, (C, A1)) \
MM_APPLY_16(MACRONAME, C, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, A15, A16, A17)
#define MM_APPLY_18(MACRONAME, C, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, A15, A16, A17, A18) \
MM_INVOKE_B(MACRONAME, (C, A1)) \
MM_APPLY_17(MACRONAME, C, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, A15, A16, A17, A18)
#define MM_APPLY_19(MACRONAME, C, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, A15, A16, A17, A18, A19) \
MM_INVOKE_B(MACRONAME, (C, A1)) \
MM_APPLY_18(MACRONAME, C, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, A15, A16, A17, A18, A19)
#define MM_APPLY_20(MACRONAME, C, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, A15, A16, A17, A18, A19, A20) \
MM_INVOKE_B(MACRONAME, (C, A1)) \
MM_APPLY_19(MACRONAME, C, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, A15, A16, A17, A18, A19, A20)
#define MM_APPLY_21(MACRONAME, C, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, A15, A16, A17, A18, A19, A20, A21) \
MM_INVOKE_B(MACRONAME, (C, A1)) \
MM_APPLY_20(MACRONAME, C, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, A15, A16, A17, A18, A19, A20, A21)
#define MM_APPLY_22(MACRONAME, C, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, A15, A16, A17, A18, A19, A20, A21, A22) \
MM_INVOKE_B(MACRONAME, (C, A1)) \
MM_APPLY_21(MACRONAME, C, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, A15, A16, A17, A18, A19, A20, A21, A22)
#define MM_NARG(...) \
MM_NARG_(__VA_ARGS__, MM_RSEQ_N())
#define MM_NARG_(...) \
MM_ARG_N(__VA_ARGS__)
#define MM_ARG_N( \
_1, _2, _3, _4, _5, _6, _7, _8, _9, _10, \
_11, _12, _13, _14, _15, _16, _17, _18, _19, _20, \
_21, _22, _23, _24, _25, _26, _27, _28, _29, _30, \
_31, _32, _33, _34, _35, _36, _37, _38, _39, _40, \
_41, _42, _43, _44, _45, _46, _47, _48, _49, _50, \
_51, _52, _53, _54, _55, _56, _57, _58, _59, _60, \
_61, _62, _63, N, ...) N
#define MM_RSEQ_N() \
63, 62, 61, 60, \
59, 58, 57, 56, 55, 54, 53, 52, 51, 50, \
49, 48, 47, 46, 45, 44, 43, 42, 41, 40, \
39, 38, 37, 36, 35, 34, 33, 32, 31, 30, \
29, 28, 27, 26, 25, 24, 23, 22, 21, 20, \
19, 18, 17, 16, 15, 14, 13, 12, 11, 10, \
9, 8, 7, 6, 5, 4, 3, 2, 1, 0
#define MM_APPLY(MACRONAME, C, ...) \
MM_INVOKE( \
MM_CONCAT(MM_APPLY_, MM_NARG(__VA_ARGS__)), \
(MACRONAME, C, __VA_ARGS__) \
// Concat in depth context.
#define L_CONCAT__(A, B) A ## B
#define L_CONCAT_(A, B) L_CONCAT__(A, B)
#define L_CONCAT(A, B) L_CONCAT_(A, B)
// Get argument numbers from variadic.
#define L_ARG_N( \
A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, \
A11, A12, A13, A14, A15, A16, N, ... \
) N
#define L_GET_N_ARGS_HELPER(...) L_ARG_N(__VA_ARGS__)
#define L_GET_N_ARGS(...) L_GET_N_ARGS_HELPER( \
__VA_ARGS__, \
16, 15, 14, 13, 12, 11, 10, \
9, 8, 7, 6, 5, 4, 3, 2, 1, 0 \
)
// Get argument numbers - 1 from variadic.
#define L_GET_N_ARGS_SUB(X, ...) L_GET_N_ARGS(__VA_ARGS__)
// Get argument from variadic macro.
#define L_GET_ARG_1(A1, ...) A1
#define L_GET_ARG_2(A1, A2, ...) A2
#define L_GET_ARG_3(A1, A2, A3, ...) A3
#define L_GET_ARG_4(A1, A2, A3, A4, ...) A4
#define L_GET_ARG_5(A1, A2, A3, A4, A5, ...) A5
#define L_GET_ARG_6(A1, A2, A3, A4, A5, A6, ...) A6
#define L_GET_ARG_7(A1, A2, A3, A4, A5, A6, A7, ...) A7
#define L_GET_ARG_8(A1, A2, A3, A4, A5, A6, A7, A8, ...) A8
#define L_GET_ARG_9(A1, A2, A3, A4, A5, A6, A7, A8, A9, ...) A9
#define L_GET_ARG_10(A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, ...) A10
#define L_GET_ARG_11(A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, ...) A11
#define L_GET_ARG_12(A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, ...) A12
#define L_GET_ARG_13(A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, ...) A13
#define L_GET_ARG_14(A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, ...) A14
#define L_GET_ARG_15(A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, A15, ...) A15
#define L_GET_ARG_16(A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, A15, A16, ...) A16
// Get left part of variadic.
#define L_GET_HEAP_1(A1, ...) A1
#define L_GET_HEAP_2(A1, A2, ...) A1, A2
#define L_GET_HEAP_3(A1, A2, A3, ...) A1, A2, A3
#define L_GET_HEAP_4(A1, A2, A3, A4, ...) A1, A2, A3, A4
#define L_GET_HEAP_5(A1, A2, A3, A4, A5, ...) A1, A2, A3, A4, A5
#define L_GET_HEAP_6(A1, A2, A3, A4, A5, A6, ...) A1, A2, A3, A4, A5, A6
#define L_GET_HEAP_7(A1, A2, A3, A4, A5, A6, A7, ...) A1, A2, A3, A4, A5, A6, A7
#define L_GET_HEAP_8(A1, A2, A3, A4, A5, A6, A7, A8, ...) A1, A2, A3, A4, A5, A6, A7, A8
#define L_GET_HEAP_9(A1, A2, A3, A4, A5, A6, A7, A8, A9, ...) A1, A2, A3, A4, A5, A6, A7, A8, A9
#define L_GET_HEAP_10(A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, ...) A1, A2, A3, A4, A5, A6, A7, A8, A9, A10
#define L_GET_HEAP_11(A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, ...) A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11
#define L_GET_HEAP_12(A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, ...) A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12
#define L_GET_HEAP_13(A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, ...) A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13
#define L_GET_HEAP_14(A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, ...) A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14
#define L_GET_HEAP_15(A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, A15, ...) A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, A15
#define L_GET_HEAP_16(A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, A15, A16, ...) A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, A15, A16
#define L_GET_HEAP(...) \
L_CONCAT(L_GET_HEAP_, L_GET_N_ARGS_SUB(__VA_ARGS__)) (__VA_ARGS__)
// Call a macro on args.
#define L_CALL(MACRO, ARGS) MACRO ARGS
#define L_CALL_HELPER(MACRO, ARGS) MACRO ARGS
// Map each variadic args.
#define L_APPLY_1(MACRONAME, DATA, A1) \
L_CALL_HELPER(MACRONAME, (DATA, A1))
#define L_APPLY_2(MACRONAME, DATA, A1, A2) \
L_CALL_HELPER(MACRONAME, (DATA, A1)), \
L_APPLY_1(MACRONAME, DATA, A2)
#define L_APPLY_3(MACRONAME, DATA, A1, A2, A3) \
L_CALL_HELPER(MACRONAME, (DATA, A1)), \
L_APPLY_2(MACRONAME, DATA, A2, A3)
#define L_APPLY_4(MACRONAME, DATA, A1, A2, A3, A4) \
L_CALL_HELPER(MACRONAME, (DATA, A1)), \
L_APPLY_3(MACRONAME, DATA, A2, A3, A4)
#define L_APPLY_5(MACRONAME, DATA, A1, A2, A3, A4, A5) \
L_CALL_HELPER(MACRONAME, (DATA, A1)), \
L_APPLY_4(MACRONAME, DATA, A2, A3, A4, A5)
#define L_APPLY_6(MACRONAME, DATA, A1, A2, A3, A4, A5, A6) \
L_CALL_HELPER(MACRONAME, (DATA, A1)), \
L_APPLY_5(MACRONAME, DATA, A2, A3, A4, A5, A6)
#define L_APPLY_7(MACRONAME, DATA, A1, A2, A3, A4, A5, A6, A7) \
L_CALL_HELPER(MACRONAME, (DATA, A1)), \
L_APPLY_6(MACRONAME, DATA, A2, A3, A4, A5, A6, A7)
#define L_APPLY_8(MACRONAME, DATA, A1, A2, A3, A4, A5, A6, A7, A8) \
L_CALL_HELPER(MACRONAME, (DATA, A1)), \
L_APPLY_7(MACRONAME, DATA, A2, A3, A4, A5, A6, A7, A8)
#define L_APPLY_9(MACRONAME, DATA, A1, A2, A3, A4, A5, A6, A7, A8, A9) \
L_CALL_HELPER(MACRONAME, (DATA, A1)), \
L_APPLY_8(MACRONAME, DATA, A2, A3, A4, A5, A6, A7, A8, A9)
#define L_APPLY_10(MACRONAME, DATA, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10) \
L_CALL_HELPER(MACRONAME, (DATA, A1)), \
L_APPLY_9(MACRONAME, DATA, A2, A3, A4, A5, A6, A7, A8, A9, A10)
#define L_APPLY_11(MACRONAME, DATA, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11) \
L_CALL_HELPER(MACRONAME, (DATA, A1)), \
L_APPLY_10(MACRONAME, DATA, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11)
#define L_APPLY_12(MACRONAME, DATA, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12) \
L_CALL_HELPER(MACRONAME, (DATA, A1)), \
L_APPLY_11(MACRONAME, DATA, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12)
#define L_APPLY_13(MACRONAME, DATA, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13) \
L_CALL_HELPER(MACRONAME, (DATA, A1)), \
L_APPLY_12(MACRONAME, DATA, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13)
#define L_APPLY_14(MACRONAME, DATA, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14) \
L_CALL_HELPER(MACRONAME, (DATA, A1)), \
L_APPLY_13(MACRONAME, DATA, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14)
#define L_APPLY_15(MACRONAME, DATA, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, A15) \
L_CALL_HELPER(MACRONAME, (DATA, A1)), \
L_APPLY_14(MACRONAME, DATA, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, A15)
#define L_APPLY_16(MACRONAME, DATA, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, A15, A16) \
L_CALL_HELPER(MACRONAME, (DATA, A1)), \
L_APPLY_15(MACRONAME, DATA, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, A15, A16)
#define L_APPLY(MACRONAME, DATA, ...) \
L_CALL( \
L_CONCAT(L_APPLY_, L_GET_N_ARGS(__VA_ARGS__)), \
(MACRONAME, DATA, __VA_ARGS__) \
)
#define MM_APPLY_COMMA(MACRONAME, C, ...) \
MM_INVOKE( \
MM_CONCAT(MM_APPLY_COMMA_, MM_NARG(__VA_ARGS__)), \
(MACRONAME, C, __VA_ARGS__) \
)
#define MM_APPLY_COMMA_1(MACRONAME, C, A1) \
MM_INVOKE_B(MACRONAME, (C, A1))
#define MM_APPLY_COMMA_2(MACRONAME, C, A1, A2) \
MM_INVOKE_B(MACRONAME, (C, A1)), \
MM_APPLY_COMMA_1(MACRONAME, C, A2)
#define MM_APPLY_COMMA_3(MACRONAME, C, A1, A2, A3) \
MM_INVOKE_B(MACRONAME, (C, A1)), \
MM_APPLY_COMMA_2(MACRONAME, C, A2, A3)
#define MM_APPLY_COMMA_4(MACRONAME, C, A1, A2, A3, A4) \
MM_INVOKE_B(MACRONAME, (C, A1)), \
MM_APPLY_COMMA_3(MACRONAME, C, A2, A3, A4)
#define MM_APPLY_COMMA_5(MACRONAME, C, A1, A2, A3, A4, A5) \
MM_INVOKE_B(MACRONAME, (C, A1)), \
MM_APPLY_COMMA_4(MACRONAME, C, A2, A3, A4, A5)
#define MM_APPLY_COMMA_6(MACRONAME, C, A1, A2, A3, A4, A5, A6) \
MM_INVOKE_B(MACRONAME, (C, A1)), \
MM_APPLY_COMMA_5(MACRONAME, C, A2, A3, A4, A5, A6)
#define MM_APPLY_COMMA_7(MACRONAME, C, A1, A2, A3, A4, A5, A6, A7) \
MM_INVOKE_B(MACRONAME, (C, A1)), \
MM_APPLY_COMMA_6(MACRONAME, C, A2, A3, A4, A5, A6, A7)
#define MM_APPLY_COMMA_8(MACRONAME, C, A1, A2, A3, A4, A5, A6, A7, A8) \
MM_INVOKE_B(MACRONAME, (C, A1)), \
MM_APPLY_COMMA_7(MACRONAME, C, A2, A3, A4, A5, A6, A7, A8)
#define MM_APPLY_COMMA_9(MACRONAME, C, A1, A2, A3, A4, A5, A6, A7, A8, A9) \
MM_INVOKE_B(MACRONAME, (C, A1)), \
MM_APPLY_COMMA_8(MACRONAME, C, A2, A3, A4, A5, A6, A7, A8, A9)
#define MM_APPLY_COMMA_10(MACRONAME, C, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10) \
MM_INVOKE_B(MACRONAME, (C, A1)), \
MM_APPLY_COMMA_9(MACRONAME, C, A2, A3, A4, A5, A6, A7, A8, A9, A10)
#define MM_APPLY_COMMA_11(MACRONAME, C, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11) \
MM_INVOKE_B(MACRONAME, (C, A1)), \
MM_APPLY_COMMA_10(MACRONAME, C, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11)
#define MM_APPLY_COMMA_12(MACRONAME, C, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12) \
MM_INVOKE_B(MACRONAME, (C, A1)), \
MM_APPLY_COMMA_11(MACRONAME, C, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12)
#define MM_APPLY_COMMA_13(MACRONAME, C, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13) \
MM_INVOKE_B(MACRONAME, (C, A1)), \
MM_APPLY_COMMA_12(MACRONAME, C, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13)
#define MM_APPLY_COMMA_14(MACRONAME, C, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14) \
MM_INVOKE_B(MACRONAME, (C, A1)), \
MM_APPLY_COMMA_13(MACRONAME, C, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14)
#define MM_APPLY_COMMA_15(MACRONAME, C, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, A15) \
MM_INVOKE_B(MACRONAME, (C, A1)), \
MM_APPLY_COMMA_14(MACRONAME, C, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, A15)
#define MM_APPLY_COMMA_16(MACRONAME, C, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, A15, A16) \
MM_INVOKE_B(MACRONAME, (C, A1)), \
MM_APPLY_COMMA_15(MACRONAME, C, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, A15, A16)
LINPHONE_END_NAMESPACE
#endif // ifndef _MAGIC_MACROS_H_
......@@ -281,17 +281,17 @@ EventsDb::EventsDb () : AbstractDb(*new EventsDbPrivate) {}
// TODO.
switch (eventLog.getType()) {
case EventLog::TypeNone:
case EventLog::Type::None:
return false;
case EventLog::TypeMessage:
case EventLog::TypeCallStart:
case EventLog::TypeCallEnd:
case EventLog::TypeConferenceCreated:
case EventLog::TypeConferenceDestroyed:
case EventLog::TypeConferenceParticipantAdded:
case EventLog::TypeConferenceParticipantRemoved:
case EventLog::TypeConferenceParticipantSetAdmin:
case EventLog::TypeConferenceParticipantUnsetAdmin:
case EventLog::Type::Message:
case EventLog::Type::CallStart:
case EventLog::Type::CallEnd:
case EventLog::Type::ConferenceCreated:
case EventLog::Type::ConferenceDestroyed:
case EventLog::Type::ConferenceParticipantAdded:
case EventLog::Type::ConferenceParticipantRemoved:
case EventLog::Type::ConferenceParticipantSetAdmin:
case EventLog::Type::ConferenceParticipantUnsetAdmin:
break;
}
......
......@@ -36,7 +36,7 @@ public:
CallEvent::CallEvent (Type type, const shared_ptr<Call> &call) : EventLog(*new CallEventPrivate, type) {
L_D(CallEvent);
L_ASSERT(call);
L_ASSERT(type == TypeCallStart || type == TypeCallEnd);
L_ASSERT(type == Type::CallStart || type == Type::CallEnd);
d->call = call;
}
......
......@@ -30,7 +30,7 @@ LINPHONE_BEGIN_NAMESPACE
ConferenceEvent::ConferenceEvent (Type type, const shared_ptr<const Address> &address) :
EventLog(*new ConferenceEventPrivate, type) {
L_D(ConferenceEvent);
L_ASSERT(type == TypeConferenceCreated || type == TypeConferenceDestroyed);
L_ASSERT(type == Type::ConferenceCreated || type == Type::ConferenceDestroyed);
L_ASSERT(address);
d->address = make_shared<Address>(*address);
}
......
......@@ -41,10 +41,10 @@ ConferenceParticipantEvent::ConferenceParticipantEvent (
) : ConferenceEvent(*new ConferenceParticipantEventPrivate, type, conferenceAddress) {
L_D(ConferenceParticipantEvent);
L_ASSERT(
type == TypeConferenceParticipantAdded ||
type == TypeConferenceParticipantRemoved ||
type == TypeConferenceParticipantSetAdmin ||
type == TypeConferenceParticipantUnsetAdmin
type == Type::ConferenceParticipantAdded ||
type == Type::ConferenceParticipantRemoved ||
type == Type::ConferenceParticipantSetAdmin ||
type == Type::ConferenceParticipantUnsetAdmin
);
L_ASSERT(participantAddress);
d->participantAddress = make_shared<Address>(*participantAddress);
......
......@@ -28,7 +28,7 @@ LINPHONE_BEGIN_NAMESPACE
class EventLogPrivate : public ClonableObjectPrivate {
private:
EventLog::Type type = EventLog::TypeNone;
EventLog::Type type = EventLog::Type::None;
L_DECLARE_PUBLIC(EventLog);
};
......
......@@ -20,6 +20,7 @@
#define _EVENT_LOG_H_
#include "linphone/enums/event-log-enums.h"
#include "linphone/utils/enum-generator.h"
#include "object/clonable-object.h"
......@@ -31,9 +32,7 @@ class EventLogPrivate;
class LINPHONE_PUBLIC EventLog : public ClonableObject {
public:
enum Type {
L_ENUM_VALUES_EVENT_LOG_TYPE
};
L_DECLARE_ENUM(Type, L_ENUM_VALUES_EVENT_LOG_TYPE);
EventLog ();
EventLog (const EventLog &src);
......
......@@ -34,7 +34,7 @@ public:
// -----------------------------------------------------------------------------
MessageEvent::MessageEvent (const shared_ptr<Message> &message) :
EventLog(*new MessageEventPrivate, EventLog::TypeMessage) {
EventLog(*new MessageEventPrivate, EventLog::Type::Message) {
L_D(MessageEvent);
L_ASSERT(message);
d->message = message;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment