#include <TColStd_HSequenceOfHAsciiString.hxx>
#include <TCollection_HAsciiString.hxx>
#include <TCollection_AsciiString.hxx>
+#include <OSD_Environment.hxx>
#include <EDL_FunctionSignature.hxx>
#include <EDL_ProcedureSignature.hxx>
#include <Standard_PCharacter.hxx>
Standard_Integer DirCount = 1;
Handle(TColStd_HSequenceOfAsciiString) IncludeDirectory = GlobalInter->GetIncludeDirectory();
-
+
if (aFile != NULL) {
FILE *fic = 0L;
DirCount = 1;
#ifndef WNT
- if( !access(aFile, F_OK) )
+ if( !access(aFile, F_OK) )
#else
- if ( GetFileAttributes(aFile) != 0xFFFFFFFF )
+ if ( GetFileAttributes(aFile) != 0xFFFFFFFF )
#endif
{
if ( ( fic = fopen ( aFile, "r" ) ) != NULL ) {
const TCollection_AsciiString& adir = IncludeDirectory->Value(DirCount);
memcpy(tmpName, adir.ToCString(), adir.Length());
tmpName[adir.Length()] = '/';
- strcpy(&(tmpName[adir.Length()+1]),aFile);
-
+ strcpy(&(tmpName[adir.Length()+1]),aFile);
+
#ifndef WNT
- if( !access(tmpName, F_OK) )
+ if( !access(tmpName, F_OK) )
#else
- if ( GetFileAttributes(tmpName) != 0xFFFFFFFF )
+ if ( GetFileAttributes(tmpName) != 0xFFFFFFFF )
#endif
{
if ( ( fic = fopen ( tmpName, "r" ) ) != NULL ) {
IsFound = Standard_True;
}
}
-
+
//delete [] tmpName;
DirCount++;
}
-
+
if (fic) {
edlstring edlstr;
edlstr.str = (char *)aFile;
{
TCollection_AsciiString anAscName(aVariable);
char *realFilename = (char *)filename;
-
+
// we can open a file with a name defined by a string or a variable
//
if (myParameterType == EDL_VARIABLE) {
}
}
-EDL_Error EDL_Interpretor::AddVariable(const Standard_CString aVariable, const Standard_CString aValue)
+EDL_Error EDL_Interpretor::AddVariable (const Standard_CString theVariable,
+ const Standard_CString theValue)
{
- if (aVariable != NULL && aValue != NULL) {
- TCollection_AsciiString anAscName(aVariable);
-
- if (aVariable[0] != '%') {
+ if (theVariable != NULL && theValue != NULL)
+ {
+ TCollection_AsciiString aVarName (theVariable);
+ TCollection_AsciiString aValue (theValue);
+ if (theVariable[0] != '%')
+ {
// Raise
- //
- anAscName.AssignCat(" : wrong indirection...");
- EDL::PrintError(EDL_VARNOTFOUND,anAscName.ToCString());
+ aVarName.AssignCat (" : wrong indirection...");
+ EDL::PrintError (EDL_VARNOTFOUND, aVarName.ToCString());
Standard_NoSuchObject::Raise();
}
- if (mySymbolTable.IsBound(anAscName)) {
- mySymbolTable.ChangeFind(anAscName).SetValue(aValue);
+ Standard_Integer aValLen = aValue.Length();
+ if (aValLen > 3 && theValue[0] == '$' && theValue[1] == '{' && theValue[aValLen - 1] == '}')
+ {
+ OSD_Environment anEnvVar (aValue.SubString (3, aValLen - 1));
+ aValue = anEnvVar.Value();
}
- else {
- EDL_Variable aVar(aVariable,aValue);
- mySymbolTable.Bind(anAscName,aVar);
+
+ if (mySymbolTable.IsBound (aVarName))
+ {
+ mySymbolTable.ChangeFind (aVarName).SetValue (aValue.ToCString());
+ }
+ else
+ {
+ EDL_Variable aEdlVar (theVariable, aValue.ToCString());
+ mySymbolTable.Bind (aVarName, aEdlVar);
}
}
- else {
+ else
+ {
return EDL_SYNTAXERROR;
}
EDL_Variable& EDL_Interpretor::GetVariable(const Standard_CString aVariable)
{
if (aVariable != NULL) {
-
+
TCollection_AsciiString anAscName(aVariable);
if (mySymbolTable.IsBound(anAscName)) {
Standard_Boolean EDL_Interpretor::IsDefined(const Standard_CString aVariable) const
{
if (aVariable != NULL) {
-
+
TCollection_AsciiString anAscName(aVariable);
if (mySymbolTable.IsBound(anAscName) ||myTemplateTable.IsBound(anAscName)) {
Standard_Boolean EDL_Interpretor::IsFile(const Standard_CString aFileName) const
{
if (aFileName != NULL) {
-
+
TCollection_AsciiString fname(aFileName);
-
+
Standard_Boolean IsFound = Standard_False;
Standard_Integer DirCount = 1;
const TCollection_AsciiString& adir = IncludeDirectory->Value(DirCount);
memcpy(tmpName, adir.ToCString(), adir.Length());
tmpName[adir.Length()] = '/';
- strcpy(&(tmpName[adir.Length()+1]),aFileName);
-
+ strcpy(&(tmpName[adir.Length()+1]),aFileName);
+
#ifndef WNT
- if( !access(tmpName, F_OK) )
+ if( !access(tmpName, F_OK) )
#else
- if ( GetFileAttributes(tmpName) != 0xFFFFFFFF )
+ if ( GetFileAttributes(tmpName) != 0xFFFFFFFF )
#endif
{
IsFound = Standard_True;
{
if (aTemplate != NULL) {
myCurrentTemplate = aTemplate;
-
+
if (myTemplateTable.IsBound(myCurrentTemplate)) {
myTemplateTable.UnBind(myCurrentTemplate);
}
-
+
EDL_Template aTmp(aTemplate);
myTemplateTable.Bind(myCurrentTemplate,aTmp);
}
EDL_Error EDL_Interpretor::AddToTemplate(const Standard_CString aTemplate)
{
if (aTemplate != NULL) {
-
+
if (myTemplateTable.IsBound(myCurrentTemplate)) {
myCurrentTemplate = aTemplate;
}
//=======================================================================
//function : RemoveTemplate
-//purpose :
+//purpose :
//=======================================================================
void EDL_Interpretor::RemoveTemplate(const Standard_CString aTemplate)
{
if (aTemplate != NULL) {
TCollection_AsciiString TmpName(aTemplate);
-
+
if (myTemplateTable.IsBound(TmpName)) {
myTemplateTable.UnBind(TmpName);
}
else {
EDL_Library aLib(aLibrary);
char *aStatus = (char *)aLib.GetStatus();
-
+
if (aStatus != NULL) {
EDL::PrintError(EDL_LIBNOTOPEN,aStatus);
return EDL_LIBNOTOPEN;
- }
+ }
else {
myLibraryTable.Bind(anAscName,aLib);
}
{
if (aLibrary != NULL) {
TCollection_AsciiString aName(aLibrary);
-
+
if (myLibraryTable.IsBound(aName)) {
return myLibraryTable.ChangeFind(aName);
}
return myLibraryTable.ChangeFind(TCollection_AsciiString());
}
-EDL_Error EDL_Interpretor::CallFunction(const Standard_CString libname, const Standard_CString funcname, const Standard_CString returnName)
+EDL_Error EDL_Interpretor::CallFunction(const Standard_CString libname, const Standard_CString funcname, const Standard_CString returnName)
{
if (libname != NULL) {
TCollection_AsciiString anAscName(libname);
-
+
if (!myLibraryTable.IsBound(anAscName)) {
EDL::PrintError(EDL_LIBRARYNOTFOUND,libname);
return EDL_LIBRARYNOTFOUND;
{
if (aLibrary != NULL) {
TCollection_AsciiString aName(aLibrary);
-
+
if (myLibraryTable.IsBound(aName)) {
myLibraryTable.UnBind(aName);
}
Standard_Boolean EDL_Interpretor::RemoveExecutionStatus()
{
Standard_Boolean aResult;
-
+
if (!myExecutionStatus.IsEmpty()) {
aResult = myExecutionStatus.Top();
myExecutionStatus.Pop();
else {
aResult = Standard_True;
}
-
+
return aResult;
}
myExpressionMember.Push(aValue);
}
-Standard_Boolean EDL_Interpretor::GetExpressionMember()
+Standard_Boolean EDL_Interpretor::GetExpressionMember()
{
Standard_Boolean aResult = myExpressionMember.Top();
-
+
myExpressionMember.Pop();
return aResult;
{
if (aVariable != NULL) {
TCollection_AsciiString aVar(aVariable);
-
+
if (!mySymbolTable.IsBound(aVar)) {
EDL::PrintError(EDL_VARNOTFOUND,aVariable);
// Raise
{
if (aVariable != NULL) {
TCollection_AsciiString aVar(aVariable);
-
+
if (!mySymbolTable.IsBound(aVar)) {
EDL::PrintError(EDL_VARNOTFOUND,aVariable);
// Raise
// destruction of a variable :
//
-void edl_unset_var(const edlstring varname)
-{
+void edl_unset_var(const edlstring varname)
+{
if (!edl_must_execute()) return;
GlobalInter->RemoveVariable(varname.str);
// destruction of a pointer variable :
//
-void edl_unset_pvar(const edlstring varname)
-{
+void edl_unset_pvar(const edlstring varname)
+{
if (!edl_must_execute()) return;
char *aString = (char *)GlobalInter->GetVariable(varname.str).GetValue();
-
+
GlobalInter->RemoveVariable(aString);
}
// assign or creation of a variable :
// if the variable doesnt exist we create it , otherwise we change its value...
//
-void edl_set_var(const edlstring varname, const edlstring value)
-{
+void edl_set_var(const edlstring varname, const edlstring value)
+{
if (!edl_must_execute()) return;
GlobalInter->AddVariable(varname.str,value.str);
// assign or creation of a variable with an other variable:
// if the variable doesnt exist we create it , otherwise we change its value...
//
-void edl_set_varvar(const edlstring varname, const edlstring value)
-{
+void edl_set_varvar(const edlstring varname, const edlstring value)
+{
if (!edl_must_execute()) return;
// we need to erase the quote
// assign or creation of a variable with a pointer:
// if the variable doesnt exist we create it , otherwise we change its value...
//
-void edl_set_varevalvar(const edlstring varname, const edlstring value)
-{
+void edl_set_varevalvar(const edlstring varname, const edlstring value)
+{
if (!edl_must_execute()) return;
// we need to erase the quote
// assign or creation of a variable :
// if the variable doesnt exist we create it , otherwise we change its value...
//
-void edl_set_pvar(const edlstring varname, const edlstring value)
-{
+void edl_set_pvar(const edlstring varname, const edlstring value)
+{
if (!edl_must_execute()) return;
char *aString = (char *)GlobalInter->GetVariable(varname.str).GetValue();
-
+
GlobalInter->AddVariable(aString,value.str);
}
// assign or creation of a variable with an other variable:
// if the variable doesnt exist we create it , otherwise we change its value...
//
-void edl_set_pvarvar(const edlstring varname, const edlstring value)
-{
+void edl_set_pvarvar(const edlstring varname, const edlstring value)
+{
if (!edl_must_execute()) return;
// we need to erase the quote
// assign or creation of a variable with a pointer:
// if the variable doesnt exist we create it , otherwise we change its value...
//
-void edl_set_pvarevalvar(const edlstring varname, const edlstring value)
-{
+void edl_set_pvarevalvar(const edlstring varname, const edlstring value)
+{
if (!edl_must_execute()) return;
// we need to erase the quote
char *aString1 = (char *)GlobalInter->GetVariable(varname.str).GetValue(),
*aString2 = value.str;
-
+
Standard_Integer aResult = strcmp(aString1,aString2);
Standard_Boolean aMember;
-
+
switch (ope) {
case EQ: if (aResult == 0) {
aMember = Standard_True;
}
else {
- aMember = Standard_False;
+ aMember = Standard_False;
}
break;
case NEQ: if (aResult != 0) {
aMember = Standard_True;
}
else {
- aMember = Standard_False;
+ aMember = Standard_False;
}
break;
default:
EDLerror((char*)"wrong logical operator...",(char*)"");
exit(EDL_SYNTAXERROR);
}
-
+
// we add the evaluation of the expression to the stack
//
GlobalInter->AddExpressionMember(aMember);
// take the results from previous expressions evaluation
// from stack and build a final result
-// rule : conditions: condition
+// rule : conditions: condition
//
void edl_eval_condition()
{
}
}
-void edl_isvardefined(const edlstring varname)
+void edl_isvardefined(const edlstring varname)
{
if (!edl_must_execute()) {
GlobalInter->AddExecutionStatus(Standard_False);
if (varname.str) Standard::Free((void*&)varname.str);
}
-void edl_isvardefinedm(const edlstring varname)
+void edl_isvardefinedm(const edlstring varname)
{
if (!edl_must_execute()) {
if (varname.str) Standard::Free((void*&)varname.str);
if (varname.str) Standard::Free((void*&)varname.str);
}
-void edl_fileexist(const edlstring varname)
+void edl_fileexist(const edlstring varname)
{
if (!edl_must_execute()) {
GlobalInter->AddExecutionStatus(Standard_False);
if (varname.str) Standard::Free((void*&)varname.str);
}
-void edl_fileexistm(const edlstring varname)
+void edl_fileexistm(const edlstring varname)
{
if (!edl_must_execute()) {
if (varname.str) Standard::Free((void*&)varname.str);
if (varname.str) Standard::Free((void*&)varname.str);
}
-void edl_fileexist_var(const edlstring varname)
+void edl_fileexist_var(const edlstring varname)
{
if (!edl_must_execute()) {
GlobalInter->AddExecutionStatus(Standard_False);
if (varname.str) Standard::Free((void*&)varname.str);
}
-void edl_fileexist_varm(const edlstring varname)
+void edl_fileexist_varm(const edlstring varname)
{
if (!edl_must_execute()) {
if (varname.str) Standard::Free((void*&)varname.str);
if (varname.str) Standard::Free((void*&)varname.str);
}
-void edl_filenotexist(const edlstring varname)
+void edl_filenotexist(const edlstring varname)
{
if (!edl_must_execute()) {
GlobalInter->AddExecutionStatus(Standard_False);
if (varname.str) Standard::Free((void*&)varname.str);
}
-void edl_filenotexistm(const edlstring varname)
+void edl_filenotexistm(const edlstring varname)
{
if (!edl_must_execute()) {
if (varname.str) Standard::Free((void*&)varname.str);
if (varname.str) Standard::Free((void*&)varname.str);
}
-void edl_filenotexist_var(const edlstring varname)
+void edl_filenotexist_var(const edlstring varname)
{
if (!edl_must_execute()) {
GlobalInter->AddExecutionStatus(Standard_False);
if (varname.str) Standard::Free((void*&)varname.str);
}
-void edl_filenotexist_varm(const edlstring varname)
+void edl_filenotexist_varm(const edlstring varname)
{
if (!edl_must_execute()) {
if (varname.str) Standard::Free((void*&)varname.str);
if (varname.str) Standard::Free((void*&)varname.str);
}
-void edl_isvarnotdefined(const edlstring varname)
+void edl_isvarnotdefined(const edlstring varname)
{
if (!edl_must_execute()) {
GlobalInter->AddExecutionStatus(Standard_False);
if (varname.str) Standard::Free((void*&)varname.str);
}
-void edl_isvarnotdefinedm(const edlstring varname)
+void edl_isvarnotdefinedm(const edlstring varname)
{
if (!edl_must_execute()) {
if (varname.str) Standard::Free((void*&)varname.str);
// we need to erase the quote
//
char* aString = (char *)GlobalInter->GetVariable(varname.str).GetValue();
-
+
GlobalInter->GetPrintList().AssignCat(aString);
if (varname.str) Standard::Free((void*&)varname.str);
}
// we need to erase the quote
//
char *aString = (char *)GlobalInter->GetVariable(varname.str).GetValue();
-
+
GlobalInter->GetPrintList().AssignCat(aString);
}
void edl_end_template()
{
if (!edl_must_execute()) return;
-
+
GlobalInter->SetCurrentTemplate(NULL);
}
}
GlobalInter->SetCurrentTemplate(tempname.str);
-
+
GlobalInter->ClearVariableList();
-
-
+
+
// to check if the template is defined
//
EDL_Template& atemp = GlobalInter->GetTemplate(tempname.str);
for (Standard_Integer i = 1; i <= listvar->Length(); i++) {
GlobalInter->AddToVariableList(listvar->Value(i)->ToCString());
}
-
+
if (tempname.str) Standard::Free((void*&)tempname.str);
}
}
EDL_File& aFile = GlobalInter->GetFile(varname.str);
-
+
aFile.Close();
GlobalInter->RemoveFile(varname.str);
if (varname.str) Standard::Free((void*&)varname.str);
extern "C" FILE *EDLin;
#endif // WNT
-void edl_uses_var(const edlstring var)
+void edl_uses_var(const edlstring var)
{
if (edl_must_execute()) {
EDL_Variable& aVar = GlobalInter->GetVariable(var.str);
if (var.str) Standard::Free((void*&)var.str);
}
-void edl_uses(const edlstring filename)
+void edl_uses(const edlstring filename)
{
Standard_Boolean IsFound = Standard_False;
Standard_Integer DirCount = 1;
// from lex
//
-
+
if (edl_must_execute()) {
numFileDesc++;
-
+
if (numFileDesc > 9) {
EDL::PrintError(EDL_TOOMANYINCLUDELEVEL," ");
Standard_NoSuchObject::Raise();
const TCollection_AsciiString& adir = IncludeDirectory->Value(DirCount);
memcpy(tmpName, adir.ToCString(), adir.Length());
tmpName[adir.Length()] = '/';
- strcpy(&(tmpName[adir.Length()+1]),filename.str);
-
+ strcpy(&(tmpName[adir.Length()+1]),filename.str);
+
#ifndef WNT
- if( !access(tmpName, F_OK) )
+ if( !access(tmpName, F_OK) )
#else
- if ( GetFileAttributes(tmpName) != 0xFFFFFFFF )
+ if ( GetFileAttributes(tmpName) != 0xFFFFFFFF )
#endif
{
EDLin = fopen(tmpName,"r");
}
DirCount++;
}
-
+
if (EDLin == NULL) {
EDL::PrintError(EDL_FILENOTOPENED,filename.str);
if (filename.str) Standard::Free((void*&)filename.str);