Author Topic: The DLL thing  (Read 3669 times)

Marcus

  • Guest
The DLL thing
« on: February 28, 2013, 10:32:00 AM »
Ok, I'm the newbee in the crowd, but how do you make usage of DLL:s possible in an interpreted (on the fly) language?

I've made it possible in naalaa to work with DLL:s written FOR naalaa, and it work fine. Since I technically can't create function pointers on the fly, I've added a parameter passing layer that the DLL's got to respect. But this means, that if the programmer wishes to use an arbitrary DLL he's got to implement a freaking layer between the DLL and naalaa. That is, if someone wanted to write a chipmunk extension for naalaa, he'd have to implement a layer DLL to communicate with naalaa. He ends up with the chipmunc dll, the communication dll and most likely a naalaa libray that hides all the DLL stuff.

I simply can't make this clean enough.

Marcus

  • Guest
Re: The DLL thing
« Reply #1 on: February 28, 2013, 10:56:53 AM »
But on the other hand I assume it's inevitable. Most DLL:s require the use of structs and classes that can't be defined in a runtime environment. i'm just annoyed by the fact that I have to wrap a DLL within another DLL wrapped within a naalaa library to make it work for new beginners.

edit: i know you can load dll:s from scriptbasic, but I know barely nothing about scriptbasic, so how the hell it is it done? i simply can't get pass the communication layer (the extra dll)!

edit2: uhm, sorry, these drunk posts should've been put under interpreters, but I assume the problem is the same under scripting.
« Last Edit: February 28, 2013, 11:19:45 AM by Marcus »

Offline John

  • Forum Support / SB Dev
  • Posts: 2999
    • ScriptBasic Open Source Project
Re: The DLL thing
« Reply #2 on: February 28, 2013, 01:49:52 PM »
Hey Marcus, good to hear from you old buddy.  No magic to share but if you do a little digging into FFI, I think the DLLC / DYC / GTK-Server will make more sense to you. ScriptBasic was released in 2000 and used the DynaCall FFI library to load/manage it's shared object (dll/so) extension modules. SB shared objects are unique in that there is a bit of version checking and on load/unload calls made automatically by SB. The SB functions expect a pointer to the instance of the SB executing object and it's return pointer.

I would checkout libffi if your looking for a solution for naalaa as it is more up to date and better supported. You may be able to adapt the DLLC FFI interface Charles did in O2 to work with your language.
« Last Edit: February 28, 2013, 02:39:41 PM by JRS »

Marcus

  • Guest
Re: The DLL thing
« Reply #3 on: March 07, 2013, 10:05:30 AM »
Thanks John! Having a look at libffi, at a first glance it seems to be just about what I'm looking for :)

Offline John

  • Forum Support / SB Dev
  • Posts: 2999
    • ScriptBasic Open Source Project
Re: The DLL thing
« Reply #4 on: March 07, 2013, 11:13:46 AM »
You should look at the GTK-Server source before getting started using the library. It will save you a lot of time.

Marcus

  • Guest
Re: The DLL thing
« Reply #5 on: March 08, 2013, 02:00:40 AM »
Why's that? I've looked at the libffi docs and it looks very straight forward? I will enjoy looking at the source, because the whole topic beats me.

Offline John

  • Forum Support / SB Dev
  • Posts: 2999
    • ScriptBasic Open Source Project
Re: The DLL thing
« Reply #6 on: March 08, 2013, 07:43:40 AM »
Your approach to argument handling is critical. GTK-Server uses the predefined template method and DYC uses ASM to simplify the task. That was my point.