SRL Archive - OSR Help

Possible To Host Script Logic in Different Programming Language


ZappyDude

2013-03-16 23:03:19

I'm new here and just wondering: is it possible to host the majority of a script's logic in a different programming language or environment and have it communicate with the Simba process to make requests for data and issue commands? This sounds like a really convenient feature and I'm wondering if there is a built-in way to access Simba programmatically through something like a foreign function interface or inter-process communication. I tried looking around but I'm not 100% sure what terms to search for. Thanks in advance.

x[Warrior]x3500

2013-03-16 23:07:17

afaik, the only thing similar to this is dlls using c++. but they are almost never used simply because they dont need to be used for most things.

ZappyDude

2013-03-16 23:13:41

I have two proposed use-cases:
- programmer can use language they are most familiar with
- programmer can use domain-specific libraries for algorithmic tasks

It sounds like a really cool idea on paper, and I'm curious if there is an existing implementation or what practical approaches could be used to make one.

ZappyDude

2013-03-17 01:57:48

Is it possible for a plugin to call back into the current Simba script?

Richard

2013-03-17 08:20:29

As both core and Warrior have stated, you can basically make a library if you'd rather use a different programming language, if you know how. While you'll still need to code to some extent in Simba, it'll take your methods from the library you've created. It has a couple of benefits:
1) Generally it is much more efficient
2) You're not limited by the procs/funcs of Simba.

However, you cannot write a .dll in java, or at least not without some magic from C++. From my limited knowledge, I think you'll need some C++ to actually initiate the JVM, to run the java code.

You might want to check these out:
http://villavu.com/forum/showthread.php?t=58815 - How to create plugins, but it's in Lazarus, you'll have to adapt.
http://villavu.com/forum/showthread.php?t=13118 - An example of a C++ plugin, if you wanted to work form there.

ZappyDude

2013-03-17 13:25:52

Thank you all. These responses have been very insightful. I'm definitely curious to explore this idea, even though I'm not sure of its overall practicality yet.

In the case of an extension, how would I make the extension call back into Simba? That is, I'm looking to invoke the extension from within Simba, then have the extension invoke some function that was defined inside the Pascal interpreter in Simba (e.g. some SRL library function). The conceptual call stack would look like the following:

(top - most recent call)
SomeSRLLibraryFunction
SomeExternalLanguageLibraryFunction
FunctionProvidedByExtension
MainLoopOfSimbaScript

The expected use-cases for this are:
- use Simba color-related and SRL RS-related routines from within the extension
- use Simba mouse-related routines from within the extension

Where can I learn more about how extensions pass data around? Are arrays/strings/structs encoded according to Pascal convention, Delphi convention, or something else? (I'm not sure these are even the correct names, to be honest, since I have only used C among languages in this category.) I previously thought the two were the same, but Google suggests I need to specifically distinguish between the two which one I have.