Merged wrap improvements back from develop branch

release/4.3a0
Frank Dellaert 2013-12-23 14:41:49 -05:00
parent b4344cfe16
commit 3b4fd765ec
4 changed files with 21 additions and 7 deletions

View File

@ -2,6 +2,12 @@
set(WRAP_BOOST_LIBRARIES ${Boost_SYSTEM_LIBRARY} ${Boost_FILESYSTEM_LIBRARY} ${Boost_THREAD_LIBRARY} ${Boost_REGEX_LIBRARY})
# Allow for disabling serialization to handle errors related to Clang's linker
option(GTSAM_WRAP_SERIALIZATION "If enabled, allows for wrapped objects to be saved via boost.serialization" ON)
if (NOT GTSAM_WRAP_SERIALIZATION)
add_definitions(-DWRAP_DISABLE_SERIALIZE)
endif()
# Build the executable itself
file(GLOB wrap_srcs "*.cpp")
file(GLOB wrap_headers "*.h")
@ -17,11 +23,9 @@ file(RELATIVE_PATH relative_path "${PROJECT_SOURCE_DIR}" "${CMAKE_CURRENT_SOURCE
set_target_properties(wrap_lib wrap PROPERTIES FOLDER "${relative_path}")
# Install wrap binary and export target
if (GTSAM_INSTALL_WRAP)
install(TARGETS wrap EXPORT GTSAM-exports DESTINATION bin)
list(APPEND GTSAM_EXPORTED_TARGETS wrap)
set(GTSAM_EXPORTED_TARGETS "${GTSAM_EXPORTED_TARGETS}" PARENT_SCOPE)
endif(GTSAM_INSTALL_WRAP)
install(TARGETS wrap EXPORT GTSAM-exports DESTINATION bin)
list(APPEND GTSAM_EXPORTED_TARGETS wrap)
set(GTSAM_EXPORTED_TARGETS "${GTSAM_EXPORTED_TARGETS}" PARENT_SCOPE)
# Install matlab header
install(FILES matlab.h DESTINATION include/wrap)

View File

@ -20,7 +20,7 @@
#include "Module.h"
#include "FileWriter.h"
#include "TypeAttributesTable.h"
#include "utilities.h"
#include "utilities.h"
//#define BOOST_SPIRIT_DEBUG
#include "spirit_actors.h"
@ -382,14 +382,22 @@ void Module::parseMarkup(const std::string& data) {
BOOST_FOREACH(Class& cls, classes) {
Class::Methods::iterator serializable_it = cls.methods.find("serializable");
if (serializable_it != cls.methods.end()) {
#ifndef WRAP_DISABLE_SERIALIZE
cls.isSerializable = true;
#else
cout << "Ignoring serializable() flag in class " << cls.name << endl;
#endif
cls.methods.erase(serializable_it);
}
Class::Methods::iterator serialize_it = cls.methods.find("serialize");
if (serialize_it != cls.methods.end()) {
#ifndef WRAP_DISABLE_SERIALIZE
cls.isSerializable = true;
cls.hasSerialization= true;
#else
cout << "Ignoring serialize() flag in class " << cls.name << endl;
#endif
cls.methods.erase(serialize_it);
}
}
@ -449,6 +457,7 @@ void Module::generateIncludes(FileWriter& file) const {
file.oss << "#include <" << *it << ">" << endl;
file.oss << "\n";
}
/* ************************************************************************* */
void Module::matlab_code(const string& toolboxPath, const string& headerPath) const {

View File

@ -225,6 +225,7 @@ mxArray* wrap<gtsam::Matrix >(const gtsam::Matrix& A) {
template <typename T>
T unwrap(const mxArray* array) {
error("wrap internal error: attempted unwrap of invalid type");
return T();
}
// specialization to string

View File

@ -58,7 +58,7 @@ TEST( wrap, ArgumentList ) {
}
/* ************************************************************************* */
TEST_UNSAFE( wrap, check_exception ) {
TEST( wrap, check_exception ) {
THROWS_EXCEPTION(Module("/notarealpath", "geometry",enable_verbose));
CHECK_EXCEPTION(Module("/alsonotarealpath", "geometry",enable_verbose), CantOpenFile);