From 9780af72d94a2e572c20e0011b333ba6babc844c Mon Sep 17 00:00:00 2001 From: Frank Dellaert Date: Fri, 21 Oct 2011 05:34:53 +0000 Subject: [PATCH] Added UNSAFE_WRAP flag that omits type-checking, to allow for GaussianFactor -> JacobianFactor inheritance. TODO: how can we have type safety AND inheritance? --- wrap/Makefile.am | 2 +- wrap/matlab.h | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/wrap/Makefile.am b/wrap/Makefile.am index ee1db45c8..895830537 100644 --- a/wrap/Makefile.am +++ b/wrap/Makefile.am @@ -52,7 +52,7 @@ interfacePath = $(top_srcdir) moduleName = gtsam toolboxpath = ../toolbox nameSpace = "gtsam" -mexFlags = "${BOOST_CPPFLAGS} -I${prefix}/include -I${prefix}/include/gtsam -I${prefix}/include/gtsam/base -I${prefix}/include/gtsam/geometry -I${prefix}/include/gtsam/linear -I${prefix}/include/gtsam/nonlinear -I${prefix}/include/gtsam/slam -L${exec_prefix}/lib -lgtsam" +mexFlags = "${BOOST_CPPFLAGS} -DUNSAFE_WRAP -I${prefix}/include -I${prefix}/include/gtsam -I${prefix}/include/gtsam/base -I${prefix}/include/gtsam/geometry -I${prefix}/include/gtsam/linear -I${prefix}/include/gtsam/nonlinear -I${prefix}/include/gtsam/slam -L${exec_prefix}/lib -lgtsam" all: ./wrap ${interfacePath} ${moduleName} ${toolboxpath} ${nameSpace} ${mexFlags} diff --git a/wrap/matlab.h b/wrap/matlab.h index 91f30b800..7e1a8b745 100644 --- a/wrap/matlab.h +++ b/wrap/matlab.h @@ -438,11 +438,13 @@ mxArray* wrap_shared_ptr(shared_ptr< Class > shared_ptr, const char *classname) */ template shared_ptr unwrap_shared_ptr(const mxArray* obj, const string& className) { +#ifndef UNSAFE_WRAP bool isClass = mxIsClass(obj, className.c_str()); if (!isClass) { mexPrintf("Expected %s, got %s\n", className.c_str(), mxGetClassName(obj)); error("Argument has wrong type."); } +#endif mxArray* mxh = mxGetProperty(obj,0,"self"); if (mxh==NULL) error("unwrap_reference: invalid wrap object"); ObjectHandle* handle = ObjectHandle::from_mex_handle(mxh);