You can subscribe to this list here.
2002 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
(37) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2003 |
Jan
(15) |
Feb
(26) |
Mar
(97) |
Apr
(224) |
May
(226) |
Jun
|
Jul
(3) |
Aug
(22) |
Sep
(48) |
Oct
|
Nov
|
Dec
(38) |
2004 |
Jan
(28) |
Feb
|
Mar
(1) |
Apr
|
May
|
Jun
(37) |
Jul
|
Aug
(73) |
Sep
|
Oct
|
Nov
|
Dec
|
From: Baptiste L. <bl...@us...> - 2004-08-07 15:52:33
|
Update of /cvsroot/cpptool/CppParser/src/cpputtest In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv9448/src/cpputtest Modified Files: cpputtest.vcproj Log Message: * made a library out of the c++ parser (cppparser) * exposed the c++ parser to python (pycppparser) * migrating refactoring framework to python (pyrfta) Index: cpputtest.vcproj =================================================================== RCS file: /cvsroot/cpptool/CppParser/src/cpputtest/cpputtest.vcproj,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** cpputtest.vcproj 5 Aug 2004 20:52:46 -0000 1.2 --- cpputtest.vcproj 7 Aug 2004 15:52:24 -0000 1.3 *************** *** 26,30 **** PreprocessorDefinitions="WIN32,NDEBUG,_CONSOLE" StringPooling="TRUE" ! RuntimeLibrary="0" EnableFunctionLevelLinking="TRUE" DisableLanguageExtensions="TRUE" --- 26,30 ---- PreprocessorDefinitions="WIN32,NDEBUG,_CONSOLE" StringPooling="TRUE" ! RuntimeLibrary="2" EnableFunctionLevelLinking="TRUE" DisableLanguageExtensions="TRUE" *************** *** 92,96 **** BasicRuntimeChecks="3" SmallerTypeCheck="TRUE" ! RuntimeLibrary="1" BufferSecurityCheck="TRUE" EnableFunctionLevelLinking="TRUE" --- 92,96 ---- BasicRuntimeChecks="3" SmallerTypeCheck="TRUE" ! RuntimeLibrary="3" BufferSecurityCheck="TRUE" EnableFunctionLevelLinking="TRUE" |
From: Baptiste L. <bl...@us...> - 2004-08-07 15:52:33
|
Update of /cvsroot/cpptool/CppParser/include/rfta/cppparser In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv9448/include/rfta/cppparser Added Files: autolink.h config.h conststring.h cppparser.h cppparserfacade.h cppparsersettings.h forwards.h node.h nodeprocessor.h token.h Log Message: * made a library out of the c++ parser (cppparser) * exposed the c++ parser to python (pycppparser) * migrating refactoring framework to python (pyrfta) --- NEW FILE: config.h --- #ifndef RFTA_CPPPARSER_CONFIG_H_INCLUDED # define RFTA_CPPPARSER_CONFIG_H_INCLUDED # include <boost/config.hpp> //# define CPPUT_THREAD_SAFE //# define CPPUT_USE_WIN32_THREAD //# define CPPUT_USE_PTHREAD_THREAD // untested //# define CPPUT_USE_BOOST_ATOMIC_COUNTER //# define CPPUT_USE_BOOST_SHARED_PTR # define CPPUT_BOOST_FRIENDLY //# define CPPUT_DLL_SUPPORT //# define CPPUT_USE_WIN32_DLL // LoadLibrary //# define CPPUT_USE_DL_DLL // dlopen //# define CPPUT_USE_SHL_DLL // shl_open //# define CPPUT_USE_BEOS_DLL // compiler specific stuffs... /////////////////////////////////////////////////////////////////////////// # if _MSC_VER <= 1200 // VC++ 6 or before # pragma warning( disable : 4786 ) // ident trunc to '255' chars in debug info # define CPPUT_STD_VECTOR_ITERATOR_IS_POINTER 1 # define CPPUT_HAS_FUNCTION_TEMPLATE_ORDERING 0 # define CPPUT_HAS_TEMPLATE_PARTIAL_SPECIALIZATION 0 # endif # if _MSC_VER <= 1300 // VC++ 7.0 or before // VC++ 7.0 does have deduced typename, but their behavior is not consistent with // VC++ 7.1. Since it is not required to compile, we just pretend it's not available. # define CPPUT_NO_DEDUCED_TYPENAME # endif # if _MSC_VER >= 1310 // VC++ 7.1 # define CPPUT_HAS_FUNCTION_TEMPLATE_ORDERING 1 # define CPPUT_HAS_TEMPLATE_PARTIAL_SPECIALIZATION 1 # pragma warning( disable : 4800 ) // forcing value to bool performance warning # pragma warning( disable : 4018 ) // '<' signed/unsigned mismatch # endif // define CPPUT_DLL_BUILD when building rfta parser dll. # ifdef RFTA_CPPPARSER_DLL_BUILD # define RFTA_CPPARSER_API __declspec(dllexport) # else # define RFTA_CPPARSER_API __declspec(dllimport) # endif // Auto-link feature, define symbol CPPUT_NO_AUTO_LINK to disable # ifndef RFTA_CPPPARSER_DLL_BUILD # define CPPUT_LIB_NAME "rfta_cppparser" # include <rfta/cppparser/autolink.h> # undef CPPUT_LIB_NAME # endif #endif // RFTA_CPPPARSER_CONFIG_H_INCLUDED --- NEW FILE: cppparser.h --- #ifndef PARSER_CPPARSER_H_INCLUDED # define PARSER_CPPARSER_H_INCLUDED # include <rfta/cppparser/node.h> # include <string> namespace Parser { class GrammarBuilder; namespace CppParser { extern TokenType RFTA_CPPARSER_API tkSpaces; extern TokenType RFTA_CPPARSER_API tkIdentifier; extern TokenType RFTA_CPPARSER_API tkString; extern TokenType RFTA_CPPARSER_API tkCharacter; extern TokenType RFTA_CPPARSER_API tkInteger; extern TokenType RFTA_CPPARSER_API tkFloat; extern TokenType RFTA_CPPARSER_API tkCppComment; extern TokenType RFTA_CPPARSER_API tkCComment; extern TokenType RFTA_CPPARSER_API tkPreprocessorDirective; extern TokenType RFTA_CPPARSER_API tkError; extern TokenType RFTA_CPPARSER_API tkSymbol; void RFTA_CPPARSER_API tokenize( const std::string &input, Tokens &tokens ); void RFTA_CPPARSER_API preprocess( const std::string &input, Tokens &tokens ); void RFTA_CPPARSER_API setUpGrammarBuilder( GrammarBuilder &builder ); } // namespace CppParser } // namespace Parser #endif // PARSER_CPPARSER_H_INCLUDED --- NEW FILE: cppparsersettings.h --- #ifndef PARSER_CPPPARSERSETTINGS_H_INCLUDED # define PARSER_CPPPARSERSETTINGS_H_INCLUDED # include <rfta/cppparser/config.h> # include <string> namespace Parser { class RFTA_CPPARSER_API CppParserSettings { public: virtual ~CppParserSettings() { } virtual std::string grammarPath() const =0; }; } // namespace Parser #endif // PARSER_CPPPARSERSETTINGS_H_INCLUDED --- NEW FILE: nodeprocessor.h --- #ifndef TEST_NODEPROCESSOR_H_INCLUDED # define TEST_NODEPROCESSOR_H_INCLUDED # include <rfta/cppparser/config.h> # include <cpput/enumerator.h> # include <boost/shared_ptr.hpp> # include <map> # include <set> # include <string> enum NodeSpecificationTypes { nsNone = 0, nsHasBraceValue = 1, nsHasBraceValues = nsHasBraceValue << 1, nsHasBraceNodeValue = nsHasBraceValues << 1, nsHasColonValue = nsHasBraceNodeValue << 1, nsHasColonNodeValue = nsHasColonValue << 1, nsHasColonEnumerationValue = nsHasColonNodeValue << 1, nsHasColonStringListValue = nsHasColonEnumerationValue << 1, nsHasChildren = nsHasColonStringListValue << 1 }; // class NodeSpecification // /////////////////////////////////////////////////////////////// class RFTA_CPPARSER_API NodeSpecification { public: typedef unsigned int Features; NodeSpecification(); NodeSpecification( const std::string &specificationName, const std::string &inputName, Features features ); const std::string &specificationName() const; const std::string &inputName() const; bool hasBraceValue() const; bool hasBraceValues() const; bool hasBraceNodeValue() const; bool hasColonValue() const; bool hasColonNodeValue() const; bool hasColonEnumerationValue() const; bool hasColonStringListValue() const; bool hasChildren() const; void addEnumerationValue( const std::string &value ); void addChild( const std::string &specificationName ); void addMandatoryChild( const std::string &specificationName ); void getAllEnumerationValue( std::set<std::string> &enumeration ) const; void getAllPossibleChildren( std::set<std::string> &children ) const; bool isAcceptableChild( const std::string &specificationName ) const; private: typedef std::set<std::string> Children; Children children_; Children mandatoryChildren_; std::set<std::string> enumerationValues_; std::string specificationName_; std::string inputName_; Features features_; }; typedef boost::shared_ptr<NodeSpecification> NodeSpecificationPtr; // class Node // /////////////////////////////////////////////////////////////// class Node; typedef boost::shared_ptr<Node> NodePtr; class RFTA_CPPARSER_API Node { public: typedef CppUT::Enumerator<NodePtr> NodeEnumerator; typedef CppUT::Enumerator<std::string> ValueEnumerator; virtual ~Node(); virtual unsigned int line() const = 0; virtual unsigned int column() const = 0; virtual const std::string &inputName() const = 0; virtual const std::string &specificationName() const = 0; virtual std::string braceValue() const = 0; virtual CppUT::Enumerator<std::string> braceValues() const = 0; virtual NodePtr braceNodeValue() const = 0; virtual CppUT::Enumerator<NodePtr> braceNodeValues() const = 0; virtual std::string colonValue() const = 0; virtual CppUT::Enumerator<std::string> colonValues() const =0; virtual NodePtr colonNodeValue() const =0; virtual CppUT::Enumerator<NodePtr> colonNodeValues() const =0; virtual bool hasChild( const std::string &inputName ) const =0; virtual NodePtr child( const std::string &inputName ) const =0; virtual CppUT::Enumerator<NodePtr> children() const = 0; }; // class Node // /////////////////////////////////////////////////////////////// class NodeImpl : public Node { public: NodeImpl( const NodeSpecificationPtr &specification, unsigned int line, unsigned int column ); const NodeSpecification &specification() const; void addBraceValue( const std::string &value ); void addBraceValue( const NodePtr &node ); void addColonValue( const std::string &value ); void addColonValue( const NodePtr &node ); void addChild( const NodePtr &node ); public: // overridden from Node unsigned int line() const; unsigned int column() const; const std::string &inputName() const; const std::string &specificationName() const; std::string braceValue() const; CppUT::Enumerator<std::string> braceValues() const; NodePtr braceNodeValue() const; CppUT::Enumerator<NodePtr> braceNodeValues() const; std::string colonValue() const; CppUT::Enumerator<std::string> colonValues() const; NodePtr colonNodeValue() const; CppUT::Enumerator<NodePtr> colonNodeValues() const; bool hasChild( const std::string &inputName ) const; NodePtr child( const std::string &inputName ) const; CppUT::Enumerator<NodePtr> children() const; private: NodeSpecificationPtr specification_; std::deque<std::string> braceValues_; std::deque<NodePtr> braceNodeValues_; std::deque<std::string> colonValues_; std::deque<NodePtr> colonNodeValues_; std::multimap<std::string, NodePtr> children_; unsigned int line_; unsigned int column_; }; typedef boost::shared_ptr<NodeImpl> NodeImplPtr; // class NodeProcessorError // /////////////////////////////////////////////////////////////////// struct RFTA_CPPARSER_API NodeProcessorError : public std::runtime_error { NodeProcessorError( const std::string &message ) : std::runtime_error( message ) { } }; // class NodeProcessor // /////////////////////////////////////////////////////////////// class RFTA_CPPARSER_API NodeProcessor { public: NodeProcessor(); void recordSpecfication( const NodeSpecification &specification ); void setRootSpecification( const std::string &rootSpecificationName ); void checkSpecifications(); NodePtr parseNodeTree( const std::string &nodeTree, unsigned int startLine ); private: struct Token { enum TokenType // update typeName() when changed { tokenIdentifier = 0, tokenOpenRoundBrace, tokenCloseRoundBrace, tokenOpenCurlyBrace, tokenCloseCurlyBrace, tokenColon, tokenComma, tokenError }; Token( const std::string &text, TokenType type, unsigned int line, unsigned int column ) : text_( text ) , type_( type ) , line_( line ) , column_( column ) { } static std::string typeName( TokenType type ); std::string text_; TokenType type_; unsigned int line_; unsigned int column_; }; typedef std::deque<Token> Tokens; void tokenize( const std::string &declarations, unsigned int startLine ); static bool isIdFirstLetter( char c ); static bool isIdOtherLetter( char c ); NodeImplPtr expectNode( const NodeSpecification &specification ); /// Checks that the node meet its specification requirements void checkNodeRequirements( const NodeImplPtr &node, const Token &start ) const; void checkNodeColonEnumerationConstraint( const NodeImplPtr &node, const Token &start ) const; void parseNodeBraceValues( const NodeImplPtr &node ); void parseNodeBraceNodeValue( const NodeImplPtr &node ); void parseNodeColonValue( const NodeImplPtr &node ); void parseNodeColonNodeValue( const NodeImplPtr &node ); void parseNodeChildren( const NodeImplPtr &node ); void syntaxError( const Token &token, const std::string &message ) const; void syntaxError( const std::string &message ) const; bool hasMoreTokens() const; bool expectMoreTokens( const Token &errorLocation, const std::string &message ) const; const Token &expectToken( Token::TokenType type, const std::string &message = "" ); bool isAheadTokenType( Token::TokenType type ) const; void nextToken(); typedef std::map<std::string,NodeSpecificationPtr> NodeSpecifications; NodeSpecifications specifications_; typedef std::deque<std::string> SpecificationNames; typedef std::map<std::string,SpecificationNames> ParseNamesToSpecificationNames; ParseNamesToSpecificationNames parseNamesToSpecificationNames_; int tokenIndex_; Tokens tokens_; std::string rootSpecificationName_; }; #endif // TEST_NODEPROCESSOR_H_INCLUDED --- NEW FILE: token.h --- #ifndef PARSER_TOKEN_H_INCLUDED # define PARSER_TOKEN_H_INCLUDED # include <rfta/cppparser/conststring.h> # include <map> # include <sstream> # include <vector> namespace Parser { typedef unsigned int BufferId; class RFTA_CPPARSER_API TokenLocation { public: TokenLocation() : startPos_(-1) , endPos_(-1) , bufferId_(-1) { } TokenLocation( unsigned int startPos, unsigned int endPos, BufferId bufferId ) : startPos_( startPos ) , endPos_( endPos ) , bufferId_( bufferId ) { } bool isValid() const { return startPos_ != -1 && endPos_ != -1; } bool operator ==( const TokenLocation &other ) const { return startPos_ == other.startPos_ && endPos_ == other.endPos_ && bufferId_ == other.bufferId_; } bool operator !=( const TokenLocation &other ) const { return !( *this == other ); } unsigned int length() const { return endPos_ - startPos_; } unsigned int startPos_; unsigned int endPos_; BufferId bufferId_; }; class RFTA_CPPARSER_API TokenType { public: enum { idShift = 16 }; TokenType() { } TokenType( unsigned int type ) : type_( type ) { } TokenType( TokenType category, unsigned int id ) : type_( category.type_ | id ) { } bool operator ==( TokenType other ) const; bool operator !=( TokenType other ) const; bool operator <( TokenType other ) const; unsigned int id() const; bool isSilent() const; TokenType category() const; TokenType nextCategory() const; unsigned int hash() const; void setSilent(); private: enum { tokenIdMask = 0xffff0000, tokenCategoryMask = 0xfff, tokenCategoryIncrement = 0x1, tokenSilentMask = 0x8000000 }; unsigned int type_; }; class RFTA_CPPARSER_API TokenIdManager { public: static unsigned int get( const ConstString &text ); static std::string str( TokenType type ); private: static TokenIdManager &instance(); typedef std::map<ConstString,unsigned int> TokenIds; TokenIds ids_; typedef std::map<unsigned int,std::string> IdTexts; IdTexts texts_; }; enum DefaultTokenType { invalidTokenType = -1, endStream = 0, symbol, lastUsedTokenType }; class RFTA_CPPARSER_API TokenTypeManager { public: TokenTypeManager(); static TokenTypeManager &instance(); TokenType add( const ConstString &name, bool isSilent = false ); ConstString typeName( TokenType type ) const; private: void set( TokenType id, const ConstString &name ); typedef std::map<ConstString,TokenType> Types; Types types_; typedef std::map<TokenType,ConstString> Names; Names names_; ConstString unknownName_; TokenType last_; }; inline ConstString RFTA_CPPARSER_API tokenTypeName( TokenType type ) { return TokenTypeManager::instance().typeName( type ); } class RFTA_CPPARSER_API Token { public: Token( const ConstString &text, TokenType tokenType, TokenLocation location = TokenLocation() ); const ConstString &text() const; const TokenLocation &location() const; TokenType type() const; TokenType category() const; bool isSilent() const; ConstString typeName() const; unsigned int hash() const; bool operator ==( const Token &other ) const; bool operator !=( const Token &other ) const; std::string str() const; private: ConstString text_; TokenLocation location_; TokenType tokenType_; }; typedef std::vector<Token> Tokens; // Inline functions // ////////////////////////////////////////// inline bool TokenType::operator ==( TokenType other ) const { return type_ == other.type_; } inline bool TokenType::operator !=( TokenType other ) const { return type_ != other.type_; } inline bool TokenType::operator <( TokenType other ) const { return type_ < other.type_; } inline unsigned int TokenType::id() const { return type_ & tokenIdMask; } inline bool TokenType::isSilent() const { return (type_ & tokenSilentMask) != 0; } inline void TokenType::setSilent() { type_ |= tokenSilentMask; } inline TokenType TokenType::category() const { return TokenType( type_ & ~tokenIdMask ); } inline TokenType TokenType::nextCategory() const { return category().type_ + tokenCategoryIncrement; } inline unsigned int TokenType::hash() const { return type_; } inline unsigned int TokenIdManager::get( const ConstString &text ) { TokenIds::iterator it = instance().ids_.find( text ); if ( it == instance().ids_.end() ) { unsigned int id = (instance().ids_.size()+1) << TokenType::idShift; instance().ids_.insert( TokenIds::value_type( text, id ) ); instance().texts_.insert( IdTexts::value_type( id, text.str() ) ); return id; } return it->second; } inline std::string TokenIdManager::str( TokenType type ) { if ( instance().texts_.count(type.id()) == 0) return "<unknown>"; return instance().texts_.find(type.id())->second; } inline TokenIdManager & TokenIdManager::instance() { static TokenIdManager manager; return manager; } inline TokenTypeManager::TokenTypeManager() : last_( lastUsedTokenType ) , unknownName_( "?" ) { set( endStream, "end_stream" ); set( symbol, "symbol" ); } inline TokenTypeManager & TokenTypeManager::instance() { static TokenTypeManager manager; return manager; } inline TokenType TokenTypeManager::add( const ConstString &name, bool isSilent ) { Types::iterator it = types_.find( name ); if ( it == types_.end() ) { TokenType type = last_; if ( isSilent ) { type.setSilent(); set( last_, "__silent__." + name.str() ); } else set( last_, name ); last_ = last_.nextCategory(); return type; } return it->second; } inline ConstString TokenTypeManager::typeName( TokenType type ) const { Names::const_iterator it = names_.find( type.category() ); if ( it == names_.end() ) return unknownName_; if ( type.isSilent() ) return it->second.str().substr( 11 ); // "__silent__." return it->second; } inline void TokenTypeManager::set( TokenType id, const ConstString &name ) { types_[name] = id; names_[id] = name; } inline Token::Token( const ConstString &text, TokenType tokenType, TokenLocation location ) : text_( text ) , tokenType_( tokenType ) , location_( location ) { if ( tokenType.category() == TokenType(symbol) && tokenType.id() == 0 ) tokenType_ = TokenType( tokenType.category(), TokenIdManager::get( text ) ); } inline const ConstString & Token::text() const { return text_; } inline const TokenLocation & Token::location() const { return location_; } inline TokenType Token::type() const { return tokenType_; } inline TokenType Token::category() const { return tokenType_.category(); } inline bool Token::isSilent() const { return tokenType_.isSilent(); } inline ConstString Token::typeName() const { return tokenTypeName( tokenType_ ); } inline unsigned int Token::hash() const { return (tokenType_.hash() << 17) + text_.hash(); } inline bool Token::operator ==( const Token &other ) const { return text_ == other.text_ && tokenType_ == other.tokenType_ && location_ == other.location_; } inline bool Token::operator !=( const Token &other ) const { return !( *this == other ); } inline std::string Token::str() const { std::ostringstream os; os << "Token(" << tokenTypeName(tokenType_).str() << ", " << location_.startPos_ << "-" << location_.endPos_ << " = '" << text_.str() << "')"; return os.str(); } } // namespace Parser #endif // PARSER_TOKEN_H_INCLUDED --- NEW FILE: node.h --- #ifndef PARSER_NODE_H_INCLUDED # define PARSER_NODE_H_INCLUDED # include <boost/intrusive_ptr.hpp> # include <rfta/cppparser/token.h> # include <stack> # include <stdexcept> namespace Parser { class Node; typedef boost::intrusive_ptr<Node> NodePtr; } // namespace Parser namespace boost { void RFTA_CPPARSER_API intrusive_ptr_add_ref( Parser::Node *); void RFTA_CPPARSER_API intrusive_ptr_release( Parser::Node *); } // namespace boost namespace Parser { typedef std::vector<NodePtr> Nodes; class RFTA_CPPARSER_API NodeVisitor { public: virtual ~NodeVisitor() { } virtual void visitNode( Node &node ) = 0; }; class RFTA_CPPARSER_API NodeEnumerator { public: NodeEnumerator( const NodePtr ¤t ) : current_( current ) { } bool hasNext() const { return current_; } Node &next(); NodePtr nextPtr(); private: NodePtr current_; }; class RFTA_CPPARSER_API DepthFirstEnumerator { public: DepthFirstEnumerator( const NodePtr ¤t ) : current_( current.get() ) { } bool hasNext() const; bool hasPrevious() const; Node &next(); Node &previous(); private: std::stack<Node *> parents_; Node *current_; }; class RFTA_CPPARSER_API Node { public: friend void boost::intrusive_ptr_add_ref( Node *); friend void boost::intrusive_ptr_release( Node *); // Node name is really a node type Node( const ConstString &name, const Nodes &children = Nodes() ) : parent_( 0 ) , previousSibling_( 0 ) , name_( name ) , token_( "", invalidTokenType ) , count_( 0 ) { for ( int index =0; index < children.size(); ++index ) appendChild( children.at( index ) ); } Node( const Token &token ) : parent_( 0 ) , previousSibling_( 0 ) , name_( token.typeName() ) , token_( token ) { } virtual ~Node() { } void setParent( Node *parent ) { parent_ = parent; } NodePtr getPreviousSibling() const { return previousSibling_; } const NodePtr &getNextSibling() const { return nextSibling_; } void unparent() { parent_ = 0; } Node *parent() const { return parent_; } NodeEnumerator enumChildren() const { return NodeEnumerator( firstChild_ ); } void setName( const ConstString &name ) { name_ = name; } const ConstString &name() const { return name_; } virtual bool accept( NodeVisitor &visitor ) { visitor.visitNode( *this ); return true; } NodePtr thisPtr() const; NodePtr childAt( std::size_t index ) const; NodePtr getLastChild() const; bool hasChildren() const; int getChildCount() const; std::string treeStr( int margin = 0, int indentLevel = 0 ); std::string str() const; void appendChild( const NodePtr &child ); void prependChild( const NodePtr &child ); NodePtr removeFromParent(); void insertSiblingAfter( const NodePtr &newNextSibling ); // token functions const Token &token() const { return token_; } void setToken( const Token &token ) { token_ = token; } const ConstString &text() const { return token_.text(); } unsigned int textLength() const { return text().length(); } TokenType type() const { return token_.type(); } TokenType category() const { return token_.category(); } bool hasValidToken() const { return token_.type() != invalidTokenType; } ConstString typeName() const { return token_.typeName(); } const TokenLocation &location() const { return token_.location(); } private: void setNextSibling( const NodePtr &nextSibling ); void setFirstChild( const NodePtr &firstChild ); virtual std::string nodeHeaderStr() const; Node( const Node &other ); void operator=( const Node &other ); private: Token token_; ConstString name_; Node *parent_; NodePtr firstChild_; Node *previousSibling_; NodePtr nextSibling_; long count_; // reference count for intrusive_ptr }; inline NodePtr RFTA_CPPARSER_API makeCompositeNode( const ConstString &name ) { return NodePtr( new Node( name ) ); } inline NodePtr RFTA_CPPARSER_API makeNode( const ConstString &name ) { return makeCompositeNode( name ); } inline NodePtr RFTA_CPPARSER_API makeTokenNode( const Token &token ) { return NodePtr( new Node( token ) ); } } // namespace Parser #endif // PARSER_NODE_H_INCLUDED --- NEW FILE: cppparserfacade.h --- #ifndef PARSER_CPPPARSERFACADE_H_INCLUDED # define PARSER_CPPPARSERFACADE_H_INCLUDED # include <rfta/cppparser/forwards.h> # include <rfta/cppparser/cppparsersettings.h> # include <stdexcept> namespace Parser { class RFTA_CPPARSER_API CppParserFacade { public: CppParserFacade( const CppParserSettings &settings ); // clearly not final api, will need filename & 'file provider' for preprocessing NodePtr parse( const std::string &input ); private: const CppParserSettings &settings_; boost::shared_ptr<GrammarBuilder> builder_; MatcherPtr translationUnitMatcher_; }; class RFTA_CPPARSER_API CppParserFacadeError : public std::runtime_error { public: CppParserFacadeError( const std::string &message ) : std::runtime_error( message ) { } }; } // namespace Parser #endif // PARSER_CPPPARSERFACADE_H_INCLUDED --- NEW FILE: conststring.h --- #ifndef PARSER_CONSTSTRING_H_INCLUDED # define PARSER_CONSTSTRING_H_INCLUDED # include <rfta/cppparser/config.h> # include <algorithm> # include <string> namespace Parser { class RFTA_CPPARSER_API ConstString { public: typedef const char *const_iterator; typedef char value_type; ConstString( const std::string &s ) : buffer_( 0 ) { const char *begin = s.c_str(); const char *end = begin + s.length(); initialize( begin, end ); } ConstString( const char *cstring = "" ) : buffer_( 0 ) { const char *end = cstring; while ( *end != 0 ) ++end; initialize( cstring, end ); } ConstString( const char *begin, const char *end ) : buffer_( 0 ) { initialize( begin, end ); } ConstString( const ConstString &other ) : buffer_( 0 ) { initializeBuffer( other.buffer_, other.buffer_ + other.length_ ); checksum_ = other.checksum_; } ~ConstString() { delete [] const_cast<char *>(buffer_); } ConstString &operator =( const ConstString &other ) { ConstString tmp( other ); std::swap( buffer_, tmp.buffer_ ); std::swap( checksum_, tmp.checksum_ ); std::swap( length_, tmp.length_ ); return *this; } const char *begin() const { return buffer_; } const char *end() const { return buffer_ + length_; } unsigned int length() const { return length_; } unsigned int hash() const { return checksum_; } const char *c_str() const { return buffer_; } std::string str() const { return buffer_; } char operator[]( int index ) const { return buffer_[index]; } bool operator ==( const ConstString &other ) const { if ( checksum_ != other.checksum_ || length_ != other.length_ ) return false; const char *end = buffer_+length_; return std::mismatch( buffer_, end, other.buffer_ ).first == end; } bool operator !=( const ConstString &other ) const { return !( *this == other ); } bool operator <( const ConstString &other ) const { return strcmp( buffer_, other.buffer_ ) < 0; } bool operator >( const ConstString &other ) const { return !( *this < other ); } private: void initialize( const char *begin, const char *end ) { initializeBuffer( begin, end ); computeChecksum(); } void initializeBuffer( const char *begin, const char *end ) { length_ = unsigned int(end - begin); char *buffer = new char[end-begin+1]; std::copy( begin, end, buffer ); buffer[length_] = 0; buffer_ = buffer; } void computeChecksum() { const char *begin = this->begin(); const char *end = this->end(); unsigned int checksum = length_ * 0x03010515; while ( begin != end ) { unsigned int c( *begin++ ); checksum ^= checksum * 0x02005001 + c; } checksum_ = checksum; } unsigned int length_; unsigned int checksum_; const char *buffer_; }; } // namespace Parser #endif // PARSER_CONSTSTRING_H_INCLUDED --- NEW FILE: forwards.h --- #ifndef PARSER_FORWARDS_H_INCLUDED # define PARSER_FORWARDS_H_INCLUDED # include <rfta/cppparser/config.h> # include <boost/intrusive_ptr.hpp> # include <boost/shared_ptr.hpp> namespace Parser { class GrammarBuilder; class Matcher; typedef boost::shared_ptr<Matcher> MatcherPtr; class Node; typedef boost::intrusive_ptr<Node> NodePtr; } // namespace Parser #endif // PARSER_FORWARDS_H_INCLUDED --- NEW FILE: autolink.h --- // No gards, this header can be included multiple time // Generic header to automatically link against a specified library // The library name prefix must be defined in CPPUT_LIB_NAME. // CPPUT_LIB_NAME will be undefined after including this header. // The full library name is build according to the followin rules: // (0) CPPUT_LIB_NAME: library name prefix (lut,...) // (a) TOOLSET: vc6, vc7, bcb4, bcb5, bcb6 // (b) THREADING: m(multithreaded), s(single threaded) // (c) DEBUG MODE: r(release), d(debug) // (d) LINKAGE: s(static), d(dynamic) // FULLNAME: 0_a_bcd.lib #if !defined(CPPUT_LIB_NAME) # error Macro CPPUT_LIB_NAME should be defined. You should not include this header directly. #endif // Select compiler #if defined(_MSC_VER) && (_MSC_VER == 1200) // VC6 # define CPPUT_LIB_TOOLSET "vc6" #elif defined(_MSC_VER) && (_MSC_VER >= 1300) //VC7 (.NET 2002) # define CPPUT_LIB_TOOLSET "vc7" #elif defined(__BORLANDC__) && (__BORLANDC__ >= 0x560) // CBuilder 6 # define CPPUT_LIB_TOOLSET "bcb6" #elif defined(__BORLANDC__) && (__BORLANDC__ >= 0x550) # define CPPUT_LIB_TOOLSET "bcb5" #elif defined(__BORLANDC__) && (__BORLANDC__ >= 0x540) # define CPPUT_LIB_TOOLSET "bcb4" #endif // Select threading #if defined(_MT) || defined(__MT__) # define CPPUT_LIB_THREADING "m" #else # define CPPUT_LIB_THREADING "s" #endif // Select debug mode #if defined(_DEBUG) # define CPPUT_LIB_DEBUG_MODE "d" #else # define CPPUT_LIB_DEBUG_MODE "r" #endif // Select linkage #if defined(CPPUT_STATIC_LINK) # define CPPUT_LIB_LINKAGE "s" #else # define CPPUT_LIB_LINKAGE "d" #endif // Automatic link #if defined(CPPUT_LIB_TOOLSET) && \ defined(CPPUT_LIB_THREADING) && \ defined(CPPUT_LIB_LINKAGE) && \ defined(CPPUT_LIB_DEBUG_MODE) # define CPPUT_LIB_FULL_NAME \ CPPUT_LIB_NAME "_" CPPUT_LIB_TOOLSET "_" CPPUT_LIB_THREADING CPPUT_LIB_DEBUG_MODE \ CPPUT_LIB_LINKAGE ".lib" # pragma comment(lib,CPPUT_LIB_FULL_NAME) #endif #undef CPPUT_LIB_TOOLSET #undef CPPUT_LIB_THREADING #undef CPPUT_LIB_LINKAGE #undef CPPUT_LIB_DEBUG_MODE #undef CPPUT_LIB_FULL_NAME #undef CPPUT_LIB_NAME |
From: Baptiste L. <bl...@us...> - 2004-08-07 15:52:33
|
Update of /cvsroot/cpptool/CppParser/src/cpput In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv9448/src/cpput Modified Files: cpput.vcproj Log Message: * made a library out of the c++ parser (cppparser) * exposed the c++ parser to python (pycppparser) * migrating refactoring framework to python (pyrfta) Index: cpput.vcproj =================================================================== RCS file: /cvsroot/cpptool/CppParser/src/cpput/cpput.vcproj,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** cpput.vcproj 5 Aug 2004 20:52:46 -0000 1.2 --- cpput.vcproj 7 Aug 2004 15:52:24 -0000 1.3 *************** *** 26,30 **** PreprocessorDefinitions="WIN32,NDEBUG,_LIB" StringPooling="TRUE" ! RuntimeLibrary="0" EnableFunctionLevelLinking="TRUE" DisableLanguageExtensions="TRUE" --- 26,30 ---- PreprocessorDefinitions="WIN32,NDEBUG,_LIB" StringPooling="TRUE" ! RuntimeLibrary="2" EnableFunctionLevelLinking="TRUE" DisableLanguageExtensions="TRUE" *************** *** 80,84 **** BasicRuntimeChecks="3" SmallerTypeCheck="TRUE" ! RuntimeLibrary="1" BufferSecurityCheck="TRUE" EnableFunctionLevelLinking="TRUE" --- 80,84 ---- BasicRuntimeChecks="3" SmallerTypeCheck="TRUE" ! RuntimeLibrary="3" BufferSecurityCheck="TRUE" EnableFunctionLevelLinking="TRUE" *************** *** 129,136 **** Filter=""> <File ! RelativePath=".\SConscript"> </File> <File ! RelativePath="..\cpputtest\SConscript"> </File> <File --- 129,136 ---- Filter=""> <File ! RelativePath="..\cpputtest\SConscript"> </File> <File ! RelativePath=".\SConscript"> </File> <File |
From: Baptiste L. <bl...@us...> - 2004-08-07 15:52:33
|
Update of /cvsroot/cpptool/CppParser/src/pyrfta In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv9448/src/pyrfta Added Files: .cvsignore pycppparser.py pycppparsertest.py Log Message: * made a library out of the c++ parser (cppparser) * exposed the c++ parser to python (pycppparser) * migrating refactoring framework to python (pyrfta) --- NEW FILE: .cvsignore --- *.dll cpp_grammar.txt *.pyc *.pyd --- NEW FILE: pycppparser.py --- from pycppparser_ import * --- NEW FILE: pycppparsertest.py --- import unittest import pycppparser as cprs class TokenTest(unittest.TestCase): def setUp(self): pass def tearDown(self): pass def testTokenType( self ): cprs.TK_SPACES cprs.TK_IDENTIFIER cprs.TK_SYMBOL assert( cprs.TK_SPACES.isSilent ) assert( not cprs.TK_IDENTIFIER.isSilent ) def testTokenLocation( self ): loc = cprs.TokenLocation( 10, 17, 3 ) assert loc.isValid() self.assertEqual( 10, loc.startPos ) self.assertEqual( 17, loc.endPos ) self.assertEqual( 7, loc.length ) self.assertEqual( 3, loc.bufferId ) def testToken( self ): tk = cprs.Token( 'myVar', cprs.TK_IDENTIFIER ) self.assertEqual( 'myVar', tk.text ) assert not tk.location.isValid() self.assertEqual( cprs.TK_IDENTIFIER, tk.type ) self.assertEqual( cprs.TK_IDENTIFIER, tk.category ) assert not tk.isSilent self.assertEqual( cprs.TK_IDENTIFIER.name, tk.typeName ) tkcopy = cprs.Token( tk ) self.assertEqual( tk, tkcopy ) tkother = cprs.Token('otherVar', cprs.TK_IDENTIFIER ) assert tkcopy != tkother class CppParserFacadeTest(unittest.TestCase): def setUp(self): pass def tearDown(self): pass def testParseCpp( self ): grammar_path = 'cpp_grammar.txt' parser = cprs.makeParser( grammar_path ) translation_unit = parser.parse( 'void main() { }' ) #print translation_unit.treeStr() self.assertEqual( 'translation_unit', translation_unit.name ) self.visitChildren( translation_unit ) def visitChildren( self, node ): for child in node.enumChildren(): print 'visiting:', child self.visitChildren( child ) if __name__ == '__main__': unittest.main() |
From: Baptiste L. <bl...@us...> - 2004-08-07 15:52:33
|
Update of /cvsroot/cpptool/CppParser/include In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv9448/include Modified Files: .cvsignore Log Message: * made a library out of the c++ parser (cppparser) * exposed the c++ parser to python (pycppparser) * migrating refactoring framework to python (pyrfta) Index: .cvsignore =================================================================== RCS file: /cvsroot/cpptool/CppParser/include/.cvsignore,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** .cvsignore 8 Jun 2004 20:23:19 -0000 1.1.1.1 --- .cvsignore 7 Aug 2004 15:52:22 -0000 1.2 *************** *** 1 **** ! boost --- 1 ---- ! boost* |
From: Baptiste L. <bl...@us...> - 2004-08-07 15:52:33
|
Update of /cvsroot/cpptool/CppParser/examples/parser In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv9448/examples/parser Modified Files: cpp_parser.sln cpp_parser.suo parser.vcproj Log Message: * made a library out of the c++ parser (cppparser) * exposed the c++ parser to python (pycppparser) * migrating refactoring framework to python (pyrfta) Index: parser.vcproj =================================================================== RCS file: /cvsroot/cpptool/CppParser/examples/parser/parser.vcproj,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** parser.vcproj 5 Aug 2004 20:52:41 -0000 1.5 --- parser.vcproj 7 Aug 2004 15:52:22 -0000 1.6 *************** *** 27,31 **** BasicRuntimeChecks="0" SmallerTypeCheck="FALSE" ! RuntimeLibrary="1" BufferSecurityCheck="FALSE" EnableFunctionLevelLinking="TRUE" --- 27,31 ---- BasicRuntimeChecks="0" SmallerTypeCheck="FALSE" ! RuntimeLibrary="3" BufferSecurityCheck="FALSE" EnableFunctionLevelLinking="TRUE" *************** *** 87,91 **** PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE;PARSER_ENABLE_TRACKING" StringPooling="FALSE" ! RuntimeLibrary="0" EnableFunctionLevelLinking="TRUE" DisableLanguageExtensions="FALSE" --- 87,91 ---- PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE;PARSER_ENABLE_TRACKING" StringPooling="FALSE" ! RuntimeLibrary="2" EnableFunctionLevelLinking="TRUE" DisableLanguageExtensions="FALSE" *************** *** 430,433 **** --- 430,438 ---- <File RelativePath=".\preprocessortest.cpp"> + <FileConfiguration + Name="Debug|Win32"> + <Tool + Name="VCCLCompilerTool"/> + </FileConfiguration> </File> <File Index: cpp_parser.suo =================================================================== RCS file: /cvsroot/cpptool/CppParser/examples/parser/cpp_parser.suo,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 Binary files /tmp/cvsO1ynS1 and /tmp/cvswiu1fT differ Index: cpp_parser.sln =================================================================== RCS file: /cvsroot/cpptool/CppParser/examples/parser/cpp_parser.sln,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** cpp_parser.sln 8 Jun 2004 20:23:13 -0000 1.1.1.1 --- cpp_parser.sln 7 Aug 2004 15:52:22 -0000 1.2 *************** *** 1,18 **** Microsoft Visual Studio Solution File, Format Version 8.00 ! Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "parser", "parser.vcproj", "{062AF22A-37AF-4347-91A7-997141307217}" ProjectSection(ProjectDependencies) = postProject - {18A62E20-3130-4A6F-B6EB-85B126D46E6D} = {18A62E20-3130-4A6F-B6EB-85B126D46E6D} - {BC6A1042-3AC9-44E7-BCEB-1B2DB7D1ABE7} = {BC6A1042-3AC9-44E7-BCEB-1B2DB7D1ABE7} EndProjectSection EndProject ! Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "cpput", "..\..\src\cpput\cpput.vcproj", "{18A62E20-3130-4A6F-B6EB-85B126D46E6D}" ProjectSection(ProjectDependencies) = postProject EndProjectSection EndProject ! Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "cpputtest", "..\..\src\cpputtest\cpputtest.vcproj", "{BC6A1042-3AC9-44E7-BCEB-1B2DB7D1ABE7}" ProjectSection(ProjectDependencies) = postProject {18A62E20-3130-4A6F-B6EB-85B126D46E6D} = {18A62E20-3130-4A6F-B6EB-85B126D46E6D} EndProjectSection EndProject Global GlobalSection(SolutionConfiguration) = preSolution --- 1,22 ---- Microsoft Visual Studio Solution File, Format Version 8.00 ! Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "cpput", "..\..\src\cpput\cpput.vcproj", "{18A62E20-3130-4A6F-B6EB-85B126D46E6D}" ProjectSection(ProjectDependencies) = postProject EndProjectSection EndProject ! Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "cpputtest", "..\..\src\cpputtest\cpputtest.vcproj", "{BC6A1042-3AC9-44E7-BCEB-1B2DB7D1ABE7}" ProjectSection(ProjectDependencies) = postProject + {18A62E20-3130-4A6F-B6EB-85B126D46E6D} = {18A62E20-3130-4A6F-B6EB-85B126D46E6D} EndProjectSection EndProject ! Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "cppparser", "..\..\src\cppparser\cppparser.vcproj", "{EA6D6F9C-4BA7-4A0D-BD46-7ACA6F3D6E72}" ProjectSection(ProjectDependencies) = postProject {18A62E20-3130-4A6F-B6EB-85B126D46E6D} = {18A62E20-3130-4A6F-B6EB-85B126D46E6D} EndProjectSection EndProject + Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "pycppparser", "..\..\src\pycppparser\pycppparser.vcproj", "{481DC14A-E1BD-4146-8789-113C962EDA21}" + ProjectSection(ProjectDependencies) = postProject + {EA6D6F9C-4BA7-4A0D-BD46-7ACA6F3D6E72} = {EA6D6F9C-4BA7-4A0D-BD46-7ACA6F3D6E72} + EndProjectSection + EndProject Global GlobalSection(SolutionConfiguration) = preSolution *************** *** 21,28 **** EndGlobalSection GlobalSection(ProjectConfiguration) = postSolution - {062AF22A-37AF-4347-91A7-997141307217}.Debug.ActiveCfg = Debug|Win32 - {062AF22A-37AF-4347-91A7-997141307217}.Debug.Build.0 = Debug|Win32 - {062AF22A-37AF-4347-91A7-997141307217}.Release.ActiveCfg = Release|Win32 - {062AF22A-37AF-4347-91A7-997141307217}.Release.Build.0 = Release|Win32 {18A62E20-3130-4A6F-B6EB-85B126D46E6D}.Debug.ActiveCfg = Debug|Win32 {18A62E20-3130-4A6F-B6EB-85B126D46E6D}.Debug.Build.0 = Debug|Win32 --- 25,28 ---- *************** *** 33,36 **** --- 33,44 ---- {BC6A1042-3AC9-44E7-BCEB-1B2DB7D1ABE7}.Release.ActiveCfg = Release|Win32 {BC6A1042-3AC9-44E7-BCEB-1B2DB7D1ABE7}.Release.Build.0 = Release|Win32 + {EA6D6F9C-4BA7-4A0D-BD46-7ACA6F3D6E72}.Debug.ActiveCfg = Debug|Win32 + {EA6D6F9C-4BA7-4A0D-BD46-7ACA6F3D6E72}.Debug.Build.0 = Debug|Win32 + {EA6D6F9C-4BA7-4A0D-BD46-7ACA6F3D6E72}.Release.ActiveCfg = Release|Win32 + {EA6D6F9C-4BA7-4A0D-BD46-7ACA6F3D6E72}.Release.Build.0 = Release|Win32 + {481DC14A-E1BD-4146-8789-113C962EDA21}.Debug.ActiveCfg = Debug|Win32 + {481DC14A-E1BD-4146-8789-113C962EDA21}.Debug.Build.0 = Debug|Win32 + {481DC14A-E1BD-4146-8789-113C962EDA21}.Release.ActiveCfg = Release|Win32 + {481DC14A-E1BD-4146-8789-113C962EDA21}.Release.Build.0 = Release|Win32 EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution |
From: Baptiste L. <bl...@us...> - 2004-08-07 15:52:33
|
Update of /cvsroot/cpptool/CppParser/include/cpput In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv9448/include/cpput Modified Files: config.h Log Message: * made a library out of the c++ parser (cppparser) * exposed the c++ parser to python (pycppparser) * migrating refactoring framework to python (pyrfta) Index: config.h =================================================================== RCS file: /cvsroot/cpptool/CppParser/include/cpput/config.h,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** config.h 5 Aug 2004 20:52:45 -0000 1.2 --- config.h 7 Aug 2004 15:52:23 -0000 1.3 *************** *** 99,102 **** --- 99,103 ---- # define CPPUT_LIB_NAME "cpput" //# include <cpput/autolink.h> + # undef CPPUT_LIB_NAME # endif |
From: Baptiste L. <bl...@us...> - 2004-08-07 15:47:45
|
Update of /cvsroot/cpptool/CppParser/src/cppparsertest In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv8568/cppparsertest Log Message: Directory /cvsroot/cpptool/CppParser/src/cppparsertest added to the repository |
From: Baptiste L. <bl...@us...> - 2004-08-07 15:47:05
|
Update of /cvsroot/cpptool/CppParser/src/cppparser In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv8349/cppparser Log Message: Directory /cvsroot/cpptool/CppParser/src/cppparser added to the repository |
From: Baptiste L. <bl...@us...> - 2004-08-07 15:35:33
|
Update of /cvsroot/cpptool/CppParser/src/pycppparser In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv6463/pycppparser Log Message: Directory /cvsroot/cpptool/CppParser/src/pycppparser added to the repository |
From: Baptiste L. <bl...@us...> - 2004-08-07 15:32:24
|
Update of /cvsroot/cpptool/CppParser/src/pyrfta In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5938/pyrfta Log Message: Directory /cvsroot/cpptool/CppParser/src/pyrfta added to the repository |
From: Baptiste L. <bl...@us...> - 2004-08-07 15:25:06
|
Update of /cvsroot/cpptool/CppParser/include/rfta/cppparser In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv4714/cppparser Log Message: Directory /cvsroot/cpptool/CppParser/include/rfta/cppparser added to the repository |
From: Baptiste L. <bl...@us...> - 2004-08-07 15:24:50
|
Update of /cvsroot/cpptool/CppParser/include/rfta In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv4671/rfta Log Message: Directory /cvsroot/cpptool/CppParser/include/rfta added to the repository |
From: Baptiste L. <bl...@us...> - 2004-08-07 05:39:34
|
Update of /cvsroot/cpptool/CppParser/examples/parser In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv21407 Modified Files: cpplexer.cpp Log Message: * upgraded to future boost 1.32 (cvs) * fixed preprocessor directive patterns Index: cpplexer.cpp =================================================================== RCS file: /cvsroot/cpptool/CppParser/examples/parser/cpplexer.cpp,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** cpplexer.cpp 8 Jun 2004 20:23:10 -0000 1.1.1.1 --- cpplexer.cpp 7 Aug 2004 05:39:26 -0000 1.2 *************** *** 1,5 **** #include "cpplexer.h" #include "stlhelper.h" ! #include <boost/regex/v3/regex.hpp> #include <algorithm> #include <iterator> --- 1,5 ---- #include "cpplexer.h" #include "stlhelper.h" ! #include <boost/regex/v4/regex.hpp> #include <algorithm> #include <iterator> *************** *** 8,11 **** --- 8,12 ---- #include <vector> + using namespace Parser::CppLexerMatchType; *************** *** 97,104 **** if ( !isMacroLexer ) { ! addPattern( matchPreprocessorDirective, "\\A#[ \t]*[a-zA-Z_][^\\r\\n]*" ! "(?:" "\\\\(?:\r|\n|\r\n)|" ! "(?:/\\*.*?\\*/)|" ! "[^\r\n])*" ); } addPattern( matchIdentifier, "\\A[A-Za-z_][A-Za-z0-9_]*" ); --- 98,107 ---- if ( !isMacroLexer ) { ! addPattern( matchPreprocessorDirective, "\\A#[ \t]*[a-zA-Z_]" ! "(?:" ! "(?:\\\\(?:\\r|\\n|\\r\\n))|" // '\n': macro continue ! "(?:/\\*.*?\\*/)|" // C comment ! "[^\\r\\n]" ! ")*" ); } addPattern( matchIdentifier, "\\A[A-Za-z_][A-Za-z0-9_]*" ); |
From: Baptiste L. <bl...@us...> - 2004-08-05 20:59:36
|
Update of /cvsroot/cpptool/CppParser/examples/parser/testdata/symbol_table In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv22118/examples/parser/testdata/symbol_table Modified Files: __tests__.txt Log Message: * added new failing test Index: __tests__.txt =================================================================== RCS file: /cvsroot/cpptool/CppParser/examples/parser/testdata/symbol_table/__tests__.txt,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** __tests__.txt 21 Jun 2004 13:49:29 -0000 1.3 --- __tests__.txt 5 Aug 2004 20:59:22 -0000 1.4 *************** *** 8,9 **** --- 8,11 ---- namespace3.txt enum1.txt + variable1.txt + |
From: Baptiste L. <bl...@us...> - 2004-08-05 20:53:22
|
Update of /cvsroot/cpptool/CppParser/examples/parser In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv20897/examples/parser Modified Files: main.cpp parser.vcproj Log Message: * upgraded to current cppunit 2 cvs Index: parser.vcproj =================================================================== RCS file: /cvsroot/cpptool/CppParser/examples/parser/parser.vcproj,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** parser.vcproj 20 Jun 2004 15:53:41 -0000 1.4 --- parser.vcproj 5 Aug 2004 20:52:41 -0000 1.5 *************** *** 366,369 **** --- 366,372 ---- </File> <File + RelativePath="node.cpp"> + </File> + <File RelativePath="node.h"> </File> *************** *** 482,488 **** </File> <File - RelativePath="node.cpp"> - </File> - <File RelativePath=".\nodeprocessor.cpp"> </File> --- 485,488 ---- Index: main.cpp =================================================================== RCS file: /cvsroot/cpptool/CppParser/examples/parser/main.cpp,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** main.cpp 8 Jun 2004 20:23:14 -0000 1.1.1.1 --- main.cpp 5 Aug 2004 20:52:40 -0000 1.2 *************** *** 1,4 **** #include <cpput/registry.h> ! #include <cpput/result.h> #include <cpput/test.h> #include <cpput/testcontext.h> --- 1,5 ---- #include <cpput/registry.h> ! #include <cpput/progresslistener.h> ! #include <cpput/testrunresult.h> #include <cpput/test.h> #include <cpput/testcontext.h> *************** *** 7,19 **** - static std::string makeTestPath( const CppUT::Test &test ) - { - if ( test.parentTest() ) - return makeTestPath( *test.parentTest() ) + "/" + test.name(); - return test.name(); - } - static void dumpFailures( const CppUT::TestSuite &allSuite, ! const CppUT::Result &result ) { if ( result.successful() ) --- 8,13 ---- static void dumpFailures( const CppUT::TestSuite &allSuite, ! const CppUT::TestRunResult &result ) { if ( result.successful() ) *************** *** 25,29 **** for ( int index =0; index < result.failureCount(); ++index ) { ! const CppUT::TestFailure &failure = result.failureAt( index ); if ( failure.location().isValid() ) --- 19,23 ---- for ( int index =0; index < result.failureCount(); ++index ) { ! const CppUT::TestResult &failure = result.failureAt( index ); if ( failure.location().isValid() ) *************** *** 31,35 **** else std::cout << "Unknown failure location: "; ! std::cout << makeTestPath( failure.failedTest() ) << std::endl; std::cout << failure.message().toString() << std::endl; } --- 25,29 ---- else std::cout << "Unknown failure location: "; ! std::cout << CppUT::path( failure.test() ) << std::endl; std::cout << failure.message().toString() << std::endl; } *************** *** 41,76 **** - class ShowProgress : public CppUT::TestListener - { - public: - void testFailed( const CppUT::TestFailure &failure, - CppUT::TestContext &context ) - { - testFailed_ = true; - } - - void enterTest( CppUT::Test &test, CppUT::TestContext &context ) - { - testFailed_ = false; - std::cout << "Testing '" << makeTestPath( test ) << "' : "; - std::cout.flush(); - } - - void exitTest( CppUT::Test &test, CppUT::TestContext &context ) - { - std::cout << (testFailed_ ? "FAILURE" : "OK") << std::endl; - } - - bool testFailed_; - }; - - int main( int argc, char *argv[] ) { CppUT::TestSuitePtr allSuite = CppUT::Registry::instance().createDefaultTests(); CppUT::TestContext context; ! CppUT::Result result; context.add( result ); ! ShowProgress progress; context.add( progress ); allSuite->run( context ); --- 35,45 ---- int main( int argc, char *argv[] ) { CppUT::TestSuitePtr allSuite = CppUT::Registry::instance().createDefaultTests(); CppUT::TestContext context; ! CppUT::TestRunResult result; context.add( result ); ! CppUT::BriefProgressListener progress; context.add( progress ); allSuite->run( context ); |
Update of /cvsroot/cpptool/CppParser/src/cpputtest In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv20897/src/cpputtest Modified Files: assertstringtest.cpp cpputtest.dsp cpputtest.vcproj main.cpp mocktestlistener.h testbasicassertion.cpp testfixturetest.cpp testfixturetest.h testfunctor.cpp testtestcase.cpp testtestcontext.cpp testtestsuite.cpp Added Files: commandlineoptionstest.cpp commandlineoptionstest.h testtestrunresult.cpp Removed Files: testresult.cpp Log Message: * upgraded to current cppunit 2 cvs Index: main.cpp =================================================================== RCS file: /cvsroot/cpptool/CppParser/src/cpputtest/main.cpp,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** main.cpp 8 Jun 2004 20:23:24 -0000 1.1.1.1 --- main.cpp 5 Aug 2004 20:52:46 -0000 1.2 *************** *** 1,9 **** ! #include <iostream> ! #include <cpput/result.h> #include <cpput/test.h> #include <cpput/testcontext.h> #include <cpput/testsuite.h> #include "assertenumtest.h" #include "assertstringtest.h" #include "registrytest.h" #include "enumeratortest.h" --- 1,11 ---- ! #include <cpput/progresslistener.h> ! #include <cpput/testrunresult.h> #include <cpput/test.h> #include <cpput/testcontext.h> #include <cpput/testsuite.h> + #include <iostream> #include "assertenumtest.h" #include "assertstringtest.h" + #include "commandlineoptionstest.h" #include "registrytest.h" #include "enumeratortest.h" *************** *** 13,17 **** bool testBasicAssertions(); bool testTestContext(); ! bool testResult(); bool testTestSuite(); bool testTestCase(); --- 15,19 ---- bool testBasicAssertions(); bool testTestContext(); ! bool testTestRunResult(); bool testTestSuite(); bool testTestCase(); *************** *** 23,27 **** return testBasicAssertions() && testFunctors() && ! testResult() && testTestContext() && testTestSuite() && --- 25,29 ---- return testBasicAssertions() && testFunctors() && ! testTestRunResult() && testTestContext() && testTestSuite() && *************** *** 30,42 **** - static std::string makeTestPath( const CppUT::Test &test ) - { - if ( test.parentTest() ) - return makeTestPath( *test.parentTest() ) + "/" + test.name(); - return test.name(); - } - static void dumpFailures( const CppUT::TestSuite &allSuite, ! const CppUT::Result &result ) { if ( result.successful() ) --- 32,37 ---- static void dumpFailures( const CppUT::TestSuite &allSuite, ! const CppUT::TestRunResult &result ) { if ( result.successful() ) *************** *** 48,52 **** for ( int index =0; index < result.failureCount(); ++index ) { ! const CppUT::TestFailure &failure = result.failureAt( index ); if ( failure.location().isValid() ) --- 43,47 ---- for ( int index =0; index < result.failureCount(); ++index ) { ! const CppUT::TestResult &failure = result.failureAt( index ); if ( failure.location().isValid() ) *************** *** 54,58 **** else std::cout << "Unknown failure location: "; ! std::cout << makeTestPath( failure.failedTest() ) << std::endl; std::cout << failure.message().toString() << std::endl; } --- 49,53 ---- else std::cout << "Unknown failure location: "; ! std::cout << CppUT::path( failure.test() ) << std::endl; std::cout << failure.message().toString() << std::endl; } *************** *** 63,90 **** - - class ShowProgress : public CppUT::TestListener - { - public: - void testFailed( const CppUT::TestFailure &failure, - CppUT::TestContext &context ) - { - testFailed_ = true; - } - - void enterTest( CppUT::Test &test, CppUT::TestContext &context ) - { - testFailed_ = false; - std::cout << "Testing '" << makeTestPath( test ) << "' : "; - } - - void exitTest( CppUT::Test &test, CppUT::TestContext &context ) - { - std::cout << (testFailed_ ? "FAILURE" : "OK") << std::endl; - } - - bool testFailed_; - }; - int main( int argc, const char *argv[] ) { --- 58,61 ---- *************** *** 105,114 **** allSuite->add( EnumeratorTest::suite() ); allSuite->add( AssertEnumTest::suite() ); CppUT::TestContext context; ! CppUT::Result result; context.add( result ); ! ShowProgress progress; context.add( progress ); allSuite->run( context ); --- 76,86 ---- allSuite->add( EnumeratorTest::suite() ); allSuite->add( AssertEnumTest::suite() ); + allSuite->add( CommandLineOptionsTest::suite() ); CppUT::TestContext context; ! CppUT::TestRunResult result; context.add( result ); ! CppUT::BriefProgressListener progress; context.add( progress ); allSuite->run( context ); Index: assertstringtest.cpp =================================================================== RCS file: /cvsroot/cpptool/CppParser/src/cpputtest/assertstringtest.cpp,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** assertstringtest.cpp 8 Jun 2004 20:23:24 -0000 1.1.1.1 --- assertstringtest.cpp 5 Aug 2004 20:52:46 -0000 1.2 *************** *** 1,5 **** #include "assertstringtest.h" #include <cpput/assertstring.h> ! #include <cpput/assertexception.h> #include <string.h> // use string.h for easier portability --- 1,5 ---- #include "assertstringtest.h" #include <cpput/assertstring.h> ! #include <cpput/resultexception.h> #include <string.h> // use string.h for easier portability --- NEW FILE: commandlineoptionstest.cpp --- #include "commandlineoptionstest.h" #include <cpput/assertstring.h> //#include <cpputtools/value.h> using namespace CppUTTools; #define LOCAL_CHECK_PARSE \ CPPUT_BEGIN_ASSERTION_MACRO() \ checkParse #define LOCAL_CHECK_PARSE_BAD_OPTION \ CPPUT_BEGIN_ASSERTION_MACRO() \ checkParseBadOption void CommandLineOptionsTest::setUp() { values_ = 0; } void CommandLineOptionsTest::tearDown() { delete values_; } void CommandLineOptionsTest::checkParse( CommandLineOptions::OptionsDescription &description, const char *argv[] ) { delete values_; values_ = new CommandLineOptions::OptionsValues(); std::vector<const char *> commandLine; commandLine.push_back( "test_app.exe" ); while ( *argv ) commandLine.push_back( *argv++ ); CommandLineOptions::parseCommandLine( commandLine.size(), &commandLine[0], description, *values_ ); values_->validate( description ); values_->store( description ); } void CommandLineOptionsTest::checkParseBadOption( CommandLineOptions::OptionsDescription &description, const char *argv[], const std::string &badOptionName ) { try { checkParse( description, argv ); CppUT::fail( "Bad option '" + badOptionName + "' not detected" ); } catch ( const CommandLineOptions::CommandLineParseError &e ) { CppUT::checkEquals( CommandLineOptions::CommandLineParseError::invalidOptionName, e.cause() ); CppUT::checkEquals( badOptionName, e.optionName() ); } } void CommandLineOptionsTest::testParseShortOption() { CommandLineOptions::OptionsDescription options( "test" ); options.add( ",f", "" ); options.add( ",x", "" ); const char *args[] = { "-f", "-x", 0 }; LOCAL_CHECK_PARSE( options, args ); CPPUT_ASSERT_EXPR( values_->hasOption("-f") ); CPPUT_ASSERT_EXPR( values_->hasOption("-x") ); } void CommandLineOptionsTest::testLongOption() { CommandLineOptions::OptionsDescription options( "test" ); options.add( "flag", "" ); options.add( "exclude", "" ); const char *args[] = { "--flag", "--exclude", 0 }; LOCAL_CHECK_PARSE( options, args ); CPPUT_ASSERT_EXPR( values_->hasOption("flag") ); CPPUT_ASSERT_EXPR( values_->hasOption("exclude") ); } void CommandLineOptionsTest::testErrorOnBadOptionName() { CommandLineOptions::OptionsDescription options( "test" ); options.add( "time", "" ); options.add( "exclude,x", "" ); options.add( ",I", "" ); options.add( "duration,d", "" ); options.add( "fast,f", "" ); const char *args1[] = { "--time", "--exclude", "-I", "--duration", "--fast", 0 }; LOCAL_CHECK_PARSE( options, args1 ); const char *args1b[] = { "-x", "-I", "-d", "-f", 0 }; LOCAL_CHECK_PARSE( options, args1b ); const char *args2[] = { "-t", "--exclude", 0 }; LOCAL_CHECK_PARSE_BAD_OPTION( options, args2, "-t" ); const char *args3[] = { "--exclude", "--super", 0 }; LOCAL_CHECK_PARSE_BAD_OPTION( options, args3, "--super" ); const char *args4[] = { "--x", "--super", 0 }; LOCAL_CHECK_PARSE_BAD_OPTION( options, args4, "--x" ); // Notes: we might want to allow this const char *args5[] = { "-exclude", "--super", 0 }; LOCAL_CHECK_PARSE_BAD_OPTION( options, args5, "-exclude" ); } /* void CommandLineOptionsTest::testParseOptionParameter() { CommandLineOptions::OptionsDescription options( "test" ); int time; std::string excluded; double duration; options.add( "time,t", time, "" ); options.add( "exclude,x", excluded, "" ); options.add( "include,i", "" ); options.add( "duration,d", duration, "" ); options.add( "fast,f", "" ); const char *args[] = { "--time", "1234", "--fast", "--exclude", "arg", "--include", "arg2", "--duration", "12.34", 0 }; LOCAL_CHECK_PARSE( options, args ); CPPUT_ASSERT_EXPR( values_->hasOption("fast") ); CPPUT_ASSERT_EXPR( values_->hasOption("time") ); CPPUT_ASSERT_EXPR( values_->hasOption("exclude") ); CPPUT_ASSERT_EXPR( values_->hasOption("include") ); CPPUT_ASSERT_EXPR( values_->hasOption("duration") ); } */ void CommandLineOptionsTest::testParseShortOptionAdjascentParameter() { CommandLineOptions::OptionsDescription options( "test" ); options.add( CommandLineOptions::option<std::string>( ",c:", "" ) ); options.add( CommandLineOptions::optionDefault<std::string>( ",f", ".config", "" ) ); const char *args[] = { "-cabcdef", 0 }; LOCAL_CHECK_PARSE( options, args ); CPPUT_ASSERT_EXPR( values_->hasOption("-c") ); CPPUT_ASSERTSTR_EQUAL( "abcdef", get<std::string>( values_->optionValue("-c") ) ); const char *args2[] = { "-f.ini", 0 }; LOCAL_CHECK_PARSE( options, args2 ); CPPUT_ASSERT_EXPR( values_->hasOption("-f") ); CPPUT_ASSERTSTR_EQUAL( ".ini", get<std::string>( values_->optionValue("-f") ) ); const char *args3[] = { "-f", 0 }; LOCAL_CHECK_PARSE( options, args3 ); CPPUT_ASSERT_EXPR( values_->hasOption("-f") ); CPPUT_ASSERTSTR_EQUAL( ".config", get<std::string>( values_->optionValue("-f") ) ); } void CommandLineOptionsTest::testParseShortOptionNextParameter() { CommandLineOptions::OptionsDescription options( "test" ); options.add( CommandLineOptions::option<std::string>( ",c:", "" ) ); options.add( CommandLineOptions::optionDefault<std::string>(",f", ".config", "" ) ); options.add( ",t", "" ); const char *args[] = { "-c", "abcdef", 0 }; LOCAL_CHECK_PARSE( options, args ); CPPUT_ASSERT_EXPR( values_->hasOption("-c") ); CPPUT_ASSERTSTR_EQUAL( "abcdef", get<std::string>( values_->optionValue("-c") ) ); const char *args2[] = { "-f", ".ini", 0 }; LOCAL_CHECK_PARSE( options, args2 ); CPPUT_ASSERT_EXPR( values_->hasOption("-f") ); CPPUT_ASSERTSTR_EQUAL( ".ini", get<std::string>( values_->optionValue("-f") ) ); const char *args3[] = { "-f", 0 }; LOCAL_CHECK_PARSE( options, args3 ); CPPUT_ASSERT_EXPR( values_->hasOption("-f") ); CPPUT_ASSERTSTR_EQUAL( ".config", get<std::string>( values_->optionValue("-f") ) ); const char *args4[] = { "-c", "abcdef", "-t", 0 }; LOCAL_CHECK_PARSE( options, args4 ); CPPUT_ASSERT_EXPR( values_->hasOption("-c") ); CPPUT_ASSERTSTR_EQUAL( "abcdef", get<std::string>( values_->optionValue("-c") ) ); const char *args5[] = { "-f", ".ini", "-t", 0 }; LOCAL_CHECK_PARSE( options, args5 ); CPPUT_ASSERT_EXPR( values_->hasOption("-f") ); CPPUT_ASSERTSTR_EQUAL( ".ini", get<std::string>( values_->optionValue("-f") ) ); const char *args6[] = { "-f", "-t", 0 }; LOCAL_CHECK_PARSE( options, args6 ); CPPUT_ASSERT_EXPR( values_->hasOption("-f") ); CPPUT_ASSERTSTR_EQUAL( ".config", get<std::string>( values_->optionValue("-f") ) ); } void CommandLineOptionsTest::testParserLongOptionAdjascentParameter() { CommandLineOptions::OptionsDescription options( "test" ); options.add( "column:", "" ); options.add( CommandLineOptions::optionDefault<std::string>( "file", ".config", "" ) ); const char *args[] = { "--column=abcdef", 0 }; LOCAL_CHECK_PARSE( options, args ); CPPUT_ASSERT_EXPR( values_->hasOption("column") ); CPPUT_ASSERTSTR_EQUAL( "abcdef", get<std::string>( values_->optionValue("column") ) ); const char *args2[] = { "--file=.ini", 0 }; LOCAL_CHECK_PARSE( options, args2 ); CPPUT_ASSERT_EXPR( values_->hasOption("file") ); CPPUT_ASSERTSTR_EQUAL( ".ini", get<std::string>( values_->optionValue("file") ) ); const char *args3[] = { "--file", 0 }; LOCAL_CHECK_PARSE( options, args3 ); CPPUT_ASSERT_EXPR( values_->hasOption("file") ); CPPUT_ASSERTSTR_EQUAL( ".config", get<std::string>( values_->optionValue("file") ) ); } void CommandLineOptionsTest::testParserLongOptionNextParameter() { CommandLineOptions::OptionsDescription options( "test" ); options.add( "column:", "" ); options.add( CommandLineOptions::optionDefault<std::string>( "file", ".config", "" ) ); options.add( ",t", "" ); const char *args[] = { "--column", "abcdef", 0 }; LOCAL_CHECK_PARSE( options, args ); CPPUT_ASSERT_EXPR( values_->hasOption("column") ); CPPUT_ASSERTSTR_EQUAL( "abcdef", get<std::string>( values_->optionValue("column") ) ); const char *args2[] = { "--file", ".ini", 0 }; LOCAL_CHECK_PARSE( options, args2 ); CPPUT_ASSERT_EXPR( values_->hasOption("file") ); CPPUT_ASSERTSTR_EQUAL( ".ini", get<std::string>( values_->optionValue("file") ) ); const char *args3[] = { "--file", 0 }; LOCAL_CHECK_PARSE( options, args3 ); CPPUT_ASSERT_EXPR( values_->hasOption("file") ); CPPUT_ASSERTSTR_EQUAL( ".config", get<std::string>( values_->optionValue("file") ) ); const char *args4[] = { "--column", "abcdef", "-t", 0 }; LOCAL_CHECK_PARSE( options, args4 ); CPPUT_ASSERT_EXPR( values_->hasOption("column") ); CPPUT_ASSERTSTR_EQUAL( "abcdef", get<std::string>( values_->optionValue("column") ) ); const char *args5[] = { "--file", ".ini", "-t", 0 }; LOCAL_CHECK_PARSE( options, args5 ); CPPUT_ASSERT_EXPR( values_->hasOption("file") ); CPPUT_ASSERTSTR_EQUAL( ".ini", get<std::string>( values_->optionValue("file") ) ); const char *args6[] = { "--file", "-t", 0 }; LOCAL_CHECK_PARSE( options, args6 ); CPPUT_ASSERT_EXPR( values_->hasOption("file") ); CPPUT_ASSERTSTR_EQUAL( ".config", get<std::string>( values_->optionValue("file") ) ); } void CommandLineOptionsTest::testValuesLookUpAsShortOrLong() { CommandLineOptions::OptionsDescription options( "test" ); options.add( "column,c:", "" ); const char *args[] = { "-c8", 0 }; LOCAL_CHECK_PARSE( options, args ); CPPUT_ASSERT_EXPR( values_->hasOption("-c") ); CPPUT_ASSERT_EXPR( values_->hasOption("column") ); const char *args2[] = { "--column", "8", 0 }; LOCAL_CHECK_PARSE( options, args2 ); CPPUT_ASSERT_EXPR( values_->hasOption("-c") ); CPPUT_ASSERT_EXPR( values_->hasOption("column") ); } void CommandLineOptionsTest::testStoreParameterValues() { CommandLineOptions::OptionsDescription options( "test" ); int column = -1; std::string file; options.add( CommandLineOptions::option( "column,c:", column, "" ) ); options.add( CommandLineOptions::option( "file", file, ".config", "" ) ); const char *args[] = { "-c8", "--file", "test", 0 }; LOCAL_CHECK_PARSE( options, args ); CPPUT_ASSERT_EXPR( values_->hasOption("column") ); CPPUT_ASSERT_EXPR( values_->hasOption("file") ); CPPUT_ASSERTSTR_EQUAL( "test", file ); CPPUT_ASSERT_EQUAL( 8, column ); const char *args2[] = { "--file", "-c", "8", 0 }; LOCAL_CHECK_PARSE( options, args2 ); CPPUT_ASSERT_EXPR( values_->hasOption("column") ); CPPUT_ASSERT_EXPR( values_->hasOption("file") ); CPPUT_ASSERTSTR_EQUAL( ".config", file ); CPPUT_ASSERT_EQUAL( 8, column ); } void CommandLineOptionsTest::testParseRequiredParameter() { CommandLineOptions::OptionsDescription options( "test" ); options.add( "column,c:", "" ); options.add( "file:", "" ); const char *args[] = { "--file", "--column", "abcdef", 0 }; try { checkParse( options, args ); CPPUT_FAIL( "Command line parsing should have failed because of missing parameter of --file." ); } catch ( const CommandLineOptions::ValidatorError &e ) { CPPUT_ASSERT_EXPR( e.cause() == CommandLineOptions::ValidatorError::missingParameter ); } } static Value validateTraceOrTime( const CommandLineOptions::Parameters ¶meters ) { std::string text = parameters.at(0); if ( text != "trace" && text != "time" ) throw CommandLineOptions::ValidatorError( CommandLineOptions::ValidatorError::badParameterValue, "trace or time expected." ); return value( text ); } void CommandLineOptionsTest::testCustomValidator() { CommandLineOptions::OptionsDescription options( "test" ); std::string file; options.add( CommandLineOptions::option( "debug,d:", file, "" ).setValidator( CommandLineOptions::validator( &validateTraceOrTime ) ) ); const char *args[] = { "-d", "trace", 0 }; LOCAL_CHECK_PARSE( options, args ); CPPUT_ASSERT_EXPR( values_->hasOption("debug") ); CPPUT_ASSERTSTR_EQUAL( "trace", file ); const char *args2[] = { "-d", "time", 0 }; LOCAL_CHECK_PARSE( options, args2 ); CPPUT_ASSERT_EXPR( values_->hasOption("debug") ); CPPUT_ASSERTSTR_EQUAL( "time", file ); const char *args3[] = { "-d", "bad", 0 }; try { checkParse( options, args3 ); CPPUT_FAIL( "Validation should have failed because of bad parameter for -d." ); } catch ( const CommandLineOptions::ValidatorError &e ) { CPPUT_ASSERTSTR_EQUAL( "debug", e.optionName() ); CPPUT_ASSERT_EXPR( e.cause() == CommandLineOptions::ValidatorError::badParameterValue ); } } void CommandLineOptionsTest::testEnumerationValidator() { CommandLineOptions::OptionsDescription options( "test" ); LogLevel level; CommandLineOptions::EnumerationValidator<LogLevel> logLevelValidator; logLevelValidator.add( "fatal", fatal, "Log only fatal events." ); logLevelValidator.add( "warning", warning, "Log only fatal and warning events." ); logLevelValidator.add( "info", info, "Log all events." ); options.add( CommandLineOptions::validatedOption( "level,l", level, fatal, "Set log level", logLevelValidator.clone() ) ); const char *args[] = { "-l", "info", 0 }; LOCAL_CHECK_PARSE( options, args ); CPPUT_ASSERT_EXPR( values_->hasOption("level") ); CPPUT_ASSERT_EQUAL( info, level ); const char *args2[] = { "-l", 0 }; LOCAL_CHECK_PARSE( options, args2 ); CPPUT_ASSERT_EXPR( values_->hasOption("level") ); CPPUT_ASSERT_EQUAL( fatal, level ); } Index: testfixturetest.h =================================================================== RCS file: /cvsroot/cpptool/CppParser/src/cpputtest/testfixturetest.h,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** testfixturetest.h 8 Jun 2004 20:23:25 -0000 1.1.1.1 --- testfixturetest.h 5 Aug 2004 20:52:46 -0000 1.2 *************** *** 7,11 **** # include <cpput/testcontext.h> # include <cpput/testfixture.h> ! # include <cpput/result.h> --- 7,11 ---- # include <cpput/testcontext.h> # include <cpput/testfixture.h> ! # include <cpput/testrunresult.h> Index: testtestcase.cpp =================================================================== RCS file: /cvsroot/cpptool/CppParser/src/cpputtest/testtestcase.cpp,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** testtestcase.cpp 8 Jun 2004 20:23:25 -0000 1.1.1.1 --- testtestcase.cpp 5 Aug 2004 20:52:46 -0000 1.2 *************** *** 1,5 **** #include <cpput/assert.h> ! #include <cpput/assertexception.h> ! #include <cpput/result.h> #include <cpput/testcase.h> #include <cpput/testcontext.h> --- 1,5 ---- #include <cpput/assert.h> ! #include <cpput/resultexception.h> ! #include <cpput/testrunresult.h> #include <cpput/testcase.h> #include <cpput/testcontext.h> *************** *** 94,98 **** CppUT::TestContext context; ! CppUT::Result result; context.add( result ); test->run( context ); --- 94,98 ---- CppUT::TestContext context; ! CppUT::TestRunResult result; context.add( result ); test->run( context ); *************** *** 129,133 **** CppUT::TestContext context; ! CppUT::Result result; context.add( result ); test->run( context ); --- 129,133 ---- CppUT::TestContext context; ! CppUT::TestRunResult result; context.add( result ); test->run( context ); *************** *** 150,154 **** CppUT::TestContext context; ! CppUT::Result result; context.add( result ); test->run( context ); --- 150,154 ---- CppUT::TestContext context; ! CppUT::TestRunResult result; context.add( result ); test->run( context ); *************** *** 171,175 **** CppUT::TestContext context; ! CppUT::Result result; context.add( result ); test->run( context ); --- 171,175 ---- CppUT::TestContext context; ! CppUT::TestRunResult result; context.add( result ); test->run( context ); *************** *** 192,196 **** CppUT::TestContext context; ! CppUT::Result result; context.add( result ); test->run( context ); --- 192,196 ---- CppUT::TestContext context; ! CppUT::TestRunResult result; context.add( result ); test->run( context ); *************** *** 213,217 **** CPPUT_ASSERT_EQUAL( "Test1", test->name() ); CppUT::TestContext context; ! CppUT::Result result; context.add( result ); test->run( context ); --- 213,217 ---- CPPUT_ASSERT_EQUAL( "Test1", test->name() ); CppUT::TestContext context; ! CppUT::TestRunResult result; context.add( result ); test->run( context ); *************** *** 233,237 **** CPPUT_ASSERT_EQUAL( "Test1", test->name() ); CppUT::TestContext context; ! CppUT::Result result; context.add( result ); test->run( context ); --- 233,237 ---- CPPUT_ASSERT_EQUAL( "Test1", test->name() ); CppUT::TestContext context; ! CppUT::TestRunResult result; context.add( result ); test->run( context ); --- NEW FILE: testtestrunresult.cpp --- #include <cpput/testrunresult.h> #include <cpput/assert.h> #include <cpput/resultexception.h> #include <cpput/test.h> #include <cpput/testcontext.h> #include <iostream> namespace { class DummyTest : public CppUT::AbstractTest { public: void run( CppUT::TestContext &context ) { } void accept( CppUT::TestVisitor &visitor ) { } int totalTestCount() const { return 1; } }; } bool testTestRunResult() { try { CppUT::TestRunResult result; CppUT::TestContext context; CPPUT_ASSERT( result.successful() ); CPPUT_ASSERT_EQUAL( 0, result.failureCount() ); DummyTest dummyTest1; CppUT::Message message1( "message1" ); message1.setStatus( false ); message1.setResultType( "fault" ); CppUT::TestResult failure1( dummyTest1, message1 ); result.processTestResult( failure1, context ); CPPUT_ASSERT_FALSE( result.successful() ); CPPUT_ASSERT_EQUAL( 1, result.failureCount() ); const CppUT::TestResult &failure1b = result.failureAt(0); CPPUT_ASSERT_FALSE( failure1b.isAssertionFailure() ); CPPUT_ASSERT_EQUAL( 1, failure1b.message().count() ); CPPUT_ASSERT_EQUAL( "message1", failure1b.message().at(0) ); DummyTest dummyTest2; CppUT::Message message2( "message2" ); message2.setStatus( false ); message2.setResultType( "assertion" ); CppUT::TestResult failure2( dummyTest2, message2, CppUT::Location( "somefile.cpp", 123 ) ); result.processTestResult( failure2, context ); CPPUT_ASSERT_FALSE( result.successful() ); CPPUT_ASSERT_EQUAL( 2, result.failureCount() ); const CppUT::TestResult &failure2b = result.failureAt(1); CPPUT_ASSERT( failure2b.isAssertionFailure() ); CPPUT_ASSERT_EQUAL( 1, failure2b.message().count() ); CPPUT_ASSERT_EQUAL( "message2", failure2b.message().at(0) ); CPPUT_ASSERT_EQUAL( "somefile.cpp", failure2b.location().fileName() ); CPPUT_ASSERT_EQUAL( 123, failure2b.location().lineNumber() ); DummyTest dummyTest3; CppUT::Message message3( "message3" ); message3.setStatus( false ); message3.setResultType( "assertion" ); CppUT::TestResult failure3( dummyTest3, message3, CppUT::Location( "somefile3.cpp", 23 ) ); result.processTestResult( failure3, context ); CPPUT_ASSERT_EQUAL( 3, result.failureCount() ); CPPUT_ASSERT( result.failureAt(2).isAssertionFailure() ); DummyTest dummyTest4; CppUT::Message message4( "message4" ); message3.setStatus( false ); message3.setResultType( "assertion" ); CppUT::TestResult failure4( dummyTest4, message4 ); result.processTestResult( failure4, context ); CPPUT_ASSERT_EQUAL( 4, result.failureCount() ); CPPUT_ASSERT_FALSE( result.failureAt(3).isAssertionFailure() ); } catch ( CppUT::AssertException &e ) { std::cout << "testResult() failed: " << e.what() << std::endl; return false; } return true; } Index: testtestsuite.cpp =================================================================== RCS file: /cvsroot/cpptool/CppParser/src/cpputtest/testtestsuite.cpp,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** testtestsuite.cpp 8 Jun 2004 20:23:25 -0000 1.1.1.1 --- testtestsuite.cpp 5 Aug 2004 20:52:46 -0000 1.2 *************** *** 1,4 **** #include <cpput/assert.h> ! #include <cpput/assertexception.h> #include <cpput/testsuite.h> #include <cpput/testcontext.h> --- 1,4 ---- #include <cpput/assert.h> ! #include <cpput/resultexception.h> #include <cpput/testsuite.h> #include <cpput/testcontext.h> Index: testtestcontext.cpp =================================================================== RCS file: /cvsroot/cpptool/CppParser/src/cpputtest/testtestcontext.cpp,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** testtestcontext.cpp 8 Jun 2004 20:23:25 -0000 1.1.1.1 --- testtestcontext.cpp 5 Aug 2004 20:52:46 -0000 1.2 *************** *** 1,6 **** #include <cpput/assert.h> ! #include <cpput/assertexception.h> #include <cpput/test.h> ! #include <cpput/testfailure.h> #include <cpput/testsuite.h> #include <cpput/testcontext.h> --- 1,6 ---- #include <cpput/assert.h> ! #include <cpput/resultexception.h> #include <cpput/test.h> ! #include <cpput/testresult.h> #include <cpput/testsuite.h> #include <cpput/testcontext.h> *************** *** 66,72 **** }; ! class CustomException1TestFailureGuard : public CppUT::TestFailureGuard { ! public: // overridden from TestFailureGuard bool protect( Context &context ) { --- 66,72 ---- }; ! class CustomException1TestExceptionGuard : public CppUT::TestExceptionGuard { ! public: // overridden from TestExceptionGuard bool protect( Context &context ) { *************** *** 78,82 **** { CppUT::FaultException fault( "CustomException1" ); ! context.failureHandler_.handleFault( context.protectedTest_, fault ); } --- 78,82 ---- { CppUT::FaultException fault( "CustomException1" ); ! context.exceptionHandler_.handleResultException( context.protectedTest_, fault ); } *************** *** 85,91 **** }; ! class CustomException2TestFailureGuard : public CppUT::TestFailureGuard { ! public: // overridden from TestFailureGuard bool protect( Context &context ) { --- 85,91 ---- }; ! class CustomException2TestExceptionGuard : public CppUT::TestExceptionGuard { ! public: // overridden from TestExceptionGuard bool protect( Context &context ) { *************** *** 97,101 **** { CppUT::FaultException fault( "CustomException2" ); ! context.failureHandler_.handleFault( context.protectedTest_, fault ); } --- 97,101 ---- { CppUT::FaultException fault( "CustomException2" ); ! context.exceptionHandler_.handleResultException( context.protectedTest_, fault ); } *************** *** 107,112 **** { public: // overridden from CppUT::TestListener ! void testFailed( const CppUT::TestFailure &failure, ! CppUT::TestContext &context ) { message_ = failure.message().toString(); --- 107,112 ---- { public: // overridden from CppUT::TestListener ! void processTestResult( CppUT::TestResult &failure, ! CppUT::TestContext &context ) { message_ = failure.message().toString(); *************** *** 260,263 **** --- 260,265 ---- CPPUT_ASSERT_EQUAL( 1, listener1.exitTestCount_ ); CPPUT_ASSERT_EQUAL( 0, listener1.testFailedCount_ ); + CPPUT_ASSERT_EQUAL( 1, listener1.testResultCount_ ); + CPPUT_ASSERT_EQUAL( 1, listener1.testSucceededCount_ ); CPPUT_ASSERT_EQUAL( 0, listener1.enterSuiteCount_ ); CPPUT_ASSERT_EQUAL( 0, listener1.exitSuiteCount_ ); *************** *** 270,276 **** --- 272,282 ---- CPPUT_ASSERT_EQUAL( 2, listener1.exitTestCount_ ); CPPUT_ASSERT_EQUAL( 1, listener1.testFailedCount_ ); + CPPUT_ASSERT_EQUAL( 2, listener1.testResultCount_ ); + CPPUT_ASSERT_EQUAL( 1, listener1.testSucceededCount_ ); CPPUT_ASSERT_EQUAL( 1, listener2.enterTestCount_ ); CPPUT_ASSERT_EQUAL( 1, listener2.exitTestCount_ ); CPPUT_ASSERT_EQUAL( 1, listener2.testFailedCount_ ); + CPPUT_ASSERT_EQUAL( 1, listener2.testResultCount_ ); + CPPUT_ASSERT_EQUAL( 0, listener2.testSucceededCount_ ); MockTestListener listener3; *************** *** 281,290 **** --- 287,302 ---- CPPUT_ASSERT_EQUAL( 3, listener1.exitTestCount_ ); CPPUT_ASSERT_EQUAL( 2, listener1.testFailedCount_ ); + CPPUT_ASSERT_EQUAL( 3, listener1.testResultCount_ ); + CPPUT_ASSERT_EQUAL( 1, listener1.testSucceededCount_ ); CPPUT_ASSERT_EQUAL( 2, listener2.enterTestCount_ ); CPPUT_ASSERT_EQUAL( 2, listener2.exitTestCount_ ); CPPUT_ASSERT_EQUAL( 2, listener2.testFailedCount_ ); + CPPUT_ASSERT_EQUAL( 2, listener2.testResultCount_ ); + CPPUT_ASSERT_EQUAL( 0, listener2.testSucceededCount_ ); CPPUT_ASSERT_EQUAL( 1, listener3.enterTestCount_ ); CPPUT_ASSERT_EQUAL( 1, listener3.exitTestCount_ ); CPPUT_ASSERT_EQUAL( 1, listener3.testFailedCount_ ); + CPPUT_ASSERT_EQUAL( 1, listener3.testResultCount_ ); + CPPUT_ASSERT_EQUAL( 0, listener3.testSucceededCount_ ); MockTestListener listener4; *************** *** 295,307 **** --- 307,327 ---- CPPUT_ASSERT_EQUAL( 4, listener1.exitTestCount_ ); CPPUT_ASSERT_EQUAL( 3, listener1.testFailedCount_ ); + CPPUT_ASSERT_EQUAL( 4, listener1.testResultCount_ ); + CPPUT_ASSERT_EQUAL( 1, listener1.testSucceededCount_ ); CPPUT_ASSERT_EQUAL( 3, listener2.enterTestCount_ ); CPPUT_ASSERT_EQUAL( 3, listener2.exitTestCount_ ); CPPUT_ASSERT_EQUAL( 3, listener2.testFailedCount_ ); + CPPUT_ASSERT_EQUAL( 3, listener2.testResultCount_ ); + CPPUT_ASSERT_EQUAL( 0, listener2.testSucceededCount_ ); CPPUT_ASSERT_EQUAL( 2, listener3.enterTestCount_ ); CPPUT_ASSERT_EQUAL( 2, listener3.exitTestCount_ ); CPPUT_ASSERT_EQUAL( 2, listener3.testFailedCount_ ); + CPPUT_ASSERT_EQUAL( 2, listener3.testResultCount_ ); + CPPUT_ASSERT_EQUAL( 0, listener3.testSucceededCount_ ); CPPUT_ASSERT_EQUAL( 1, listener4.enterTestCount_ ); CPPUT_ASSERT_EQUAL( 1, listener4.exitTestCount_ ); CPPUT_ASSERT_EQUAL( 1, listener4.testFailedCount_ ); + CPPUT_ASSERT_EQUAL( 1, listener4.testResultCount_ ); + CPPUT_ASSERT_EQUAL( 0, listener4.testSucceededCount_ ); /* DummyTestSuite suite; *************** *** 321,328 **** CaptureMessageTestListener listener; context.add( listener ); ! context.appendGuard( CppUT::TestFailureGuardPtr( ! new CustomException1TestFailureGuard() ) ); ! context.appendGuard( CppUT::TestFailureGuardPtr( ! new CustomException2TestFailureGuard() ) ); DummyTest dummyTest; --- 341,348 ---- CaptureMessageTestListener listener; context.add( listener ); ! context.appendGuard( CppUT::TestExceptionGuardPtr( ! new CustomException1TestExceptionGuard() ) ); ! context.appendGuard( CppUT::TestExceptionGuardPtr( ! new CustomException2TestExceptionGuard() ) ); DummyTest dummyTest; Index: testfixturetest.cpp =================================================================== RCS file: /cvsroot/cpptool/CppParser/src/cpputtest/testfixturetest.cpp,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** testfixturetest.cpp 8 Jun 2004 20:23:25 -0000 1.1.1.1 --- testfixturetest.cpp 5 Aug 2004 20:52:46 -0000 1.2 *************** *** 156,160 **** CppUT::TestPtr suite = EmptyFixture::suite(); CppUT::TestContext context; ! CppUT::Result result; context.add( result ); suite->run( context ); --- 156,160 ---- CppUT::TestPtr suite = EmptyFixture::suite(); CppUT::TestContext context; ! CppUT::TestRunResult result; context.add( result ); suite->run( context ); *************** *** 168,172 **** CppUT::TestPtr suite = TwoTestFixture::suite(); CppUT::TestContext context; ! CppUT::Result result; context.add( result ); suite->run( context ); --- 168,172 ---- CppUT::TestPtr suite = TwoTestFixture::suite(); CppUT::TestContext context; ! CppUT::TestRunResult result; context.add( result ); suite->run( context ); *************** *** 181,185 **** CppUT::TestPtr suite = ExtendTestFixture::suite(); CppUT::TestContext context; ! CppUT::Result result; context.add( result ); suite->run( context ); --- 181,185 ---- CppUT::TestPtr suite = ExtendTestFixture::suite(); CppUT::TestContext context; ! CppUT::TestRunResult result; context.add( result ); suite->run( context ); *************** *** 194,198 **** CppUT::TestPtr suite = ConcretTestFixture::suite(); CppUT::TestContext context; ! CppUT::Result result; context.add( result ); suite->run( context ); --- 194,198 ---- CppUT::TestPtr suite = ConcretTestFixture::suite(); CppUT::TestContext context; ! CppUT::TestRunResult result; context.add( result ); suite->run( context ); *************** *** 207,211 **** CppUT::TestPtr suite = NoSharedFixtureTest::suite(); CppUT::TestContext context; ! CppUT::Result result; context.add( result ); SharedFixtureTestBase::instances_.clear(); --- 207,211 ---- CppUT::TestPtr suite = NoSharedFixtureTest::suite(); CppUT::TestContext context; ! CppUT::TestRunResult result; context.add( result ); SharedFixtureTestBase::instances_.clear(); *************** *** 222,226 **** CppUT::TestPtr suite = SharedFixtureTest::suite(); CppUT::TestContext context; ! CppUT::Result result; context.add( result ); SharedFixtureTestBase::instances_.clear(); --- 222,226 ---- CppUT::TestPtr suite = SharedFixtureTest::suite(); CppUT::TestContext context; ! CppUT::TestRunResult result; context.add( result ); SharedFixtureTestBase::instances_.clear(); --- NEW FILE: commandlineoptionstest.h --- #ifndef CPPUT_COMMANDLINEOPTIONS_H_INCLUDED #define CPPUT_COMMANDLINEOPTIONS_H_INCLUDED # include <cpput/assert.h> # include <cpput/testfixture.h> # include <cpput/registry.h> # include <cpputtools/configuration.h> class CommandLineOptionsTest : public CppUT::TestFixture { public: CPPUT_TESTSUITE_BEGIN( CommandLineOptionsTest ); CPPUT_TEST( testParseShortOption ); CPPUT_TEST( testLongOption ); CPPUT_TEST( testErrorOnBadOptionName ); CPPUT_TEST( testParseShortOptionAdjascentParameter ); CPPUT_TEST( testParseShortOptionNextParameter ); CPPUT_TEST( testParserLongOptionAdjascentParameter ); CPPUT_TEST( testParserLongOptionNextParameter ); CPPUT_TEST( testStoreParameterValues ); CPPUT_TEST( testValuesLookUpAsShortOrLong ); CPPUT_TEST( testParseRequiredParameter ); CPPUT_TEST( testCustomValidator ); CPPUT_TEST( testEnumerationValidator ); CPPUT_TESTSUITE_END(); void setUp(); void tearDown(); void testParseShortOption(); void testLongOption(); void testErrorOnBadOptionName(); void testParseShortOptionAdjascentParameter(); void testParseShortOptionNextParameter(); void testParserLongOptionAdjascentParameter(); void testParserLongOptionNextParameter(); void testValuesLookUpAsShortOrLong(); void testStoreParameterValues(); void testParseRequiredParameter(); void testCustomValidator(); void testEnumerationValidator(); private: void checkParse( CppUTTools::CommandLineOptions::OptionsDescription &description, const char *argv[] ); void checkParseBadOption( CppUTTools::CommandLineOptions::OptionsDescription &description, const char *argv[], const std::string &badOptionName ); enum LogLevel { fatal = 1, warning, info }; CppUTTools::CommandLineOptions::OptionsValues *values_; }; #endif // CPPUT_COMMANDLINEOPTIONS_H_INCLUDED Index: cpputtest.dsp =================================================================== RCS file: /cvsroot/cpptool/CppParser/src/cpputtest/cpputtest.dsp,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** cpputtest.dsp 8 Jun 2004 20:23:24 -0000 1.1.1.1 --- cpputtest.dsp 5 Aug 2004 20:52:46 -0000 1.2 *************** *** 52,56 **** # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 /libpath:"..\..\build\cpput\release" # Begin Special Build Tool ! TargetPath=\prg\vc\Lib\CppUT\build\cpputtest\release\cpputtest.exe SOURCE="$(InputPath)" PostBuild_Desc=Testing cpput library... --- 52,56 ---- # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 /libpath:"..\..\build\cpput\release" # Begin Special Build Tool ! TargetPath=\prg\vc\Lib\cppunit2\build\cpputtest\release\cpputtest.exe SOURCE="$(InputPath)" PostBuild_Desc=Testing cpput library... *************** *** 82,86 **** # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept /libpath:"..\..\build\cpput\debug" # Begin Special Build Tool ! TargetPath=\prg\vc\Lib\CppUT\build\cpputtest\debug\cpputtest.exe SOURCE="$(InputPath)" PostBuild_Desc=Testing cpput library... --- 82,86 ---- # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept /libpath:"..\..\build\cpput\debug" # Begin Special Build Tool ! TargetPath=\prg\vc\Lib\cppunit2\build\cpputtest\debug\cpputtest.exe SOURCE="$(InputPath)" PostBuild_Desc=Testing cpput library... *************** *** 112,115 **** --- 112,123 ---- # Begin Source File + SOURCE=.\commandlineoptions.cpp + # End Source File + # Begin Source File + + SOURCE=.\commandlineoptions.h + # End Source File + # Begin Source File + SOURCE=.\enumeratortest.cpp # End Source File --- testresult.cpp DELETED --- Index: mocktestlistener.h =================================================================== RCS file: /cvsroot/cpptool/CppParser/src/cpputtest/mocktestlistener.h,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** mocktestlistener.h 8 Jun 2004 20:23:24 -0000 1.1.1.1 --- mocktestlistener.h 5 Aug 2004 20:52:46 -0000 1.2 *************** *** 10,13 **** --- 10,15 ---- MockTestListener() : testFailedCount_( 0 ) + , testSucceededCount_( 0 ) + , testResultCount_( 0 ) , enterTestCount_( 0 ) , exitTestCount_( 0 ) *************** *** 17,24 **** } ! void testFailed( const CppUT::TestFailure &failure, ! CppUT::TestContext &context ) { ! ++testFailedCount_; } --- 19,32 ---- } ! // overridden from CppUT::TestListener ! ! void processTestResult( CppUT::TestResult &result, ! CppUT::TestContext &context ) { ! ++testResultCount_; ! if ( result.failed() ) ! ++testFailedCount_; ! else ! ++testSucceededCount_; } *************** *** 46,49 **** --- 54,59 ---- int testFailedCount_; + int testSucceededCount_; + int testResultCount_; int enterTestCount_; int exitTestCount_; Index: testfunctor.cpp =================================================================== RCS file: /cvsroot/cpptool/CppParser/src/cpputtest/testfunctor.cpp,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** testfunctor.cpp 8 Jun 2004 20:23:25 -0000 1.1.1.1 --- testfunctor.cpp 5 Aug 2004 20:52:46 -0000 1.2 *************** *** 1,4 **** #include <cpput/assert.h> ! #include <cpput/assertexception.h> #include <cpput/functor.h> #include <iostream> --- 1,4 ---- #include <cpput/assert.h> ! #include <cpput/resultexception.h> #include <cpput/functor.h> #include <iostream> Index: testbasicassertion.cpp =================================================================== RCS file: /cvsroot/cpptool/CppParser/src/cpputtest/testbasicassertion.cpp,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** testbasicassertion.cpp 8 Jun 2004 20:23:25 -0000 1.1.1.1 --- testbasicassertion.cpp 5 Aug 2004 20:52:46 -0000 1.2 *************** *** 1,4 **** #include <cpput/assert.h> ! #include <cpput/assertexception.h> #include <iostream> --- 1,4 ---- #include <cpput/assert.h> ! #include <cpput/resultexception.h> #include <iostream> *************** *** 73,76 **** --- 73,79 ---- try { + CPPUT_ASSERT_THROW( CPPUT_SUCCEED( CppUT::Message( "warning..." ) ), + CppUT::SuccessException ); + // CPPUT_ASSERT CPPUT_ASSERT_ASSERTION_PASS( CPPUT_ASSERT( true ) ); Index: cpputtest.vcproj =================================================================== RCS file: /cvsroot/cpptool/CppParser/src/cpputtest/cpputtest.vcproj,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** cpputtest.vcproj 8 Jun 2004 20:23:24 -0000 1.1.1.1 --- cpputtest.vcproj 5 Aug 2004 20:52:46 -0000 1.2 *************** *** 163,166 **** --- 163,172 ---- </File> <File + RelativePath=".\commandlineoptionstest.cpp"> + </File> + <File + RelativePath=".\commandlineoptionstest.h"> + </File> + <File RelativePath="enumeratortest.cpp"> </File> *************** *** 202,208 **** </File> <File - RelativePath=".\testresult.cpp"> - </File> - <File RelativePath=".\testtestcase.cpp"> </File> --- 208,211 ---- *************** *** 211,214 **** --- 214,220 ---- </File> <File + RelativePath=".\testtestrunresult.cpp"> + </File> + <File RelativePath=".\testtestsuite.cpp"> </File> |
From: Baptiste L. <bl...@us...> - 2004-08-05 20:52:58
|
Update of /cvsroot/cpptool/CppParser/src/cpput In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv20897/src/cpput Modified Files: assert.cpp cpput.dsp cpput.vcproj dllproxy.cpp parametrizedsource.cpp testcontext.cpp testfailureguard.cpp Added Files: tablefixture.cpp Log Message: * upgraded to current cppunit 2 cvs Index: cpput.vcproj =================================================================== RCS file: /cvsroot/cpptool/CppParser/src/cpput/cpput.vcproj,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** cpput.vcproj 8 Jun 2004 20:23:23 -0000 1.1.1.1 --- cpput.vcproj 5 Aug 2004 20:52:46 -0000 1.2 *************** *** 129,136 **** Filter=""> <File ! RelativePath="..\cpputtest\SConscript"> </File> <File ! RelativePath=".\SConscript"> </File> <File --- 129,136 ---- Filter=""> <File ! RelativePath=".\SConscript"> </File> <File ! RelativePath="..\cpputtest\SConscript"> </File> <File *************** *** 138,141 **** --- 138,188 ---- </File> </Filter> + <Filter + Name="cpputtools" + Filter=""> + <File + RelativePath="..\..\include\cpputtools\configuration.h"> + </File> + <File + RelativePath="..\..\include\cpputtools\convertor.h"> + </File> + <File + RelativePath="..\..\include\cpputtools\ctti.h"> + </File> + <File + RelativePath="..\..\include\cpputtools\refcountptr.h"> + </File> + <File + RelativePath="..\..\include\cpputtools\value.h"> + </File> + <File + RelativePath="..\..\include\cpputtools\valuebinder.h"> + </File> + <Filter + Name="configuration" + Filter=""> + <File + RelativePath="..\..\include\cpputtools\configuration\description.h"> + </File> + <File + RelativePath="..\..\include\cpputtools\configuration\errors.h"> + </File> + <File + RelativePath="..\..\include\cpputtools\configuration\forwards.h"> + </File> + <File + RelativePath="..\..\include\cpputtools\configuration\parser.h"> + </File> + <File + RelativePath="..\..\include\cpputtools\configuration\simplertti.h"> + </File> + <File + RelativePath="..\..\include\cpputtools\configuration\validator.h"> + </File> + <File + RelativePath="..\..\include\cpputtools\configuration\values.h"> + </File> + </Filter> + </Filter> <File RelativePath=".\assert.cpp"> *************** *** 148,154 **** </File> <File - RelativePath="..\..\include\cpput\assertexception.h"> - </File> - <File RelativePath="assertstring.cpp"> </File> --- 195,198 ---- *************** *** 223,226 **** --- 267,276 ---- </File> <File + RelativePath="..\..\include\cpput\progresslistener.h"> + </File> + <File + RelativePath="..\..\include\cpput\properties.h"> + </File> + <File RelativePath=".\registry.cpp"> </File> *************** *** 229,233 **** </File> <File ! RelativePath="..\..\include\cpput\result.h"> </File> <File --- 279,286 ---- </File> <File ! RelativePath="..\..\include\cpput\resource.h"> ! </File> ! <File ! RelativePath="..\..\include\cpput\resultexception.h"> </File> <File *************** *** 238,241 **** --- 291,312 ---- </File> <File + RelativePath=".\tablefixture.cpp"> + <FileConfiguration + Name="Release|Win32" + ExcludedFromBuild="TRUE"> + <Tool + Name="VCCLCompilerTool"/> + </FileConfiguration> + <FileConfiguration + Name="Debug|Win32" + ExcludedFromBuild="TRUE"> + <Tool + Name="VCCLCompilerTool"/> + </FileConfiguration> + </File> + <File + RelativePath="..\..\include\cpput\tablefixture.h"> + </File> + <File RelativePath="..\..\include\cpput\test.h"> </File> *************** *** 253,259 **** </File> <File - RelativePath="..\..\include\cpput\testfailure.h"> - </File> - <File RelativePath=".\testfailureguard.cpp"> </File> --- 324,327 ---- *************** *** 268,271 **** --- 336,345 ---- </File> <File + RelativePath="..\..\include\cpput\testresult.h"> + </File> + <File + RelativePath="..\..\include\cpput\testrunresult.h"> + </File> + <File RelativePath=".\testsuite.cpp"> </File> Index: testcontext.cpp =================================================================== RCS file: /cvsroot/cpptool/CppParser/src/cpput/testcontext.cpp,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** testcontext.cpp 8 Jun 2004 20:23:24 -0000 1.1.1.1 --- testcontext.cpp 5 Aug 2004 20:52:46 -0000 1.2 *************** *** 1,5 **** #include <cpput/testcontext.h> ! #include <cpput/assertexception.h> ! #include <cpput/testfailure.h> #include <cpput/testlistener.h> #include <cpput/testsuite.h> --- 1,5 ---- #include <cpput/testcontext.h> ! #include <cpput/resultexception.h> ! #include <cpput/testresult.h> #include <cpput/testlistener.h> #include <cpput/testsuite.h> *************** *** 14,17 **** --- 14,18 ---- TestContext::TestContext() + : testSucceeded_( true ) { } *************** *** 22,29 **** --- 23,35 ---- Functor1<TestContext *> runTest ) { + testSucceeded_ = true; + dispatchTestEvent( test, &TestListener::enterTest ); guardsChain_.protect( *this, bind1( runTest, this ), test ); + if ( testSucceeded_ ) + dispatchTestSuccessResult( test ); + dispatchTestEvent( test, &TestListener::exitTest ); } *************** *** 61,65 **** void ! TestContext::appendGuard( const TestFailureGuardPtr &guard ) { guardsChain_.appendGuard( guard ); --- 67,71 ---- void ! TestContext::appendGuard( const TestExceptionGuardPtr &guard ) { guardsChain_.appendGuard( guard ); *************** *** 102,107 **** void ! TestContext::dispatchTestFailure( const TestFailure &failure ) { Listeners::const_iterator it = listeners_.begin(); Listeners::const_iterator itEnd = listeners_.end(); --- 108,116 ---- void ! TestContext::dispatchTestResult( TestResult &result ) { + if ( result.failed() ) + testSucceeded_ = false; + Listeners::const_iterator it = listeners_.begin(); Listeners::const_iterator itEnd = listeners_.end(); *************** *** 109,113 **** { TestListener &listener = **it++; ! listener.testFailed( failure, *this ); } } --- 118,122 ---- { TestListener &listener = **it++; ! listener.processTestResult( result, *this ); } } *************** *** 115,129 **** void ! TestContext::handleAssertion( Test &failedTest, const AssertException &e ) { ! TestFailure failure( failedTest, e.message(), e.location() ); ! dispatchTestFailure( failure ); } void ! TestContext::handleFault( Test &failedTest, const FaultException &e ) { ! TestFailure failure( failedTest, e.message(), e.location() ); ! dispatchTestFailure( failure ); } --- 124,141 ---- void ! TestContext::dispatchTestSuccessResult( Test &test ) { ! Message message; ! message.setStatus( true ); ! TestResult result( test, message ); ! dispatchTestResult( result ); } + void ! TestContext::handleResultException( Test &test, const ResultException &e ) { ! TestResult result( test, e.message(), e.location() ); ! dispatchTestResult( result ); } Index: cpput.dsp =================================================================== RCS file: /cvsroot/cpptool/CppParser/src/cpput/cpput.dsp,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** cpput.dsp 8 Jun 2004 20:23:23 -0000 1.1.1.1 --- cpput.dsp 5 Aug 2004 20:52:46 -0000 1.2 *************** *** 89,92 **** --- 89,151 ---- # End Source File # End Group + # Begin Group "cpputtools" + + # PROP Default_Filter "" + # Begin Group "configuration" + + # PROP Default_Filter "" + # Begin Source File + + SOURCE=..\..\include\cpputtools\configuration\description.h + # End Source File + # Begin Source File + + SOURCE=..\..\include\cpputtools\configuration\errors.h + # End Source File + # Begin Source File + + SOURCE=..\..\include\cpputtools\configuration\forwards.h + # End Source File + # Begin Source File + + SOURCE=..\..\include\cpputtools\configuration\parser.h + # End Source File + # Begin Source File + + SOURCE=..\..\include\cpputtools\configuration\simplertti.h + # End Source File + # Begin Source File + + SOURCE=..\..\include\cpputtools\configuration\validator.h + # End Source File + # Begin Source File + + SOURCE=..\..\include\cpputtools\configuration\value.h + # End Source File + # Begin Source File + + SOURCE=..\..\include\cpputtools\configuration\values.h + # End Source File + # End Group + # Begin Source File + + SOURCE=..\..\include\cpputtools\configuration.h + # End Source File + # Begin Source File + + SOURCE=..\..\include\cpputtools\convertor.h + # End Source File + # Begin Source File + + SOURCE=..\..\include\cpputtools\ctti.h + # End Source File + # Begin Source File + + SOURCE=..\..\include\cpputtools\value.h + # End Source File + # End Group + # Begin Group "stuffs" + + # PROP Default_Filter "" # Begin Source File *************** *** 249,252 **** --- 308,312 ---- SOURCE=..\..\include\cpput\typehelper.h # End Source File + # End Group # End Target # End Project Index: dllproxy.cpp =================================================================== RCS file: /cvsroot/cpptool/CppParser/src/cpput/dllproxy.cpp,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** dllproxy.cpp 8 Jun 2004 20:23:23 -0000 1.1.1.1 --- dllproxy.cpp 5 Aug 2004 20:52:46 -0000 1.2 *************** *** 155,159 **** DllProxy::doLoadLibrary( const std::string &libraryName ) { ! return ::dlopen( libraryName.c_str(), RTLD_NOW ); // RTLD_LAZY ? } --- 155,159 ---- DllProxy::doLoadLibrary( const std::string &libraryName ) { ! return ::dlopen( libraryName.c_str(), RTLD_NOW | RTLD_GLOBAL ); } Index: parametrizedsource.cpp =================================================================== RCS file: /cvsroot/cpptool/CppParser/src/cpput/parametrizedsource.cpp,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** parametrizedsource.cpp 8 Jun 2004 20:23:24 -0000 1.1.1.1 --- parametrizedsource.cpp 5 Aug 2004 20:52:46 -0000 1.2 *************** *** 1,4 **** ! # include <cpput/parametrizedsource.h> ! # include <cpput/test.h> namespace CppUT { --- 1,5 ---- ! #include <cpput/parametrizedsource.h> ! #include <cpput/test.h> ! #include <cpput/tablefixture.h> namespace CppUT { --- NEW FILE: tablefixture.cpp --- #include <cpput/tablefixture.h> namespace CppUT { // class TableRow // ////////////////////////////////////////////////////////////////// TableRow::TableRow( const Table &table, int rowIndex ) : table_( table ) , rowIndex_( rowIndex ) { } int TableRow::getCellIndex( const std::string &name ) { return table_.getColumnIndex( name ); } int TableRow::cellCount() { return table_.rowLength( rowIndex ); } bool TableRow::isCellEmpty( int index ) { return table_.isCellEmpty( rowIndex, index ); } int TableRow::cellAsInt( int index ) { return table_.cellAsInt( rowIndex, index ); } unsigned int TableRow::cellAsUnsignedInt( int index ) { return table_.cellAsUnsignedInt( rowIndex, index ); } char TableRow::cellAsChar( int index ) { return table_.cellAsChar( rowIndex, index ); } float TableRow::cellAsFloat( int index ) { return table_.cellAsFloat( rowIndex, index ); } double TableRow::cellAsDouble( int index ) { return table_.cellAsDouble( rowIndex, index ); } std::string TableRow::cellAsString( double index ) { return table_.cellAsInt( rowIndex, index ); } // class TableFixture // ////////////////////////////////////////////////////////////////// void TableFixture::bindAction( const std::string &actionName, ActionFn actionMethod ); void TableFixture::bindInput( const std::string &inputName, const CellBinderPtr &binder ) { binders_[inputName].binder_ = binder; } void TableFixture::bindInput( const std::string &inputName, CharInput input ) { bindInput( inputName, CellBinderPtr( new CommonCellBinder<char>( input, &TableRow::cellAsChar ) ) ); } void TableFixture::bindInput( const std::string &inputName, IntInput input ) { bindInput( inputName, CellBinderPtr( new CommonCellBinder<int>( input, &TableRow::cellAsInt ) ) ); } void TableFixture::bindInput( const std::string &inputName, UnsignedIntInput input ) { bindInput( inputName, CellBinderPtr( new CommonCellBinder<unsigned int>( input, &TableRow::cellAsUnsignedInt ) ) ); } void TableFixture::bindInput( const std::string &inputName, FloatInput input ) { bindInput( inputName, CellBinderPtr( new CommonCellBinder<float>( input, &TableRow::cellAsFloat ) ) ); } void TableFixture::bindInput( const std::string &inputName, DoubleInput input ) { bindInput( inputName, CellBinderPtr( new CommonCellBinder<double>( input, &TableRow::cellAsDouble ) ) ); } void TableFixture::bindInput( const std::string &inputName, StringInput input ) { bindInput( inputName, CellBinderPtr( new CommonCellBinder<std::string>( input, &TableRow::cellAsString ) ) ); } void TableFixture::beginProcessRow( const TableRow &row ) { Binders::const_iterator it = binders_.begin(); Binders::const_iterator itEnd = binders_.end(); for ( ; it != itEnd; ++it ) { const std::string &name = it->first; int cellIndex = row->getCellIndex( name ); CPPUT_ASSERT( cellIndex != TableRow::invalidRow, "Row contains no column named '" + name + "'." ); it->second->bind( *this, row, cellIndex ); } } void TableFixture::endProcessRow( const TableRow &row ) { } void TableFixture::processRow( const TableRow &row ) { } } // namespace CppUT Index: testfailureguard.cpp =================================================================== RCS file: /cvsroot/cpptool/CppParser/src/cpput/testfailureguard.cpp,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** testfailureguard.cpp 8 Jun 2004 20:23:24 -0000 1.1.1.1 --- testfailureguard.cpp 5 Aug 2004 20:52:46 -0000 1.2 *************** *** 1,12 **** #include <cpput/testfailureguard.h> ! #include <cpput/assertexception.h> #include <cpput/typehelper.h> namespace CppUT { ! // class TestFailureGuard // ////////////////////////////////////////////////////////////////// void ! TestFailureGuard::setNextInChain( const TestFailureGuardPtr &deleguate ) { deleguate_ = deleguate; --- 1,12 ---- #include <cpput/testfailureguard.h> ! #include <cpput/resultexception.h> #include <cpput/typehelper.h> namespace CppUT { ! // class TestExceptionGuard // ////////////////////////////////////////////////////////////////// void ! TestExceptionGuard::setNextInChain( const TestExceptionGuardPtr &deleguate ) { deleguate_ = deleguate; *************** *** 15,19 **** bool ! TestFailureGuard::callNextInChain( Context &context ) { return deleguate_->protect( context ); --- 15,19 ---- bool ! TestExceptionGuard::callNextInChain( Context &context ) { return deleguate_->protect( context ); *************** *** 23,33 **** namespace Impl { ! // class StandardTestFailureGuard // ////////////////////////////////////////////////////////////////// // catch CppUT::AssertionException, std::exception, ... ! class CPPUT_API StandardTestFailureGuard : public TestFailureGuard { ! public: // overridden from TestFailureGuard bool protect( Context &context ) { --- 23,33 ---- namespace Impl { ! // class StandardTestExceptionGuard // ////////////////////////////////////////////////////////////////// // catch CppUT::AssertionException, std::exception, ... ! class CPPUT_API StandardTestExceptionGuard : public TestExceptionGuard { ! public: // overridden from TestExceptionGuard bool protect( Context &context ) { *************** *** 36,50 **** return callNextInChain( context ); } ! catch ( const FailuresPropagationException &e ) ! { ! e.handleFailures( context.failureHandler_ ); ! } ! catch ( const FaultException &e ) { ! context.failureHandler_.handleFault( context.protectedTest_, e ); } ! catch ( const AssertException &e ) { ! context.failureHandler_.handleAssertion( context.protectedTest_, e ); } catch ( const std::exception &e ) --- 36,46 ---- return callNextInChain( context ); } ! catch ( const TestResultsPropagationException &e ) { ! e.handleFailures( context.exceptionHandler_ ); } ! catch ( const ResultException &e ) { ! context.exceptionHandler_.handleResultException( context.protectedTest_, e ); } catch ( const std::exception &e ) *************** *** 55,63 **** FaultException fault( message ); ! context.failureHandler_.handleFault( context.protectedTest_, fault ); } catch ( ... ) { Message message( "unexpected unknown exception caught" ); FaultException fault( message ); ! context.failureHandler_.handleFault( context.protectedTest_, fault ); } --- 51,59 ---- FaultException fault( message ); ! context.exceptionHandler_.handleResultException( context.protectedTest_, fault ); } catch ( ... ) { Message message( "unexpected unknown exception caught" ); FaultException fault( message ); ! context.exceptionHandler_.handleResultException( context.protectedTest_, fault ); } *************** *** 67,76 **** ! // class Impl::ExecutorTestFailureGuard // ////////////////////////////////////////////////////////////////// ! class ExecutorTestFailureGuard : public TestFailureGuard { ! public: // overridden from TestFailureGuard bool protect( Context &context ) { --- 63,72 ---- ! // class Impl::ExecutorTestExceptionGuard // ////////////////////////////////////////////////////////////////// ! class ExecutorTestExceptionGuard : public TestExceptionGuard { ! public: // overridden from TestExceptionGuard bool protect( Context &context ) { *************** *** 84,88 **** ! // class TestFailureGuardChain // ////////////////////////////////////////////////////////////////// --- 80,84 ---- ! // class TestExceptionGuardChain // ////////////////////////////////////////////////////////////////// *************** *** 93,100 **** // executor ! TestFailureGuardChain::TestFailureGuardChain() { ! guards_.push_back( TestFailureGuardPtr( new Impl::StandardTestFailureGuard() ) ); ! guards_.push_back( TestFailureGuardPtr( new Impl::ExecutorTestFailureGuard() ) ); connectChain(); } --- 89,96 ---- // executor ! TestExceptionGuardChain::TestExceptionGuardChain() { ! guards_.push_back( TestExceptionGuardPtr( new Impl::StandardTestExceptionGuard() ) ); ! guards_.push_back( TestExceptionGuardPtr( new Impl::ExecutorTestExceptionGuard() ) ); connectChain(); } *************** *** 102,106 **** void ! TestFailureGuardChain::appendGuard( const TestFailureGuardPtr &guard ) { guards_.insert( guards_.end()-1, guard ); --- 98,102 ---- void ! TestExceptionGuardChain::appendGuard( const TestExceptionGuardPtr &guard ) { guards_.insert( guards_.end()-1, guard ); *************** *** 110,114 **** void ! TestFailureGuardChain::removeGuard() { if ( guards_.size() <= 2 ) // should we throw an exception ? --- 106,110 ---- void ! TestExceptionGuardChain::removeGuard() { if ( guards_.size() <= 2 ) // should we throw an exception ? *************** *** 121,129 **** bool ! TestFailureGuardChain::protect( TestFailureHandler &failureHandler, Functor0 test, Test &protectedTest ) { ! TestFailureGuard::Context context( failureHandler, test, protectedTest ); return guards_.front()->protect( context ); } --- 117,125 ---- bool ! TestExceptionGuardChain::protect( TestExceptionHandler &exceptionHandler, Functor0 test, Test &protectedTest ) { ! TestExceptionGuard::Context context( exceptionHandler, test, protectedTest ); return guards_.front()->protect( context ); } *************** *** 131,135 **** void ! TestFailureGuardChain::connectChain() { unsigned int length = guards_.size(); --- 127,131 ---- void ! TestExceptionGuardChain::connectChain() { unsigned int length = guards_.size(); *************** *** 142,148 **** ! // class FailuresPropagationException // ////////////////////////////////////////////////////////////////// ! FailuresPropagationException::FailuresPropagationException() : std::exception( "propagating multiple test failures" ) { --- 138,144 ---- ! // class TestResultsPropagationException // ////////////////////////////////////////////////////////////////// ! TestResultsPropagationException::TestResultsPropagationException() : std::exception( "propagating multiple test failures" ) { *************** *** 151,188 **** void ! FailuresPropagationException::addAssertion( Test &failedTest, ! const AssertException &e ) ! { ! assertions_.push_back( AssertionData( failedTest, e ) ); ! } ! ! ! void ! FailuresPropagationException::addFault( Test &failedTest, ! const FaultException &e ) ! { ! faults_.push_back( FaultData( failedTest, e ) ); ! } ! ! bool ! FailuresPropagationException::hasFailures() const { ! return !assertions_.empty() || !faults_.empty(); } void ! FailuresPropagationException::handleFailures( TestFailureHandler &handler ) const { ! for ( unsigned int index = 0; index < assertions_.size(); ++index ) ! { ! const AssertionData &data = assertions_[index]; ! handler.handleAssertion( data.failedTest_, data.exception_ ); ! } ! ! for ( unsigned int index2 = 0; index2 < faults_.size(); ++index2 ) { ! const FaultData &data = faults_[index2]; ! handler.handleFault( data.failedTest_, data.exception_ ); } } --- 147,164 ---- void ! TestResultsPropagationException::addResult( Test &test, ! const ResultException &e ) { ! results_.push_back( ResultData( test, e ) ); } void ! TestResultsPropagationException::handleFailures( TestExceptionHandler &handler ) const { ! for ( unsigned int index = 0; index < results_.size(); ++index ) { ! const ResultData &data = results_[index]; ! handler.handleResultException( data.test_, data.exception_ ); } } Index: assert.cpp =================================================================== RCS file: /cvsroot/cpptool/CppParser/src/cpput/assert.cpp,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** assert.cpp 8 Jun 2004 20:23:23 -0000 1.1.1.1 --- assert.cpp 5 Aug 2004 20:52:46 -0000 1.2 *************** *** 1,4 **** # include <cpput/assert.h> ! # include <cpput/assertexception.h> # include <cpput/location.h> # include <cpput/message.h> --- 1,4 ---- # include <cpput/assert.h> ! # include <cpput/resultexception.h> # include <cpput/location.h> # include <cpput/message.h> *************** *** 32,35 **** --- 32,41 ---- } + void + succeed( const Message &message ) + { + throw SuccessException( message, getCheckPointLocation() ); + } + void |
From: Baptiste L. <bl...@us...> - 2004-08-05 20:52:58
|
Update of /cvsroot/cpptool/CppParser/include/cpputtools/configuration In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv20897/include/cpputtools/configuration Added Files: description.h errors.h forwards.h parser.h simplertti.h validator.h value.h values.h Log Message: * upgraded to current cppunit 2 cvs --- NEW FILE: value.h --- #ifndef CPPUTTOOLS_CONFIGURATION_VALUE_H_INCUDED # define CPPUTTOOLS_CONFIGURATION_VALUE_H_INCUDED # include "simplertti.h" # include "validator.h" # include <cpputtools/value.h> namespace CppUTTools { namespace CommandLineOptions { class OptionHandler { public: virtual ~OptionHandler() {} virtual Value validate( const Parameters ¶meters ) const = 0; }; template<class TheOptionType> class SimpleOptionHandler : public OptionHandler { public: typedef TheOptionType OptionType; SimpleOptionHandler(); SimpleOptionHandler( Validator *validator ); SimpleOptionHandler( Validator *validator, OptionType *storage ); ~SimpleOptionHandler(); public: // overridden from OptionHandler Value validate( const Parameters ¶meters ) const; private: Validator *validator_; }; // template class SimpleOptionHandler // ////////////////////////////////////////////////////////////////// template<class TheOptionType> SimpleOptionHandler<TheOptionType>::SimpleOptionHandler() : storage_( 0 ) , validator_( new StringStreamValidator<TheOptionType>() ) { } template<class TheOptionType> SimpleOptionHandler<TheOptionType>::SimpleOptionHandler( OptionType *storage ) : storage_( storage ) , validator_( new StringStreamValidator<TheOptionType>() ) { } template<class TheOptionType> SimpleOptionHandler<TheOptionType>::SimpleOptionHandler( Validator *validator ) : storage_( 0 ) , validator_( validator ) { } template<class TheOptionType> SimpleOptionHandler<TheOptionType>::SimpleOptionHandler( Validator *validator, OptionType *storage ) : storage_( storage ) , validator_( validator ) { } template<class TheOptionType> SimpleOptionHandler<TheOptionType>::~SimpleOptionHandler() { delete validator_; } template<class TheOptionType> bool SimpleOptionHandler<TheOptionType>::hasStorage() const { return storage_ != 0; } template<class TheOptionType> void SimpleOptionHandler<TheOptionType>::storeValue( const Value &value ) const { if ( hasStorage() ) *storage_ = get<TheOptionType>( value ); } template<class TheOptionType> Value SimpleOptionHandler<TheOptionType>::validate( const Parameters ¶meters ) const { return validator_->validate( parameters ); } } } // namespace CommandLineOptions #endif // CPPUTTOOLS_CONFIGURATION_VALUE_H_INCUDED --- NEW FILE: validator.h --- #ifndef CPPUTTOOLS_CONFIGURATION_VALIDATOR_H_INCUDED # define CPPUTTOOLS_CONFIGURATION_VALIDATOR_H_INCUDED # include "errors.h" # include <cpputtools/value.h> // <cpputtools/forwards.h> namespace CppUTTools { namespace CommandLineOptions { class Validator : public ReferenceCountedPolicy { public: virtual ~Validator() {} virtual Value validate( const Parameters ¶meters ) const = 0; }; template<class OptionType> class StringStreamValidator : public Validator { public: // overridden from Validator Value validate( const Parameters ¶meters ) const; }; template<class OptionType> ValidatorPtr defaultValidator(); template<class OptionType> class EnumerationValidator : public Validator { public: void add( const String &text, const OptionType &value, const String &help = "" ); std::deque<String> inputs() const; String inputHelp( const String &text ) const; ValidatorPtr clone() const; public: // overridden from Validator Value validate( const Parameters ¶meters ) const; private: struct ValueData { OptionType value_; String help_; }; typedef std::map<String,ValueData> Values; Values values_; std::deque<String> inputs_; }; template<class Functor> ValidatorPtr makeValidator( Functor functor ); template<class OptionType> std::string validatorAdditionalMessage(); #undef COMMANDLINEOPTIONS_VALIDATOR_MESSAGE #define COMMANDLINEOPTIONS_VALIDATOR_MESSAGE( OptionType, message ) \ template<> \ inline std::string validatorAdditionalMessage<OptionType>() \ { \ return message; \ } COMMANDLINEOPTIONS_VALIDATOR_MESSAGE( int, "is not an integer." ); COMMANDLINEOPTIONS_VALIDATOR_MESSAGE( unsigned int, "is not an integer." ); COMMANDLINEOPTIONS_VALIDATOR_MESSAGE( short, "is not an integer." ); COMMANDLINEOPTIONS_VALIDATOR_MESSAGE( unsigned short, "is not an integer." ); COMMANDLINEOPTIONS_VALIDATOR_MESSAGE( long, "is not an integer." ); COMMANDLINEOPTIONS_VALIDATOR_MESSAGE( unsigned long, "is not an integer." ); COMMANDLINEOPTIONS_VALIDATOR_MESSAGE( float, "is not a real number." ); COMMANDLINEOPTIONS_VALIDATOR_MESSAGE( double, "is not a real number." ); COMMANDLINEOPTIONS_VALIDATOR_MESSAGE( long double, "is not a real number." ); COMMANDLINEOPTIONS_VALIDATOR_MESSAGE( char, "is not a character." ); COMMANDLINEOPTIONS_VALIDATOR_MESSAGE( std::string, "is not a string." ); //COMMANDLINEOPTIONS_VALIDATOR_MESSAGE( wchar_t, "is not a character." ); // Template StringStreamValidator // ////////////////////////////////////////////////////////////////// template<class OptionType> Value StringStreamValidator<OptionType>::validate( const Parameters ¶meters ) const { IStringStream is( parameters.at(0) ); OptionType optionValue; is >> optionValue; is >> std::ws; if ( !is.eof() ) // input not completly consumed { std::ostringstream os; os << "parameter '" << parameters.at(0) << "', "; os << validatorAdditionalMessage<OptionType>(); throw ValidatorError( ValidatorError::badParameterValue, os.str() ); } return value( optionValue ); } template<class OptionType> ValidatorPtr defaultValidator() { return ValidatorPtr( new StringStreamValidator<OptionType>() ); } // Template EnumerationValidator // ////////////////////////////////////////////////////////////////// template<class OptionType> ValidatorPtr EnumerationValidator<OptionType>::clone() const { return ValidatorPtr( new EnumerationValidator<OptionType>( *this ) ); } template<class OptionType> void EnumerationValidator<OptionType>::add( const String &text, const OptionType &value, const String &help ) { ValueData data; data.value_ = value; data.help_ = help; values_.insert( Values::value_type( text, data ) ); inputs_.push_back( text ); } template<class OptionType> std::deque<String> EnumerationValidator<OptionType>::inputs() const { return inputs_; } template<class OptionType> String EnumerationValidator<OptionType>::inputHelp( const String &text ) const { Values::const_iterator it = values_.find( text ); if ( it == values_.end() ) return ""; return it->second.help_; } template<class OptionType> Value EnumerationValidator<OptionType>::validate( const Parameters ¶meters ) const { String text = parameters.at(0); Values::const_iterator it = values_.find( text ); if ( it == values_.end() ) throw ValidatorError( ValidatorError::badParameterValue, "value must be..." ); return value( it->second.value_ ); } // Function makeValidator // ////////////////////////////////////////////////////////////////// template<class Functor> class ValidatorImpl : public Validator { public: ValidatorImpl( Functor functor ) : functor_( functor ) { } // overridden from Validator Value validate( const Parameters ¶meters ) const { return functor_( parameters ); } private: Functor functor_; }; template<class Functor> ValidatorPtr validator( Functor functor ) { return ValidatorPtr( new ValidatorImpl<Functor>( functor ) ); } } } // namespace CommandLineOptions #endif // CPPUTTOOLS_CONFIGURATION_VALIDATOR_H_INCUDED --- NEW FILE: description.h --- #ifndef CPPUTTOOLS_CONFIGURATION_DESCRIPTION_H_INCUDED # define CPPUTTOOLS_CONFIGURATION_DESCRIPTION_H_INCUDED # include "forwards.h" # include "errors.h" # include "validator.h" # include <cpputtools/valuebinder.h> # include <iostream> # include <map> # include <set> namespace CppUTTools { namespace CommandLineOptions { class OptionDescription // not copyable { public: enum ParameterRequirement { noParameter, // | optionalParameter, // ? requiredParameter, // : oneOrMoreParameter, // + zeroOrMoreParameter // * }; OptionDescription( const Char &shortName, const String &longName, const String &description, const ValidatorPtr &validator ); // @param packedName Has the following format: "longName,shortName". // ShortName must be a single letter. Example: "exclude,x" // Will match --exclude or -x on the command line. OptionDescription( const String &packedName, const String &description, const ValidatorPtr &validator ); ~OptionDescription(); OptionDescription &setValidator( const ValidatorPtr &validator ); // Switch parameter requirement as follow: // * if value is empty: // optionalParameter -> requiredParameter // * if value is not empty: // noParameter, requiredParameter -> optionalParameter // oneOrMoreParameter -> zeroOrMoreParameter OptionDescription &setDefaultValue( const Value &value ); OptionDescription &setStorage( const ValueBinder &storage ); const Value &defaultValue() const; bool hasDefaultValue() const; bool hasStorage() const; bool hasShortName() const; bool hasLongName() const; String shortName() const; String longName() const; String name() const; String description() const; bool hasNoParameter() const; bool mayHaveParameter() const; bool requireParameter() const; // @exception ValidatorError if validation fail. Value validate( const Parameters ¶meters ) const; // Store the final value into the location specified by the user if any. void store( const Value &value ) const; private: void setDefaultParameterRequirement(); Value defaultValue_; String shortName_; String longName_; ValueBinder storage_; String description_; ParameterRequirement parameter_; ValidatorPtr validator_; }; class OptionsDescription { public: OptionsDescription( const String &caption ); virtual ~OptionsDescription(); /// @exception OptionsDescriptionError if an option has already been registered with conflicting /// names. OptionsDescription &add( const OptionDescription &description ); /// @exception OptionsDescriptionError if an option has already been registered with conflicting /// names. OptionsDescription &add( const String &optionName, const String &description ); #if 0 /// @exception OptionsDescriptionError if an option has already been registered with conflicting /// names. OptionsDescription &add( const String &optionName, const OptionHandlerHelper &handlerHelper, const String &description ); /// @exception OptionsDescriptionError if an option has already been registered with conflicting /// names. OptionsDescription &add( const String &optionName, const OptionHandlerHelper &handlerHelper, Validator *validator, const String &description ); /// @exception OptionsDescriptionError if an option has already been registered with conflicting /// names. OptionsDescription &add( const String &optionName, Validator *validator, const String &description ); /// @exception OptionsDescriptionError if an option has already been registered with conflicting /// names. OptionsDescription &add( const String &optionName, OptionHandler *handler, const String &description ); /// @exception OptionsDescriptionError if an option has already been registered with conflicting /// names. OptionsDescription &add( const String &optionName, OptionHandler *handler, Validator *validator, const String &description ); #endif std::set<String> optionNames() const; bool hasOption( const String &optionName ) const; // long name or -shortName const OptionDescription &description( const String &optionName ) const; friend std::ostream &operator <<( std::ostream &os, const OptionsDescription &options ); private: typedef std::deque<OptionDescription> Options; Options options_; String caption_; typedef std::map<String,int> OptionIndexes; OptionIndexes shortNameIndexes_; OptionIndexes longNameIndexes_; OptionIndexes nameIndexes_; }; template<class ValueType> OptionDescription option( const std::string &optionName, const std::string &description ); template<class DefaultValueType> OptionDescription optionDefault( const std::string &optionName, const DefaultValueType &defaultValue, const std::string &description ); template<class StorageValueType> OptionDescription option( const std::string &optionName, StorageValueType &storageValue, const std::string &description ); template<class StorageValueType ,class DefaultValueType> OptionDescription option( const std::string &optionName, StorageValueType &storageValue, const DefaultValueType &defaultValue, const std::string &description ); template<class ValueType> OptionDescription validatedOption( const std::string &optionName, const std::string &description, const ValidatorPtr &validator ); template<class DefaultValueType> OptionDescription validatedOptionDefault( const std::string &optionName, const DefaultValueType &defaultValue, const std::string &description, const ValidatorPtr &validator ); template<class StorageValueType> OptionDescription validatedOption( const std::string &optionName, StorageValueType &storageValue, const std::string &description, const ValidatorPtr &validator ); template<class StorageValueType ,class DefaultValueType> OptionDescription validatedOption( const std::string &optionName, StorageValueType &storageValue, const DefaultValueType &defaultValue, const std::string &description, const ValidatorPtr &validator ); // class OptionDescription // ////////////////////////////////////////////////////////////////// inline OptionDescription::OptionDescription( const String &packedName, const String &description, const ValidatorPtr &validator ) : description_( description ) , validator_( validator ) { unsigned int commaPos = packedName.find( ',' ); String parameter( "|?:+*" ); String cleanPackedName = packedName; Char parameterRequirement = cleanPackedName.at( cleanPackedName.length()-1 ); int pos = parameter.find( parameterRequirement ); if ( pos != String::npos ) { static ParameterRequirement parameters[] = { noParameter, optionalParameter, requiredParameter, oneOrMoreParameter, zeroOrMoreParameter }; parameter_ = parameters[pos]; cleanPackedName.resize( cleanPackedName.length()-1 ); } else setDefaultParameterRequirement(); if ( commaPos != String::npos ) { longName_ = cleanPackedName.substr(0,commaPos); shortName_ = cleanPackedName.substr(commaPos+1,1); } else longName_ = cleanPackedName; } inline OptionDescription::OptionDescription( const Char &shortName, const String &longName, const String &description, const ValidatorPtr &validator ) : shortName_( String(1,shortName) ) , longName_( longName ) , description_( description ) , validator_( validator ) { setDefaultParameterRequirement(); } inline void OptionDescription::setDefaultParameterRequirement() { if ( hasStorage() || hasDefaultValue() ) parameter_ = hasDefaultValue() ? optionalParameter : requiredParameter; else parameter_ = noParameter; } inline OptionDescription::~OptionDescription() { } inline OptionDescription & OptionDescription::setValidator( const ValidatorPtr &validator ) { validator_ = validator; return *this; } inline OptionDescription & OptionDescription::setDefaultValue( const Value &value ) { defaultValue_ = value; if ( value.isEmpty() ) { if ( parameter_ == optionalParameter ) parameter_ = requiredParameter; } else { if ( parameter_ == noParameter || parameter_ == requiredParameter ) parameter_ = optionalParameter; else if ( parameter_ == oneOrMoreParameter ) parameter_ = zeroOrMoreParameter; } return *this; } inline OptionDescription & OptionDescription::setStorage( const ValueBinder &storage ) { storage_ = storage; return *this; } inline const Value & OptionDescription::defaultValue() const { return defaultValue_; } inline bool OptionDescription::hasDefaultValue() const { return !defaultValue_.isEmpty(); } inline bool OptionDescription::hasStorage() const { return !storage_.isEmpty(); } inline bool OptionDescription::hasShortName() const { return !shortName_.empty(); } inline bool OptionDescription::hasLongName() const { return !longName_.empty(); } inline String OptionDescription::shortName() const { return shortName_; } inline String OptionDescription::longName() const { return longName_; } inline String OptionDescription::name() const { return longName_.empty() ? "-" + shortName() : longName_; } inline String OptionDescription::description() const { return description_; } inline bool OptionDescription::hasNoParameter() const { return parameter_ == noParameter; } inline bool OptionDescription::mayHaveParameter() const { return parameter_ == optionalParameter || parameter_ == zeroOrMoreParameter; } inline bool OptionDescription::requireParameter() const { return parameter_ == requiredParameter || parameter_ == oneOrMoreParameter; } inline Value OptionDescription::validate( const Parameters ¶meters ) const { if ( requireParameter() && parameters.empty() ) throw ValidatorError( ValidatorError::missingParameter, "required parameter is missing." ); if ( requireParameter() || ( mayHaveParameter() && !parameters.empty() ) ) { if ( !validator_ ) throw ValidatorError( ValidatorError::undefinedValidator, "no validator set for this option." ); return validator_->validate( parameters ); } return defaultValue(); } inline void OptionDescription::store( const Value &value ) const { if ( hasStorage() ) storage_.set( value ); } // class OptionsDescription // ////////////////////////////////////////////////////////////////// inline OptionsDescription::OptionsDescription( const String &caption ) : caption_( caption ) { } inline OptionsDescription::~OptionsDescription() { } inline OptionsDescription & OptionsDescription::add( const OptionDescription &description ) { int index = options_.size(); options_.push_back( description ); if ( longNameIndexes_.count( description.longName() ) > 0 ) throw OptionsDescriptionError( "More than one option registered with long name '" + description.longName() + "'." ); if ( shortNameIndexes_.count( description.shortName() ) > 0 ) throw OptionsDescriptionError( "More than one option registered with short name '" + description.shortName() + "'." ); if ( description.hasLongName() ) { longNameIndexes_.insert( OptionIndexes::value_type( description.longName(), index ) ); nameIndexes_.insert( OptionIndexes::value_type( description.longName(), index ) ); } if ( description.hasShortName() ) { shortNameIndexes_.insert( OptionIndexes::value_type( description.shortName(), index ) ); nameIndexes_.insert( OptionIndexes::value_type( "-" + description.shortName(), index ) ); } return *this; } inline OptionsDescription & OptionsDescription::add( const String &optionName, const String &description ) { return add( option<std::string>( optionName, description ) ); } inline std::set<String> OptionsDescription::optionNames() const { std::set<String> optionNames; Options::const_iterator it = options_.begin(); for ( ; it != options_.end(); ++it ) { const OptionDescription &option = *it; optionNames.insert( option.name() ); } return optionNames; } inline bool OptionsDescription::hasOption( const String &optionName ) const { return nameIndexes_.count( optionName) > 0; } inline const OptionDescription & OptionsDescription::description( const String &optionName ) const { OptionIndexes::const_iterator it = nameIndexes_.find( optionName ); if ( it == nameIndexes_.end() ) { std::ostringstream os; os << "No option registered for name '" + optionName + "'."; throw OptionsDescriptionError( os.str() ); } return options_[it->second]; } // template function option // ////////////////////////////////////////////////////////////////// template<class ValueType> OptionDescription option( const std::string &optionName, const std::string &description ) { return OptionDescription( optionName, description, defaultValidator<ValueType>() ); } template<class DefaultValueType> OptionDescription optionDefault( const std::string &optionName, const DefaultValueType &defaultValue, const std::string &description ) { Value value; set( value, defaultValue ); OptionDescription option( optionName, description, defaultValidator<DefaultValueType>() ); return option.setDefaultValue( value ); } template<class StorageValueType> OptionDescription option( const std::string &optionName, StorageValueType &storageValue, const std::string &description ) { OptionDescription option( optionName, description, defaultValidator<StorageValueType>() ); return option.setStorage( valueBinder( storageValue ) ); } template<class StorageValueType ,class DefaultValueType> OptionDescription option( const std::string &optionName, StorageValueType &storageValue, const DefaultValueType &defaultValue, const std::string &description ) { Value value; set( value, StorageValueType( defaultValue ) ); OptionDescription option( optionName, description, defaultValidator<StorageValueType>() ); option.setDefaultValue( value ); return option.setStorage( valueBinder( storageValue ) ); } template<class ValueType> OptionDescription validatedOption( const std::string &optionName, const std::string &description, const ValidatorPtr &validator ) { return OptionDescription( optionName, description, validator ); } template<class DefaultValueType> OptionDescription validatedOptionDefault( const std::string &optionName, const DefaultValueType &defaultValue, const std::string &description, const ValidatorPtr &validator ) { Value value; set( value, defaultValue ); OptionDescription option( optionName, description, validator ); return option.setDefaultValue( value ); } template<class StorageValueType> OptionDescription validatedOption( const std::string &optionName, StorageValueType &storageValue, const std::string &description, const ValidatorPtr &validator ) { OptionDescription option( optionName, description, validator ); return option.setStorage( valueBinder( storageValue ) ); } template<class StorageValueType ,class DefaultValueType> OptionDescription validatedOption( const std::string &optionName, StorageValueType &storageValue, const DefaultValueType &defaultValue, const std::string &description, const ValidatorPtr &validator ) { Value value; set( value, StorageValueType( defaultValue ) ); OptionDescription option( optionName, description, validator ); option.setDefaultValue( value ); return option.setStorage( valueBinder( storageValue ) ); } } } // namespace CommandLineOptions #endif // CPPUTTOOLS_CONFIGURATION_DESCRIPTION_H_INCUDED --- NEW FILE: values.h --- #ifndef CPPUTTOOLS_CONFIGURATION_VALUES_H_INCUDED # define CPPUTTOOLS_CONFIGURATION_VALUES_H_INCUDED # include "description.h" namespace CppUTTools { namespace CommandLineOptions { class OptionsValues { public: virtual ~OptionsValues(); const Value &operator[]( const String &name ) const; Value &operator[]( const String &name ); const Value &optionValue( const String &name ) const; Value &optionValue( const String &name ); bool hasOption( const String &name ) const; void setOption( const String &optionKey ); void setOptionAlias( const String &alias, const String &optionKey ); const String &optionName( const String &name ) const; Parameters optionParameters( const String &name ) const; void addOptionParameter( const String &optionKey, const String ¶meter ); void validate( const OptionsDescription &description ); void store( const OptionsDescription &description ); private: typedef std::map<String,Value> Values; Values values_; typedef std::map< String, std::deque<String> > OptionParameters; OptionParameters parameters_; typedef std::map<String, String> NameByAliases; NameByAliases nameByAliases_; }; // class OptionValues // /////////////////////////////////////////////////////////////////// inline OptionsValues::~OptionsValues() { } inline const Value & OptionsValues::operator[]( const String &name ) const { return optionValue( name ); } inline Value & OptionsValues::operator[]( const String &name ) { return optionValue( name ); } inline const Value & OptionsValues::optionValue( const String &name ) const { Values::const_iterator it = values_.find( optionName(name) ); if ( it == values_.end() ) throw std::invalid_argument( "No option named: " + name ); return it->second; } inline Value & OptionsValues::optionValue( const String &name ) { Values::iterator it = values_.find( optionName(name) ); if ( it == values_.end() ) throw std::invalid_argument( "No option named: " + name ); return it->second; } inline bool OptionsValues::hasOption( const String &name ) const { return parameters_.count( optionName(name) ) > 0; } inline void OptionsValues::setOption( const String &optionKey ) { parameters_[ optionKey ]; } inline void OptionsValues::setOptionAlias( const String &alias, const String &optionKey ) { nameByAliases_.insert( NameByAliases::value_type( alias, optionKey ) ); } inline const std::string & OptionsValues::optionName( const String &name ) const { NameByAliases::const_iterator it = nameByAliases_.find( name ); if ( it == nameByAliases_.end() ) throw std::invalid_argument( "OptionsValues::optionName: " + name + " is not an option." ); return it->second; } inline Parameters OptionsValues::optionParameters( const String &name ) const { OptionParameters::const_iterator it = parameters_.find( optionName(name) ); if ( it == parameters_.end() ) return Parameters(); return it->second; } inline void OptionsValues::addOptionParameter( const String &optionKey, const String ¶meter ) { parameters_[ optionKey ].push_back( parameter ); } inline void OptionsValues::validate( const OptionsDescription &description ) { OptionParameters::iterator it = parameters_.begin(); for ( ; it != parameters_.end(); ++it ) { const String &name = it->first; const OptionDescription &option = description.description( name ); try { /// @todo real parameters stuff for sequence support const Parameters ¶meters = it->second; Value value = option.validate( parameters ); values_[name] = value; } catch ( ValidatorError &e ) { e.setOptionName( name ); throw; } } } inline void OptionsValues::store( const OptionsDescription &description ) { Values::iterator it = values_.begin(); for ( ; it != values_.end(); ++it ) { const String &name = it->first; const OptionDescription &option = description.description( name ); const Value &value = it->second; option.store( value ); } } } } // namespace CommandLineOptions #endif // CPPUTTOOLS_CONFIGURATION_VALUES_H_INCUDED --- NEW FILE: errors.h --- #ifndef CPPUTTOOLS_CONFIGURATION_ERRORS_H_INCUDED # define CPPUTTOOLS_CONFIGURATION_ERRORS_H_INCUDED # include "forwards.h" # include <sstream> # include <stdexcept> namespace CppUTTools { namespace CommandLineOptions { class OptionError : public std::runtime_error { public: OptionError( const std::string &message ) : std::runtime_error( message ) { } }; class ValidatorError : public std::runtime_error { public: typedef std::runtime_error SuperClass; enum Cause { missingParameter = 1, badParameterValue, undefinedValidator }; ValidatorError( Cause cause, const std::string &message ) : std::runtime_error( message ) , cause_( cause ) { } void setOptionName( const String &name ) { name_ = name; } String optionName() const { return name_; } Cause cause() const { return cause_; } const char *what() const throw() { std::ostringstream os; os << "In option '"; if ( name_[0] != '-' ) os << "--"; os << name_ << "':" << SuperClass::what(); message_ = os.str(); return message_.c_str(); } private: std::string name_; mutable std::string message_; Cause cause_; }; class OptionsDescriptionError : public std::runtime_error { public: OptionsDescriptionError( const std::string &message ) : std::runtime_error( message ) { } }; class BadCastOptionError : public OptionError { public: BadCastOptionError( const std::string &message ) : OptionError( message ) { } }; class CommandLineParseError : public std::runtime_error { public: enum Cause { invalidOptionName = 1, syntaxError }; CommandLineParseError( Cause cause, const String &optionName ); Cause cause() const; String optionName() const; const char *what() const throw(); private: String optionName_; Cause cause_; mutable std::string message_; }; // class CommandLineParseError // ////////////////////////////////////////////////////////////////// inline CommandLineParseError::CommandLineParseError( Cause cause, const String &optionName ) : cause_( cause ) , optionName_( optionName ) , std::runtime_error( "CommandLineParseError" ) { } inline CommandLineParseError::Cause CommandLineParseError::cause() const { return cause_; } inline String CommandLineParseError::optionName() const { return optionName_; } inline const char * CommandLineParseError::what() const throw() { if ( message_.empty() ) { std::ostringstream os; switch ( cause_ ) { case invalidOptionName: os << "Invalid option name: "; break; case syntaxError: os << "Syntax error: "; break; } if ( !optionName_.empty() ) os << optionName_; message_ = os.str(); } return message_.c_str(); } } } // namespace CommandLineOptions #endif // CPPUTTOOLS_CONFIGURATION_ERRORS_H_INCUDED --- NEW FILE: simplertti.h --- #ifndef CPPUTTOOLS_CONFIGURATION_SIMPLERTTI_H_INCUDED # define CPPUTTOOLS_CONFIGURATION_SIMPLERTTI_H_INCUDED # include "errors.h" # include <typeinfo> namespace CppUTTools { namespace CommandLineOptions { typedef const std::type_info *OptionTypeId; template<class TheType> struct Type {}; template<class OptionType> OptionTypeId optionTypeId( Type<OptionType> ); void checkBadCast( const OptionTypeId &type1, const OptionTypeId &type2 ); // RTTI functions // ////////////////////////////////////////////////////////////////// template<class OptionType> OptionTypeId optionTypeId( Type<OptionType> ) { return &typeid( OptionType ); } inline void checkBadCast( const OptionTypeId &type1, const OptionTypeId &type2 ) { if ( *type1 != *type2 ) throw BadCastOptionError( "Incorrect get or set call on option value." ); } } } // namespace CommandLineOptions #endif // CPPUTTOOLS_CONFIGURATION_SIMPLERTTI_H_INCUDED --- NEW FILE: forwards.h --- #ifndef CPPUTTOOLS_CONFIGURATION_FORWARDS_H_INCUDED # define CPPUTTOOLS_CONFIGURATION_FORWARDS_H_INCUDED # include <cpput/config.h> // to be moved partially in cpputtools # include <cpputtools/refcountptr.h> # include <deque> # include <sstream> # include <string> namespace CppUTTools { namespace CommandLineOptions { typedef char Char; typedef std::string String; typedef std::deque<String> StringList; typedef std::istringstream IStringStream; class CommandLineParseError; class CommandLineParser; class OptionDescription; class OptionsDescription; class OptionsDescriptionError; class OptionError; class OptionHandler; class OptionHandlerHelper; template<class TheOptionType> class OptionValueStorage; class OptionsValues; template<class TheOptionType> class SimpleOptionHandler; class Validator; typedef RefCountPtr<Validator> ValidatorPtr; typedef ReferenceCountedNoThread ReferenceCountedPolicy; class ValidatorError; typedef std::deque<String> Parameters; } } // namespace CommandLineOptions #endif // CPPUTTOOLS_CONFIGURATION_FORWARDS_H_INCUDED --- NEW FILE: parser.h --- #ifndef CPPUTTOOLS_CONFIGURATION_PARSER_H_INCUDED # define CPPUTTOOLS_CONFIGURATION_PARSER_H_INCUDED # include "values.h" # include <algorithm> # include <iterator> # include <vector> namespace CppUTTools { namespace CommandLineOptions { bool parseCommandLine( int argc, const Char *argv[], const OptionsDescription &description, OptionsValues &values ); class CommandLineParser { public: enum ParseState { parseNewOption = 1, nextParameter }; enum OptionStyle { noOptionStyle = 0, shortOption, longOption }; CommandLineParser( const std::vector<String> &arguments, const OptionsDescription &description ) : arguments_( arguments ) , parseState_( parseNewOption ) , tokenIndex_( 0 ) , description_( description ) , currentOption_( 0 ) { } // @exception CommandLineParseError if invalid option name OptionsValues parse(); void processToken(); String currentToken() const; void consumeToken(); bool hasMoreToken() const; OptionStyle optionStyle( const std::string &token ) const; // @exception CommandLineParseError if invalid option name void checkOptionNameIsValid( const std::string &optionName, const std::string &optionToken ) const; private: void setOptionAliases(); typedef std::vector<String> Arguments; Arguments arguments_; OptionsValues values_; const OptionsDescription &description_; ParseState parseState_; int tokenIndex_; const OptionDescription *currentOption_; }; // Function parseCommandLine // ////////////////////////////////////////////////////////////////// inline bool parseCommandLine( int argc, const Char *argv[], const OptionsDescription &description, OptionsValues &values ) { std::vector<String> args; if ( argc > 0 ) std::copy( argv+1, argv+argc, std::back_inserter( args ) ); CommandLineParser parser( args, description ); values = parser.parse(); return true; } // class CommandLineParser // ////////////////////////////////////////////////////////////////// inline OptionsValues CommandLineParser::parse() { setOptionAliases(); while ( hasMoreToken() ) processToken(); return values_; } inline void CommandLineParser::processToken() { String token = currentToken(); switch ( parseState_ ) { case parseNewOption: { switch ( optionStyle( token ) ) { case shortOption: { String name = token.substr(1,1); String shortOptionKey = "-" + name; checkOptionNameIsValid( shortOptionKey, token ); consumeToken(); const OptionDescription &option = description_.description( shortOptionKey ); values_.setOption( option.name() ); if ( option.hasNoParameter() ) break; // if ( option.mayHaveParameter() // && optionStyle( currentToken() ) != noOption ) // break; std::string parameter = token.substr(2); if ( !parameter.empty() ) values_.addOptionParameter( option.name(), parameter ); else { parseState_ = nextParameter; currentOption_ = &option; } // if ( parameter.empty() && option.hasDefaultValue() ) // option.applyDefaultValue( values_[ optionKey ] ); } break; case longOption: { String name = token.substr(2); String parameter; int equalPos = name.find( '=' ); if ( equalPos != String::npos ) { parameter = name.substr( equalPos + 1 ); name = name.substr(0,equalPos); } checkOptionNameIsValid( name, token ); values_.setOption( name ); consumeToken(); const OptionDescription &option = description_.description( name ); if ( option.hasNoParameter() ) break; if ( equalPos != String::npos ) values_.addOptionParameter( name, parameter ); else { parseState_ = nextParameter; currentOption_ = &option; } } break; default: throw CommandLineParseError( CommandLineParseError::syntaxError, token ); break; } } break; case nextParameter: { if ( optionStyle( token ) == noOptionStyle ) { values_.addOptionParameter( currentOption_->name(), token ); consumeToken(); } parseState_ = parseNewOption; } break; default: throw CommandLineParseError( CommandLineParseError::syntaxError, token ); } } inline void CommandLineParser::checkOptionNameIsValid( const std::string &optionName, const std::string &optionToken ) const { if ( !description_.hasOption( optionName ) ) throw CommandLineParseError( CommandLineParseError::invalidOptionName, optionToken ); } inline std::string CommandLineParser::currentToken() const { return tokenIndex_ < arguments_.size() ? arguments_[tokenIndex_] : std::string(); } inline void CommandLineParser::consumeToken() { ++tokenIndex_; } inline bool CommandLineParser::hasMoreToken() const { return tokenIndex_ < arguments_.size(); } inline CommandLineParser::OptionStyle CommandLineParser::optionStyle( const std::string &token ) const { if ( token.substr(0,2) == "--" && token.length() > 2 ) return longOption; if ( token.substr(0,1) == "-" && token.length() > 1 ) return shortOption; return noOptionStyle; } inline void CommandLineParser::setOptionAliases() { std::set<String> optionNames = description_.optionNames(); std::set<String>::iterator it = optionNames.begin(); for ( ; it != optionNames.end(); ++it ) { const OptionDescription &description = description_.description( *it ); String optionKey = description.name(); values_.setOptionAlias( optionKey, optionKey ); if ( description.hasLongName() && description.hasShortName() ) values_.setOptionAlias( "-" + description.shortName(), optionKey ); } } } } // namespace CommandLineOptions #endif // CPPUTTOOLS_CONFIGURATION_PARSER_H_INCUDED |
Update of /cvsroot/cpptool/CppParser/include/cpput In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv20897/include/cpput Modified Files: assert.h config.h enumerator.h forwards.h message.h properties.h test.h testcontext.h testfailureguard.h testlistener.h Added Files: progresslistener.h resource.h resultexception.h tablefixture.h testresult.h testrunresult.h Removed Files: assertexception.h result.h testfailure.h Log Message: * upgraded to current cppunit 2 cvs --- result.h DELETED --- --- NEW FILE: progresslistener.h --- #ifndef CPPUT_PROGRESSLISTENER_H_INCLUDED # define CPPUT_PROGRESSLISTENER_H_INCLUDED # include <cpput/test.h> # include <cpput/testlistener.h> # include <cpput/testresult.h> # include <iostream> namespace CppUT { class CPPUT_API BriefProgressListener : public TestListener { public: // overridden from CppUT::TestListener void processTestResult( CppUT::TestResult &result, CppUT::TestContext &context ) { if ( result.failed() ) { if ( result.isAssertionFailure() ) resultType_ = "ASSERTION"; else if ( result.isFaultFailure() ) resultType_ = "FAULT"; else // user custom failure resultType_ = "FAILURE"; } } void enterTest( CppUT::Test &test, CppUT::TestContext &context ) { resultType_ = "OK"; std::cout << "Testing '" << path( test ) << "' : "; std::cout.flush(); } void exitTest( CppUT::Test &test, CppUT::TestContext &context ) { std::cout << resultType_ << std::endl; } std::string resultType_; }; class CPPUT_API DotProgressListener : public TestListener { public: // overridden from CppUT::TestListener void processTestResult( CppUT::TestResult &result, CppUT::TestContext &context ) { char out = '.'; if ( result.failed() ) { if ( result.isAssertionFailure() ) out = 'A'; else if ( result.isFaultFailure() ) out = 'F'; else // user custom failure out = 'E'; } std::cout << out; std::cout.flush(); } }; } // namespace CppUT #endif // CPPUT_PROGRESSLISTENER_H_INCLUDED --- NEW FILE: resultexception.h --- #ifndef CPPUT_RESULTEXCEPTION_H_INCLUDED # define CPPUT_RESULTEXCEPTION_H_INCLUDED # include <cpput/config.h> # include <cpput/location.h> # include <cpput/message.h> # include <exception> // TODO: operator =() default implementation bugged in VC 6. See CppUnit 1.9 for work-around. namespace CppUT { class CPPUT_API ResultException : public std::exception { public: ResultException( const Message &message, const Location &location = Location() ) : location_( location ) , message_( message ) , messageAdjusted_( false ) { } ResultException( const ResultException &other ) : location_( other.location_ ) , message_( other.message() ) // retrieves adjusted message , messageAdjusted_( true ) { } virtual ~ResultException() // CPPUT_STD_EXCEPTION_THROW_CLAUSE { } ResultException &operator =( const ResultException &other ) { // Don't call superclass operator =(). VC++ 6.0 STL implementation // has a bug. It calls the destructor and copy constructor of // std::exception() which reset the virtual table to std::exception. // SuperClass::operator =(other); location_ = other.location_; message_ = other.message(); // retrieves adjusted message messageAdjusted_ = true; return *this; } const Location &location() const { return location_; } const Message &message() const { adjustMessage(); return message_; } // overridden from std::exception const char *what() const throw() { if ( what_.empty() ) { adjustMessage(); what_ = "Failure at "; what_ += location_.toString(); what_ += "\n"; what_ += message_.toString(); } return what_.c_str(); } protected: /// Should be overriden to set test status and result type. virtual void doAdjustMessage( Message &message ) const { } private: void adjustMessage() const { if ( messageAdjusted_ ) return; doAdjustMessage( message_ ); messageAdjusted_ = true; } mutable std::string what_; Location location_; mutable Message message_; mutable bool messageAdjusted_; }; class CPPUT_API SuccessException : public ResultException { public: SuccessException( const Message &message, const Location &location = Location() ) : ResultException( message, location ) { } protected: // overriden from ResultException void doAdjustMessage( Message &message ) const { message.setStatus( true ); } }; class CPPUT_API FailureException : public ResultException { public: FailureException( const Message &message, const Location &location = Location() ) : ResultException( message, location ) { } protected: // overriden from ResultException void doAdjustMessage( Message &message ) const { message.setStatus( false ); } }; class CPPUT_API AssertException : public FailureException { public: AssertException( const Message &message, const Location &location = Location() ) : FailureException( message, location ) { } protected: // overriden from ResultException void doAdjustMessage( Message &message ) const { FailureException::doAdjustMessage( message ); if ( !message.hasResultType() ) // allow user to set a custom result type message.setResultType( "assertion" ); } }; class CPPUT_API FaultException : public FailureException { public: FaultException( const Message &message, const Location &location = Location() ) : FailureException( message, location ) { } protected: // overriden from ResultException void doAdjustMessage( Message &message ) const { FailureException::doAdjustMessage( message ); if ( !message.hasResultType() ) // allow user to set a custom result type message.setResultType( "fault" ); } }; } // namespace CppUT #endif // CPPUT_RESULTEXCEPTION_H_INCLUDED --- assertexception.h DELETED --- Index: config.h =================================================================== RCS file: /cvsroot/cpptool/CppParser/include/cpput/config.h,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** config.h 8 Jun 2004 20:23:20 -0000 1.1.1.1 --- config.h 5 Aug 2004 20:52:45 -0000 1.2 *************** *** 37,40 **** --- 37,42 ---- # define CPPUT_HAS_FUNCTION_TEMPLATE_ORDERING 1 # define CPPUT_HAS_TEMPLATE_PARTIAL_SPECIALIZATION 1 + # pragma warning( disable : 4800 ) // forcing value to bool performance warning + # pragma warning( disable : 4018 ) // '<' signed/unsigned mismatch # endif --- NEW FILE: testresult.h --- #ifndef CPPUT_TESTFAILURE_H_INCLUDED # define CPPUT_TESTFAILURE_H_INCLUDED # include <cpput/config.h> # include <cpput/forwards.h> # include <cpput/location.h> # include <cpput/message.h> namespace CppUT { /// @todo make succeeded a property like failure_type. class CPPUT_API TestResult { public: TestResult( Test &test, const Message &message ) : test_( &test ) , message_( message ) { } TestResult( Test &test, const Message &message, const Location &location ) : test_( &test ) , message_( message ) , location_( location ) { } bool succeeded() const { return get<bool>( properties().tryGet( "cpput.status", false ) ); } bool failed() const { return !succeeded(); } bool isFaultFailure() const { return resultType() == "fault"; } bool isAssertionFailure() const { return resultType() == "assertion"; } std::string resultType() const { return get<std::string>( properties().tryGet( "cpput.result_type", std::string("") ) ); } Test &test() const { return *test_; } const Properties &properties() const { return message_.properties(); } const Message &message() const { return message_; } const Location &location() const { return location_; } private: Test *test_; Message message_; Location location_; }; } // namespace CppUT #endif // CPPUT_TESTFAILURE_H_INCLUDED Index: testfailureguard.h =================================================================== RCS file: /cvsroot/cpptool/CppParser/include/cpput/testfailureguard.h,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** testfailureguard.h 8 Jun 2004 20:23:21 -0000 1.1.1.1 --- testfailureguard.h 5 Aug 2004 20:52:45 -0000 1.2 *************** *** 3,12 **** # include <cpput/forwards.h> ! # include <cpput/assertexception.h> # include <cpput/functor.h> # include <deque> # include <stdexcept> ! /* Tests setUp(), tearDown(), run() call are protected by a TestFailureGuardChain. * * This guard chain ensures that any exceptions thrown by the call is caught and properly handled. --- 3,12 ---- # include <cpput/forwards.h> ! # include <cpput/resultexception.h> # include <cpput/functor.h> # include <deque> # include <stdexcept> ! /* Tests setUp(), tearDown(), run() call are protected by a TestExceptionGuardChain. * * This guard chain ensures that any exceptions thrown by the call is caught and properly handled. *************** *** 14,18 **** * std::exception, and any other exception. * ! * A TestFailureGuard can be added to the guard chain to handle exception type unknown * to the test framework which are not derived from std::exception (MFC CException * for example). */ --- 14,18 ---- * std::exception, and any other exception. * ! * A TestExceptionGuard can be added to the guard chain to handle exception type unknown * to the test framework which are not derived from std::exception (MFC CException * for example). */ *************** *** 20,68 **** namespace CppUT { - namespace Impl { - template<class ExceptionType> - struct FailureData - { - FailureData( Test &failedTest, const ExceptionType &e ) - : failedTest_( failedTest ) - , exception_( e ) - { - } - - Test &failedTest_; - ExceptionType exception_; - }; - } // namespace Impl - - // Test fault & assertion failure are forwarded to that handler. ! class CPPUT_API TestFailureHandler { public: ! virtual ~TestFailureHandler() { } ! virtual void handleAssertion( Test &failedTest, const AssertException &e ) = 0; ! ! virtual void handleFault( Test &failedTest, const FaultException &e ) =0; }; ! class CPPUT_API TestFailureGuard { public: ! virtual ~TestFailureGuard() { } ! void setNextInChain( const TestFailureGuardPtr &deleguate ); struct Context { ! Context( TestFailureHandler &failureHandler, Functor0 test, Test &protectedTest ) ! : failureHandler_( failureHandler ) , test_( test ) , protectedTest_( protectedTest ) --- 20,50 ---- namespace CppUT { // Test fault & assertion failure are forwarded to that handler. ! class CPPUT_API TestExceptionHandler { public: ! virtual ~TestExceptionHandler() { } ! virtual void handleResultException( Test &test, const ResultException &e ) = 0; }; ! class CPPUT_API TestExceptionGuard { public: ! virtual ~TestExceptionGuard() { } ! void setNextInChain( const TestExceptionGuardPtr &deleguate ); struct Context { ! Context( TestExceptionHandler &exceptionHandler, Functor0 test, Test &protectedTest ) ! : exceptionHandler_( exceptionHandler ) , test_( test ) , protectedTest_( protectedTest ) *************** *** 70,74 **** } ! TestFailureHandler &failureHandler_; Functor0 test_; Test &protectedTest_; --- 52,56 ---- } ! TestExceptionHandler &exceptionHandler_; Functor0 test_; Test &protectedTest_; *************** *** 82,99 **** private: ! TestFailureGuardPtr deleguate_; }; ! class CPPUT_API TestFailureGuardChain { public: ! TestFailureGuardChain(); ! void appendGuard( const TestFailureGuardPtr &guard ); void removeGuard(); ! bool protect( TestFailureHandler &failureHandler, Functor0 test, Test &protectedTest ); --- 64,81 ---- private: ! TestExceptionGuardPtr deleguate_; }; ! class CPPUT_API TestExceptionGuardChain { public: ! TestExceptionGuardChain(); ! void appendGuard( const TestExceptionGuardPtr &guard ); void removeGuard(); ! bool protect( TestExceptionHandler &exceptionHandler, Functor0 test, Test &protectedTest ); *************** *** 102,142 **** private: ! typedef std::deque<TestFailureGuardPtr> Guards; Guards guards_; }; ! class CPPUT_API FailuresPropagationException : public std::exception { public: ! FailuresPropagationException(); ! virtual ~FailuresPropagationException() // CPPUT_STD_EXCEPTION_THROW_CLAUSE { } ! void addAssertion( Test &failedTest, ! const AssertException &e ); ! void addFault( Test &failedTest, ! const FaultException &e ); ! bool hasFailures() const; ! void handleFailures( TestFailureHandler &handler ) const; ! private: ! typedef Impl::FailureData<AssertException> AssertionData; ! typedef Impl::FailureData<FaultException> FaultData; ! std::deque<AssertionData> assertions_; ! std::deque<FaultData> faults_; }; /* ! class CPPUT_API ThreadGuard : public TestFailureGuardChain { public: ThreadGuard(); ! ThreadGuard( const TestFailureGuardChain &other ); }; */ --- 84,128 ---- private: ! typedef std::deque<TestExceptionGuardPtr> Guards; Guards guards_; }; ! class CPPUT_API TestResultsPropagationException : public std::exception { public: ! TestResultsPropagationException(); ! virtual ~TestResultsPropagationException() // CPPUT_STD_EXCEPTION_THROW_CLAUSE { } ! void addResult( Test &test, ! const ResultException &e ); ! void handleFailures( TestExceptionHandler &handler ) const; ! private: ! struct ResultData ! { ! ResultData( Test &test, const ResultException &e ) ! : test_( test ) ! , exception_( e ) ! { ! } ! Test &test_; ! ResultException exception_; ! }; ! std::deque<ResultData> results_; }; /* ! class CPPUT_API ThreadGuard : public TestExceptionGuardChain { public: ThreadGuard(); ! ThreadGuard( const TestExceptionGuardChain &other ); }; */ --- NEW FILE: resource.h --- #ifndef CPPUT_RESOURCE_H_INCLUDED # define CPPUT_RESOURCE_H_INCLUDED # include <cpput/smartptr.h> /* * Notes: * 1) it would be interesting to use the dependency injection pattern for test fixture * that use resource. This would allows the fixture to be run with different resources, making * it simple to run different set of input/expected set on the same fixture. * * 2) the above seems to relate to some of the tablefixture ideas... */ namespace CppUT { class Resource; typedef SmartPtr<Resource> ResourcePtr; class CPPUT_API Resource { public: virtual ~Resource() { } virtual void setUp() { } virtual void cleanUp() { } }; class CPPUT_API ResourceProvider { public: virtual ~ResourceProvider() { } virtual std::string handledProtocol() const = 0; virtual ResourcePtr makeResource( const std::string &uri ) = 0; }; class CPPUT_API InjectResource { public: virtual ~InjectResource() { } virtual void setResource( const std::string &uri, const ResourcePtr &resource ) = 0; }; template<class FixtureType> class SharedFixtureResourceProvider : public ResourceProvider { public: // overridden from ResourceProvider std::string handledProtocol() const { return "shared_fixture"; } ResourcePtr makeResource( const std::string &uri ) { return ResourcePtr<FixtureType>(); } }; } // namespace CppUT #endif // CPPUT_RESOURCE_H_INCLUDED --- testfailure.h DELETED --- Index: test.h =================================================================== RCS file: /cvsroot/cpptool/CppParser/include/cpput/test.h,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** test.h 8 Jun 2004 20:23:21 -0000 1.1.1.1 --- test.h 5 Aug 2004 20:52:45 -0000 1.2 *************** *** 64,67 **** --- 64,75 ---- + inline std::string CPPUT_API path( Test &test ) + { + if ( test.parentTest() ) + return path( *test.parentTest() ) + "/" + test.name(); + return test.name(); + } + + } // namespace CppUT Index: forwards.h =================================================================== RCS file: /cvsroot/cpptool/CppParser/include/cpput/forwards.h,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** forwards.h 8 Jun 2004 20:23:20 -0000 1.1.1.1 --- forwards.h 5 Aug 2004 20:52:45 -0000 1.2 *************** *** 9,23 **** class AbstractTestSuite; class AssertException; class FaultException; class Location; class Message; ! class StandardTestFailureGuard; class Test; class TestCase; class TestContext; ! class TestFailure; ! class TestFailureHandler; ! class TestFailureGuard; ! class TestFailureGuardChain; class TestListener; class TestSuite; --- 9,26 ---- class AbstractTestSuite; class AssertException; + class FailureException; class FaultException; class Location; class Message; ! class ResultException; ! class StandardTestExceptionGuard; ! class SuccessException; class Test; class TestCase; class TestContext; ! class TestResult; ! class TestExceptionHandler; ! class TestExceptionGuard; ! class TestExceptionGuardChain; class TestListener; class TestSuite; *************** *** 25,29 **** typedef SmartPtr<Test> TestPtr; ! typedef SmartPtr<TestFailureGuard> TestFailureGuardPtr; typedef SmartPtr<TestSuite> TestSuitePtr; --- 28,32 ---- typedef SmartPtr<Test> TestPtr; ! typedef SmartPtr<TestExceptionGuard> TestExceptionGuardPtr; typedef SmartPtr<TestSuite> TestSuitePtr; Index: assert.h =================================================================== RCS file: /cvsroot/cpptool/CppParser/include/cpput/assert.h,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** assert.h 8 Jun 2004 20:23:19 -0000 1.1.1.1 --- assert.h 5 Aug 2004 20:52:41 -0000 1.2 *************** *** 2,6 **** # define CPPUT_ASSERT_H_INCLUDED ! # include <cpput/assertexception.h> # include <cpput/equality.h> # include <cpput/location.h> --- 2,6 ---- # define CPPUT_ASSERT_H_INCLUDED ! # include <cpput/resultexception.h> # include <cpput/equality.h> # include <cpput/location.h> *************** *** 18,21 **** --- 18,23 ---- void CPPUT_API fail( const Message &message = translate( "Assertion failed." ) ); + void CPPUT_API succeed( const Message &message ); + void CPPUT_API checkTrue( bool shouldBeTrue, const Message &message = Message() ); *************** *** 123,126 **** --- 125,132 ---- ::CppUT::fail + # define CPPUT_SUCCEED \ + CPPUT_BEGIN_ASSERTION_MACRO() \ + ::CppUT::succeed + # define CPPUT_ASSERT \ CPPUT_BEGIN_ASSERTION_MACRO() \ Index: properties.h =================================================================== RCS file: /cvsroot/cpptool/CppParser/include/cpput/properties.h,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** properties.h 8 Jun 2004 20:23:21 -0000 1.1.1.1 --- properties.h 5 Aug 2004 20:52:45 -0000 1.2 *************** *** 4,12 **** # include <cpput/config.h> # include <cpput/enumerator.h> # include <map> ! # include <stdexcept> namespace CppUT { class CPPUT_API Properties --- 4,19 ---- # include <cpput/config.h> # include <cpput/enumerator.h> + # include <cpputtools/value.h> # include <map> ! ! ! // @todo thread-safety issue when using copy constructor with std::string... namespace CppUT { + using CppUTTools::ValueBadCast; + using CppUTTools::Value; + using CppUTTools::value; + class CPPUT_API Properties *************** *** 17,73 **** } ! Properties( const Property &property ) { - add( property ); } ! Properties &add( const Property &property ) { ! properties.erase( property.name() ); ! properties.insert( Map::value_type( property.name(), ! property.value() ) ); ! return *this; } ! Properties &set( const std::string &name, ! const std::string &value ) { ! return add( Property( name, value ) ); } Enumerator<std::string> names() const { ! return enumStlMapValues( properties ); } ! bool has( const std::string &name ) { ! return properties_.count( name ) > 0; } ! std::string get( const std::string &name ) const { ! Map::const_iterator it = properties_.find( name ); ! if ( it == properties_.end() ) ! throw std::invalid_argument( "No properties named " + name ); return it->second; } ! std::string tryGet( const std::string &name ) const { ! Map::const_iterator it = properties_.find( name ); ! if ( it == properties_.end() ) ! return ""; return it->second; } ! bool has( const std::string &name ) const { ! return properties_.count( name ) > 0; } private: ! typedef std::map<std::string,std::string> Map; ! Map properties_; }; --- 24,95 ---- } ! virtual ~Properties() { } ! void add( const Properties &other ) { ! ValuesByName::const_iterator it = other.valuesByName_.begin(); ! for ( ; it != other.valuesByName_.end(); ++it ) ! if ( valuesByName_.count( it->first ) == 0 ) ! valuesByName_[ it->first ] = it->second; } ! void replace( const Properties &other ) { ! ValuesByName::const_iterator it = other.valuesByName_.begin(); ! for ( ; it != other.valuesByName_.end(); ++it ) ! valuesByName_[ it->first ] = it->second; ! } ! ! void set( const std::string &name, ! const CppUTTools::Value &value ) ! { ! valuesByName_[ name ] = value; ! } ! ! void copy( const Properties &other, ! const std::string &name ) ! { ! set( name, other.get( name ) ); } Enumerator<std::string> names() const { ! return enumStlMapKeys( valuesByName_, Type<std::string>() ); } ! bool has( const std::string &name ) const { ! return valuesByName_.count( name ) > 0; } ! Value get( const std::string &name ) const { ! ValuesByName::const_iterator it = valuesByName_.find( name ); ! if ( it == valuesByName_.end() ) ! throw std::invalid_argument( "No properties named '" + name + "'." ); return it->second; } ! Value tryGet( const std::string &name, ! const CppUTTools::Value &defaultValue = CppUTTools::Value() ) const { ! ValuesByName::const_iterator it = valuesByName_.find( name ); ! if ( it == valuesByName_.end() ) ! return defaultValue; return it->second; } ! /* ! int getInt( const std::string &name ) const { ! return get<int>( get( name ) ); } + */ private: ! typedef std::map<std::string,CppUTTools::Value> ValuesByName; ! ValuesByName valuesByName_; }; *************** *** 77,80 **** ! ! #endif // CPPUT_PROPERTIES_H_INCLUDED \ No newline at end of file --- 99,101 ---- ! #endif // CPPUT_PROPERTIES_H_INCLUDED Index: testlistener.h =================================================================== RCS file: /cvsroot/cpptool/CppParser/include/cpput/testlistener.h,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** testlistener.h 8 Jun 2004 20:23:21 -0000 1.1.1.1 --- testlistener.h 5 Aug 2004 20:52:45 -0000 1.2 *************** *** 15,24 **** } ! virtual void testFailed( const TestFailure &failure, ! TestContext &context ) { } ! virtual void enterTest( Test &test, TestContext &context ) { } --- 15,24 ---- } ! virtual void enterTest( Test &test, TestContext &context ) { } ! virtual void processTestResult( TestResult &result, ! TestContext &context ) { } --- NEW FILE: testrunresult.h --- #ifndef CPPUT_TESTRUNRESULT_H_INCLUDED # define CPPUT_TESTRUNRESULT_H_INCLUDED # include <cpput/config.h> # include <cpput/forwards.h> # include <cpput/testlistener.h> # include <cpput/testresult.h> # include <deque> namespace CppUT { class CPPUT_API TestRunResult : public TestListener { public: int testCount() const { return int(results_.size()); } int successCount() const { return int(successes_.size()); } int failureCount() const { return int(failures_.size()); } const TestResult &testResultAt( int index ) const { #if CPPUT_HAS_VECTOR_AT return results_.at( index ); #else return results_[ index ]; #endif } const TestResult &failureAt( int index ) const { #if CPPUT_HAS_VECTOR_AT return results_.at( failures_.at(index) ); #else return results_[ failures_[index] ]; #endif } const TestResult &successAt( int index ) const { #if CPPUT_HAS_VECTOR_AT return results_.at( failures_.at(index) ); #else return results_[ failures_[index] ]; #endif } bool successful() const { return failures_.empty(); } // overridden from TestListener void processTestResult( TestResult &result, TestContext &context ) { if ( result.failed() ) failures_.push_back( results_.size() ); else successes_.push_back( results_.size() ); results_.push_back( result ); } private: typedef std::deque<TestResult> Results; Results results_; typedef std::deque<int> Failures; Failures failures_; typedef std::deque<int> Successes; Successes successes_; }; } // namespace CppUT #endif // CPPUT_TESTRUNRESULT_H_INCLUDED Index: testcontext.h =================================================================== RCS file: /cvsroot/cpptool/CppParser/include/cpput/testcontext.h,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** testcontext.h 8 Jun 2004 20:23:21 -0000 1.1.1.1 --- testcontext.h 5 Aug 2004 20:52:45 -0000 1.2 *************** *** 9,13 **** namespace CppUT { ! class CPPUT_API TestContext : private TestFailureHandler { public: --- 9,13 ---- namespace CppUT { ! class CPPUT_API TestContext : private TestExceptionHandler { public: *************** *** 24,28 **** void remove( TestListener &listener ); ! void appendGuard( const TestFailureGuardPtr &guard ); void removeGuard(); --- 24,28 ---- void remove( TestListener &listener ); ! void appendGuard( const TestExceptionGuardPtr &guard ); void removeGuard(); *************** *** 35,50 **** void (TestListener::*eventMethod)( AbstractTestSuite &, TestContext &) ) ; ! void dispatchTestFailure( const TestFailure &failure ); ! // overridden from TestFailureHandler ! void handleAssertion( Test &failedTest, const AssertException &e ); ! void handleFault( Test &failedTest, const FaultException &e ); private: ! TestFailureGuardChain guardsChain_; typedef std::vector<TestListener *> Listeners; Listeners listeners_; }; --- 35,52 ---- void (TestListener::*eventMethod)( AbstractTestSuite &, TestContext &) ) ; ! void dispatchTestResult( TestResult &result ); ! void dispatchTestSuccessResult( Test &test ); ! // overridden from TestExceptionHandler ! void handleResultException( Test &test, const ResultException &e ); private: ! TestExceptionGuardChain guardsChain_; typedef std::vector<TestListener *> Listeners; Listeners listeners_; + + bool testSucceeded_; }; Index: enumerator.h =================================================================== RCS file: /cvsroot/cpptool/CppParser/include/cpput/enumerator.h,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** enumerator.h 8 Jun 2004 20:23:20 -0000 1.1.1.1 --- enumerator.h 5 Aug 2004 20:52:45 -0000 1.2 *************** *** 591,595 **** ,typename EnumeratedType> Enumerator<CPPUT_DEDUCED_TYPENAME StlMapType::key_type> ! enumStlMapKeys( const StlMapType &map, Type<EnumeratedType>() ) { return enumStlMapKeysAdapt( map, ConversionEnumAdaptor<EnumeratedType>() ); --- 591,595 ---- ,typename EnumeratedType> Enumerator<CPPUT_DEDUCED_TYPENAME StlMapType::key_type> ! enumStlMapKeys( const StlMapType &map, Type<EnumeratedType> ) { return enumStlMapKeysAdapt( map, ConversionEnumAdaptor<EnumeratedType>() ); Index: message.h =================================================================== RCS file: /cvsroot/cpptool/CppParser/include/cpput/message.h,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** message.h 8 Jun 2004 20:23:20 -0000 1.1.1.1 --- message.h 5 Aug 2004 20:52:45 -0000 1.2 *************** *** 3,6 **** --- 3,7 ---- # include <cpput/config.h> + # include <cpput/properties.h> # include <string> # include <vector> *************** *** 88,92 **** --- 89,120 ---- } + Properties &properties() + { + return properties_; + } + + const Properties &properties() const + { + return properties_; + } + + void setStatus( bool succeeded ) + { + properties().set( "cpput.status", succeeded ); + } + + void setResultType( const std::string &resultType ) + { + properties().set( "cpput.result_type", resultType ); + } + + bool hasResultType() const + { + return properties().has( "cpput.result_type" ); + } + private: + Properties properties_; + typedef std::vector<std::string> Details; Details details_; --- NEW FILE: tablefixture.h --- #ifndef CPPUT_TABLEFIXTURE_H_INCLUDED # define CPPUT_TABLEFIXTURE_H_INCLUDED # include <cpput/testcase.h> # include <map> namespace CppUT { class CellBinder; class TableFixture; class TableRow; typedef SmartPtr<CellBinder> CellBinderPtr; class Table { public: virtual ~Table() { } }; class TableRow { public: TableRow( const Table &table, int rowIndex ); virtual ~TableRow() { } enum { invalidRow = -1 }; // invalidRow if it does not exist virtual int getCellIndex( const std::string &name ) = 0; virtual int cellCount() = 0; virtual bool isCellEmpty( int index ) = 0; virtual int cellAsInt( int index ) = 0; virtual unsigned int cellAsUnsignedInt( int index ) = 0; virtual char cellAsChar( int index ) = 0; virtual float cellAsFloat( int index ) = 0; virtual double cellAsDouble( int index ) = 0; virtual std::string cellAsString( double index ) = 0; }; class CellBinder { public: virtual ~CellBinder() { } virtual void bind( TableFixture &fixture, const TableRow &row, int cellIndex ) const = 0; }; template<class MemberType> class CommonCellBinder : public CellBinder { public: CommonCellBinder( MemberType TableFixture::*input, MemberType (TableRow::*cellGetter)() ) { } // overridden from CellBinder void bind( TableFixture &fixture, const TableRow &row, int cellIndex ) const { fixture->*input_ = (row->*cellGetter_)( cellIndex ); } private: MemberType TableFixture::*input_; MemberType (TableRow::*cellGetter_)(); }; class TableFixture : public AbstractTestCase { public: typedef void (TableFixture::*ActionFn)(); typedef char TableFixture::*CharInput; typedef int TableFixture::*IntInput; typedef unsigned int TableFixture::*UnsignedIntInput; typedef float TableFixture::*FloatInput; typedef double TableFixture::*DoubleInput; typedef std::string TableFixture::*StringInput; void bindAction( const std::string &actionName, ActionFn actionMethod ); void bindInput( const std::string &inputName, CharInput input ); void bindInput( const std::string &inputName, IntInput input ); void bindInput( const std::string &inputName, UnsignedIntInput input ); void bindInput( const std::string &inputName, FloatInput input ); void bindInput( const std::string &inputName, DoubleInput input ); void bindInput( const std::string &inputName, StringInput input ); void bindInput( const std::string &inputName, const CellBinderPtr &binder ); //void beginProcessTable( const Table &table ); //void endProcessTable( const Table &table ); virtual void beginProcessRow( const TableRow &row ); virtual void endProcessRow( const TableRow &row ); virtual void processRow( const TableRow &row ); private: typedef std::map< std::string, CellBinderPtr > Binders; Binders binders_; typedef std::map< std::string, Functor0 > Actions; Actions actions_; }; } // namespace CppUT #endif // CPPUT_TABLEFIXTURE_H_INCLUDED |
From: Baptiste L. <bl...@us...> - 2004-08-05 20:52:56
|
Update of /cvsroot/cpptool/CppParser/include/cpputtools In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv20897/include/cpputtools Added Files: configuration.h convertor.h ctti.h refcountptr.h value.h valuebinder.h Log Message: * upgraded to current cppunit 2 cvs --- NEW FILE: value.h --- #ifndef CPPUTTOOLS_VALUE_H_INCLUDED # define CPPUTTOOLS_VALUE_H_INCLUDED # include "ctti.h" # include <stdexcept> namespace CppUTTools { class ValueBadCast : public std::bad_cast { public: ValueBadCast() : std::bad_cast( "CppUTTools::ValueBadCast" ) { } }; namespace Impl { class ValueHolder { public: virtual ~ValueHolder() {} virtual TypeId type() const = 0; virtual ValueHolder *clone() const = 0; virtual void *pointer() = 0; }; template<class ValueType> class ValueHolderImpl : public ValueHolder { public: ValueHolderImpl( const ValueType &value ) : value_( value ) { } const ValueType &value() const { return value_; } public: // overridden from ValueHolder TypeId type() const { return typeId<ValueType>(); } void *pointer() { return &value_; } ValueHolder *clone() const { return new ValueHolderImpl<ValueType>( value_ ); } private: ValueType value_; }; } // namespace Impl class Value { public: Value(); Value( char value ); Value( bool value ); Value( short value ); Value( int value ); Value( long value ); Value( unsigned short value ); Value( unsigned int value ); Value( unsigned long value ); Value( float value ); Value( double value ); Value( long double value ); Value( const std::string &value ); Value( const std::wstring &value ); Value( const Value &other ); Value &operator =( const Value &other ); TypeId type() const; void swap( Value &other ); bool hasSameType( const Value &other ) const; bool isEmpty() const; const void *valuePointer() const; void *valuePointer(); void copyValueTo( void *storage ); //private: // not private for access by get/set/cast function Value( Impl::ValueHolder *holder ); Impl::ValueHolder *holder_; }; template<class ValueType> Value value( const ValueType &newValue ) { return Value( new Impl::ValueHolderImpl<ValueType>( newValue ) ); } // class Value // /////////////////////////////////////////////////////////////// inline Value::Value() : holder_( 0 ) { } inline Value::Value( bool value ) : holder_( new Impl::ValueHolderImpl<bool>( value ) ) { } inline Value::Value( char value ) : holder_( new Impl::ValueHolderImpl<char>( value ) ) { } inline Value::Value( short value ) : holder_( new Impl::ValueHolderImpl<short>( value ) ) { } inline Value::Value( int value ) : holder_( new Impl::ValueHolderImpl<int>( value ) ) { } inline Value::Value( long value ) : holder_( new Impl::ValueHolderImpl<long>( value ) ) { } inline Value::Value( unsigned short value ) : holder_( new Impl::ValueHolderImpl<unsigned short>( value ) ) { } inline Value::Value( unsigned int value ) : holder_( new Impl::ValueHolderImpl<unsigned int>( value ) ) { } inline Value::Value( unsigned long value ) : holder_( new Impl::ValueHolderImpl<unsigned long>( value ) ) { } inline Value::Value( float value ) : holder_( new Impl::ValueHolderImpl<float>( value ) ) { } inline Value::Value( double value ) : holder_( new Impl::ValueHolderImpl<double>( value ) ) { } inline Value::Value( long double value ) : holder_( new Impl::ValueHolderImpl<long double>( value ) ) { } inline Value::Value( const std::string &value ) : holder_( new Impl::ValueHolderImpl<std::string>( value ) ) { } inline Value::Value( const std::wstring &value ) : holder_( new Impl::ValueHolderImpl<std::wstring>( value ) ) { } inline Value::Value( const Value &other ) : holder_( other.holder_ ? other.holder_->clone() : 0 ) { } inline Value & Value::operator =( const Value &other ) { Value tmp( other ); swap( tmp ); return *this; } inline TypeId Value::type() const { return holder_ ? holder_->type() : typeId<void>(); } inline void Value::swap( Value &other ) { Impl::ValueHolder *tmp = holder_; holder_ = other.holder_; other.holder_ = tmp; } inline bool Value::hasSameType( const Value &other ) const { return type() == other.type(); } inline bool Value::isEmpty() const { return holder_ == 0; } inline Value::Value( Impl::ValueHolder *holder ) : holder_( holder ) { } inline const void * Value::valuePointer() const { // this const cast avoid extra virtual function Impl::ValueHolder *holder = const_cast<Impl::ValueHolder *>( holder_ ); return holder ? holder->pointer() : 0; } inline void * Value::valuePointer() { return holder_ ? holder_->pointer() : 0; } } // namespace CppUTTools // Those function are imported in the global namespace since all compiler don't have // argument dependent look-up. They all take type 'Value' in parameter which is in a namespace. template<class ValueType> CppUTTools::Value &set( CppUTTools::Value &value, const ValueType &newValue ) { return value = CppUTTools::Value( new Impl::ValueHolderImpl<ValueType>( newValue ) ); } template<class ValueType> const ValueType &get( const CppUTTools::Value &value ) { if ( value.type() != CppUTTools::typeId<ValueType>() ) throw CppUTTools::ValueBadCast(); return static_cast<CppUTTools::Impl::ValueHolderImpl<ValueType> *>( value.holder_ )->value(); } template<class ValueType> const ValueType *get( const CppUTTools::Value *value ) { if ( value.type() != CppUTTools::typeId<ValueType>() ) return 0; return static_cast<CppUTTools::Impl::ValueHolderImpl<ValueType> *>( value.holder_ )->value(); } #endif // CPPUTTOOLS_VALUE_H_INCLUDED --- NEW FILE: configuration.h --- #ifndef COMMANDLINE_OPTIONS_H_INCUDED # define COMMANDLINE_OPTIONS_H_INCUDED # include "configuration/parser.h" #endif // COMMANDLINE_OPTIONS_H_INCUDED --- NEW FILE: ctti.h --- #ifndef CPPUTTOOLS_CONFIGURATION_CTTI_H_INCUDED # define CPPUTTOOLS_CONFIGURATION_CTTI_H_INCUDED #include <string> // ///////////////////////////////////////////////////// // ///////////////////////////////////////////////////// // CTTI using std::type_info & typeid // ///////////////////////////////////////////////////// // ///////////////////////////////////////////////////// # ifndef CPPUTTOOLS_CTTI_NO_TYPEINFO # include <typeinfo> namespace CppUTTools { class TypeId { public: TypeId( const std::type_info &typeId ) : type_( typeId ) { } bool operator ==( const TypeId &other ) const { return type_ == other.type_; } bool operator !=( const TypeId &other ) const { return !( *this == other ); } bool operator <( const TypeId &other ) const { return type_.before( other.type_ ); } private: const std::type_info &type_; }; // Compile Time Type Information functions // ////////////////////////////////////////////////////////////////// template<class Type> TypeId typeId() { return typeid( Type ); } } // namespace CommandLineOptions // ///////////////////////////////////////////////////// // ///////////////////////////////////////////////////// // CTTI using hande-made mecanism (template overload) // ///////////////////////////////////////////////////// // ///////////////////////////////////////////////////// # else // ifndef CPPUTTOOLS_CTTI_NO_TYPEINFO class TypeId { public: TypeId( const char *type ) : type_( type ) { } bool operator <( const TypeId &other ) const { return strcmp( type_, other.type_) < 0; } bool operator ==( const TypeId &other ) const { return strcmp( type_, other.type_ ) == 0; } bool operator !=( const TypeId &other ) const { return !( *this == other ); } private: const char *type_; }; template<class Type> TypeId typeId<Type>() { return __error__typeId_function_not_overloaded; } #define CPPUTTOOLS_DECLARE_CTTI( type ) \ template<> \ TypeId typeId<type>() \ { \ return TypeId( #type ); \ } CPPUTTOOLS_DECLARE_CTTI( char ); CPPUTTOOLS_DECLARE_CTTI( signed char ); CPPUTTOOLS_DECLARE_CTTI( unsigned char ); CPPUTTOOLS_DECLARE_CTTI( short ); CPPUTTOOLS_DECLARE_CTTI( unsigned short ); CPPUTTOOLS_DECLARE_CTTI( int ); CPPUTTOOLS_DECLARE_CTTI( unsigned int ); CPPUTTOOLS_DECLARE_CTTI( long ); CPPUTTOOLS_DECLARE_CTTI( unsigned long ); CPPUTTOOLS_DECLARE_CTTI( float ); CPPUTTOOLS_DECLARE_CTTI( double ); CPPUTTOOLS_DECLARE_CTTI( long double ); CPPUTTOOLS_DECLARE_CTTI( const char * ); CPPUTTOOLS_DECLARE_CTTI( const wchar_t * ); CPPUTTOOLS_DECLARE_CTTI( std::string ); CPPUTTOOLS_DECLARE_CTTI( std::wstring ); # endif #endif // CPPUTTOOLS_CONFIGURATION_CTTI_H_INCUDED --- NEW FILE: convertor.h --- #ifndef CPPUTTOOLS_CONVERTOR_H_INCLUDED # define CPPUTTOOLS_CONVERTOR_H_INCLUDED # include "ctti.h" # include <stdexcept> # include <map> class Convertor { public: virtual ~Convertor() {} virtual void convert( const void *source, void *target ) = 0; }; template<class SourceType ,class TargetType> class ConstructorConvertor : public Convertor { public: // overridden from Convertor void convert( const void *source, void *target ) { *( static_cast<TargetType *>(target) ) = TargetType( static_cast<SourceType *>(source) ); } }; template<class SourceType ,class TargetType> class CStrConvertor : public Convertor { public: // overridden from Convertor void convert( const void *source, void *target ) { *( static_cast<TargetType *>(target) ) = static_cast<SourceType *>(source)->c_str(); } } class ConvertorRegistry { public: static ConvertorRegistry &instance(); ConvertorRegistry(); ~ConvertorRegistry(); void add( TypeId sourceType, TypeId targetType, Convertor &convertor ); bool isConvertible( TypeId sourceType, TypeId targetType ); bool convert( TypeId sourceType, TypeId targetType, const void *source, void *target ) const; private: typedef std::map<TypeId,Convertor *> TargetConvertors; typedef std::map<TypeId, TargetConvertors> SourceConvertors; SourceConvertors convertors_; }; #define CPPUTTOOLS_REGISTER_CONVERTOR( SourceType, TargetType, convertor ) \ ConvertorRegistry::instance().add( typeId<sourceType>(), \ typeId<targetType>(), \ convertor ) #define CPPUTTOOLS_REGISTER_CONSTRUCTOR_CONVERTOR( SourceType, TargetType ) \ CPPUTTOOLS_REGISTER_CONVERTOR( sourceType, targetType, \ new ConstructorConvertor<SourceType,TargetType>() ) #define CPPUTTOOLS_REGISTER_CSTR_CONVERTOR( SourceType, TargetType ) \ CPPUTTOOLS_REGISTER_CONVERTOR( sourceType, targetType, \ new CStrConvertor<SourceType,TargetType>() ) inline void ConvertorRegistry::add( TypeId sourceType, TypeId targetType, Convertor &convertor ) { convertors_[sourceType][targetType] = &convertor; } inline bool ConvertorRegistry::isConvertible( TypeId sourceType, TypeId targetType ) { SourceConvertors::const_iterator it = convertors_.find( sourceType ); return it != convertors_.end() && it->second.count( targetType ) > 0; } inline bool ConvertorRegistry::convert( TypeId sourceType, TypeId targetType, const void *source, void *target ) const { SourceConvertors::const_iterator it = convertors_.find( sourceType ); TargetConvertors::const_iterator itTarget = it->second.find( targetType ); if ( itTarget == it->second.end() ) return false; itTarget->second->convert( sourceType, target ); return true; } inline ConvertorRegistry::ConvertorRegistry() { CPPUTTOOLS_REGISTER_CONSTRUCTOR_CONVERTOR( short, int ); CPPUTTOOLS_REGISTER_CONSTRUCTOR_CONVERTOR( short, long ); CPPUTTOOLS_REGISTER_CONSTRUCTOR_CONVERTOR( short, float ); CPPUTTOOLS_REGISTER_CONSTRUCTOR_CONVERTOR( short, double ); CPPUTTOOLS_REGISTER_CONSTRUCTOR_CONVERTOR( short, long double ); CPPUTTOOLS_REGISTER_CONSTRUCTOR_CONVERTOR( int, long ); CPPUTTOOLS_REGISTER_CONSTRUCTOR_CONVERTOR( int, float ); CPPUTTOOLS_REGISTER_CONSTRUCTOR_CONVERTOR( int, double ); CPPUTTOOLS_REGISTER_CONSTRUCTOR_CONVERTOR( int, long double ); CPPUTTOOLS_REGISTER_CONSTRUCTOR_CONVERTOR( long, int ); CPPUTTOOLS_REGISTER_CONSTRUCTOR_CONVERTOR( long, float ); CPPUTTOOLS_REGISTER_CONSTRUCTOR_CONVERTOR( long, double ); CPPUTTOOLS_REGISTER_CONSTRUCTOR_CONVERTOR( long, long double ); CPPUTTOOLS_REGISTER_CONSTRUCTOR_CONVERTOR( float, double ); CPPUTTOOLS_REGISTER_CONSTRUCTOR_CONVERTOR( float, long double ); CPPUTTOOLS_REGISTER_CONSTRUCTOR_CONVERTOR( double, long double ); CPPUTTOOLS_REGISTER_CONSTRUCTOR_CONVERTOR( unsigned short, unsigned int ); CPPUTTOOLS_REGISTER_CONSTRUCTOR_CONVERTOR( unsigned short, unsigned long ); CPPUTTOOLS_REGISTER_CONSTRUCTOR_CONVERTOR( unsigned short, float ); CPPUTTOOLS_REGISTER_CONSTRUCTOR_CONVERTOR( unsigned short, double ); CPPUTTOOLS_REGISTER_CONSTRUCTOR_CONVERTOR( unsigned short, long double ); CPPUTTOOLS_REGISTER_CONSTRUCTOR_CONVERTOR( unsigned int, long ); CPPUTTOOLS_REGISTER_CONSTRUCTOR_CONVERTOR( unsigned int, float ); CPPUTTOOLS_REGISTER_CONSTRUCTOR_CONVERTOR( unsigned int, double ); CPPUTTOOLS_REGISTER_CONSTRUCTOR_CONVERTOR( unsigned int, long double ); CPPUTTOOLS_REGISTER_CONSTRUCTOR_CONVERTOR( unsigned long, float ); CPPUTTOOLS_REGISTER_CONSTRUCTOR_CONVERTOR( unsigned long, double ); CPPUTTOOLS_REGISTER_CONSTRUCTOR_CONVERTOR( unsigned long, long double ); CPPUTTOOLS_REGISTER_CONSTRUCTOR_CONVERTOR( double, long double ); CPPUTTOOLS_REGISTER_CONSTRUCTOR_CONVERTOR( char *, std::string ); CPPUTTOOLS_REGISTER_CONSTRUCTOR_CONVERTOR( const char *, std::string ); CPPUTTOOLS_REGISTER_CONSTRUCTOR_CONVERTOR( wchar_t *, std::wstring ); CPPUTTOOLS_REGISTER_CONSTRUCTOR_CONVERTOR( const wchar_t *, std::wstring ); CPPUTTOOLS_REGISTER_CSTR_CONVERTOR( std::string, const char * ); CPPUTTOOLS_REGISTER_CSTR_CONVERTOR( std::wstring, const wchar_t * ); } ConvertorRegistry::~ConvertorRegistry() { SourceConvertors::iterator it = convertors_.begin(); for ( ; it != convertors_.end; ++it ) { TargetConvertors::iterator itTarget = it->second.begin(); for ( ; itTarget != it->second.end(); ++itTarget ) delete itTarget->second; } } } // namespace CppUTTools #endif // CPPUTTOOLS_CONVERTOR_H_INCLUDED --- NEW FILE: valuebinder.h --- #ifndef CPPUTTOOLS_VALUEBINDER_H_INCLUDED # define CPPUTTOOLS_VALUEBINDER_H_INCLUDED # include "value.h" namespace CppUTTools { namespace Impl { class ValueBinderImpl { public: virtual ~ValueBinderImpl() {} virtual void set( void *storage, const Value &value ) const = 0; virtual Value get( const void *storage ) const = 0; virtual TypeId type() const = 0; }; template<class ValueType> class SpecificValueBinderImpl : public ValueBinderImpl { public: static const ValueBinderImpl &instance() { static SpecificValueBinderImpl dummy; return dummy; } public: // overridden from ValueBinderImpl void set( void *storage, const Value &value ) const { if ( !value.isEmpty() ) *( static_cast<ValueType *>( storage ) )= ::get<ValueType>( value ); } Value get( const void *storage ) const { return value( *( static_cast<const ValueType *>( storage ) ) ); } TypeId type() const { return typeId<ValueType>(); } }; class VoidValueBinderImpl : public ValueBinderImpl { public: static const ValueBinderImpl &instance() { static VoidValueBinderImpl dummy; return dummy; } public: // overridden from ValueBinderImpl void set( void *storage, const Value &value ) const { } Value get( const void *storage ) const { return Value(); } TypeId type() const { return typeId<void>(); } }; } // namespace Impl class ValueBinder { public: ValueBinder(); void set( const Value &value ) const; Value get() const; TypeId type() const; bool isEmpty() const; public: // private, but friendly template function ValueBinder( void *storage, const Impl::ValueBinderImpl &impl ); private: void *storage_; const Impl::ValueBinderImpl *impl_; }; template<class ValueType> ValueBinder valueBinder( ValueType &storage ) { return ValueBinder( &storage, Impl::SpecificValueBinderImpl<ValueType>::instance() ); } // Implementation // //////////////////////////////////////////////////////////// inline ValueBinder::ValueBinder() : storage_( 0 ) , impl_( &Impl::VoidValueBinderImpl::instance() ) { } inline ValueBinder::ValueBinder( void *storage, const Impl::ValueBinderImpl &impl ) : storage_( storage ) , impl_( &impl ) { } inline void ValueBinder::set( const Value &value ) const { if ( value.type() != type() ) throw ValueBadCast(); impl_->set( storage_, value ); } inline Value ValueBinder::get() const { if ( isEmpty() ) return Value(); return impl_->get( storage_ ); } inline TypeId ValueBinder::type() const { return impl_->type(); } inline bool ValueBinder::isEmpty() const { return storage_ == 0; } } // namespace CppUTTools #endif // CPPUTTOOLS_VALUEBINDER_H_INCLUDED --- NEW FILE: refcountptr.h --- #ifndef CPPUTTOOLS_REFCOUNTPTR_H_INCLUDED # define CPPUTTOOLS_REFCOUNTPTR_H_INCLUDED # include <cpput/config.h> namespace CppUTTools { class ReferenceCounted { public: virtual ~ReferenceCounted() {} virtual void incrementReferenceCount() = 0; virtual bool decrementReferenceCount() = 0; virtual unsigned int getReferenceCount() const = 0; }; // A ReferenceCount which does not provide thread-safety. class ReferenceCountedNoThread : public ReferenceCounted { public: ReferenceCountedNoThread() : count_( 0 ) { } public: // overridden from ReferenceCounted void incrementReferenceCount() { ++count_; } bool decrementReferenceCount() { return --count_ == 0; } unsigned int getReferenceCount() const { return count_; } private: unsigned int count_; }; namespace Impl { /// ReferenceCountPtr base class, implementation common to all pointers... class ReferenceCountPtrBase { public: long use_count() const { if ( p_ ) return p_->getReferenceCount(); return 0; } bool unique() const { return use_count() == 1; } operator bool() const { return p_ != 0; } bool operator !() const { return p_ == 0; } void reset() { ReferenceCountPtrBase tmp; tmp.swap( *this ); } protected: ReferenceCountPtrBase() : p_( 0 ) { } ReferenceCountPtrBase( ReferenceCounted *p ) : p_( p ) { if ( p_ ) p_->incrementReferenceCount(); } ReferenceCountPtrBase( const ReferenceCountPtrBase &other ) : p_( other.p_ ) { if ( p_ ) p_->incrementReferenceCount(); } ~ReferenceCountPtrBase() { if ( p_ && p_->decrementReferenceCount() ) delete p_; } void swap( ReferenceCountPtrBase &other ) { ReferenceCounted *tmpP = p_; p_ = other.p_; other.p_ = tmpP; } ReferenceCounted *get() const { return p_; } private: ReferenceCounted *p_; }; } // namespace Impl template<class PointeeType> class RefCountPtr : public Impl::ReferenceCountPtrBase { public: typedef RefCountPtr<PointeeType> ThisType; typedef Impl::ReferenceCountPtrBase SuperClass; RefCountPtr() { } RefCountPtr( PointeeType *p ) : Impl::ReferenceCountPtrBase( p ) { } RefCountPtr( const ThisType &other ) : Impl::ReferenceCountPtrBase( other ) { } void reset( PointeeType *p ) { RefCountPtr tmp( p ); tmp.swap( *this ); } PointeeType *get() const { return static_cast<PointeeType *>( SuperClass::get() ); } void swap( RefCountPtr &other ) { SuperClass::swap( other ); } ThisType &operator =( const RefCountPtr &other ) { ThisType tmp( other ); swap( tmp ); return *this; } PointeeType &operator *() const { // assert( SuperClass::get() != 0 ) return *( static_cast<PointeeType *>( SuperClass::get() ) ); } PointeeType *operator ->() const { return static_cast<PointeeType *>( SuperClass::get() ); } }; template<class TargetType, class SourceType> RefCountPtr<TargetType> staticPointerCast( const RefCountPtr<SourceType> &p ) { TargetType *target = static_cast<TargetType *>( p.get() ); return RefCountPtr<TargetType>( target ); } } // namespace CppUT #endif // CPPUTTOOLS_REFCOUNTPTR_H_INCLUDED |
From: Baptiste L. <bl...@us...> - 2004-08-05 20:46:44
|
Update of /cvsroot/cpptool/CppParser/include/cpputtools/configuration In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19853/configuration Log Message: Directory /cvsroot/cpptool/CppParser/include/cpputtools/configuration added to the repository |
From: Baptiste L. <bl...@us...> - 2004-08-05 20:39:14
|
Update of /cvsroot/cpptool/CppParser/include/cpputtools In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv18338/cpputtools Log Message: Directory /cvsroot/cpptool/CppParser/include/cpputtools added to the repository |
From: Baptiste L. <bl...@us...> - 2004-06-21 18:53:33
|
Update of /cvsroot/cpptool/CppParser/examples/parser In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv32593/examples/parser Modified Files: symboltabletestprocessor.cpp scope.cpp scope.h symboldeclarator.cpp symboltabletest.cpp Log Message: * added enum support to symbol table Index: symboldeclarator.cpp =================================================================== RCS file: /cvsroot/cpptool/CppParser/examples/parser/symboldeclarator.cpp,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** symboldeclarator.cpp 21 Jun 2004 13:49:30 -0000 1.4 --- symboldeclarator.cpp 21 Jun 2004 18:53:16 -0000 1.5 *************** *** 332,336 **** SymbolDeclarationPtr valueDeclaration = symbolTable_.declare( valueSymbol ); enumScope->addValue( valueDeclaration ); - //parentScope.add( } } --- 332,335 ---- Index: scope.h =================================================================== RCS file: /cvsroot/cpptool/CppParser/examples/parser/scope.h,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** scope.h 21 Jun 2004 13:49:30 -0000 1.4 --- scope.h 21 Jun 2004 18:53:16 -0000 1.5 *************** *** 234,237 **** --- 234,238 ---- void accept( ScopeVisitor &visitor ); SymbolDeclarationPtr resolve( const std::string &name ) const; + SymbolDeclarationPtr getMemberDeclaration( const std::string &name ) const; SymbolDeclarationPtr memberResolve( const std::string &name ) const; std::string str() const; *************** *** 239,243 **** private: ! std::deque<SymbolDeclarationPtr> values_; }; --- 240,245 ---- private: ! typedef std::map<std::string, SymbolDeclarationPtr> Values; ! Values values_; }; Index: scope.cpp =================================================================== RCS file: /cvsroot/cpptool/CppParser/examples/parser/scope.cpp,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** scope.cpp 21 Jun 2004 13:49:30 -0000 1.4 --- scope.cpp 21 Jun 2004 18:53:16 -0000 1.5 *************** *** 1,3 **** --- 1,4 ---- #include "scope.h" + #include "stlhelper.h" namespace Parser { *************** *** 505,509 **** EnumScope::values() const { ! return CppUT::enumStl( values_ ); } --- 506,510 ---- EnumScope::values() const { ! return CppUT::enumStlMapValues( values_, CppUT::Type<SymbolDeclarationPtr>() ); } *************** *** 511,515 **** EnumScope::addValue( const SymbolDeclarationPtr &valueSymbol ) { ! values_.push_back( valueSymbol ); } --- 512,516 ---- EnumScope::addValue( const SymbolDeclarationPtr &valueSymbol ) { ! values_[ valueSymbol->name() ] = valueSymbol; } *************** *** 533,536 **** --- 534,545 ---- } + SymbolDeclarationPtr + EnumScope::getMemberDeclaration( const std::string &name ) const + { + if ( name == declaration()->name() ) + return declaration(); + return StlHelper::mapDefaultGet( values_, name, SymbolDeclarationPtr() ); + } + std::string EnumScope::str() const Index: symboltabletestprocessor.cpp =================================================================== RCS file: /cvsroot/cpptool/CppParser/examples/parser/symboltabletestprocessor.cpp,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** symboltabletestprocessor.cpp 20 Jun 2004 15:53:41 -0000 1.1 --- symboltabletestprocessor.cpp 21 Jun 2004 18:53:16 -0000 1.2 *************** *** 176,180 **** recordSpecfication( enumerationValues ); ! NodeSpecification enumerationValue( "enumeration_value", "value", nsHasBraceValue ); recordSpecfication( enumerationValue ); --- 176,181 ---- recordSpecfication( enumerationValues ); ! NodeSpecification enumerationValue( "enumeration_value", "value", nsHasBraceValue | nsHasChildren ); ! enumerationValue.addMandatoryChild( "references" ); recordSpecfication( enumerationValue ); Index: symboltabletest.cpp =================================================================== RCS file: /cvsroot/cpptool/CppParser/examples/parser/symboltabletest.cpp,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** symboltabletest.cpp 21 Jun 2004 13:49:30 -0000 1.7 --- symboltabletest.cpp 21 Jun 2004 18:53:16 -0000 1.8 *************** *** 49,52 **** --- 49,53 ---- void checkEnumerationValues( const Parser::EnumScopePtr &enumScope, const NodePtr &valuesNode ); + void checkEnumerationValue( const NodePtr &valueNode ); CppUT::Message makeMessage( const NodePtr &node, *************** *** 330,334 **** makeMessage( valuesNode, "Enumerator values do not match." ) ); ! // for each expected value: // resolve value name // check type --- 331,343 ---- makeMessage( valuesNode, "Enumerator values do not match." ) ); ! enumNode = valuesNode->children(); ! while ( enumNode.hasNext() ) ! checkEnumerationValue( enumNode.next() ); ! } ! ! ! void ! DeclarationChecker::checkEnumerationValue( const NodePtr &valueNode ) ! { // resolve value name // check type *************** *** 336,341 **** --- 345,356 ---- // check declarations // check references + + std::string valueName = valueNode->braceValue(); + Parser::SymbolDeclarationPtr declaration = memberResolve( valueName ); + CppUT::checkTrue( declaration, makeMessage( valueNode, "Declaration not found." ) ); + checkReferences( valueNode, declaration ); } + } // anonymous namespace |
From: Baptiste L. <bl...@us...> - 2004-06-21 18:53:33
|
Update of /cvsroot/cpptool/CppParser/examples/parser/testdata/symbol_table In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv32593/examples/parser/testdata/symbol_table Modified Files: enum1.txt Log Message: * added enum support to symbol table Index: enum1.txt =================================================================== RCS file: /cvsroot/cpptool/CppParser/examples/parser/testdata/symbol_table/enum1.txt,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** enum1.txt 21 Jun 2004 13:49:29 -0000 1.2 --- enum1.txt 21 Jun 2004 18:53:17 -0000 1.3 *************** *** 1,7 **** ====file: enum1.cpp $Values.0$enum $Values.1$Values { ! v1 = 0, ! v2, ! v3 }; --- 1,7 ---- ====file: enum1.cpp $Values.0$enum $Values.1$Values { ! $v1.1$v1 = 0, ! $v2.1$v2, ! $v3.1$v3 }; *************** *** 11,17 **** references: $Values.1 values { ! value(v1) ! value(v2) ! value(v3) } } --- 11,23 ---- references: $Values.1 values { ! value(v1) { ! references: $v1.1 ! } ! value(v2) { ! references: $v2.1 ! } ! value(v3) { ! references: $v3.1 ! } } } |