11/12/2007

11-12-07 - 2

I finally got off my ass and started uploading some of the junk I've worked on in the last few years. Some of the stuff has mod times from January 2006 which is pretty scary; WTF happened to 2007? Oh well.

I put my new "cblib" in the Misc section. So far as I know the old "crblib" (which was ugly as hell) and the newer "Galaxy3" never really caught on with anyone (for actual use as a library), but since I have an audience of zero I'm devoted to updating them with another library that noone will use. Anyway the point of cblib isn't that anyone use it as is, but rather people can look at the code and steal some snippets they like. It's got a bunch of the old stuff cleaned up and unified as well as some hot new stuff.

Some bits you might be interested in :

There's lots of good 3d maths stuff, but it's the same stuff that's in Galaxy3 for the most part. There's really nothing new in terms of 3d stuff, but there are a few little cleanups and fixes compared to the Galaxy3 versions.

Lots of funny STL and C++ ism stuff. If you think this stuff is retarded you can have a good laugh looking at the weird stuff I do. Probably the funniest of these are the next two :

Reflection & Prefs mechanism. The code for this looks rather complex, but it comes out very very simple to use in the client and I'm very happy with how it works. My big poker app uses this system and it roxors the hizzouse. The prefs are very easy to mark up in code, human editable, and the whole system is "Immediate Mode" to use Casey's lingo which means you can do version-conversions right in the reader and nice stuff like that very elegantly. The system is so simple to the client that you can use it without understanding it; if you want to decode some template functor insanity you can try to follow the execution flow.

safeprintf - looks just like printf to the client but validates args (at runtime). I'm mostly happy with this. It has helped me find a lot of bugs already and it does create a pretty nice human readable error that tells you exactly what the error is, like "printf expected %s but got data of type (int)". You could easily use the exact same mechanism to make a printf that does conversions, eg. so you can just pass in your own String and print it with a %s, but I haven't actually done that because I'm not sure if it's a good idea. For one thing that makes it no longer directly interchangeable with printf and that could lead to disasters when you search-replace to change your printf to a fprintf or something that's not patched.

Some useful Win32 junk, like a little DirChangeWatcher file that compactly exposes the ReadDirectoryChangesW that everyone does; the "Metered Section" code that I mentioned here previously, and some goodies in Win32Util like how to make an app that can be either console-attached or make its own console, how to really mess with other apps, stuff like that.

BTW while I'm on the topic, the damn HWND system in Win32 is so fucking hosed. The handles are not unique (they get reused), they can become invalid at any time, and it's not a valid safe weakpointer system so if you are holding HWND's to other apps they can suddenly and with no notification to you either change identity or become garbage pointers. Now of course you should never store an HWND to another app's window in your state, but even if you're just holding one in a local while you do some work on it, a thread switch can destroy you. Stupid OS should've had a proper Smart/Weak pointer system so that my HWND reference was a unique weak reference.

There's a half decent BmpImage class finally; I'm still not delighted with it; how is it that I've worked on images for all this time and never really written a decent image class?

No comments:

old rants