本文整理汇总了C++中ExecState::globalData方法的典型用法代码示例。如果您正苦于以下问题:C++ ExecState::globalData方法的具体用法?C++ ExecState::globalData怎么用?C++ ExecState::globalData使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ExecState
的用法示例。
在下文中一共展示了ExecState::globalData方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: JSCheckScriptSyntax
bool JSCheckScriptSyntax(JSContextRef ctx, JSStringRef script, JSStringRef sourceURL, int startingLineNumber, JSValueRef* exception)
{
ExecState* exec = toJS(ctx);
exec->globalData().heap.registerThread();
JSLock lock(exec);
SourceCode source = makeSource(script->ustring(), sourceURL->ustring(), startingLineNumber);
Completion completion = checkSyntax(exec->dynamicGlobalObject()->globalExec(), source);
if (completion.complType() == Throw) {
if (exception)
*exception = toRef(completion.value());
return false;
}
return true;
}
示例2: JSObjectDeletePrivateProperty
bool JSObjectDeletePrivateProperty(JSContextRef ctx, JSObjectRef object, JSStringRef propertyName)
{
ExecState* exec = toJS(ctx);
APIEntryShim entryShim(exec);
JSObject* jsObject = toJS(object);
Identifier name(propertyName->identifier(&exec->globalData()));
if (jsObject->inherits(&JSCallbackObject<JSGlobalObject>::s_info)) {
static_cast<JSCallbackObject<JSGlobalObject>*>(jsObject)->deletePrivateProperty(name);
return true;
}
if (jsObject->inherits(&JSCallbackObject<JSNonFinalObject>::s_info)) {
static_cast<JSCallbackObject<JSNonFinalObject>*>(jsObject)->deletePrivateProperty(name);
return true;
}
return false;
}
示例3: JSGlobalContextRelease
void JSGlobalContextRelease(JSGlobalContextRef ctx)
{
ExecState* exec = toJS(ctx);
APIEntryShim entryShim(exec);
gcUnprotect(exec->dynamicGlobalObject());
JSGlobalData& globalData = exec->globalData();
if (globalData.refCount() == 2) { // One reference is held by JSGlobalObject, another added by JSGlobalContextRetain().
// The last reference was released, this is our last chance to collect.
globalData.heap.destroy();
} else
globalData.heap.collectAllGarbage();
globalData.deref();
}
示例4: JSObjectSetPropertyAtIndex
void JSObjectSetPropertyAtIndex(JSContextRef ctx, JSObjectRef object, unsigned propertyIndex, JSValueRef value, JSValueRef* exception)
{
ExecState* exec = toJS(ctx);
exec->globalData().heap.registerThread();
JSLock lock(exec);
JSObject* jsObject = toJS(object);
JSValuePtr jsValue = toJS(value);
jsObject->put(exec, propertyIndex, jsValue);
if (exec->hadException()) {
if (exception)
*exception = toRef(exec->exception());
exec->clearException();
}
}
示例5: JSObjectGetPrivateProperty
JSValueRef JSObjectGetPrivateProperty(JSContextRef ctx, JSObjectRef object, JSStringRef propertyName)
{
ExecState* exec = toJS(ctx);
APIEntryShim entryShim(exec);
JSObject* jsObject = toJS(object);
JSValue result;
Identifier name(propertyName->identifier(&exec->globalData()));
if (jsObject->inherits(&JSCallbackObject<JSGlobalObject>::s_info))
result = jsCast<JSCallbackObject<JSGlobalObject>*>(jsObject)->getPrivateProperty(name);
else if (jsObject->inherits(&JSCallbackObject<JSDestructibleObject>::s_info))
result = jsCast<JSCallbackObject<JSDestructibleObject>*>(jsObject)->getPrivateProperty(name);
#if JSC_OBJC_API_ENABLED
else if (jsObject->inherits(&JSCallbackObject<JSAPIWrapperObject>::s_info))
result = jsCast<JSCallbackObject<JSAPIWrapperObject>*>(jsObject)->getPrivateProperty(name);
#endif
return toRef(exec, result);
}
示例6: JSValueMakeNumber
JSValueRef JSValueMakeNumber(JSContextRef ctx, double value)
{
ExecState* exec = toJS(ctx);
exec->globalData().heap.registerThread();
JSLock lock(exec);
#if 1
// added at webkit.org trunk r64706
// Our JSValue representation relies on a standard bit pattern for NaN. NaNs
// generated internally to JavaScriptCore naturally have that representation,
// but an external NaN might not.
if (isnan(value))
value = NaN;
#endif
return toRef(exec, jsNumber(exec, value));
}
示例7: JSValueToObject
JSObjectRef JSValueToObject(JSContextRef ctx, JSValueRef value, JSValueRef* exception)
{
ExecState* exec = toJS(ctx);
exec->globalData().heap.registerThread();
JSLock lock(exec);
JSValuePtr jsValue = toJS(value);
JSObjectRef objectRef = toRef(jsValue.toObject(exec));
if (exec->hadException()) {
if (exception)
*exception = toRef(exec->exception());
exec->clearException();
objectRef = 0;
}
return objectRef;
}
示例8: JSValueToNumber
double JSValueToNumber(JSContextRef ctx, JSValueRef value, JSValueRef* exception)
{
ExecState* exec = toJS(ctx);
exec->globalData().heap.registerThread();
JSLock lock(exec);
JSValuePtr jsValue = toJS(value);
double number = jsValue.toNumber(exec);
if (exec->hadException()) {
if (exception)
*exception = toRef(exec->exception());
exec->clearException();
number = NaN;
}
return number;
}
示例9: JSValueIsEqual
bool JSValueIsEqual(JSContextRef ctx, JSValueRef a, JSValueRef b, JSValueRef* exception)
{
ExecState* exec = toJS(ctx);
exec->globalData().heap.registerThread();
JSLock lock(exec);
JSValuePtr jsA = toJS(a);
JSValuePtr jsB = toJS(b);
bool result = JSValuePtr::equal(exec, jsA, jsB); // false if an exception is thrown
if (exec->hadException()) {
if (exception)
*exception = toRef(exec->exception());
exec->clearException();
}
return result;
}
示例10: JSValueToStringCopy
JSStringRef JSValueToStringCopy(JSContextRef ctx, JSValueRef value, JSValueRef* exception)
{
ExecState* exec = toJS(ctx);
exec->globalData().heap.registerThread();
JSLock lock(exec);
JSValuePtr jsValue = toJS(value);
RefPtr<OpaqueJSString> stringRef(OpaqueJSString::create(jsValue.toString(exec)));
if (exec->hadException()) {
if (exception)
*exception = toRef(exec->exception());
exec->clearException();
stringRef.clear();
}
return stringRef.release().releaseRef();
}
示例11: garbageCollection
bool OAGlobalObject::garbageCollection()
{
AJOAGlobalObject *globalObject = wrapper();
if (globalObject) {
ExecState *exec = globalObject->globalExec();
s_explicit_gc = true;
AJLock lock(exec);
AJGlobalData& globalData = exec->globalData();
if (!globalData.heap.isBusy()) {
globalData.heap.collectAllGarbage();
s_explicit_gc = false;
return true;
}
}
return false;
}
示例12: JSValueIsInstanceOfConstructor
bool JSValueIsInstanceOfConstructor(JSContextRef ctx, JSValueRef value, JSObjectRef constructor, JSValueRef* exception)
{
ExecState* exec = toJS(ctx);
exec->globalData().heap.registerThread();
JSLock lock(exec);
JSValuePtr jsValue = toJS(value);
JSObject* jsConstructor = toJS(constructor);
if (!jsConstructor->structure()->typeInfo().implementsHasInstance())
return false;
bool result = jsConstructor->hasInstance(exec, jsValue, jsConstructor->get(exec, exec->propertyNames().prototype)); // false if an exception is thrown
if (exec->hadException()) {
if (exception)
*exception = toRef(exec->exception());
exec->clearException();
}
return result;
}
示例13: JSGlobalContextRelease
void JSGlobalContextRelease(JSGlobalContextRef ctx)
{
ExecState* exec = toJS(ctx);
JSLock lock(exec);
gcUnprotect(exec->dynamicGlobalObject());
JSGlobalData& globalData = exec->globalData();
if (globalData.refCount() == 2) { // One reference is held by JSGlobalObject, another added by JSGlobalContextRetain().
// The last reference was released, this is our last chance to collect.
ASSERT(!globalData.heap.protectedObjectCount());
ASSERT(!globalData.heap.isBusy());
globalData.heap.destroy();
} else
globalData.heap.collect();
globalData.deref();
}
示例14: JSGlobalContextRelease
void JSGlobalContextRelease(JSGlobalContextRef ctx)
{
IdentifierTable* savedIdentifierTable;
ExecState* exec = toJS(ctx);
{
JSLockHolder lock(exec);
JSGlobalData& globalData = exec->globalData();
savedIdentifierTable = wtfThreadData().setCurrentIdentifierTable(globalData.identifierTable);
bool protectCountIsZero = Heap::heap(exec->dynamicGlobalObject())->unprotect(exec->dynamicGlobalObject());
if (protectCountIsZero)
globalData.heap.reportAbandonedObjectGraph();
globalData.deref();
}
wtfThreadData().setCurrentIdentifierTable(savedIdentifierTable);
}
示例15: JSObjectCopyPropertyNames
JSPropertyNameArrayRef JSObjectCopyPropertyNames(JSContextRef ctx, JSObjectRef object)
{
JSObject* jsObject = toJS(object);
ExecState* exec = toJS(ctx);
APIEntryShim entryShim(exec);
JSGlobalData* globalData = &exec->globalData();
JSPropertyNameArrayRef propertyNames = new OpaqueJSPropertyNameArray(globalData);
PropertyNameArray array(globalData);
jsObject->methodTable()->getPropertyNames(jsObject, exec, array, ExcludeDontEnumProperties);
size_t size = array.size();
propertyNames->array.reserveInitialCapacity(size);
for (size_t i = 0; i < size; ++i)
propertyNames->array.append(JSRetainPtr<JSStringRef>(Adopt, OpaqueJSString::create(array[i].ustring()).leakRef()));
return JSPropertyNameArrayRetain(propertyNames);
}