trying to fix ~ErrorDescriptor segfault in p21read. stumbling in dark.
rewrote some code while trying to figure it out: * replaced many char* with string, especially in class ErrorDescriptor * added some FIXMEs and a printf to identify source of generated code * fixed a warning in generated code (no return) * astyle seems to have missed errordesc.h, unfortunately
This commit is contained in:
1 parent
ac9a402470
commit
1016b07d83
9 files changed
+91
-180
No files matched your search
@@ -1540,7 +1540,7 @@ STEPfile::CreateInstance( istream & in, ostream & out ) {
|
||||
// Common causes of error is that obj is an abstract supertype
|
||||
// or that it can only be instantiated using external mapping.
|
||||
// If neither are the case, create a generic message.
|
||||
if( *obj->Error().UserMsg() != '\0' ) {
|
||||
if( !obj->Error().UserMsg().empty() ) {
|
||||
result.UserMsg( obj->Error().UserMsg() );
|
||||
} else {
|
||||
result.UserMsg( "Could not create ENTITY" );
|
||||
@@ -1549,11 +1549,6 @@ STEPfile::CreateInstance( istream & in, ostream & out ) {
|
||||
delete obj;
|
||||
obj = ENTITY_NULL;
|
||||
}
|
||||
#ifdef __O3DB__
|
||||
if( obj ) {
|
||||
obj -> persist();
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1565,7 +1560,6 @@ STEPfile::CreateInstance( istream & in, ostream & out ) {
|
||||
return ENTITY_NULL;
|
||||
}
|
||||
obj -> STEPfile_id = fileid;
|
||||
// AppendEntityErrorMsg( &(obj->Error()) );
|
||||
|
||||
// scan values
|
||||
SkipInstance( in, tmpbuf );
|
||||
|
||||
@@ -691,9 +691,8 @@ SCLP23( Application_instance )::STEPread( int id, int idIncr,
|
||||
_error.GreaterSeverity( severe );
|
||||
sprintf( errStr, " %s : ", attributes[i].Name() );
|
||||
_error.AppendToDetailMsg( errStr ); // add attr name
|
||||
_error.AppendToDetailMsg( ( char * ) // add attr error
|
||||
attributes[i].Error().DetailMsg() );
|
||||
_error.AppendToUserMsg( ( char * )attributes[i].Error().UserMsg() );
|
||||
_error.AppendToDetailMsg( attributes[i].Error().DetailMsg() ); // add attr error
|
||||
_error.AppendToUserMsg( attributes[i].Error().UserMsg() );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -49,7 +49,7 @@ Severity SCLP23( Select )::severity( Severity s ) {
|
||||
return _error.severity( s );
|
||||
} /** end function **/
|
||||
|
||||
const char * SCLP23( Select )::Error() {
|
||||
const std::string SCLP23( Select )::Error() {
|
||||
/** fn Error **/
|
||||
return _error.DetailMsg();
|
||||
} /** end function **/
|
||||
|
||||
@@ -41,7 +41,7 @@ class SCLP23_NAME(Select) {
|
||||
public:
|
||||
Severity severity() const;
|
||||
Severity severity( Severity );
|
||||
const char *Error();
|
||||
const std::string Error();
|
||||
void Error( const char * );
|
||||
// clears select's error
|
||||
void ClearError();
|
||||
|
||||
+24
-89
@@ -21,19 +21,19 @@ ostream * ErrorDescriptor::_out = 0;
|
||||
void
|
||||
ErrorDescriptor::PrintContents( ostream & out ) const {
|
||||
std::string s;
|
||||
out << "Severity: " << severity( s ) << endl;
|
||||
if( _userMsg ) {
|
||||
severity( s );
|
||||
out << "Severity: " << s << endl;
|
||||
if( !_userMsg.empty() ) {
|
||||
out << "User message in parens:" << endl << "(";
|
||||
out << UserMsg() << ")" << endl;
|
||||
}
|
||||
if( _detailMsg ) {
|
||||
if( !_detailMsg.empty() ) {
|
||||
out << "Detailed message in parens:" << endl << "(";
|
||||
out << DetailMsg() << ")" << endl;
|
||||
}
|
||||
}
|
||||
|
||||
const char *
|
||||
ErrorDescriptor::severity( std::string & s ) const {
|
||||
void ErrorDescriptor::severity( std::string & s ) const {
|
||||
s.clear();
|
||||
switch( severity() ) {
|
||||
case SEVERITY_NULL : {
|
||||
@@ -73,7 +73,6 @@ ErrorDescriptor::severity( std::string & s ) const {
|
||||
break;
|
||||
}
|
||||
}
|
||||
return s.c_str();
|
||||
}
|
||||
|
||||
|
||||
@@ -127,106 +126,42 @@ ErrorDescriptor::GetCorrSeverity( const char * s ) {
|
||||
return SEVERITY_BUG;
|
||||
}
|
||||
|
||||
ErrorDescriptor::ErrorDescriptor( Severity s, DebugLevel d )
|
||||
: _severity( s ),
|
||||
_userMsg( 0 ),
|
||||
_detailMsg( 0 ) {
|
||||
ErrorDescriptor::ErrorDescriptor( Severity s, DebugLevel d ) : _severity( s ) {
|
||||
if( d != DEBUG_OFF ) {
|
||||
_debug_level = d;
|
||||
}
|
||||
_userMsg.clear();
|
||||
_detailMsg.clear();
|
||||
}
|
||||
|
||||
/*
|
||||
ErrorDescriptor::ErrorDescriptor ( Severity s, Enforcement e, DebugLevel d)
|
||||
: _severity (s),
|
||||
_enforcement_level (e),
|
||||
_userMsg (0),
|
||||
_detailMsg (0)
|
||||
{
|
||||
if (d != DEBUG_OFF)
|
||||
_debug_level = d;
|
||||
}
|
||||
*/
|
||||
|
||||
const char *
|
||||
ErrorDescriptor::UserMsg() const {
|
||||
if( _userMsg ) {
|
||||
return _userMsg->c_str();
|
||||
} else {
|
||||
return "";
|
||||
}
|
||||
void ErrorDescriptor::UserMsg( const char * msg ) {
|
||||
_userMsg.assign( msg );
|
||||
}
|
||||
|
||||
void
|
||||
ErrorDescriptor::UserMsg( const char * msg ) {
|
||||
if( !_userMsg ) {
|
||||
_userMsg = new std::string;
|
||||
}
|
||||
_userMsg->assign( msg );
|
||||
void ErrorDescriptor::PrependToUserMsg( const char * msg ) {
|
||||
_userMsg.insert( 0, msg );
|
||||
}
|
||||
|
||||
void
|
||||
ErrorDescriptor::PrependToUserMsg( const char * msg ) {
|
||||
if( !_userMsg ) {
|
||||
_userMsg = new std::string;
|
||||
}
|
||||
_userMsg->insert( 0, msg );
|
||||
void ErrorDescriptor::AppendToUserMsg( const char c ) {
|
||||
_userMsg.append( &c );
|
||||
}
|
||||
|
||||
void
|
||||
ErrorDescriptor::AppendToUserMsg( const char c ) {
|
||||
if( !_userMsg ) {
|
||||
_userMsg = new std::string;
|
||||
}
|
||||
_userMsg->append( &c );
|
||||
void ErrorDescriptor::AppendToUserMsg( const char * msg ) {
|
||||
_userMsg.append( msg );
|
||||
}
|
||||
|
||||
void
|
||||
ErrorDescriptor::AppendToUserMsg( const char * msg ) {
|
||||
if( !_userMsg ) {
|
||||
_userMsg = new std::string;
|
||||
}
|
||||
_userMsg->append( msg );
|
||||
void ErrorDescriptor::DetailMsg( const char * msg ) {
|
||||
_detailMsg.assign( msg );
|
||||
}
|
||||
|
||||
|
||||
const char *
|
||||
ErrorDescriptor::DetailMsg() const {
|
||||
if( _detailMsg ) {
|
||||
return _detailMsg->c_str();
|
||||
} else {
|
||||
return "";
|
||||
}
|
||||
void ErrorDescriptor::PrependToDetailMsg( const char * msg ) {
|
||||
_detailMsg.insert( 0, msg );
|
||||
}
|
||||
|
||||
void
|
||||
ErrorDescriptor::DetailMsg( const char * msg ) {
|
||||
if( !_detailMsg ) {
|
||||
_detailMsg = new std::string;
|
||||
}
|
||||
_detailMsg->assign( msg );
|
||||
void ErrorDescriptor::AppendToDetailMsg( const char c ) {
|
||||
_detailMsg.append( &c );
|
||||
}
|
||||
|
||||
void
|
||||
ErrorDescriptor::PrependToDetailMsg( const char * msg ) {
|
||||
if( !_detailMsg ) {
|
||||
_detailMsg = new std::string;
|
||||
}
|
||||
_detailMsg->insert( 0, msg );
|
||||
}
|
||||
|
||||
void
|
||||
ErrorDescriptor::AppendToDetailMsg( const char c ) {
|
||||
if( !_detailMsg ) {
|
||||
_detailMsg = new std::string;
|
||||
}
|
||||
_detailMsg->append( &c );
|
||||
}
|
||||
|
||||
void
|
||||
ErrorDescriptor::AppendToDetailMsg( const char * msg ) {
|
||||
if( !_detailMsg ) {
|
||||
_detailMsg = new std::string;
|
||||
}
|
||||
_detailMsg->append( msg );
|
||||
void ErrorDescriptor::AppendToDetailMsg( const char * msg ) {
|
||||
_detailMsg.append( msg );
|
||||
}
|
||||
+58
-78
@@ -1,6 +1,6 @@
|
||||
|
||||
#ifndef ERRORDESC_H
|
||||
#define ERRORDESC_H
|
||||
#define ERRORDESC_H
|
||||
|
||||
/*
|
||||
* NIST Utils Class Library
|
||||
@@ -13,128 +13,108 @@
|
||||
* and is not subject to copyright.
|
||||
*/
|
||||
|
||||
/* $Id: errordesc.h,v 3.0.1.2 1997/11/05 22:33:46 sauderd DP3.1 $ */
|
||||
|
||||
#ifdef __O3DB__
|
||||
#include <OpenOODB.h>
|
||||
#endif
|
||||
|
||||
#include <string>
|
||||
#include <iostream>
|
||||
using namespace std;
|
||||
|
||||
#define _POC_ " report problem to brlcad-devel"
|
||||
#define _POC_ " report problem to scl-dev at groups.google.com"
|
||||
|
||||
typedef enum Severity {
|
||||
SEVERITY_MAX = -5,
|
||||
SEVERITY_DUMP = -4,
|
||||
SEVERITY_EXIT = -3, // fatal
|
||||
SEVERITY_BUG = -2, // non-recoverable error -- probably bug
|
||||
SEVERITY_INPUT_ERROR = -1, // non-recoverable error
|
||||
SEVERITY_WARNING = 0, // recoverable error
|
||||
SEVERITY_INCOMPLETE = 1, // incomplete data
|
||||
SEVERITY_USERMSG = 2, // possibly an error
|
||||
SEVERITY_NULL = 3 // no error or message
|
||||
SEVERITY_MAX = -5,
|
||||
SEVERITY_DUMP = -4,
|
||||
SEVERITY_EXIT = -3, // fatal
|
||||
SEVERITY_BUG = -2, // non-recoverable error -- probably bug
|
||||
SEVERITY_INPUT_ERROR = -1, // non-recoverable error
|
||||
SEVERITY_WARNING = 0, // recoverable error
|
||||
SEVERITY_INCOMPLETE = 1, // incomplete data
|
||||
SEVERITY_USERMSG = 2, // possibly an error
|
||||
SEVERITY_NULL = 3 // no error or message
|
||||
} Severity;
|
||||
|
||||
/* DAS not used
|
||||
enum Enforcement {
|
||||
ENFORCE_OFF,
|
||||
ENFORCE_OPTIONALITY,
|
||||
ENFORCE_ALL
|
||||
|
||||
} ;
|
||||
*/
|
||||
|
||||
enum DebugLevel {
|
||||
DEBUG_OFF =0,
|
||||
DEBUG_USR =1,
|
||||
DEBUG_ALL =2
|
||||
DEBUG_OFF =0,
|
||||
DEBUG_USR =1,
|
||||
DEBUG_ALL =2
|
||||
|
||||
};
|
||||
|
||||
/******************************************************************
|
||||
** Class: ErrorDescriptor
|
||||
** Data Members:
|
||||
** severity level of error
|
||||
** user message
|
||||
** detailed message
|
||||
** severity level of error
|
||||
** user message
|
||||
** detailed message
|
||||
** Description:
|
||||
** the error is a detailed error message + a severity level
|
||||
** also keeps a user message separately
|
||||
** detailed message gets sent to ostream
|
||||
** uses std::string class to keep the user messages
|
||||
** keeps severity of error
|
||||
** created with or without error
|
||||
** the error is a detailed error message + a severity level
|
||||
** also keeps a user message separately
|
||||
** detailed message gets sent to ostream
|
||||
** uses std::string class to keep the user messages
|
||||
** keeps severity of error
|
||||
** created with or without error
|
||||
** Status:
|
||||
******************************************************************/
|
||||
|
||||
class ErrorDescriptor {
|
||||
// friend istream &operator<< ( istream&, ErrorDescriptor& );
|
||||
protected:
|
||||
|
||||
Severity _severity;
|
||||
protected:
|
||||
Severity _severity;
|
||||
|
||||
static DebugLevel _debug_level;
|
||||
static ostream* _out; // note this will not be persistent
|
||||
|
||||
std::string *_userMsg;
|
||||
std::string *_detailMsg;
|
||||
public:
|
||||
static DebugLevel _debug_level;
|
||||
static ostream* _out; // note this will not be persistent
|
||||
|
||||
ErrorDescriptor (Severity s = SEVERITY_NULL,
|
||||
DebugLevel d = DEBUG_OFF);
|
||||
~ErrorDescriptor () { delete _userMsg; delete _detailMsg; }
|
||||
std::string _userMsg, _detailMsg;
|
||||
public:
|
||||
ErrorDescriptor (Severity s = SEVERITY_NULL,
|
||||
DebugLevel d = DEBUG_OFF);
|
||||
|
||||
void PrintContents(ostream &out = cout) const;
|
||||
void PrintContents(ostream &out = cout) const;
|
||||
|
||||
void ClearErrorMsg() {
|
||||
_severity = SEVERITY_NULL;
|
||||
delete _userMsg; _userMsg = 0;
|
||||
delete _detailMsg; _detailMsg = 0;
|
||||
}
|
||||
void ClearErrorMsg() {
|
||||
_severity = SEVERITY_NULL;
|
||||
_userMsg.clear();
|
||||
_detailMsg.clear();
|
||||
}
|
||||
|
||||
// return the enum value of _severity
|
||||
Severity severity() const { return _severity; }
|
||||
// return _severity as a const char * in the std::string provided
|
||||
const char * severity(std::string &s) const;
|
||||
// return the enum value of _severity
|
||||
Severity severity() const { return _severity; }
|
||||
// return _severity as a const char * in the std::string provided
|
||||
void severity(std::string &s) const;
|
||||
Severity severity(Severity s) { return (_severity = s); }
|
||||
Severity GetCorrSeverity(const char *s);
|
||||
Severity GreaterSeverity(Severity s)
|
||||
{ return ((s < _severity) ? _severity = s : _severity); }
|
||||
Severity GreaterSeverity(Severity s) {
|
||||
return ((s < _severity) ? _severity = s : _severity);
|
||||
}
|
||||
|
||||
const char * UserMsg () const; // UserMsg is from String
|
||||
// inline const char * UserMsg() const { return _userMsg.c_str(); }
|
||||
inline const std::string UserMsg() const { return _userMsg; }
|
||||
void UserMsg ( const char *);
|
||||
void UserMsg( const std::string msg ) { _userMsg.assign( msg ); }
|
||||
|
||||
void AppendToUserMsg ( const char *);
|
||||
void AppendToUserMsg( const std::string & msg ) { _userMsg.append( msg ); }
|
||||
void PrependToUserMsg ( const char *);
|
||||
void AppendToUserMsg ( const char c);
|
||||
|
||||
const char * DetailMsg () const;
|
||||
// const char * DetailMsg() const { return _detailMsg.c_str(); }
|
||||
const std::string DetailMsg() const { return _detailMsg; }
|
||||
inline void DetailMsg( const std::string msg ) { _detailMsg.assign( msg ); }
|
||||
void DetailMsg ( const char *);
|
||||
void AppendToDetailMsg ( const char *);
|
||||
void AppendToDetailMsg( const std::string & msg ) { _detailMsg.append( msg ); }
|
||||
void PrependToDetailMsg ( const char *);
|
||||
void AppendToDetailMsg ( const char c);
|
||||
|
||||
Severity AppendFromErrorArg(ErrorDescriptor *err)
|
||||
{
|
||||
GreaterSeverity( err->severity() );
|
||||
AppendToDetailMsg( err->DetailMsg() );
|
||||
AppendToUserMsg( err->UserMsg() );
|
||||
return severity();
|
||||
Severity AppendFromErrorArg(ErrorDescriptor *err) {
|
||||
GreaterSeverity( err->severity() );
|
||||
AppendToDetailMsg( err->DetailMsg() );
|
||||
AppendToUserMsg( err->UserMsg() );
|
||||
return severity();
|
||||
}
|
||||
|
||||
DebugLevel debug_level() const { return _debug_level; }
|
||||
void debug_level(DebugLevel d) { _debug_level = d; }
|
||||
void SetOutput(ostream *o) { _out = o; }
|
||||
|
||||
/*
|
||||
// Enforcement _enforcement_level;
|
||||
ErrorDescriptor (Severity s = SEVERITY_NULL,
|
||||
Enforcement e = ENFORCE_OFF,
|
||||
DebugLevel d = DEBUG_OFF);
|
||||
Enforcement enforcement() const { return _enforcement_level; }
|
||||
void enforcement(Enforcement e) { _enforcement_level = e; }
|
||||
*/
|
||||
} ;
|
||||
|
||||
#endif
|
||||
@@ -682,6 +682,7 @@ getMCPrint( Express express, FILE * schema_h, FILE * schema_cc ) {
|
||||
|
||||
fprintf( schema_h,
|
||||
"\nSCLP23(Model_contents_ptr) GetModelContents(char *schemaName);\n" );
|
||||
fprintf( schema_cc, "/* Generated at %s:%d. */\n\n", __FILE__, __LINE__);
|
||||
fprintf( schema_cc, "%s%s%s%s",
|
||||
"// Generate a function to be called by Model to help it\n",
|
||||
"// create the necessary Model_contents without the\n",
|
||||
@@ -705,7 +706,7 @@ getMCPrint( Express express, FILE * schema_h, FILE * schema_cc ) {
|
||||
" return (SCLP23(Model_contents_ptr)) new SdaiModel_contents_%s; \n",
|
||||
SCHEMAget_name( schema ) );
|
||||
}
|
||||
fprintf( schema_cc, "}\n" );
|
||||
fprintf( schema_cc, " else return (SCLP23(Model_contents_ptr)) 0;\n}\n" );
|
||||
}
|
||||
|
||||
/******************************************************************
|
||||
|
||||
@@ -71,6 +71,7 @@ void print_schemas_separate( Express express, void * complexCol, FILES * files )
|
||||
/* First set all marks we'll be using to UNPROCESSED/NOTKNOWN: */
|
||||
initializeMarks( express );
|
||||
|
||||
//FIXME SdaiAll.cc:12:24: warning: unused variable ‘is’ [-Wunused-variable] (also for ui & ri)
|
||||
fprintf( files->create, " Interface_spec_ptr is;\n Used_item_ptr ui;\n Referenced_item_ptr ri;\n Uniqueness_rule_ptr ur;\n Where_rule_ptr wr;\n Global_rule_ptr gr;\n" );
|
||||
while( !complete ) {
|
||||
complete = TRUE;
|
||||
|
||||
@@ -67,6 +67,7 @@ void ComplexCollect::write( const char * fname )
|
||||
// First write to os the variables it will need:
|
||||
complex << " ComplexCollect *cc;\n";
|
||||
complex << " ComplexList *cl;\n";
|
||||
//FIXME compstructs.cc:26:50: warning: unused variable ‘next30’ [-Wunused-variable]
|
||||
complex << " EntList *node, *child, *next1, *next2, *next3, *next4,\n"
|
||||
<< " *next5, *next6, *next7, *next8, *next9, *next10,\n"
|
||||
<< " *next11, *next12, *next13, *next14, *next15,\n"
|
||||
|
||||
Reference in new issue
Block a user