Commit 60c6b3b7 authored by hrchilds's avatar hrchilds
Browse files

Update from January 3, 2005

git-svn-id: http://visit.ilight.com/svn/visit/trunk/src@388 18c085ea-50e0-402c-830e-de6fd14e8384
parent 72a07802
......@@ -38,6 +38,10 @@ class Pos;
// the true base class for expressions -- a List is a valid argument
// to a function but currently is not an Expression (i.e. ExprNode).
//
// Jeremy Meredith, Tue Dec 28 11:21:13 PST 2004
// Added the original text for an argument to ArgExpr because it is
// useful for implementing macros.
//
// ****************************************************************************
class EXPR_API ExprNode : public ExprParseTreeNode
{
......@@ -164,18 +168,21 @@ class EXPR_API ListExpr : public ExprParseTreeNode
class EXPR_API ArgExpr : public ExprParseTreeNode
{
public:
ArgExpr(const Pos &p, ExprParseTreeNode *e)
: ExprParseTreeNode(p), id(NULL), expr(e) {}
ArgExpr(const Pos &p, ExprParseTreeNode *e, const std::string &t)
: ExprParseTreeNode(p), id(NULL), expr(e), text(t) {}
virtual ~ArgExpr() { }
ArgExpr(const Pos &p, Identifier *i, ExprParseTreeNode *e)
: ExprParseTreeNode(p), id(i), expr(e) {}
ArgExpr(const Pos &p, Identifier *i, ExprParseTreeNode *e,
const std::string &t)
: ExprParseTreeNode(p), id(i), expr(e), text(t) {}
virtual void PrintNode(ostream &o);
Identifier *GetId(void) {return id;};
ExprParseTreeNode *GetExpr(void) {return expr;};
virtual const std::string GetTypeName() { return "Arg"; }
const std::string &GetText(void) const { return text; };
protected:
Identifier *id;
ExprParseTreeNode *expr;
std::string text;
};
class EXPR_API ArgsExpr : public ExprParseTreeNode
......
......@@ -84,6 +84,10 @@ ExprParser::ExprParser(ExprNodeFactory *f) : Parser(), factory(f)
// since no filter can yet support expressions anyway. We can
// change it back later if we ever support it.
//
// Jeremy Meredith, Tue Dec 28 11:22:13 PST 2004
// Added the original text for an argument to ArgExpr because it is
// useful for implementing macros.
//
// ****************************************************************************
ParseTreeNode*
ExprParser::ApplyRule(const Symbol &sym,
......@@ -278,13 +282,14 @@ ExprParser::ApplyRule(const Symbol &sym,
switch (rule->GetID())
{
case 0:
node = new ArgExpr(p, (ExprParseTreeNode*)E[0]);
node = new ArgExpr(p, (ExprParseTreeNode*)E[0], p.GetText(text));
break;
case 1:
node = new ArgExpr(p, ((Identifier*)T[0]),(ExprParseTreeNode*)E[2]);
node = new ArgExpr(p, ((Identifier*)T[0]),(ExprParseTreeNode*)E[2],
p.GetText(text));
break;
case 2:
node = new ArgExpr(p, (ExprParseTreeNode*)E[0]);
node = new ArgExpr(p, (ExprParseTreeNode*)E[0], p.GetText(text));
break;
}
} else if (sym == PathSpec)
......@@ -436,7 +441,8 @@ ExprParser::ApplyRule(const Symbol &sym,
// debugging and can still go to cerr.
//
// Hank Childs, Fri Aug 8 08:13:21 PDT 2003
// Have error messages be issued in a way that it is indepent of component.
// Have error messages be issued in a way that it is independent of
// component.
//
// Jeremy Meredith, Fri Aug 15 12:49:01 PDT 2003
// Added the EMT_EXCEPTION type, and renamed EMT_VIEWER to EMT_COMPONENT.
......@@ -445,11 +451,18 @@ ExprParser::ApplyRule(const Symbol &sym,
// Refactored. There's a new base class for the ExprParser and the
// return types became more general.
//
// Jeremy Meredith, Tue Dec 28 11:18:37 PST 2004
// Made the current text a data member to help with macro support.
//
// Hank Childs, Tue Dec 28 16:14:47 PST 2004
// Rename GetText and PrintText to GetErrorText and PrintErrorText.
//
// ****************************************************************************
ParseTreeNode*
ExprParser::Parse(const std::string &s)
{
string text(s);
text = s;
// Change weird spacing (tabs, newlines) to normal ones.
// This will make printing error messages later much easier.
for (int i=0; i<text.length(); i++)
......@@ -472,14 +485,14 @@ ExprParser::Parse(const std::string &s)
// This should only occur during debugging; print to cerr anyway
cerr << e.Message() << endl;
cerr << "Rule = " << *(e.GetRule()) << endl;
e.GetPos().PrintText(cerr, text);
e.GetPos().PrintErrorText(cerr, text);
return NULL;
}
catch (ParseException &e)
{
char error[1024];
SNPRINTF(error, 1024, "%s\n%s",
e.Message(), e.GetPos().GetText(text).c_str());
e.Message(), e.GetPos().GetErrorText(text).c_str());
if (errorMessageTarget == EMT_COMPONENT)
{
......
......@@ -32,6 +32,10 @@
// Refactored. There's a new base class for the ExprParser and the
// return types became more general.
//
// Jeremy Meredith, Tue Dec 28 11:18:09 PST 2004
// Added the current parse text as a data member to help with macro
// support.
//
// ****************************************************************************
class EXPR_API ExprParser : public Parser
......@@ -58,6 +62,8 @@ class EXPR_API ExprParser : public Parser
std::vector<Token*>&, Pos);
private:
std::string text; // the current parse text
ExprScanner scanner;
ExprNodeFactory *factory;
static ErrorMessageTarget errorMessageTarget;
......
......@@ -22,6 +22,9 @@
// I replaced min,max with Minimum,Maximum since the former are defined
// as macros that cause compilation errors on Windows.
//
// Hank Childs, Tue Dec 28 16:04:59 PST 2004
// Renamed GetText to be GetErrorText. Added new method called GetText.
//
// ****************************************************************************
class PARSER_API Pos
......@@ -41,7 +44,7 @@ class PARSER_API Pos
void operator=(const Pos &p) { p1=p.p1; p2=p.p2; }
bool IsNull() { return (p1 == -1) && (p2 == -1); }
void PrintText(ostream &o, const std::string &s) const
void PrintErrorText(ostream &o, const std::string &s) const
{
int i;
o << s.c_str() << endl;
......@@ -51,7 +54,7 @@ class PARSER_API Pos
o << '^';
o << endl;
}
std::string GetText(const std::string &s) const
std::string GetErrorText(const std::string &s) const
{
int i;
std::string msg = s + '\n';
......@@ -62,6 +65,14 @@ class PARSER_API Pos
msg += '\n';
return msg;
}
std::string GetText(const std::string &s) const
{
std::string msg = "";
if (s.length() < p1 || s.length() < p2 || p1 < 0)
return msg;
msg = s.substr(p1, p2-p1+1);
return msg;
}
};
#endif
......@@ -231,6 +231,9 @@
# Kathleen Bonnell, Mon Aug 16 11:39:46 PDT 2004
# Added InteractorAttributes.
#
# Jeremy Meredith, Tue Nov 2 11:37:34 PST 2004
# Added SimulationCommand.
#
##############################################################################
##
......@@ -309,6 +312,7 @@ SRC= AnimationAttributes.C \
SILRestrictionAttributes.C \
SimilarityTransformAttributes.C \
SimpleObserver.C \
SimulationCommand.C \
SphereAttributes.C \
StatusAttributes.C \
Subject.C \
......
#include <SimulationCommand.h>
#include <DataNode.h>
//
// Enum conversion methods for SimulationCommand::Command
//
static const char *Command_strings[] = {
"NoCommand", "Pause", "Step",
"Run"};
std::string
SimulationCommand::Command_ToString(SimulationCommand::Command t)
{
int index = int(t);
if(index < 0 || index >= 4) index = 0;
return Command_strings[index];
}
std::string
SimulationCommand::Command_ToString(int t)
{
int index = (t < 0 || t >= 4) ? 0 : t;
return Command_strings[index];
}
bool
SimulationCommand::Command_FromString(const std::string &s, SimulationCommand::Command &val)
{
val = SimulationCommand::NoCommand;
for(int i = 0; i < 4; ++i)
{
if(s == Command_strings[i])
{
val = (Command)i;
return true;
}
}
return false;
}
// ****************************************************************************
// Method: SimulationCommand::SimulationCommand
//
// Purpose:
// Constructor for the SimulationCommand class.
//
// Note: Autogenerated by xml2atts.
//
// Programmer: xml2atts
// Creation: Tue Nov 2 11:32:19 PDT 2004
//
// Modifications:
//
// ****************************************************************************
SimulationCommand::SimulationCommand() : AttributeSubject("i")
{
commandType = NoCommand;
}
// ****************************************************************************
// Method: SimulationCommand::SimulationCommand
//
// Purpose:
// Copy constructor for the SimulationCommand class.
//
// Note: Autogenerated by xml2atts.
//
// Programmer: xml2atts
// Creation: Tue Nov 2 11:32:19 PDT 2004
//
// Modifications:
//
// ****************************************************************************
SimulationCommand::SimulationCommand(const SimulationCommand &obj) : AttributeSubject("i")
{
commandType = obj.commandType;
SelectAll();
}
// ****************************************************************************
// Method: SimulationCommand::~SimulationCommand
//
// Purpose:
// Destructor for the SimulationCommand class.
//
// Note: Autogenerated by xml2atts.
//
// Programmer: xml2atts
// Creation: Tue Nov 2 11:32:19 PDT 2004
//
// Modifications:
//
// ****************************************************************************
SimulationCommand::~SimulationCommand()
{
// nothing here
}
// ****************************************************************************
// Method: SimulationCommand::operator =
//
// Purpose:
// Assignment operator for the SimulationCommand class.
//
// Note: Autogenerated by xml2atts.
//
// Programmer: xml2atts
// Creation: Tue Nov 2 11:32:19 PDT 2004
//
// Modifications:
//
// ****************************************************************************
SimulationCommand&
SimulationCommand::operator = (const SimulationCommand &obj)
{
if (this == &obj) return *this;
commandType = obj.commandType;
SelectAll();
return *this;
}
// ****************************************************************************
// Method: SimulationCommand::operator ==
//
// Purpose:
// Comparison operator == for the SimulationCommand class.
//
// Note: Autogenerated by xml2atts.
//
// Programmer: xml2atts
// Creation: Tue Nov 2 11:32:19 PDT 2004
//
// Modifications:
//
// ****************************************************************************
bool
SimulationCommand::operator == (const SimulationCommand &obj) const
{
// Create the return value
return ((commandType == obj.commandType));
}
// ****************************************************************************
// Method: SimulationCommand::operator !=
//
// Purpose:
// Comparison operator != for the SimulationCommand class.
//
// Note: Autogenerated by xml2atts.
//
// Programmer: xml2atts
// Creation: Tue Nov 2 11:32:19 PDT 2004
//
// Modifications:
//
// ****************************************************************************
bool
SimulationCommand::operator != (const SimulationCommand &obj) const
{
return !(this->operator == (obj));
}
// ****************************************************************************
// Method: SimulationCommand::TypeName
//
// Purpose:
// Type name method for the SimulationCommand class.
//
// Note: Autogenerated by xml2atts.
//
// Programmer: xml2atts
// Creation: Tue Nov 2 11:32:19 PDT 2004
//
// Modifications:
//
// ****************************************************************************
const std::string
SimulationCommand::TypeName() const
{
return "SimulationCommand";
}
// ****************************************************************************
// Method: SimulationCommand::CopyAttributes
//
// Purpose:
// CopyAttributes method for the SimulationCommand class.
//
// Note: Autogenerated by xml2atts.
//
// Programmer: xml2atts
// Creation: Tue Nov 2 11:32:19 PDT 2004
//
// Modifications:
//
// ****************************************************************************
bool
SimulationCommand::CopyAttributes(const AttributeGroup *atts)
{
if(TypeName() != atts->TypeName())
return false;
// Call assignment operator.
const SimulationCommand *tmp = (const SimulationCommand *)atts;
*this = *tmp;
return true;
}
// ****************************************************************************
// Method: SimulationCommand::CreateCompatible
//
// Purpose:
// CreateCompatible method for the SimulationCommand class.
//
// Note: Autogenerated by xml2atts.
//
// Programmer: xml2atts
// Creation: Tue Nov 2 11:32:19 PDT 2004
//
// Modifications:
//
// ****************************************************************************
AttributeSubject *
SimulationCommand::CreateCompatible(const std::string &tname) const
{
AttributeSubject *retval = 0;
if(TypeName() == tname)
retval = new SimulationCommand(*this);
// Other cases could go here too.
return retval;
}
// ****************************************************************************
// Method: SimulationCommand::NewInstance
//
// Purpose:
// NewInstance method for the SimulationCommand class.
//
// Note: Autogenerated by xml2atts.
//
// Programmer: xml2atts
// Creation: Tue Nov 2 11:32:19 PDT 2004
//
// Modifications:
//
// ****************************************************************************
AttributeSubject *
SimulationCommand::NewInstance(bool copy) const
{
AttributeSubject *retval = 0;
if(copy)
retval = new SimulationCommand(*this);
else
retval = new SimulationCommand;
return retval;
}
// ****************************************************************************
// Method: SimulationCommand::SelectAll
//
// Purpose:
// Selects all attributes.
//
// Note: Autogenerated by xml2atts.
//
// Programmer: xml2atts
// Creation: Tue Nov 2 11:32:19 PDT 2004
//
// Modifications:
//
// ****************************************************************************
void
SimulationCommand::SelectAll()
{
Select(0, (void *)&commandType);
}
///////////////////////////////////////////////////////////////////////////////
// Set property methods
///////////////////////////////////////////////////////////////////////////////
void
SimulationCommand::SetCommandType(SimulationCommand::Command commandType_)
{
commandType = commandType_;
Select(0, (void *)&commandType);
}
///////////////////////////////////////////////////////////////////////////////
// Get property methods
///////////////////////////////////////////////////////////////////////////////
SimulationCommand::Command
SimulationCommand::GetCommandType() const
{
return Command(commandType);
}
///////////////////////////////////////////////////////////////////////////////
// Keyframing methods
///////////////////////////////////////////////////////////////////////////////
// ****************************************************************************
// Method: SimulationCommand::GetFieldName
//
// Purpose:
// This method returns the name of a field given its index.
//
// Note: Autogenerated by xml2atts.
//
// Programmer: xml2atts
// Creation: Tue Nov 2 11:32:19 PDT 2004
//
// Modifications:
//
// ****************************************************************************
std::string
SimulationCommand::GetFieldName(int index) const
{
switch (index)
{
case 0: return "Command Type";
default: return "invalid index";
}
}
// ****************************************************************************
// Method: SimulationCommand::GetFieldType
//
// Purpose:
// This method returns the type of a field given its index.
//
// Note: Autogenerated by xml2atts.
//
// Programmer: xml2atts
// Creation: Tue Nov 2 11:32:19 PDT 2004
//
// Modifications:
//
// ****************************************************************************
AttributeGroup::FieldType
SimulationCommand::GetFieldType(int index) const
{
switch (index)
{
case 0: return FieldType_enum;
default: return FieldType_unknown;
}
}
// ****************************************************************************
// Method: SimulationCommand::GetFieldTypeName
//
// Purpose:
// This method returns the name of a field type given its index.
//
// Note: Autogenerated by xml2atts.
//
// Programmer: xml2atts
// Creation: Tue Nov 2 11:32:19 PDT 2004
//
// Modifications:
//
// ****************************************************************************
std::string
SimulationCommand::GetFieldTypeName(int index) const
{
switch (index)
{
case 0: return "enum";
default: return "invalid index";
}
}
// ****************************************************************************
// Method: SimulationCommand::FieldsEqual
//
// Purpose:
// This method compares two fields and return true if they are equal.
//
// Note: Autogenerated by xml2atts.
//
// Programmer: xml2atts
// Creation: Tue Nov 2 11:32:19 PDT 2004
//
// Modifications:
//
// ****************************************************************************
bool
SimulationCommand::FieldsEqual(int index_, const AttributeGroup *rhs) const
{
const SimulationCommand &obj = *((const SimulationCommand*)rhs);
bool retval = false;
switch (index_)
{