KParts

Script Value Types

Classes

struct  KParts::ScriptableExtension::Exception
 
struct  KParts::ScriptableExtension::FunctionRef
 
struct  KParts::ScriptableExtension::Null
 
struct  KParts::ScriptableExtension::Object
 
struct  KParts::ScriptableExtension::Undefined
 

Functions

 KParts::ScriptableExtension::Exception::Exception (const QString &msg)
 
 KParts::ScriptableExtension::FunctionRef::FunctionRef (const Object &b, const QString &f)
 
 KParts::ScriptableExtension::Object::Object (ScriptableExtension *o, quint64 id)
 
bool KParts::ScriptableExtension::FunctionRef::operator== (const FunctionRef &other) const
 
bool KParts::ScriptableExtension::Object::operator== (const Object &other) const
 

Variables

Object KParts::ScriptableExtension::FunctionRef::base
 
QString KParts::ScriptableExtension::FunctionRef::field
 
QString KParts::ScriptableExtension::Exception::message
 
quint64 KParts::ScriptableExtension::Object::objId
 
ScriptableExtensionKParts::ScriptableExtension::Object::owner
 

lifetime

 KParts::ScriptableExtension::ScriptableExtension (QObject *parent)
 
 KParts::ScriptableExtension::~ScriptableExtension () override
 
static ScriptableExtensionKParts::ScriptableExtension::childObject (QObject *obj)
 
static ScriptableExtensionKParts::ScriptableExtension::adapterFromLiveConnect (QObject *parentObj, LiveConnectExtension *oldApi)
 

Object Hierarchy

void KParts::ScriptableExtension::setHost (ScriptableExtension *host)
 
ScriptableExtensionKParts::ScriptableExtension::host () const
 
virtual QVariant KParts::ScriptableExtension::rootObject ()
 
QVariant KParts::ScriptableExtension::enclosingObject ()
 

Object Operations

All these methods share the following conventions:

  • Values are passed and returned encoded as defined in Script Value Types
  • All methods may return an exception if unsupported
  • All callers must provide an accurate callerPrincipal argument describing which ScriptableExtension (and hence which KPart) they're acting as. This is used to implement security checks. This is not the same as the owner of an object. For example, if a plugin is calling an operation on a KHTMLPart object, then the 'this' parameter would be the object owner, a ScriptableExtension provided by the KHTMLPart, while the callerPrincipal would be the ScriptableExtension of the plugin. The extension is expected to do appropriate cross-site scripting checks on this argument if it is acting as a host.
enum  KParts::ScriptableExtension::ScriptLanguage { ECMAScript, KParts::ScriptableExtension::EnumLimit = 0xFFFF }
 
typedef QList< QVariantKParts::ScriptableExtension::ArgList
 
virtual QVariant KParts::ScriptableExtension::callAsFunction (ScriptableExtension *callerPrincipal, quint64 objId, const ArgList &args)
 
virtual QVariant KParts::ScriptableExtension::callFunctionReference (ScriptableExtension *callerPrincipal, quint64 objId, const QString &f, const ArgList &args)
 
virtual QVariant KParts::ScriptableExtension::callAsConstructor (ScriptableExtension *callerPrincipal, quint64 objId, const ArgList &args)
 
virtual bool KParts::ScriptableExtension::hasProperty (ScriptableExtension *callerPrincipal, quint64 objId, const QString &propName)
 
virtual QVariant KParts::ScriptableExtension::get (ScriptableExtension *callerPrincipal, quint64 objId, const QString &propName)
 
virtual bool KParts::ScriptableExtension::put (ScriptableExtension *callerPrincipal, quint64 objId, const QString &propName, const QVariant &value)
 
virtual bool KParts::ScriptableExtension::removeProperty (ScriptableExtension *callerPrincipal, quint64 objId, const QString &propName)
 
virtual bool KParts::ScriptableExtension::enumerateProperties (ScriptableExtension *callerPrincipal, quint64 objId, QStringList *result)
 
virtual bool KParts::ScriptableExtension::setException (ScriptableExtension *callerPrincipal, const QString &message)
 
virtual QVariant KParts::ScriptableExtension::evaluateScript (ScriptableExtension *callerPrincipal, quint64 contextObjectId, const QString &code, ScriptLanguage language=ECMAScript)
 
virtual bool KParts::ScriptableExtension::isScriptLanguageSupported (ScriptLanguage lang) const
 
virtual void KParts::ScriptableExtension::acquire (quint64 objid)
 
static QVariant KParts::ScriptableExtension::acquireValue (const QVariant &v)
 
virtual void KParts::ScriptableExtension::release (quint64 objid)
 
static QVariant KParts::ScriptableExtension::releaseValue (const QVariant &v)
 

Detailed Description

Values are passed to and from scriptable methods or properties as QVariants. Valid values may be bools, strings, and numbers (doubles), as well as the following custom types:

Enumeration Type Documentation

◆ ScriptLanguage

Enumerator
EnumLimit 

< also known as JavaScript

Definition at line 261 of file scriptableextension.h.

Function Documentation

◆ acquire()

void KParts::ScriptableExtension::acquire ( quint64  objid)
virtual

increases reference count of object objId

Definition at line 160 of file scriptableextension.cpp.

◆ acquireValue()

QVariant KParts::ScriptableExtension::acquireValue ( const QVariant v)
static

Helper that calls acquire on any object or function reference base stored in v.

Returns
a copy of the passed in value

Definition at line 165 of file scriptableextension.cpp.

◆ adapterFromLiveConnect()

ScriptableExtension * KParts::ScriptableExtension::adapterFromLiveConnect ( QObject parentObj,
LiveConnectExtension oldApi 
)
static

This returns a bridge object that permits KParts implementing the older LiveConnectExtension to be used via the ScriptableExtension API.

The bridge's parent will be the parentObj.

Definition at line 31 of file scriptableextension.cpp.

◆ callAsConstructor()

QVariant KParts::ScriptableExtension::callAsConstructor ( ScriptableExtension callerPrincipal,
quint64  objId,
const ArgList args 
)
virtual

Try to use the object objId associated with 'this' as a constructor (corresponding to ECMAScript's new foo(bar, baz, glarch) expression).

Definition at line 89 of file scriptableextension.cpp.

◆ callAsFunction()

QVariant KParts::ScriptableExtension::callAsFunction ( ScriptableExtension callerPrincipal,
quint64  objId,
const ArgList args 
)
virtual

Try to use the object objId associated with 'this' as a function.

Definition at line 72 of file scriptableextension.cpp.

◆ callFunctionReference()

QVariant KParts::ScriptableExtension::callFunctionReference ( ScriptableExtension callerPrincipal,
quint64  objId,
const QString f,
const ArgList args 
)
virtual

Try to use a function reference to field f of object @objId as a function.

Definition at line 80 of file scriptableextension.cpp.

◆ childObject()

ScriptableExtension * KParts::ScriptableExtension::childObject ( QObject obj)
static

Queries obj for a child object which inherits from this ScriptableExtension class.

Convenience method.

Definition at line 26 of file scriptableextension.cpp.

◆ enclosingObject()

QVariant KParts::ScriptableExtension::enclosingObject ( )

Returns an object that represents the host()'s view of us.

For example, if the host is an HTML part, it would return a DOM node of an <object> handled by this part. May be undefined or null

Implemented in terms of objectForKid

Definition at line 51 of file scriptableextension.cpp.

◆ enumerateProperties()

bool KParts::ScriptableExtension::enumerateProperties ( ScriptableExtension callerPrincipal,
quint64  objId,
QStringList result 
)
virtual

Tries to enumerate all fields of object objId associated with this to result.

Returns true on success

Definition at line 130 of file scriptableextension.cpp.

◆ evaluateScript()

QVariant KParts::ScriptableExtension::evaluateScript ( ScriptableExtension callerPrincipal,
quint64  contextObjectId,
const QString code,
ScriptLanguage  language = ECMAScript 
)
virtual

Tries to evaluate a script code with the given object as its context.

The parameter language specifies the language to execute it as. Use isScriptLanguageSupported to check for support.

Definition at line 145 of file scriptableextension.cpp.

◆ get()

QVariant KParts::ScriptableExtension::get ( ScriptableExtension callerPrincipal,
quint64  objId,
const QString propName 
)
virtual

Tries to get field propName from object objId associated with 'this'.

Definition at line 105 of file scriptableextension.cpp.

◆ hasProperty()

bool KParts::ScriptableExtension::hasProperty ( ScriptableExtension callerPrincipal,
quint64  objId,
const QString propName 
)
virtual

Returns true if the object objId associated with 'this' has the property propName.

Definition at line 97 of file scriptableextension.cpp.

◆ host()

ScriptableExtension * KParts::ScriptableExtension::host ( ) const

Returns any registered parent scripting context.

May be 0 if setHost was not called (or not call yet).

Definition at line 41 of file scriptableextension.cpp.

◆ isScriptLanguageSupported()

bool KParts::ScriptableExtension::isScriptLanguageSupported ( ScriptLanguage  lang) const
virtual

returns true if this extension can execute scripts in the given language

Definition at line 154 of file scriptableextension.cpp.

◆ put()

bool KParts::ScriptableExtension::put ( ScriptableExtension callerPrincipal,
quint64  objId,
const QString propName,
const QVariant value 
)
virtual

Tries to set the field propName from object objId associated with 'this' to value.

Returns true on success

Definition at line 113 of file scriptableextension.cpp.

◆ release()

void KParts::ScriptableExtension::release ( quint64  objid)
virtual

decreases reference count of object objId

Definition at line 177 of file scriptableextension.cpp.

◆ releaseValue()

QVariant KParts::ScriptableExtension::releaseValue ( const QVariant v)
static

Helper that calls release on any object or function reference base stored in v.

Returns
a copy of the passed in value

Definition at line 182 of file scriptableextension.cpp.

◆ removeProperty()

bool KParts::ScriptableExtension::removeProperty ( ScriptableExtension callerPrincipal,
quint64  objId,
const QString propName 
)
virtual

Tries to remove the field d propName from object objId associated with 'this'.

Returns true on success

Definition at line 122 of file scriptableextension.cpp.

◆ rootObject()

QVariant KParts::ScriptableExtension::rootObject ( )
virtual

Return the root scriptable object of this KPart.

For example for an HTML part, it would represent a Window object. May be undefined or null

Definition at line 46 of file scriptableextension.cpp.

◆ setException()

bool KParts::ScriptableExtension::setException ( ScriptableExtension callerPrincipal,
const QString message 
)
virtual

Tries to raise an exception with given message in this extension's scripting context.

Returns true on success

Definition at line 138 of file scriptableextension.cpp.

◆ setHost()

void KParts::ScriptableExtension::setHost ( ScriptableExtension host)

Reports the hosting ScriptableExtension to a child.

It's the responsibility of a parent part to call this method on all of its kids' ScriptableExtensions as soon as possible.

Definition at line 36 of file scriptableextension.cpp.

Variable Documentation

◆ message

QString KParts::ScriptableExtension::Exception::message

Error message returned from the callee.

This should be assumed to be low-level (in particular, it might not be translated) and should only be displayed in low-level debugging tools and the like.

Definition at line 65 of file scriptableextension.h.

This file is part of the KDE documentation.
Documentation copyright © 1996-2022 The KDE developers.
Generated on Mon Sep 26 2022 04:19:11 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.