本文整理汇总了C++中KValueRef::SetValue方法的典型用法代码示例。如果您正苦于以下问题:C++ KValueRef::SetValue方法的具体用法?C++ KValueRef::SetValue怎么用?C++ KValueRef::SetValue使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类KValueRef
的用法示例。
在下文中一共展示了KValueRef::SetValue方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: _GetEnvironment
void Process::_GetEnvironment(const ValueList& args, KValueRef result)
{
if (args.size() > 0 && args.at(0)->IsString())
{
KValueRef value = environment->Get(args.at(0)->ToString());
result->SetValue(value);
}
else {
result->SetObject(environment);
}
}
示例2: Evaluate
void PHPEvaluator::Evaluate(const ValueList& args, KValueRef result)
{
static Poco::Mutex evaluatorMutex;
Poco::Mutex::ScopedLock evaluatorLock(evaluatorMutex);
args.VerifyException("evaluate", "s s s o");
TSRMLS_FETCH();
string mimeType(args.GetString(0));
string name(args.GetString(1));
string code(args.GetString(2));
KObjectRef windowGlobal(args.GetObject(3));
KValueRef kv(Value::Undefined);
// Contexts must be the same for runs with the same global object.
string contextId(GetContextId(windowGlobal));
PHPUtils::GenerateCaseMap(code TSRMLS_CC);
std::ostringstream codeString;
codeString << "namespace " << contextId << " {\n";
codeString << code << "\n";
codeString << " $__fns = get_defined_functions();\n";
codeString << " if (array_key_exists(\"user\", $__fns)) {\n";
codeString << " foreach($__fns[\"user\"] as $fname) {\n";
codeString << " if (!$window->$fname) {";
codeString << " krollAddFunction($window, $fname);\n";
codeString << " }\n";
codeString << " }\n";
codeString << " }\n";
codeString << "}\n";
printf("%s\n", codeString.str().c_str());
// This seems to be needed to make PHP actually give us errors
// at parse/compile time -- see: main/main.c line 969
PG(during_request_startup) = 0;
KObjectRef previousGlobal(PHPUtils::GetCurrentGlobalObject());
PHPUtils::SwapGlobalObject(windowGlobal, &EG(symbol_table) TSRMLS_CC);
zend_first_try
{
zend_eval_string((char *) codeString.str().c_str(), NULL,
(char *) name.c_str() TSRMLS_CC);
}
zend_catch
{
Logger::Get("PHP")->Error("Evaluation of script failed");
}
zend_end_try();
PHPUtils::SwapGlobalObject(previousGlobal, &EG(symbol_table) TSRMLS_CC);
result->SetValue(kv);
}
示例3: 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));
}
示例4: _RunOnMainThread
void APIBinding::_RunOnMainThread(const ValueList& args, KValueRef result)
{
if (!args.at(0)->IsMethod())
{
throw ValueException::FromString(
"First argument to runOnMainThread was not a function");
}
else
{
ValueList outArgs;
for (size_t i = 1; i < args.size(); i++)
outArgs.push_back(args.at(i));
result->SetValue(RunOnMainThread(args.GetMethod(0), outArgs));
}
}
示例5: _Get
void APIBinding::_Get(const ValueList& args, KValueRef result)
{
string s = args.at(0)->ToString();
const char *key = s.c_str();
KValueRef r = 0;
string::size_type pos = s.find_first_of(".");
if (pos==string::npos)
{
r = this->Get(key);
}
else
{
// if we have a period, make it relative to the
// global scope such that <module>.<key> would resolve
// to the 'module' with key named 'key'
r = global->GetNS(key);
}
result->SetValue(r);
}
示例6: _GetExitCode
void Process::_GetExitCode(const ValueList& args, KValueRef result)
{
result->SetValue(exitCode);
}