Sign in to follow this  
Javelin

Invoking natives...

Recommended Posts

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

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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...

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this