本文整理汇总了C++中KValueRef::DisplayString方法的典型用法代码示例。如果您正苦于以下问题:C++ KValueRef::DisplayString方法的具体用法?C++ KValueRef::DisplayString怎么用?C++ KValueRef::DisplayString使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类KValueRef
的用法示例。
在下文中一共展示了KValueRef::DisplayString方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Evaluate
void RubyEvaluator::Evaluate(const ValueList& args, KValueRef result)
{
args.VerifyException("evaluate", "s s s o");
//const char *mimeType = args.GetString(0).c_str();
std::string name = args.GetString(1);
std::string code = args.GetString(2);
global_object = args.GetObject(3);
VALUE ctx = this->GetContext(global_object);
VALUE rargs = rb_ary_new();
rb_ary_push(rargs, ctx);
rb_ary_push(rargs, rb_str_new2(code.c_str()));
int error;
VALUE returnValue = rb_protect(reval_do_call, rargs, &error);
RubyEvaluator::ContextToGlobal(ctx, global_object);
if (error != 0)
{
std::string error("An error occured while parsing Ruby (");
error += name;
error += "): ";
// Display a stringified version of the exception.
VALUE exception = rb_gv_get("$!");
KValueRef v = RubyUtils::ToKrollValue(exception);
SharedString ss = v->DisplayString();
error.append(ss->c_str());
// Try to make a nice backtrace for the user.
VALUE backtrace = rb_funcall(exception,
rb_intern("backtrace"), 0);
VALUE rBacktraceString = rb_funcall(backtrace,
rb_intern("join"), 1, rb_str_new2("\n"));
if (TYPE(rBacktraceString) == T_STRING)
{
error.append("\n");
error.append(StringValuePtr(rBacktraceString));
}
Logger *logger = Logger::Get("Ruby");
logger->Error(error);
result->SetUndefined();
return;
}
result->SetValue(RubyUtils::ToKrollValue(returnValue));
}
示例2: _Print
void APIBinding::_Print(const ValueList& args, KValueRef result)
{
for (size_t c=0; c < args.size(); c++)
{
KValueRef arg = args.at(c);
if (arg->IsString())
{
const char *s = arg->ToString();
std::cout << s;
}
else
{
SharedString ss = arg->DisplayString();
std::cout << *ss;
}
}
std::cout.flush();
}
示例3: StdErr
void AppBinding::StdErr(const ValueList& args, KValueRef result)
{
for (size_t c = 0; c < args.size(); c++)
{
KValueRef arg = args.at(c);
if (arg->IsString())
{
const char *s = arg->ToString();
std::cerr << s;
}
else
{
SharedString ss = arg->DisplayString();
std::cerr << *ss;
}
}
std::cerr << std::endl;
}
示例4: Log
//---------------- IMPLEMENTATION METHODS
void APIBinding::Log(int severity, KValueRef value)
{
// optimize these calls since they're called a lot
if (false == logger->IsEnabled((Logger::Level)severity))
{
return;
}
if (value->IsString())
{
string message = value->ToString();
logger->Log((Logger::Level) severity, message);
}
else
{
SharedString message = value->DisplayString();
logger->Log((Logger::Level) severity, *message);
}
}
示例5: DisplayString
SharedString KObject::DisplayString(int levels)
{
std::stringstream ss;
SharedStringList props = this->GetPropertyNames();
ss << "(" << this->GetType() << ")" << " {";
for (size_t i = 0; i < props->size(); i++)
{
KValueRef prop = this->Get(props->at(i));
SharedString disp_string = prop->DisplayString(levels);
ss << " " << *(props->at(i))
<< " : " << *disp_string << ",";
}
if (props->size() > 0) // Erase last comma
ss.seekp((int)ss.tellp() - 1);
ss << "}";
return new std::string(ss.str());
}