- Those dang window message dispatcher macros again, too unclean? - 1 Update
- My C++ Coding Standards ( apologies to Bjarne Stroustrup ). - 2 Updates
- What's in a type? - 2 Updates
- Qucksort for Linked List - 1 Update
Tim Rentsch <txr@alumni.caltech.edu>: Dec 29 02:31PM -0800 > message name expands to some hex number, e.g. 0x000F for WM_PAINT, > which would generate a macro invocation like HANDLE_0x000F instead of > HANDLE_WM_PAINT. [...] (Before I start, thank you for the later explanation of message flow. I think I was able to figure out what I was looking for.) Well, that is annoying. Normally I would expect those would be enumeration constants, but I guess they are macros instead. After seeing this message, I looked into this more deeply. Basically, if you want to handle cracking "automatically" rather than by hand, I think you're stuck with some sort of macro solution. (Disclaimer: I know essentially nothing about the newer variadic template stuff.) However, and here is the good news, I think a macro solution can be constructed that is a lot simpler than the earlier ones. Here is my example file, including some minor warts (partly because the environment is linux but with a -I to get the MS windows header files, and also I dummied up a 'winapi' since I didn't discover one otherwise), which compiles. The definition of SELF_ON() is the key item to look at - does this approach seem cleaner to you? I would be inclined to use something like this. ============================================================================= #define __i686__ 1 #include <windows.h> #include "generated/crackit.h" struct winapi { struct Message { UINT message_id; WPARAM wParam; LPARAM lParam; }; typedef LRESULT Lresult; }; struct Base { virtual winapi::Lresult on( winapi::Message const& m ) = 0; }; #define SELF_ON( type, m ) \ case type: return CRACK_##type( this->on_##type, (m).wParam, (m).lParam ) struct Sample : Base { auto on( winapi::Message const& m ) noexcept -> winapi::Lresult override { switch( m.message_id ){ SELF_ON( WM_COMMAND, m ); SELF_ON( WM_SIZE, m ); SELF_ON( WM_PAINT, m ); } return 0; //subclassing_.original_processing( m ); } winapi::Lresult on_WM_COMMAND( ULONG a, HWND b, ULONG c ){ return 0; } winapi::Lresult on_WM_SIZE( ULONG a, ULONG b, ULONG c ){ return 0; } winapi::Lresult on_WM_PAINT(){ return 0; } }; ============================================================================= The definitions for the CRACK_... macros (ie, in the generated file "generated/crackit.h") are produced programmatically from the HANDLE_... macros in <windowsx.h>, using a short awk script: #! /bin/awk -f $0 ~ /#define HANDLE_WM_/ { gsub( /[(]hwnd,/, "(fn," ); gsub( /,fn[)]/, ")" ); gsub( /[(][(]hwnd[)],/, "(" ); gsub( /[(]fn[)][(]hwnd[)]/, "(fn)()" ); gsub( / HANDLE_/, " CRACK_" ); } So, for what it's worth, that is now the best suggestion I have to offer. |
woodbrian77@gmail.com: Dec 29 02:19PM -0800 On Thursday, December 29, 2016 at 2:55:57 PM UTC-6, Ian Collins wrote: > > like little children, you will never enter the kingdom of heaven. > > Matthew 18:3 > Do little children insult whole countries? I agree with Ben Shapiro when he describes himself as a "radical individualist". I'm for people, but against the baseless hatred in some "leaders" -- Putin, Obama ... Some would like to set a trap for Israel with this UN (United Nothing) vote. The funny thing is that these "leaders" will have the trap they intended for Israel recoil on themselves. I'll be buying products from Taiwan and South Korea, rather than China or Japan. Brian Ebenezer Enterprises - "They prepared a net for my steps; My soul is bowed down; They dug a pit before me; they themselves have fallen into the midst of it. Selah." Psalms 57:6 http://webEbenezer.net |
Ian Collins <ian-news@hotmail.com>: Dec 30 11:25AM +1300 > I agree with Ben Shapiro when he describes himself > as a "radical individualist". I'm for people, > but against the baseless hatred in some "leaders" So how much do you know about the people and leaders of New Zealand? Enough to insult us? -- Ian |
Tim Rentsch <txr@alumni.caltech.edu>: Dec 29 02:00PM -0800 > Simple question, simple answer: in C++ a type is that which an object > is an instance of; an object doesn't have to be an instance of a class > type: an 'int' variable is also an object. This answer conflates the two different notions of type, as explained in my other posting. For example a variable of type 'int' and a variable of type 'const int' are both instances of the 'int' representation, but they have different types (ie, in the sense of what is checked at compile time). |
Tim Rentsch <txr@alumni.caltech.edu>: Dec 29 02:06PM -0800 > when are two >>bundles<< equal? Because of this vagueness, > the sentence possibly cannot be used as a definition. > [...] All these ideas have been explored in the literature 20, 30, or 40 years ago. A good starting point is the paper by James Morris, "Types are not Sets": http://dl.acm.org/citation.cfm?id=582168 |
Tim Rentsch <txr@alumni.caltech.edu>: Dec 29 01:56PM -0800 >> asymptotic complexity, worst-case or otherwise. > So how to get the middle element without traversing linked list O(n) > times for each partition? You are basically contradicting yourself. I gather you now agree that this can be done without changing the order, so I guess there is no need to explain further. The problem of finding the middle element of a list while traversing the list once does make an amusing little exercise. |
You received this digest because you're subscribed to updates for this group. You can change your settings on the group membership page. To unsubscribe from this group and stop receiving emails from it send an email to comp.lang.c+++unsubscribe@googlegroups.com. |
No comments:
Post a Comment