platform libraries and #close

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

platform libraries and #close

jtuchel
Hi,

I am new to accessing external DLLs, never had to do that on my own before. So I have a few possibly not so clever questions.

* Do I always have to #close a platform library? 
* If so, how can I do that if all my calls are inlined in the source code. I never have Acces to a PlatformFunction instance...
* If a library is in the PATH of the operating system, is there a way to avoid the .dll or .so suffix for portability's sake, other than maintaining a mapping in the .ini for each platform? 

These are surely just the first in a series of questions, but nevertheless, thanks for your help,

Joachim

--
You received this message because you are subscribed to the Google Groups "VA Smalltalk" group.
To view this discussion on the web visit https://groups.google.com/d/msg/va-smalltalk/-/KTE3fPc0-x4J.
To post to this group, send email to [hidden email].
To unsubscribe from this group, send email to [hidden email].
For more options, visit this group at http://groups.google.com/group/va-smalltalk?hl=en.
Reply | Threaded
Open this post in threaded view
|

Re: platform libraries and #close

Marten Feldtmann-2
Am 18.09.2012 10:47, schrieb [hidden email]:
>
>
> * Do I always have to #close a platform library?

No, you do not need to do this - but then of course you are not able to
exchange the dll's while running your program. This is especially nice
when debugging the wrappers of such a library.

> * If so, how can I do that if all my calls are inlined in the source
> code. I never have Acces to a PlatformFunction instance...

  Each platform function belongs to an instance of PlatformLibrary -
search for the specific instance and send it a #close.

> * If a library is in the PATH of the operating system, is there a way
> to avoid the .dll or .so suffix for portability's sake, other than
> maintaining a mapping in the .ini for each platform?

  Initialize the name according to your platform ...

Marten

--
You received this message because you are subscribed to the Google Groups "VA Smalltalk" group.
To post to this group, send email to [hidden email].
To unsubscribe from this group, send email to [hidden email].
For more options, visit this group at http://groups.google.com/group/va-smalltalk?hl=en.

Reply | Threaded
Open this post in threaded view
|

Re: platform libraries and #close

jtuchel
Hi Marten,

thanks for your answers. 
I am not sure I completely understand your answers:

Am Dienstag, 18. September 2012 11:05:31 UTC+2 schrieb Marten Feldtmann:
Am 18.09.2012 10:47, schrieb <a href="javascript:" target="_blank" gdf-obfuscated-mailto="EAMu9BaUZT4J">jtu...@...:
>
>
> * Do I always have to #close a platform library?

No, you do not need to do this - but then of course you are not able to
exchange the dll's while running your program. This is especially nice
when debugging the wrappers of such a library.

Okay. So I'd do it when my application finishes, so that I can do so in a dev image.

 

> * If so, how can I do that if all my calls are inlined in the source
> code. I never have Acces to a PlatformFunction instance...

  Each platform function belongs to an instance of PlatformLibrary -
search for the specific instance and send it a #close.

Sure, but I have no instance of PlatformLibrary that I can access. All my calls are inlined, meaning the look like this:

callAnAPIFunction:
  <c: uint32 'myDLL':NameOfFunction pointer>
  ^self primiitveFailed

So I guess you are referring to PlatformLibrary class >>#logicalName:? This method creates an instance if there is none, is it safe to use it?
 

> * If a library is in the PATH of the operating system, is there a way
> to avoid the .dll or .so suffix for portability's sake, other than
> maintaining a mapping in the .ini for each platform?

  Initialize the name according to your platform ...

Hmm. Not so easy for inlined calls. I cannot swap the name of these. So I guess my only option here is the logical mapping and the .ini file ... ?

Joachim

--
You received this message because you are subscribed to the Google Groups "VA Smalltalk" group.
To view this discussion on the web visit https://groups.google.com/d/msg/va-smalltalk/-/L1TpgkDeGEQJ.
To post to this group, send email to [hidden email].
To unsubscribe from this group, send email to [hidden email].
For more options, visit this group at http://groups.google.com/group/va-smalltalk?hl=en.
Reply | Threaded
Open this post in threaded view
|

Re: platform libraries and #close

Marten Feldtmann-2
Am 18.09.2012 11:28, schrieb [hidden email]:
No, you do not need to do this - but then of course you are not able to
exchange the dll's while running your program. This is especially nice
when debugging the wrappers of such a library.

Okay. So I'd do it when my application finishes, so that I can do so in a dev image.


 When the executable terminates it closes all libraries. Actually I have NEVER ever had the need to close a library - the only situations were when I developed a shared library containing c Smalltalk primitives and the C source was wrong and I had to exchange it more often.


Sure, but I have no instance of PlatformLibrary that I can access. All my calls are inlined, meaning the look like this:

callAnAPIFunction:
  <c: uint32 'myDLL':NameOfFunction pointer>
  ^self primiitveFailed


 There will be one .... when you call your library for the first time ... I think :-)

 

> * If a library is in the PATH of the operating system, is there a way
> to avoid the .dll or .so suffix for portability's sake, other than
> maintaining a mapping in the .ini for each platform?

  Initialize the name according to your platform ...

Hmm. Not so easy for inlined calls. I cannot swap the name of these. So I guess my only option here is the logical mapping and the .ini file ... ?


 Just use the name without "dll" .....

Marten

--
You received this message because you are subscribed to the Google Groups "VA Smalltalk" group.
To post to this group, send email to [hidden email].
To unsubscribe from this group, send email to [hidden email].
For more options, visit this group at http://groups.google.com/group/va-smalltalk?hl=en.
Reply | Threaded
Open this post in threaded view
|

Re: platform libraries and #close

jtuchel
Hi Marten,
  When the executable terminates it closes all libraries. Actually I have NEVER ever had the need to close a library - the only situations were when I developed a shared library containing c Smalltalk primitives and the C source was wrong and I had to exchange it more often.


Sure, but I have no instance of PlatformLibrary that I can access. All my calls are inlined, meaning the look like this:

callAnAPIFunction:
  <c: uint32 'myDLL':NameOfFunction pointer>
  ^self primiitveFailed


 There will be one .... when you call your library for the first time ... I think :-)

Sure there'll be one, but I never get a hold of it if all my calls never use an instance of PlatformFunction. All calls are handled by these pragma-like embedded calls, so I never see an instance of PlatformFunction or PlatformLibrary... 

 Just use the name without "dll" .....


Duhh! Stupid me. This works of course.  Thanks for pointing this out to me.


Joachim



--
You received this message because you are subscribed to the Google Groups "VA Smalltalk" group.
To view this discussion on the web visit https://groups.google.com/d/msg/va-smalltalk/-/3squ-YM3uCYJ.
To post to this group, send email to [hidden email].
To unsubscribe from this group, send email to [hidden email].
For more options, visit this group at http://groups.google.com/group/va-smalltalk?hl=en.