4 Helper script to wrap C++ to Matlab. 5 This script is installed via CMake to the user's binary directory 6 and invoked during the wrapping by CMake. 16 if __name__ ==
"__main__":
17 arg_parser = argparse.ArgumentParser(
18 formatter_class=argparse.ArgumentDefaultsHelpFormatter)
19 arg_parser.add_argument(
"--src", type=str, required=
True,
20 help=
"Input interface .h file.")
21 arg_parser.add_argument(
"--module_name", type=str, required=
True,
22 help=
"Name of the C++ class being wrapped.")
23 arg_parser.add_argument(
"--out", type=str, required=
True,
24 help=
"Name of the output folder.")
25 arg_parser.add_argument(
26 "--top_module_namespaces",
29 help=
"C++ namespace for the top module, e.g. `ns1::ns2::ns3`. " 30 "Only the content within this namespace and its sub-namespaces " 31 "will be wrapped. The content of this namespace will be available at " 32 "the top module level, and its sub-namespaces' in the submodules.\n" 33 "For example, `import <module_name>` gives you access to a Python " 34 "`<module_name>.Class` of the corresponding C++ `ns1::ns2::ns3::Class`" 35 ", and `from <module_name> import ns4` gives you access to a Python " 36 "`ns4.Class` of the C++ `ns1::ns2::ns3::ns4::Class`. ")
37 arg_parser.add_argument(
"--ignore",
40 help=
"A space-separated list of classes to ignore. " 41 "Class names must include their full namespaces.")
42 args = arg_parser.parse_args()
44 top_module_namespaces = args.top_module_namespaces.split(
"::")
45 if top_module_namespaces[0]:
46 top_module_namespaces = [
''] + top_module_namespaces
48 with open(args.src,
'r') as f: 51 if not os.path.exists(args.src):
54 module = parser.Module.parseString(content)
56 instantiator.instantiate_namespace_inplace(module)
60 print(
"Ignoring classes: {}".format(args.ignore), file=sys.stderr)
62 module_name=args.module_name,
63 top_module_namespace=top_module_namespaces,
64 ignore_classes=args.ignore)
66 cc_content = wrapper.wrap()
void print(const Matrix &A, const string &s, ostream &stream)
def generate_content(cc_content, path, verbose=False)