Ok, I've run into another problem.
I have a need to manually run the event loop occasionally. In Win32, I
do
if (::PeekMessage(&msg, nsnull, 0, 0, PM_NOREMOVE)) {
if (::GetMessage(&msg, nsnull, 0, 0)) {
wasHandled = PR_FALSE;
::NS_HandleEmbeddingEvent(msg, wasHandled);
if (!wasHandled) {
::TranslateMessage(&msg);
::DispatchMessage(&msg);
}
}
}
and in Unix I do
while(gtk_events_pending()) {
gtk_main_iteration();
}
So I was thinking in Mac, I could do:
NSEvent *currentEvent = [NSApp currentEvent];
[NSApp sendEvent: currentEvent];
So I defined this function prototype in a .h, and implemented it in a
.mm file:
#ifdef __cplusplus
extern "C" {
#endif
JNIEXPORT void JNICALL cocoaProcessEventLoop(void);
#ifdef __cplusplus
}
#endif
The JNIEXPORT and JNICALL things are just macros that expand out
to properly mark the function as an export.
And the function has this simple implementation:
JNIEXPORT void JNICALL cocoaProcessEventLoop(void) {
NSEvent *currentEvent = [NSApp currentEvent];
[NSApp sendEvent: currentEvent];
}
However, when I try to link the library containing the C++ and .mm
files I get this error:
ld: cocoa/CocoaBrowserControlCanvas.o illegal reference to symbol:
_NSApp defined in indirectly referenced dynamic library
/System/Library/Frameworks/AppKit.framework/Versions/C/AppKit
ld: cocoa/CocoaBrowserControlCanvas.o illegal reference to symbol:
_objc_msgSend defined in indirectly referenced dynamic library
/usr/lib/libobjc.A.dylib
ld: warning multiple definitions of symbol _finite
/System/Library/Frameworks/JavaVM.framework/Versions/1.4.2/Libraries/libjava.jnilib(single
module) definition of _finite
/usr/lib/libpthread.dylib(finite.o) definition of _finite
ld: warning multiple definitions of symbol _ldexp
/System/Library/Frameworks/JavaVM.framework/Versions/1.4.2/Libraries/libjava.jnilib(single
module) definition of _ldexp
/usr/lib/libpthread.dylib(frexpldexp.o) definition of _ldexp
ld: warning multiple definitions of symbol _frexp
/System/Library/Frameworks/JavaVM.framework/Versions/1.4.2/Libraries/libjava.jnilib(single
module) definition of _frexp
/usr/lib/libpthread.dylib(frexpldexp.o) definition of _frexp
ld: warning multiple definitions of symbol _isnan
/System/Library/Frameworks/JavaVM.framework/Versions/1.4.2/Libraries/libjava.jnilib(single
module) definition of _isnan
/usr/lib/libpthread.dylib(isnan.So) definition of _isnan
/usr/bin/libtool: internal link edit command failed
Can someone please help with this error?
I'm very new to Cocoa so I'm probably doing something simple.
edburns - 12 May 2005 04:46 GMT
For the record, I was told by smfr that this approach will probably not
work and that I should look into using nsIEventQueueService instead.
Ed