本文整理汇总了C++中WeakMapData类的典型用法代码示例。如果您正苦于以下问题:C++ WeakMapData类的具体用法?C++ WeakMapData怎么用?C++ WeakMapData使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了WeakMapData类的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: protoFuncWeakMapHas
EncodedJSValue JSC_HOST_CALL protoFuncWeakMapHas(CallFrame* callFrame)
{
WeakMapData* map = getWeakMapData(callFrame, callFrame->thisValue());
if (!map)
return JSValue::encode(jsUndefined());
JSValue key = callFrame->argument(0);
return JSValue::encode(jsBoolean(key.isObject() && map->contains(asObject(key))));
}
示例2: protoFuncWeakMapClear
EncodedJSValue JSC_HOST_CALL protoFuncWeakMapClear(CallFrame* callFrame)
{
WeakMapData* map = getWeakMapData(callFrame, callFrame->thisValue());
if (!map)
return JSValue::encode(jsUndefined());
map->clear();
return JSValue::encode(jsUndefined());
}
示例3: protoFuncWeakMapGet
EncodedJSValue JSC_HOST_CALL protoFuncWeakMapGet(CallFrame* callFrame)
{
WeakMapData* map = getWeakMapData(callFrame, callFrame->thisValue());
if (!map)
return JSValue::encode(jsUndefined());
JSValue key = callFrame->argument(0);
if (!key.isObject())
return JSValue::encode(throwTypeError(callFrame, WTF::ASCIILiteral("A WeakMap cannot have a non-object key")));
return JSValue::encode(map->get(asObject(key)));
}
示例4: protoFuncWeakMapSet
EncodedJSValue JSC_HOST_CALL protoFuncWeakMapSet(CallFrame* callFrame)
{
WeakMapData* map = getWeakMapData(callFrame, callFrame->thisValue());
if (!map)
return JSValue::encode(jsUndefined());
JSValue key = callFrame->argument(0);
if (!key.isObject())
return JSValue::encode(throwTypeError(callFrame, WTF::ASCIILiteral("Attempted to set a non-object key in a WeakMap")));
map->set(callFrame->vm(), asObject(key), callFrame->argument(1));
return JSValue::encode(callFrame->thisValue());
}
示例5: protoFuncWeakMapSet
EncodedJSValue JSC_HOST_CALL protoFuncWeakMapSet(CallFrame* callFrame)
{
VM& vm = callFrame->vm();
auto scope = DECLARE_THROW_SCOPE(vm);
WeakMapData* map = getWeakMapData(callFrame, callFrame->thisValue());
ASSERT(!!scope.exception() == !map);
if (!map)
return JSValue::encode(jsUndefined());
JSValue key = callFrame->argument(0);
if (!key.isObject())
return JSValue::encode(throwTypeError(callFrame, scope, WTF::ASCIILiteral("Attempted to set a non-object key in a WeakMap")));
map->set(vm, asObject(key), callFrame->argument(1));
return JSValue::encode(callFrame->thisValue());
}