Commit cf0b474a authored by hrchilds's avatar hrchilds

Update from February 8, 2005

git-svn-id: http://visit.ilight.com/svn/visit/trunk/src@409 18c085ea-50e0-402c-830e-de6fd14e8384
parent d2bee180
......@@ -88,6 +88,9 @@ ExprParser::ExprParser(ExprNodeFactory *f) : Parser(), factory(f)
// Added the original text for an argument to ArgExpr because it is
// useful for implementing macros.
//
// Hank Childs, Fri Jan 28 14:07:18 PST 2005
// Use exception macros.
//
// ****************************************************************************
ParseTreeNode*
ExprParser::ApplyRule(const Symbol &sym,
......@@ -392,7 +395,7 @@ ExprParser::ApplyRule(const Symbol &sym,
{
const string & id = ((Identifier*)T[3])->GetVal();
if (id.length() != 1)
throw SyntacticException(E[3]->GetPos(),
EXCEPTION2(SyntacticException,E[3]->GetPos(),
"needs to be 'i', 'c', or 't'");
char c = id[0];
TimeExpr::Type t;
......@@ -403,7 +406,7 @@ ExprParser::ApplyRule(const Symbol &sym,
else if (c == 'i' || c == 'I')
t = TimeExpr::Index;
else
throw SyntacticException(E[3]->GetPos(),
EXCEPTION2(SyntacticException, E[3]->GetPos(),
"needs to be 'i', 'c', or 't'");
node = new TimeExpr(p, (ListExpr*)(E[1]), t);
break;
......@@ -457,6 +460,9 @@ ExprParser::ApplyRule(const Symbol &sym,
// Hank Childs, Tue Dec 28 16:14:47 PST 2004
// Rename GetText and PrintText to GetErrorText and PrintErrorText.
//
// Hank Childs, Fri Jan 28 14:07:18 PST 2005
// Use exception macros.
//
// ****************************************************************************
ParseTreeNode*
ExprParser::Parse(const std::string &s)
......@@ -468,7 +474,7 @@ ExprParser::Parse(const std::string &s)
for (int i=0; i<text.length(); i++)
if (text[i] == '\t' || text[i] == '\n') text[i] = ' ';
try
TRY
{
Init();
scanner.SetInput(text);
......@@ -480,15 +486,15 @@ ExprParser::Parse(const std::string &s)
ParseOneToken(token);
}
}
catch (UnhandledReductionException &e)
CATCH (UnhandledReductionException &e)
{
// This should only occur during debugging; print to cerr anyway
cerr << e.Message() << endl;
cerr << "Rule = " << *(e.GetRule()) << endl;
e.GetPos().PrintErrorText(cerr, text);
return NULL;
CATCH_RETURN2(1, NULL);
}
catch (ParseException &e)
CATCH (ParseException &e)
{
char error[1024];
SNPRINTF(error, 1024, "%s\n%s",
......@@ -507,8 +513,9 @@ ExprParser::Parse(const std::string &s)
EXCEPTION1(InvalidExpressionException, error);
}
return NULL;
CATCH_RETURN2(1, NULL);
}
ENDTRY
return GetParseTree();
}
......
......@@ -154,7 +154,7 @@ ExprScanner::GetAcceptToken(const Pos &pos, const std::string &parsed, int state
case 12:
return new Space(pos, parsed);
}
throw LexicalException(pos);
EXCEPTION1(LexicalException, pos);
}
// ****************************************************************************
......@@ -270,9 +270,9 @@ ExprScanner::ScanOneToken()
if (lastacceptstate == -1)
{
if (lookahead == 0)
throw UnexpectedEndException(pos);
EXCEPTION1(UnexpectedEndException, pos)
else
throw LexicalException(pos);
EXCEPTION1(LexicalException, pos);
}
UpdateScanState(lastacceptstring);
......
......@@ -2,6 +2,7 @@
#define PARSEEXEPTION_H
#include "Pos.h"
#include <VisItException.h>
#include <snprintf.h>
class Rule;
......@@ -25,8 +26,11 @@ class Rule;
// Added a SyntacticException with no specific token type name, for the
// times that information is not readily available.
//
// Hank Childs, Fri Jan 28 14:57:14 PST 2005
// Inherit from VisItException.
//
// ****************************************************************************
class ParseException
class ParseException : public VisItException
{
public:
ParseException(Pos p) : pos(p) { }
......
......@@ -81,6 +81,9 @@ Parser::Shift(Token *t, int s)
// Jeremy Meredith, Wed Nov 24 09:02:32 PST 2004
// Added list of tokens. Also, significant refactoring.
//
// Hank Childs, Fri Jan 28 13:19:33 PST 2005
// Use exception macros.
//
// ****************************************************************************
void
Parser::Reduce(int r)
......@@ -111,7 +114,7 @@ Parser::Reduce(int r)
if (!node)
{
throw UnhandledReductionException(p, rule);
EXCEPTION2(UnhandledReductionException, p, rule);
}
node->GetPos().Join(p);
......@@ -177,6 +180,9 @@ Parser::PrintState(ostream &o)
// Added list of allowed tokens to the error message. Did not yet
// enable it by default because it may be exposing the guts too much.
//
// Hank Childs, Fri Jan 28 13:19:33 PST 2005
// Use exception macros.
//
// ****************************************************************************
void
Parser::ParseOneToken(Token *t)
......@@ -203,7 +209,9 @@ Parser::ParseOneToken(Token *t)
else
{
if (t->GetType() == EOF_TOKEN_ID)
throw UnexpectedEndException(t->GetPos());
{
EXCEPTION1(UnexpectedEndException, t->GetPos());
}
else
{
#ifdef DEBUG
......@@ -217,9 +225,9 @@ Parser::ParseOneToken(Token *t)
{
allowed += it->first->GetDisplayString() + " ";
}
throw SyntacticException(t->GetPos(), allowed);
EXCEPTION2(SyntacticException, t->GetPos(), allowed);
#else
throw SyntacticException(t->GetPos());
EXCEPTION1(SyntacticException, t->GetPos());
#endif
}
}
......
......@@ -73,7 +73,7 @@ class TestScanner : public Scanner
}
if (input[pos] < 'a' || input[pos] > 'z')
throw LexicalException(pos);
EXCEPTION1(LexicalException, pos);
string var;
while (input[pos] >= 'a' && input[pos] <= 'z')
......@@ -150,6 +150,12 @@ class TestGrammar : public Grammar
// ----------------------------------------------------------------------------
// Parser
//
// Modifications:
//
// Hank Childs, Fri Jan 28 15:43:04 PST 2005
// Use expression macros.
//
// ----------------------------------------------------------------------------
class TestParser : public Parser
{
......@@ -209,7 +215,7 @@ class TestParser : public Parser
ParseTreeNode *Parse(const string &input)
{
try
TRY
{
Init();
TestScanner scanner;
......@@ -220,25 +226,26 @@ class TestParser : public Parser
ParseOneToken(token);
}
}
catch (UnhandledReductionException &e)
CATCH (UnhandledReductionException &e)
{
// This should only occur during debugging; print to cerr anyway
cerr << e.Message() << endl;
cerr << "Rule = " << *(e.GetRule()) << endl;
cerr << e.GetPos().GetText(input) << endl;
return NULL;
CATCH_RETURN2(1, NULL);
}
catch (ParseException &e)
CATCH (ParseException &e)
{
cerr << e.Message() << endl;
cerr << e.GetPos().GetText(input) << endl;
return NULL;
CATCH_RETURN2(1, NULL);
}
catch (...)
CATCHALL (...)
{
cerr << "Unknown exception!\n";
return NULL;
CATCH_RETURN2(1, NULL);
}
ENDTRY
return GetParseTree();
}
......
......@@ -49,10 +49,14 @@ using std::sort;
// Jeremy Meredith, Fri Feb 28 12:33:52 PST 2003
// Added initialization of loadOnDemand.
//
// Jeremy Meredith, Tue Feb 8 08:40:57 PST 2005
// Added initialization of pluginInitErrors.
//
// ****************************************************************************
PluginManager::PluginManager(const string &mgr)
{
pluginInitErrors = "";
loadOnDemand = false;
managerName = mgr;
category = no_category;
......@@ -502,6 +506,11 @@ PluginManager::GetPluginList(vector<pair<string,string> > &libs)
// Made it only match I and GSVE plugins from the same directory.
// Made it refuse to load more than one plugin with the same id.
//
// Jeremy Meredith, Tue Feb 8 09:02:32 PST 2005
// Added logic to confirm that the version the plugin was generated
// with matches the current version of VisIt. Added code to store
// the appropriate list of errors.
//
// ****************************************************************************
void
......@@ -511,6 +520,9 @@ PluginManager::ReadPluginInfo()
vector<pair<string,string> > libs;
GetPluginList(libs);
// Keep track of plugin version errors
vector<string> pluginsWithWrongVersion;
// Read the plugin info for each plugin in the libs list.
string ext(PLUGIN_EXTENSION);
for (int i=0; i<libs.size(); i++)
......@@ -548,7 +560,18 @@ PluginManager::ReadPluginInfo()
// We're okay, now try to open the plugin info.
string pluginFile(dirname + SLASH_STRING + filename);
PluginOpen(pluginFile);
bool success = LoadGeneralPluginInfo();
const char **VisItPluginVersion =
(const char**)PluginSymbol("VisItPluginVersion");
bool success;
if (!VisItPluginVersion || strcmp(*VisItPluginVersion, VERSION) != 0)
{
pluginsWithWrongVersion.push_back(pluginFile);
success = false;
}
else
{
success = LoadGeneralPluginInfo();
}
PluginClose();
if (success)
......@@ -561,6 +584,29 @@ PluginManager::ReadPluginInfo()
debug1 << "Succesfully loaded info about "
<< ids.size() << " " << managerName.c_str() << " plugins.\n";
if (pluginsWithWrongVersion.size() != 0)
{
pluginInitErrors += "The following plugins were built with an old "
"version of VisIt. Please either rebuild the plugins associated "
"with these files (after running xml2makefile) or delete them:\n";
for (int i=0; i<pluginsWithWrongVersion.size(); i++)
{
string pluginFile(pluginsWithWrongVersion[i]);
string ext(PLUGIN_EXTENSION);
int slashPos = pluginFile.rfind("/");
string dirname = pluginFile.substr(0, slashPos);
int suffixLen = (pluginFile.find("_ser") != -1 ||
pluginFile.find("_par") != -1) ? 4 : 0;
int len = pluginFile.size() - slashPos - suffixLen - 5 -
managerName.size() - ext.size();
string pluginPrefix(pluginFile.substr(slashPos + 5, len));
pluginInitErrors += string(" the ")+pluginPrefix+
" plugin in the directory "+dirname+"\n";
}
}
}
// ****************************************************************************
......@@ -630,6 +676,9 @@ PluginManager::LoadPluginsNow()
// and fail to load the plugin, as long as we're not the viewer or
// the gui.
//
// Hank Childs, Fri Jan 28 13:19:33 PST 2005
// Use catch return.
//
// ****************************************************************************
void
......@@ -671,7 +720,7 @@ PluginManager::LoadSinglePlugin(int index)
<< names[index].c_str()
<< " version " << versions[index].c_str()
<< " because it failed to open." << endl;
return;
CATCH_RETURN(1);
}
}
ENDTRY
......@@ -871,6 +920,29 @@ PluginManager::GetAllIndexFromName(const string &name) const
return pluginTypeIndex;
}
// ****************************************************************************
// Method: PluginManager::GetPluginInitializationErrors
//
// Purpose:
// Return errors generated by plugin initialization, then clear
// them out so we don't wind up reporting errors twice.
//
// Arguments:
// none
//
// Programmer: Jeremy Meredith
// Creation: February 7, 2005
//
// ****************************************************************************
std::string
PluginManager::GetPluginInitializationErrors()
{
std::string ret = pluginInitErrors;
pluginInitErrors = "";
return ret;
}
#if defined(__APPLE__)
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
......@@ -930,6 +1002,14 @@ const char *dlerror(void)
}
// ****************************************************************************
// Modifications:
//
// Hank Childs, Fri Jan 28 13:19:33 PST 2005
// Change comment style so escan will not pick up false positives.
//
// ****************************************************************************
void *dlopen(const char *path, int mode)
{
void *module = 0;
......@@ -970,8 +1050,8 @@ void *dlopen(const char *path, int mode)
}
break;
case NSObjectFileImageInappropriateFile:
/* It may have been a dynamic library rather
than a bundle, try to load it */
// It may have been a dynamic library rather
// than a bundle, try to load it
module = (void *)NSAddImage(path,
NSADDIMAGE_OPTION_RETURN_ON_ERROR);
break;
......@@ -1222,7 +1302,10 @@ PluginManager::ReadPluginDir(vector<pair<string,string> > &files)
// Creation: Fri Mar 29 11:58:42 PDT 2002
//
// Modifications:
//
// Jeremy Meredith, Tue Feb 8 09:06:53 PST 2005
// Told PluginSymbol not to complain if it could not find
// the g++ initialization code.
//
// ****************************************************************************
void
......@@ -1247,7 +1330,7 @@ PluginManager::PluginOpen(const string &pluginFile)
}
// Try to initialize static constructors. This is a g++ism.
void (*init)(void) = (void(*)(void))PluginSymbol("_GLOBAL__DI");
void (*init)(void) = (void(*)(void))PluginSymbol("_GLOBAL__DI", true);
if (init)
init();
#endif
......@@ -1283,7 +1366,7 @@ PluginManager::PluginOpen(const string &pluginFile)
// ****************************************************************************
void *
PluginManager::PluginSymbol(const string &symbol)
PluginManager::PluginSymbol(const string &symbol, bool noError)
{
void *retval;
#if defined(_WIN32)
......@@ -1299,7 +1382,7 @@ PluginManager::PluginSymbol(const string &symbol)
// function name. Here, we use the name of the plugin file to determine the
// name of the plugin so we can create the symbol that we're really after.
//
if(symbol.substr(0,3) == "Get")
if(symbol.substr(0,3) == "Get" || symbol == "VisItPluginVersion")
{
string ext(PLUGIN_EXTENSION);
int slashPos = openPlugin.rfind("/");
......@@ -1318,8 +1401,8 @@ PluginManager::PluginSymbol(const string &symbol)
retval = dlsym(handle, symbol.c_str());
#endif
// If the symbol was not found, print the error message.
if(retval == 0)
// If the symbol was not found, print the error message if appropriate.
if (retval == 0 && !noError)
debug5 << PluginError() << endl;
return retval;
......@@ -1366,6 +1449,10 @@ PluginManager::PluginError() const
// Jeremy Meredith, Tue Mar 18 13:24:05 PST 2003
// Added destruction of static objects.
//
// Jeremy Meredith, Tue Feb 8 09:06:53 PST 2005
// Told PluginSymbol not to complain if it could not find
// the g++ destruction code.
//
// ****************************************************************************
void
......@@ -1381,7 +1468,7 @@ PluginManager::PluginClose()
}
#else
// Try to destruct static objects. This is a g++ism.
void (*fini)(void) = (void(*)(void))PluginSymbol("_GLOBAL__DD");
void (*fini)(void) = (void(*)(void))PluginSymbol("_GLOBAL__DD", true);
if (fini)
fini();
......
......@@ -37,6 +37,13 @@
// Jeremy Meredith, Wed Nov 5 13:48:58 PST 2003
// Added ability to check if a plugin is enabled (by id).
//
// Jeremy Meredith, Mon Feb 7 18:55:26 PST 2005
// Added ability to check if any errors were generated when
// the plugins were initialized. Right now it is only used
// for detecting incompatible versions. Also, added ability
// for PluginSymbol to not print an error if requested to be
// silent about such things.
//
// ****************************************************************************
class PLUGIN_API PluginManager
......@@ -82,6 +89,8 @@ class PLUGIN_API PluginManager
std::string GetEnabledID(const int) const;
int GetEnabledIndex(const std::string &);
std::string GetPluginInitializationErrors();
protected:
PluginManager(const std::string&);
void ReadPluginInfo();
......@@ -96,7 +105,7 @@ class PLUGIN_API PluginManager
bool PluginLoaded(const std::string&);
void PluginOpen(const std::string &pluginFile);
void *PluginSymbol(const std::string &symbol);
void *PluginSymbol(const std::string &symbol,bool ne=false);
char *PluginError() const;
void PluginClose();
......@@ -139,6 +148,9 @@ class PLUGIN_API PluginManager
// arrays containing enabled plugins
std::vector<void*> loadedhandles;
std::vector<std::string> loadedids;
// accumlated plugin initialization errors
std::string pluginInitErrors;
};
#endif
......@@ -2078,6 +2078,9 @@ AttributeGroup::DeclareVectorString()
// Brad Whitlock, Tue Aug 29 10:30:02 PDT 2000
// I changed it so an empty or NULL format string is allowable.
//
// Hank Childs, Fri Jan 28 15:36:03 PST 2005
// Use exception macros.
//
// ****************************************************************************
void
......@@ -2141,7 +2144,7 @@ AttributeGroup::CreateTypeMap(const char *formatString)
DeclareVectorAttributeGroup();
break;
default:
throw BadDeclareFormatString();
EXCEPTION0(BadDeclareFormatString);
}
}
else
......@@ -2204,7 +2207,7 @@ AttributeGroup::CreateTypeMap(const char *formatString)
DeclareListBool();
break;
default:
throw BadDeclareFormatString();
EXCEPTION0(BadDeclareFormatString);
}
}
}
......
......@@ -5,6 +5,7 @@
#include <string>
#include <exception>
#include <visitstream.h>
#include <VisItException.h>
// Forward declaration
class AttributeGroup;
......@@ -58,6 +59,9 @@ class DataNode;
// Brad Whitlock, Thu Dec 9 15:04:41 PST 2004
// I added FieldType_variablename.
//
// Hank Childs, Fri Jan 28 15:36:03 PST 2005
// Re-inherit exceptions from VisItException.
//
// ****************************************************************************
class STATE_API AttributeGroup
......@@ -199,6 +203,6 @@ ostream& operator<<(ostream& os, const AttributeGroup&);
typedef std::vector<AttributeGroup *> AttributeGroupVector;
// An exception class
class BadDeclareFormatString : public std::exception { };
class BadDeclareFormatString : public VisItException { };
#endif
......@@ -2875,3 +2875,34 @@ avtStructuredDomainBoundaries::CalculateBoundaries(void)
}
// ****************************************************************************
// Method: avtStructuredDomainBoundaries::GetExtents
//
// Purpose:
// Get the extents of one domain.
//
// Arguments:
// domain the domain to get the extents of
// e the extents
//
// Programmer: Kathleen Bonnell
// Creation: February 8, 2005
//
// ****************************************************************************
void
avtStructuredDomainBoundaries::GetExtents(int domain, int e[6])
{
if (domain >= wholeBoundary.size())
EXCEPTION1(VisItException,
"avtStructuredDomainBoundaries: "
"targetted domain more than number of domains");
e[0] = wholeBoundary[domain].oldnextents[0];
e[1] = wholeBoundary[domain].oldnextents[1];
e[2] = wholeBoundary[domain].oldnextents[2];
e[3] = wholeBoundary[domain].oldnextents[3];
e[4] = wholeBoundary[domain].oldnextents[4];
e[5] = wholeBoundary[domain].oldnextents[5];
}
......@@ -164,6 +164,9 @@ class BoundaryHelperFunctions
// Hank Childs, Sat Aug 14 06:41:00 PDT 2004
// Added CreateGhostNodes.
//
// Kathleen Bonnell, Tue Feb 8 15:32:22 PST 2005
// Added GetExtents.
//
// ****************************************************************************
class DATABASE_API avtStructuredDomainBoundaries : public avtDomainBoundaries
......@@ -179,6 +182,8 @@ class DATABASE_API avtStructuredDomainBoundaries : public avtDomainBoundaries
void AddNeighbor(int domain, int d,int mi, int o[3], int e[6]);
void Finish(int domain);
void GetExtents(int domain, int e[6]);
// methods for cases where neighbors can be computed
void SetIndicesForRectGrid(int domain, int e[6]);
void SetIndicesForAMRPatch(int domain, int level, int e[6]);
......
......@@ -454,6 +454,9 @@ avtExpressionEvaluatorFilter::PerformRestriction(
// Kathleen Bonnell, Thu Apr 22 14:42:38 PDT 2004
// Moved code to new pipelineState method.
//
// Hank Childs, Mon Feb 7 16:41:36 PST 2005
// Fix memory leak.
//
// ****************************************************************************
void
......@@ -461,6 +464,11 @@ avtExpressionEvaluatorFilter::ReleaseData(void)
{
avtDatasetToDatasetFilter::ReleaseData();
pipelineState.ReleaseData();
if (termsrc != NULL)
{
delete termsrc;
termsrc = NULL;
}
}
// ****************************************************************************
......
......@@ -337,6 +337,9 @@ TetMIR::~TetMIR()
// Removed support for clean-zones-only. Leaving it in would have required
// more maintenance to this class than we would like to support.
//
// Hank Childs, Fri Jan 28 15:39:23 PST 2005
// Use exception macros.
//
// ****************************************************************************
bool
TetMIR::Reconstruct3DMesh(vtkDataSet *mesh, avtMaterial *mat_orig)
......@@ -618,6 +621,9 @@ TetMIR::Reconstruct3DMesh(vtkDataSet *mesh, avtMaterial *mat_orig)
// Removed support for clean-zones-only. Leaving it in would have required
// more maintenance to this class than we would like to support.
//
// Hank Childs, Fri Jan 28 15:36:03 PST 2005
// Use exception macros.
//
// ****************************************************************************
bool
TetMIR::Reconstruct2DMesh(vtkDataSet *mesh, avtMaterial *mat_orig)
......@@ -1923,6 +1929,9 @@ TetMIR::ReconstructCleanTri(int matno, int c, int npts, const int *c_ptr,
// Jeremy Meredith, Tue Jan 14 14:38:37 PST 2003
// Simplified the logic. The assertion was never called.
//
// Hank Childs, Fri Jan 28 15:36:03 PST 2005
// Use exception macros.
//
// ****************************************************************************
static double
FindIntersect(double a1, double b1, double a2, double b2)
......@@ -1932,7 +1941,7 @@ FindIntersect(double a1, double b1, double a2, double b2)
double c;
if (s2==s1) /* parallel */
throw;
EXCEPTION0(VisItException)
else if (a1==a2) /* meet at c=0 */
return 0;
else if (b1==b2) /* meet at c=1 */
......@@ -2000,6 +2009,9 @@ FindIntersect(double a1, double b1, double a2, double b2)
// Leave any created wedges whole. We will split them into tets only if
// they need to be.
//
// Hank Childs, Fri Jan 28 15:36:03 PST 2005
// Use exception macros.
//
// ****************************************************************************
void
TetMIR::MergeTetsHelper(TetList &tetlist, WedgeList &wedgelist,
......@@ -2147,7 +2159,7 @@ TetMIR::MergeTetsHelper(TetList &tetlist, WedgeList &wedgelist,
else
{
// Internal Error in MergeTetsHelper()
throw;
EXCEPTION0(VisItException);
}
}
......@@ -2192,6 +2204,9 @@ TetMIR::MergeTetsHelper(TetList &tetlist, WedgeList &wedgelist,
// Added a "forced material" where if it is >=0, any added tet will have
// the forced material instead of the normal requested material.
//
// Hank Childs, Fri Jan 28 15:36:03 PST 2005
// Use exception macros.
//
// ****************************************************************************
void
TetMIR::MergeTrisHelper(TriList &trilist, int c, int npts, const int *c_ptr,
......@@ -2282,7 +2297,7 @@ TetMIR::MergeTrisHelper(TriList &trilist, int c, int npts, const int *c_ptr,
else
{
// Internal Error in MergeTrisHelper()
throw;
EXCEPTION0(VisItException);
}
}
......
#include "Tetrahedralizer.h"
#include "mat3d_tet.h"
#include <vtkCell.h>
#include <VisItException.h>
#include <vector>
using std::vector;
......@@ -620,6 +621,9 @@ Tetrahedralizer::fill_tets_low()
// Hank Childs, Mon Oct 7 17:43:41 PDT 2002
// Remove costly VTK calls.
//
// Hank Childs, Fri Jan 28 15:43:04 PST 2005
// Use exception macros.
//
// ****************************************************************************
void
Tetrahedralizer::Tetrahedralize(MIROptions::SubdivisionLevel s, int celltype,
......@@ -648,7 +652,7 @@ Tetrahedralizer::Tetrahedralize(MIROptions::SubdivisionLevel s, int celltype,
case VTK_HEXAHEDRON: calc_hex_low(); break;
case VTK_WEDGE: calc_wdg_low(); break;
case VTK_PYRAMID: calc_pyr_low(); break;
default: throw;
default: EXCEPTION0(VisItException);
}