Changeset 34865

Show
Ignore:
Timestamp:
08/13/09 12:39:38 (4 years ago)
Author:
saturday06
Message:

iaopfdjadofijasfojdi

Location:
lang/objective-cplusplus/i3/trunk
Files:
14 modified

Legend:

Unmodified
Added
Removed
  • lang/objective-cplusplus/i3/trunk/am/mil_test.am

    r34839 r34865  
    77src/mil/src/TestMain.cpp \ 
    88src/mil/src/StaticData.cpp \ 
    9 src/mil/src/Test11.cpp 
     9src/mil/src/Test2.cpp \ 
     10src/mil/src/Test3.cpp \ 
     11src/mil/src/Test4.cpp \ 
     12src/mil/src/Test6.cpp \ 
     13src/mil/src/Test7.cpp \ 
     14src/mil/src/Test8.cpp \ 
     15src/mil/src/Test10.cpp \ 
     16src/mil/src/Test11.cpp \ 
     17src/mil/src/Test12.cpp 
    1018 
     19# src/mil/src/Test9.cpp \ 
    1120# 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 \ 
    2021# src/mil/src/Test11.cpp 
    2122 
  • lang/objective-cplusplus/i3/trunk/kdevelop/i3.kdevses

    r34849 r34865  
    1616  </Doc3> 
    1717  <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" /> 
    1919  </Doc4> 
    2020  <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  
    1515namespace i3 { 
    1616typedef std::string string; 
    17 typedef boost::format format; 
     17//typedef boost::format format; 
    1818} 
    1919 
  • lang/objective-cplusplus/i3/trunk/src/mil/include/mil/ModuleCommon.h

    r34853 r34865  
    99    struct Data { 
    1010#ifdef MIL_GUI_WINDOWS 
    11         HWND hWndCache; 
     11        HWND window_cache; 
     12#else 
     13        NSWindow* window_cache; 
    1214#endif 
    1315    } data[MIL_MAX_THREADS]; 
     
    2325    void flush() { 
    2426        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; 
    2828        } 
    2929    } 
  • lang/objective-cplusplus/i3/trunk/src/mil/include/mil/Synchronize.h

    r34841 r34865  
    6969        } 
    7070    } 
    71  
     71     
    7272    void passeren() { 
    7373        sem_post(&sem); 
     74    } 
     75 
     76    void p() { 
     77        passeren(); 
    7478    } 
    7579 
     
    7781        sem_wait(&sem); 
    7882    } 
     83 
     84    void v() { 
     85        verhoog(); 
     86    }     
    7987     
    8088    ~Semaphore() { 
  • lang/objective-cplusplus/i3/trunk/src/mil/include/mil/gui-cocoa/GuiModule.h

    r34447 r34865  
    1212public: 
    1313    Tls tls; 
     14    MIL_CRTP_CLASS_MEMBERS; 
     15 
    1416private: 
    1517    template <typename T> 
     
    1820        typedef T DataType; 
    1921        T data; 
     22        void (*execute)(void* event, void* target); 
    2023    }; 
    21  
    22     friend class Module_test; 
    2324 
    2425private: 
     
    3435 
    3536    void requestExit(void* event_memory) { 
     37        exitNotifier.tls.flush(); 
    3638        ExitEvent e; 
    37         post(e, *this); 
     39        post(e, exitNotifier, event_memory, exitNotifier.tls.thread_id); 
    3840    } 
    3941 
    4042    GuiModule() : tls(this->thread_id), repost(false), window(NULL) { 
    41         set_auto_join(this); 
    4243    } 
    4344 
    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(); 
    4650    } 
    4751 
     
    5357    template <typename Data, typename Sender> 
    5458    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; 
    6260        Target& target = *static_cast<Target*>(target_); 
    6361        Event<Data>& event = *static_cast<Event<Data>*>(event_); 
    64         target.list.pop(); 
    6562        target.repost = false; 
    66         ModuleExecuteProxy<Data, Target>::execute(event.data, target); 
     63        ModuleExecuteProxy::execute<Data, Target>(event.data, target); 
    6764        if (target.repost) { 
    6865            target.post(event.data, target); 
     
    7067        } 
    7168    } 
     69 
    7270public: 
    7371    void requestExit() { 
     
    7674    } 
    7775 
     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 
    7890    template <typename T, typename Sender> 
    7991    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); 
    8693        Event<T> e; 
    8794        e.data = event; 
     
    9097public: 
    9198    void destroy() { 
     99    } 
     100 
     101    ~GuiModule() { 
     102        do_auto_join(); 
    92103        if (!window) { 
    93104            return; 
     
    97108    } 
    98109 
    99     ~GuiModule() { 
    100         do_auto_join(); 
    101     } 
    102  
    103     void execute_front() { 
     110    bool execute_front() { 
     111        return false; 
    104112    } 
    105113 
     
    109117    void loop() { 
    110118        [[NSRunLoop currentRunLoop] run]; 
    111         destroy(); 
    112119    } 
    113120}; 
  • lang/objective-cplusplus/i3/trunk/src/mil/include/mil/gui-cocoa/GuiModuleObjC.cpp

    r34447 r34865  
    11#import "GuiModuleObjC.h" 
    22 
    3 @implementation WindowType : 
    4 NSWindow 
    5 - (NSWindow*)setParent: 
    6 (ParentType*)parent_ { 
     3@implementation WindowType : NSWindow 
     4 
     5- (NSWindow*)setParent:(ParentType*)parent_ { 
    76    parent = parent_; 
    87    return self; 
    98} 
    10 - (void)mouseDown: 
    11 (NSEvent*)event { 
     9 
     10- (void)mouseDown:(NSEvent*)event { 
    1211    parent->mouseDown(event); 
    1312} 
     13 
     14- (oneway void)someVoid:(out void*)data { 
     15    //parent->mouseDown(event); 
     16} 
     17 
    1418@end 
    1519 
  • lang/objective-cplusplus/i3/trunk/src/mil/include/mil/gui-cocoa/GuiModuleObjC.h

    r34815 r34865  
    11@interface WindowType : 
     2 
    23NSWindow { 
    34    ParentType* parent; 
    45} 
    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 
    910@end 
    1011 
  • lang/objective-cplusplus/i3/trunk/src/mil/include/mil/gui-windows/GuiModule.h

    r34851 r34865  
    2323 
    2424    class EventBase : boost::noncopyable { 
    25     public: 
    26         //void (*execute)(void* event, void* target); 
    2725    }; 
    2826 
     
    198196 
    199197    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)) { 
    207204                return NULL; 
    208205            } 
    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; 
    212209    } 
    213210 
    214211    template <class Sender> 
    215212    void postWindowsMessage(Sender& sender, UINT msg, LPARAM lParam, WPARAM wParam) { 
    216         if (!PostMessage(getCachedHWnd(sender), msg, lParam, wParam)) { 
     213        if (!PostMessage(getCachedWindow(sender), msg, lParam, wParam)) { 
    217214            DWORD e = GetLastError(); 
    218215            if (e == 1400) { 
    219                 PostMessage(getCachedHWnd(sender, true), msg, lParam, wParam); 
     216                PostMessage(getCachedWindow(sender, true), msg, lParam, wParam); 
    220217            } 
    221218        } 
  • lang/objective-cplusplus/i3/trunk/src/mil/src/Test10.cpp

    r34815 r34865  
    33#include <mil/Atomic.h> 
    44#include <mil/Thread.h> 
    5 #include <mil/GuiModule.h> 
    65#include <mil/DoubleBuffer.h> 
    76#include <quicktest/quicktest.h> 
  • lang/objective-cplusplus/i3/trunk/src/mil/src/Test11.cpp

    r34853 r34865  
    11#include <mil/PrecompiledHeaders.h> 
    2  
    32#include <mil/Mil.h> 
    43#include <mil/Atomic.h> 
  • lang/objective-cplusplus/i3/trunk/src/mil/src/Test5.cpp

    r34815 r34865  
    11#include <mil/PrecompiledHeaders.h> 
    2 #include <mil/GuiModule.h> 
    32#include <mil/Module.h> 
    43#include <mil/Thread.h> 
    54#include <quicktest/quicktest.h> 
    65 
    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 #else 
    14 #  include <mil/gui-cocoa/GuiModule.h> 
    15 #endif 
    16  
    176namespace Test5 { 
    187using namespace mil; 
    198 
     9static int global = 0; 
    2010struct Plus6 { 
    2111    int pad[5]; 
  • lang/objective-cplusplus/i3/trunk/src/mil/src/Test6.cpp

    r34447 r34865  
    11#include <mil/PrecompiledHeaders.h> 
    2 #include <mil/GuiModule.h> 
    32#include <mil/Module.h> 
    43#include <quicktest/quicktest.h> 
  • lang/objective-cplusplus/i3/trunk/src/mil/src/Test7.cpp

    r34447 r34865  
    22#include <mil/Thread.h> 
    33#include <mil/Atomic.h> 
    4 //#include <mil/GuiModule.h> 
    5 //#include <mil/Module.h> 
    64#include <quicktest/quicktest.h> 
    75 
     
    4543void test2() { 
    4644    struct abcde { 
    47         abcde(T data) : val(data) { 
     45        abcde(T data) { 
     46            memset(this, 0xaa, sizeof(*this)); 
     47            val.store(data); 
    4848        } 
    4949        char pad1[10];