Audacity 3.2.0
Functions
ScriptCommandRelay.cpp File Reference

Contains definitions for ScriptCommandRelay. More...

#include "ScriptCommandRelay.h"
#include "CommandTargets.h"
#include "CommandBuilder.h"
#include "ActiveProject.h"
#include "AppCommandEvent.h"
#include "Project.h"
#include <wx/app.h>
#include <thread>
Include dependency graph for ScriptCommandRelay.cpp:

Go to the source code of this file.

Functions

static int ExecCommand (wxString *pIn, wxString *pOut, bool fromMain)
 This is the function which actually obeys one command. More...
 
static int ExecFromWorker (wxString *pIn, wxString *pOut)
 Executes a command in the worker (script) thread. More...
 
int ExecFromMain (wxString *pIn, wxString *pOut)
 Executes a command on the main (GUI) thread. More...
 

Detailed Description

Contains definitions for ScriptCommandRelay.

Definition in file ScriptCommandRelay.cpp.

Function Documentation

◆ ExecCommand()

static int ExecCommand ( wxString *  pIn,
wxString *  pOut,
bool  fromMain 
)
static

This is the function which actually obeys one command.

Definition at line 33 of file ScriptCommandRelay.cpp.

34{
35 if (auto pProject = ::GetActiveProject().lock()) {
36 CommandBuilder builder(*pProject, *pIn);
37 if (builder.WasValid())
38 {
39 OldStyleCommandPointer cmd = builder.GetCommand();
40
42 ev.SetCommand(cmd);
43
44 if (fromMain)
45 {
46 // Use SafelyProcessEvent, which stops exceptions, because this is
47 // expected to be reached from within the XLisp runtime
48 wxTheApp->SafelyProcessEvent(ev);
49 }
50 else
51 {
52 // Send the event to the main thread
53 wxTheApp->AddPendingEvent(ev);
54 }
55 }
56
57 // Wait for and retrieve the response
58 *pOut = builder.GetResponse();
59 }
60 else
61 *pOut = wxString{};
62
63 return 0;
64}
AUDACITY_DLL_API std::weak_ptr< AudacityProject > GetActiveProject()
An event 'envelope' for sending Command objects through the wxwidgets event loop.
void SetCommand(const OldStyleCommandPointer &cmd)
Store a pointer to a command object.
A type of factory for Commands of various sorts.
OldStyleCommandPointer is a unique_ptr to an OldStyleCommand.

References GetActiveProject(), CommandBuilder::GetCommand(), CommandBuilder::GetResponse(), AppCommandEvent::SetCommand(), and CommandBuilder::WasValid().

Referenced by ExecFromMain(), and ExecFromWorker().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ExecFromMain()

int ExecFromMain ( wxString *  pIn,
wxString *  pOut 
)

Executes a command on the main (GUI) thread.

Definition at line 73 of file ScriptCommandRelay.cpp.

74{
75 return ExecCommand(pIn, pOut, true);
76}
static int ExecCommand(wxString *pIn, wxString *pOut, bool fromMain)
This is the function which actually obeys one command.

References ExecCommand().

Here is the call graph for this function:

◆ ExecFromWorker()

static int ExecFromWorker ( wxString *  pIn,
wxString *  pOut 
)
static

Executes a command in the worker (script) thread.

Definition at line 67 of file ScriptCommandRelay.cpp.

68{
69 return ExecCommand(pIn, pOut, false);
70}

References ExecCommand().

Referenced by ScriptCommandRelay::StartScriptServer().

Here is the call graph for this function:
Here is the caller graph for this function: