Hey guys,
Update:
okay..., I've been able to determine that at least some of it has to be done in assembly language.
I've looked at the source code that John provided and the sources for "DynaCall", written by Ton Plooy.
It looks like I have two options,
1) I can use inline assembly, embedded in C, or
2) write a module entirely in assembly and compile it into an ".obj" file and "link" it to Bxbasic.
Why Assembly Language, you may ask ?
Well, it has to do with passing parameters to arbitrary functions.
You never know ahead of time how many parameters nor their type(s).
Recall the illustration I made with all the templates.
If you used templates (an obsurd idea) it can be done entirely in C.
You can't simply say: <call> MessageBoxA(hwnd, "helloworld", "Hello", uType)
or: <call> toupper(mychar)
or: <call> exp(MyDouble)
for calling external functions and expect it to work.
It doesn't.
Remember, we are not talking about a compiler here.
When you compile those statements, the compiler, linker and loader handle all the details for you.
We are talking about calling and executing those DLLs and Functions "on the fly".
The root problem is pushing an arbitrary number of arbitrary types of parameters onto the stack.
C, by itself, has no direct control of the stack.
Their isn't a C method for doing a "push" or "pop".
That is the problem.
The solution is to manually parse the parameters, push them onto the stack and then call the DLL or API function.
I'd like to hear any input, ideas or thoughts you may have on this.
Steve