Make sure it works for namespaces as well
parent
399c5e5551
commit
5048946ae9
|
@ -0,0 +1,8 @@
|
||||||
|
function varargout = overloadedGlobalFunction(varargin)
|
||||||
|
if length(varargin) == 1 && isa(varargin{1},'ns1.ClassA')
|
||||||
|
varargout{1} = testNamespaces_wrapper(24, varargin{:});
|
||||||
|
elseif length(varargin) == 2 && isa(varargin{1},'ns1.ClassA') && isa(varargin{2},'double')
|
||||||
|
varargout{1} = testNamespaces_wrapper(25, varargin{:});
|
||||||
|
else
|
||||||
|
error('Arguments do not match any overload of function ns2.overloadedGlobalFunction');
|
||||||
|
end
|
|
@ -342,6 +342,21 @@ void ns2aGlobalFunction_23(int nargout, mxArray *out[], int nargin, const mxArra
|
||||||
checkArguments("ns2aGlobalFunction",nargout,nargin,0);
|
checkArguments("ns2aGlobalFunction",nargout,nargin,0);
|
||||||
out[0] = wrap< Vector >(ns2::aGlobalFunction());
|
out[0] = wrap< Vector >(ns2::aGlobalFunction());
|
||||||
}
|
}
|
||||||
|
void ns2overloadedGlobalFunction_24(int nargout, mxArray *out[], int nargin, const mxArray *in[])
|
||||||
|
{
|
||||||
|
typedef boost::shared_ptr<ns1::ClassA> SharedClassA;
|
||||||
|
checkArguments("ns2overloadedGlobalFunction",nargout,nargin,1);
|
||||||
|
ns1::ClassA& a = *unwrap_shared_ptr< ns1::ClassA >(in[0], "ptr_ns1ClassA");
|
||||||
|
out[0] = wrap_shared_ptr(SharedClassA(new ns1::ClassA(ns2::overloadedGlobalFunction(a))),"ns1.ClassA", false);
|
||||||
|
}
|
||||||
|
void ns2overloadedGlobalFunction_25(int nargout, mxArray *out[], int nargin, const mxArray *in[])
|
||||||
|
{
|
||||||
|
typedef boost::shared_ptr<ns1::ClassA> SharedClassA;
|
||||||
|
checkArguments("ns2overloadedGlobalFunction",nargout,nargin,2);
|
||||||
|
ns1::ClassA& a = *unwrap_shared_ptr< ns1::ClassA >(in[0], "ptr_ns1ClassA");
|
||||||
|
double b = unwrap< double >(in[1]);
|
||||||
|
out[0] = wrap_shared_ptr(SharedClassA(new ns1::ClassA(ns2::overloadedGlobalFunction(a,b))),"ns1.ClassA", false);
|
||||||
|
}
|
||||||
|
|
||||||
void mexFunction(int nargout, mxArray *out[], int nargin, const mxArray *in[])
|
void mexFunction(int nargout, mxArray *out[], int nargin, const mxArray *in[])
|
||||||
{
|
{
|
||||||
|
@ -426,6 +441,12 @@ void mexFunction(int nargout, mxArray *out[], int nargin, const mxArray *in[])
|
||||||
case 23:
|
case 23:
|
||||||
ns2aGlobalFunction_23(nargout, out, nargin-1, in+1);
|
ns2aGlobalFunction_23(nargout, out, nargin-1, in+1);
|
||||||
break;
|
break;
|
||||||
|
case 24:
|
||||||
|
ns2overloadedGlobalFunction_24(nargout, out, nargin-1, in+1);
|
||||||
|
break;
|
||||||
|
case 25:
|
||||||
|
ns2overloadedGlobalFunction_25(nargout, out, nargin-1, in+1);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
} catch(const std::exception& e) {
|
} catch(const std::exception& e) {
|
||||||
mexErrMsgTxt(("Exception from gtsam:\n" + std::string(e.what()) + "\n").c_str());
|
mexErrMsgTxt(("Exception from gtsam:\n" + std::string(e.what()) + "\n").c_str());
|
||||||
|
|
|
@ -47,6 +47,10 @@ class ClassC {
|
||||||
// separate namespace global function, same name
|
// separate namespace global function, same name
|
||||||
Vector aGlobalFunction();
|
Vector aGlobalFunction();
|
||||||
|
|
||||||
|
// An overloaded global function
|
||||||
|
ns1::ClassA overloadedGlobalFunction(const ns1::ClassA& a);
|
||||||
|
ns1::ClassA overloadedGlobalFunction(const ns1::ClassA& a, double b);
|
||||||
|
|
||||||
} //\namespace ns2
|
} //\namespace ns2
|
||||||
|
|
||||||
class ClassD {
|
class ClassD {
|
||||||
|
|
|
@ -382,7 +382,7 @@ TEST( wrap, parse_namespaces ) {
|
||||||
// evaluate global functions
|
// evaluate global functions
|
||||||
// Vector ns1::aGlobalFunction();
|
// Vector ns1::aGlobalFunction();
|
||||||
// Vector ns2::aGlobalFunction();
|
// Vector ns2::aGlobalFunction();
|
||||||
LONGS_EQUAL(1, module.global_functions.size());
|
LONGS_EQUAL(2, module.global_functions.size());
|
||||||
CHECK(module.global_functions.find("aGlobalFunction") != module.global_functions.end());
|
CHECK(module.global_functions.find("aGlobalFunction") != module.global_functions.end());
|
||||||
{
|
{
|
||||||
GlobalFunction gfunc = module.global_functions.at("aGlobalFunction");
|
GlobalFunction gfunc = module.global_functions.at("aGlobalFunction");
|
||||||
|
@ -422,8 +422,12 @@ TEST( wrap, matlab_code_namespaces ) {
|
||||||
EXPECT(files_equal(exp_path + "+ns1/ClassB.m", act_path + "+ns1/ClassB.m" ));
|
EXPECT(files_equal(exp_path + "+ns1/ClassB.m", act_path + "+ns1/ClassB.m" ));
|
||||||
EXPECT(files_equal(exp_path + "+ns2/ClassA.m", act_path + "+ns2/ClassA.m" ));
|
EXPECT(files_equal(exp_path + "+ns2/ClassA.m", act_path + "+ns2/ClassA.m" ));
|
||||||
EXPECT(files_equal(exp_path + "+ns2/ClassC.m", act_path + "+ns2/ClassC.m" ));
|
EXPECT(files_equal(exp_path + "+ns2/ClassC.m", act_path + "+ns2/ClassC.m" ));
|
||||||
EXPECT(files_equal(exp_path + "+ns2/+ns3/ClassB.m" , act_path + "+ns2/+ns3/ClassB.m" ));
|
EXPECT(
|
||||||
EXPECT(files_equal(exp_path + "testNamespaces_wrapper.cpp" , act_path + "testNamespaces_wrapper.cpp" ));
|
files_equal(exp_path + "+ns2/overloadedGlobalFunction.m", exp_path + "+ns2/overloadedGlobalFunction.m" ));
|
||||||
|
EXPECT(
|
||||||
|
files_equal(exp_path + "+ns2/+ns3/ClassB.m", act_path + "+ns2/+ns3/ClassB.m" ));
|
||||||
|
EXPECT(
|
||||||
|
files_equal(exp_path + "testNamespaces_wrapper.cpp", act_path + "testNamespaces_wrapper.cpp" ));
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ************************************************************************* */
|
/* ************************************************************************* */
|
||||||
|
|
Loading…
Reference in New Issue