84 const void* var, VarType type,
85 const Int_t* count,
const char* errloc )
92 Warning( errloc,
"Variable %s already exists. Not redefined.",
99 Warning( errloc,
"Error creating variable %s",
name );
110 const TString& def,
const void*
const obj,
111 TClass*
const cl,
const char* errloc )
115 typedef vector<TSeqCollection*> VecSC_t;
117 static_assert(
sizeof(
ULong_t) ==
sizeof(
void*),
"ULong_t must be of pointer size" );
120 Warning( errloc,
"Invalid class or object. Variable %s not defined.",
127 Warning( errloc,
"Variable %s already exists. Not redefined.",
136 while( (pos = def.
Index(
".", pos )) !=
kNPOS && ndot<2 ) {
139 s[ndot] = def(ppos,
len);
143 s[ndot] = def(ppos, def.
Length()-ppos );
147 Warning( errloc,
"Too many dots in definition of variable %s (%s). "
148 "Variable not defined.",
name.Data(), desc.
Data() );
154 if( s[i++].Length() == 0 )
157 TClass* theClass =
nullptr;
158 auto loc =
reinterpret_cast<ULong_t>(obj);
173 objrtti.
Find( cl, s[0], obj );
176 Warning( errloc,
"Unsupported type of data member %s. "
177 "Variable %s (%s) not defined.",
178 s[0].Data(),
name.Data(), desc.
Data() );
183 void** ploc = (
void**)loc;
191 objrtti.
Find( cl, s[0], obj );
196 if(
s0 &&
s0.IsArray() &&
s0.GetNdim() == 1 ) {
197 objrtti.
Find( cl,
s0, obj );
199 objrtti.
GetType() == kObjectPV ) {
205 Warning( errloc,
"Unsupported type of data member %s. "
206 "Variable %s (%s) not defined.",
207 s[0].Data(),
name.Data(), desc.
Data() );
214 Warning( errloc,
"Data member %s is not a TSeqCollection. "
215 "Variable %s (%s) not defined.",
216 s[0].Data(),
name.Data(), desc.
Data() );
221 void** ploc = (
void**)loc;
226 VecSC_t
vec = *
reinterpret_cast<VecSC_t*
>(loc);
227 if( vecidx < 0 || vecidx >= (
Int_t)
vec.size() ) {
228 Warning( errloc,
"Illegal index %d into std::vector %s. "
229 "Current size = %d. Variable %s (%s) not defined.",
236 Warning( errloc,
"Null pointer in std::vector %s. "
237 "Variable %s (%s) not defined.",
238 s[0].Data(),
name.Data(), desc.
Data() );
244 theClass =
gROOT->GetClass( s[1] );
246 Warning( errloc,
"Cannot determine class of container "
247 "member object %s. Variable %s (%s) not defined.",
248 s[1].Data(),
name.Data(), desc.
Data() );
263 rtti.
Find( theClass, s[ndot], (ndot==0) ? obj : nullptr );
265 Warning( errloc,
"No RTTI information for variable %s. "
266 "Not defined.",
name.Data() );
270 Warning( errloc,
"Variable %s is an object. Must be a basic type. "
271 "Not defined.",
name.Data() );
279 Int_t* count_loc =
nullptr;
301 assert(
type == kObjectV ||
type == kObjectPV );
309 Warning( errloc,
"Error creating variable %s",
name.Data() );
320 assert(pos2 !=
kNPOS );
321 funcName = funcName(0, pos2);
323 auto* theMethod =
new TMethodCall(theClass, funcName,
"" );
324 if( !theMethod->IsValid() ) {
325 Warning( errloc,
"Error getting function information for variable %s. "
326 "Not defined.",
name.Data() );
330 TFunction* func = theMethod->GetMethod();
332 Warning( errloc,
"Function %s does not exist. Variable %s not defined.",
333 s[ndot].Data(),
name.Data() );
340 Warning( errloc,
"Unsupported return type for function %s. "
341 "Variable %s not defined.", s[ndot].Data(),
name.Data() );
347 VarType
type = kVarTypeEnd;
349 if( ntype ==
"double" )
351 else if( (
sizeof(
int) ==
sizeof(
Int_t) && ntype ==
"int") ||
352 (
sizeof(
long) ==
sizeof(
Int_t) && ntype ==
"long") )
354 else if( (
sizeof(
unsigned int) ==
sizeof(
UInt_t) && ntype ==
"unsigned int") ||
355 (
sizeof(
unsigned long) ==
sizeof(
UInt_t) && ntype ==
"unsigned long") )
357 else if( ntype ==
"float" )
359 else if( ntype ==
"bool" ) {
360 if(
sizeof(
bool) ==
sizeof(
Char_t) )
362 else if(
sizeof(
bool) ==
sizeof(
Short_t) )
364 else if(
sizeof(
bool) ==
sizeof(
Int_t) )
367 else if( (
sizeof(
long) ==
sizeof(
Long_t) && ntype ==
"long") ||
368 (
sizeof(
long long) ==
sizeof(
Long_t) && ntype ==
"long long") ||
369 (
sizeof(
int) ==
sizeof(
Long_t) && ntype ==
"int") )
371 else if( (
sizeof(
unsigned long) ==
sizeof(
ULong_t) && ntype ==
"unsigned long") ||
372 (
sizeof(
unsigned long long) ==
sizeof(
ULong_t) && ntype ==
"unsigned long long") ||
373 (
sizeof(
unsigned int) ==
sizeof(
ULong_t) && ntype ==
"unsigned int") )
375 else if( (
sizeof(
short) ==
sizeof(
Short_t) && ntype ==
"short") )
377 else if( (
sizeof(
unsigned short) ==
sizeof(
UShort_t) && ntype ==
"unsigned short") )
379 else if( ntype ==
"char" )
381 else if( ntype ==
"unsigned char" )
384 if(
type == kVarTypeEnd ) {
385 Warning( errloc,
"Unsupported return type \"%s\" for function %s. "
386 "Variable %s not defined.", ntype.c_str(), s[ndot].
Data(),
name.Data() );
393 Warning( errloc,
"Ill-formed TMethodCall returned from ROOT for function %s, "
394 "variable %s. Call expert.", s[ndot].Data(),
name.Data() );
399 var =
new THaVar(
name, desc, (
void*)loc,
type, ((ndot==2) ? 0 : -1),
403 VarType otype = objrtti.
GetType();
404 assert( otype == kObjectV || otype == kObjectPV );
406 var =
new THaVar(
name, desc, (
void*)loc,
type, sz, 0, theMethod );
411 Warning( errloc,
"Error creating variable %s",
name.Data() );
446 TString errloc(
"DefineVariables [called from ");
447 if( !caller || !*caller ) {
448 caller =
"(global scope)";
454 Error(errloc,
"Empty input list. No variables registered.");
461 const VarDef* item = list;
465 while( item->name ) {
467 const char* description = item->desc;
468 if( !description || !*description )
469 description = item->name;
473 name.Append(item->name);
475 bool fixed_array = (item->size > 1);
476 bool var_array = (item->count !=
nullptr) ||
477 (item->type >= kIntV && item->type <= kDoubleV);
478 if( item->size>0 && var_array ) {
479 Warning( errloc,
"Variable %s: variable-size arrays must have size=0. "
480 "Ignoring size.",
name.Data() );
481 }
else if( fixed_array ) {
484 snprintf( dimstr, LEN,
"[%d]", item->size );
491 static_cast<VarType
>( item->type ),
492 item->count, errloc );
503 const char* prefix,
const char* caller,
504 const char* def_prefix,
505 const char* comment_subst )
525 TString errloc(
"DefineVariables [called from ");
526 if( !caller || !*caller) {
527 caller =
"(global scope)";
533 Error(errloc,
"No input list. No variables registered.");
538 Error(errloc,
"No base object. No variables registered.");
546 Error( errloc,
"Base object has no class?!? No variables registered.");
552 while( (item = list++) && item->name ) {
559 name.Prepend(prefix);
562 if( item->desc && *item->desc ) {
571 desc.
Remove(TString::EStripType::kLeading,
' ')
572 .
Remove(TString::EStripType::kTrailing,
' ');
577 char*
c = ::Compress( item->def );
581 Warning( errloc,
"Invalid definition for variable %s (%s). "
582 "Variable not defined.",
name.Data(), desc.
Data() );
585 if( def_prefix && *def_prefix )
606 auto pos = s.find(
'[');
607 return dynamic_cast<THaVar*
>(
625 while(
TObject* obj = next() ) {
660 if( re.
Status() )
return -1;
664 while(
TObject* ptr = next() ) {
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char Pixmap_t Pixmap_t PictureAttributes_t attr const char char ret_data h unsigned char height h Atom_t Int_t ULong_t ULong_t unsigned char prop_list Atom_t Atom_t Atom_t Time_t UChar_t len
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char Pixmap_t Pixmap_t PictureAttributes_t attr const char char ret_data h unsigned char height h Atom_t Int_t ULong_t ULong_t unsigned char prop_list Atom_t Atom_t Atom_t Time_t type
static const Int_t kVarListRehashLevel
static const Int_t kInitVarListCapacity
Bool_t InheritsFrom(const char *cl) const override
virtual void SetOwner(Bool_t enable=kTRUE)
std::string GetReturnTypeNormalizedName() const
Bool_t IsObjVector() const
Long_t GetCountOffset() const
EArrayType GetArrayType() const
TClass * GetClass() const
Int_t Find(TClass *cl, const TString &var, const void *p=nullptr)
const char * GetSubscript() const
virtual Int_t RemoveRegexp(const char *expr, Bool_t wildcard=true)
virtual Int_t RemoveName(const char *name)
virtual void PrintFull(Option_t *opt="") const
virtual THaVar * DefineByType(const char *name, const char *desc, const void *loc, VarType type, const Int_t *count, const char *errloc="DefineByType")
virtual THaVar * DefineByRTTI(const TString &name, const TString &desc, const TString &def, const void *obj, TClass *cl, const char *errloc="DefineByRTTI")
virtual THaVar * Find(const char *name) const
virtual Int_t DefineVariables(const VarDef *list, const char *prefix="", const char *caller="")
TObject * Remove(TObject *obj) override
TObject * FindObject(const char *name) const override
void AddLast(TObject *obj) override
static const EReturnType kLong
TInterpreter::EReturnType EReturnType
static const EReturnType kDouble
const char * GetName() const override
virtual void Warning(const char *method, const char *msgfmt,...) const
R__ALWAYS_INLINE Bool_t IsZombie() const
virtual void Error(const char *method, const char *msgfmt,...) const
virtual TClass * IsA() const
Bool_t EndsWith(const char *pat, ECaseCompare cmp=kExact) const
const char * Data() const
TString & Append(char c, Ssiz_t rep=1)
TString & Prepend(char c, Ssiz_t rep=1)
TString & Remove(EStripType s, char c)
TString & ReplaceAll(const char *s1, const char *s2)
Ssiz_t Index(const char *pat, Ssiz_t i=0, ECaseCompare cmp=kExact) const
void function(const Char_t *name_, T fun, const Char_t *docstring=0)