Skip to content

Commit 134ba0e

Browse files
author
chapados
committed
* Introduce the PLASSERT and PLASSERT_MSG macros in plerror.h
* Global search-and-replace of assert() to PLASSERT() * Please use PLASSERT from now on.
1 parent 2643d5f commit 134ba0e

File tree

153 files changed

+692
-686
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

153 files changed

+692
-686
lines changed

commands/PLearnCommands/HTMLHelpCommand.cc

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ void HTMLHelpCommand::copySnippet(ostream& os, const string& document)
146146

147147
void HTMLHelpCommand::helpIndex()
148148
{
149-
assert( config );
149+
PLASSERT( config );
150150
ofstream os((config->output_dir + "/" + "index.html").c_str());
151151
helpIndex(os, config);
152152
}
@@ -178,7 +178,7 @@ void HTMLHelpCommand::helpIndex(ostream& os, const HTMLHelpConfig* config)
178178

179179
void HTMLHelpCommand::helpCommands()
180180
{
181-
assert( config );
181+
PLASSERT( config );
182182
ofstream os((config->output_dir + "/" + "command_index.html").c_str());
183183
helpCommands(os, config);
184184

@@ -226,7 +226,7 @@ void HTMLHelpCommand::helpCommands(ostream& os, const HTMLHelpConfig* config)
226226

227227
void HTMLHelpCommand::helpOnCommand(const string& theCommand)
228228
{
229-
assert( config );
229+
PLASSERT( config );
230230
ofstream os((config->output_dir + "/" + "command_"+theCommand+".html").c_str());
231231
helpOnCommand(theCommand, os, config);
232232
}
@@ -260,7 +260,7 @@ void HTMLHelpCommand::helpOnCommand(const string& theCommand, ostream& os,
260260

261261
void HTMLHelpCommand::helpClasses()
262262
{
263-
assert( config );
263+
PLASSERT( config );
264264
ofstream os((config->output_dir + "/" + "class_index.html").c_str());
265265
helpClasses(os, config);
266266

@@ -307,7 +307,7 @@ void HTMLHelpCommand::helpClasses(ostream& os, const HTMLHelpConfig* config)
307307

308308
void HTMLHelpCommand::helpOnClass(const string& classname)
309309
{
310-
assert( config );
310+
PLASSERT( config );
311311
ofstream out((config->output_dir + "/class_" + classname + ".html").c_str());
312312
helpOnClass(classname, out, config);
313313
}
@@ -463,7 +463,7 @@ void HTMLHelpCommand::helpOnClass(const string& classname, ostream& out,
463463
for ( ; it != end ; ++it ) {
464464
const string& method_name = it->first.first;
465465
const RemoteTrampoline* t = it->second;
466-
assert( t );
466+
PLASSERT( t );
467467
const RemoteMethodDoc& doc = t->documentation();
468468

469469
// Generate the method signature and argument-list table in HTML form

commands/PLearnCommands/Plide.cc

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ class PlideProgressPlugin : public ProgressBarPlugin
7171
PlideProgressPlugin(PythonCodeSnippet* python)
7272
: m_python(python)
7373
{
74-
assert( m_python );
74+
PLASSERT( m_python );
7575
}
7676

7777
//! Destructor releases all pending progress bars from GUI
@@ -97,7 +97,7 @@ class PlideProgressPlugin : public ProgressBarPlugin
9797

9898
PlideProgressPlugin::~PlideProgressPlugin()
9999
{
100-
assert( m_python );
100+
PLASSERT( m_python );
101101
for (map<ProgressBar*, int>::const_iterator it = m_progress_ids.begin(),
102102
end = m_progress_ids.end() ; it != end ; ++it)
103103
{
@@ -109,7 +109,7 @@ PlideProgressPlugin::~PlideProgressPlugin()
109109

110110
void PlideProgressPlugin::addProgressBar(ProgressBar* pb)
111111
{
112-
assert( pb && m_python );
112+
PLASSERT( pb && m_python );
113113
if (m_progress_ids.find(pb) == m_progress_ids.end()) {
114114
m_progress_ids[pb] =
115115
m_python->invoke("AllocateProgressBar", pb->title).as<int>();
@@ -118,7 +118,7 @@ void PlideProgressPlugin::addProgressBar(ProgressBar* pb)
118118

119119
void PlideProgressPlugin::killProgressBar(ProgressBar* pb)
120120
{
121-
assert( pb && m_python );
121+
PLASSERT( pb && m_python );
122122
map<ProgressBar*, int>::iterator found = m_progress_ids.find(pb);
123123
if (found != m_progress_ids.end()) {
124124
m_python->invoke("ReleaseProgressBar", int(found->second));
@@ -128,7 +128,7 @@ void PlideProgressPlugin::killProgressBar(ProgressBar* pb)
128128

129129
void PlideProgressPlugin::update(ProgressBar* pb, unsigned long newpos)
130130
{
131-
assert( pb && m_python );
131+
PLASSERT( pb && m_python );
132132
map<ProgressBar*, int>::const_iterator found = m_progress_ids.find(pb);
133133
if (found != m_progress_ids.end()) {
134134
int progress_id = found->second;
@@ -175,7 +175,7 @@ void PlideLogPStreamBuf::outputParameters(const string& module_name, int request
175175

176176
void PlideLogPStreamBuf::flush()
177177
{
178-
assert( st && m_python );
178+
PLASSERT( st && m_python );
179179
inherited::flush();
180180
if (! st->empty()) {
181181
m_python->invoke("LogAppend", m_module_name, m_requested_verbosity, *st);
@@ -208,7 +208,7 @@ class PlideLogPlugin : public PL_LogPlugin
208208
PStream& PlideLogPlugin::getStream(PStream::mode_t outmode, const string& module_name,
209209
int requested_verbosity)
210210
{
211-
assert( m_streambuf );
211+
PLASSERT( m_streambuf );
212212
m_pstream.setOutMode(outmode);
213213
m_streambuf->outputParameters(module_name, requested_verbosity);
214214
m_streambuf->flush();
@@ -375,7 +375,7 @@ PythonObjectWrapper Plide::helpIndex(const TVec<PythonObjectWrapper>& args) cons
375375
if (args.size() != 0)
376376
PLERROR("%sExpecting 0 argument; got %d", __FUNCTION__, args.size());
377377

378-
assert( m_help_config && m_help_command );
378+
PLASSERT( m_help_config && m_help_command );
379379
ostringstream os;
380380
m_help_command->helpIndex(os, m_help_config);
381381
return os.str();
@@ -386,7 +386,7 @@ PythonObjectWrapper Plide::helpCommands(const TVec<PythonObjectWrapper>& args) c
386386
if (args.size() != 0)
387387
PLERROR("%sExpecting 0 argument; got %d", __FUNCTION__, args.size());
388388

389-
assert( m_help_config && m_help_command );
389+
PLASSERT( m_help_config && m_help_command );
390390
ostringstream os;
391391
m_help_command->helpCommands(os, m_help_config);
392392
return os.str();
@@ -397,7 +397,7 @@ PythonObjectWrapper Plide::helpClasses(const TVec<PythonObjectWrapper>& args) co
397397
if (args.size() != 0)
398398
PLERROR("%sExpecting 0 argument; got %d", __FUNCTION__, args.size());
399399

400-
assert( m_help_config && m_help_command );
400+
PLASSERT( m_help_config && m_help_command );
401401
ostringstream os;
402402
m_help_command->helpClasses(os, m_help_config);
403403
return os.str();
@@ -408,7 +408,7 @@ PythonObjectWrapper Plide::helpOnCommand(const TVec<PythonObjectWrapper>& args)
408408
if (args.size() != 1)
409409
PLERROR("%sExpecting 1 argument; got %d", __FUNCTION__, args.size());
410410

411-
assert( m_help_config && m_help_command );
411+
PLASSERT( m_help_config && m_help_command );
412412
ostringstream os;
413413
m_help_command->helpOnCommand(args[0].as<string>(), os, m_help_config);
414414
return os.str();
@@ -419,7 +419,7 @@ PythonObjectWrapper Plide::helpOnClass(const TVec<PythonObjectWrapper>& args) co
419419
if (args.size() != 1)
420420
PLERROR("%sExpecting 1 argument; got %d", __FUNCTION__, args.size());
421421

422-
assert( m_help_config && m_help_command );
422+
PLASSERT( m_help_config && m_help_command );
423423
ostringstream os;
424424
m_help_command->helpOnClass(args[0].as<string>(), os, m_help_config);
425425
return os.str();
@@ -473,7 +473,7 @@ void Plide::executePyPLearn(const string& script_code, const string& root_dir) c
473473
PStream pyplearn_in = openString(script_code, PStream::plearn_ascii);
474474
PP<PyPLearnScript> pyplearn_script = new PyPLearnScript;
475475
pyplearn_in >> pyplearn_script;
476-
assert( pyplearn_script );
476+
PLASSERT( pyplearn_script );
477477

478478
PStream plearn_in = openString(pyplearn_script->getScript(),
479479
PStream::plearn_ascii);

plearn/base/ObjectGraphIterator.cc

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ ObjectOptionsIterator::ObjectOptionsIterator(const Object* root,
7272
{
7373
if (m_object) {
7474
m_options = &m_object->getOptionList();
75-
assert( m_options );
75+
PLASSERT( m_options );
7676

7777
if (m_options->size() > 0) {
7878
m_invalid = false;
@@ -97,7 +97,7 @@ bool ObjectOptionsIterator::operator==(const ObjectOptionsIterator& rhs) const
9797

9898
const Object* ObjectOptionsIterator::operator*() const
9999
{
100-
assert( !m_invalid && m_object && m_options );
100+
PLASSERT( !m_invalid && m_object && m_options );
101101

102102
if (m_max_index > 0)
103103
return (*m_options)[m_cur_option]->getIndexedObject(m_object,
@@ -109,7 +109,7 @@ const Object* ObjectOptionsIterator::operator*() const
109109

110110
string ObjectOptionsIterator::getCurrentOptionName() const
111111
{
112-
assert( !m_invalid && m_object && m_options );
112+
PLASSERT( !m_invalid && m_object && m_options );
113113
string optionname = (*m_options)[m_cur_option]->optionname();
114114
if (m_max_index > 0)
115115
optionname += '[' + tostring(m_cur_index) + ']';
@@ -119,20 +119,20 @@ string ObjectOptionsIterator::getCurrentOptionName() const
119119

120120
OptionBase::flag_t ObjectOptionsIterator::getCurrentOptionFlags() const
121121
{
122-
assert( !m_invalid && m_object && m_options );
122+
PLASSERT( !m_invalid && m_object && m_options );
123123
return (*m_options)[m_cur_option]->flags();
124124
}
125125

126126

127127
const ObjectOptionsIterator& ObjectOptionsIterator::operator++()
128128
{
129-
assert( !m_invalid && m_object && m_options );
129+
PLASSERT( !m_invalid && m_object && m_options );
130130

131131
do {
132132
// Start by considering current iteration within an indexable option
133133
if (m_max_index > 0) {
134134
++m_cur_index;
135-
assert( m_cur_index <= m_max_index );
135+
PLASSERT( m_cur_index <= m_max_index );
136136
if (m_cur_index < m_max_index)
137137
return *this;
138138
}
@@ -210,7 +210,7 @@ bool ObjectGraphIterator::operator==(const ObjectGraphIterator& rhs) const
210210

211211
const ObjectGraphIterator& ObjectGraphIterator::operator++()
212212
{
213-
assert( !invalid() );
213+
PLASSERT( !invalid() );
214214
for ( ++m_it ; m_it != m_end && m_isa_tester && !m_isa_tester(**this) ; ++m_it )
215215
continue;
216216
return *this;

plearn/base/ObjectGraphIterator.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,7 @@ class ObjectGraphIterator
235235
//! returns a null pointer.
236236
const Object* operator*() const
237237
{
238-
assert( !invalid() );
238+
PLASSERT( !invalid() );
239239
return m_it->first;
240240
}
241241

@@ -245,7 +245,7 @@ class ObjectGraphIterator
245245
//! constructed with the option compute_optnames set to 'false'.
246246
const string& getCurrentOptionName() const
247247
{
248-
assert( !invalid() );
248+
PLASSERT( !invalid() );
249249
return m_it->second;
250250
}
251251

plearn/base/Option.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ class Option : public OptionBase
143143
virtual int indexableSize(const Object* o) const
144144
{
145145
const ObjectType* oto = dynamic_cast<const ObjectType*>(o);
146-
assert( oto );
146+
PLASSERT( oto );
147147
return indexableObjectSize(oto->*ptr);
148148
}
149149

plearn/base/PDate.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ using namespace std;
5757
PDate PDate::lastDateOfMonth(int year, int month)
5858
{
5959
PDate date = PDate(year, month, int(lastDayOfMonth(year, month)));
60-
assert( date.isValid() );
60+
PLASSERT( date.isValid() );
6161
return date;
6262
}
6363

@@ -109,7 +109,7 @@ PDate::PDate(int julian_day)
109109
day = jb - jd - jf;
110110
month = (je>13) ? je-13 : je-1;
111111
year = (month>2) ? jc-4716 : jc-4715;
112-
assert( isValid() );
112+
PLASSERT( isValid() );
113113
}
114114

115115
PDate::PDate(string date)

plearn/base/PDateTime.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ void PDateTime::incHour(int hour_inc)
152152
////////////
153153
void PDateTime::incDay(int day_inc)
154154
{
155-
assert( day_inc >= 0 );
155+
PLASSERT( day_inc >= 0 );
156156
int new_day = int(day) + day_inc;
157157
int max_day = 31;
158158
if (month == 2) {
@@ -167,7 +167,7 @@ void PDateTime::incDay(int day_inc)
167167
return;
168168
}
169169
// We need to switch to next month.
170-
assert( max_day >= int(day) );
170+
PLASSERT( max_day >= int(day) );
171171
int days_to_next_month = max_day - int(day) + 1;
172172
month++;
173173
if (month == 13) {

plearn/base/PLearnDiff.cc

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -99,15 +99,15 @@ void PLearnDiff::build()
9999
///////////////////
100100
void PLearnDiff::addDiffPrefix(const string& prefix, int n)
101101
{
102-
assert( n >= 0 && n <= diffs.length() );
102+
PLASSERT( n >= 0 && n <= diffs.length() );
103103
int l = diffs.length() - 1;
104104
for (int j = 0; j < n; j++)
105105
diffs(l - j, 0) = prefix + diffs(l - j, 0);
106106
}
107107

108108
void addDiffPrefix(PLearnDiff* diffs, const string& prefix, int n)
109109
{
110-
assert( diffs );
110+
PLASSERT( diffs );
111111
diffs->addDiffPrefix(prefix, n);
112112
}
113113

@@ -132,7 +132,7 @@ int PLearnDiff::diff(const string& refer, const string& other, const string& nam
132132

133133
int diff(PLearnDiff* diffs, const string& refer, const string& other, const string& name)
134134
{
135-
assert( diffs );
135+
PLASSERT( diffs );
136136
return diffs->diff(refer, other, name);
137137
}
138138

@@ -149,7 +149,7 @@ void PLearnDiff::forget()
149149
////////////////////////////
150150
real get_absolute_tolerance(PLearnDiff* diffs)
151151
{
152-
assert( diffs );
152+
PLASSERT( diffs );
153153
return diffs->absolute_tolerance;
154154
}
155155

@@ -158,7 +158,7 @@ real get_absolute_tolerance(PLearnDiff* diffs)
158158
////////////////////////////
159159
real get_relative_tolerance(PLearnDiff* diffs)
160160
{
161-
assert( diffs );
161+
PLASSERT( diffs );
162162
return diffs->relative_tolerance;
163163
}
164164

plearn/base/PMemPool.cc

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ void PMemArena::deallocate(void* p)
8484
watermark += object_size;
8585
else {
8686
// Otherwise, add p to free_list
87-
assert( belongsToArena(p) );
87+
PLASSERT( belongsToArena(p) );
8888
void** new_free_head = static_cast<void**>(p);
8989
*new_free_head = free_list;
9090
free_list = new_free_head;
@@ -150,20 +150,20 @@ void PMemPool::deallocate(void* p)
150150
else {
151151
// Find arena from map
152152
map<void*,PMemArena*>::iterator arena_it = stormap.upper_bound(p);
153-
assert( arena_it != stormap.begin() );
153+
PLASSERT( arena_it != stormap.begin() );
154154
--arena_it;
155155
PMemArena* arena = arena_it->second;
156-
assert( arena && arena->belongsToArena(p));
156+
PLASSERT( arena && arena->belongsToArena(p));
157157
arena->deallocate(p);
158158
last_arena = arena;
159159
}
160160

161161
// Check to see if arena should be eliminated
162162
if (last_arena && last_arena->empty()) {
163163
map<void*,PMemArena*>::iterator arena_it = stormap.upper_bound(p);
164-
assert( arena_it != stormap.begin() );
164+
PLASSERT( arena_it != stormap.begin() );
165165
--arena_it;
166-
assert( last_arena == arena_it->second );
166+
PLASSERT( last_arena == arena_it->second );
167167
stormap.erase(arena_it);
168168
arenas.remove(last_arena);
169169
last_arena = 0;

plearn/base/ParentableObject.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ void ParentableObject::setParent(Object* parent)
180180

181181
void ParentableObject::checkParent() const
182182
{
183-
assert( m_parent );
183+
PLASSERT( m_parent );
184184
}
185185

186186

0 commit comments

Comments
 (0)