This commit is contained in:
Axel Naumann 2015-12-11 16:18:29 +01:00 committed by sftnight
parent 986f7938dd
commit f405ea4ed2

View File

@ -7,8 +7,11 @@
#include "cling/Interpreter/Interpreter.h" #include "cling/Interpreter/Interpreter.h"
#include "cling/Interpreter/Value.h" #include "cling/Interpreter/Value.h"
#include "llvm/Support/raw_ostream.h"
#include <map> #include <map>
#include <string> #include <string>
#include <cstring>
// FIXME: should be moved into a Jupyter interp struct that then gets returned // FIXME: should be moved into a Jupyter interp struct that then gets returned
// from create. // from create.
@ -90,7 +93,7 @@ void cling_destroy(TheInterpreter *interpVP) {
static std::string ValueToString(const cling::Value& V) { static std::string ValueToString(const cling::Value& V) {
std::string valueString; std::string valueString;
{ {
llvm::raw_ostringstream os(valueString); llvm::raw_string_ostream os(valueString);
V.print(os); V.print(os);
} }
return valueString; return valueString;
@ -108,7 +111,7 @@ char* cling_eval(TheInterpreter *interpVP, const char *code) {
cling::Jupyter::pushOutput({{"text/html", "You just executed C++ code!"}}); cling::Jupyter::pushOutput({{"text/html", "You just executed C++ code!"}});
if (!V.isValid()) if (!V.isValid())
return strdup(""); return strdup("");
return strdup(valueString(V)); return strdup(ValueToString(V).c_str());
} }
void cling_eval_free(char* str) { void cling_eval_free(char* str) {
@ -126,7 +129,7 @@ void* cling_complete_start(const char* code) {
/// Grab the next completion of some code. Returns nullptr if none is left. /// Grab the next completion of some code. Returns nullptr if none is left.
const char* cling_complete_next(void* completionHandle) { const char* cling_complete_next(void* completionHandle) {
int* counter = *(int*) completionHandle; int* counter = (int*) completionHandle;
if (++(*counter) > 43) { if (++(*counter) > 43) {
delete counter; delete counter;
return nullptr; return nullptr;