LeechCraft  0.6.70-15082-g543737046d
Modular cross-platform feature rich live environment.
IScript Class Referenceabstract

Interface for objects representing scripts. More...

#include "iscriptloader.h"

Public Member Functions

virtual ~IScript ()
 
virtual QObject * GetQObject ()=0
 Returns this script object as a QObject. More...
 
virtual QVariant InvokeMethod (const QString &name, const QVariantList &args={})=0
 Runs the given function and returns its value. More...
 
virtual void AddQObject (QObject *object, const QString &name)=0
 Adds the given object to the script context. More...
 
virtual void Execute ()=0
 Executes the script. More...
 

Detailed Description

Interface for objects representing scripts.

This interface is to be implemented by the objects that represent loaded scripts.

Definition at line 19 of file iscriptloader.h.

Constructor & Destructor Documentation

◆ ~IScript()

virtual IScript::~IScript ( )
inlinevirtual

Definition at line 28 of file iscriptloader.h.

Member Function Documentation

◆ AddQObject()

virtual void IScript::AddQObject ( QObject *  object,
const QString &  name 
)
pure virtual

Adds the given object to the script context.

This method adds the object to the script context under the given name. The metafunctions of the object (that is, signals, slots, properties and Q_INVOKABLE functions) will become available to the script.

Warning
This function should be called before Execute() or InvokeMethod (), otherwise the added objects may not be visible to the script.
Parameters
[in]objectThe object to add to the script context.
[in]nameThe name under which the object should be added.

◆ Execute()

virtual void IScript::Execute ( )
pure virtual

Executes the script.

There is no need to call this function explicitly if InvokeMethod() will be called, since the latter implies executing the script.

Warning
This function should be called after all required objects are added with AddQObject() otherwise they may not be visible to the script.

◆ GetQObject()

virtual QObject* IScript::GetQObject ( )
pure virtual

Returns this script object as a QObject.

Returns
This script object as a QObject.

◆ InvokeMethod()

virtual QVariant IScript::InvokeMethod ( const QString &  name,
const QVariantList &  args = {} 
)
pure virtual

Runs the given function and returns its value.

This method invokes the method identified by name with the given args, if any, and returns its value.

If there is no such method or call has failed, the returned variant is null.

Warning
This function should be called after all required objects are added with AddQObject() otherwise they may not be visible to the script.
Parameters
[in]nameThe name of the method to invoke.
[in]argsThe list of arguments for the method.
Returns
The return value of the method, if any, or null variant if the call has failed.

The documentation for this class was generated from the following file: