KateScript

#include <katescript.h>

Inheritance diagram for KateScript:

Public Types

typedef QMap< QString, QJSValueFieldMap
 
enum  InputType { InputURL, InputSCRIPT }
 

Public Member Functions

 KateScript (const QString &urlOrScript, enum InputType inputType=InputURL)
 
QString backtrace (const QJSValue &error, const QString &header=QString())
 
void clearExceptions ()
 
void displayBacktrace (const QJSValue &error, const QString &header=QString())
 
const QStringerrorMessage ()
 
QJSValue evaluate (const QString &program, const FieldMap &env=FieldMap())
 
QJSValue function (const QString &name)
 
KateScriptHeader & generalHeader ()
 
QJSValue global (const QString &name)
 
bool load ()
 
void setGeneralHeader (const KateScriptHeader &generalHeader)
 
bool setView (KTextEditor::ViewPrivate *view)
 
const QStringurl ()
 

Protected Member Functions

bool hasException (const QJSValue &object, const QString &file)
 

Protected Attributes

QJSEnginem_engine = nullptr
 

Detailed Description

KateScript objects represent a script that can be executed and inspected.

Definition at line 120 of file katescript.h.

Constructor & Destructor Documentation

KateScript::KateScript ( const QString urlOrScript,
enum InputType  inputType = InputURL 
)
explicit

Create a new script representation, passing either a file or the script content urlOrScript to it.

In case of a file, loading of the script will happen lazily.

Definition at line 42 of file katescript.cpp.

Member Function Documentation

QString KateScript::backtrace ( const QJSValue error,
const QString header = QString() 
)

Returns the backtrace when a script has errored out.

Definition at line 60 of file katescript.cpp.

void KateScript::clearExceptions ( )

Clears any uncaught exceptions in the script engine.

Definition at line 82 of file katescript.cpp.

void KateScript::displayBacktrace ( const QJSValue error,
const QString header = QString() 
)

Displays the backtrace when a script has errored out.

Definition at line 73 of file katescript.cpp.

const QString& KateScript::errorMessage ( )
inline

Return a context-specific error message.

Definition at line 169 of file katescript.h.

QJSValue KateScript::evaluate ( const QString program,
const FieldMap env = FieldMap() 
)

Execute a piece of code.

Definition at line 195 of file katescript.cpp.

QJSValue KateScript::function ( const QString name)

Return a function in the script of the given name, or an invalid QJSValue if no such function exists.

Definition at line 98 of file katescript.cpp.

KateScriptHeader & KateScript::generalHeader ( )

Return the general header.

Definition at line 248 of file katescript.cpp.

QJSValue KateScript::global ( const QString name)

Get a QJSValue for a global item in the script given its name, or an invalid QJSValue if no such global item exists.

Definition at line 89 of file katescript.cpp.

bool KateScript::hasException ( const QJSValue object,
const QString file 
)
protected

Checks for exception and gives feedback on the console.

Definition at line 219 of file katescript.cpp.

bool KateScript::load ( )

Load the script.

If loading is successful, returns true. Otherwise, returns returns false and an error message will be set (see errorMessage()). Note that you don't have to call this – it is called as necessary by the functions that require it. Subsequent calls to load will return the value it returned the first time.

Definition at line 107 of file katescript.cpp.

void KateScript::setGeneralHeader ( const KateScriptHeader &  generalHeader)

set the general header after construction of the script

Definition at line 243 of file katescript.cpp.

bool KateScript::setView ( KTextEditor::ViewPrivate *  view)

set view for this script for the execution will trigger load!

Definition at line 232 of file katescript.cpp.

const QString& KateScript::url ( )
inline

The script's URL.

Definition at line 136 of file katescript.h.

Member Data Documentation

QJSEngine* KateScript::m_engine = nullptr
protected

The Qt interpreter for this script.

Definition at line 210 of file katescript.h.


The documentation for this class was generated from the following files:
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Fri Jul 10 2020 22:55:57 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.