Phlub - Complexity for the sake of being complex

Community Forums/Showcase/Phlub - Complexity for the sake of being complex

N(Posted 2006) [#1]
Phlub is my experiment in making something as stupidly complex as I could. I failed in that regard, I think, since it's not as stupidly complex as I could make it, but it's certainly over the top.

What Phlub does is it acts as a host (not server host, it's a plugin host) for DLLs to be called from. Phlub loads a server DLL from the data directory and executes it, whereupon the server DLL takes over from there.

The server DLL has access to a limited API specific to Phlub. This is the API in general:
// memory management
void* CALL (*mm_alloc)(int size);
void* CALL (*mm_resize)(void* mem, int size, int newsize);
int CALL (*mm_copy)(void* from, void* to, int size);
int CALL (*mm_free)(void* mem);

// object table
int CALL (*ob_register)(int plugin, const wchar_t* name, const void* p, int shared);
int CALL (*ob_unregister)(int plugin, int handle);
void* CALL (*ob_getname)(int plugin, const wchar_t* name);
void* CALL (*ob_gethandle)(int plugin, int handle);

// file system
int CALL (*fs_open)(const wchar_t* filename, int *file, int write);
int CALL (*fs_close)(int file);
int CALL (*fs_read)(int file, void* to, int bytes);
int CALL (*fs_write)(int file, const void* from, int bytes);
int CALL (*fs_seek)(int file, int to);
int CALL (*fs_pos)(int file);
int CALL (*fs_eof)(int file);

// console output
int CALL (*con_print)(const wchar_t* text);
int CALL (*con_get)(wchar_t* putin, int length);

// access to other plugins
int CALL (*pl_open)(const wchar_t* name);
int CALL (*pl_free)(int plugin);
int CALL (*pl_msg)(int plugin, int msg, const void* in, int insize, void* out, int outsize);
int CALL (*pl_plugins)(wchar_t** plugins, int count);


What I wanted to do with this after I decided I wasn't going to be able to make it as stupidly complex as I could was use it as a way to create a sort of pseudo-runtime-environment (yes, I realize how utterly retarded this sounds) for other things with the server plugin being the equivalent of a main function.

If you don't think this is incredibly stupid yet then I applaud your ability to rationalize. There are no screenshots, by the way.

There is no way to use graphics without a plugin, filesystem access is limited. You have only rudimentary implementations of Input( ) and Print( ) (no formatting options like printf and scanf -- that's not to say you can't use those to produce the strings you pass to con_print though -- as for con_get, well, the string you pass to it is where the output is stored).

You can, of course, call other plugins from the server (and likewise other plugins can call other plugins, call back to the server, etc.). There is also a simple object registry that lets you store data using string-based names and integer keys that is based off of Defoc8's hash table code (that I pretty much molested).

Anyhow, for complete source code and the like (includes a cross-platform plugin loader), you can...

DOWNLOAD HERE


Boiled Sweets(Posted 2006) [#2]
Erm wot? Why? And lampost?


Zenith(Posted 2006) [#3]
Sweet, I've always wanted this, really


BlackJumper(Posted 2006) [#4]
I'm surprised that no one has yet pointed out the error in this line
int CALL (*pl_msg)(int plugin, int msg, const void* in, int insize, void* out, int outsize);




N(Posted 2006) [#5]
What error?


BlackJumper(Posted 2006) [#6]
should be...

int CALL (*pl_message)(int plugin, int msg, const void* in, int insize, void* out, int outsize);




/BlackJumper yanks the rod and starts to reel Noel in...


N(Posted 2006) [#7]
That's not an error.