#include "TArrayL64.h"
#include "TClass.h"
#include "TInterpreter.h"
-
-#ifdef R__BUILDING_CINT7
-#include "cint7/Api.h"
-#else
-#include "Api.h"
-#endif
+#include "TCint.h"
ClassImp(AliHLTGlobalTriggerWrapper)
+namespace
+{
+ /// Variable to store the error message if an error occured in CINT when interpreting code.
+ TString gCINTErrorMessage = "";
+
+ /**
+ * This routine is the callback for the CINT interpreter when it finds a syntax error
+ * in the source code generated by the AliHLTGlobalTriggerComponent class.
+ */
+ void AliHLTOnErrorInCINT(char* message)
+ {
+ gCINTErrorMessage += message;
+ }
+
+} // end of namespace
+
+
AliHLTGlobalTriggerWrapper::AliHLTGlobalTriggerWrapper(const char* classname) :
AliHLTGlobalTrigger(),
AliHLTLogging(),
fAddCall(),
fCalculateTriggerDecisionCall(),
fGetCountersCall(),
- fSetCountersCall()
+ fSetCountersCall(),
+ fCallFailed(false)
{
// The default constructor.
{
HLTError("Could not create a new object of type '%s'.", classname);
}
+
+ // The following is a workaround for casting void* to void (*)(), i.e. a pointer to object to
+ // a pointer to function. Unfortunately the G__set_errmsgcallback routine interface is defined
+ // using a pointer to object so this workaround is necessary.
+ // We check that the two types are the same size. If they are not then such an operation is
+ // unsafe on the platform on which we are running and will not be performed.
+ union
+ {
+ void* fPtr;
+ void (*fFuncPtr)(char*);
+ };
+ fFuncPtr = AliHLTOnErrorInCINT;
+ if (sizeof(fPtr) == sizeof(fFuncPtr))
+ {
+ gInterpreter->SetErrmsgcallback(fPtr);
+ }
+ else
+ {
+ HLTWarning("On this platform a pointer to function and pointer to object are different sizes."
+ " For this reason we cannot use the G__set_errmsgcallback CINT API call in a safe way so all"
+ " error messages generated by CINT will not be captured or logged in the HLT system."
+ );
+ }
}
// Default destructor.
fClass->Destructor(fObject);
+ G__set_errmsgcallback(NULL);
}
{
// Fills internal values from the trigger menu.
+ fCallFailed = false;
struct Params
{
const void* fMenu;
} params;
params.fMenu = &menu;
fFillFromMenuCall.SetParamPtrs(¶ms, 1);
+ gCINTErrorMessage = "";
fFillFromMenuCall.Execute(fObject);
- int error = G__lasterror();
- if (error != TInterpreter::kNoError)
+ if (gCINTErrorMessage != "")
{
- if (error == TInterpreter::kFatal)
- {
- HLTFatal("Error interpreting the code for class '%s' at line %d.", fClass->GetName(), G__lasterror_linenum());
- }
- else
- {
- HLTError("Error interpreting the code for class '%s' at line %d.", fClass->GetName(), G__lasterror_linenum());
- }
+ fCallFailed = true;
+ HLTError(gCINTErrorMessage.Data());
+ HLTFatal("Error interpreting the code for class '%s' at line %d.", fClass->GetName(), G__lasterror_linenum());
}
}
{
// Clears the internal buffers for a new event.
+ fCallFailed = false;
+ gCINTErrorMessage = "";
fNewEventCall.Execute(fObject);
- int error = G__lasterror();
- if (error != TInterpreter::kNoError)
+ if (gCINTErrorMessage != "")
{
- if (error == TInterpreter::kFatal)
- {
- HLTFatal("Error interpreting the code for class '%s' at line %d.", fClass->GetName(), G__lasterror_linenum());
- }
- else
- {
- HLTError("Error interpreting the code for class '%s' at line %d.", fClass->GetName(), G__lasterror_linenum());
- }
+ fCallFailed = true;
+ HLTError(gCINTErrorMessage.Data());
+ HLTFatal("Error interpreting the code for class '%s' at line %d.", fClass->GetName(), G__lasterror_linenum());
}
}
{
// Adds parameters from the object to the internal buffers and variables.
+ fCallFailed = false;
struct Params
{
const void* fObj;
params.fType = &type;
params.fSpec = spec;
fAddCall.SetParamPtrs(¶ms, 3);
+ gCINTErrorMessage = "";
fAddCall.Execute(fObject);
- int error = G__lasterror();
- if (error != TInterpreter::kNoError)
+ if (gCINTErrorMessage != "")
{
- if (error == TInterpreter::kFatal)
- {
- HLTFatal("Error interpreting the code for class '%s' at line %d.", fClass->GetName(), G__lasterror_linenum());
- }
- else
- {
- HLTError("Error interpreting the code for class '%s' at line %d.", fClass->GetName(), G__lasterror_linenum());
- }
+ fCallFailed = true;
+ HLTError(gCINTErrorMessage.Data());
+ HLTFatal("Error interpreting the code for class '%s' at line %d.", fClass->GetName(), G__lasterror_linenum());
}
}
{
// Calculates the global trigger decision.
+ fCallFailed = false;
struct Params
{
const void* fDomain;
params.fDesc = &description;
fCalculateTriggerDecisionCall.SetParamPtrs(¶ms, 2);
Long_t retval;
+ gCINTErrorMessage = "";
fCalculateTriggerDecisionCall.Execute(fObject, retval);
- int error = G__lasterror();
- if (error != TInterpreter::kNoError)
+ if (gCINTErrorMessage != "")
{
- if (error == TInterpreter::kFatal)
- {
- HLTFatal("Error interpreting the code for class '%s' at line %d.", fClass->GetName(), G__lasterror_linenum());
- }
- else
- {
- HLTError("Error interpreting the code for class '%s' at line %d.", fClass->GetName(), G__lasterror_linenum());
- }
+ fCallFailed = true;
+ HLTError(gCINTErrorMessage.Data());
+ HLTFatal("Error interpreting the code for class '%s' at line %d.", fClass->GetName(), G__lasterror_linenum());
+ return false;
}
return bool(retval);
}
// Returns the internal counter array.
Long_t retval = 0x0;
+ gCINTErrorMessage = "";
fGetCountersCall.Execute(fObject, retval);
- int error = G__lasterror();
- if (error != TInterpreter::kNoError)
+ if (gCINTErrorMessage != "")
{
- if (error == TInterpreter::kFatal)
- {
- HLTFatal("Error interpreting the code for class '%s' at line %d.", fClass->GetName(), G__lasterror_linenum());
- }
- else
- {
- HLTError("Error interpreting the code for class '%s' at line %d.", fClass->GetName(), G__lasterror_linenum());
- }
+ fCallFailed = true;
+ HLTError(gCINTErrorMessage.Data());
+ HLTFatal("Error interpreting the code for class '%s' at line %d.", fClass->GetName(), G__lasterror_linenum());
}
static const TArrayL64 emptyArray;
const TArrayL64* ptr = &emptyArray; // Make sure we do not return a NULL pointer.
{
// Fills the internal counter array with new values.
+ fCallFailed = false;
struct Params
{
const void* fCounters;
} params;
params.fCounters = &counters;
fSetCountersCall.SetParamPtrs(¶ms, 1);
+ gCINTErrorMessage = "";
fSetCountersCall.Execute(fObject);
- int error = G__lasterror();
- if (error != TInterpreter::kNoError)
+ if (gCINTErrorMessage != "")
{
- if (error == TInterpreter::kFatal)
- {
- HLTFatal("Error interpreting the code for class '%s' at line %d.", fClass->GetName(), G__lasterror_linenum());
- }
- else
- {
- HLTError("Error interpreting the code for class '%s' at line %d.", fClass->GetName(), G__lasterror_linenum());
- }
+ fCallFailed = true;
+ HLTError(gCINTErrorMessage.Data());
+ HLTFatal("Error interpreting the code for class '%s' at line %d.", fClass->GetName(), G__lasterror_linenum());
}
}