Trying to write a plugin - how to store a pointer
Todd Blanchard
tblanchard at mac.com
Mon Jan 23 23:01:28 UTC 2006
For various reasons, I'm wanting to build a plugin to a library that
requires me to hold onto pointers to things. This means I need to
store the pointer in an ivar in a squeak object and use it on
subsequent calls.
Can I get away with using a SmallInteger for this? Basically doing
something like:
primNewContext
| ctx |
self export: true.
self primitive: 'primCreateContext' parameters: #().
self var: #ctx type: 'int'.
ctx := self cCode: 'LIB_NewContext()'.
^ctx.
primDestroyContext: ctx
self export: true.
self primitive: 'primDestroyContext' parameters: #(SmallInteger).
self cCode: 'LIB_DestroyContext((void*)ctx)'.
Or is this evil and I should consider a different technique?
If this is evil, what is the good way to store external addresses in
ivars?
Thanks
More information about the Vm-dev
mailing list