(No Title)
It’s late. I’m not sleepy.
Thinking about Sigma, it’s about time to work on the Python. I just realized that it is infrastructurally possible for me to implement Python “behaviors” for denizens. Meaning, every n ticks (probably equivalent to about 5 seconds), an arbitrary Python function is executed for a designated denizen.
Although it is untested so far, it is quite possible to perform some amazing “look and feel” type procedures just using the one Python extension interface I have already written. This is the Python wrapper to the Server::Message() function, which implements the ability to send a per-case formatted message to user(s) in the room, world, or just one character, based upon a format string like those seen in the printf() cstdlib function family. This allows things like “You enter the room” and “Brandon enters the room” to be sent to the proper parties based upon who is reading the text.
The interpreter is fully functional (I have tested this, or I wouldn’t even be talking about it), but I haven’t quite decided upon the architecture for the Python bindings. To summarize the procedure, you load a “module” (codename.py file) into the interpreter, which then passes you a Dictionary object containing function name (string) vs. function “pointer”. You then pass this “pointer” into a Py_CallFunc()-type thing and deal with the return value. I think I’m going to use something called a functor to encapsulate and provide an interface to the actual calling process. The link eloquently describes a functor as a class that overloads the () operator (i.e., the function calling operator). This would serve as a great interface, and you could pretty much treat this functor class as a C++ function pointer.
The morbidly curious might wonder how I plan to deal with object access from Python scripts. The answer is a 32 bit number. Memory locations are addressed at the upper limit of the “bit” of the operating system, or 32 bits. An unsigned long is also maxed out at the bit of the OS. So, I’m casting my object pointers to unsigned longs and sending them raw to Python, which then will call interface functions like sigma.messageTo(“format string”, int dest, ...). The C++ implementations of these interface functions will cast the ulong’s back to object pointers and dereference them to complete the action.
I’m working on getting dynamic_cast<>()’s to work in order to check the integrity of these back-casted long addresses, but this may not be possible (at least with GCC 3.3.4). It wants these things to be object pointers to start with (instead of “numbers”). Maybe I can static cast the ulong to a Character*, and then cast the Character* to itself (just to take advantage of the type-checking provided by dynamic_cast’s). I don’t know.
Anyway, the challenger won Iron Chef America and I need to force myself to bed.