Developer forums (C::B DEVELOPMENT STRICTLY!) > Plugins development
PipedProcess usage?
thomas:
--- Quote from: dmoore on October 30, 2006, 05:42:37 am ---But now I'm not sure about how to read from stdout at progressive intervals. [...]
EVT_PIPEDPROCESS_STDOUT messages
--- End quote ---
Although reading at regular intervals is possible, it is not advisable. If you did not get a message, then there is nothing to read, so you'll needlessly block.
Granted, passing all data around as messages is not the most efficient way, but that's how wxExecute works internally, too. To get to your data, simply implement a handler for EVT_PIPEDPROCESS_STDOUT (and optionally EVT_PIPEDPROCESS_STDERR, if you want to listen what might arrive there). To know when the child process has exited, listen to EVT_PIPEDPROCESS_TERMINATED.
Note that due to the generally dismal performance of wxExecute, a replacement is in work (actually should be finished long ago). However, while creating a process may be slightly different, the method of getting output via messages will stay available (though not the only option).
dmoore:
thanks for the responses from all of you. I now have a slightly better understanding.
My next stumbling block: It doesn't look like EVT_PIPEDPROCESS_STDOUT messages get passed to standard CB plugins? (unless i've done something silly - quite likely)
Code snipped:
--- Code: ---BEGIN_EVENT_TABLE(InterpretedLangs, cbPlugin)
EVT_MENU(ID_LangMenu_RunPiped,InterpretedLangs::OnRunPiped)
EVT_PIPEDPROCESS_STDOUT(ID_PipedProcess, InterpretedLangs::OnPipedOutput)
END_EVENT_TABLE()
void InterpretedLangs::OnPipedOutput(wxCommandEvent& event)
{
wxMessageBox(_T("Piped output"));
wxString msg = event.GetString();
if (!msg.IsEmpty())
{
wxMessageBox(msg);
}
}
void InterpretedLangs::OnRunPiped(wxCommandEvent &event)
{
m_pp=new PipedProcess((void **)&m_pp,this,ID_PipedProcess);
m_pp->Launch(_T("C:/Python25/python.exe"),100);
}
--- End code ---
As you can see, I have a menu item that calls OnRunPiped, which opens the piped process with unique identifier ID_PipedProcess. This works, but I don't seem to receive any EVT_PIPEDPROCESS_STDOUT messages. On the other hand, if I just call m_pp->Read(...) (not shown) there is stuff coming in through standard out.
Unrelated Question: Why is wxString manipulation so poor? It doesn't seem to be able convert char *, int, double etc to wxStrings (or back). Is this just incompleteness of unicode wxWidgets?
mandrav:
--- Quote ---m_pp->Launch(_T("C:/Python25/python.exe"),100);
--- End quote ---
That function doesn't work (is incomplete). You should do the polling yourself. Check debugger/compiler plugins, mainly EVT_TIMER and EVT_IDLE.
--- Quote ---Unrelated Question: Why is wxString manipulation so poor? It doesn't seem to be able convert char *, int, double etc to wxStrings (or back). Is this just incompleteness of unicode wxWidgets?
--- End quote ---
It's not poor, it's just the hassle of supporting unicode. In an ANSI wx build, you wouldn't have any of those problems...
dmoore:
--- Quote from: mandrav on October 30, 2006, 06:52:18 pm ---That function doesn't work (is incomplete). You should do the polling yourself. Check debugger/compiler plugins, mainly EVT_TIMER and EVT_IDLE.
--- End quote ---
This clears things up somewhat. I was looking at the GDB plugin and it seemed to be hadling EVT_TIMER and EVT_IDLE, hence my question about these above. I'm still a little uncertain about how the GDB plugin is actually parsing stdout. It seems to handle a EVT_PIPEDPROCESS_STDOUT event, but since this is incomplete I wonder how this works. EVT_IDLE just seems to pass/block the event, so not sure where the output is finally parsed. (I could of course trace through the code in the debugger, but thought i'd ask the experts first).
--- Quote ---It's not poor, it's just the hassle of supporting unicode. In an ANSI wx build, you wouldn't have any of those problems...
--- End quote ---
so what is the standard way of converting int/float/double to a unicode wxString and back? operator<<, operator>> and the relevant constructor appear to simply fail without warning.
mandrav:
--- Quote ---I'm still a little uncertain about how the GDB plugin is actually parsing stdout. It seems to handle a EVT_PIPEDPROCESS_STDOUT event, but since this is incomplete I wonder how this works.
--- End quote ---
No, no...
EVT_PIPEDPROCESS_STDOUT works fine (proven).
PipedProcess::Launch() doesn't work and it's not used.
Now that I remember, I think ToolsManager uses PipedProcess too so you might want to check that out. It's a much smaller unit than the compiler and debugger units so it might be easier to follow.
--- Quote ---so what is the standard way of converting int/float/double to a unicode wxString and back? operator<<, operator>> and the relevant constructor appear to simply fail without warning.
--- End quote ---
wxString::Format(_T("%d, %5.2f"), i, f);
Navigation
[0] Message Index
[#] Next page
[*] Previous page
Go to full version