Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Avoid using the interpreter from TDataMember if possible.
We can't use the interpreter when generating a PCM as this would
generate AST nodes which then would end up in the module, which
is causing a long chain of modules (such as redefinitons as we
suddenly have the same cling warpper function multiple times).

In this code path we seem to always have a number that we want
to convert to a string. So let's just use strtol instead here if
the argument is just a number, which should avoid the issue with
the generated code.

As we also now check if the input is a number, I added an assert
that verifies we fail when we can't handle the given user input.
  • Loading branch information
Teemperor committed Aug 23, 2017
commit 55aefa96e5a92c944cb4502d6bf4ae6938740f2c
38 changes: 23 additions & 15 deletions core/meta/src/TDataMember.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,8 @@ but also in Dump() and Inspect() methods and by the THtml class.
#include "TROOT.h"
#include "TVirtualMutex.h"

#include <cassert>
#include <cctype>
#include <stdlib.h>


Expand Down Expand Up @@ -398,21 +400,27 @@ void TDataMember::Init(bool afterReading)
it1=new TOptionListItem(this,-9999,0,0,ptr3,ptr2);
fOptions->Add(it1);
} else {
//We'll try to find global enum existing in ROOT...
Long_t l=0;
Int_t *value;
TGlobal *enumval = gROOT->GetGlobal(ptr1,kTRUE);
if (enumval){
value = (Int_t*)(enumval->GetAddress());
l = (Long_t)(*value);
} else if (IsEnum()) {
TObject *obj = fClass->GetListOfDataMembers(false)->FindObject(ptr1);
if (obj)
l = ((TEnumConstant*)obj)->GetValue();
else
l = gInterpreter->Calc(Form("%s;",ptr1));
} else
l = atol(ptr1);

char *strtolResult;
Long_t l = std::strtol(ptr1, &strtolResult, 10);
bool isnumber = (strtolResult != ptr1);

if (!isnumber) {
TGlobal *enumval = gROOT->GetGlobal(ptr1, kTRUE);
if (enumval) {
Int_t *value = (Int_t *)(enumval->GetAddress());
// We'll try to find global enum existing in ROOT...
l = (Long_t)(*value);
} else if (IsEnum()) {
TObject *obj = fClass->GetListOfDataMembers(false)->FindObject(ptr1);
if (obj)
l = ((TEnumConstant *)obj)->GetValue();
else
l = gInterpreter->Calc(Form("%s;", ptr1));
} else {
Fatal("TDataMember", "Internal error, couldn't recognize enum/global value %s.", ptr1);
}
}

it1 = new TOptionListItem(this,l,0,0,ptr3,ptr1);
fOptions->Add(it1);
Expand Down