本文整理汇总了C++中ExecState::lexicalGlobalObject方法的典型用法代码示例。如果您正苦于以下问题:C++ ExecState::lexicalGlobalObject方法的具体用法?C++ ExecState::lexicalGlobalObject怎么用?C++ ExecState::lexicalGlobalObject使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ExecState
的用法示例。
在下文中一共展示了ExecState::lexicalGlobalObject方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: JSContextGetGlobalObject
JSObjectRef JSContextGetGlobalObject(JSContextRef ctx)
{
ExecState* exec = toJS(ctx);
APIEntryShim entryShim(exec);
// It is necessary to call toThisObject to get the wrapper object when used with WebCore.
return toRef(exec->lexicalGlobalObject()->methodTable()->toThisObject(exec->lexicalGlobalObject(), exec));
}
示例2: JSObjectMakeConstructor
JSObjectRef JSObjectMakeConstructor(JSContextRef ctx, JSClassRef jsClass, JSObjectCallAsConstructorCallback callAsConstructor)
{
ExecState* exec = toJS(ctx);
APIEntryShim entryShim(exec);
JSValue jsPrototype = jsClass ? jsClass->prototype(exec) : 0;
if (!jsPrototype)
jsPrototype = exec->lexicalGlobalObject()->objectPrototype();
JSCallbackConstructor* constructor = JSCallbackConstructor::create(exec, exec->lexicalGlobalObject(), exec->lexicalGlobalObject()->callbackConstructorStructure(), jsClass, callAsConstructor);
constructor->putDirect(exec->globalData(), exec->propertyNames().prototype, jsPrototype, DontEnum | DontDelete | ReadOnly);
return toRef(constructor);
}
示例3: JSObjectMake
JSObjectRef JSObjectMake(JSContextRef ctx, JSClassRef jsClass, void* data)
{
JSLock lock;
ExecState* exec = toJS(ctx);
if (!jsClass)
return toRef(new (exec) JSObject(exec->lexicalGlobalObject()->objectPrototype())); // slightly more efficient
JSValue* jsPrototype = jsClass->prototype(ctx);
if (!jsPrototype)
jsPrototype = exec->lexicalGlobalObject()->objectPrototype();
return toRef(new (exec) JSCallbackObject<JSObject>(exec, jsClass, jsPrototype, data));
}
示例4: JSObjectMake
JSObjectRef JSObjectMake(JSContextRef ctx, JSClassRef jsClass, void* data)
{
ExecState* exec = toJS(ctx);
APIEntryShim entryShim(exec);
if (!jsClass)
return toRef(new (exec) JSObject(exec->lexicalGlobalObject()->emptyObjectStructure())); // slightly more efficient
JSCallbackObject<JSObject>* object = new (exec) JSCallbackObject<JSObject>(exec, exec->lexicalGlobalObject()->callbackObjectStructure(), jsClass, data);
if (JSObject* prototype = jsClass->prototype(exec))
object->setPrototype(prototype);
return toRef(object);
}
示例5: JSObjectMakeConstructor
JSObjectRef JSObjectMakeConstructor(JSContextRef ctx, JSClassRef jsClass, JSObjectCallAsConstructorCallback callAsConstructor)
{
ExecState* exec = toJS(ctx);
exec->globalData().heap.registerThread();
JSLock lock(exec);
JSValuePtr jsPrototype = jsClass
? jsClass->prototype(exec)
: exec->lexicalGlobalObject()->objectPrototype();
JSCallbackConstructor* constructor = new (exec) JSCallbackConstructor(exec->lexicalGlobalObject()->callbackConstructorStructure(), jsClass, callAsConstructor);
constructor->putDirect(exec->propertyNames().prototype, jsPrototype, DontEnum | DontDelete | ReadOnly);
return toRef(constructor);
}
示例6: JSObjectMake
JSObjectRef JSObjectMake(JSContextRef ctx, JSClassRef jsClass, void* data)
{
ExecState* exec = toJS(ctx);
exec->globalData().heap->registerThread();
JSLock lock(exec);
if (!jsClass)
return toRef(new (exec) JSObject(exec->lexicalGlobalObject()->objectPrototype())); // slightly more efficient
JSObject* jsPrototype = jsClass->prototype(exec);
if (!jsPrototype)
jsPrototype = exec->lexicalGlobalObject()->objectPrototype();
return toRef(new (exec) JSCallbackObject<JSObject>(exec, jsClass, jsPrototype, data));
}
示例7: JSObjectMakeRegExp
JSObjectRef JSObjectMakeRegExp(JSContextRef ctx, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
{
if (!ctx) {
ASSERT_NOT_REACHED();
return 0;
}
ExecState* exec = toJS(ctx);
JSLockHolder locker(exec);
MarkedArgumentBuffer argList;
for (size_t i = 0; i < argumentCount; ++i)
argList.append(toJS(exec, arguments[i]));
JSObject* result = constructRegExp(exec, exec->lexicalGlobalObject(), argList);
if (exec->hadException()) {
JSValue exceptionValue = exec->exception();
if (exception)
*exception = toRef(exec, exceptionValue);
exec->clearException();
#if ENABLE(REMOTE_INSPECTOR)
exec->vmEntryGlobalObject()->inspectorController().reportAPIException(exec, exceptionValue);
#endif
result = 0;
}
return toRef(result);
}
示例8: JSObjectMakeError
JSObjectRef JSObjectMakeError(JSContextRef ctx, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
{
if (!ctx) {
ASSERT_NOT_REACHED();
return 0;
}
ExecState* exec = toJS(ctx);
JSLockHolder locker(exec);
JSValue message = argumentCount ? toJS(exec, arguments[0]) : jsUndefined();
Structure* errorStructure = exec->lexicalGlobalObject()->errorStructure();
JSObject* result = ErrorInstance::create(exec, errorStructure, message);
if (exec->hadException()) {
JSValue exceptionValue = exec->exception();
if (exception)
*exception = toRef(exec, exceptionValue);
exec->clearException();
#if ENABLE(REMOTE_INSPECTOR)
exec->vmEntryGlobalObject()->inspectorController().reportAPIException(exec, exceptionValue);
#endif
result = 0;
}
return toRef(result);
}
示例9: JSObjectMakeFunction
JSObjectRef JSObjectMakeFunction(JSContextRef ctx, JSStringRef name, unsigned parameterCount, const JSStringRef parameterNames[], JSStringRef body, JSStringRef sourceURL, int startingLineNumber, JSValueRef* exception)
{
if (!ctx) {
ASSERT_NOT_REACHED();
return 0;
}
ExecState* exec = toJS(ctx);
APIEntryShim entryShim(exec);
Identifier nameID = name ? name->identifier(&exec->vm()) : Identifier(exec, "anonymous");
MarkedArgumentBuffer args;
for (unsigned i = 0; i < parameterCount; i++)
args.append(jsString(exec, parameterNames[i]->string()));
args.append(jsString(exec, body->string()));
JSObject* result = constructFunction(exec, exec->lexicalGlobalObject(), args, nameID, sourceURL->string(), TextPosition(OrdinalNumber::fromOneBasedInt(startingLineNumber), OrdinalNumber::first()));
if (exec->hadException()) {
if (exception)
*exception = toRef(exec, exec->exception());
exec->clearException();
result = 0;
}
return toRef(result);
}
示例10: constructJSWorker
EncodedJSValue JSC_HOST_CALL constructJSWorker(ExecState& exec)
{
VM& vm = exec.vm();
auto scope = DECLARE_THROW_SCOPE(vm);
DOMConstructorObject* jsConstructor = jsCast<DOMConstructorObject*>(exec.callee());
if (!exec.argumentCount())
return throwVMError(&exec, scope, createNotEnoughArgumentsError(&exec));
String scriptURL = exec.uncheckedArgument(0).toWTFString(&exec);
if (exec.hadException())
return JSValue::encode(JSValue());
// See section 4.8.2 step 14 of WebWorkers for why this is the lexicalGlobalObject.
DOMWindow& window = asJSDOMWindow(exec.lexicalGlobalObject())->wrapped();
ExceptionCode ec = 0;
ASSERT(window.document());
RefPtr<Worker> worker = Worker::create(*window.document(), scriptURL, ec);
if (ec) {
setDOMException(&exec, ec);
return JSValue::encode(JSValue());
}
return JSValue::encode(toJSNewlyCreated(&exec, jsConstructor->globalObject(), WTFMove(worker)));
}
示例11: open
JSValue JSHTMLDocument::open(ExecState& state)
{
// For compatibility with other browsers, pass open calls with more than 2 parameters to the window.
if (state.argumentCount() > 2) {
if (Frame* frame = wrapped().frame()) {
JSDOMWindowShell* wrapper = toJSDOMWindowShell(frame, currentWorld(&state));
if (wrapper) {
JSValue function = wrapper->get(&state, Identifier::fromString(&state, "open"));
CallData callData;
CallType callType = ::getCallData(function, callData);
if (callType == CallTypeNone)
return throwTypeError(&state);
return JSC::call(&state, function, callType, callData, wrapper, ArgList(&state));
}
}
return jsUndefined();
}
// document.open clobbers the security context of the document and
// aliases it with the active security context.
Document* activeDocument = asJSDOMWindow(state.lexicalGlobalObject())->wrapped().document();
// In the case of two parameters or fewer, do a normal document open.
wrapped().open(activeDocument);
return this;
}
示例12: JSObjectMakeRegExp
JSObjectRef JSObjectMakeRegExp(JSContextRef ctx, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
{
if (!ctx) {
ASSERT_NOT_REACHED();
return 0;
}
ExecState* exec = toJS(ctx);
VM& vm = exec->vm();
JSLockHolder locker(vm);
auto scope = DECLARE_CATCH_SCOPE(vm);
MarkedArgumentBuffer argList;
for (size_t i = 0; i < argumentCount; ++i)
argList.append(toJS(exec, arguments[i]));
if (UNLIKELY(argList.hasOverflowed())) {
auto throwScope = DECLARE_THROW_SCOPE(vm);
throwOutOfMemoryError(exec, throwScope);
handleExceptionIfNeeded(scope, exec, exception);
return 0;
}
JSObject* result = constructRegExp(exec, exec->lexicalGlobalObject(), argList);
if (handleExceptionIfNeeded(scope, exec, exception) == ExceptionStatus::DidThrow)
result = 0;
return toRef(result);
}
示例13: injectIDBKeyIntoScriptValue
bool injectIDBKeyIntoScriptValue(DOMRequestState* requestState, PassRefPtr<IDBKey> key, Deprecated::ScriptValue& value, const IDBKeyPath& keyPath)
{
LOG(StorageAPI, "injectIDBKeyIntoScriptValue");
ASSERT(keyPath.type() == IndexedDB::KeyPathType::String);
Vector<String> keyPathElements;
IDBKeyPathParseError error;
IDBParseKeyPath(keyPath.string(), keyPathElements, error);
ASSERT(error == IDBKeyPathParseError::None);
if (keyPathElements.isEmpty())
return false;
ExecState* exec = requestState->exec();
JSValue parent = ensureNthValueOnKeyPath(exec, value.jsValue(), keyPathElements, keyPathElements.size() - 1);
if (parent.isUndefined())
return false;
if (!set(exec, parent, keyPathElements.last(), idbKeyToJSValue(exec, exec->lexicalGlobalObject(), key.get())))
return false;
return true;
}
示例14: injectInternalsObject
void injectInternalsObject(JSContextRef context)
{
JSLock lock(SilenceAssertionsOnly);
ExecState* exec = toJS(context);
JSDOMGlobalObject* globalObject = static_cast<JSDOMGlobalObject*>(exec->lexicalGlobalObject());
globalObject->putDirect(exec->globalData(), Identifier(exec, "internals"), toJS(exec, globalObject, Internals::create()));
}
示例15: JSContextGetGlobalContext
JSGlobalContextRef JSContextGetGlobalContext(JSContextRef ctx)
{
ExecState* exec = toJS(ctx);
APIEntryShim entryShim(exec);
return toGlobalRef(exec->lexicalGlobalObject()->globalExec());
}