On 27 June 2013 15:34, Henrik Johansen <[email protected]> wrote: > > On Jun 27, 2013, at 2:22 , Igor Stasenko wrote: > > i think it fails because you passing strange (NBExternalObject null) > as length parameter. > i guess you meant NBExternalAddress null instead. > > > Speaking of weird external stuff… > > NBExternalArray class >> #initElementType: aTypeName > "Initialize the element type and size. > If you want to use a public subclass of me, then make sure you call this > method > in your class #initialize method. > " > > elementType := aTypeName. > elementSize := (NBFFICallout new requestor: self; resolveType: elementType) > valueSize . > self installAccessors. > > Shouldn't that be storageSize?
Yes, you right. (NBFFICallout new resolveType: 'byte*') valueSize => 1 (NBFFICallout new resolveType: 'byte*') storageSize => 4 apparently, if one wants array with 'byte*' element type (or any other) it should use a pointer size (4), not byte size (1) for it. > Or is a disclaimer not to use the class for, say, 'char*' elements more > appropriate? > no , it should be fine. The difference between valueSize and storageSize is a bit confusing, and easy to confuse which to use.. Perhaps they need different naming. There also stackSize, which means "how many bytes a value of given type will take, if pushed on stack , and aligned accordingly" ... after some more investigation, i found that actually storageSize should not be used. There is typeSize instead. So, the final expression should be: elementType := aTypeName. elementSize := (NBFFICallout new requestor: self; resolveType: elementType) typeSize. and #sizeOf: method should also use typeSize apparently. > Cheers, > Henry -- Best regards, Igor Stasenko.
