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 <wx/string.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...
 
static int ExecFromMain (wxString *pIn, wxString *pOut)
 Executes a command on the main (GUI) thread. More...
 
void * ExecForLisp (char *pIn)
 

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 34 of file ScriptCommandRelay.cpp.

35{
36 if (auto pProject = ::GetActiveProject().lock()) {
37 CommandBuilder builder(*pProject, *pIn);
38 if (builder.WasValid())
39 {
40 OldStyleCommandPointer cmd = builder.GetCommand();
41
43 ev.SetCommand(cmd);
44
45 if (fromMain)
46 {
47 // Use SafelyProcessEvent, which stops exceptions, because this is
48 // expected to be reached from within the XLisp runtime
49 wxTheApp->SafelyProcessEvent(ev);
50 }
51 else
52 {
53 // Send the event to the main thread
54 wxTheApp->AddPendingEvent(ev);
55 }
56 }
57
58 // Wait for and retrieve the response
59 *pOut = builder.GetResponse();
60 }
61 else
62 *pOut = wxString{};
63
64 return 0;
65}
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:

◆ ExecForLisp()

void * ExecForLisp ( char *  pIn)

Definition at line 95 of file ScriptCommandRelay.cpp.

96{
97 wxString Str1(pIn);
98 wxString Str2;
99
100 ExecFromMain(&Str1, &Str2);
101
103}
static int ExecFromMain(wxString *pIn, wxString *pOut)
Executes a command on the main (GUI) thread.
void * nyq_reformat_aud_do_response(const wxString &Str)
Definition: Nyquist.cpp:3514
wxString Str2

References ExecFromMain(), nyq_reformat_aud_do_response(), and Str2.

Referenced by xlc_aud_do().

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

◆ ExecFromMain()

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

Executes a command on the main (GUI) thread.

Definition at line 74 of file ScriptCommandRelay.cpp.

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

References ExecCommand().

Referenced by ExecForLisp().

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

◆ ExecFromWorker()

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

Executes a command in the worker (script) thread.

Definition at line 68 of file ScriptCommandRelay.cpp.

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

References ExecCommand().

Referenced by ScriptCommandRelay::StartScriptServer().

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