KateScript

Search for usage in LXR

#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)
 
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 ()
 

Static Public Member Functions

static QString backtrace (const QJSValue &error, const QString &header=QString())
 

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 106 of file katescript.h.

Member Typedef Documentation

◆ FieldMap

Definition at line 111 of file katescript.h.

Member Enumeration Documentation

◆ InputType

enum KateScript::InputType

Definition at line 109 of file katescript.h.

Constructor & Destructor Documentation

◆ KateScript()

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 26 of file katescript.cpp.

◆ ~KateScript()

KateScript::~KateScript ( )
virtual

Definition at line 33 of file katescript.cpp.

Member Function Documentation

◆ backtrace()

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

Returns the backtrace when a script has errored out.

Definition at line 44 of file katescript.cpp.

◆ clearExceptions()

void KateScript::clearExceptions ( )

Clears any uncaught exceptions in the script engine.

Definition at line 66 of file katescript.cpp.

◆ displayBacktrace()

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

Displays the backtrace when a script has errored out.

Definition at line 57 of file katescript.cpp.

◆ errorMessage()

const QString & KateScript::errorMessage ( )
inline

Return a context-specific error message.

Definition at line 155 of file katescript.h.

◆ evaluate()

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

Execute a piece of code.

Definition at line 184 of file katescript.cpp.

◆ function()

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 82 of file katescript.cpp.

◆ generalHeader()

KateScriptHeader & KateScript::generalHeader ( )

Return the general header.

Definition at line 240 of file katescript.cpp.

◆ global()

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 73 of file katescript.cpp.

◆ hasException()

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

Checks for exception and gives feedback on the console.

Definition at line 211 of file katescript.cpp.

◆ load()

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 91 of file katescript.cpp.

◆ setGeneralHeader()

void KateScript::setGeneralHeader ( const KateScriptHeader & generalHeader)

set the general header after construction of the script

Definition at line 235 of file katescript.cpp.

◆ setView()

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

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

Definition at line 224 of file katescript.cpp.

◆ url()

const QString & KateScript::url ( )
inline

The script's URL.

Definition at line 122 of file katescript.h.

Member Data Documentation

◆ m_engine

QJSEngine* KateScript::m_engine = nullptr
protected

The Qt interpreter for this script.

Definition at line 196 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-2024 The KDE developers.
Generated on Fri Oct 11 2024 12:17:27 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.