Advertisement

wierd scripting hack

Started by May 30, 2001 02:13 PM
0 comments, last by Dog_Food 23 years, 8 months ago
Is this legal... I have a list of functions with parameters void* function1( void*) void* function2( void*, void*) void* function3( void*, void*, ...) Then any function can be added to the scripting language and cast to void*. When the function is called, it is cast to the function with the correct number of parameters. Like this... int add( int a, int b); add is added to the scripting language. when it is called, it is cast to function2 ((function2*)(functionpointer))( (void*)1, (void*)2); Then in the scripting language, there is a list of functions that can call the various void functions. The scripting language function is passed its arguments in an array, and then it dispatches them to the correct void* function which is really a pointer to a different function. This way, functions with any number of parameters can be supported by a scripting language as long as they are all 32 bit. Any questions, any problems with this approach?
Sure it's legal, good luck debugging

Package the stuff up more. If you want to the functionality to be extensible you'll probably want to use .dlls. Make a spec that all the dlls have to follow - i.e. a couple of functions must be in them.

Something like
ListFunctions(int nFuncs, char* szFunc[])
And a
GetFuncParams(int iFuncID, int nParams, enum ParamType[])

This way the script executor can make some sanity checks before blindly calling into code and messing up the stack while it's at it.


or learn COM cause that's what it does.

Magmai Kai Holmlor
- The disgruntled & disillusioned


Edited by - Magmai Kai Holmlor on May 30, 2001 8:33:43 PM
- The trade-off between price and quality does not exist in Japan. Rather, the idea that high quality brings on cost reduction is widely accepted.-- Tajima & Matsubara

This topic is closed to new replies.

Advertisement