AOP for GPCP is on the way, so I decided on the weekend to come to grips with GPCP in its current version. I want to put together a fantasy day-trading application so I can compete with my family, so I thought I would attack both problems at once and code it all in CP. Just to spice things up a little, I don't know Pascal (or Component Pascal).
On the whole it was pretty easy to get the hang of. I was able to knock out some working code quickly, and the interaction with other .NET assemblies was fairly seamless.
However, I did have a couple of problems:
- ValueType records - I started by coding several record types and associated procedures in GPCP. I then switched to C# to write some GUI code on top of these GPCP records. To my dismay, I discovered the records had been split into a Boxed_XXXX, containing all the methods, and a field with an instance of XXXX, containing all the fields. After messing around for a while I discovered that declaring the record EXTENSIBLE solved the problem.
- Cast in CP? - This is probably down to my own ignorance, but it proved frustrating. Most of the time, CP arrays must have a statically declared, constant size. This wasn't the behaviour I needed, so I decided to use System.Collections.ArrayList. Unfortunately, the get_Item method (and a lot of others I wanted) returns an object instance. How can I cast it to a strongly-typed pointer in CP? The "solution" I settled on was to create strongly-typed wrappers in C# that took the casting out of my CP code. This was all fine in theory...
- N2cps broken - To interact with my C# strongly-typed collection from CP I needed to create some sort of header file using N2cps. At least that is what I think. Anyway, N2cps fell in a heap at startup, with a message about an incorrect .NET version. I am running Everret, so who knows? I'll try it on my Whidbey machine some other time.
|