3 Helper script to wrap C++ to Matlab.
4 This script is installed via CMake to the user's binary directory
5 and invoked during the wrapping by CMake.
13 if __name__ ==
"__main__":
14 arg_parser = argparse.ArgumentParser(
15 formatter_class=argparse.ArgumentDefaultsHelpFormatter)
16 arg_parser.add_argument(
"--src",
19 help=
"Input interface .h file.")
20 arg_parser.add_argument(
"--module_name",
23 help=
"Name of the C++ class being wrapped.")
24 arg_parser.add_argument(
"--out",
27 help=
"Name of the output folder.")
28 arg_parser.add_argument(
29 "--top_module_namespaces",
32 help=
"C++ namespace for the top module, e.g. `ns1::ns2::ns3`. "
33 "Only the content within this namespace and its sub-namespaces "
34 "will be wrapped. The content of this namespace will be available at "
35 "the top module level, and its sub-namespaces' in the submodules.\n"
36 "For example, `import <module_name>` gives you access to a Python "
37 "`<module_name>.Class` of the corresponding C++ `ns1::ns2::ns3::Class`"
38 ", and `from <module_name> import ns4` gives you access to a Python "
39 "`ns4.Class` of the C++ `ns1::ns2::ns3::ns4::Class`. ")
40 arg_parser.add_argument(
44 help=
"A space-separated list of classes to ignore. "
45 "Class names must include their full namespaces.")
46 arg_parser.add_argument(
47 "--use-boost-serialization",
49 help=
"Allow boost based serialization methods",
51 args = arg_parser.parse_args()
53 top_module_namespaces = args.top_module_namespaces.split(
"::")
54 if top_module_namespaces[0]:
55 top_module_namespaces = [
''] + top_module_namespaces
57 print(f
"[MatlabWrapper] Ignoring classes: {args.ignore}", file=sys.stderr)
60 module_name=args.module_name,
61 top_module_namespace=top_module_namespaces,
62 ignore_classes=args.ignore,
63 use_boost_serialization=args.use_boost_serialization)
65 sources = args.src.split(
';')
66 cc_content = wrapper.wrap(sources, path=args.out)