Jump to content
  • Advertisement
Sign in to follow this  
Javelin

Invoking natives...

This topic is 5067 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

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
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.

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
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!