Well.. some more DLLCC stuff. It's pretty much impossible to re-use .h files as classes in Smalltalk. Why's that? Because you may have something like this in your header file:
#ifdef BLAH
#define FOO BLAH
#endif
In this scenario, initially BLAH won't be defined. But then when another header file includes your header file and defines BLAH to be "Baz" - now we have a new variant of our header file. It doesn't make sense for our header files class to record that result - the header file that included the result should record that result.
So, what does that mean for reuse? Well, it means it is an incomplete concept. It'll work most of the time, but not in cases like the above. So what do we do? Well - I think we borrow a page from the book of DLLCC again.
DLLCC defines a C Interface that has libraries and header files. DLLCC would parse the header files and includes and then ask the developer which bits from all of those header files you wanted to keep. This is a bit insane - I think we can do better here. Why don't we say that we'll keep everything in the header files you specified and keep anything in any other included header file that is referenced by our primary header files.
That way, if there's a definition you really need to use your library, you just promote it to your header files include list.
Okay, so if we're doing things this way - is it now possible to use CPP? .. no. CPP will flatten everything out and there's no guarantee you can find out where a definition came from from its output. So we're back to square one - although now we're only doing a regular c pre-processor in Smalltalk and we're using a bit of smarts to automatically figure out what definitions to install.
Vassili suggested to me that I might have to be able to parse the C expressions as well. I'm not entirely sure if that's true yet - it certainly would be down the path if we decided to do some of the more advanced ideas that have been floating around. But for now, I may get away with just using DLLCC... I guess I'll have to see if there's enough information in DLLCC to figure out which definitions are referenced from the primary definitions.
Like I said in the first of these articles - you have to let these ideas percolate a bit to identify what really needs to be done and how big the task actually is. I've got through a few different iterations now and as you can see we've chopped back from a grandiose new kind pre-processor to an almost stock run of the mill pre processor. The less the merrier.