Split value printing interface into printValue(), printType().
TString is missing a newline; will refactor printing of delims (to be done by pcaller).
This commit is contained in:
parent
9a9f49f129
commit
4219c4e1a9
@ -25,10 +25,19 @@ namespace cling {
|
||||
std::string printValue(const void* const p, TY* const u,
|
||||
const ValuePrinterInfo& VPI);
|
||||
|
||||
// Can be re-implemented to print a user type differently, e.g. as
|
||||
// template <typename POSSIBLYDERIVED>
|
||||
// std::string printType(const MyClass* const p, POSSIBLYDERIVED* ac,
|
||||
// const ValuePrinterInfo& VPI);
|
||||
template <typename TY>
|
||||
std::string printType(const void* const p, TY* const u,
|
||||
const ValuePrinterInfo& VPI);
|
||||
|
||||
namespace valuePrinterInternal {
|
||||
|
||||
std::string printValue_Default(const void* const p,
|
||||
const ValuePrinterInfo& PVI);
|
||||
std::string printType_Default(const ValuePrinterInfo& PVI);
|
||||
|
||||
void StreamStoredValueRef(llvm::raw_ostream& o, const StoredValueRef* VR,
|
||||
clang::ASTContext& C, const char* Sep = "\n");
|
||||
@ -40,7 +49,8 @@ namespace cling {
|
||||
clang::ASTContext* C, const T& value) {
|
||||
ValuePrinterInfo VPI(E, C);
|
||||
// Only because we don't want to include llvm::raw_ostream in the header
|
||||
flushToStream(*o, printValue(&value, &value, VPI));
|
||||
flushToStream(*o, printType(&value, &value, VPI)
|
||||
+ printValue(&value, &value, VPI));
|
||||
return value;
|
||||
}
|
||||
|
||||
@ -49,7 +59,8 @@ namespace cling {
|
||||
clang::ASTContext* C, const T* value) {
|
||||
ValuePrinterInfo VPI(E, C);
|
||||
// Only because we don't want to include llvm::raw_ostream in the header
|
||||
flushToStream(*o, printValue((const void*) value, value, VPI));
|
||||
flushToStream(*o, printType((const void*) value, value, VPI)
|
||||
+ printValue((const void*) value, value, VPI));
|
||||
return value;
|
||||
}
|
||||
|
||||
@ -58,7 +69,8 @@ namespace cling {
|
||||
clang::ASTContext* C, T* value) {
|
||||
ValuePrinterInfo VPI(E, C);
|
||||
// Only because we don't want to include llvm::raw_ostream in the header
|
||||
flushToStream(*o, printValue((const void*) value, value, VPI));
|
||||
flushToStream(*o, printType((const void*) value, value, VPI)
|
||||
+ printValue((const void*) value, value, VPI));
|
||||
return value;
|
||||
}
|
||||
|
||||
@ -69,6 +81,11 @@ namespace cling {
|
||||
const ValuePrinterInfo& PVI) {
|
||||
return valuePrinterInternal::printValue_Default(p, PVI);
|
||||
}
|
||||
template <typename TY>
|
||||
std::string printType(const void* const p, TY* const /*u*/,
|
||||
const ValuePrinterInfo& PVI) {
|
||||
return valuePrinterInternal::printType_Default(PVI);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
@ -55,7 +55,8 @@ extern "C" void cling_PrintValue(void* /*clang::Expr**/ E,
|
||||
// the results in pipes (Savannah #99234).
|
||||
llvm::raw_fd_ostream outs (STDOUT_FILENO, /*ShouldClose*/false);
|
||||
|
||||
valuePrinterInternal::flushToStream(outs, printValue(value, value, VPI));
|
||||
valuePrinterInternal::flushToStream(outs, printType(value, value, VPI)
|
||||
+ printValue(value, value, VPI));
|
||||
}
|
||||
|
||||
|
||||
@ -308,13 +309,21 @@ namespace valuePrinterInternal {
|
||||
std::string printValue_Default(const void* const p,
|
||||
const ValuePrinterInfo& VPI) {
|
||||
std::string buf;
|
||||
{
|
||||
llvm::raw_string_ostream o(buf);
|
||||
StreamValue(o, p, VPI);
|
||||
o << '\n';
|
||||
}
|
||||
return buf;
|
||||
}
|
||||
|
||||
std::string printType_Default(const ValuePrinterInfo& VPI) {
|
||||
std::string buf;
|
||||
{
|
||||
llvm::raw_string_ostream o(buf);
|
||||
o << "(";
|
||||
o << VPI.getType().getAsString();
|
||||
o << ") ";
|
||||
StreamValue(o, p, VPI);
|
||||
o.flush();
|
||||
}
|
||||
return buf;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user