本文整理汇总了C++中JSGlobalObject::globalData方法的典型用法代码示例。如果您正苦于以下问题:C++ JSGlobalObject::globalData方法的具体用法?C++ JSGlobalObject::globalData怎么用?C++ JSGlobalObject::globalData使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类JSGlobalObject
的用法示例。
在下文中一共展示了JSGlobalObject::globalData方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: handleEvent
bool JSCustomSQLStatementErrorCallback::handleEvent(SQLTransaction* transaction, SQLError* error)
{
ASSERT(m_callback);
ASSERT(m_frame);
if (!m_frame->script()->isEnabled())
return true;
JSGlobalObject* globalObject = m_frame->script()->globalObject();
ExecState* exec = globalObject->globalExec();
JSC::JSLock lock(false);
JSValue handleEventFunction = m_callback->get(exec, Identifier(exec, "handleEvent"));
CallData handleEventCallData;
CallType handleEventCallType = handleEventFunction.getCallData(handleEventCallData);
CallData callbackCallData;
CallType callbackCallType = CallTypeNone;
if (handleEventCallType == CallTypeNone) {
callbackCallType = m_callback->getCallData(callbackCallData);
if (callbackCallType == CallTypeNone) {
// FIXME: Should an exception be thrown here?
return true;
}
}
RefPtr<JSCustomSQLStatementErrorCallback> protect(this);
MarkedArgumentBuffer args;
args.append(toJS(exec, transaction));
args.append(toJS(exec, error));
JSValue result;
globalObject->globalData()->timeoutChecker.start();
if (handleEventCallType != CallTypeNone)
result = call(exec, handleEventFunction, handleEventCallType, handleEventCallData, m_callback, args);
else
result = call(exec, m_callback, callbackCallType, callbackCallData, m_callback, args);
globalObject->globalData()->timeoutChecker.stop();
if (exec->hadException()) {
reportCurrentException(exec);
// The spec says:
// "If the error callback returns false, then move on to the next statement..."
// "Otherwise, the error callback did not return false, or there was no error callback"
// Therefore an exception and returning true are the same thing - so, return true on an exception
return true;
}
Document::updateStyleForAllDocuments();
return result.toBoolean(exec);
}
示例2: lookupNamespaceURI
String JSCustomXPathNSResolver::lookupNamespaceURI(const String& prefix)
{
ASSERT(m_customResolver);
if (!m_frame)
return String();
if (!m_frame->script()->isEnabled())
return String();
JSLock lock(false);
JSGlobalObject* globalObject = m_frame->script()->globalObject();
ExecState* exec = globalObject->globalExec();
JSValue function = m_customResolver->get(exec, Identifier(exec, "lookupNamespaceURI"));
CallData callData;
CallType callType = function.getCallData(callData);
if (callType == CallTypeNone) {
callType = m_customResolver->getCallData(callData);
if (callType == CallTypeNone) {
// FIXME: Pass actual line number and source URL.
m_frame->domWindow()->console()->addMessage(JSMessageSource, ErrorMessageLevel, "XPathNSResolver does not have a lookupNamespaceURI method.", 0, String());
return String();
}
function = m_customResolver;
}
RefPtr<JSCustomXPathNSResolver> selfProtector(this);
MarkedArgumentBuffer args;
args.append(jsString(exec, prefix));
globalObject->globalData()->timeoutChecker.start();
JSValue retval = call(exec, function, callType, callData, m_customResolver, args);
globalObject->globalData()->timeoutChecker.stop();
String result;
if (exec->hadException())
reportCurrentException(exec);
else {
if (!retval.isUndefinedOrNull())
result = retval.toString(exec);
}
Document::updateStyleForAllDocuments();
return result;
}
示例3: constructFunction
// ECMA 15.3.2 The Function Constructor
JSObject* constructFunction(ExecState* exec, const ArgList& args, const Identifier& functionName, const UString& sourceURL, int lineNumber)
{
// Functions need to have a space following the opening { due to for web compatibility
// see https://bugs.webkit.org/show_bug.cgi?id=24350
// We also need \n before the closing } to handle // comments at the end of the last line
UString program;
if (args.isEmpty())
program = "(function() { \n})";
else if (args.size() == 1)
program = makeString("(function() { ", args.at(0).toString(exec), "\n})");
else {
StringBuilder builder;
builder.append("(function(");
builder.append(args.at(0).toString(exec));
for (size_t i = 1; i < args.size() - 1; i++) {
builder.append(",");
builder.append(args.at(i).toString(exec));
}
builder.append(") { ");
builder.append(args.at(args.size() - 1).toString(exec));
builder.append("\n})");
program = builder.build();
}
int errLine;
UString errMsg;
SourceCode source = makeSource(program, sourceURL, lineNumber);
RefPtr<FunctionExecutable> function = FunctionExecutable::fromGlobalCode(functionName, exec, exec->dynamicGlobalObject()->debugger(), source, &errLine, &errMsg);
if (!function)
return throwError(exec, SyntaxError, errMsg, errLine, source.provider()->asID(), source.provider()->url());
JSGlobalObject* globalObject = exec->lexicalGlobalObject();
ScopeChain scopeChain(globalObject, globalObject->globalData(), globalObject, exec->globalThisValue());
return new (exec) JSFunction(exec, function, scopeChain.node());
}
示例4: constructFunction
// ECMA 15.3.2 The Function Constructor
JSObject* constructFunction(ExecState* exec, const ArgList& args, const Identifier& functionName, const UString& sourceURL, int lineNumber)
{
UString program;
if (args.isEmpty())
program = "(function(){})";
else if (args.size() == 1)
program = "(function(){" + args.at(exec, 0)->toString(exec) + "})";
else {
program = "(function(" + args.at(exec, 0)->toString(exec);
for (size_t i = 1; i < args.size() - 1; i++)
program += "," + args.at(exec, i)->toString(exec);
program += "){" + args.at(exec, args.size() - 1)->toString(exec) + "})";
}
int errLine;
UString errMsg;
SourceCode source = makeSource(program, sourceURL, lineNumber);
RefPtr<ProgramNode> programNode = exec->globalData().parser->parse<ProgramNode>(exec, exec->dynamicGlobalObject()->debugger(), source, &errLine, &errMsg);
FunctionBodyNode* body = functionBody(programNode.get());
if (!body)
return throwError(exec, SyntaxError, errMsg, errLine, source.provider()->asID(), source.provider()->url());
JSGlobalObject* globalObject = exec->lexicalGlobalObject();
ScopeChain scopeChain(globalObject, globalObject->globalData(), exec->globalThisValue());
return new (exec) JSFunction(exec, functionName, body, scopeChain.node());
}
示例5: handleEvent
void JSCustomSQLStatementCallback::handleEvent(SQLTransaction* transaction, SQLResultSet* resultSet, bool& raisedException)
{
ASSERT(m_callback);
ASSERT(m_frame);
if (!m_frame->script()->isEnabled())
return;
// FIXME: This is likely the wrong globalObject (for prototype chains at least)
JSGlobalObject* globalObject = m_frame->script()->globalObject();
ExecState* exec = globalObject->globalExec();
JSC::JSLock lock(SilenceAssertionsOnly);
JSValue function = m_callback->get(exec, Identifier(exec, "handleEvent"));
CallData callData;
CallType callType = function.getCallData(callData);
if (callType == CallTypeNone) {
callType = m_callback->getCallData(callData);
if (callType == CallTypeNone) {
// FIXME: Should an exception be thrown here?
return;
}
function = m_callback;
}
RefPtr<JSCustomSQLStatementCallback> protect(this);
MarkedArgumentBuffer args;
args.append(toJS(exec, deprecatedGlobalObjectForPrototype(exec), transaction));
args.append(toJS(exec, deprecatedGlobalObjectForPrototype(exec), resultSet));
globalObject->globalData()->timeoutChecker.start();
call(exec, function, callType, callData, m_callback, args);
globalObject->globalData()->timeoutChecker.stop();
if (exec->hadException()) {
reportCurrentException(exec);
raisedException = true;
}
Document::updateStyleForAllDocuments();
}
示例6: handleEvent
void JSCustomVoidCallback::handleEvent()
{
ASSERT(m_callback);
ASSERT(m_frame);
if (!m_frame->script()->isEnabled())
return;
JSGlobalObject* globalObject = m_frame->script()->globalObject();
ExecState* exec = globalObject->globalExec();
JSC::JSLock lock(SilenceAssertionsOnly);
JSValue function = m_callback->get(exec, Identifier(exec, "handleEvent"));
CallData callData;
CallType callType = function.getCallData(callData);
if (callType == CallTypeNone) {
callType = m_callback->getCallData(callData);
if (callType == CallTypeNone) {
// FIXME: Should an exception be thrown here?
return;
}
function = m_callback;
}
RefPtr<JSCustomVoidCallback> protect(this);
MarkedArgumentBuffer args;
globalObject->globalData()->timeoutChecker.start();
call(exec, function, callType, callData, m_callback, args);
globalObject->globalData()->timeoutChecker.stop();
if (exec->hadException())
reportCurrentException(exec);
Document::updateStyleForAllDocuments();
}
示例7: initializeGlobalProperties
JSObject* ProgramExecutable::initializeGlobalProperties(JSGlobalData& globalData, CallFrame* callFrame, JSScope* scope)
{
ASSERT(scope);
JSGlobalObject* globalObject = scope->globalObject();
ASSERT(globalObject);
ASSERT(&globalObject->globalData() == &globalData);
JSObject* exception = 0;
UnlinkedProgramCodeBlock* unlinkedCode = globalObject->createProgramCodeBlock(callFrame, this, &exception);
if (exception)
return exception;
m_unlinkedProgramCodeBlock.set(globalData, this, unlinkedCode);
BatchedTransitionOptimizer optimizer(globalData, globalObject);
const UnlinkedProgramCodeBlock::VariableDeclations& variableDeclarations = unlinkedCode->variableDeclarations();
const UnlinkedProgramCodeBlock::FunctionDeclations& functionDeclarations = unlinkedCode->functionDeclarations();
size_t newGlobals = variableDeclarations.size() + functionDeclarations.size();
if (!newGlobals)
return 0;
globalObject->addRegisters(newGlobals);
CallFrame* globalExec = globalObject->globalExec();
for (size_t i = 0; i < functionDeclarations.size(); ++i) {
bool propertyDidExist = globalObject->removeDirect(globalData, functionDeclarations[i].first); // Newly declared functions overwrite existing properties.
UnlinkedFunctionExecutable* unlinkedFunctionExecutable = functionDeclarations[i].second.get();
JSValue value = JSFunction::create(globalExec, unlinkedFunctionExecutable->link(globalData, m_source, lineNo(), 0), scope);
int index = addGlobalVar(globalObject, functionDeclarations[i].first, IsVariable,
!propertyDidExist ? IsFunctionToSpecialize : NotFunctionOrNotSpecializable);
globalObject->registerAt(index).set(globalData, globalObject, value);
}
for (size_t i = 0; i < variableDeclarations.size(); ++i) {
if (globalObject->hasProperty(globalExec, variableDeclarations[i].first))
continue;
addGlobalVar(globalObject, variableDeclarations[i].first,
(variableDeclarations[i].second & DeclarationStacks::IsConstant) ? IsConstant : IsVariable,
NotFunctionOrNotSpecializable);
}
return 0;
}