本文整理汇总了C++中JSDOMWindow::put方法的典型用法代码示例。如果您正苦于以下问题:C++ JSDOMWindow::put方法的具体用法?C++ JSDOMWindow::put怎么用?C++ JSDOMWindow::put使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类JSDOMWindow
的用法示例。
在下文中一共展示了JSDOMWindow::put方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: attachExtensionObjectToFrame
// FIXME: Revisit the creation of this class and make sure this is the best way to approach it.
void attachExtensionObjectToFrame(Frame* frame, WebPageClient* client)
{
JSC::JSLock lock(JSC::SilenceAssertionsOnly);
JSDOMWindow* window = frame->script()->windowShell(mainThreadNormalWorld())->window();
JSC::ExecState* exec = window->globalExec();
JSContextRef scriptCtx = toRef(exec);
JSClassDefinition definition = kJSClassDefinitionEmpty;
definition.staticValues = clientExtensionStaticValues;
definition.staticFunctions = clientExtensionStaticFunctions;
definition.initialize = clientExtensionInitialize;
definition.finalize = clientExtensionFinalize;
JSClassRef clientClass = JSClassCreate(&definition);
JSObjectRef clientClassObject = JSObjectMake(scriptCtx, clientClass, 0);
JSObjectSetPrivate(clientClassObject, reinterpret_cast<void*>(client));
JSC::UString name("qnx");
JSC::PutPropertySlot slot;
window->put(window, exec, JSC::Identifier(exec, name), toJS(clientClassObject), slot);
JSClassRelease(clientClass);
}
示例2: addToJSWindowObject
void WebFrame::addToJSWindowObject(const char* name, void *object)
{
KJS::JSLock lock(false);
JSDOMWindow *window = toJSDOMWindow(core(this));
if (!window)
return;
KJS::Bindings::RootObject *root = core(this)->bindingRootObject();
KJS::ExecState* exec = window->globalExec();
KJS::JSObject *runtimeObject = KJS::Bindings::Instance::createRuntimeObject(exec, KJS::Bindings::BalInstance::create(static_cast<BalObject*>(object), root));
window->put(exec, KJS::Identifier(exec, name), runtimeObject);
}
示例3: addToJavaScriptWindowObject
/*!
\fn void QWebFrame::addToJavaScriptWindowObject(const QString &name, QObject *object, QScriptEngine::ValueOwnership own)
\overload
Make \a object available under \a name from within the frame's JavaScript
context. The \a object will be inserted as a child of the frame's window
object.
Qt properties will be exposed as JavaScript properties and slots as
JavaScript methods.
If you want to ensure that your QObjects remain accessible after loading a
new URL, you should add them in a slot connected to the
javaScriptWindowObjectCleared() signal.
The ownership of \a object is specified using \a own.
*/
void QWebFrame::addToJavaScriptWindowObject(const QString &name, QObject *object, QScriptEngine::ValueOwnership ownership)
{
JSC::JSLock lock(false);
JSDOMWindow* window = toJSDOMWindow(d->frame);
JSC::Bindings::RootObject* root = d->frame->script()->bindingRootObject();
if (!window) {
qDebug() << "Warning: couldn't get window object";
return;
}
JSC::ExecState* exec = window->globalExec();
JSC::JSObject*runtimeObject =
JSC::Bindings::Instance::createRuntimeObject(exec, JSC::Bindings::QtInstance::getQtInstance(object, root, ownership));
JSC::PutPropertySlot slot;
window->put(exec, JSC::Identifier(exec, (const UChar *) name.constData(), name.length()), runtimeObject, slot);
}
示例4: addToJSWindowObject
void WebFrame::addToJSWindowObject(const char* name, void *object)
{
JSC::JSLock lock(false);
JSDOMWindow *window = toJSDOMWindow(core(this));
if (!window)
return;
JSC::Bindings::RootObject *root = core(this)->script()->bindingRootObject();
JSC::ExecState* exec = window->globalExec();
JSC::PropertySlot pr;
if (!window->getOwnPropertySlot(exec, JSC::Identifier(exec, name), pr)) {
//printf("addToJSWindowObject %p name =%s ok \n", core(this), name);
//JSC::JSObject *runtimeObject = JSC::Bindings::Instance::createRuntimeObject(exec, JSC::Bindings::BalInstance::create(static_cast<BalObject*>(object), root));
JSC::JSObject *runtimeObject = JSC::Bindings::Instance::createRuntimeObject(exec, JSC::Bindings::BalInstance::getBalInstance(static_cast<BalObject*>(object), root));
JSC::PutPropertySlot prop;
window->put(exec, JSC::Identifier(exec, name), runtimeObject, prop);
}
}
示例5: addToJavaScriptWindowObject
/*!
\fn void QWebFrame::addToJavaScriptWindowObject(const QString &name, QObject *object, QScriptEngine::ValueOwnership own)
\overload
Make \a object available under \a name from within the frame's JavaScript
context. The \a object will be inserted as a child of the frame's window
object.
Qt properties will be exposed as JavaScript properties and slots as
JavaScript methods.
If you want to ensure that your QObjects remain accessible after loading a
new URL, you should add them in a slot connected to the
javaScriptWindowObjectCleared() signal.
If Javascript is not enabled for this page, then this method does nothing.
The ownership of \a object is specified using \a own.
*/
void QWebFrame::addToJavaScriptWindowObject(const QString &name, QObject *object, QScriptEngine::ValueOwnership ownership)
{
if (!page()->settings()->testAttribute(QWebSettings::JavascriptEnabled))
return;
JSC::JSLock lock(JSC::SilenceAssertionsOnly);
JSDOMWindow* window = toJSDOMWindow(d->frame, mainThreadNormalWorld());
JSC::Bindings::RootObject* root = d->frame->script()->bindingRootObject();
if (!window) {
qDebug() << "Warning: couldn't get window object";
return;
}
JSC::ExecState* exec = window->globalExec();
JSC::JSObject* runtimeObject =
JSC::Bindings::QtInstance::getQtInstance(object, root, ownership)->createRuntimeObject(exec);
JSC::PutPropertySlot slot;
window->put(exec, JSC::Identifier(exec, (const UChar *) name.constData(), name.length()), runtimeObject, slot);
}
示例6: installDOMFunction
void PagePopupBlackBerry::installDOMFunction(Frame* frame)
{
JSDOMWindow* window = toJSDOMWindow(frame, mainThreadNormalWorld());
ASSERT(window);
JSC::ExecState* exec = window->globalExec();
ASSERT(exec);
JSC::JSLockHolder lock(exec);
JSContextRef context = ::toRef(exec);
JSObjectRef globalObject = JSContextGetGlobalObject(context);
JSStringRef functionName = JSStringCreateWithUTF8CString(
"setValueAndClosePopup");
JSObjectRef function = JSObjectMakeFunctionWithCallback(context,
functionName, setValueAndClosePopupCallback);
JSObjectSetProperty(context, globalObject, functionName, function,
kJSPropertyAttributeDontDelete | kJSPropertyAttributeReadOnly, 0);
// Register client into DOM
JSClassDefinition definition = kJSClassDefinitionEmpty;
definition.staticValues = popUpExtensionStaticValues;
definition.staticFunctions = popUpExtensionStaticFunctions;
definition.initialize = popUpExtensionInitialize;
definition.finalize = popUpExtensionFinalize;
JSClassRef clientClass = JSClassCreate(&definition);
JSObjectRef clientClassObject = JSObjectMake(context, clientClass, 0);
// Add a reference. See popUpExtensionFinalize.
m_sharedClientPointer->ref();
JSObjectSetPrivate(clientClassObject, m_sharedClientPointer.get());
String name("popUp");
JSC::PutPropertySlot slot;
window->put(window, exec, JSC::Identifier(exec, name),
toJS(clientClassObject), slot);
JSClassRelease(clientClass);
}