On 27 June 2013 17:14, Henrik Johansen <[email protected]> wrote:
>
> On Jun 27, 2013, at 4:11 , Igor Stasenko wrote:
>
>>
>>> Or is a disclaimer not to use the class for, say, 'char*' elements more
>>> appropriate?
>>>
>> no , it should be fine.
>
> Was thinking of that in conjunction with putting ST object refs in the
> External arrays, the trying to pass as parameters, it could be a recipe for
> disaster :)
> Like, say:
>
> "Add a null at end so ExternalArrays basic #readString won't keep on readin'"
> string := 'Hello world!' copyWith: (Character value: 0).
> extArray := (NBExternalArray ofType: 'char*') new: 1.
> "Tenure the string first, lest we invalidate on next scavenge"
> Smalltalk garbageCollectMost.
> extArray at:1 put: string.
>
> "X our fingers, and hope GC doesn't move string.
> Often serves as a nice example that it will :)"
> (extArray at: 1) readString
> string at: 7 put: $W.
> (extArray at: 1) readString
>
hehe.. that certainly a recipe for disaster.
That's why there should be no NBExternalValue>>address (pointing at Ciprian),
which answers a pointer to oop's first byte, like that given test:
testOutVoidArg
|x value|
NBTestExternalValue initialize.
value := 12345678.
x := NBTestExternalValue new.
self outputVoidArg: x address value: value.
self assert: x value = value.
may work.
But actually it will not. And this is **WRONG** in same way as your example.
> Cheers,
> Henry
--
Best regards,
Igor Stasenko.