Changeset 34865
- Timestamp:
- 08/13/09 12:39:38 (4 years ago)
- Location:
- lang/objective-cplusplus/i3/trunk
- Files:
-
- 14 modified
-
am/mil_test.am (modified) (1 diff)
-
kdevelop/i3.kdevses (modified) (1 diff)
-
src/gui-cocoa/Gui.h (modified) (1 diff)
-
src/mil/include/mil/ModuleCommon.h (modified) (2 diffs)
-
src/mil/include/mil/Synchronize.h (modified) (2 diffs)
-
src/mil/include/mil/gui-cocoa/GuiModule.h (modified) (9 diffs)
-
src/mil/include/mil/gui-cocoa/GuiModuleObjC.cpp (modified) (1 diff)
-
src/mil/include/mil/gui-cocoa/GuiModuleObjC.h (modified) (1 diff)
-
src/mil/include/mil/gui-windows/GuiModule.h (modified) (2 diffs)
-
src/mil/src/Test10.cpp (modified) (1 diff)
-
src/mil/src/Test11.cpp (modified) (1 diff)
-
src/mil/src/Test5.cpp (modified) (1 diff)
-
src/mil/src/Test6.cpp (modified) (1 diff)
-
src/mil/src/Test7.cpp (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
lang/objective-cplusplus/i3/trunk/am/mil_test.am
r34839 r34865 7 7 src/mil/src/TestMain.cpp \ 8 8 src/mil/src/StaticData.cpp \ 9 src/mil/src/Test11.cpp 9 src/mil/src/Test2.cpp \ 10 src/mil/src/Test3.cpp \ 11 src/mil/src/Test4.cpp \ 12 src/mil/src/Test6.cpp \ 13 src/mil/src/Test7.cpp \ 14 src/mil/src/Test8.cpp \ 15 src/mil/src/Test10.cpp \ 16 src/mil/src/Test11.cpp \ 17 src/mil/src/Test12.cpp 10 18 19 # src/mil/src/Test9.cpp \ 11 20 # src/mil/src/Test1.cpp \ 12 # src/mil/src/Test2.cpp \13 # src/mil/src/Test3.cpp \14 # src/mil/src/Test4.cpp \15 # src/mil/src/Test6.cpp \16 # src/mil/src/Test7.cpp \17 # src/mil/src/Test8.cpp \18 # src/mil/src/Test9.cpp \19 # src/mil/src/Test10.cpp \20 21 # src/mil/src/Test11.cpp 21 22 -
lang/objective-cplusplus/i3/trunk/kdevelop/i3.kdevses
r34849 r34865 16 16 </Doc3> 17 17 <Doc4 NumberOfViews="1" URL="file:///home/saturday06/projects/i3/src/mil/include/mil/Thread.h" > 18 <View0 Encoding="" line="108"Type="Source" />18 <View0 Encoding="" Type="Source" /> 19 19 </Doc4> 20 20 <Doc5 NumberOfViews="1" URL="file:///home/saturday06/projects/i3/src/mil/include/mil/os-unix/Debug.h" > -
lang/objective-cplusplus/i3/trunk/src/gui-cocoa/Gui.h
r34447 r34865 15 15 namespace i3 { 16 16 typedef std::string string; 17 typedef boost::format format;17 //typedef boost::format format; 18 18 } 19 19 -
lang/objective-cplusplus/i3/trunk/src/mil/include/mil/ModuleCommon.h
r34853 r34865 9 9 struct Data { 10 10 #ifdef MIL_GUI_WINDOWS 11 HWND hWndCache; 11 HWND window_cache; 12 #else 13 NSWindow* window_cache; 12 14 #endif 13 15 } data[MIL_MAX_THREADS]; … … 23 25 void flush() { 24 26 for (size_t i = 0; i < _countof(data); i++) { 25 #ifdef MIL_GUI_WINDOWS 26 data[i].hWndCache = NULL; 27 #endif 27 data[i].window_cache = NULL; 28 28 } 29 29 } -
lang/objective-cplusplus/i3/trunk/src/mil/include/mil/Synchronize.h
r34841 r34865 69 69 } 70 70 } 71 71 72 72 void passeren() { 73 73 sem_post(&sem); 74 } 75 76 void p() { 77 passeren(); 74 78 } 75 79 … … 77 81 sem_wait(&sem); 78 82 } 83 84 void v() { 85 verhoog(); 86 } 79 87 80 88 ~Semaphore() { -
lang/objective-cplusplus/i3/trunk/src/mil/include/mil/gui-cocoa/GuiModule.h
r34447 r34865 12 12 public: 13 13 Tls tls; 14 MIL_CRTP_CLASS_MEMBERS; 15 14 16 private: 15 17 template <typename T> … … 18 20 typedef T DataType; 19 21 T data; 22 void (*execute)(void* event, void* target); 20 23 }; 21 22 friend class Module_test;23 24 24 25 private: … … 34 35 35 36 void requestExit(void* event_memory) { 37 exitNotifier.tls.flush(); 36 38 ExitEvent e; 37 post(e, *this);39 post(e, exitNotifier, event_memory, exitNotifier.tls.thread_id); 38 40 } 39 41 40 42 GuiModule() : tls(this->thread_id), repost(false), window(NULL) { 41 set_auto_join(this);42 43 } 43 44 44 Child& getChild() { 45 return *static_cast<Child*>(this); 45 void createGui() { 46 } 47 48 void run() { 49 MIL_MODULE_GET_SUPER_CHILD(*this).loop(); 46 50 } 47 51 … … 53 57 template <typename Data, typename Sender> 54 58 static void dispatcher(void* event_, void* target_) { 55 typedef Child Target; 56 57 if (!event_ || !target_) { 58 return; 59 } 60 61 // XXX type safety?? 59 typedef Child Target; 62 60 Target& target = *static_cast<Target*>(target_); 63 61 Event<Data>& event = *static_cast<Event<Data>*>(event_); 64 target.list.pop();65 62 target.repost = false; 66 ModuleExecuteProxy <Data, Target>::execute(event.data, target);63 ModuleExecuteProxy::execute<Data, Target>(event.data, target); 67 64 if (target.repost) { 68 65 target.post(event.data, target); … … 70 67 } 71 68 } 69 72 70 public: 73 71 void requestExit() { … … 76 74 } 77 75 76 template <typename Sender> 77 NSWindow* getCachedWindow(Sender& sender, bool flush = false) { 78 NSWindow* window = NULL; 79 80 if (flush || !(window = sender.tls.getData(this->thread_id).window_cache)) { 81 window = getWindow(); 82 if (!window) { 83 return NULL; 84 } 85 sender.tls.getData(this->thread_id).window_cache = window; 86 } 87 return window; 88 } 89 78 90 template <typename T, typename Sender> 79 91 void post(const T& event, Sender& sender, void* memory = NULL, intptr_t owner_id = 0) { 80 NSWindow* localWindow = sender.tls.thread[this->thread_id].window; 81 if (!localWindow) { 82 localWindow = getWindow(); 83 sender.tls.thread[this->thread_id].window = localWindow; 84 } 85 92 NSWindow* window = getCachedWindow(sender); 86 93 Event<T> e; 87 94 e.data = event; … … 90 97 public: 91 98 void destroy() { 99 } 100 101 ~GuiModule() { 102 do_auto_join(); 92 103 if (!window) { 93 104 return; … … 97 108 } 98 109 99 ~GuiModule() { 100 do_auto_join(); 101 } 102 103 void execute_front() { 110 bool execute_front() { 111 return false; 104 112 } 105 113 … … 109 117 void loop() { 110 118 [[NSRunLoop currentRunLoop] run]; 111 destroy();112 119 } 113 120 }; -
lang/objective-cplusplus/i3/trunk/src/mil/include/mil/gui-cocoa/GuiModuleObjC.cpp
r34447 r34865 1 1 #import "GuiModuleObjC.h" 2 2 3 @implementation WindowType : 4 NSWindow 5 - (NSWindow*)setParent: 6 (ParentType*)parent_ { 3 @implementation WindowType : NSWindow 4 5 - (NSWindow*)setParent:(ParentType*)parent_ { 7 6 parent = parent_; 8 7 return self; 9 8 } 10 - (void)mouseDown: 11 (NSEvent*)event {9 10 - (void)mouseDown:(NSEvent*)event { 12 11 parent->mouseDown(event); 13 12 } 13 14 - (oneway void)someVoid:(out void*)data { 15 //parent->mouseDown(event); 16 } 17 14 18 @end 15 19 -
lang/objective-cplusplus/i3/trunk/src/mil/include/mil/gui-cocoa/GuiModuleObjC.h
r34815 r34865 1 1 @interface WindowType : 2 2 3 NSWindow { 3 4 ParentType* parent; 4 5 } 5 - (NSWindow*)setParent: 6 (ParentType*)parent_;7 - (oneway void)someVoid: 8 (out void*)data; 6 7 - (NSWindow*)setParent:(ParentType*)parent_; 8 - (oneway void)someVoid:(out void*)data; 9 9 10 @end 10 11 -
lang/objective-cplusplus/i3/trunk/src/mil/include/mil/gui-windows/GuiModule.h
r34851 r34865 23 23 24 24 class EventBase : boost::noncopyable { 25 public:26 //void (*execute)(void* event, void* target);27 25 }; 28 26 … … 198 196 199 197 template <typename Sender> 200 HWND getCachedHWnd(Sender& sender, bool flush = false) { 201 HWND hWnd = NULL; 202 203 //if (__builtin_expect(!hWnd, false)) 204 if (flush || !(hWnd = sender.tls.getData(this->thread_id).hWndCache)) { 205 hWnd = getWindow(); 206 if (!IsWindow(hWnd)) { 198 HWND getCachedWindow(Sender& sender, bool flush = false) { 199 HWND window = NULL; 200 201 if (flush || !(window = sender.tls.getData(this->thread_id).window_cache)) { 202 window = getWindow(); 203 if (!IsWindow(window)) { 207 204 return NULL; 208 205 } 209 sender.tls.getData(this->thread_id). hWndCache = hWnd;210 } 211 return hWnd;206 sender.tls.getData(this->thread_id).window_cache = window; 207 } 208 return window; 212 209 } 213 210 214 211 template <class Sender> 215 212 void postWindowsMessage(Sender& sender, UINT msg, LPARAM lParam, WPARAM wParam) { 216 if (!PostMessage(getCached HWnd(sender), msg, lParam, wParam)) {213 if (!PostMessage(getCachedWindow(sender), msg, lParam, wParam)) { 217 214 DWORD e = GetLastError(); 218 215 if (e == 1400) { 219 PostMessage(getCached HWnd(sender, true), msg, lParam, wParam);216 PostMessage(getCachedWindow(sender, true), msg, lParam, wParam); 220 217 } 221 218 } -
lang/objective-cplusplus/i3/trunk/src/mil/src/Test10.cpp
r34815 r34865 3 3 #include <mil/Atomic.h> 4 4 #include <mil/Thread.h> 5 #include <mil/GuiModule.h>6 5 #include <mil/DoubleBuffer.h> 7 6 #include <quicktest/quicktest.h> -
lang/objective-cplusplus/i3/trunk/src/mil/src/Test11.cpp
r34853 r34865 1 1 #include <mil/PrecompiledHeaders.h> 2 3 2 #include <mil/Mil.h> 4 3 #include <mil/Atomic.h> -
lang/objective-cplusplus/i3/trunk/src/mil/src/Test5.cpp
r34815 r34865 1 1 #include <mil/PrecompiledHeaders.h> 2 #include <mil/GuiModule.h>3 2 #include <mil/Module.h> 4 3 #include <mil/Thread.h> 5 4 #include <quicktest/quicktest.h> 6 5 7 static int global = 0;8 9 #if defined(MIL_GUI_WINDOWS)10 # include <mil/gui-windows/GuiModule.h>11 #elif defined(MIL_GUI_COCOA)12 # include <mil/gui-cocoa/GuiModule.h>13 #else14 # include <mil/gui-cocoa/GuiModule.h>15 #endif16 17 6 namespace Test5 { 18 7 using namespace mil; 19 8 9 static int global = 0; 20 10 struct Plus6 { 21 11 int pad[5]; -
lang/objective-cplusplus/i3/trunk/src/mil/src/Test6.cpp
r34447 r34865 1 1 #include <mil/PrecompiledHeaders.h> 2 #include <mil/GuiModule.h>3 2 #include <mil/Module.h> 4 3 #include <quicktest/quicktest.h> -
lang/objective-cplusplus/i3/trunk/src/mil/src/Test7.cpp
r34447 r34865 2 2 #include <mil/Thread.h> 3 3 #include <mil/Atomic.h> 4 //#include <mil/GuiModule.h>5 //#include <mil/Module.h>6 4 #include <quicktest/quicktest.h> 7 5 … … 45 43 void test2() { 46 44 struct abcde { 47 abcde(T data) : val(data) { 45 abcde(T data) { 46 memset(this, 0xaa, sizeof(*this)); 47 val.store(data); 48 48 } 49 49 char pad1[10];
![(please configure the [header_logo] section in trac.ini)](/share/chrome/site/your_project_logo.png)