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).
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.
If anyone is interested in helping out please let me know!