commit
d39cb295b9
106
.cproject
106
.cproject
|
@ -592,6 +592,7 @@
|
|||
</target>
|
||||
<target name="tests/testBayesTree.run" path="inference" targetID="org.eclipse.cdt.build.MakeTargetBuilder">
|
||||
<buildCommand>make</buildCommand>
|
||||
<buildArguments/>
|
||||
<buildTarget>tests/testBayesTree.run</buildTarget>
|
||||
<stopOnError>true</stopOnError>
|
||||
<useDefaultCommand>false</useDefaultCommand>
|
||||
|
@ -599,6 +600,7 @@
|
|||
</target>
|
||||
<target name="testBinaryBayesNet.run" path="inference" targetID="org.eclipse.cdt.build.MakeTargetBuilder">
|
||||
<buildCommand>make</buildCommand>
|
||||
<buildArguments/>
|
||||
<buildTarget>testBinaryBayesNet.run</buildTarget>
|
||||
<stopOnError>true</stopOnError>
|
||||
<useDefaultCommand>false</useDefaultCommand>
|
||||
|
@ -646,6 +648,7 @@
|
|||
</target>
|
||||
<target name="testSymbolicBayesNet.run" path="inference" targetID="org.eclipse.cdt.build.MakeTargetBuilder">
|
||||
<buildCommand>make</buildCommand>
|
||||
<buildArguments/>
|
||||
<buildTarget>testSymbolicBayesNet.run</buildTarget>
|
||||
<stopOnError>true</stopOnError>
|
||||
<useDefaultCommand>false</useDefaultCommand>
|
||||
|
@ -653,6 +656,7 @@
|
|||
</target>
|
||||
<target name="tests/testSymbolicFactor.run" path="inference" targetID="org.eclipse.cdt.build.MakeTargetBuilder">
|
||||
<buildCommand>make</buildCommand>
|
||||
<buildArguments/>
|
||||
<buildTarget>tests/testSymbolicFactor.run</buildTarget>
|
||||
<stopOnError>true</stopOnError>
|
||||
<useDefaultCommand>false</useDefaultCommand>
|
||||
|
@ -660,6 +664,7 @@
|
|||
</target>
|
||||
<target name="testSymbolicFactorGraph.run" path="inference" targetID="org.eclipse.cdt.build.MakeTargetBuilder">
|
||||
<buildCommand>make</buildCommand>
|
||||
<buildArguments/>
|
||||
<buildTarget>testSymbolicFactorGraph.run</buildTarget>
|
||||
<stopOnError>true</stopOnError>
|
||||
<useDefaultCommand>false</useDefaultCommand>
|
||||
|
@ -675,6 +680,7 @@
|
|||
</target>
|
||||
<target name="tests/testBayesTree" path="inference" targetID="org.eclipse.cdt.build.MakeTargetBuilder">
|
||||
<buildCommand>make</buildCommand>
|
||||
<buildArguments/>
|
||||
<buildTarget>tests/testBayesTree</buildTarget>
|
||||
<stopOnError>true</stopOnError>
|
||||
<useDefaultCommand>false</useDefaultCommand>
|
||||
|
@ -1122,6 +1128,7 @@
|
|||
</target>
|
||||
<target name="testErrors.run" path="linear" targetID="org.eclipse.cdt.build.MakeTargetBuilder">
|
||||
<buildCommand>make</buildCommand>
|
||||
<buildArguments/>
|
||||
<buildTarget>testErrors.run</buildTarget>
|
||||
<stopOnError>true</stopOnError>
|
||||
<useDefaultCommand>false</useDefaultCommand>
|
||||
|
@ -1351,6 +1358,46 @@
|
|||
<useDefaultCommand>true</useDefaultCommand>
|
||||
<runAllBuilders>true</runAllBuilders>
|
||||
</target>
|
||||
<target name="testBTree.run" path="build/gtsam_unstable/base/tests" targetID="org.eclipse.cdt.build.MakeTargetBuilder">
|
||||
<buildCommand>make</buildCommand>
|
||||
<buildArguments>-j5</buildArguments>
|
||||
<buildTarget>testBTree.run</buildTarget>
|
||||
<stopOnError>true</stopOnError>
|
||||
<useDefaultCommand>true</useDefaultCommand>
|
||||
<runAllBuilders>true</runAllBuilders>
|
||||
</target>
|
||||
<target name="testDSF.run" path="build/gtsam_unstable/base/tests" targetID="org.eclipse.cdt.build.MakeTargetBuilder">
|
||||
<buildCommand>make</buildCommand>
|
||||
<buildArguments>-j5</buildArguments>
|
||||
<buildTarget>testDSF.run</buildTarget>
|
||||
<stopOnError>true</stopOnError>
|
||||
<useDefaultCommand>true</useDefaultCommand>
|
||||
<runAllBuilders>true</runAllBuilders>
|
||||
</target>
|
||||
<target name="testDSFMap.run" path="build/gtsam_unstable/base/tests" targetID="org.eclipse.cdt.build.MakeTargetBuilder">
|
||||
<buildCommand>make</buildCommand>
|
||||
<buildArguments>-j5</buildArguments>
|
||||
<buildTarget>testDSFMap.run</buildTarget>
|
||||
<stopOnError>true</stopOnError>
|
||||
<useDefaultCommand>true</useDefaultCommand>
|
||||
<runAllBuilders>true</runAllBuilders>
|
||||
</target>
|
||||
<target name="testDSFVector.run" path="build/gtsam_unstable/base/tests" targetID="org.eclipse.cdt.build.MakeTargetBuilder">
|
||||
<buildCommand>make</buildCommand>
|
||||
<buildArguments>-j5</buildArguments>
|
||||
<buildTarget>testDSFVector.run</buildTarget>
|
||||
<stopOnError>true</stopOnError>
|
||||
<useDefaultCommand>true</useDefaultCommand>
|
||||
<runAllBuilders>true</runAllBuilders>
|
||||
</target>
|
||||
<target name="testFixedVector.run" path="build/gtsam_unstable/base/tests" targetID="org.eclipse.cdt.build.MakeTargetBuilder">
|
||||
<buildCommand>make</buildCommand>
|
||||
<buildArguments>-j5</buildArguments>
|
||||
<buildTarget>testFixedVector.run</buildTarget>
|
||||
<stopOnError>true</stopOnError>
|
||||
<useDefaultCommand>true</useDefaultCommand>
|
||||
<runAllBuilders>true</runAllBuilders>
|
||||
</target>
|
||||
<target name="all" path="slam" targetID="org.eclipse.cdt.build.MakeTargetBuilder">
|
||||
<buildCommand>make</buildCommand>
|
||||
<buildArguments>-j2</buildArguments>
|
||||
|
@ -1433,7 +1480,6 @@
|
|||
</target>
|
||||
<target name="testSimulated2DOriented.run" path="slam" targetID="org.eclipse.cdt.build.MakeTargetBuilder">
|
||||
<buildCommand>make</buildCommand>
|
||||
<buildArguments/>
|
||||
<buildTarget>testSimulated2DOriented.run</buildTarget>
|
||||
<stopOnError>true</stopOnError>
|
||||
<useDefaultCommand>false</useDefaultCommand>
|
||||
|
@ -1473,7 +1519,6 @@
|
|||
</target>
|
||||
<target name="testSimulated2D.run" path="slam" targetID="org.eclipse.cdt.build.MakeTargetBuilder">
|
||||
<buildCommand>make</buildCommand>
|
||||
<buildArguments/>
|
||||
<buildTarget>testSimulated2D.run</buildTarget>
|
||||
<stopOnError>true</stopOnError>
|
||||
<useDefaultCommand>false</useDefaultCommand>
|
||||
|
@ -1481,7 +1526,6 @@
|
|||
</target>
|
||||
<target name="testSimulated3D.run" path="slam" targetID="org.eclipse.cdt.build.MakeTargetBuilder">
|
||||
<buildCommand>make</buildCommand>
|
||||
<buildArguments/>
|
||||
<buildTarget>testSimulated3D.run</buildTarget>
|
||||
<stopOnError>true</stopOnError>
|
||||
<useDefaultCommand>false</useDefaultCommand>
|
||||
|
@ -1495,46 +1539,6 @@
|
|||
<useDefaultCommand>true</useDefaultCommand>
|
||||
<runAllBuilders>true</runAllBuilders>
|
||||
</target>
|
||||
<target name="testBTree.run" path="build/gtsam_unstable/base/tests" targetID="org.eclipse.cdt.build.MakeTargetBuilder">
|
||||
<buildCommand>make</buildCommand>
|
||||
<buildArguments>-j5</buildArguments>
|
||||
<buildTarget>testBTree.run</buildTarget>
|
||||
<stopOnError>true</stopOnError>
|
||||
<useDefaultCommand>true</useDefaultCommand>
|
||||
<runAllBuilders>true</runAllBuilders>
|
||||
</target>
|
||||
<target name="testDSF.run" path="build/gtsam_unstable/base/tests" targetID="org.eclipse.cdt.build.MakeTargetBuilder">
|
||||
<buildCommand>make</buildCommand>
|
||||
<buildArguments>-j5</buildArguments>
|
||||
<buildTarget>testDSF.run</buildTarget>
|
||||
<stopOnError>true</stopOnError>
|
||||
<useDefaultCommand>true</useDefaultCommand>
|
||||
<runAllBuilders>true</runAllBuilders>
|
||||
</target>
|
||||
<target name="testDSFMap.run" path="build/gtsam_unstable/base/tests" targetID="org.eclipse.cdt.build.MakeTargetBuilder">
|
||||
<buildCommand>make</buildCommand>
|
||||
<buildArguments>-j5</buildArguments>
|
||||
<buildTarget>testDSFMap.run</buildTarget>
|
||||
<stopOnError>true</stopOnError>
|
||||
<useDefaultCommand>true</useDefaultCommand>
|
||||
<runAllBuilders>true</runAllBuilders>
|
||||
</target>
|
||||
<target name="testDSFVector.run" path="build/gtsam_unstable/base/tests" targetID="org.eclipse.cdt.build.MakeTargetBuilder">
|
||||
<buildCommand>make</buildCommand>
|
||||
<buildArguments>-j5</buildArguments>
|
||||
<buildTarget>testDSFVector.run</buildTarget>
|
||||
<stopOnError>true</stopOnError>
|
||||
<useDefaultCommand>true</useDefaultCommand>
|
||||
<runAllBuilders>true</runAllBuilders>
|
||||
</target>
|
||||
<target name="testFixedVector.run" path="build/gtsam_unstable/base/tests" targetID="org.eclipse.cdt.build.MakeTargetBuilder">
|
||||
<buildCommand>make</buildCommand>
|
||||
<buildArguments>-j5</buildArguments>
|
||||
<buildTarget>testFixedVector.run</buildTarget>
|
||||
<stopOnError>true</stopOnError>
|
||||
<useDefaultCommand>true</useDefaultCommand>
|
||||
<runAllBuilders>true</runAllBuilders>
|
||||
</target>
|
||||
<target name="testEliminationTree.run" path="build/gtsam/inference/tests" targetID="org.eclipse.cdt.build.MakeTargetBuilder">
|
||||
<buildCommand>make</buildCommand>
|
||||
<buildArguments>-j5</buildArguments>
|
||||
|
@ -1792,6 +1796,7 @@
|
|||
</target>
|
||||
<target name="Generate DEB Package" path="" targetID="org.eclipse.cdt.build.MakeTargetBuilder">
|
||||
<buildCommand>cpack</buildCommand>
|
||||
<buildArguments/>
|
||||
<buildTarget>-G DEB</buildTarget>
|
||||
<stopOnError>true</stopOnError>
|
||||
<useDefaultCommand>false</useDefaultCommand>
|
||||
|
@ -1799,6 +1804,7 @@
|
|||
</target>
|
||||
<target name="Generate RPM Package" path="" targetID="org.eclipse.cdt.build.MakeTargetBuilder">
|
||||
<buildCommand>cpack</buildCommand>
|
||||
<buildArguments/>
|
||||
<buildTarget>-G RPM</buildTarget>
|
||||
<stopOnError>true</stopOnError>
|
||||
<useDefaultCommand>false</useDefaultCommand>
|
||||
|
@ -1806,6 +1812,7 @@
|
|||
</target>
|
||||
<target name="Generate TGZ Package" path="" targetID="org.eclipse.cdt.build.MakeTargetBuilder">
|
||||
<buildCommand>cpack</buildCommand>
|
||||
<buildArguments/>
|
||||
<buildTarget>-G TGZ</buildTarget>
|
||||
<stopOnError>true</stopOnError>
|
||||
<useDefaultCommand>false</useDefaultCommand>
|
||||
|
@ -1813,6 +1820,7 @@
|
|||
</target>
|
||||
<target name="Generate TGZ Source Package" path="" targetID="org.eclipse.cdt.build.MakeTargetBuilder">
|
||||
<buildCommand>cpack</buildCommand>
|
||||
<buildArguments/>
|
||||
<buildTarget>--config CPackSourceConfig.cmake</buildTarget>
|
||||
<stopOnError>true</stopOnError>
|
||||
<useDefaultCommand>false</useDefaultCommand>
|
||||
|
@ -2425,6 +2433,14 @@
|
|||
<useDefaultCommand>true</useDefaultCommand>
|
||||
<runAllBuilders>true</runAllBuilders>
|
||||
</target>
|
||||
<target name="testGlobalFunction.run" path="build/wrap/tests" targetID="org.eclipse.cdt.build.MakeTargetBuilder">
|
||||
<buildCommand>make</buildCommand>
|
||||
<buildArguments>-j4</buildArguments>
|
||||
<buildTarget>testGlobalFunction.run</buildTarget>
|
||||
<stopOnError>true</stopOnError>
|
||||
<useDefaultCommand>true</useDefaultCommand>
|
||||
<runAllBuilders>true</runAllBuilders>
|
||||
</target>
|
||||
<target name="schedulingExample.run" path="build/gtsam_unstable/discrete/tests" targetID="org.eclipse.cdt.build.MakeTargetBuilder">
|
||||
<buildCommand>make</buildCommand>
|
||||
<buildArguments>-j5</buildArguments>
|
||||
|
@ -2659,6 +2675,7 @@
|
|||
</target>
|
||||
<target name="testGraph.run" path="build/tests" targetID="org.eclipse.cdt.build.MakeTargetBuilder">
|
||||
<buildCommand>make</buildCommand>
|
||||
<buildArguments/>
|
||||
<buildTarget>testGraph.run</buildTarget>
|
||||
<stopOnError>true</stopOnError>
|
||||
<useDefaultCommand>false</useDefaultCommand>
|
||||
|
@ -2666,6 +2683,7 @@
|
|||
</target>
|
||||
<target name="testJunctionTree.run" path="build/tests" targetID="org.eclipse.cdt.build.MakeTargetBuilder">
|
||||
<buildCommand>make</buildCommand>
|
||||
<buildArguments/>
|
||||
<buildTarget>testJunctionTree.run</buildTarget>
|
||||
<stopOnError>true</stopOnError>
|
||||
<useDefaultCommand>false</useDefaultCommand>
|
||||
|
@ -2673,6 +2691,7 @@
|
|||
</target>
|
||||
<target name="testSymbolicBayesNetB.run" path="build/tests" targetID="org.eclipse.cdt.build.MakeTargetBuilder">
|
||||
<buildCommand>make</buildCommand>
|
||||
<buildArguments/>
|
||||
<buildTarget>testSymbolicBayesNetB.run</buildTarget>
|
||||
<stopOnError>true</stopOnError>
|
||||
<useDefaultCommand>false</useDefaultCommand>
|
||||
|
@ -3216,7 +3235,6 @@
|
|||
</target>
|
||||
<target name="tests/testGaussianISAM2" path="build/slam" targetID="org.eclipse.cdt.build.MakeTargetBuilder">
|
||||
<buildCommand>make</buildCommand>
|
||||
<buildArguments/>
|
||||
<buildTarget>tests/testGaussianISAM2</buildTarget>
|
||||
<stopOnError>true</stopOnError>
|
||||
<useDefaultCommand>false</useDefaultCommand>
|
||||
|
|
|
@ -171,27 +171,28 @@ struct ArgumentListGrammar: public classic::grammar<ArgumentListGrammar> {
|
|||
|
||||
wrap::ArgumentList& result_; ///< successful parse will be placed in here
|
||||
|
||||
const Argument arg0; ///< used to reset arg
|
||||
mutable Argument arg; ///< temporary argument for use during parsing
|
||||
ArgumentGrammar argument_g; ///< single Argument parser
|
||||
|
||||
/// Construct type grammar and specify where result is placed
|
||||
ArgumentListGrammar(wrap::ArgumentList& result) :
|
||||
result_(result), argument_g(arg) {
|
||||
result_(result) {
|
||||
}
|
||||
|
||||
/// Definition of type grammar
|
||||
template<typename ScannerT>
|
||||
struct definition {
|
||||
|
||||
const Argument arg0; ///< used to reset arg
|
||||
Argument arg; ///< temporary argument for use during parsing
|
||||
ArgumentGrammar argument_g; ///< single Argument parser
|
||||
|
||||
classic::rule<ScannerT> argument_p, argumentList_p;
|
||||
|
||||
definition(ArgumentListGrammar const& self) {
|
||||
definition(ArgumentListGrammar const& self) :
|
||||
argument_g(arg) {
|
||||
using namespace classic;
|
||||
|
||||
argument_p = self.argument_g //
|
||||
[classic::push_back_a(self.result_, self.arg)] //
|
||||
[assign_a(self.arg, self.arg0)];
|
||||
argument_p = argument_g //
|
||||
[classic::push_back_a(self.result_, arg)] //
|
||||
[assign_a(arg, arg0)];
|
||||
|
||||
argumentList_p = '(' >> !argument_p >> *(',' >> argument_p) >> ')';
|
||||
}
|
||||
|
|
132
wrap/Class.h
132
wrap/Class.h
|
@ -19,6 +19,7 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include "spirit.h"
|
||||
#include "Template.h"
|
||||
#include "Constructor.h"
|
||||
#include "Deconstructor.h"
|
||||
|
@ -26,6 +27,18 @@
|
|||
#include "StaticMethod.h"
|
||||
#include "TypeAttributesTable.h"
|
||||
|
||||
#ifdef __GNUC__
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wunused-variable"
|
||||
#endif
|
||||
#include <boost/lambda/bind.hpp>
|
||||
#include <boost/lambda/lambda.hpp>
|
||||
#ifdef __GNUC__
|
||||
#pragma GCC diagnostic pop
|
||||
#endif
|
||||
|
||||
namespace bl = boost::lambda;
|
||||
|
||||
#include <boost/foreach.hpp>
|
||||
#include <boost/range/adaptor/map.hpp>
|
||||
#include <boost/optional.hpp>
|
||||
|
@ -145,5 +158,122 @@ private:
|
|||
void comment_fragment(FileWriter& proxyFile) const;
|
||||
};
|
||||
|
||||
} // \namespace wrap
|
||||
/* ************************************************************************* */
|
||||
// http://boost-spirit.com/distrib/spirit_1_8_2/libs/spirit/doc/grammar.html
|
||||
struct ClassGrammar: public classic::grammar<ClassGrammar> {
|
||||
|
||||
Class& cls_; ///< successful parse will be placed in here
|
||||
Template& template_; ///< result needs to be visible outside
|
||||
|
||||
/// Construct type grammar and specify where result is placed
|
||||
ClassGrammar(Class& cls, Template& t) :
|
||||
cls_(cls), template_(t) {
|
||||
}
|
||||
|
||||
/// Definition of type grammar
|
||||
template<typename ScannerT>
|
||||
struct definition: BasicRules<ScannerT> {
|
||||
|
||||
using BasicRules<ScannerT>::name_p;
|
||||
using BasicRules<ScannerT>::className_p;
|
||||
using BasicRules<ScannerT>::comments_p;
|
||||
|
||||
// NOTE: allows for pointers to all types
|
||||
ArgumentList args;
|
||||
ArgumentListGrammar argumentList_g;
|
||||
|
||||
Constructor constructor0, constructor;
|
||||
|
||||
ReturnValue retVal0, retVal;
|
||||
ReturnValueGrammar returnValue_g;
|
||||
|
||||
Template methodTemplate;
|
||||
TemplateGrammar methodTemplate_g, classTemplate_g;
|
||||
|
||||
std::string methodName;
|
||||
bool isConst, T, F;
|
||||
|
||||
// Parent class
|
||||
Qualified possibleParent;
|
||||
TypeGrammar classParent_g;
|
||||
|
||||
classic::rule<ScannerT> constructor_p, methodName_p, method_p,
|
||||
staticMethodName_p, static_method_p, templateList_p, classParent_p,
|
||||
functions_p, class_p;
|
||||
|
||||
definition(ClassGrammar const& self) :
|
||||
argumentList_g(args), returnValue_g(retVal), //
|
||||
methodTemplate_g(methodTemplate), classTemplate_g(self.template_), //
|
||||
T(true), F(false), classParent_g(possibleParent) {
|
||||
|
||||
using namespace classic;
|
||||
bool verbose = false; // TODO
|
||||
|
||||
// ConstructorGrammar
|
||||
constructor_p = (className_p >> argumentList_g >> ';' >> !comments_p) //
|
||||
[bl::bind(&Constructor::push_back, bl::var(constructor),
|
||||
bl::var(args))] //
|
||||
[clear_a(args)];
|
||||
|
||||
// MethodGrammar
|
||||
methodName_p = lexeme_d[(upper_p | lower_p) >> *(alnum_p | '_')];
|
||||
|
||||
// gtsam::Values retract(const gtsam::VectorValues& delta) const;
|
||||
method_p = !methodTemplate_g
|
||||
>> (returnValue_g >> methodName_p[assign_a(methodName)]
|
||||
>> argumentList_g >> !str_p("const")[assign_a(isConst, T)] >> ';'
|
||||
>> *comments_p) //
|
||||
[bl::bind(&Class::addMethod, bl::var(self.cls_), verbose,
|
||||
bl::var(isConst), bl::var(methodName), bl::var(args),
|
||||
bl::var(retVal), bl::var(methodTemplate))] //
|
||||
[assign_a(retVal, retVal0)][clear_a(args)] //
|
||||
[clear_a(methodTemplate)][assign_a(isConst, F)];
|
||||
|
||||
// StaticMethodGrammar
|
||||
staticMethodName_p = lexeme_d[(upper_p | lower_p) >> *(alnum_p | '_')];
|
||||
|
||||
static_method_p = (str_p("static") >> returnValue_g
|
||||
>> staticMethodName_p[assign_a(methodName)] >> argumentList_g >> ';'
|
||||
>> *comments_p) //
|
||||
[bl::bind(&StaticMethod::addOverload,
|
||||
bl::var(self.cls_.static_methods)[bl::var(methodName)],
|
||||
bl::var(methodName), bl::var(args), bl::var(retVal), boost::none,
|
||||
verbose)] //
|
||||
[assign_a(retVal, retVal0)][clear_a(args)];
|
||||
|
||||
// template<POSE, POINT>
|
||||
templateList_p = (str_p("template") >> '<'
|
||||
>> name_p[push_back_a(self.cls_.templateArgs)]
|
||||
>> *(',' >> name_p[push_back_a(self.cls_.templateArgs)]) >> '>');
|
||||
|
||||
// parse a full class
|
||||
classParent_p = (':' >> classParent_g >> '{') //
|
||||
[bl::bind(&Class::assignParent, bl::var(self.cls_),
|
||||
bl::var(possibleParent))][clear_a(possibleParent)];
|
||||
|
||||
functions_p = constructor_p | method_p | static_method_p;
|
||||
|
||||
// parse a full class
|
||||
class_p = (!(classTemplate_g[push_back_a(self.cls_.templateArgs,
|
||||
self.template_.argName())] | templateList_p)
|
||||
>> !(str_p("virtual")[assign_a(self.cls_.isVirtual, T)])
|
||||
>> str_p("class") >> className_p[assign_a(self.cls_.name_)]
|
||||
>> (classParent_p | '{') >> //
|
||||
*(functions_p | comments_p) >> str_p("};")) //
|
||||
[bl::bind(&Constructor::initializeOrCheck, bl::var(constructor),
|
||||
bl::var(self.cls_.name_), boost::none, verbose)][assign_a(
|
||||
self.cls_.constructor, constructor)] //
|
||||
[assign_a(self.cls_.deconstructor.name, self.cls_.name_)] //
|
||||
[assign_a(constructor, constructor0)];
|
||||
}
|
||||
|
||||
classic::rule<ScannerT> const& start() const {
|
||||
return class_p;
|
||||
}
|
||||
|
||||
};
|
||||
};
|
||||
// ClassGrammar
|
||||
|
||||
}// \namespace wrap
|
||||
|
||||
|
|
|
@ -11,6 +11,18 @@
|
|||
|
||||
#include "FullyOverloadedFunction.h"
|
||||
|
||||
#ifdef __GNUC__
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wunused-variable"
|
||||
#endif
|
||||
#include <boost/lambda/bind.hpp>
|
||||
#include <boost/lambda/lambda.hpp>
|
||||
#ifdef __GNUC__
|
||||
#pragma GCC diagnostic pop
|
||||
#endif
|
||||
|
||||
namespace bl = boost::lambda;
|
||||
|
||||
namespace wrap {
|
||||
|
||||
struct GlobalFunction: public FullyOverloadedFunction {
|
||||
|
@ -47,5 +59,67 @@ private:
|
|||
|
||||
};
|
||||
|
||||
} // \namespace wrap
|
||||
typedef std::map<std::string, GlobalFunction> GlobalFunctions;
|
||||
|
||||
/* ************************************************************************* */
|
||||
// http://boost-spirit.com/distrib/spirit_1_8_2/libs/spirit/doc/grammar.html
|
||||
struct GlobalFunctionGrammar: public classic::grammar<GlobalFunctionGrammar> {
|
||||
|
||||
GlobalFunctions& global_functions_; ///< successful parse will be placed in here
|
||||
std::vector<std::string>& namespaces_;
|
||||
|
||||
/// Construct type grammar and specify where result is placed
|
||||
GlobalFunctionGrammar(GlobalFunctions& global_functions,
|
||||
std::vector<std::string>& namespaces) :
|
||||
global_functions_(global_functions), namespaces_(namespaces) {
|
||||
}
|
||||
|
||||
/// Definition of type grammar
|
||||
template<typename ScannerT>
|
||||
struct definition: BasicRules<ScannerT> {
|
||||
|
||||
// using BasicRules<ScannerT>::name_p;
|
||||
// using BasicRules<ScannerT>::className_p;
|
||||
using BasicRules<ScannerT>::comments_p;
|
||||
|
||||
ArgumentList args;
|
||||
ArgumentListGrammar argumentList_g;
|
||||
|
||||
ReturnValue retVal0, retVal;
|
||||
ReturnValueGrammar returnValue_g;
|
||||
|
||||
Qualified globalFunction;
|
||||
|
||||
classic::rule<ScannerT> globalFunctionName_p, global_function_p;
|
||||
|
||||
definition(GlobalFunctionGrammar const& self) :
|
||||
argumentList_g(args), returnValue_g(retVal) {
|
||||
|
||||
using namespace classic;
|
||||
bool verbose = false; // TODO
|
||||
|
||||
globalFunctionName_p = lexeme_d[(upper_p | lower_p) >> *(alnum_p | '_')];
|
||||
|
||||
// parse a global function
|
||||
global_function_p = (returnValue_g
|
||||
>> globalFunctionName_p[assign_a(globalFunction.name_)]
|
||||
>> argumentList_g >> ';' >> *comments_p) //
|
||||
[assign_a(globalFunction.namespaces_, self.namespaces_)][bl::bind(
|
||||
&GlobalFunction::addOverload,
|
||||
bl::var(self.global_functions_)[bl::var(globalFunction.name_)],
|
||||
bl::var(globalFunction), bl::var(args), bl::var(retVal),
|
||||
boost::none, verbose)] //
|
||||
[assign_a(retVal, retVal0)][clear_a(globalFunction)][clear_a(args)];
|
||||
|
||||
}
|
||||
|
||||
classic::rule<ScannerT> const& start() const {
|
||||
return global_function_p;
|
||||
}
|
||||
|
||||
};
|
||||
};
|
||||
// GlobalFunctionGrammar
|
||||
|
||||
}// \namespace wrap
|
||||
|
||||
|
|
166
wrap/Module.cpp
166
wrap/Module.cpp
|
@ -22,19 +22,6 @@
|
|||
#include "TypeAttributesTable.h"
|
||||
#include "utilities.h"
|
||||
|
||||
//#define BOOST_SPIRIT_DEBUG
|
||||
#include "spirit.h"
|
||||
|
||||
#ifdef __GNUC__
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wunused-variable"
|
||||
#endif
|
||||
#include <boost/lambda/bind.hpp>
|
||||
#include <boost/lambda/lambda.hpp>
|
||||
#ifdef __GNUC__
|
||||
#pragma GCC diagnostic pop
|
||||
#endif
|
||||
#include <boost/lambda/construct.hpp>
|
||||
#include <boost/foreach.hpp>
|
||||
#include <boost/filesystem.hpp>
|
||||
#include <boost/lexical_cast.hpp>
|
||||
|
@ -111,15 +98,24 @@ void Module::parseMarkup(const std::string& data) {
|
|||
typedef rule<phrase_scanner_t> Rule;
|
||||
BasicRules<phrase_scanner_t> basic;
|
||||
|
||||
// TODO, do we really need cls here? Non-local
|
||||
vector<string> namespaces; // current namespace tag
|
||||
|
||||
// parse a full class
|
||||
Class cls0(verbose),cls(verbose);
|
||||
|
||||
Template classTemplate;
|
||||
ClassGrammar class_g(cls,classTemplate);
|
||||
Rule class_p = class_g //
|
||||
[assign_a(cls.namespaces_, namespaces)]
|
||||
[bl::bind(&handle_possible_template, bl::var(classes), bl::var(cls),
|
||||
bl::var(classTemplate.argValues()))]
|
||||
[clear_a(classTemplate)] //
|
||||
[assign_a(cls,cls0)];
|
||||
|
||||
// parse "gtsam::Pose2" and add to singleInstantiation.typeList
|
||||
TemplateInstantiationTypedef singleInstantiation, singleInstantiation0;
|
||||
TypeListGrammar<'<','>'> typelist_g(singleInstantiation.typeList);
|
||||
|
||||
// typedef gtsam::RangeFactor<gtsam::Pose2, gtsam::Point2> RangeFactorPosePoint2;
|
||||
vector<string> namespaces; // current namespace tag
|
||||
TypeGrammar instantiationClass_g(singleInstantiation.class_);
|
||||
Rule templateSingleInstantiation_p =
|
||||
(str_p("typedef") >> instantiationClass_g >>
|
||||
|
@ -130,109 +126,8 @@ void Module::parseMarkup(const std::string& data) {
|
|||
[push_back_a(templateInstantiationTypedefs, singleInstantiation)]
|
||||
[assign_a(singleInstantiation, singleInstantiation0)];
|
||||
|
||||
// template<POSE, POINT>
|
||||
Rule templateList_p =
|
||||
(str_p("template") >>
|
||||
'<' >> basic.name_p[push_back_a(cls.templateArgs)] >> *(',' >> basic.name_p[push_back_a(cls.templateArgs)]) >>
|
||||
'>');
|
||||
|
||||
// NOTE: allows for pointers to all types
|
||||
ArgumentList args;
|
||||
ArgumentListGrammar argumentList_g(args);
|
||||
|
||||
// parse class constructor
|
||||
Constructor constructor0(verbose), constructor(verbose);
|
||||
Rule constructor_p =
|
||||
(basic.className_p >> argumentList_g >> ';' >> !basic.comments_p)
|
||||
[bl::bind(&Constructor::push_back, bl::var(constructor), bl::var(args))]
|
||||
[clear_a(args)];
|
||||
|
||||
vector<string> namespaces_return; /// namespace for current return type
|
||||
Rule namespace_ret_p = basic.namespace_p[push_back_a(namespaces_return)] >> str_p("::");
|
||||
|
||||
ReturnValue retVal0, retVal;
|
||||
ReturnValueGrammar returnValue_g(retVal);
|
||||
|
||||
Rule methodName_p = lexeme_d[(upper_p | lower_p) >> *(alnum_p | '_')];
|
||||
|
||||
// template<CALIBRATION = {gtsam::Cal3DS2}>
|
||||
Template methodTemplate;
|
||||
TemplateGrammar methodTemplate_g(methodTemplate);
|
||||
|
||||
// gtsam::Values retract(const gtsam::VectorValues& delta) const;
|
||||
string methodName;
|
||||
bool isConst, isConst0 = false;
|
||||
Rule method_p =
|
||||
!methodTemplate_g >>
|
||||
(returnValue_g >> methodName_p[assign_a(methodName)] >>
|
||||
argumentList_g >>
|
||||
!str_p("const")[assign_a(isConst,true)] >> ';' >> *basic.comments_p)
|
||||
[bl::bind(&Class::addMethod, bl::var(cls), verbose, bl::var(isConst),
|
||||
bl::var(methodName), bl::var(args), bl::var(retVal),
|
||||
bl::var(methodTemplate))]
|
||||
[assign_a(retVal,retVal0)]
|
||||
[clear_a(args)]
|
||||
[clear_a(methodTemplate)]
|
||||
[assign_a(isConst,isConst0)];
|
||||
|
||||
Rule staticMethodName_p = lexeme_d[(upper_p | lower_p) >> *(alnum_p | '_')];
|
||||
|
||||
Rule static_method_p =
|
||||
(str_p("static") >> returnValue_g >> staticMethodName_p[assign_a(methodName)] >>
|
||||
argumentList_g >> ';' >> *basic.comments_p)
|
||||
[bl::bind(&StaticMethod::addOverload,
|
||||
bl::var(cls.static_methods)[bl::var(methodName)],
|
||||
bl::var(methodName), bl::var(args), bl::var(retVal), boost::none,verbose)]
|
||||
[assign_a(retVal,retVal0)]
|
||||
[clear_a(args)];
|
||||
|
||||
Rule functions_p = constructor_p | method_p | static_method_p;
|
||||
|
||||
// template<CALIBRATION = {gtsam::Cal3DS2}>
|
||||
Template classTemplate;
|
||||
TemplateGrammar classTemplate_g(classTemplate);
|
||||
|
||||
// Parent class
|
||||
Qualified possibleParent;
|
||||
TypeGrammar classParent_p(possibleParent);
|
||||
|
||||
// parse a full class
|
||||
Rule class_p =
|
||||
eps_p[assign_a(cls,cls0)]
|
||||
>> (!(classTemplate_g
|
||||
[push_back_a(cls.templateArgs, classTemplate.argName())]
|
||||
| templateList_p)
|
||||
>> !(str_p("virtual")[assign_a(cls.isVirtual, true)])
|
||||
>> str_p("class")
|
||||
>> basic.className_p[assign_a(cls.name_)]
|
||||
>> ((':' >> classParent_p >> '{')
|
||||
[bl::bind(&Class::assignParent, bl::var(cls), bl::var(possibleParent))]
|
||||
[clear_a(possibleParent)] | '{')
|
||||
>> *(functions_p | basic.comments_p)
|
||||
>> str_p("};"))
|
||||
[bl::bind(&Constructor::initializeOrCheck, bl::var(constructor),
|
||||
bl::var(cls.name_), boost::none, verbose)]
|
||||
[assign_a(cls.constructor, constructor)]
|
||||
[assign_a(cls.namespaces_, namespaces)]
|
||||
[assign_a(cls.deconstructor.name,cls.name_)]
|
||||
[bl::bind(&handle_possible_template, bl::var(classes), bl::var(cls),
|
||||
bl::var(classTemplate.argValues()))]
|
||||
[clear_a(classTemplate)]
|
||||
[assign_a(constructor, constructor0)]
|
||||
[assign_a(cls,cls0)];
|
||||
|
||||
// parse a global function
|
||||
Qualified globalFunction;
|
||||
Rule global_function_p =
|
||||
(returnValue_g >> staticMethodName_p[assign_a(globalFunction.name_)] >>
|
||||
argumentList_g >> ';' >> *basic.comments_p)
|
||||
[assign_a(globalFunction.namespaces_,namespaces)]
|
||||
[bl::bind(&GlobalFunction::addOverload,
|
||||
bl::var(global_functions)[bl::var(globalFunction.name_)],
|
||||
bl::var(globalFunction), bl::var(args), bl::var(retVal), boost::none,verbose)]
|
||||
[assign_a(retVal,retVal0)]
|
||||
[clear_a(globalFunction)]
|
||||
[clear_a(args)];
|
||||
// Create grammar for global functions
|
||||
GlobalFunctionGrammar global_function_g(global_functions,namespaces);
|
||||
|
||||
Rule include_p = str_p("#include") >> ch_p('<') >> (*(anychar_p - '>'))[push_back_a(includes)] >> ch_p('>');
|
||||
|
||||
|
@ -245,7 +140,7 @@ void Module::parseMarkup(const std::string& data) {
|
|||
(str_p("namespace")
|
||||
>> basic.namespace_p[push_back_a(namespaces)]
|
||||
>> ch_p('{')
|
||||
>> *(include_p | class_p | templateSingleInstantiation_p | global_function_p | namespace_def_p | basic.comments_p)
|
||||
>> *(include_p | class_p | templateSingleInstantiation_p | global_function_g | namespace_def_p | basic.comments_p)
|
||||
>> ch_p('}'))
|
||||
[pop_a(namespaces)];
|
||||
|
||||
|
@ -265,41 +160,16 @@ void Module::parseMarkup(const std::string& data) {
|
|||
|
||||
Rule module_content_p = basic.comments_p | include_p | class_p
|
||||
| templateSingleInstantiation_p | forward_declaration_p
|
||||
| global_function_p | namespace_def_p;
|
||||
| global_function_g | namespace_def_p;
|
||||
|
||||
Rule module_p = *module_content_p >> !end_p;
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
// for debugging, define BOOST_SPIRIT_DEBUG
|
||||
# ifdef BOOST_SPIRIT_DEBUG
|
||||
BOOST_SPIRIT_DEBUG_NODE(className_p);
|
||||
BOOST_SPIRIT_DEBUG_NODE(classPtr_p);
|
||||
BOOST_SPIRIT_DEBUG_NODE(classRef_p);
|
||||
BOOST_SPIRIT_DEBUG_NODE(basisType_p);
|
||||
BOOST_SPIRIT_DEBUG_NODE(name_p);
|
||||
BOOST_SPIRIT_DEBUG_NODE(argument_p);
|
||||
BOOST_SPIRIT_DEBUG_NODE(argumentList_g);
|
||||
BOOST_SPIRIT_DEBUG_NODE(constructor_p);
|
||||
BOOST_SPIRIT_DEBUG_NODE(returnType1_p);
|
||||
BOOST_SPIRIT_DEBUG_NODE(returnType2_p);
|
||||
BOOST_SPIRIT_DEBUG_NODE(pair_p);
|
||||
BOOST_SPIRIT_DEBUG_NODE(void_p);
|
||||
BOOST_SPIRIT_DEBUG_NODE(returnValue_g);
|
||||
BOOST_SPIRIT_DEBUG_NODE(methodName_p);
|
||||
BOOST_SPIRIT_DEBUG_NODE(method_p);
|
||||
BOOST_SPIRIT_DEBUG_NODE(class_p);
|
||||
BOOST_SPIRIT_DEBUG_NODE(namespace_def_p);
|
||||
BOOST_SPIRIT_DEBUG_NODE(module_p);
|
||||
# endif
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
// and parse contents
|
||||
parse_info<const char*> info = parse(data.c_str(), module_p, space_p);
|
||||
if(!info.full) {
|
||||
printf("parsing stopped at \n%.20s\n",info.stop);
|
||||
cout << "Stopped near:\n"
|
||||
"class '" << cls.name_ << "'\n"
|
||||
"method '" << methodName << "'" << endl;
|
||||
cout << "Stopped in:\n"
|
||||
"class '" << cls.name_ << "'" << endl;
|
||||
throw ParseFailed((int)info.length);
|
||||
}
|
||||
|
||||
|
|
|
@ -34,8 +34,6 @@ namespace wrap {
|
|||
*/
|
||||
struct Module {
|
||||
|
||||
typedef std::map<std::string, GlobalFunction> GlobalFunctions;
|
||||
|
||||
// Filled during parsing:
|
||||
std::string name; ///< module name
|
||||
bool verbose; ///< verbose flag
|
||||
|
|
|
@ -222,25 +222,26 @@ struct TypeListGrammar: public classic::grammar<TypeListGrammar<OPEN, CLOSE> > {
|
|||
typedef std::vector<wrap::Qualified> TypeList;
|
||||
TypeList& result_; ///< successful parse will be placed in here
|
||||
|
||||
mutable wrap::Qualified type; // temporary type for use during parsing
|
||||
TypeGrammar type_g;
|
||||
|
||||
/// Construct type grammar and specify where result is placed
|
||||
TypeListGrammar(TypeList& result) :
|
||||
result_(result), type_g(type) {
|
||||
result_(result) {
|
||||
}
|
||||
|
||||
/// Definition of type grammar
|
||||
template<typename ScannerT>
|
||||
struct definition {
|
||||
|
||||
wrap::Qualified type; ///< temporary for use during parsing
|
||||
TypeGrammar type_g; ///< Individual Type grammars
|
||||
|
||||
classic::rule<ScannerT> type_p, typeList_p;
|
||||
|
||||
definition(TypeListGrammar const& self) {
|
||||
definition(TypeListGrammar const& self) :
|
||||
type_g(type) {
|
||||
using namespace classic;
|
||||
type_p = self.type_g //
|
||||
[push_back_a(self.result_, self.type)] //
|
||||
[clear_a(self.type)];
|
||||
|
||||
type_p = type_g[push_back_a(self.result_, type)][clear_a(type)];
|
||||
|
||||
typeList_p = OPEN >> !type_p >> *(',' >> type_p) >> CLOSE;
|
||||
}
|
||||
|
||||
|
|
|
@ -46,7 +46,7 @@ TEST( Class, OverloadingMethod ) {
|
|||
EXPECT_LONGS_EQUAL(1, cls.method(name).nrOverloads());
|
||||
|
||||
// add an overload w different argument list
|
||||
args.push_back(Argument(Qualified("Vector",Qualified::EIGEN),"v"));
|
||||
args.push_back(Argument(Qualified("Vector", Qualified::EIGEN), "v"));
|
||||
cls.addMethod(verbose, is_const, name, args, retVal, tmplate);
|
||||
EXPECT_LONGS_EQUAL(1, cls.nrMethods());
|
||||
EXPECT_LONGS_EQUAL(2, cls.method(name).nrOverloads());
|
||||
|
@ -82,6 +82,84 @@ TEST( Class, TemplatedMethods ) {
|
|||
EXPECT(cls.exists(name+"Point3"));
|
||||
}
|
||||
|
||||
//******************************************************************************
|
||||
TEST( Class, Grammar ) {
|
||||
|
||||
using classic::space_p;
|
||||
|
||||
// Create type grammar that will place result in cls
|
||||
Class cls;
|
||||
Template t;
|
||||
ClassGrammar g(cls, t);
|
||||
|
||||
EXPECT(parse("class Point2 {\n};", g, space_p).full);
|
||||
|
||||
string markup(
|
||||
string("class Point2 { \n")
|
||||
+ string(" double x() const; \n") // Method 1
|
||||
+ string(" Matrix returnMatrix() const; \n") // Method 2
|
||||
+ string(" Point2 returnPoint2() const; \n") // Method 3
|
||||
+ string(" static Vector returnVector(); \n") // Static Method 1
|
||||
+ string("};"));
|
||||
|
||||
EXPECT(parse(markup.c_str(), g, space_p).full);
|
||||
|
||||
// check return types
|
||||
EXPECT(assert_equal("Point2", cls.name()));
|
||||
EXPECT(!cls.isVirtual);
|
||||
EXPECT(cls.namespaces().empty());
|
||||
LONGS_EQUAL(3, cls.nrMethods());
|
||||
LONGS_EQUAL(1, cls.static_methods.size());
|
||||
|
||||
// Method 1
|
||||
Method m1 = cls.method("x");
|
||||
EXPECT(assert_equal("x", m1.name()));
|
||||
EXPECT(m1.isConst());
|
||||
LONGS_EQUAL(1, m1.nrOverloads());
|
||||
|
||||
ReturnValue rv1 = m1.returnValue(0);
|
||||
EXPECT(!rv1.isPair);
|
||||
EXPECT(!rv1.type1.isPtr);
|
||||
EXPECT(assert_equal("double", rv1.type1.name()));
|
||||
EXPECT_LONGS_EQUAL(ReturnType::BASIS, rv1.type1.category);
|
||||
|
||||
// Method 2
|
||||
Method m2 = cls.method("returnMatrix");
|
||||
EXPECT(assert_equal("returnMatrix", m2.name()));
|
||||
EXPECT(m2.isConst());
|
||||
LONGS_EQUAL(1, m2.nrOverloads());
|
||||
|
||||
ReturnValue rv2 = m2.returnValue(0);
|
||||
EXPECT(!rv2.isPair);
|
||||
EXPECT(!rv2.type1.isPtr);
|
||||
EXPECT(assert_equal("Matrix", rv2.type1.name()));
|
||||
EXPECT_LONGS_EQUAL(ReturnType::EIGEN, rv2.type1.category);
|
||||
|
||||
// Method 3
|
||||
Method m3 = cls.method("returnPoint2");
|
||||
EXPECT(assert_equal("returnPoint2", m3.name()));
|
||||
EXPECT(m3.isConst());
|
||||
LONGS_EQUAL(1, m3.nrOverloads());
|
||||
|
||||
ReturnValue rv3 = m3.returnValue(0);
|
||||
EXPECT(!rv3.isPair);
|
||||
EXPECT(!rv3.type1.isPtr);
|
||||
EXPECT(assert_equal("Point2", rv3.type1.name()));
|
||||
EXPECT_LONGS_EQUAL(ReturnType::CLASS, rv3.type1.category);
|
||||
|
||||
// Static Method 1
|
||||
// static Vector returnVector();
|
||||
StaticMethod sm1 = cls.static_methods.at("returnVector");
|
||||
EXPECT(assert_equal("returnVector", sm1.name()));
|
||||
LONGS_EQUAL(1, sm1.nrOverloads());
|
||||
|
||||
ReturnValue rv4 = sm1.returnValue(0);
|
||||
EXPECT(!rv4.isPair);
|
||||
EXPECT(!rv4.type1.isPtr);
|
||||
EXPECT(assert_equal("Vector", rv4.type1.name()));
|
||||
EXPECT_LONGS_EQUAL(ReturnType::EIGEN, rv4.type1.category);
|
||||
}
|
||||
|
||||
/* ************************************************************************* */
|
||||
int main() {
|
||||
TestResult tr;
|
||||
|
|
|
@ -0,0 +1,54 @@
|
|||
/* ----------------------------------------------------------------------------
|
||||
|
||||
* 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
|
||||
|
||||
* -------------------------------------------------------------------------- */
|
||||
|
||||
/**
|
||||
* @file testMethod.cpp
|
||||
* @brief Unit test for GlobalFunction class
|
||||
* @author Frank Dellaert
|
||||
* @date Nov 12, 2014
|
||||
**/
|
||||
|
||||
#include <wrap/GlobalFunction.h>
|
||||
#include <CppUnitLite/TestHarness.h>
|
||||
#include <iostream>
|
||||
|
||||
using namespace std;
|
||||
using namespace wrap;
|
||||
|
||||
//******************************************************************************
|
||||
// Constructor
|
||||
TEST( GlobalFunction, Constructor ) {
|
||||
GlobalFunction f;
|
||||
}
|
||||
|
||||
//******************************************************************************
|
||||
TEST( GlobalFunction, Grammar ) {
|
||||
|
||||
using classic::space_p;
|
||||
|
||||
// Create type grammar that will place result in actual
|
||||
GlobalFunctions actual;
|
||||
vector<string> namespaces;
|
||||
GlobalFunctionGrammar g(actual,namespaces);
|
||||
|
||||
// a class type with namespaces
|
||||
EXPECT(parse("Vector aGlobalFunction();", g, space_p).full);
|
||||
EXPECT(parse("Vector overloadedGlobalFunction(int a);", g, space_p).full);
|
||||
EXPECT(parse("Vector overloadedGlobalFunction(int a, double b);", g, space_p).full);
|
||||
LONGS_EQUAL(2,actual.size());
|
||||
}
|
||||
|
||||
//******************************************************************************
|
||||
int main() {
|
||||
TestResult tr;
|
||||
return TestRegistry::runAllTests(tr);
|
||||
}
|
||||
//******************************************************************************
|
|
@ -42,83 +42,6 @@ TEST( Method, addOverload ) {
|
|||
EXPECT_LONGS_EQUAL(2, method.nrOverloads());
|
||||
}
|
||||
|
||||
//// http://boost-spirit.com/distrib/spirit_1_8_2/libs/spirit/doc/grammar.html
|
||||
//struct method_grammar: public classic::grammar<method_grammar> {
|
||||
//
|
||||
// wrap::Method& result_; ///< successful parse will be placed in here
|
||||
//
|
||||
// ArgumentList args;
|
||||
// Argument arg0, arg;
|
||||
// TypeGrammar argument_type_g;
|
||||
//
|
||||
// ReturnType retType0, retType;
|
||||
// TypeGrammar returntype_g;
|
||||
//
|
||||
// ReturnValue retVal0, retVal;
|
||||
//
|
||||
// /// Construct type grammar and specify where result is placed
|
||||
// method_grammar(wrap::Method& result) :
|
||||
// result_(result), argument_type_g(arg.type), returntype_g(retType) {
|
||||
// }
|
||||
//
|
||||
// /// Definition of type grammar
|
||||
// template<typename ScannerT>
|
||||
// struct definition: basic_rules<ScannerT> {
|
||||
//
|
||||
// Rule templateArgValue_p, templateArgValues_p, argument_p, argumentList_p,
|
||||
// returnType1_p, returnType2_p, pair_p, returnValue_p, methodName_p,
|
||||
// method_p;
|
||||
//
|
||||
// definition(method_grammar const& self) {
|
||||
//
|
||||
// using namespace wrap;
|
||||
// using namespace classic;
|
||||
//
|
||||
//// Rule templateArgValue_p = type_grammar(self.templateArgValue);
|
||||
////
|
||||
//// // template<CALIBRATION = {gtsam::Cal3DS2}>
|
||||
//// Rule templateArgValues_p = (str_p("template") >> '<' >> name_p >> '='
|
||||
//// >> '{' >> !(templateArgValue_p >> *(',' >> templateArgValue_p)) >> '}'
|
||||
//// >> '>');
|
||||
////
|
||||
// // Create type grammar that will place result in actual
|
||||
// ArgumentList actual;
|
||||
// ArgumentListGrammar g(actual);
|
||||
//
|
||||
// EXPECT(parse("(const gtsam::Point2& p4)", g, space_p).full);
|
||||
// EXPECT_LONGS_EQUAL(1, actual.size());
|
||||
// actual.clear();
|
||||
//
|
||||
// returnType1_p = self.returntype_g //
|
||||
// [assign_a(self.retVal.type1, retType)] //
|
||||
// [assign_a(self.retType, self.retType0)];
|
||||
//
|
||||
// returnType2_p = self.returntype_g //
|
||||
// [assign_a(self.retVal.type2, retType)] //
|
||||
// [assign_a(self.retType, self.retType0)];
|
||||
//
|
||||
// pair_p = (str_p("pair") >> '<' >> returnType1_p >> ',' >> returnType2_p
|
||||
// >> '>')[assign_a(self.retVal.isPair, true)];
|
||||
//
|
||||
// returnValue_p = pair_p | returnType1_p;
|
||||
//
|
||||
// methodName_p = lexeme_d[(upper_p | lower_p) >> *(alnum_p | '_')];
|
||||
//
|
||||
// // gtsam::Values retract(const gtsam::VectorValues& delta) const;
|
||||
// method_p =
|
||||
//// !templateArgValues_p >>
|
||||
// (returnValue_p >> methodName_p >> '(' >> argumentList_p >> ')'
|
||||
// >> !str_p("const") >> ';' >> *basic_rules<ScannerT>::comments_p);
|
||||
// }
|
||||
//
|
||||
// Rule const& start() const {
|
||||
// return method_p;
|
||||
// }
|
||||
//
|
||||
// };
|
||||
//};
|
||||
//// method_grammar
|
||||
//
|
||||
////******************************************************************************
|
||||
//TEST( Method, grammar ) {
|
||||
//
|
||||
|
|
Loading…
Reference in New Issue