Merging 'master' into 'wrap'
commit
35fa8c89be
|
@ -26,25 +26,30 @@ class CheckMixin:
|
||||||
return True
|
return True
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
def can_be_pointer(self, arg_type: parser.Type):
|
||||||
|
"""
|
||||||
|
Determine if the `arg_type` can have a pointer to it.
|
||||||
|
|
||||||
|
E.g. `Pose3` can have `Pose3*` but
|
||||||
|
`Matrix` should not have `Matrix*`.
|
||||||
|
"""
|
||||||
|
return (arg_type.typename.name not in self.not_ptr_type
|
||||||
|
and arg_type.typename.name not in self.ignore_namespace
|
||||||
|
and arg_type.typename.name != 'string')
|
||||||
|
|
||||||
def is_shared_ptr(self, arg_type: parser.Type):
|
def is_shared_ptr(self, arg_type: parser.Type):
|
||||||
"""
|
"""
|
||||||
Determine if the `interface_parser.Type` should be treated as a
|
Determine if the `interface_parser.Type` should be treated as a
|
||||||
shared pointer in the wrapper.
|
shared pointer in the wrapper.
|
||||||
"""
|
"""
|
||||||
return arg_type.is_shared_ptr or (
|
return arg_type.is_shared_ptr
|
||||||
arg_type.typename.name not in self.not_ptr_type
|
|
||||||
and arg_type.typename.name not in self.ignore_namespace
|
|
||||||
and arg_type.typename.name != 'string')
|
|
||||||
|
|
||||||
def is_ptr(self, arg_type: parser.Type):
|
def is_ptr(self, arg_type: parser.Type):
|
||||||
"""
|
"""
|
||||||
Determine if the `interface_parser.Type` should be treated as a
|
Determine if the `interface_parser.Type` should be treated as a
|
||||||
raw pointer in the wrapper.
|
raw pointer in the wrapper.
|
||||||
"""
|
"""
|
||||||
return arg_type.is_ptr or (
|
return arg_type.is_ptr
|
||||||
arg_type.typename.name not in self.not_ptr_type
|
|
||||||
and arg_type.typename.name not in self.ignore_namespace
|
|
||||||
and arg_type.typename.name != 'string')
|
|
||||||
|
|
||||||
def is_ref(self, arg_type: parser.Type):
|
def is_ref(self, arg_type: parser.Type):
|
||||||
"""
|
"""
|
||||||
|
|
|
@ -147,11 +147,13 @@ class MatlabWrapper(CheckMixin, FormatMixin):
|
||||||
"""
|
"""
|
||||||
def args_copy(args):
|
def args_copy(args):
|
||||||
return ArgumentList([copy.copy(arg) for arg in args.list()])
|
return ArgumentList([copy.copy(arg) for arg in args.list()])
|
||||||
|
|
||||||
def method_copy(method):
|
def method_copy(method):
|
||||||
method2 = copy.copy(method)
|
method2 = copy.copy(method)
|
||||||
method2.args = args_copy(method.args)
|
method2.args = args_copy(method.args)
|
||||||
method2.args.backup = method.args.backup
|
method2.args.backup = method.args.backup
|
||||||
return method2
|
return method2
|
||||||
|
|
||||||
if save_backup:
|
if save_backup:
|
||||||
method.args.backup = args_copy(method.args)
|
method.args.backup = args_copy(method.args)
|
||||||
method = method_copy(method)
|
method = method_copy(method)
|
||||||
|
@ -162,7 +164,8 @@ class MatlabWrapper(CheckMixin, FormatMixin):
|
||||||
method.args.list().remove(arg)
|
method.args.list().remove(arg)
|
||||||
return [
|
return [
|
||||||
methodWithArg,
|
methodWithArg,
|
||||||
*MatlabWrapper._expand_default_arguments(method, save_backup=False)
|
*MatlabWrapper._expand_default_arguments(method,
|
||||||
|
save_backup=False)
|
||||||
]
|
]
|
||||||
break
|
break
|
||||||
assert all(arg.default is None for arg in method.args.list()), \
|
assert all(arg.default is None for arg in method.args.list()), \
|
||||||
|
@ -180,9 +183,12 @@ class MatlabWrapper(CheckMixin, FormatMixin):
|
||||||
|
|
||||||
if method_index is None:
|
if method_index is None:
|
||||||
method_map[method.name] = len(method_out)
|
method_map[method.name] = len(method_out)
|
||||||
method_out.append(MatlabWrapper._expand_default_arguments(method))
|
method_out.append(
|
||||||
|
MatlabWrapper._expand_default_arguments(method))
|
||||||
else:
|
else:
|
||||||
method_out[method_index] += MatlabWrapper._expand_default_arguments(method)
|
method_out[
|
||||||
|
method_index] += MatlabWrapper._expand_default_arguments(
|
||||||
|
method)
|
||||||
|
|
||||||
return method_out
|
return method_out
|
||||||
|
|
||||||
|
@ -337,43 +343,42 @@ class MatlabWrapper(CheckMixin, FormatMixin):
|
||||||
body_args = ''
|
body_args = ''
|
||||||
|
|
||||||
for arg in args.list():
|
for arg in args.list():
|
||||||
|
ctype_camel = self._format_type_name(arg.ctype.typename,
|
||||||
|
separator='')
|
||||||
|
ctype_sep = self._format_type_name(arg.ctype.typename)
|
||||||
|
|
||||||
if self.is_ref(arg.ctype): # and not constructor:
|
if self.is_ref(arg.ctype): # and not constructor:
|
||||||
ctype_camel = self._format_type_name(arg.ctype.typename,
|
arg_type = "{ctype}&".format(ctype=ctype_sep)
|
||||||
separator='')
|
unwrap = '*unwrap_shared_ptr< {ctype} >(in[{id}], "ptr_{ctype_camel}");'.format(
|
||||||
body_args += textwrap.indent(textwrap.dedent('''\
|
ctype=ctype_sep, ctype_camel=ctype_camel, id=arg_id)
|
||||||
{ctype}& {name} = *unwrap_shared_ptr< {ctype} >(in[{id}], "ptr_{ctype_camel}");
|
|
||||||
'''.format(ctype=self._format_type_name(arg.ctype.typename),
|
|
||||||
ctype_camel=ctype_camel,
|
|
||||||
name=arg.name,
|
|
||||||
id=arg_id)),
|
|
||||||
prefix=' ')
|
|
||||||
|
|
||||||
elif (self.is_shared_ptr(arg.ctype) or self.is_ptr(arg.ctype)) and \
|
elif self.is_ptr(arg.ctype) and \
|
||||||
arg.ctype.typename.name not in self.ignore_namespace:
|
arg.ctype.typename.name not in self.ignore_namespace:
|
||||||
if arg.ctype.is_shared_ptr:
|
|
||||||
call_type = arg.ctype.is_shared_ptr
|
|
||||||
else:
|
|
||||||
call_type = arg.ctype.is_ptr
|
|
||||||
|
|
||||||
body_args += textwrap.indent(textwrap.dedent('''\
|
arg_type = "{ctype_sep}*".format(ctype_sep=ctype_sep)
|
||||||
{std_boost}::shared_ptr<{ctype_sep}> {name} = unwrap_shared_ptr< {ctype_sep} >(in[{id}], "ptr_{ctype}");
|
unwrap = 'unwrap_ptr< {ctype_sep} >(in[{id}], "ptr_{ctype}");'.format(
|
||||||
'''.format(std_boost='boost' if constructor else 'boost',
|
ctype_sep=ctype_sep, ctype=ctype_camel, id=arg_id)
|
||||||
ctype_sep=self._format_type_name(
|
|
||||||
arg.ctype.typename),
|
elif (self.is_shared_ptr(arg.ctype) or self.can_be_pointer(arg.ctype)) and \
|
||||||
ctype=self._format_type_name(arg.ctype.typename,
|
arg.ctype.typename.name not in self.ignore_namespace:
|
||||||
separator=''),
|
call_type = arg.ctype.is_shared_ptr
|
||||||
name=arg.name,
|
|
||||||
id=arg_id)),
|
arg_type = "{std_boost}::shared_ptr<{ctype_sep}>".format(
|
||||||
prefix=' ')
|
std_boost='boost' if constructor else 'boost',
|
||||||
|
ctype_sep=ctype_sep)
|
||||||
|
unwrap = 'unwrap_shared_ptr< {ctype_sep} >(in[{id}], "ptr_{ctype}");'.format(
|
||||||
|
ctype_sep=ctype_sep, ctype=ctype_camel, id=arg_id)
|
||||||
|
|
||||||
else:
|
else:
|
||||||
body_args += textwrap.indent(textwrap.dedent('''\
|
arg_type = "{ctype}".format(ctype=arg.ctype.typename.name)
|
||||||
{ctype} {name} = unwrap< {ctype} >(in[{id}]);
|
unwrap = 'unwrap< {ctype} >(in[{id}]);'.format(
|
||||||
'''.format(ctype=arg.ctype.typename.name,
|
ctype=arg.ctype.typename.name, id=arg_id)
|
||||||
name=arg.name,
|
|
||||||
id=arg_id)),
|
|
||||||
prefix=' ')
|
|
||||||
|
|
||||||
|
body_args += textwrap.indent(textwrap.dedent('''\
|
||||||
|
{arg_type} {name} = {unwrap}
|
||||||
|
'''.format(arg_type=arg_type, name=arg.name,
|
||||||
|
unwrap=unwrap)),
|
||||||
|
prefix=' ')
|
||||||
arg_id += 1
|
arg_id += 1
|
||||||
|
|
||||||
params = ''
|
params = ''
|
||||||
|
@ -383,12 +388,14 @@ class MatlabWrapper(CheckMixin, FormatMixin):
|
||||||
if params != '':
|
if params != '':
|
||||||
params += ','
|
params += ','
|
||||||
|
|
||||||
if (arg.default is not None) and (arg.name not in explicit_arg_names):
|
if (arg.default is not None) and (arg.name
|
||||||
|
not in explicit_arg_names):
|
||||||
params += arg.default
|
params += arg.default
|
||||||
continue
|
continue
|
||||||
|
|
||||||
if (not self.is_ref(arg.ctype)) and (self.is_shared_ptr(arg.ctype)) and (self.is_ptr(
|
if not self.is_ref(arg.ctype) and (self.is_shared_ptr(arg.ctype) or \
|
||||||
arg.ctype)) and (arg.ctype.typename.name not in self.ignore_namespace):
|
self.is_ptr(arg.ctype) or self.can_be_pointer(arg.ctype))and \
|
||||||
|
arg.ctype.typename.name not in self.ignore_namespace:
|
||||||
if arg.ctype.is_shared_ptr:
|
if arg.ctype.is_shared_ptr:
|
||||||
call_type = arg.ctype.is_shared_ptr
|
call_type = arg.ctype.is_shared_ptr
|
||||||
else:
|
else:
|
||||||
|
@ -601,7 +608,8 @@ class MatlabWrapper(CheckMixin, FormatMixin):
|
||||||
if not isinstance(ctors, Iterable):
|
if not isinstance(ctors, Iterable):
|
||||||
ctors = [ctors]
|
ctors = [ctors]
|
||||||
|
|
||||||
ctors = sum((MatlabWrapper._expand_default_arguments(ctor) for ctor in ctors), [])
|
ctors = sum((MatlabWrapper._expand_default_arguments(ctor)
|
||||||
|
for ctor in ctors), [])
|
||||||
|
|
||||||
methods_wrap = textwrap.indent(textwrap.dedent("""\
|
methods_wrap = textwrap.indent(textwrap.dedent("""\
|
||||||
methods
|
methods
|
||||||
|
@ -885,10 +893,10 @@ class MatlabWrapper(CheckMixin, FormatMixin):
|
||||||
wrapper=self._wrapper_name(),
|
wrapper=self._wrapper_name(),
|
||||||
id=self._update_wrapper_id(
|
id=self._update_wrapper_id(
|
||||||
(namespace_name, instantiated_class,
|
(namespace_name, instantiated_class,
|
||||||
static_overload.name, static_overload)),
|
static_overload.name, static_overload)),
|
||||||
class_name=instantiated_class.name,
|
class_name=instantiated_class.name,
|
||||||
end_statement=end_statement),
|
end_statement=end_statement),
|
||||||
prefix=' ')
|
prefix=' ')
|
||||||
|
|
||||||
# If the arguments don't match any of the checks above,
|
# If the arguments don't match any of the checks above,
|
||||||
# throw an error with the class and method name.
|
# throw an error with the class and method name.
|
||||||
|
@ -1079,7 +1087,8 @@ class MatlabWrapper(CheckMixin, FormatMixin):
|
||||||
pair_value = 'first' if func_id == 0 else 'second'
|
pair_value = 'first' if func_id == 0 else 'second'
|
||||||
new_line = '\n' if func_id == 0 else ''
|
new_line = '\n' if func_id == 0 else ''
|
||||||
|
|
||||||
if self.is_shared_ptr(return_type) or self.is_ptr(return_type):
|
if self.is_shared_ptr(return_type) or self.is_ptr(return_type) or \
|
||||||
|
self.can_be_pointer(return_type):
|
||||||
shared_obj = 'pairResult.' + pair_value
|
shared_obj = 'pairResult.' + pair_value
|
||||||
|
|
||||||
if not (return_type.is_shared_ptr or return_type.is_ptr):
|
if not (return_type.is_shared_ptr or return_type.is_ptr):
|
||||||
|
@ -1145,7 +1154,8 @@ class MatlabWrapper(CheckMixin, FormatMixin):
|
||||||
|
|
||||||
if return_1_name != 'void':
|
if return_1_name != 'void':
|
||||||
if return_count == 1:
|
if return_count == 1:
|
||||||
if self.is_shared_ptr(return_1) or self.is_ptr(return_1):
|
if self.is_shared_ptr(return_1) or self.is_ptr(return_1) or \
|
||||||
|
self.can_be_pointer(return_1):
|
||||||
sep_method_name = partial(self._format_type_name,
|
sep_method_name = partial(self._format_type_name,
|
||||||
return_1.typename,
|
return_1.typename,
|
||||||
include_namespace=True)
|
include_namespace=True)
|
||||||
|
|
|
@ -477,6 +477,14 @@ boost::shared_ptr<Class> unwrap_shared_ptr(const mxArray* obj, const string& pro
|
||||||
return *spp;
|
return *spp;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template <typename Class>
|
||||||
|
Class* unwrap_ptr(const mxArray* obj, const string& propertyName) {
|
||||||
|
|
||||||
|
mxArray* mxh = mxGetProperty(obj,0, propertyName.c_str());
|
||||||
|
Class* x = reinterpret_cast<Class*> (mxGetData(mxh));
|
||||||
|
return x;
|
||||||
|
}
|
||||||
|
|
||||||
//// throw an error if unwrap_shared_ptr is attempted for an Eigen Vector
|
//// throw an error if unwrap_shared_ptr is attempted for an Eigen Vector
|
||||||
//template <>
|
//template <>
|
||||||
//Vector unwrap_shared_ptr<Vector>(const mxArray* obj, const string& propertyName) {
|
//Vector unwrap_shared_ptr<Vector>(const mxArray* obj, const string& propertyName) {
|
||||||
|
|
|
@ -11,9 +11,9 @@ classdef ForwardKinematicsFactor < gtsam.BetweenFactor<gtsam.Pose3>
|
||||||
if nargin == 2
|
if nargin == 2
|
||||||
my_ptr = varargin{2};
|
my_ptr = varargin{2};
|
||||||
else
|
else
|
||||||
my_ptr = inheritance_wrapper(36, varargin{2});
|
my_ptr = inheritance_wrapper(52, varargin{2});
|
||||||
end
|
end
|
||||||
base_ptr = inheritance_wrapper(35, my_ptr);
|
base_ptr = inheritance_wrapper(51, my_ptr);
|
||||||
else
|
else
|
||||||
error('Arguments do not match any overload of ForwardKinematicsFactor constructor');
|
error('Arguments do not match any overload of ForwardKinematicsFactor constructor');
|
||||||
end
|
end
|
||||||
|
@ -22,7 +22,7 @@ classdef ForwardKinematicsFactor < gtsam.BetweenFactor<gtsam.Pose3>
|
||||||
end
|
end
|
||||||
|
|
||||||
function delete(obj)
|
function delete(obj)
|
||||||
inheritance_wrapper(37, obj.ptr_ForwardKinematicsFactor);
|
inheritance_wrapper(53, obj.ptr_ForwardKinematicsFactor);
|
||||||
end
|
end
|
||||||
|
|
||||||
function display(obj), obj.print(''); end
|
function display(obj), obj.print(''); end
|
||||||
|
|
|
@ -86,7 +86,7 @@ void load2D_2(int nargout, mxArray *out[], int nargin, const mxArray *in[])
|
||||||
{
|
{
|
||||||
checkArguments("load2D",nargout,nargin,2);
|
checkArguments("load2D",nargout,nargin,2);
|
||||||
string filename = unwrap< string >(in[0]);
|
string filename = unwrap< string >(in[0]);
|
||||||
boost::shared_ptr<gtsam::noiseModel::Diagonal> model = unwrap_shared_ptr< gtsam::noiseModel::Diagonal >(in[1], "ptr_gtsamnoiseModelDiagonal");
|
gtsam::noiseModel::Diagonal* model = unwrap_ptr< gtsam::noiseModel::Diagonal >(in[1], "ptr_gtsamnoiseModelDiagonal");
|
||||||
auto pairResult = load2D(filename,model);
|
auto pairResult = load2D(filename,model);
|
||||||
out[0] = wrap_shared_ptr(pairResult.first,"gtsam.NonlinearFactorGraph", false);
|
out[0] = wrap_shared_ptr(pairResult.first,"gtsam.NonlinearFactorGraph", false);
|
||||||
out[1] = wrap_shared_ptr(pairResult.second,"gtsam.Values", false);
|
out[1] = wrap_shared_ptr(pairResult.second,"gtsam.Values", false);
|
||||||
|
|
|
@ -151,7 +151,7 @@ void gtsamPoint2_argChar_7(int nargout, mxArray *out[], int nargin, const mxArra
|
||||||
{
|
{
|
||||||
checkArguments("argChar",nargout,nargin-1,1);
|
checkArguments("argChar",nargout,nargin-1,1);
|
||||||
auto obj = unwrap_shared_ptr<gtsam::Point2>(in[0], "ptr_gtsamPoint2");
|
auto obj = unwrap_shared_ptr<gtsam::Point2>(in[0], "ptr_gtsamPoint2");
|
||||||
boost::shared_ptr<char> a = unwrap_shared_ptr< char >(in[1], "ptr_char");
|
char* a = unwrap_ptr< char >(in[1], "ptr_char");
|
||||||
obj->argChar(a);
|
obj->argChar(a);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -175,7 +175,7 @@ void gtsamPoint2_argChar_10(int nargout, mxArray *out[], int nargin, const mxArr
|
||||||
{
|
{
|
||||||
checkArguments("argChar",nargout,nargin-1,1);
|
checkArguments("argChar",nargout,nargin-1,1);
|
||||||
auto obj = unwrap_shared_ptr<gtsam::Point2>(in[0], "ptr_gtsamPoint2");
|
auto obj = unwrap_shared_ptr<gtsam::Point2>(in[0], "ptr_gtsamPoint2");
|
||||||
boost::shared_ptr<char> a = unwrap_shared_ptr< char >(in[1], "ptr_char");
|
char* a = unwrap_ptr< char >(in[1], "ptr_char");
|
||||||
obj->argChar(a);
|
obj->argChar(a);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -9,6 +9,7 @@
|
||||||
|
|
||||||
typedef MyTemplate<gtsam::Point2> MyTemplatePoint2;
|
typedef MyTemplate<gtsam::Point2> MyTemplatePoint2;
|
||||||
typedef MyTemplate<gtsam::Matrix> MyTemplateMatrix;
|
typedef MyTemplate<gtsam::Matrix> MyTemplateMatrix;
|
||||||
|
typedef MyTemplate<A> MyTemplateA;
|
||||||
|
|
||||||
typedef std::set<boost::shared_ptr<MyBase>*> Collector_MyBase;
|
typedef std::set<boost::shared_ptr<MyBase>*> Collector_MyBase;
|
||||||
static Collector_MyBase collector_MyBase;
|
static Collector_MyBase collector_MyBase;
|
||||||
|
@ -16,6 +17,8 @@ typedef std::set<boost::shared_ptr<MyTemplatePoint2>*> Collector_MyTemplatePoint
|
||||||
static Collector_MyTemplatePoint2 collector_MyTemplatePoint2;
|
static Collector_MyTemplatePoint2 collector_MyTemplatePoint2;
|
||||||
typedef std::set<boost::shared_ptr<MyTemplateMatrix>*> Collector_MyTemplateMatrix;
|
typedef std::set<boost::shared_ptr<MyTemplateMatrix>*> Collector_MyTemplateMatrix;
|
||||||
static Collector_MyTemplateMatrix collector_MyTemplateMatrix;
|
static Collector_MyTemplateMatrix collector_MyTemplateMatrix;
|
||||||
|
typedef std::set<boost::shared_ptr<MyTemplateA>*> Collector_MyTemplateA;
|
||||||
|
static Collector_MyTemplateA collector_MyTemplateA;
|
||||||
typedef std::set<boost::shared_ptr<ForwardKinematicsFactor>*> Collector_ForwardKinematicsFactor;
|
typedef std::set<boost::shared_ptr<ForwardKinematicsFactor>*> Collector_ForwardKinematicsFactor;
|
||||||
static Collector_ForwardKinematicsFactor collector_ForwardKinematicsFactor;
|
static Collector_ForwardKinematicsFactor collector_ForwardKinematicsFactor;
|
||||||
|
|
||||||
|
@ -44,6 +47,12 @@ void _deleteAllObjects()
|
||||||
collector_MyTemplateMatrix.erase(iter++);
|
collector_MyTemplateMatrix.erase(iter++);
|
||||||
anyDeleted = true;
|
anyDeleted = true;
|
||||||
} }
|
} }
|
||||||
|
{ for(Collector_MyTemplateA::iterator iter = collector_MyTemplateA.begin();
|
||||||
|
iter != collector_MyTemplateA.end(); ) {
|
||||||
|
delete *iter;
|
||||||
|
collector_MyTemplateA.erase(iter++);
|
||||||
|
anyDeleted = true;
|
||||||
|
} }
|
||||||
{ for(Collector_ForwardKinematicsFactor::iterator iter = collector_ForwardKinematicsFactor.begin();
|
{ for(Collector_ForwardKinematicsFactor::iterator iter = collector_ForwardKinematicsFactor.begin();
|
||||||
iter != collector_ForwardKinematicsFactor.end(); ) {
|
iter != collector_ForwardKinematicsFactor.end(); ) {
|
||||||
delete *iter;
|
delete *iter;
|
||||||
|
@ -67,6 +76,7 @@ void _inheritance_RTTIRegister() {
|
||||||
types.insert(std::make_pair(typeid(MyBase).name(), "MyBase"));
|
types.insert(std::make_pair(typeid(MyBase).name(), "MyBase"));
|
||||||
types.insert(std::make_pair(typeid(MyTemplatePoint2).name(), "MyTemplatePoint2"));
|
types.insert(std::make_pair(typeid(MyTemplatePoint2).name(), "MyTemplatePoint2"));
|
||||||
types.insert(std::make_pair(typeid(MyTemplateMatrix).name(), "MyTemplateMatrix"));
|
types.insert(std::make_pair(typeid(MyTemplateMatrix).name(), "MyTemplateMatrix"));
|
||||||
|
types.insert(std::make_pair(typeid(MyTemplateA).name(), "MyTemplateA"));
|
||||||
types.insert(std::make_pair(typeid(ForwardKinematicsFactor).name(), "ForwardKinematicsFactor"));
|
types.insert(std::make_pair(typeid(ForwardKinematicsFactor).name(), "ForwardKinematicsFactor"));
|
||||||
|
|
||||||
|
|
||||||
|
@ -462,7 +472,157 @@ void MyTemplateMatrix_Level_34(int nargout, mxArray *out[], int nargin, const mx
|
||||||
out[0] = wrap_shared_ptr(boost::make_shared<MyTemplate<Matrix>>(MyTemplate<gtsam::Matrix>::Level(K)),"MyTemplateMatrix", false);
|
out[0] = wrap_shared_ptr(boost::make_shared<MyTemplate<Matrix>>(MyTemplate<gtsam::Matrix>::Level(K)),"MyTemplateMatrix", false);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ForwardKinematicsFactor_collectorInsertAndMakeBase_35(int nargout, mxArray *out[], int nargin, const mxArray *in[])
|
void MyTemplateA_collectorInsertAndMakeBase_35(int nargout, mxArray *out[], int nargin, const mxArray *in[])
|
||||||
|
{
|
||||||
|
mexAtExit(&_deleteAllObjects);
|
||||||
|
typedef boost::shared_ptr<MyTemplate<A>> Shared;
|
||||||
|
|
||||||
|
Shared *self = *reinterpret_cast<Shared**> (mxGetData(in[0]));
|
||||||
|
collector_MyTemplateA.insert(self);
|
||||||
|
|
||||||
|
typedef boost::shared_ptr<MyBase> SharedBase;
|
||||||
|
out[0] = mxCreateNumericMatrix(1, 1, mxUINT32OR64_CLASS, mxREAL);
|
||||||
|
*reinterpret_cast<SharedBase**>(mxGetData(out[0])) = new SharedBase(*self);
|
||||||
|
}
|
||||||
|
|
||||||
|
void MyTemplateA_upcastFromVoid_36(int nargout, mxArray *out[], int nargin, const mxArray *in[]) {
|
||||||
|
mexAtExit(&_deleteAllObjects);
|
||||||
|
typedef boost::shared_ptr<MyTemplate<A>> Shared;
|
||||||
|
boost::shared_ptr<void> *asVoid = *reinterpret_cast<boost::shared_ptr<void>**> (mxGetData(in[0]));
|
||||||
|
out[0] = mxCreateNumericMatrix(1, 1, mxUINT32OR64_CLASS, mxREAL);
|
||||||
|
Shared *self = new Shared(boost::static_pointer_cast<MyTemplate<A>>(*asVoid));
|
||||||
|
*reinterpret_cast<Shared**>(mxGetData(out[0])) = self;
|
||||||
|
}
|
||||||
|
|
||||||
|
void MyTemplateA_constructor_37(int nargout, mxArray *out[], int nargin, const mxArray *in[])
|
||||||
|
{
|
||||||
|
mexAtExit(&_deleteAllObjects);
|
||||||
|
typedef boost::shared_ptr<MyTemplate<A>> Shared;
|
||||||
|
|
||||||
|
Shared *self = new Shared(new MyTemplate<A>());
|
||||||
|
collector_MyTemplateA.insert(self);
|
||||||
|
out[0] = mxCreateNumericMatrix(1, 1, mxUINT32OR64_CLASS, mxREAL);
|
||||||
|
*reinterpret_cast<Shared**> (mxGetData(out[0])) = self;
|
||||||
|
|
||||||
|
typedef boost::shared_ptr<MyBase> SharedBase;
|
||||||
|
out[1] = mxCreateNumericMatrix(1, 1, mxUINT32OR64_CLASS, mxREAL);
|
||||||
|
*reinterpret_cast<SharedBase**>(mxGetData(out[1])) = new SharedBase(*self);
|
||||||
|
}
|
||||||
|
|
||||||
|
void MyTemplateA_deconstructor_38(int nargout, mxArray *out[], int nargin, const mxArray *in[])
|
||||||
|
{
|
||||||
|
typedef boost::shared_ptr<MyTemplate<A>> Shared;
|
||||||
|
checkArguments("delete_MyTemplateA",nargout,nargin,1);
|
||||||
|
Shared *self = *reinterpret_cast<Shared**>(mxGetData(in[0]));
|
||||||
|
Collector_MyTemplateA::iterator item;
|
||||||
|
item = collector_MyTemplateA.find(self);
|
||||||
|
if(item != collector_MyTemplateA.end()) {
|
||||||
|
collector_MyTemplateA.erase(item);
|
||||||
|
}
|
||||||
|
delete self;
|
||||||
|
}
|
||||||
|
|
||||||
|
void MyTemplateA_accept_T_39(int nargout, mxArray *out[], int nargin, const mxArray *in[])
|
||||||
|
{
|
||||||
|
checkArguments("accept_T",nargout,nargin-1,1);
|
||||||
|
auto obj = unwrap_shared_ptr<MyTemplate<A>>(in[0], "ptr_MyTemplateA");
|
||||||
|
A& value = *unwrap_shared_ptr< A >(in[1], "ptr_A");
|
||||||
|
obj->accept_T(value);
|
||||||
|
}
|
||||||
|
|
||||||
|
void MyTemplateA_accept_Tptr_40(int nargout, mxArray *out[], int nargin, const mxArray *in[])
|
||||||
|
{
|
||||||
|
checkArguments("accept_Tptr",nargout,nargin-1,1);
|
||||||
|
auto obj = unwrap_shared_ptr<MyTemplate<A>>(in[0], "ptr_MyTemplateA");
|
||||||
|
boost::shared_ptr<A> value = unwrap_shared_ptr< A >(in[1], "ptr_A");
|
||||||
|
obj->accept_Tptr(value);
|
||||||
|
}
|
||||||
|
|
||||||
|
void MyTemplateA_create_MixedPtrs_41(int nargout, mxArray *out[], int nargin, const mxArray *in[])
|
||||||
|
{
|
||||||
|
checkArguments("create_MixedPtrs",nargout,nargin-1,0);
|
||||||
|
auto obj = unwrap_shared_ptr<MyTemplate<A>>(in[0], "ptr_MyTemplateA");
|
||||||
|
auto pairResult = obj->create_MixedPtrs();
|
||||||
|
out[0] = wrap_shared_ptr(boost::make_shared<A>(pairResult.first),"A", false);
|
||||||
|
out[1] = wrap_shared_ptr(pairResult.second,"A", false);
|
||||||
|
}
|
||||||
|
|
||||||
|
void MyTemplateA_create_ptrs_42(int nargout, mxArray *out[], int nargin, const mxArray *in[])
|
||||||
|
{
|
||||||
|
checkArguments("create_ptrs",nargout,nargin-1,0);
|
||||||
|
auto obj = unwrap_shared_ptr<MyTemplate<A>>(in[0], "ptr_MyTemplateA");
|
||||||
|
auto pairResult = obj->create_ptrs();
|
||||||
|
out[0] = wrap_shared_ptr(pairResult.first,"A", false);
|
||||||
|
out[1] = wrap_shared_ptr(pairResult.second,"A", false);
|
||||||
|
}
|
||||||
|
|
||||||
|
void MyTemplateA_return_T_43(int nargout, mxArray *out[], int nargin, const mxArray *in[])
|
||||||
|
{
|
||||||
|
checkArguments("return_T",nargout,nargin-1,1);
|
||||||
|
auto obj = unwrap_shared_ptr<MyTemplate<A>>(in[0], "ptr_MyTemplateA");
|
||||||
|
A* value = unwrap_ptr< A >(in[1], "ptr_A");
|
||||||
|
out[0] = wrap_shared_ptr(boost::make_shared<A>(obj->return_T(value)),"A", false);
|
||||||
|
}
|
||||||
|
|
||||||
|
void MyTemplateA_return_Tptr_44(int nargout, mxArray *out[], int nargin, const mxArray *in[])
|
||||||
|
{
|
||||||
|
checkArguments("return_Tptr",nargout,nargin-1,1);
|
||||||
|
auto obj = unwrap_shared_ptr<MyTemplate<A>>(in[0], "ptr_MyTemplateA");
|
||||||
|
boost::shared_ptr<A> value = unwrap_shared_ptr< A >(in[1], "ptr_A");
|
||||||
|
out[0] = wrap_shared_ptr(obj->return_Tptr(value),"A", false);
|
||||||
|
}
|
||||||
|
|
||||||
|
void MyTemplateA_return_ptrs_45(int nargout, mxArray *out[], int nargin, const mxArray *in[])
|
||||||
|
{
|
||||||
|
checkArguments("return_ptrs",nargout,nargin-1,2);
|
||||||
|
auto obj = unwrap_shared_ptr<MyTemplate<A>>(in[0], "ptr_MyTemplateA");
|
||||||
|
boost::shared_ptr<A> p1 = unwrap_shared_ptr< A >(in[1], "ptr_A");
|
||||||
|
boost::shared_ptr<A> p2 = unwrap_shared_ptr< A >(in[2], "ptr_A");
|
||||||
|
auto pairResult = obj->return_ptrs(p1,p2);
|
||||||
|
out[0] = wrap_shared_ptr(pairResult.first,"A", false);
|
||||||
|
out[1] = wrap_shared_ptr(pairResult.second,"A", false);
|
||||||
|
}
|
||||||
|
|
||||||
|
void MyTemplateA_templatedMethod_46(int nargout, mxArray *out[], int nargin, const mxArray *in[])
|
||||||
|
{
|
||||||
|
checkArguments("templatedMethodMatrix",nargout,nargin-1,1);
|
||||||
|
auto obj = unwrap_shared_ptr<MyTemplate<A>>(in[0], "ptr_MyTemplateA");
|
||||||
|
Matrix t = unwrap< Matrix >(in[1]);
|
||||||
|
out[0] = wrap< Matrix >(obj->templatedMethod<gtsam::Matrix>(t));
|
||||||
|
}
|
||||||
|
|
||||||
|
void MyTemplateA_templatedMethod_47(int nargout, mxArray *out[], int nargin, const mxArray *in[])
|
||||||
|
{
|
||||||
|
checkArguments("templatedMethodPoint2",nargout,nargin-1,1);
|
||||||
|
auto obj = unwrap_shared_ptr<MyTemplate<A>>(in[0], "ptr_MyTemplateA");
|
||||||
|
Point2 t = unwrap< Point2 >(in[1]);
|
||||||
|
out[0] = wrap< Point2 >(obj->templatedMethod<gtsam::Point2>(t));
|
||||||
|
}
|
||||||
|
|
||||||
|
void MyTemplateA_templatedMethod_48(int nargout, mxArray *out[], int nargin, const mxArray *in[])
|
||||||
|
{
|
||||||
|
checkArguments("templatedMethodPoint3",nargout,nargin-1,1);
|
||||||
|
auto obj = unwrap_shared_ptr<MyTemplate<A>>(in[0], "ptr_MyTemplateA");
|
||||||
|
Point3 t = unwrap< Point3 >(in[1]);
|
||||||
|
out[0] = wrap< Point3 >(obj->templatedMethod<gtsam::Point3>(t));
|
||||||
|
}
|
||||||
|
|
||||||
|
void MyTemplateA_templatedMethod_49(int nargout, mxArray *out[], int nargin, const mxArray *in[])
|
||||||
|
{
|
||||||
|
checkArguments("templatedMethodVector",nargout,nargin-1,1);
|
||||||
|
auto obj = unwrap_shared_ptr<MyTemplate<A>>(in[0], "ptr_MyTemplateA");
|
||||||
|
Vector t = unwrap< Vector >(in[1]);
|
||||||
|
out[0] = wrap< Vector >(obj->templatedMethod<gtsam::Vector>(t));
|
||||||
|
}
|
||||||
|
|
||||||
|
void MyTemplateA_Level_50(int nargout, mxArray *out[], int nargin, const mxArray *in[])
|
||||||
|
{
|
||||||
|
checkArguments("MyTemplate<A>.Level",nargout,nargin,1);
|
||||||
|
A& K = *unwrap_shared_ptr< A >(in[0], "ptr_A");
|
||||||
|
out[0] = wrap_shared_ptr(boost::make_shared<MyTemplate<A>>(MyTemplate<A>::Level(K)),"MyTemplateA", false);
|
||||||
|
}
|
||||||
|
|
||||||
|
void ForwardKinematicsFactor_collectorInsertAndMakeBase_51(int nargout, mxArray *out[], int nargin, const mxArray *in[])
|
||||||
{
|
{
|
||||||
mexAtExit(&_deleteAllObjects);
|
mexAtExit(&_deleteAllObjects);
|
||||||
typedef boost::shared_ptr<ForwardKinematicsFactor> Shared;
|
typedef boost::shared_ptr<ForwardKinematicsFactor> Shared;
|
||||||
|
@ -475,7 +635,7 @@ void ForwardKinematicsFactor_collectorInsertAndMakeBase_35(int nargout, mxArray
|
||||||
*reinterpret_cast<SharedBase**>(mxGetData(out[0])) = new SharedBase(*self);
|
*reinterpret_cast<SharedBase**>(mxGetData(out[0])) = new SharedBase(*self);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ForwardKinematicsFactor_upcastFromVoid_36(int nargout, mxArray *out[], int nargin, const mxArray *in[]) {
|
void ForwardKinematicsFactor_upcastFromVoid_52(int nargout, mxArray *out[], int nargin, const mxArray *in[]) {
|
||||||
mexAtExit(&_deleteAllObjects);
|
mexAtExit(&_deleteAllObjects);
|
||||||
typedef boost::shared_ptr<ForwardKinematicsFactor> Shared;
|
typedef boost::shared_ptr<ForwardKinematicsFactor> Shared;
|
||||||
boost::shared_ptr<void> *asVoid = *reinterpret_cast<boost::shared_ptr<void>**> (mxGetData(in[0]));
|
boost::shared_ptr<void> *asVoid = *reinterpret_cast<boost::shared_ptr<void>**> (mxGetData(in[0]));
|
||||||
|
@ -484,7 +644,7 @@ void ForwardKinematicsFactor_upcastFromVoid_36(int nargout, mxArray *out[], int
|
||||||
*reinterpret_cast<Shared**>(mxGetData(out[0])) = self;
|
*reinterpret_cast<Shared**>(mxGetData(out[0])) = self;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ForwardKinematicsFactor_deconstructor_37(int nargout, mxArray *out[], int nargin, const mxArray *in[])
|
void ForwardKinematicsFactor_deconstructor_53(int nargout, mxArray *out[], int nargin, const mxArray *in[])
|
||||||
{
|
{
|
||||||
typedef boost::shared_ptr<ForwardKinematicsFactor> Shared;
|
typedef boost::shared_ptr<ForwardKinematicsFactor> Shared;
|
||||||
checkArguments("delete_ForwardKinematicsFactor",nargout,nargin,1);
|
checkArguments("delete_ForwardKinematicsFactor",nargout,nargin,1);
|
||||||
|
@ -615,13 +775,61 @@ void mexFunction(int nargout, mxArray *out[], int nargin, const mxArray *in[])
|
||||||
MyTemplateMatrix_Level_34(nargout, out, nargin-1, in+1);
|
MyTemplateMatrix_Level_34(nargout, out, nargin-1, in+1);
|
||||||
break;
|
break;
|
||||||
case 35:
|
case 35:
|
||||||
ForwardKinematicsFactor_collectorInsertAndMakeBase_35(nargout, out, nargin-1, in+1);
|
MyTemplateA_collectorInsertAndMakeBase_35(nargout, out, nargin-1, in+1);
|
||||||
break;
|
break;
|
||||||
case 36:
|
case 36:
|
||||||
ForwardKinematicsFactor_upcastFromVoid_36(nargout, out, nargin-1, in+1);
|
MyTemplateA_upcastFromVoid_36(nargout, out, nargin-1, in+1);
|
||||||
break;
|
break;
|
||||||
case 37:
|
case 37:
|
||||||
ForwardKinematicsFactor_deconstructor_37(nargout, out, nargin-1, in+1);
|
MyTemplateA_constructor_37(nargout, out, nargin-1, in+1);
|
||||||
|
break;
|
||||||
|
case 38:
|
||||||
|
MyTemplateA_deconstructor_38(nargout, out, nargin-1, in+1);
|
||||||
|
break;
|
||||||
|
case 39:
|
||||||
|
MyTemplateA_accept_T_39(nargout, out, nargin-1, in+1);
|
||||||
|
break;
|
||||||
|
case 40:
|
||||||
|
MyTemplateA_accept_Tptr_40(nargout, out, nargin-1, in+1);
|
||||||
|
break;
|
||||||
|
case 41:
|
||||||
|
MyTemplateA_create_MixedPtrs_41(nargout, out, nargin-1, in+1);
|
||||||
|
break;
|
||||||
|
case 42:
|
||||||
|
MyTemplateA_create_ptrs_42(nargout, out, nargin-1, in+1);
|
||||||
|
break;
|
||||||
|
case 43:
|
||||||
|
MyTemplateA_return_T_43(nargout, out, nargin-1, in+1);
|
||||||
|
break;
|
||||||
|
case 44:
|
||||||
|
MyTemplateA_return_Tptr_44(nargout, out, nargin-1, in+1);
|
||||||
|
break;
|
||||||
|
case 45:
|
||||||
|
MyTemplateA_return_ptrs_45(nargout, out, nargin-1, in+1);
|
||||||
|
break;
|
||||||
|
case 46:
|
||||||
|
MyTemplateA_templatedMethod_46(nargout, out, nargin-1, in+1);
|
||||||
|
break;
|
||||||
|
case 47:
|
||||||
|
MyTemplateA_templatedMethod_47(nargout, out, nargin-1, in+1);
|
||||||
|
break;
|
||||||
|
case 48:
|
||||||
|
MyTemplateA_templatedMethod_48(nargout, out, nargin-1, in+1);
|
||||||
|
break;
|
||||||
|
case 49:
|
||||||
|
MyTemplateA_templatedMethod_49(nargout, out, nargin-1, in+1);
|
||||||
|
break;
|
||||||
|
case 50:
|
||||||
|
MyTemplateA_Level_50(nargout, out, nargin-1, in+1);
|
||||||
|
break;
|
||||||
|
case 51:
|
||||||
|
ForwardKinematicsFactor_collectorInsertAndMakeBase_51(nargout, out, nargin-1, in+1);
|
||||||
|
break;
|
||||||
|
case 52:
|
||||||
|
ForwardKinematicsFactor_upcastFromVoid_52(nargout, out, nargin-1, in+1);
|
||||||
|
break;
|
||||||
|
case 53:
|
||||||
|
ForwardKinematicsFactor_deconstructor_53(nargout, out, nargin-1, in+1);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
} catch(const std::exception& e) {
|
} catch(const std::exception& e) {
|
||||||
|
|
|
@ -54,6 +54,21 @@ PYBIND11_MODULE(inheritance_py, m_) {
|
||||||
.def("return_ptrs",[](MyTemplate<gtsam::Matrix>* self, const std::shared_ptr<gtsam::Matrix> p1, const std::shared_ptr<gtsam::Matrix> p2){return self->return_ptrs(p1, p2);}, py::arg("p1"), py::arg("p2"))
|
.def("return_ptrs",[](MyTemplate<gtsam::Matrix>* self, const std::shared_ptr<gtsam::Matrix> p1, const std::shared_ptr<gtsam::Matrix> p2){return self->return_ptrs(p1, p2);}, py::arg("p1"), py::arg("p2"))
|
||||||
.def_static("Level",[](const gtsam::Matrix& K){return MyTemplate<gtsam::Matrix>::Level(K);}, py::arg("K"));
|
.def_static("Level",[](const gtsam::Matrix& K){return MyTemplate<gtsam::Matrix>::Level(K);}, py::arg("K"));
|
||||||
|
|
||||||
|
py::class_<MyTemplate<A>, MyBase, std::shared_ptr<MyTemplate<A>>>(m_, "MyTemplateA")
|
||||||
|
.def(py::init<>())
|
||||||
|
.def("templatedMethodPoint2",[](MyTemplate<A>* self, const gtsam::Point2& t){return self->templatedMethod<gtsam::Point2>(t);}, py::arg("t"))
|
||||||
|
.def("templatedMethodPoint3",[](MyTemplate<A>* self, const gtsam::Point3& t){return self->templatedMethod<gtsam::Point3>(t);}, py::arg("t"))
|
||||||
|
.def("templatedMethodVector",[](MyTemplate<A>* self, const gtsam::Vector& t){return self->templatedMethod<gtsam::Vector>(t);}, py::arg("t"))
|
||||||
|
.def("templatedMethodMatrix",[](MyTemplate<A>* self, const gtsam::Matrix& t){return self->templatedMethod<gtsam::Matrix>(t);}, py::arg("t"))
|
||||||
|
.def("accept_T",[](MyTemplate<A>* self, const A& value){ self->accept_T(value);}, py::arg("value"))
|
||||||
|
.def("accept_Tptr",[](MyTemplate<A>* self, std::shared_ptr<A> value){ self->accept_Tptr(value);}, py::arg("value"))
|
||||||
|
.def("return_Tptr",[](MyTemplate<A>* self, std::shared_ptr<A> value){return self->return_Tptr(value);}, py::arg("value"))
|
||||||
|
.def("return_T",[](MyTemplate<A>* self, A* value){return self->return_T(value);}, py::arg("value"))
|
||||||
|
.def("create_ptrs",[](MyTemplate<A>* self){return self->create_ptrs();})
|
||||||
|
.def("create_MixedPtrs",[](MyTemplate<A>* self){return self->create_MixedPtrs();})
|
||||||
|
.def("return_ptrs",[](MyTemplate<A>* self, std::shared_ptr<A> p1, std::shared_ptr<A> p2){return self->return_ptrs(p1, p2);}, py::arg("p1"), py::arg("p2"))
|
||||||
|
.def_static("Level",[](const A& K){return MyTemplate<A>::Level(K);}, py::arg("K"));
|
||||||
|
|
||||||
py::class_<ForwardKinematicsFactor, gtsam::BetweenFactor<gtsam::Pose3>, std::shared_ptr<ForwardKinematicsFactor>>(m_, "ForwardKinematicsFactor");
|
py::class_<ForwardKinematicsFactor, gtsam::BetweenFactor<gtsam::Pose3>, std::shared_ptr<ForwardKinematicsFactor>>(m_, "ForwardKinematicsFactor");
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -4,7 +4,7 @@ virtual class MyBase {
|
||||||
};
|
};
|
||||||
|
|
||||||
// A templated class
|
// A templated class
|
||||||
template<T = {gtsam::Point2, Matrix}>
|
template<T = {gtsam::Point2, Matrix, A}>
|
||||||
virtual class MyTemplate : MyBase {
|
virtual class MyTemplate : MyBase {
|
||||||
MyTemplate();
|
MyTemplate();
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue