src/coverage.cc
/** Load coverage information generated by the python coverage
    tool (i.e.: .coverage files).
*/
Load coverage information generated by the python coverage
tool .
Load coverage information generated by the python coverage tool .
void loadPycoverage( std::vector<int>& ranges,
    const boost::filesystem::path& key,
    const boost::filesystem::path& filename )
{
	using namespace boost::filesystem;
	int proto, val, len;
	char buf[256];
	ifstream coverfile(filename);
	while( !coverfile.eof() ) {
		int key = coverfile.get();
		switch( key ) {
		case 0x80:
			proto = coverfile.get();
			if( (proto < 0) || (proto > 2) ) {
				boost::throw_exception(
				  parsingError("unsupported pickle protocol"));
			}
			break;
		case '}':
			break;
		case ']':
			ranges.clear();
			break;
		case 'q':
			val = coverfile.get();
			break;
		case '(':
			break;
		case 'e':
			break;
		case 's':
			break;
		case 'u':
			break;
		case '.':
			return;
			break;
		case 'U':
			len = coverfile.get();
			coverfile.get(buf,len + 1);
			break;
		case 'K':
			addCovered(ranges,coverfile.get());
			break;
		case 'M':
			val = coverfile.get();
			addCovered(ranges,(coverfile.get() << 8) | val);
			break;
		default: {
			std::stringstream msg;
			msg << filename << ":" << coverfile.gcount()
				<< ":error: unexpected bytecode 0x"
				<< std::hex << key << std::dec;
			boost::throw_exception(parsingError(msg.str()));
		}
		}
	}
}
void loadPycoverage ( std :: vector < int > & ranges , const boost :: filesystem :: path & key , const boost :: filesystem :: path & filename ) { using namespace boost :: filesystem ; int proto , val , len ; char buf [ 256 ] ; ifstream coverfile ( filename ) ; while ( ! coverfile . eof ( ) ) { int key = coverfile . get ( ) ; switch ( key ) { case 0x80 : proto = coverfile . get ( ) ; if ( ( proto < 0 ) || ( proto > 2 ) ) { boost :: throw_exception ( parsingError ( " " ) ) ; } break ; case ' ' : break ; case ' ' : ranges . clear ( ) ; break ; case ' ' : val = coverfile . get ( ) ; break ; case ' ' : break ; case ' ' : break ; case ' ' : break ; case ' ' : break ; case ' ' : return ; break ; case ' ' : len = coverfile . get ( ) ; coverfile . get ( buf , len + 1 ) ; break ; case ' ' : addCovered ( ranges , coverfile . get ( ) ) ; break ; case ' ' : val = coverfile . get ( ) ; addCovered ( ranges , ( coverfile . get ( ) << 8 ) | val ) ; break ; default : { std :: stringstream msg ; msg << filename << " " << coverfile . gcount ( ) << " " << std :: hex << key << std :: dec ; boost :: throw_exception ( parsingError ( msg . str ( ) ) ) ; } } } }
Load coverage information generated by the python coverage
tool (i.e.
Load coverage information generated by the python coverage tool ( i . e .
/* .coverage are written by pickle.py in binary format.
	   We donot implement the whole byte code interpreter for pickling
	   and unplicking here, only the part necessary to fetch the lines
	   of code covered in file *key*. */ /* pickle protocol */ /* push empty dict */ /* 0x5d: push empty list */ /* 0x71: store stack top in memo; index is 1-byte arg */ /* 0x28: push special markobject on stack */ /* 0x65: extend list on stack by topmost stack slice */ /* 0x73: add key+value pair to dict */ /* 0x75: modify dict by adding topmost key+value pairs */ /* every pickle ends with STOP */ /* push string; counted binary string argument < 256 bytes */ /* 0x4b: push 1-byte unsigned int */ /* 0x4d: push 2-byte unsigned int */