本文整理汇总了C++中PropertyCallbackInfo::GetReturnValue方法的典型用法代码示例。如果您正苦于以下问题:C++ PropertyCallbackInfo::GetReturnValue方法的具体用法?C++ PropertyCallbackInfo::GetReturnValue怎么用?C++ PropertyCallbackInfo::GetReturnValue使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PropertyCallbackInfo
的用法示例。
在下文中一共展示了PropertyCallbackInfo::GetReturnValue方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: GetX
void Point::GetX( Local< String > prop, const PropertyCallbackInfo< Value > &info ) {
// Enter new scope
HandleScope scope;
// Get wrapped object
Local< Object > self = info.Holder();
Local< External > wrap = Local< External >::Cast( self->GetInternalField( 0 ) );
// Set return value
Point* point = static_cast< Point* >( wrap->Value() );
info.GetReturnValue().Set( Number::New( point->GetX() ) );
}
示例2: Enumerator
void BookWrap::Enumerator(const PropertyCallbackInfo<Array>& info) {
Isolate* isolate = info.GetIsolate();
HandleScope scope(isolate);
Book* b = ObjectWrap::Unwrap<BookWrap>(info.This())->m_book;
Handle<v8::Array> result = v8::Array::New(isolate, b->size());
for(size_t i=0; i<b->size(); ++i) {
result->Set(i, Integer::New(isolate, i));
}
info.GetReturnValue().Set(result);
}
示例3: PackageGetterCallback
void MetadataNode::PackageGetterCallback(Local<String> property, const PropertyCallbackInfo<Value>& info)
{
try
{
string propName = ConvertToString(property);
if (propName.empty())
return;
auto isolate = Isolate::GetCurrent();
HandleScope handleScope(isolate);
auto thiz = info.This();
auto cachedItem = thiz->GetHiddenValue(property);
if (cachedItem.IsEmpty())
{
auto node = GetPackageMetadata(isolate, thiz);
uint8_t nodeType = s_metadataReader.GetNodeType(node->m_treeNode);
DEBUG_WRITE("MetadataNode::GetterCallback: prop '%s' for node '%s' called, nodeType=%d, hash=%d", propName.c_str(), node->m_treeNode->name.c_str(), nodeType, thiz.IsEmpty() ? -42 : thiz->GetIdentityHash());
auto child = GetChildMetadataForPackage(node, propName);
auto foundChild = child.treeNode != nullptr;
if (foundChild)
{
auto childNode = MetadataNode::GetOrCreateInternal(child.treeNode);
cachedItem = childNode->CreateWrapper(isolate);
thiz->SetHiddenValue(property, cachedItem);
}
}
info.GetReturnValue().Set(cachedItem);
}
catch (NativeScriptException& e)
{
e.ReThrowToV8();
}
catch (std::exception e) {
stringstream ss;
ss << "Error: c++ exception: " << e.what() << endl;
NativeScriptException nsEx(ss.str());
nsEx.ReThrowToV8();
}
catch (...) {
NativeScriptException nsEx(std::string("Error: c++ exception!"));
nsEx.ReThrowToV8();
}
}
示例4: GetPath
void JsHttpRequestProcessor::GetPath(Local<String> name,
const PropertyCallbackInfo<Value>& info) {
// Extract the C++ request object from the JavaScript wrapper.
HttpRequest* request = UnwrapRequest(info.Holder());
// Fetch the path.
const string& path = request->Path();
// Wrap the result in a JavaScript string and return it.
info.GetReturnValue().Set(
String::NewFromUtf8(info.GetIsolate(), path.c_str(),
NewStringType::kNormal,
static_cast<int>(path.length())).ToLocalChecked());
}
示例5: MapSet
void JsHttpRequestProcessor::MapSet(Local<Name> name, Local<Value> value_obj,
const PropertyCallbackInfo<Value>& info) {
if (name->IsSymbol()) return;
// Fetch the map wrapped by this object.
map<string, string>* obj = UnwrapMap(info.Holder());
// Convert the key and value to std::strings.
string key = ObjectToString(Local<String>::Cast(name));
string value = ObjectToString(value_obj);
// Update the map.
(*obj)[key] = value;
// Return the value; any non-empty handle will work.
info.GetReturnValue().Set(value_obj);
}
示例6: SuperAccessorGetterCallback
void MetadataNode::SuperAccessorGetterCallback(Local<String> property, const PropertyCallbackInfo<Value>& info)
{
try
{
auto thiz = info.This();
auto isolate = info.GetIsolate();
auto k = ConvertToV8String("supervalue");
auto superValue = thiz->GetHiddenValue(k).As<Object>();
if (superValue.IsEmpty())
{
superValue = s_objectManager->GetEmptyObject(isolate);
bool d = superValue->Delete(ConvertToV8String("toString"));
d = superValue->Delete(ConvertToV8String("valueOf"));
superValue->SetInternalField(static_cast<int>(ObjectManager::MetadataNodeKeys::CallSuper), True(isolate));
superValue->SetPrototype(thiz->GetPrototype().As<Object>()->GetPrototype().As<Object>()->GetPrototype());
thiz->SetHiddenValue(k, superValue);
s_objectManager->CloneLink(thiz, superValue);
DEBUG_WRITE("superValue.GetPrototype=%d", superValue->GetPrototype().As<Object>()->GetIdentityHash());
auto node = GetInstanceMetadata(isolate, thiz);
SetInstanceMetadata(isolate, superValue, node);
thiz->SetHiddenValue(k, superValue);
}
info.GetReturnValue().Set(superValue);
}
catch (NativeScriptException& e)
{
e.ReThrowToV8();
}
catch (std::exception e) {
stringstream ss;
ss << "Error: c++ exception: " << e.what() << endl;
NativeScriptException nsEx(ss.str());
nsEx.ReThrowToV8();
}
catch (...) {
NativeScriptException nsEx(std::string("Error: c++ exception!"));
nsEx.ReThrowToV8();
}
}
示例7: InnerClassAccessorGetterCallback
void MetadataNode::InnerClassAccessorGetterCallback(Local<String> property, const PropertyCallbackInfo<Value>& info)
{
try
{
auto isolate = info.GetIsolate();
auto thiz = info.This();
auto node = reinterpret_cast<MetadataNode*>(info.Data().As<External>()->Value());
auto innerKey = ConvertToV8String("inner:" + node->m_treeNode->name);
auto innerTypeCtorFunc = thiz->GetHiddenValue(innerKey).As<Function>();
if (innerTypeCtorFunc.IsEmpty())
{
auto funcTemplate = node->GetConstructorFunctionTemplate(isolate, node->m_treeNode);
auto ctorFunc = funcTemplate->GetFunction();
auto innerClassData = External::New(isolate, new InnerClassData(new Persistent<Object>(isolate, thiz), node));
auto innerTypeCtorFuncTemplate = FunctionTemplate::New(isolate, InnerClassConstructorCallback, innerClassData);
innerTypeCtorFuncTemplate->InstanceTemplate()->SetInternalFieldCount(static_cast<int>(ObjectManager::MetadataNodeKeys::END));
innerTypeCtorFunc = innerTypeCtorFuncTemplate->GetFunction();
auto prototypeName = ConvertToV8String("prototype");
auto innerTypeCtorFuncPrototype = innerTypeCtorFunc->Get(prototypeName).As<Object>();
innerTypeCtorFuncPrototype->SetPrototype(ctorFunc->Get(prototypeName));
thiz->SetHiddenValue(innerKey, innerTypeCtorFunc);
}
info.GetReturnValue().Set(innerTypeCtorFunc);
}
catch (NativeScriptException& e)
{
e.ReThrowToV8();
}
catch (std::exception e) {
stringstream ss;
ss << "Error: c++ exception: " << e.what() << endl;
NativeScriptException nsEx(ss.str());
nsEx.ReThrowToV8();
}
catch (...) {
NativeScriptException nsEx(std::string("Error: c++ exception!"));
nsEx.ReThrowToV8();
}
}
示例8: defined
static void
gum_v8_probe_args_on_get_nth (uint32_t index,
const PropertyCallbackInfo<Value> & info)
{
Handle<Object> instance = info.This ();
GumV8CallProbe * self = static_cast<GumV8CallProbe *> (
instance->GetAlignedPointerFromInternalField (0));
GumCallSite * site = static_cast<GumCallSite *> (
instance->GetAlignedPointerFromInternalField (1));
gsize value;
gsize * stack_argument = static_cast<gsize *> (site->stack_data);
#if defined (HAVE_I386) && GLIB_SIZEOF_VOID_P == 8
switch (index)
{
# if GUM_NATIVE_ABI_IS_UNIX
case 0: value = site->cpu_context->rdi; break;
case 1: value = site->cpu_context->rsi; break;
case 2: value = site->cpu_context->rdx; break;
case 3: value = site->cpu_context->rcx; break;
case 4: value = site->cpu_context->r8; break;
case 5: value = site->cpu_context->r9; break;
default:
value = stack_argument[index - 6];
break;
# else
case 0: value = site->cpu_context->rcx; break;
case 1: value = site->cpu_context->rdx; break;
case 2: value = site->cpu_context->r8; break;
case 3: value = site->cpu_context->r9; break;
default:
value = stack_argument[index];
break;
# endif
}
#else
value = stack_argument[index];
#endif
info.GetReturnValue ().Set (
_gum_v8_native_pointer_new (GSIZE_TO_POINTER (value), self->parent->core));
}
示例9: attributeGetValue
void Shape::attributeGetValue(Local<String> name,
const PropertyCallbackInfo<Value> &info)
{
Local<Object> self = info.Holder();
Local<External> wrap = Local<External>::Cast(self->GetInternalField(0));
void *ptr = wrap->Value();
map<string, int> *indexes = static_cast<map<string, int> *>(ptr);
wrap = Local<External>::Cast(self->GetInternalField(1));
ptr = wrap->Value();
char **values = static_cast<char **>(ptr);
String::Utf8Value utf8_value(name);
string key = string(*utf8_value);
map<string, int>::iterator iter = indexes->find(key);
if (iter != indexes->end()) {
const int &index = (*iter).second;
info.GetReturnValue().Set(String::New(values[index]));
}
}
示例10: FieldAccessorSetterCallback
void MetadataNode::FieldAccessorSetterCallback(Local<String> property,Local<Value> value, const PropertyCallbackInfo<void>& info)
{
DEBUG_WRITE("FieldAccessorSetterCallback");
auto thiz = info.This();
auto fieldCallbackData = reinterpret_cast<FieldCallbackData*>(info.Data().As<External>()->Value());
if (fieldCallbackData->isFinal)
{
stringstream ss;
ss << "You are trying to set \"" << fieldCallbackData->name << "\" which is a final field! Final fields can only be read.";
string exceptionMessage = ss.str();
ExceptionUtil::GetInstance()->ThrowExceptionToJs(exceptionMessage);
}
else
{
NativeScriptRuntime::SetJavaField(thiz, value, fieldCallbackData);
info.GetReturnValue().Set(value);
}
}
示例11: MapGet
void JsHttpRequestProcessor::MapGet(Local<Name> name,
const PropertyCallbackInfo<Value>& info) {
if (name->IsSymbol()) return;
// Fetch the map wrapped by this object.
map<string, string>* obj = UnwrapMap(info.Holder());
// Convert the JavaScript string to a std::string.
string key = ObjectToString(Local<String>::Cast(name));
// Look up the value if it exists using the standard STL ideom.
map<string, string>::iterator iter = obj->find(key);
// If the key is not present return an empty handle as signal
if (iter == obj->end()) return;
// Otherwise fetch the value and wrap it in a JavaScript string
const string& value = (*iter).second;
info.GetReturnValue().Set(
String::NewFromUtf8(info.GetIsolate(), value.c_str(),
NewStringType::kNormal,
static_cast<int>(value.length())).ToLocalChecked());
}
示例12: ArrayLengthGetterCallack
void MetadataNode::ArrayLengthGetterCallack(Local<String> property, const PropertyCallbackInfo<Value>& info)
{
try
{
auto thiz = info.This();
auto length = NativeScriptRuntime::GetArrayLength(thiz);
info.GetReturnValue().Set(Integer::New(info.GetIsolate(), length));
}
catch (NativeScriptException& e)
{
e.ReThrowToV8();
}
catch (std::exception e) {
stringstream ss;
ss << "Error: c++ exception: " << e.what() << endl;
NativeScriptException nsEx(ss.str());
nsEx.ReThrowToV8();
}
catch (...) {
NativeScriptException nsEx(std::string("Error: c++ exception!"));
nsEx.ReThrowToV8();
}
}
示例13: jsGetZ
//! \verbatim
//! Real Quaternion.z
//! \endverbatim
void Quaternion::jsGetZ( Local<v8::String> prop,
const PropertyCallbackInfo<v8::Value>& info )
{
Quaternion* ptr = unwrap( info.This() );
info.GetReturnValue().Set( ptr->z );
}
示例14: ArrayLengthGetterCallack
void MetadataNode::ArrayLengthGetterCallack(Local<String> property, const PropertyCallbackInfo<Value>& info)
{
auto thiz = info.This();
auto length = NativeScriptRuntime::GetArrayLength(thiz);
info.GetReturnValue().Set(Integer::New(info.GetIsolate(), length));
}
示例15: GetOriginX
void GetOriginX(Local<v8::String> name, const PropertyCallbackInfo<Value>& info)
{
DEFINE_HANDLE_SCOPE_AND_GET_SELF_FOR_TRANSFORMABLE;
info.GetReturnValue().Set(Number::New(info.GetIsolate(), static_cast<double>(self->getOrigin().x)));
}