--- a/hedgewars/uDebug.pas Sat Sep 20 00:56:54 2014 +0400
+++ b/hedgewars/uDebug.pas Sun Sep 21 00:37:50 2014 +0400
@@ -33,12 +33,7 @@
begin
WriteLnToConsole(Msg);
if isFatalError then
- begin
ParseCommand('fatal ' + lastConsoleline, true);
- // hint for the 'coverity' source analyzer
- // this halt is never actually reached because ParseCommands will halt first
- halt(HaltFatalError);
- end;
end;
procedure TryDo(Assert: boolean; Msg: shortstring; isFatal: boolean);
--- a/hedgewars/uFLIPC.pas Sat Sep 20 00:56:54 2014 +0400
+++ b/hedgewars/uFLIPC.pas Sun Sep 21 00:37:50 2014 +0400
@@ -1,13 +1,6 @@
unit uFLIPC;
interface
-uses SDLh;
-
-type TIPCMessage = record
- str: shortstring;
- len: Longword;
- buf: Pointer
- end;
- TIPCCallback = procedure (p: pointer; s: shortstring);
+uses SDLh, uFLTypes;
var msgFrontend, msgEngine: TIPCMessage;
mutFrontend, mutEngine: PSDL_mutex;
@@ -16,7 +9,7 @@
procedure initIPC;
procedure freeIPC;
-procedure ipcToEngine(s: shortstring); cdecl; export;
+procedure ipcToEngine(len: byte; msg: PChar); cdecl; export;
function ipcReadFromEngine: shortstring;
function ipcCheckFromEngine: boolean;
@@ -35,14 +28,13 @@
procedure ipcSend(var s: shortstring; var msg: TIPCMessage; mut: PSDL_mutex; cond: PSDL_cond);
begin
SDL_LockMutex(mut);
- writeln(stdout, 'ipc send', s);
+
while (msg.str[0] > #0) or (msg.buf <> nil) do
SDL_CondWait(cond, mut);
msg.str:= s;
SDL_CondSignal(cond);
SDL_UnlockMutex(mut);
- writeln(stdout, 'ipc sent', s[1])
end;
function ipcRead(var msg: TIPCMessage; mut: PSDL_mutex; cond: PSDL_cond): shortstring;
@@ -52,7 +44,7 @@
SDL_CondWait(cond, mut);
ipcRead:= msg.str;
- writeln(stdout, 'engine ipc received', msg.str[1]);
+
msg.str[0]:= #0;
if msg.buf <> nil then
begin
@@ -71,8 +63,12 @@
SDL_UnlockMutex(mut)
end;
-procedure ipcToEngine(s: shortstring); cdecl; export;
+procedure ipcToEngine(len: byte; msg: PChar); cdecl; export;
+var s: shortstring;
begin
+ writeln(stderr, len);
+ Move(msg^, s[1], len);
+ s[0]:= char(len);
ipcSend(s, msgEngine, mutEngine, condEngine)
end;
@@ -102,10 +98,12 @@
end;
function listener(p: pointer): Longint; cdecl; export;
+var s: shortstring;
begin
listener:= 0;
repeat
- callbackFunction(callbackPointer, ipcReadFromEngine())
+ s:= ipcReadFromEngine();
+ callbackFunction(callbackPointer, byte(s[0]), @s[1])
until false
end;
--- a/hedgewars/uFLTypes.pas Sat Sep 20 00:56:54 2014 +0400
+++ b/hedgewars/uFLTypes.pas Sun Sep 21 00:37:50 2014 +0400
@@ -1,6 +1,12 @@
unit uFLTypes;
+interface
-interface
+type TIPCMessage = record
+ str: shortstring;
+ len: Longword;
+ buf: Pointer
+ end;
+ TIPCCallback = procedure (p: pointer; len: byte; msg: PChar);
implementation
--- a/qmlFrontend/flib.h Sat Sep 20 00:56:54 2014 +0400
+++ b/qmlFrontend/flib.h Sun Sep 21 00:37:50 2014 +0400
@@ -18,9 +18,9 @@
};
} string255;
-typedef void RunEngine_t(int argc, char ** argv);
-typedef void registerIPCCallback_t(void * context, void (*)(void * context, string255 str));
-typedef void ipcToEngine_t(string255 str);
+typedef void RunEngine_t(int argc, const char ** argv);
+typedef void registerIPCCallback_t(void * context, void (*)(void * context, uint8_t len, const char * msg));
+typedef void ipcToEngine_t(uint8_t len, const char * msg);
typedef void flibInit_t();
#ifdef __cplusplus
--- a/qmlFrontend/hwengine.cpp Sat Sep 20 00:56:54 2014 +0400
+++ b/qmlFrontend/hwengine.cpp Sun Sep 21 00:37:50 2014 +0400
@@ -45,7 +45,7 @@
m_args.resize(m_argsList.size());
for(int i = m_argsList.size() - 1; i >=0; --i)
- m_args[i] = m_argsList[i].data();
+ m_args[i] = m_argsList[i].constData();
RunEngine(m_args.size(), m_args.data());
sendIPC("!");
@@ -68,17 +68,15 @@
void HWEngine::sendIPC(const QByteArray & b)
{
- string255 str;
- str.len = b.size() > 255 ? 255 : b.size();
- qDebug() << "semdIPC: len = " << str.len;
- qCopy(b.data(), &(b.data()[str.len - 1]), &(str.str[0]));
+ quint8 len = b.size() > 255 ? 255 : b.size();
+ qDebug() << "sendIPC: len = " << len;
- ipcToEngine(str);
+ ipcToEngine(len, b.constData());
}
-void HWEngine::engineMessageCallback(void *context, string255 str)
+void HWEngine::engineMessageCallback(void *context, quint8 len, const char *msg)
{
- QByteArray b = QByteArray::fromRawData((const char *)&str.s, str.len + 1);
+ QByteArray b = QByteArray::fromRawData(msg, len);
qDebug() << "FLIPC in" << b;
}
--- a/qmlFrontend/hwengine.h Sat Sep 20 00:56:54 2014 +0400
+++ b/qmlFrontend/hwengine.h Sun Sep 21 00:37:50 2014 +0400
@@ -23,9 +23,9 @@
private:
QList<QByteArray> m_argsList;
- QVector<char *> m_args;
+ QVector<const char *> m_args;
- static void engineMessageCallback(void *context, string255 str);
+ static void engineMessageCallback(void *context, quint8 len, const char * msg);
void sendIPC(const QByteArray &b);
};