KVIrc
4.9.2
DeveloperAPIs
|
The KVIrc Script class. More...
#include <KviKvsScript.h>
Public Types | |
enum | RunFlags { PreserveParams = 1, AssumeLocals = 2, Pedantic = 4, Quiet = 8 } |
Holds the run flags of the script. More... | |
enum | RunStatus { Error = 0, Success = 1, HaltEncountered = 2 } |
Holds the run status of the script. More... | |
enum | ScriptType { InstructionList, Expression, Parameter } |
Holds the type of the script. More... | |
Public Member Functions | |
const QString & | code () const |
Returns the code of the script. More... | |
void | dump (const char *prefix) |
Dumps the instructions tree. More... | |
KviKvsScript (const KviKvsScript &src) | |
Constructs a KVIrc Script object. More... | |
KviKvsScript (const QString &szName, const QString &szBuffer, ScriptType eType=InstructionList) | |
Constructs a KVIrc Script object. More... | |
bool | locked () const |
Returns true if the script is locked, false otherwise. More... | |
const QString & | name () const |
Returns the name of the script context. More... | |
int | run (KviWindow *pWnd, KviKvsVariantList *pParams=0, KviKvsVariant *pRetVal=0, int iRunFlags=0, KviKvsExtendedRunTimeData *pExtData=0) |
Runs the script. More... | |
int | run (KviWindow *pWnd, KviKvsVariantList *pParams, QString &szRetVal, int iRunFlags=0, KviKvsExtendedRunTimeData *pExtData=0) |
Runs the script. More... | |
int | run (KviKvsRunTimeContext *pContext, int iRunFlags=0) |
Runs the script. More... | |
void | setName (const QString &szName) |
Sets the name of the script context. More... | |
~KviKvsScript () | |
Destroys a KVIrc Script object. More... | |
Static Public Member Functions | |
static int | evaluate (const QString &szCode, KviWindow *pWindow, KviKvsVariantList *pParams, KviKvsVariant *pRetVal) |
Static helper for quick evaluating parameters. More... | |
static int | evaluateAsString (const QString &szCode, KviWindow *pWindow, KviKvsVariantList *pParams, QString &szRetVal) |
Static helper for quick evaluating parameters. More... | |
static int | run (const QString &szCode, KviWindow *pWindow, KviKvsVariantList *pParams=0, KviKvsVariant *pRetVal=0) |
Static helper for quick running. More... | |
Protected Member Functions | |
const QChar * | buffer () const |
Returns the data of the script. More... | |
void | detach () |
Detaches this script from any other shallow copies. More... | |
int | execute (KviWindow *pWnd, KviKvsVariantList *pParams=0, KviKvsVariant *pRetVal=0, int iRunFlags=0, KviKvsExtendedRunTimeData *pExtData=0) |
Runs the script. More... | |
int | executeInternal (KviKvsRunTimeContext *pContext) |
Runs the script. More... | |
KviKvsScript (const QString &szName, const QString &szBuffer, KviKvsTreeNodeInstruction *pPreparsedTree, ScriptType eType=InstructionList) | |
Constructs a KVIrc Script object. More... | |
bool | parse (KviWindow *pOutput=0, int iRunFlags=0) |
Returns true after a succesfull parsing, false otherwise. More... | |
Private Attributes | |
KviKvsScriptData * | m_pData |
Friends | |
class | KviKvsObject |
class | KviKvsParser |
class | KviKvsRunTimeContext |
The KVIrc Script class.
Holds the run flags of the script.
Enumerator | |
---|---|
PreserveParams |
Do not delete the eventual parameters passed (only execute() and run()) |
AssumeLocals |
Assume that the variables are local unless explicitly declared (flag used only for parse()) |
Pedantic |
Be more pedantic: spit more warnings and sometimes more errors |
Quiet |
Don't print any errors |
KviKvsScript::KviKvsScript | ( | const KviKvsScript & | src | ) |
Constructs a KVIrc Script object.
This is a shallow copy of the script data useful when a script can be destroyed while running (like in timers)
src | The source script |
References m_pData, and KviKvsScriptData::m_uRefs.
Referenced by KviKvsScriptAddon::allocateScripts(), KviKvsScriptAddon::setConfigureCallback(), and KviKvsScriptAddon::setHelpCallback().
KviKvsScript::KviKvsScript | ( | const QString & | szName, |
const QString & | szBuffer, | ||
ScriptType | eType = InstructionList |
||
) |
Constructs a KVIrc Script object.
szName | The name of the context |
szBuffer | The buffer :) |
eType | The type of the code in the buffer |
References KviKvsScriptData::m_eType, KviKvsScriptData::m_pBuffer, m_pData, KviKvsScriptData::m_pTree, KviKvsScriptData::m_szBuffer, KviKvsScriptData::m_szName, KviKvsScriptData::m_uLock, KviKvsScriptData::m_uRefs, and szBuffer.
KviKvsScript::~KviKvsScript | ( | ) |
Destroys a KVIrc Script object.
References m_pData, KviKvsScriptData::m_pTree, KviKvsScriptData::m_uLock, and KviKvsScriptData::m_uRefs.
|
protected |
Constructs a KVIrc Script object.
szName | The name of the context |
szBuffer | The buffer :) |
pPreparsedTree | The synthax tree |
eType | The type of the code in the buffer |
References KviKvsScriptData::m_eType, KviKvsScriptData::m_pBuffer, m_pData, KviKvsScriptData::m_pTree, KviKvsScriptData::m_szBuffer, KviKvsScriptData::m_szName, KviKvsScriptData::m_uLock, KviKvsScriptData::m_uRefs, and szBuffer.
|
protected |
Returns the data of the script.
References KviKvsScriptData::m_pBuffer, and m_pData.
Referenced by KviKvsRunTimeContext::report().
const QString & KviKvsScript::code | ( | ) | const |
Returns the code of the script.
References m_pData, and KviKvsScriptData::m_szBuffer.
Referenced by action_kvs_cmd_create(), addon_kvs_cmd_register(), addon_kvs_cmd_setconfigurecallback(), addon_kvs_cmd_sethelpcallback(), AliasEditorWidget::aliasRefresh(), KviKvsScriptAddon::configureCallbackCode(), KviKvsScriptAddon::description(), KviKvsUserAction::description(), KviKvsScriptAddon::descriptionCode(), KviKvsUserAction::descriptionCode(), dialog_kvs_cmd_file(), dialog_kvs_cmd_image(), dialog_kvs_cmd_message(), dialog_kvs_cmd_textinput(), SinglePopupEditor::findMatchingItem(), KviKvsPopupMenu::generateDefPopupCore(), KviKvsScriptAddon::helpCallbackCode(), http_kvs_cmd_asyncGet(), KviKvsScriptAddon::KviKvsScriptAddon(), KviCustomToolBarDescriptor::label(), KviCustomToolBarDescriptor::labelCode(), AliasEditorWidget::oneTimeSetup(), popup_kvs_cmd_addEpilogue(), popup_kvs_cmd_addItem(), popup_kvs_cmd_addPrologue(), KviKvsAliasManager::save(), KviKvsUserAction::save(), KviCustomToolBarDescriptor::save(), KviKvsPopupMenu::save(), KviKvsObjectScriptFunctionHandler::scriptHandlerCode(), KviKvsScriptAddon::uninstallCallbackCode(), KviKvsScriptAddon::visibleName(), KviKvsUserAction::visibleName(), KviKvsScriptAddon::visibleNameCode(), and KviKvsUserAction::visibleNameCode().
|
protected |
Detaches this script from any other shallow copies.
References d, KviKvsScriptData::m_eType, KviKvsScriptData::m_pBuffer, m_pData, KviKvsScriptData::m_pTree, KviKvsScriptData::m_szBuffer, KviKvsScriptData::m_uLock, and KviKvsScriptData::m_uRefs.
void KviKvsScript::dump | ( | const char * | prefix | ) |
Dumps the instructions tree.
prefix | The prefix of the instruction |
References KviKvsTreeNodeInstruction::dump(), m_pData, and KviKvsScriptData::m_pTree.
Referenced by KviKvsTreeNodeCallbackCommand::dumpCallback().
|
static |
Static helper for quick evaluating parameters.
Returns a combination of RunStatus flags (nonzero on no error) It does NOT take params ownership. pRetVal CAN'T be zero here since we're evaluating stuff here
szCode | The source code to run |
pWindow | The window that the command has to be bound to |
pParams | The parameter list |
pRetVal | Return value buffer |
References Parameter, PreserveParams, run(), and s.
Referenced by KviInputEditor::checkWordSpelling(), KviChannelWindow::closeEvent(), KviInputEditor::fillSpellCheckerCorrectionsPopup(), KviWindow::getDefaultLogFileName(), KviKvsCoreFunctions::KVSCF(), OptionsWidget_textEncoding::OptionsWidget_textEncoding(), KviIrcContext::terminateConnectionRequest(), and KviIrcConnection::useRealName().
|
static |
Static helper for quick evaluating parameters.
Returns a combination of RunStatus flags (nonzero on no error) It does NOT take params ownership. The QString return buffer CAN'T be zero here since we're evaluating stuff here
szCode | The source code to run |
pWindow | The window that the command has to be bound to |
pParams | The parameter list |
szRetVal | Return value buffer |
References KviKvsVariant::asString(), Parameter, PreserveParams, run(), and s.
|
protected |
Runs the script.
Returns 0 (KviKvsScript::RunFailure) on error Returns a nonzero combination of RunStatus flags on success
pWnd | The window that the command has to be bound to |
pParams | The parameter list (0 if you don't pass params) |
pRetVal | Return value buffer (0 if you ignore it) |
iRunFlags | A combination of run flags (usually default) |
pExtData | Extended data (usually 0) |
References KviKvsRunTimeContext::disableReporting(), KviKvsKernel::emptyParameterList(), Error, executeInternal(), KviKvsKernel::instance(), KVI_OUT_PARSERERROR, m_pData, KviKvsScriptData::m_pTree, KviWindow::outputNoFmt(), PreserveParams, and Quiet.
Referenced by run().
|
protected |
Runs the script.
Returns 0 (KviKvsScript::RunFailure) on error Returns a nonzero combination of RunStatus flags on success
pContext | The context where the script is bound to |
References Error, KviKvsRunTimeContext::error(), KviKvsTreeNodeInstruction::execute(), KviKvsRunTimeContext::haltCalled(), HaltEncountered, m_pData, KviKvsScriptData::m_pTree, KviKvsScriptData::m_uLock, and Success.
bool KviKvsScript::locked | ( | ) | const |
Returns true if the script is locked, false otherwise.
The lock is set while the script is being executed
References m_pData, and KviKvsScriptData::m_uLock.
const QString & KviKvsScript::name | ( | ) | const |
Returns the name of the script context.
References m_pData, and KviKvsScriptData::m_szName.
Referenced by KviKvsAliasManager::completeCommand(), AliasEditorWidget::oneTimeSetup(), KviKvsPopupMenu::removeItemByName(), KviKvsAliasManager::removeNamespace(), KviKvsParser::report(), KviKvsRunTimeContext::report(), KviKvsAliasManager::save(), KviKvsPopupMenu::save(), and KviKvsEventManager::triggerHandlers().
|
protected |
Returns true after a succesfull parsing, false otherwise.
pOutput is useful only for printing errors; if 0, no errors are printed
pOutput | The output window for errors |
iRunFlags | A combination of run flags (usually default) |
References KviKvsParser::AssumeLocals, AssumeLocals, detach(), KviKvsParser::error(), Expression, InstructionList, KviKvsScriptData::m_eType, KviKvsScriptData::m_pBuffer, m_pData, KviKvsScriptData::m_pTree, KviKvsScriptData::m_uLock, KviKvsScriptData::m_uRefs, p, Parameter, KviKvsParser::parse(), KviKvsParser::parseAsExpression(), KviKvsParser::parseAsParameter(), KviKvsParser::Pedantic, Pedantic, and Quiet.
Referenced by run().
int KviKvsScript::run | ( | KviWindow * | pWnd, |
KviKvsVariantList * | pParams = 0 , |
||
KviKvsVariant * | pRetVal = 0 , |
||
int | iRunFlags = 0 , |
||
KviKvsExtendedRunTimeData * | pExtData = 0 |
||
) |
Runs the script.
Returns 0 (KviKvsScript::RunFailure) on error Returns a nonzero combination of RunStatus flags on success
If PreserverParams is not used, the ownership is transferred. Extended data is used if you need to pass extended scope variables or alias switch lists...)
pWnd | The window that the command has to be bound to |
pParams | The parameter list (0 if you don't pass params) |
pRetVal | Return value buffer (0 if you ignore it) |
iRunFlags | A combination of run flags (usually default) |
pExtData | Extended data (usually 0) |
References Error, execute(), m_pData, KviKvsScriptData::m_pTree, parse(), and PreserveParams.
Referenced by KviKvsAction::activate(), KviApplication::autoConnectToServers(), avatar_kvs_cmd_set(), KviScriptUserButton::btnClicked(), ClassEditorWidget::build(), KviKvsObjectScriptFunctionHandler::call(), ChannelsJoinDialog::clearClicked(), OptionsWidget_textEncoding::commit(), OptionsWidget_servers::connectCurrentClicked(), KviIrcContext::connectToCurrentServer(), KviApplication::createFrame(), KviIrcContext::createLinksWindow(), KviIrcContext::createListWindow(), KviMainWindow::customizeToolBars(), UrlDialog::dblclk_url(), KviKvsScriptAddon::description(), KviKvsUserAction::description(), KviKvsDnsManager::dnsLookupTerminated(), KviInputEditor::dropEvent(), evaluate(), evaluateAsString(), KviKvsPopupMenuItem::evaluateCondition(), KviKvsPopupMenuItemWithTextAndIcon::evaluateIcon(), KviKvsTreeNodeAliasFunctionCall::evaluateReadOnly(), KviKvsPopupMenuItemWithTextAndIcon::evaluateText(), CodeTesterWidget::execute(), KviKvsTreeNodeAliasSimpleCommand::execute(), KviKvsCallbackObject::execute(), KviKvsScriptAddon::executeConfigureCallback(), KviKvsScriptAddon::executeHelpCallback(), KviMainWindow::executeInternalCommand(), KviConsoleWindow::executeInternalCommand(), KviKvsScriptAddon::executeUninstallCallback(), AddonManagementDialog::getMoreScripts(), KviStatusBarUpdateIndicator::getNewVersion(), AddonFunctions::installAddonPackage(), KviFileTransferManager::invokeTransferWindow(), KviApplication::ipcMessage(), ChannelsJoinDialog::joinClicked(), KviKvsCoreSimpleCommands::KVSCSC(), KviCustomToolBarDescriptor::label(), KviKvsObjectClass::load(), KviApplication::loadDefaultScript(), KviIrcConnection::loginComplete(), KviIrcConnection::loginToIrcServer(), KviKvsAsyncDnsOperation::lookupTerminated(), KviStatusBarAwayIndicator::mouseDoubleClickEvent(), KviIrcView::mouseDoubleClickEvent(), ClassEditorWidget::newClass(), KviMenuBar::newConnectionToServer(), KviAsyncAvatarSelectionDialog::okClicked(), KviIrcServerParser::parseCtcpReplyAvatar(), KviIrcServerParser::parseCtcpRequestAction(), KviIrcServerParser::parseLiteralKick(), KviIrcServerParser::parseLiteralNotice(), KviIrcServerParser::parseLiteralPrivmsg(), KviIrcServerParser::parseNumericEndOfWhois(), KviIrcServerParser::parseNumericNoSuchNick(), KviIrcServerParser::parseNumericNoSuchServer(), KviInputEditor::pasteFile(), KviInputEditor::pasteSlow(), KviSoundSelector::playSound(), KviJoinChannelAction::popupActivated(), KviChangeNickAction::popupActivated(), KviConnectToServerAction::popupActivated(), KviChangeUserModeAction::popupActivated(), OptionsWidget_servers::recentServersPopupClicked(), ChannelsJoinDialog::regClicked(), DccFileTransfer::retryDCC(), DccFileTransfer::retryRevDCC(), DccFileTransfer::retryTDCC(), KviIrcUrl::run(), run(), UrlDialog::sayToWin(), setup_finish(), KviInputEditor::stopPasteSlow(), KviKvsTimerManager::timerEvent(), HttpFileTransfer::transferTerminated(), KviKvsProcessAsyncOperation::trigger(), KviKvsEventManager::triggerHandlers(), KviIrcView::triggerMouseRelatedKvsEvents(), KviConsoleWindow::triggerOnHighlight(), KviKvsScriptAddon::visibleName(), and KviKvsUserAction::visibleName().
int KviKvsScript::run | ( | KviWindow * | pWnd, |
KviKvsVariantList * | pParams, | ||
QString & | szRetVal, | ||
int | iRunFlags = 0 , |
||
KviKvsExtendedRunTimeData * | pExtData = 0 |
||
) |
Runs the script.
Returns 0 (KviKvsScript::RunFailure) on error Returns a nonzero combination of RunStatus flags on success
The QString return buffer is useful only for evaluating InstructionList scripts. If PreserverParams is not used, the ownership is transferred. Extended data is used if you need to pass extended scope variables or alias switch lists...)
pWnd | The window that the command has to be bound to |
pParams | The parameter list (0 if you don't pass params) |
szRetVal | Return value buffer |
iRunFlags | A combination of run flags (usually default) |
pExtData | Extended data (usually 0) |
References KviKvsVariant::asString(), and run().
int KviKvsScript::run | ( | KviKvsRunTimeContext * | pContext, |
int | iRunFlags = 0 |
||
) |
Runs the script.
Returns 0 (KviKvsScript::RunFailure) on error Returns a nonzero combination of RunStatus flags on success
This is probably used only in /eval
pContext | The context where the script is bound to |
iRunFlags | A combination of run flags (usually default) |
References KviKvsRunTimeContext::disableReporting(), KviKvsRunTimeContext::enableReporting(), Error, executeInternal(), m_pData, KviKvsScriptData::m_pTree, parse(), Quiet, KviKvsRunTimeContext::reportingDisabled(), and KviKvsRunTimeContext::window().
|
static |
Static helper for quick running.
Returns a combination of RunStatus flags (nonzero on no error) It does NOT take params ownership
szCode | The source code to run |
pWindow | The window that the command has to be bound to |
pParams | The parameter list (0 if you don't pass params) |
pRetVal | Return value buffer (0 if you ignore it) |
References PreserveParams, run(), and s.
void KviKvsScript::setName | ( | const QString & | szName | ) |
Sets the name of the script context.
szName | The name of the context |
References detach(), m_pData, KviKvsScriptData::m_szName, and KviKvsScriptData::m_uRefs.
Referenced by KviKvsCoreCallbackCommands::KVSCCC().
|
friend |
|
friend |
|
friend |
|
private |
Referenced by buffer(), code(), detach(), dump(), execute(), executeInternal(), KviKvsScript(), locked(), name(), parse(), run(), setName(), and ~KviKvsScript().