Skip to content

Commit

Permalink
Use types from modules in complete type
Browse files Browse the repository at this point in the history
Signed-off-by: Raul Sanchez-Mateos <[email protected]>
  • Loading branch information
rsanchez15 committed Jun 27, 2023
1 parent 2041ae8 commit 44b86da
Show file tree
Hide file tree
Showing 13 changed files with 2,028 additions and 39 deletions.
148 changes: 128 additions & 20 deletions fastdds_python/test/types/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,23 +12,23 @@ if(POLICY CMP0086)
endif()

###############################################################################
# Library for types defined in test_complete IDL
# Library for types defined in test_modules IDL
###############################################################################

message(STATUS "Configuring python wrapper for types in test_complete...")
message(STATUS "Configuring python wrapper for types in test_modules...")

###############################################################################
# Type library on C++

project(test_complete)
project(test_modules)

find_package(fastcdr REQUIRED)
find_package(fastrtps REQUIRED)


set(${PROJECT_NAME}_FILES
test_complete.cxx
test_completePubSubTypes.cxx
test_modules.cxx
test_modulesPubSubTypes.cxx
)

include_directories()
Expand Down Expand Up @@ -57,7 +57,7 @@ set(PYTHON_LIBRARIES ${Python3_LIBRARIES})
include_directories(${PYTHON_INCLUDE_PATH})

set(${PROJECT_NAME}_MODULE
test_completeWrapper
test_modulesWrapper
)

set(${PROJECT_NAME}_MODULE_FILES
Expand All @@ -74,7 +74,7 @@ include_directories(
${PROJECT_SOURCE_DIR}
)

set_property(SOURCE ${PROJECT_NAME}.i PROPERTY OUTPUT_DIR "${CMAKE_CURRENT_BINARY_DIR}/")
set_property(SOURCE ${PROJECT_NAME}.i PROPERTY OUTPUT_DIR "${CMAKE_CURRENT_BINARY_DIR}/eprosima/test")

SWIG_ADD_LIBRARY(${${PROJECT_NAME}_MODULE}
TYPE SHARED
Expand All @@ -92,7 +92,7 @@ target_link_libraries(${${PROJECT_NAME}_MODULE}
)

set_target_properties(${${PROJECT_NAME}_MODULE}
PROPERTIES LIBRARY_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/"
PROPERTIES LIBRARY_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/eprosima/test"
)


Expand All @@ -114,28 +114,28 @@ install(TARGETS ${PROJECT_NAME}
LIBRARY DESTINATION lib/
ARCHIVE DESTINATION lib/
)
install(TARGETS ${${PROJECT_NAME}_MODULE} DESTINATION ${PYTHON_MODULE_PATH}/)
install(TARGETS ${${PROJECT_NAME}_MODULE} DESTINATION ${PYTHON_MODULE_PATH}/eprosima/test)
get_property(support_files TARGET ${${PROJECT_NAME}_MODULE} PROPERTY SWIG_SUPPORT_FILES)
install(FILES ${support_files} DESTINATION ${PYTHON_MODULE_PATH}/)
install(FILES ${support_files} DESTINATION ${PYTHON_MODULE_PATH}/eprosima/test)

###############################################################################
# Library for types defined in test_modules IDL
# Library for types defined in test_included_modules IDL
###############################################################################

message(STATUS "Configuring python wrapper for types in test_modules...")
message(STATUS "Configuring python wrapper for types in test_included_modules...")

###############################################################################
# Type library on C++

project(test_modules)
project(test_included_modules)

find_package(fastcdr REQUIRED)
find_package(fastrtps REQUIRED)


set(${PROJECT_NAME}_FILES
test_modules.cxx
test_modulesPubSubTypes.cxx
test_included_modules.cxx
test_included_modulesPubSubTypes.cxx
)

include_directories()
Expand Down Expand Up @@ -164,7 +164,7 @@ set(PYTHON_LIBRARIES ${Python3_LIBRARIES})
include_directories(${PYTHON_INCLUDE_PATH})

set(${PROJECT_NAME}_MODULE
test_modulesWrapper
test_included_modulesWrapper
)

set(${PROJECT_NAME}_MODULE_FILES
Expand All @@ -181,7 +181,7 @@ include_directories(
${PROJECT_SOURCE_DIR}
)

set_property(SOURCE ${PROJECT_NAME}.i PROPERTY OUTPUT_DIR "${CMAKE_CURRENT_BINARY_DIR}/eprosima/test")
set_property(SOURCE ${PROJECT_NAME}.i PROPERTY OUTPUT_DIR "${CMAKE_CURRENT_BINARY_DIR}/eprosima/test2")

SWIG_ADD_LIBRARY(${${PROJECT_NAME}_MODULE}
TYPE SHARED
Expand All @@ -199,7 +199,7 @@ target_link_libraries(${${PROJECT_NAME}_MODULE}
)

set_target_properties(${${PROJECT_NAME}_MODULE}
PROPERTIES LIBRARY_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/eprosima/test"
PROPERTIES LIBRARY_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/eprosima/test2"
)


Expand All @@ -221,7 +221,115 @@ install(TARGETS ${PROJECT_NAME}
LIBRARY DESTINATION lib/
ARCHIVE DESTINATION lib/
)
install(TARGETS ${${PROJECT_NAME}_MODULE} DESTINATION ${PYTHON_MODULE_PATH}/eprosima/test)
install(TARGETS ${${PROJECT_NAME}_MODULE} DESTINATION ${PYTHON_MODULE_PATH}/eprosima/test2)
get_property(support_files TARGET ${${PROJECT_NAME}_MODULE} PROPERTY SWIG_SUPPORT_FILES)
install(FILES ${support_files} DESTINATION ${PYTHON_MODULE_PATH}/eprosima/test)
install(FILES ${support_files} DESTINATION ${PYTHON_MODULE_PATH}/eprosima/test2)

###############################################################################
# Library for types defined in test_complete IDL
###############################################################################

message(STATUS "Configuring python wrapper for types in test_complete...")

###############################################################################
# Type library on C++

project(test_complete)

find_package(fastcdr REQUIRED)
find_package(fastrtps REQUIRED)


set(${PROJECT_NAME}_FILES
test_complete.cxx
test_completePubSubTypes.cxx
)

include_directories()

set(CMAKE_POSITION_INDEPENDENT_CODE ON)

#Create library for C++ types
add_library(${PROJECT_NAME} SHARED ${${PROJECT_NAME}_FILES})
if(WIN32)
target_compile_definitions(${PROJECT_NAME} PRIVATE EPROSIMA_USER_DLL_EXPORT)
endif(WIN32)
target_link_libraries(${PROJECT_NAME} PUBLIC fastcdr fastrtps)

###############################################################################
# Python bindings for type

find_package(SWIG REQUIRED)
include(${SWIG_USE_FILE})
set(CMAKE_SWIG_FLAGS "")

find_package(Python3 COMPONENTS Interpreter Development REQUIRED)
set(PYTHON_INCLUDE_PATH ${Python3_INCLUDE_DIRS})
set(PYTHON_EXECUTABLE ${Python3_EXECUTABLE})
set(PYTHON_LIBRARIES ${Python3_LIBRARIES})

include_directories(${PYTHON_INCLUDE_PATH})

set(${PROJECT_NAME}_MODULE
test_completeWrapper
)

set(${PROJECT_NAME}_MODULE_FILES
${PROJECT_NAME}.i
)

SET_SOURCE_FILES_PROPERTIES(
${${PROJECT_NAME}_MODULE_FILES}
PROPERTIES CPLUSPLUS ON
USE_TARGET_INCLUDE_DIRECTORIES TRUE
)

include_directories(
${PROJECT_SOURCE_DIR}
)

set_property(SOURCE ${PROJECT_NAME}.i PROPERTY OUTPUT_DIR "${CMAKE_CURRENT_BINARY_DIR}/")

SWIG_ADD_LIBRARY(${${PROJECT_NAME}_MODULE}
TYPE SHARED
LANGUAGE python
SOURCES ${${PROJECT_NAME}_MODULE_FILES})

if(UNIX AND CMAKE_SIZEOF_VOID_P EQUAL 8)
set_property(TARGET ${${PROJECT_NAME}_MODULE} PROPERTY SWIG_COMPILE_DEFINITIONS SWIGWORDSIZE64)
endif()

target_link_libraries(${${PROJECT_NAME}_MODULE}
Python3::Module
fastrtps
${PROJECT_NAME}
test_included_modules
)

set_target_properties(${${PROJECT_NAME}_MODULE}
PROPERTIES LIBRARY_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/"
)


# Find the installation path
execute_process(COMMAND ${PYTHON_EXECUTABLE} -c "from distutils import sysconfig; print(sysconfig.get_python_lib(plat_specific=True, prefix='${CMAKE_INSTALL_PREFIX}'))"
OUTPUT_VARIABLE _ABS_PYTHON_MODULE_PATH
OUTPUT_STRIP_TRAILING_WHITESPACE
)

get_filename_component (_ABS_PYTHON_MODULE_PATH ${_ABS_PYTHON_MODULE_PATH} ABSOLUTE)
file (RELATIVE_PATH _REL_PYTHON_MODULE_PATH ${CMAKE_INSTALL_PREFIX} ${_ABS_PYTHON_MODULE_PATH})
SET (PYTHON_MODULE_PATH
${_REL_PYTHON_MODULE_PATH}
)

# Install
install(TARGETS ${PROJECT_NAME}
RUNTIME DESTINATION bin/
LIBRARY DESTINATION lib/
ARCHIVE DESTINATION lib/
)
install(TARGETS ${${PROJECT_NAME}_MODULE} DESTINATION ${PYTHON_MODULE_PATH}/)
get_property(support_files TARGET ${${PROJECT_NAME}_MODULE} PROPERTY SWIG_SUPPORT_FILES)
install(FILES ${support_files} DESTINATION ${PYTHON_MODULE_PATH}/)

61 changes: 57 additions & 4 deletions fastdds_python/test/types/test_complete.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -34,19 +34,25 @@ using namespace eprosima::fastcdr::exception;

#include <utility>

#define CompleteTestType_max_cdr_typesize 40760ULL;
#define StructType_max_cdr_typesize 320ULL;
#define CompleteTestType_max_cdr_typesize 75640ULL;

#define StructType_max_cdr_typesize 640ULL;
#define eprosima_test2_StructType2_max_cdr_typesize 320ULL;


#define KeyedCompleteTestType_max_cdr_typesize 75648ULL;

#define KeyedCompleteTestType_max_cdr_typesize 40768ULL;
#define CompleteTestType_max_key_cdr_typesize 0ULL;

#define StructType_max_key_cdr_typesize 0ULL;
#define eprosima_test2_StructType2_max_key_cdr_typesize 0ULL;


#define KeyedCompleteTestType_max_key_cdr_typesize 4ULL;




StructType::StructType()
{
// char m_char_field
Expand Down Expand Up @@ -77,6 +83,8 @@ StructType::StructType()
m_enum_field = ::RED;
// Material m_enum2_field
m_enum2_field = ::WOOD;
// eprosima::test2::StructType2 m_included_module_struct


}

Expand All @@ -96,6 +104,7 @@ StructType::~StructType()




}

StructType::StructType(
Expand All @@ -115,6 +124,7 @@ StructType::StructType(
m_string_field = x.m_string_field;
m_enum_field = x.m_enum_field;
m_enum2_field = x.m_enum2_field;
m_included_module_struct = x.m_included_module_struct;
}

StructType::StructType(
Expand All @@ -134,6 +144,7 @@ StructType::StructType(
m_string_field = std::move(x.m_string_field);
m_enum_field = x.m_enum_field;
m_enum2_field = x.m_enum2_field;
m_included_module_struct = std::move(x.m_included_module_struct);
}

StructType& StructType::operator =(
Expand All @@ -154,6 +165,7 @@ StructType& StructType::operator =(
m_string_field = x.m_string_field;
m_enum_field = x.m_enum_field;
m_enum2_field = x.m_enum2_field;
m_included_module_struct = x.m_included_module_struct;

return *this;
}
Expand All @@ -176,6 +188,7 @@ StructType& StructType::operator =(
m_string_field = std::move(x.m_string_field);
m_enum_field = x.m_enum_field;
m_enum2_field = x.m_enum2_field;
m_included_module_struct = std::move(x.m_included_module_struct);

return *this;
}
Expand All @@ -184,7 +197,7 @@ bool StructType::operator ==(
const StructType& x) const
{

return (m_char_field == x.m_char_field && m_uint8_field == x.m_uint8_field && m_int16_field == x.m_int16_field && m_uint16_field == x.m_uint16_field && m_int32_field == x.m_int32_field && m_uint32_field == x.m_uint32_field && m_int64_field == x.m_int64_field && m_uint64_field == x.m_uint64_field && m_float_field == x.m_float_field && m_double_field == x.m_double_field && m_bool_field == x.m_bool_field && m_string_field == x.m_string_field && m_enum_field == x.m_enum_field && m_enum2_field == x.m_enum2_field);
return (m_char_field == x.m_char_field && m_uint8_field == x.m_uint8_field && m_int16_field == x.m_int16_field && m_uint16_field == x.m_uint16_field && m_int32_field == x.m_int32_field && m_uint32_field == x.m_uint32_field && m_int64_field == x.m_int64_field && m_uint64_field == x.m_uint64_field && m_float_field == x.m_float_field && m_double_field == x.m_double_field && m_bool_field == x.m_bool_field && m_string_field == x.m_string_field && m_enum_field == x.m_enum_field && m_enum2_field == x.m_enum2_field && m_included_module_struct == x.m_included_module_struct);
}

bool StructType::operator !=(
Expand Down Expand Up @@ -249,6 +262,7 @@ size_t StructType::getCdrSerializedSize(
current_alignment += 4 + eprosima::fastcdr::Cdr::alignment(current_alignment, 4);


current_alignment += eprosima::test2::StructType2::getCdrSerializedSize(data.included_module_struct(), current_alignment);

return current_alignment - initial_alignment;
}
Expand All @@ -271,6 +285,7 @@ void StructType::serialize(
scdr << m_string_field.c_str();
scdr << (uint32_t)m_enum_field;
scdr << (uint32_t)m_enum2_field;
scdr << m_included_module_struct;

}

Expand Down Expand Up @@ -302,6 +317,7 @@ void StructType::deserialize(
m_enum2_field = (Material)enum_value;
}

dcdr >> m_included_module_struct;
}

/*!
Expand Down Expand Up @@ -705,6 +721,43 @@ Material& StructType::enum2_field()
return m_enum2_field;
}

/*!
* @brief This function copies the value in member included_module_struct
* @param _included_module_struct New value to be copied in member included_module_struct
*/
void StructType::included_module_struct(
const eprosima::test2::StructType2& _included_module_struct)
{
m_included_module_struct = _included_module_struct;
}

/*!
* @brief This function moves the value in member included_module_struct
* @param _included_module_struct New value to be moved in member included_module_struct
*/
void StructType::included_module_struct(
eprosima::test2::StructType2&& _included_module_struct)
{
m_included_module_struct = std::move(_included_module_struct);
}

/*!
* @brief This function returns a constant reference to member included_module_struct
* @return Constant reference to member included_module_struct
*/
const eprosima::test2::StructType2& StructType::included_module_struct() const
{
return m_included_module_struct;
}

/*!
* @brief This function returns a reference to member included_module_struct
* @return Reference to member included_module_struct
*/
eprosima::test2::StructType2& StructType::included_module_struct()
{
return m_included_module_struct;
}


size_t StructType::getKeyMaxCdrSerializedSize(
Expand Down
Loading

0 comments on commit 44b86da

Please sign in to comment.