Invoking natives...

Started by
2 comments, last by Javelin 19 years, 8 months ago
Hi I'm just about to finish the front end of my script compiler and will be heading for the back end soon. I have a problem though, I want to be able to call native functions (e.g. functions defined in an external dll) from the scripts. The core of the problem is that I do not see how I can call a function by name with arguments that is defined in text (the script file). The problem is not to get handles to the functions in the dll, but rather how to invoke them whit generic arguments. I will use a virtual machine to run my compiled scripts and I really don't want to have a VMcommand for each native function I want to use (and thus rebuild the VM each time I change or add a dll). I have checked some at the JNI and thats pretty much what I want to do. I have not however found how the VM makes the native call. Any thoughts? EDIT: I use C++ and a windows platform
// Javelin// Assumption is the mother of all fuckups...
Advertisement
Well, there are two ways (that i can think of).

1 - use the "..." mechanism. It allows for variable argument lists. Ive never done it with an exported dll function, but it seems like it would work.

2 - this is probably a better idea. Use dators (see the Enginuity article about it in the articles section of gamedev). Have all the methods take a std::list of dator objects. That would provide a safe generic way to supply arguments to a function.
Quote:
1 - use the "..." mechanism. It allows for variable argument lists. Ive never done it with an exported dll function, but it seems like it would work.


I thought of that too, but for various reasons I rather avoid it.

I will look into your other sugestion... it sounds like a possible way.
Thank you.

Other idéas are still most wealcome...
// Javelin// Assumption is the mother of all fuckups...
I would really like som more input on this... :]

*bump*
// Javelin// Assumption is the mother of all fuckups...

This topic is closed to new replies.

Advertisement