No need to enable/disable, check for enabled/disabled callback. Either they are
there and we use them or not. git-svn-id: http://root.cern.ch/svn/root/trunk@46440 27541ba8-7e3a-0410-8455-c3a389f83636
This commit is contained in:
parent
a047926b87
commit
9d654b26f9
@ -70,16 +70,12 @@ namespace cling {
|
||||
///
|
||||
Interpreter* m_Interpreter; // we don't own
|
||||
|
||||
///\brief Whether or not the callbacks are enabled.
|
||||
///
|
||||
bool m_Enabled;
|
||||
|
||||
///\brief Our custom SemaExternalSource, translating interesting events into
|
||||
/// callbacks.
|
||||
///
|
||||
llvm::OwningPtr<InterpreterExternalSemaSource> m_SemaExternalSource;
|
||||
public:
|
||||
InterpreterCallbacks(Interpreter* interp, bool enabled = false,
|
||||
InterpreterCallbacks(Interpreter* interp,
|
||||
InterpreterExternalSemaSource* IESS = 0);
|
||||
|
||||
virtual ~InterpreterCallbacks();
|
||||
@ -88,12 +84,6 @@ namespace cling {
|
||||
return m_SemaExternalSource.get();
|
||||
}
|
||||
|
||||
void setEnabled(bool e = true) {
|
||||
m_Enabled = e;
|
||||
}
|
||||
|
||||
bool isEnabled() { return m_Enabled; }
|
||||
|
||||
/// \brief This callback is invoked whenever the interpreter needs to
|
||||
/// resolve the type and the adress of an object, which has been marked for
|
||||
/// delayed evaluation from the interpreter's dynamic lookup extension.
|
||||
@ -144,7 +134,7 @@ namespace cling {
|
||||
private:
|
||||
clang::NamedDecl* m_TesterDecl;
|
||||
public:
|
||||
SymbolResolverCallback(Interpreter* interp, bool enabled = false,
|
||||
SymbolResolverCallback(Interpreter* interp,
|
||||
InterpreterExternalSemaSource* IESS = 0);
|
||||
~SymbolResolverCallback();
|
||||
|
||||
|
@ -30,7 +30,7 @@ namespace cling {
|
||||
if (!test::SymbolResolverCallback::IsDynamicLookup(R, S))
|
||||
return false;
|
||||
|
||||
if (getCallbacks() && getCallbacks()->isEnabled()) {
|
||||
if (getCallbacks()) {
|
||||
return getCallbacks()->LookupObject(R, S);
|
||||
}
|
||||
|
||||
|
@ -173,7 +173,7 @@ namespace cling {
|
||||
|
||||
CurT->setState(Transaction::kCommitted);
|
||||
InterpreterCallbacks* callbacks = m_Interpreter->getCallbacks();
|
||||
if (callbacks && callbacks->isEnabled())
|
||||
if (callbacks)
|
||||
callbacks->TransactionCommitted(*CurT);
|
||||
}
|
||||
|
||||
@ -351,7 +351,7 @@ namespace cling {
|
||||
NodeEraser.RevertTransaction(T);
|
||||
|
||||
InterpreterCallbacks* callbacks = m_Interpreter->getCallbacks();
|
||||
if (callbacks && callbacks->isEnabled())
|
||||
if (callbacks)
|
||||
callbacks->TransactionUnloaded(*T);
|
||||
}
|
||||
|
||||
|
@ -660,9 +660,7 @@ namespace cling {
|
||||
|
||||
StoredValueRef Result;
|
||||
if (TheSema.getExternalSource()) {
|
||||
getCallbacks()->setEnabled();
|
||||
(ValuePrinterReq) ? echo(expr, &Result) : evaluate(expr, &Result);
|
||||
getCallbacks()->setEnabled(false);
|
||||
}
|
||||
else
|
||||
(ValuePrinterReq) ? echo(expr, &Result) : evaluate(expr, &Result);
|
||||
|
@ -21,15 +21,15 @@ namespace cling {
|
||||
|
||||
bool InterpreterExternalSemaSource::LookupUnqualified(LookupResult& R,
|
||||
Scope* S) {
|
||||
if (m_Callbacks && m_Callbacks->isEnabled())
|
||||
if (m_Callbacks)
|
||||
return m_Callbacks->LookupObject(R, S);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
InterpreterCallbacks::InterpreterCallbacks(Interpreter* interp, bool enabled,
|
||||
InterpreterCallbacks::InterpreterCallbacks(Interpreter* interp,
|
||||
InterpreterExternalSemaSource* IESS)
|
||||
: m_Interpreter(interp), m_Enabled(enabled), m_SemaExternalSource(IESS) {
|
||||
: m_Interpreter(interp), m_SemaExternalSource(IESS) {
|
||||
if (!IESS)
|
||||
m_SemaExternalSource.reset(new InterpreterExternalSemaSource());
|
||||
m_SemaExternalSource->setCallbacks(this);
|
||||
@ -92,9 +92,8 @@ namespace test {
|
||||
}
|
||||
|
||||
SymbolResolverCallback::SymbolResolverCallback(Interpreter* interp,
|
||||
bool enabled,
|
||||
InterpreterExternalSemaSource* IESS)
|
||||
: InterpreterCallbacks(interp, enabled, IESS), m_TesterDecl(0) {
|
||||
: InterpreterCallbacks(interp, IESS), m_TesterDecl(0) {
|
||||
m_Interpreter->process("cling::test::Tester = new cling::test::TestProxy();");
|
||||
}
|
||||
|
||||
@ -105,18 +104,15 @@ namespace test {
|
||||
return false;
|
||||
|
||||
// Only for demo resolve all unknown objects to cling::test::Tester
|
||||
if (m_Enabled) {
|
||||
if (!m_TesterDecl) {
|
||||
clang::Sema& S = m_Interpreter->getSema();
|
||||
clang::NamespaceDecl* NSD = utils::Lookup::Namespace(&S, "cling");
|
||||
NSD = utils::Lookup::Namespace(&S, "test", NSD);
|
||||
m_TesterDecl = utils::Lookup::Named(&S, "Tester", NSD);
|
||||
}
|
||||
assert (m_TesterDecl && "Tester not found!");
|
||||
R.addDecl(m_TesterDecl);
|
||||
return true;
|
||||
if (!m_TesterDecl) {
|
||||
clang::Sema& S = m_Interpreter->getSema();
|
||||
clang::NamespaceDecl* NSD = utils::Lookup::Namespace(&S, "cling");
|
||||
NSD = utils::Lookup::Namespace(&S, "test", NSD);
|
||||
m_TesterDecl = utils::Lookup::Named(&S, "Tester", NSD);
|
||||
}
|
||||
return false;
|
||||
assert (m_TesterDecl && "Tester not found!");
|
||||
R.addDecl(m_TesterDecl);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool SymbolResolverCallback::IsDynamicLookup(LookupResult& R, Scope* S) {
|
||||
|
@ -5,7 +5,7 @@
|
||||
|
||||
.dynamicExtensions
|
||||
|
||||
gCling->setCallbacks(new cling::test::SymbolResolverCallback(gCling, /*Enabled*/true));
|
||||
gCling->setCallbacks(new cling::test::SymbolResolverCallback(gCling));
|
||||
|
||||
// Fixed size arrays
|
||||
int a[5] = {1,2,3,4,5};
|
||||
|
@ -21,7 +21,7 @@
|
||||
#include "cling/Interpreter/InterpreterCallbacks.h"
|
||||
|
||||
.dynamicExtensions
|
||||
gCling->setCallbacks(new cling::test::SymbolResolverCallback(gCling, /*Enabled=*/true));
|
||||
gCling->setCallbacks(new cling::test::SymbolResolverCallback(gCling));
|
||||
|
||||
int a[5] = {1,2,3,4,5};
|
||||
if (h->PrintArray(a, 5)) { // runtime result type bool
|
||||
|
@ -8,7 +8,7 @@
|
||||
|
||||
.dynamicExtensions 1
|
||||
|
||||
cling::test::SymbolResolverCallback* SRC = new cling::test::SymbolResolverCallback(gCling, /*Enabled=*/ true);
|
||||
cling::test::SymbolResolverCallback* SRC = new cling::test::SymbolResolverCallback(gCling);
|
||||
gCling->setCallbacks(SRC);
|
||||
|
||||
.x LifetimeHandler.h
|
||||
|
@ -14,7 +14,7 @@
|
||||
|
||||
.dynamicExtensions
|
||||
|
||||
gCling->setCallbacks(new cling::test::SymbolResolverCallback(gCling, /*Enabled=*/true));
|
||||
gCling->setCallbacks(new cling::test::SymbolResolverCallback(gCling));
|
||||
jksghdgsjdf->getVersion() // CHECK: {{.*Interpreter.*}}
|
||||
hsdghfjagsp->Draw() // CHECK: (int const) 12
|
||||
|
||||
|
@ -5,7 +5,7 @@
|
||||
|
||||
.dynamicExtensions
|
||||
|
||||
gCling->setCallbacks(new cling::test::SymbolResolverCallback(gCling, /*Enabled=*/true));
|
||||
gCling->setCallbacks(new cling::test::SymbolResolverCallback(gCling));
|
||||
jksghdgsjdf->getVersion() // CHECK: {{.*Interpreter.*}}
|
||||
hsdghfjagsp->Draw() // CHECK: (int const) 12
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user