本文整理汇总了C++中Handle::SetHiddenValue方法的典型用法代码示例。如果您正苦于以下问题:C++ Handle::SetHiddenValue方法的具体用法?C++ Handle::SetHiddenValue怎么用?C++ Handle::SetHiddenValue使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Handle
的用法示例。
在下文中一共展示了Handle::SetHiddenValue方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: BindToJavaObject
int Conv::BindToJavaObject(JNIEnv *jniEnv, jobject jLocal, Handle<Object> val, Handle<String> key) {
jobject ob;
int result = BindToJavaObject(jniEnv, jLocal, val, &ob);
if(result == OK)
val->SetHiddenValue(key, External::Wrap(ob));
return result;
}
示例2: ScopedThreadInit
Handle< Value > ScopedThreadInit( V8Scope* scope, const Arguments &args ) {
Handle<v8::Object> it = args.This();
// NOTE I believe the passed JSThreadConfig will never be freed. If this
// policy is changed, JSThread may no longer be able to store JSThreadConfig
// by reference.
it->SetHiddenValue( v8::String::New( "_JSThreadConfig" ), External::New( new JSThreadConfig( scope, args, true ) ) );
return v8::Undefined();
}
示例3: InterfaceConstructorCallback
void MetadataNode::InterfaceConstructorCallback(const v8::FunctionCallbackInfo<v8::Value>& info)
{
SET_PROFILER_FRAME();
auto thiz = info.This();
auto node = reinterpret_cast<MetadataNode*>(info.Data().As<External>()->Value());
Handle<Object> implementationObject;
Handle<String> v8ExtendName;
string extendLocation;
bool extendLocationFound = GetExtendLocation(extendLocation);
if (info.Length() == 1)
{
if (!extendLocationFound)
{
ASSERT_FAIL("Invalid extend() call. No name specified for extend. Location: %s", extendLocation.c_str());
}
ASSERT_MESSAGE(info[0]->IsObject(), "Invalid extend() call. No implementation object specified. Location: %s", extendLocation.c_str());
implementationObject = info[0]->ToObject();
}
else if (info.Length() == 2)
{
ASSERT_MESSAGE(info[0]->IsString(), "Invalid extend() call. No name for extend specified. Location: %s", extendLocation.c_str());
ASSERT_MESSAGE(info[1]->IsObject(), "Invalid extend() call. Named extend should be called with second object parameter containing overridden methods. Location: %s", extendLocation.c_str());
DEBUG_WRITE("InterfaceConstructorCallback: getting extend name");
v8ExtendName = info[0]->ToString();
implementationObject = info[1]->ToObject();
}
else
{
ASSERT_FAIL("Invalid extend() call. Location: %s", extendLocation.c_str());
}
auto className = node->m_implType;
auto extendName = ConvertToString(v8ExtendName);
auto extendNameAndLocation = extendLocation + extendName;
SetInstanceMetadata(info.GetIsolate(), implementationObject, node);
//@@@ Refactor
string fullClassName = CreateFullClassName(className, extendNameAndLocation);
thiz->SetHiddenValue(ConvertToV8String("implClassName"), ConvertToV8String(fullClassName));
//
jclass generatedClass = s_resolveClass(fullClassName, implementationObject);
implementationObject->SetHiddenValue(ConvertToV8String(fullClassName), External::New(Isolate::GetCurrent(), generatedClass));//
implementationObject->SetPrototype(thiz->GetPrototype());
thiz->SetPrototype(implementationObject);
thiz->SetHiddenValue(ConvertToV8String("t::implObj"), implementationObject);
ArgsWrapper argWrapper(info, ArgType::Interface, Handle<Object>());
auto success = s_registerInstance(thiz, fullClassName, argWrapper, implementationObject, true);
assert(success);
}
示例4: setTiObjectToJsObject
void TiObject::setTiObjectToJsObject(Handle<Value> jsObject, TiObject* tiObj)
{
if (!jsObject->IsObject())
{
return;
}
Handle<Object> obj = Handle<Object>::Cast(jsObject);
obj->SetHiddenValue(String::New(HIDDEN_TI_OBJECT_PROPERTY), External::New(tiObj));
}
示例5:
int Conv::BindToV8Object(JNIEnv *jniEnv, Handle<Object> val, Handle<String> key, jobject jLocal, jobject *jHard) {
if(!jLocal || jniEnv->ExceptionCheck()) {
jniEnv->ExceptionClear();
return ErrorVM;
}
jobject jWeak = jniEnv->NewWeakGlobalRef(jLocal);
val->SetHiddenValue(key, External::Wrap(jWeak));
*jHard = jLocal;
return OK;
}
示例6: onAddEventListener
void TiProxy::onAddEventListener(const char* eventName, Handle<Function> eventFunction)
{
NativeObject* no = getNativeObject();
if (no == NULL)
{
// To support events we need to create a native proxy
// instance here if no native object has been set yet.
no = new NativeProxyObject(this);
setNativeObject(no);
}
Handle<Object> source = Handle<Object>::Cast(getValue());
TiV8Event* event = TiV8Event::createEvent(eventName, eventFunction, source);
no->setEventHandler(eventName, event);
no->release();
no = NULL;
int id = event->getId();
eventFunction->SetHiddenValue(String::New("POINTER"), External::New(event));
eventFunction->SetHiddenValue(String::New("OWNER"), External::New(this));
eventFunction->SetHiddenValue(String::New("ID"), Integer::New(id));
}
示例7: New
void Shape::New(const v8::FunctionCallbackInfo<Value>& args)
{
HandleScope scope;
Handle<Object> self = args.Holder();
Shape *shape;
if (args[0]->IsExternal())
{
Local<External> ext = Local<External>::Cast(args[0]);
void *ptr = ext->Value();
shape = static_cast<Shape*>(ptr);
shape->Wrap(args.Holder());
}
else
{
shapeObj *s = (shapeObj *)msSmallMalloc(sizeof(shapeObj));
msInitShape(s);
if(args.Length() >= 1) {
s->type = args[0]->Int32Value();
}
else {
s->type = MS_SHAPE_NULL;
}
shape = new Shape(s);
shape->Wrap(self);
}
/* create the attribute template. should use ObjectWrap in future */
Handle<ObjectTemplate> attributes_templ = ObjectTemplate::New();
attributes_templ->SetInternalFieldCount(2);
attributes_templ->SetNamedPropertyHandler(attributeGetValue,
attributeSetValue);
Handle<Object> attributes = attributes_templ->NewInstance();
map<string, int> *attributes_map = new map<string, int>();
attributes->SetInternalField(0, External::New(attributes_map));
attributes->SetInternalField(1, External::New(shape->get()->values));
attributes->SetHiddenValue(String::New("__parent__"), self);
if (shape->layer) {
for (int i=0; i<shape->layer->numitems; ++i) {
(*attributes_map)[string(shape->layer->items[i])] = i;
}
}
Persistent<Object> pattributes;
pattributes.Reset(Isolate::GetCurrent(), attributes);
pattributes.MakeWeak(attributes_map, attributeWeakCallback);
pattributes.MarkIndependent();
self->Set(String::New("attributes"), attributes);
}
示例8: CreateExternalArrayBuffer
Handle<Value> CreateExternalArrayBuffer(int32_t length, uint8_t *data) {
Handle<Object> buffer = Object::New();
buffer->SetHiddenValue(String::New(kArrayBufferMarkerPropName), True());
Persistent<Object> persistent_array = Persistent<Object>::New(buffer);
persistent_array.MakeWeak(data, ExternalArrayWeakCallback);
persistent_array.MarkIndependent();
buffer->SetIndexedPropertiesToExternalArrayData(
data, v8::kExternalByteArray, length);
buffer->Set(String::New("byteLength"), Int32::New(length), ReadOnly);
buffer->Set(String::New("address"), Int32::New(reinterpret_cast<uint32_t>(data)), ReadOnly);
return buffer;
}
示例9: GetCachedExtendedClassData
Handle<Object> MetadataNode::CreateExtendedJSWrapper(Isolate *isolate, const string& proxyClassName)
{
Handle<Object> extInstance;
auto cacheData = GetCachedExtendedClassData(isolate, proxyClassName);
if (cacheData.node != nullptr)
{
extInstance = Object::New(isolate);
auto extdCtorFunc = Local<Function>::New(isolate, *cacheData.extendedCtorFunction);
extInstance->SetPrototype(extdCtorFunc->Get(ConvertToV8String("prototype")));
SetInstanceMetadata(isolate, extInstance, cacheData.node);
extInstance->SetHiddenValue(ConvertToV8String("implClassName"), ConvertToV8String(cacheData.extendedName));
}
return extInstance;
}
示例10: NanEscapeScope
Handle<Value> Layer::New(OGRLayer *raw, OGRDataSource *raw_parent, bool result_set)
#endif
{
NanEscapableScope();
if (!raw) {
return NanEscapeScope(NanNull());
}
if (cache.has(raw)) {
return NanEscapeScope(NanNew(cache.get(raw)));
}
Layer *wrapped = new Layer(raw);
wrapped->is_result_set = result_set;
Handle<Value> ext = NanNew<External>(wrapped);
Handle<Object> obj = NanNew(Layer::constructor)->GetFunction()->NewInstance(1, &ext);
cache.add(raw, obj);
//add reference to datasource so datasource doesnt get GC'ed while layer is alive
if (raw_parent) {
Handle<Value> ds;
#if GDAL_VERSION_MAJOR >= 2
if (Dataset::dataset_cache.has(raw_parent)) {
ds = NanNew(Dataset::dataset_cache.get(raw_parent));
}
#else
if (Dataset::datasource_cache.has(raw_parent)) {
ds = NanNew(Dataset::datasource_cache.get(raw_parent));
}
#endif
else {
LOG("Layer's parent dataset disappeared from cache (layer = %p, dataset = %p)", raw, raw_parent);
NanThrowError("Layer's parent dataset disappeared from cache");
return NanEscapeScope(NanUndefined());
//ds = Dataset::New(raw_parent); //should never happen
}
wrapped->parent_ds = raw_parent;
obj->SetHiddenValue(NanNew("ds_"), ds);
}
return NanEscapeScope(obj);
}
示例11: rr_reflect_v8_object_as
VALUE rr_reflect_v8_object_as(Handle<Value> value, VALUE ruby_class) {
Handle<Object> object = Handle<Object>::Cast(value);
VALUE handle;
v8_weakref* backref;
Local<Value> holder = object->GetHiddenValue(String::NewSymbol("TheRubyRacer::Backref"));
if (holder.IsEmpty()) {
handle = rr_v8_handle_new(ruby_class, object);
backref = new v8_weakref(handle);
object->SetHiddenValue(String::NewSymbol("TheRubyRacer::Backref"), backref->external);
} else {
backref = (v8_weakref*)External::Unwrap(holder);
handle = backref->get();
if (!RTEST(handle)) {
handle = rr_v8_handle_new(ruby_class, object);
backref->set(handle);
}
}
return handle;
}
示例12:
bool tns::V8SetHiddenValue(const Handle<Object>& obj, const string& propName, const Handle<Value>& value)
{
auto s = tns::ConvertToV8String(propName);
return obj->SetHiddenValue(s, value);
}
示例13: ExtendCallMethodHandler
void MetadataNode::ExtendCallMethodHandler(const v8::FunctionCallbackInfo<v8::Value>& info)
{
if (info.IsConstructCall())
{
string exMsg("Cannot call 'extend' as constructor");
ExceptionUtil::GetInstance()->ThrowExceptionToJs(exMsg);
return;
}
SET_PROFILER_FRAME();
Handle<Object> implementationObject;
Handle<String> extendName;
string extendLocation;
auto validArgs = ValidateExtendArguments(info, extendLocation, extendName, implementationObject);
if (!validArgs)
return;
auto node = reinterpret_cast<MetadataNode*>(info.Data().As<External>()->Value());
DEBUG_WRITE("ExtendsCallMethodHandler: called with %s", ConvertToString(extendName).c_str());
string extendNameAndLocation = extendLocation + ConvertToString(extendName);
auto fullClassName = TNS_PREFIX + CreateFullClassName(node->m_name, extendNameAndLocation);
//
JEnv env;
//resolve class (pre-generated or generated runtime from dex generator)
jclass generatedClass = s_resolveClass(fullClassName, implementationObject); //resolve class returns GlobalRef
std::string generatedFullClassName = s_objectManager->GetClassName(generatedClass);
//
auto fullExtendedName = generatedFullClassName;
DEBUG_WRITE("ExtendsCallMethodHandler: extend full name %s", fullClassName.c_str());
auto isolate = info.GetIsolate();
auto cachedData = GetCachedExtendedClassData(isolate, fullExtendedName);
if (cachedData.extendedCtorFunction != nullptr)
{
auto cachedExtendedCtorFunc = Local<Function>::New(isolate, *cachedData.extendedCtorFunction);
info.GetReturnValue().Set(cachedExtendedCtorFunc);
return;
}
auto implementationObjectPropertyName = V8StringConstants::GetClassImplementationObject();
//reuse validation - checks that implementationObject is not reused for different classes
auto implementationObjectProperty = implementationObject->GetHiddenValue(implementationObjectPropertyName).As<String>();
if (implementationObjectProperty.IsEmpty())
{
//mark the implementationObject as such and set a pointer to it's class node inside it for reuse validation later
implementationObject->SetHiddenValue(implementationObjectPropertyName, String::NewFromUtf8(isolate, fullExtendedName.c_str()));
//append resolved class to implementation object
implementationObject->SetHiddenValue(ConvertToV8String(fullExtendedName), External::New(Isolate::GetCurrent(), generatedClass));
}
else
{
string usedClassName = ConvertToString(implementationObjectProperty);
stringstream s;
s << "This object is used to extend another class '" << usedClassName << "'";
ExceptionUtil::GetInstance()->ThrowExceptionToJs(s.str());
return;
}
auto baseClassCtorFunc = node->GetConstructorFunction(isolate);
auto extendData = External::New(isolate, new ExtendedClassData(node, extendNameAndLocation, implementationObject, fullExtendedName));
auto extendFuncTemplate = FunctionTemplate::New(isolate, ExtendedClassConstructorCallback, extendData);
auto extendFunc = extendFuncTemplate->GetFunction();
auto prototypeName = ConvertToV8String("prototype");
implementationObject->SetPrototype(baseClassCtorFunc->Get(prototypeName));
implementationObject->SetAccessor(ConvertToV8String("super"), SuperAccessorGetterCallback, nullptr, implementationObject);
extendFunc->Set(prototypeName, implementationObject);
extendFunc->SetPrototype(baseClassCtorFunc);
SetClassAccessor(extendFunc);
SetTypeMetadata(isolate, extendFunc, new TypeMetadata(fullExtendedName));
info.GetReturnValue().Set(extendFunc);
s_name2NodeCache.insert(make_pair(fullExtendedName, node));
ExtendedClassCacheData cacheData(extendFunc, fullExtendedName, node);
s_extendedCtorFuncCache.insert(make_pair(fullExtendedName, cacheData));
}
示例14: SetInstanceMetadata
void MetadataNode::SetInstanceMetadata(Isolate *isolate, Handle<Object> value, MetadataNode *node)
{
auto key = Local<String>::New(isolate, *s_metadataKey);
value->SetHiddenValue(key, External::New(isolate, node));
}
示例15: SetPackageMetadata
void MetadataNode::SetPackageMetadata(Isolate *isolate, Handle<Object> value, MetadataNode *node)
{
value->SetHiddenValue(ConvertToV8String("tns::PackageMetadata"), External::New(isolate, node));
}