Jump to content
Sign in to follow this  
noubernou

Carma: A C++ to SQF "native" Interface

Recommended Posts

Hey guys, just announcing a little project I started a few days ago to provide a "native" interface to SQF commands inside C++ using callExtension. This allows you to write plugins in C++ that can call and interact directly with SQF.

Right now its incredibly basic, more of a proof of concept than anything workable, but the concept seems solid so far. I have implemented the sqf functions for time and hintSilent and have had them perform correctly.

Method of Operation

As for technical details, the entire system is blocking, which means there is no annoying asynchronous message queues exposed to the programmer or anything that creates superfluous execution time. In both SQF and C++ they appear as native functions to the programmer who does not need to worry about the behind the scenes operations for getting data from the SQF RealVirtuality (RV) engine.

It works on a simple messaging system based on two threads, the main entrant thread and an execution thread. A call originating from SQF first enters the DLL (which if it hasn't been called before initializes the execution thread which waits for a command) and the type of call is determined. If it is a call to execute a C++ defined function then it messages the execution thread that there is a new task to execute. While that task executes the entrant thread waits for a message from the execution thread. The execution thread will run the defined task, and if it contains a call to SQF then it tells the entrant thread to stop waiting and return with a message to the original SQF call telling SQF to execute the needed command. The execution thread now enters a waiting period while the SQF command is executed.

The SQF command is parsed and executed in SQF space and the result is then messaged back to the DLL which determines that the type of call is a return value from a previous SQF command generated in the execution thread. This value is messaged to the execution thread, which then continues executing the SQF function call and handles the return data, eventually returning it to the original user defined function called originally. This can happen multiple times for each SQF command executed. It simply messages back and forth between threads and SQF with the required data. When the user defined function is finished all that is required is that the user call a specific return function, which is essentially the same as the previous call back to SQF messages except that it is final and no longer will come back to the DLL. The execution thread goes into a waiting state, waiting for the next user defined command to execute, and the original entrant thread also idles till the next command from callExtension (which would be a call to execute a C++ defined function).

Development

As far as future development goes this project is not on my front burner, but somewhere towards the back. I do plan to work on a more mature implementation of my proof of concept, but my ultimate goal would for this project to be taken up by members of the community and worked on. I plan to keep this thread updated with any developments.

Dev-Heaven: https://dev-heaven.net/projects/carma

If anyone is interested in helping out please let me know! :)

Edited by NouberNou
Added DH link.

Share this post


Link to post
Share on other sites

This sounds very interesting. I am working on a plugin for the Eclipse IDE for ARMA mission (and addon) editing, and something like that might enable me to attach the IDE directly to the editor, if there is the possibility to run scripts from within the editor somehow. That would be a very nice addition, since it could be used e.g. to connect the Equipment/Loadout editor directly to a editor-unit, or read config entries directly from the IDE...

Share this post


Link to post
Share on other sites

When I say carma, I immediately thought of carmageddon. Anybody else think that?

Share this post


Link to post
Share on other sites
When I say carma, I immediately thought of carmageddon. Anybody else think that?
Absolutely. Bring on the blood!!

Share this post


Link to post
Share on other sites
When I say carma, I immediately thought of carmageddon. Anybody else think that?

Now THERE was a game ! Outright devastation and we were able to mow down pedestrians in new and interesting ways ..... ahh the good old days !

'Take On Carmageddon' FTW .... sorry to derail!

Nice work Nou!

Share this post


Link to post
Share on other sites

I'll definitely have to check out your project. It seems like it does what I need. Maybe a bit more than I need actually... I only require the SQF to call 2 custom functions on a DLL.

First I'll have to check if it supports parameters though.

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  

×