2011-10-14 02:41:56 +08:00
|
|
|
/* ----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
* GTSAM Copyright 2010, Georgia Tech Research Corporation,
|
|
|
|
* Atlanta, Georgia 30332-0415
|
|
|
|
* All Rights Reserved
|
|
|
|
* Authors: Frank Dellaert, et al. (see THANKS for the full author list)
|
|
|
|
|
|
|
|
* See LICENSE for the license information
|
|
|
|
|
|
|
|
* -------------------------------------------------------------------------- */
|
|
|
|
|
|
|
|
/**
|
2011-12-03 00:43:15 +08:00
|
|
|
* @file wrap.cpp
|
2011-10-14 11:23:14 +08:00
|
|
|
* @brief wraps functions
|
|
|
|
* @author Frank Dellaert
|
2011-10-14 02:41:56 +08:00
|
|
|
**/
|
|
|
|
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <iostream>
|
|
|
|
|
|
|
|
#include "Module.h"
|
|
|
|
|
|
|
|
using namespace std;
|
|
|
|
|
|
|
|
/**
|
2011-10-14 12:43:06 +08:00
|
|
|
* Top-level function to wrap a module
|
|
|
|
* @param interfacePath path to where interface file lives, e.g., borg/gtsam
|
|
|
|
* @param moduleName name of the module to be generated e.g. gtsam
|
|
|
|
* @param toolboxPath path where the toolbox should be generated, e.g. borg/gtsam/build
|
2012-07-01 04:04:16 +08:00
|
|
|
* @param headerPath is the path to matlab.h
|
2011-10-14 02:41:56 +08:00
|
|
|
*/
|
2012-06-05 05:01:25 +08:00
|
|
|
void generate_matlab_toolbox(
|
2012-10-02 22:40:07 +08:00
|
|
|
const string& interfacePath,
|
|
|
|
const string& moduleName,
|
|
|
|
const string& toolboxPath,
|
|
|
|
const string& headerPath)
|
2011-10-14 02:41:56 +08:00
|
|
|
{
|
2011-10-14 12:43:06 +08:00
|
|
|
// Parse interface file into class object
|
2012-10-02 22:40:07 +08:00
|
|
|
// This recursively creates Class objects, Method objects, etc...
|
2012-06-30 02:38:54 +08:00
|
|
|
wrap::Module module(interfacePath, moduleName, false);
|
2011-10-14 02:41:56 +08:00
|
|
|
|
2011-10-14 12:43:06 +08:00
|
|
|
// Then emit MATLAB code
|
2014-11-21 23:56:03 +08:00
|
|
|
module.matlab_code(toolboxPath);
|
2011-10-14 02:41:56 +08:00
|
|
|
}
|
|
|
|
|
2012-04-02 06:21:07 +08:00
|
|
|
/** Displays usage information */
|
|
|
|
void usage() {
|
|
|
|
cerr << "wrap parses an interface file and produces a MATLAB toolbox" << endl;
|
2012-07-05 22:04:51 +08:00
|
|
|
cerr << "usage: wrap interfacePath moduleName toolboxPath headerPath" << endl;
|
2012-04-02 06:21:07 +08:00
|
|
|
cerr << " interfacePath : *absolute* path to directory of module interface file" << endl;
|
|
|
|
cerr << " moduleName : the name of the module, interface file must be called moduleName.h" << endl;
|
|
|
|
cerr << " toolboxPath : the directory in which to generate the wrappers" << endl;
|
2012-07-01 04:04:16 +08:00
|
|
|
cerr << " headerPath : path to matlab.h" << endl;
|
2012-04-02 06:21:07 +08:00
|
|
|
}
|
|
|
|
|
2011-10-14 12:43:06 +08:00
|
|
|
/**
|
|
|
|
* main parses arguments and calls generate_matlab_toolbox above
|
2011-12-02 02:57:32 +08:00
|
|
|
* Typically called from "make all" using appropriate arguments
|
2011-10-14 12:43:06 +08:00
|
|
|
*/
|
2011-10-14 02:41:56 +08:00
|
|
|
int main(int argc, const char* argv[]) {
|
2012-07-05 22:04:51 +08:00
|
|
|
if (argc != 5) {
|
2012-10-02 22:40:07 +08:00
|
|
|
cerr << "Invalid arguments:\n";
|
|
|
|
for (int i=0; i<argc; ++i)
|
|
|
|
cerr << argv[i] << endl;
|
|
|
|
cerr << endl;
|
|
|
|
usage();
|
2011-10-14 02:41:56 +08:00
|
|
|
}
|
2013-01-29 01:41:40 +08:00
|
|
|
else {
|
|
|
|
try {
|
|
|
|
generate_matlab_toolbox(argv[1],argv[2],argv[3],argv[4]);
|
|
|
|
} catch(std::exception& e) {
|
|
|
|
cerr << e.what() << endl;
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
}
|
2011-10-14 12:43:06 +08:00
|
|
|
return 0;
|
2011-10-14 02:41:56 +08:00
|
|
|
}
|