From: <bl...@us...> - 2003-04-27 13:00:58
|
Update of /cvsroot/cpptool/rfta/src/pyrfta In directory sc8-pr-cvs1:/tmp/cvs-serv19937/src/pyrfta Modified Files: Forwards.h pyrfta.cpp pyrfta.dsp Added Files: ExposeCPPParser.cpp Log Message: * exposed to python: CPPParser, ASTNode, ASTNodeVisitor, ASTNodePropertyVisitor, ASTNodeProperty, ASTNodeType --- NEW FILE: ExposeCPPParser.cpp --- #include "Forwards.h" #include <boost/python.hpp> #include <rfta/parser/CPPParser.h> #include <rfta/parser/ASTNodePropertyVisitor.h> #include <rfta/parser/ASTNodeVisitor.h> using namespace boost::python; using namespace Refactoring; class ASTNodeVisitorWrap : public ASTNodeVisitor { public: PyObject *self; ASTNodeVisitorWrap( PyObject *self_ ) : self(self_) { } // overridden from ASTNodeVisitor void visitNode( const ASTNodePtr &node ) { call_method<void>( self, "visitNode", object(node) ); } }; class ASTNodePropertyVisitorWrap : public ASTNodePropertyVisitor { public: PyObject *self; ASTNodePropertyVisitorWrap( PyObject *self_ ) : self(self_) { } // overridden from ASTNodePropertyVisitor void visitProperty( const ASTNodeProperty &property, const ASTNodePtr &propertyNode ) { call_method<void>( self, "visitProperty", property, object(propertyNode) ); } }; void exposeCPPParser() { class_<CPPParser>( "CPPParser", init<std::string>() ) .def( "parseAll", &CPPParser::parseAll ) .add_property( "sourceNode", &CPPParser::getSourceNode ) ; class_<ASTNode, ASTNodePtr, boost::noncopyable>( "ASTNode", no_init ) .add_property( "type", make_function( &ASTNode::getType, return_value_policy<copy_const_reference>() ), &ASTNode::mutateType ) // .def( "getType", &ASTNode::getType, return_value_policy<copy_const_reference>() ) .add_property( "length", &ASTNode::getLength, &ASTNode::setLength ) .add_property( "startIndex", &ASTNode::getStartIndex ) .add_property( "range", make_function( &ASTNode::getRange, return_value_policy<copy_const_reference>() ) ) // get parent node .def( "addChild", &ASTNode::addChild ) .def( "getChildCount", &ASTNode::getChildCount ) .def( "getChildAt", make_function( &ASTNode::getChildAt, return_value_policy<copy_const_reference>() ) ) .def( "setPropertyNode", &ASTNode::setPropertyNode ) .def( "hasProperty", &ASTNode::hasProperty ) .def( "getProperty", &ASTNode::getProperty ) .def( "removeProperty", &ASTNode::removeProperty ) .def( "removeAllProperties", &ASTNode::removeAllProperties ) .def( "visitProperties", &ASTNode::visitProperties ) .def( "visitChildNodes", &ASTNode::visitChildNodes ) .add_property( "blankedText", &ASTNode::getBlankedText ) .add_property( "originalText", &ASTNode::getOriginalText ) ; class_<SourceASTNode, SourceASTNodePtr, bases<ASTNode>, boost::noncopyable>( "SourceASTNode", no_init ) ; class_<ASTNodeVisitor, ASTNodeVisitorWrap, boost::noncopyable>( "ASTNodeVisitor" ) ; class_<ASTNodePropertyVisitor, ASTNodePropertyVisitorWrap, boost::noncopyable>( "ASTNodePropertyVisitor" ) ; class_<ASTNodeType>( "ASTNodeType" ) .add_property( "name", make_function( &ASTNodeType::getName, return_value_policy<copy_const_reference>() ) ) .def( "isValid", &ASTNodeType::isValid ) ; class_<ASTNodeProperty>( "ASTNodeProperty" ) .add_property( "name", make_function( &ASTNodeProperty::getName, return_value_policy<copy_const_reference>() ) ) ; } Index: Forwards.h =================================================================== RCS file: /cvsroot/cpptool/rfta/src/pyrfta/Forwards.h,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** Forwards.h 6 Apr 2003 07:20:23 -0000 1.2 --- Forwards.h 27 Apr 2003 13:00:53 -0000 1.3 *************** *** 3,6 **** --- 3,7 ---- + void exposeCPPParser(); void exposeBase(); void exposeStatements(); Index: pyrfta.cpp =================================================================== RCS file: /cvsroot/cpptool/rfta/src/pyrfta/pyrfta.cpp,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** pyrfta.cpp 6 Apr 2003 07:20:23 -0000 1.5 --- pyrfta.cpp 27 Apr 2003 13:00:53 -0000 1.6 *************** *** 94,97 **** --- 94,98 ---- BOOST_PYTHON_MODULE(pyrfta) { + exposeCPPParser(); exposeBase(); exposeStatements(); Index: pyrfta.dsp =================================================================== RCS file: /cvsroot/cpptool/rfta/src/pyrfta/pyrfta.dsp,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** pyrfta.dsp 6 Apr 2003 07:20:23 -0000 1.4 --- pyrfta.dsp 27 Apr 2003 13:00:53 -0000 1.5 *************** *** 112,115 **** --- 112,119 ---- # Begin Source File + SOURCE=.\ExposeCPPParser.cpp + # End Source File + # Begin Source File + SOURCE=.\ExposeExpressions.cpp # End Source File |