本文整理汇总了C++中ExecState::dynamicGlobalObject方法的典型用法代码示例。如果您正苦于以下问题:C++ ExecState::dynamicGlobalObject方法的具体用法?C++ ExecState::dynamicGlobalObject怎么用?C++ ExecState::dynamicGlobalObject使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ExecState
的用法示例。
在下文中一共展示了ExecState::dynamicGlobalObject方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: JSContextGetGlobalObject
JSObjectRef JSContextGetGlobalObject(JSContextRef ctx)
{
ExecState* exec = toJS(ctx);
// It is necessary to call toThisObject to get the wrapper object when used with WebCore.
return toRef(exec->dynamicGlobalObject()->toThisObject(exec));
}
示例2: prototype
/*!
// Doc here in case we make this public. (Hopefully we won't.)
@function
@abstract Returns the prototype that will be used when constructing an object with a given class.
@param ctx The execution context to use.
@param jsClass A JSClass whose prototype you want to get.
@result The JSObject prototype that was automatically generated for jsClass, or NULL if no prototype was automatically generated. This is the prototype that will be used when constructing an object using jsClass.
*/
JSObject* OpaqueJSClass::prototype(JSContextRef ctx)
{
/* Class (C++) and prototype (JS) inheritance are parallel, so:
* (C++) | (JS)
* ParentClass | ParentClassPrototype
* ^ | ^
* | | |
* DerivedClass | DerivedClassPrototype
*/
if (!prototypeClass)
return 0;
ExecState* exec = toJS(ctx);
if (!cachedPrototype) {
// Recursive, but should be good enough for our purposes
JSObject* parentPrototype = 0;
if (parentClass)
parentPrototype = parentClass->prototype(ctx); // can be null
if (!parentPrototype)
parentPrototype = exec->dynamicGlobalObject()->objectPrototype();
cachedPrototype = new (exec) JSCallbackObject<JSObject>(exec, prototypeClass, parentPrototype, this); // set ourself as the object's private data, so it can clear our reference on destruction
}
return cachedPrototype;
}
示例3: AJGlobalContextRelease
void AJGlobalContextRelease(AJGlobalContextRef ctx)
{
ExecState* exec = toJS(ctx);
AJLock lock(exec);
AJGlobalData& globalData = exec->globalData();
AJGlobalObject* dgo = exec->dynamicGlobalObject();
IdentifierTable* savedIdentifierTable = wtfThreadData().setCurrentIdentifierTable(globalData.identifierTable);
// One reference is held by AJGlobalObject, another added by AJGlobalContextRetain().
bool releasingContextGroup = globalData.refCount() == 2;
bool releasingGlobalObject = Heap::heap(dgo)->unprotect(dgo);
// If this is the last reference to a global data, it should also
// be the only remaining reference to the global object too!
ASSERT(!releasingContextGroup || releasingGlobalObject);
// An API 'AJGlobalContextRef' retains two things - a global object and a
// global data (or context group, in API terminology).
// * If this is the last reference to any contexts in the given context group,
// call destroy on the heap (the global data is being freed).
// * If this was the last reference to the global object, then unprotecting
// it may release a lot of GC memory - run the garbage collector now.
// * If there are more references remaining the the global object, then do nothing
// (specifically that is more protects, which we assume come from other AJGlobalContextRefs).
if (releasingContextGroup)
globalData.heap.destroy();
else if (releasingGlobalObject)
globalData.heap.collectAllGarbage();
globalData.deref();
wtfThreadData().setCurrentIdentifierTable(savedIdentifierTable);
}
示例4: evaluate
void WorkerScriptController::evaluate(const ScriptSourceCode& sourceCode, ScriptValue* exception)
{
if (isExecutionForbidden())
return;
initScriptIfNeeded();
JSLock lock(SilenceAssertionsOnly);
ExecState* exec = m_workerContextWrapper->globalExec();
m_workerContextWrapper->globalData().timeoutChecker.start();
JSValue evaluationException;
JSC::evaluate(exec, exec->dynamicGlobalObject()->globalScopeChain(), sourceCode.jsSourceCode(), m_workerContextWrapper.get(), &evaluationException);
m_workerContextWrapper->globalData().timeoutChecker.stop();
if ((evaluationException && isTerminatedExecutionException(evaluationException)) || m_workerContextWrapper->globalData().terminator.shouldTerminate()) {
forbidExecution();
return;
}
if (evaluationException) {
String errorMessage;
int lineNumber = 0;
String sourceURL = sourceCode.url().string();
if (m_workerContext->sanitizeScriptError(errorMessage, lineNumber, sourceURL))
*exception = ScriptValue(*m_globalData, throwError(exec, createError(exec, errorMessage.impl())));
else
*exception = ScriptValue(*m_globalData, evaluationException);
}
}
示例5: JSGlobalContextRetain
JSGlobalContextRef JSGlobalContextRetain(JSGlobalContextRef ctx)
{
JSLock lock;
ExecState* exec = toJS(ctx);
gcProtect(exec->dynamicGlobalObject());
return ctx;
}
示例6: JSEvaluateScript
JSValueRef JSEvaluateScript(JSContextRef ctx, JSStringRef script, JSObjectRef thisObject, JSStringRef sourceURL, int startingLineNumber, JSValueRef* exception)
{
ExecState* exec = toJS(ctx);
exec->globalData().heap.registerThread();
JSLock lock(exec);
JSObject* jsThisObject = toJS(thisObject);
// evaluate sets "this" to the global object if it is NULL
JSGlobalObject* globalObject = exec->dynamicGlobalObject();
SourceCode source = makeSource(script->ustring(), sourceURL->ustring(), startingLineNumber);
Completion completion = evaluate(globalObject->globalExec(), globalObject->globalScopeChain(), source, jsThisObject);
if (completion.complType() == Throw) {
if (exception)
*exception = toRef(completion.value());
return 0;
}
if (completion.value())
return toRef(completion.value());
// happens, for example, when the only statement is an empty (';') statement
return toRef(jsUndefined());
}
示例7: JSGlobalContextRelease
void JSGlobalContextRelease(JSGlobalContextRef ctx)
{
ExecState* exec = toJS(ctx);
JSLock lock(exec);
gcUnprotect(exec->dynamicGlobalObject());
}
示例8: evaluate
ScriptValue WorkerScriptController::evaluate(const ScriptSourceCode& sourceCode)
{
{
MutexLocker lock(m_sharedDataMutex);
if (m_executionForbidden)
return noValue();
}
initScriptIfNeeded();
JSLock lock(false);
ExecState* exec = m_workerContextWrapper->globalExec();
m_workerContextWrapper->startTimeoutCheck();
Completion comp = JSC::evaluate(exec, exec->dynamicGlobalObject()->globalScopeChain(), sourceCode.jsSourceCode(), m_workerContextWrapper);
m_workerContextWrapper->stopTimeoutCheck();
m_workerContext->thread()->messagingProxy()->reportWorkerThreadActivity(m_workerContext->hasPendingActivity());
if (comp.complType() == Normal || comp.complType() == ReturnValue)
return comp.value();
if (comp.complType() == Throw)
reportException(exec, comp.value());
return noValue();
}
示例9: JSEvaluateScript
JSValueRef JSEvaluateScript(JSContextRef ctx, JSStringRef script, JSObjectRef thisObject, JSStringRef sourceURL, int startingLineNumber, JSValueRef* exception)
{
if (!ctx) {
ASSERT_NOT_REACHED();
return 0;
}
ExecState* exec = toJS(ctx);
APIEntryShim entryShim(exec);
JSObject* jsThisObject = toJS(thisObject);
// evaluate sets "this" to the global object if it is NULL
JSGlobalObject* globalObject = exec->dynamicGlobalObject();
SourceCode source = makeSource(script->string(), sourceURL->string(), TextPosition(OrdinalNumber::fromOneBasedInt(startingLineNumber), OrdinalNumber::first()));
JSValue evaluationException;
JSValue returnValue = evaluate(globalObject->globalExec(), source, jsThisObject, &evaluationException);
if (evaluationException) {
if (exception)
*exception = toRef(exec, evaluationException);
return 0;
}
if (returnValue)
return toRef(exec, returnValue);
// happens, for example, when the only statement is an empty (';') statement
return toRef(exec, jsUndefined());
}
示例10: JSContextGetGlobalObject
JSObjectRef JSContextGetGlobalObject(JSContextRef ctx)
{
ExecState* exec = toJS(ctx);
exec->globalData().heap->registerThread();
JSLock lock(exec);
// It is necessary to call toThisObject to get the wrapper object when used with WebCore.
return toRef(exec->dynamicGlobalObject()->toThisObject(exec));
}
示例11: JSGlobalContextRelease
void JSGlobalContextRelease(JSGlobalContextRef ctx)
{
IdentifierTable* savedIdentifierTable;
ExecState* exec = toJS(ctx);
{
JSLockHolder lock(exec);
VM& vm = exec->vm();
savedIdentifierTable = wtfThreadData().setCurrentIdentifierTable(vm.identifierTable);
bool protectCountIsZero = Heap::heap(exec->dynamicGlobalObject())->unprotect(exec->dynamicGlobalObject());
if (protectCountIsZero)
vm.heap.reportAbandonedObjectGraph();
vm.deref();
}
wtfThreadData().setCurrentIdentifierTable(savedIdentifierTable);
}
示例12: JSGlobalContextRetain
JSGlobalContextRef JSGlobalContextRetain(JSGlobalContextRef ctx)
{
ExecState* exec = toJS(ctx);
exec->globalData().heap->registerThread();
JSLock lock(exec);
gcProtect(exec->dynamicGlobalObject());
return ctx;
}
示例13: JSGlobalContextRetain
JSGlobalContextRef JSGlobalContextRetain(JSGlobalContextRef ctx)
{
ExecState* exec = toJS(ctx);
APIEntryShim entryShim(exec);
JSGlobalData& globalData = exec->globalData();
gcProtect(exec->dynamicGlobalObject());
globalData.ref();
return ctx;
}
示例14: JSGlobalContextRetain
JSGlobalContextRef JSGlobalContextRetain(JSGlobalContextRef ctx)
{
ExecState* exec = toJS(ctx);
APIEntryShim entryShim(exec);
VM& vm = exec->vm();
gcProtect(exec->dynamicGlobalObject());
vm.ref();
return ctx;
}
示例15: evaluateInWorld
ScriptValue ScriptController::evaluateInWorld(const ScriptSourceCode& sourceCode, DOMWrapperWorld* world, ShouldAllowXSS shouldAllowXSS)
{
const SourceCode& jsSourceCode = sourceCode.jsSourceCode();
String sourceURL = ustringToString(jsSourceCode.provider()->url());
if (shouldAllowXSS == DoNotAllowXSS && !m_XSSAuditor->canEvaluate(sourceCode.source())) {
// This script is not safe to be evaluated.
return JSValue();
}
// evaluate code. Returns the JS return value or 0
// if there was none, an error occurred or the type couldn't be converted.
// inlineCode is true for <a href="javascript:doSomething()">
// and false for <script>doSomething()</script>. Check if it has the
// expected value in all cases.
// See smart window.open policy for where this is used.
JSDOMWindowShell* shell = windowShell(world);
ExecState* exec = shell->window()->globalExec();
const String* savedSourceURL = m_sourceURL;
m_sourceURL = &sourceURL;
JSLock lock(SilenceAssertionsOnly);
RefPtr<Frame> protect = m_frame;
#if ENABLE(INSPECTOR)
if (InspectorTimelineAgent* timelineAgent = m_frame->page() ? m_frame->page()->inspectorTimelineAgent() : 0)
timelineAgent->willEvaluateScript(sourceURL, sourceCode.startLine());
#endif
exec->globalData().timeoutChecker.start();
Completion comp = JSMainThreadExecState::evaluate(exec, exec->dynamicGlobalObject()->globalScopeChain(), jsSourceCode, shell);
exec->globalData().timeoutChecker.stop();
#if ENABLE(INSPECTOR)
if (InspectorTimelineAgent* timelineAgent = m_frame->page() ? m_frame->page()->inspectorTimelineAgent() : 0)
timelineAgent->didEvaluateScript();
#endif
// Evaluating the JavaScript could cause the frame to be deallocated
// so we start the keep alive timer here.
m_frame->keepAlive();
if (comp.complType() == Normal || comp.complType() == ReturnValue) {
m_sourceURL = savedSourceURL;
return comp.value();
}
if (comp.complType() == Throw || comp.complType() == Interrupted)
reportException(exec, comp.value());
m_sourceURL = savedSourceURL;
return JSValue();
}