diff --git a/include/linphone/utils/magic-macros.h b/include/linphone/utils/magic-macros.h index 0e34ba076..c1ba0b946 100644 --- a/include/linphone/utils/magic-macros.h +++ b/include/linphone/utils/magic-macros.h @@ -39,6 +39,9 @@ LINPHONE_BEGIN_NAMESPACE #define L_EXPAND(X) X +// Useful in depth context. +#define L_STRINGIFY(X) #X + #define L_GET_N_ARGS(...) L_EXPAND(L_ARG_N( \ __VA_ARGS__, \ 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, \ diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index e81f97dde..59ddaffc1 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -168,6 +168,7 @@ set(LINPHONE_CXX_OBJECTS_SOURCE_FILES c-wrapper/api/c-event-log.cpp c-wrapper/api/c-participant.cpp c-wrapper/internal/c-sal.cpp + c-wrapper/internal/c-tools.cpp call/call.cpp call/local-conference-call.cpp call/remote-conference-call.cpp diff --git a/src/c-wrapper/internal/c-tools.cpp b/src/c-wrapper/internal/c-tools.cpp new file mode 100644 index 000000000..32fb869b4 --- /dev/null +++ b/src/c-wrapper/internal/c-tools.cpp @@ -0,0 +1,42 @@ +/* + * c-tools.cpp + * Copyright (C) 2010-2018 Belledonne Communications SARL + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +#ifdef DEBUG + #include +#endif + +#include "c-tools.h" +#include "object/base-object.h" +#include "object/clonable-object.h" + +// ============================================================================= + +LINPHONE_BEGIN_NAMESPACE + +#ifdef DEBUG + void Wrapper::setName (belle_sip_object_t *cObject, const BaseObject *cppObject) { + belle_sip_object_set_name(cObject, typeid(*cppObject).name()); + } + + void Wrapper::setName (belle_sip_object_t *cObject, const ClonableObject *cppObject) { + belle_sip_object_set_name(cObject, typeid(*cppObject).name()); + } +#endif + +LINPHONE_END_NAMESPACE diff --git a/src/c-wrapper/internal/c-tools.h b/src/c-wrapper/internal/c-tools.h index 6ade0e552..55d12a33b 100644 --- a/src/c-wrapper/internal/c-tools.h +++ b/src/c-wrapper/internal/c-tools.h @@ -142,6 +142,15 @@ private: CppType *cppPtr; }; + // --------------------------------------------------------------------------- + // Debug tools. + // --------------------------------------------------------------------------- + + #ifdef DEBUG + static void setName (belle_sip_object_t *cObject, const BaseObject *cppObject); + static void setName (belle_sip_object_t *cObject, const ClonableObject *cppObject); + #endif + // --------------------------------------------------------------------------- // Runtime checker. // --------------------------------------------------------------------------- @@ -393,6 +402,10 @@ public: if (oldCppObject) oldCppObject->setCBackPtr(nullptr); cppObject->setCBackPtr(cObject); + + #ifdef DEBUG + setName(reinterpret_cast(cObject), cppObject.get()); + #endif } template< @@ -408,6 +421,10 @@ public: *cppObjectAddr = cppObject; (*cppObjectAddr)->setCBackPtr(cObject); + + #ifdef DEBUG + setName(reinterpret_cast(cObject), cppObject); + #endif } template<