Commit 69d52b3e authored by Benjamin REIS's avatar Benjamin REIS

fix private attribute access in tester

parent c98ce07b
......@@ -176,7 +176,6 @@ set(SOURCE_FILES_C
eventapi_tester.c
flexisip_tester.c
liblinphone_tester.c
liblinphone_tester.h
log_collection_tester.c
message_tester.c
offeranswer_tester.c
......@@ -205,6 +204,12 @@ set(SOURCE_FILES_CXX
property-container-tester.cpp
)
set(HEADER_FILES
liblinphone_tester.h
tools/private-access.h
tools/tester.h
)
set(SOURCE_FILES_OBJC )
if(APPLE)
if (IOS)
......@@ -241,7 +246,7 @@ endif()
# on mobile platforms, we compile the tester as a library so that we can link with it directly from native applications
if(ANDROID OR IOS)
add_library(linphonetester SHARED ${SOURCE_FILES_C} ${SOURCE_FILES_CXX})
add_library(linphonetester SHARED ${HEADER_FILES} ${SOURCE_FILES_C} ${SOURCE_FILES_CXX})
target_include_directories(linphonetester PUBLIC ${BCTOOLBOX_TESTER_INCLUDE_DIRS})
target_link_libraries(linphonetester ${LINPHONE_LIBS_FOR_TOOLS} ${OTHER_LIBS_FOR_TESTER})
if(IOS)
......@@ -262,7 +267,7 @@ if(ANDROID OR IOS)
PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ
)
elseif(CMAKE_SYSTEM_NAME STREQUAL "WindowsStore")
add_library(linphone_tester_static STATIC ${SOURCE_FILES_C} ${SOURCE_FILES_CXX})
add_library(linphone_tester_static STATIC ${HEADER_FILES} ${SOURCE_FILES_C} ${SOURCE_FILES_CXX})
target_include_directories(linphone_tester_static PUBLIC ${BCTOOLBOX_TESTER_INCLUDE_DIRS})
target_link_libraries(linphone_tester_static ${LINPHONE_LIBS_FOR_TOOLS} ${OTHER_LIBS_FOR_TESTER})
......@@ -296,9 +301,9 @@ endif()
if (NOT ANDROID AND NOT CMAKE_SYSTEM_NAME STREQUAL "WindowsStore")
if(IOS)
set_source_files_properties(${IOS_RESOURCES_FILES} PROPERTIES MACOSX_PACKAGE_LOCATION Resources)
add_executable(liblinphone_tester MACOSX_BUNDLE ${IOS_RESOURCES_FILES} ${SOURCE_FILES_C} ${SOURCE_FILES_CXX} ${SOURCE_FILES_OBJC})
add_executable(liblinphone_tester MACOSX_BUNDLE ${IOS_RESOURCES_FILES} ${HEADER_FILES} ${SOURCE_FILES_C} ${SOURCE_FILES_CXX} ${SOURCE_FILES_OBJC})
else()
add_executable(liblinphone_tester ${SOURCE_FILES_C} ${SOURCE_FILES_CXX} ${SOURCE_FILES_OBJC})
add_executable(liblinphone_tester ${HEADER_FILES} ${SOURCE_FILES_C} ${SOURCE_FILES_CXX} ${SOURCE_FILES_OBJC})
endif()
set_target_properties(liblinphone_tester PROPERTIES LINK_FLAGS "${LINPHONE_LDFLAGS}")
set_target_properties(liblinphone_tester PROPERTIES LINKER_LANGUAGE CXX)
......
......@@ -30,6 +30,8 @@
#include <type_traits>
#include "linphone/utils/utils.h"
#define L_INTERNAL_STRUCT_L_ATTR_GET(CLASS, ATTR_NAME) AttrGet ## _ ## CLASS ## _ ## ATTR_NAME
#define L_INTERNAL_STRUCT_ATTR_SPY(ATTR_NAME) AttrSpy ## _ ## ATTR_NAME
......@@ -54,8 +56,8 @@
// Warning: Allow to modify const data.
// Returns a ref to `ATTR_NAME`.
#define L_ATTR_GET(OBJECT, ATTR_NAME) \
(const_cast<std::remove_const<decltype(OBJECT)>::type &>(OBJECT)).*get( \
static_cast<L_INTERNAL_STRUCT_ATTR_SPY(ATTR_NAME)<std::decay<decltype(OBJECT)>::type> *>(nullptr) \
(const_cast<std::remove_pointer<std::decay<decltype(OBJECT)>::type>::type *>(LinphonePrivate::Utils::getPtr(OBJECT)))->*get( \
static_cast<L_INTERNAL_STRUCT_ATTR_SPY(ATTR_NAME)<std::remove_pointer<std::decay<decltype(OBJECT)>::type>::type> *>(nullptr) \
)
#endif // ifndef _PRIVATE_ACCESS_H_
......@@ -22,7 +22,7 @@
#include <utility>
#include "utils/utils.h"
#include "linphone/utils/utils.h"
// =============================================================================
......@@ -35,7 +35,7 @@ LINPHONE_BEGIN_NAMESPACE
class Tester {
public:
Tester () = delete;
template<typename Object>
static constexpr decltype(std::declval<Object>().getPrivate()) getPrivate (Object *cppObject) {
return cppObject->getPrivate();
......
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