passing a C function back to C library

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

passing a C function back to C library

Christoph Egger
Hi!

[0] discusses how to pass a callback to some C library. Now I would like
to pass a function from some C library to some C library. Is there a
better way to express this than using <cCall ...> to get a smalltalk
function and CCallbackDescriptor to pass it back?

  Christoph

[0] https://www.gnu.org/software/smalltalk/manual/html_node/Smalltalk-callbacks.html

_______________________________________________
help-smalltalk mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/help-smalltalk

signature.asc (834 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: passing a C function back to C library

Paolo Bonzini-2


On 19/02/2017 17:32, Christoph Egger wrote:
> Hi!
>
> [0] discusses how to pass a callback to some C library. Now I would like
> to pass a function from some C library to some C library. Is there a
> better way to express this than using <cCall ...> to get a smalltalk
> function and CCallbackDescriptor to pass it back?

You can get the address of a C function with something like

   CFunctionDescriptor addressOf: 'unlink'

If the function is not defined, the returned object will satisfy #isNull:

   st> (CFunctionDescriptor addressOf: 'unlink') isNull
   false
   st> (CFunctionDescriptor addressOf: 'aaa') isNull
   true

Paolo

>   Christoph
>
> [0] https://www.gnu.org/software/smalltalk/manual/html_node/Smalltalk-callbacks.html
>
>
>
> _______________________________________________
> help-smalltalk mailing list
> [hidden email]
> https://lists.gnu.org/mailman/listinfo/help-smalltalk
>

_______________________________________________
help-smalltalk mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/help-smalltalk

signature.asc (484 bytes) Download Attachment