FFI: FFI-Kernel-mt.121.mcz

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

FFI: FFI-Kernel-mt.121.mcz

commits-2
Marcel Taeumel uploaded a new version of FFI-Kernel to project FFI:
http://source.squeak.org/FFI/FFI-Kernel-mt.121.mcz

==================== Summary ====================

Name: FFI-Kernel-mt.121
Author: mt
Time: 30 April 2021, 4:02:17.500442 pm
UUID: d2b4689e-ac74-5843-9526-b4e752914eb5
Ancestors: FFI-Kernel-mt.120

Fixes off-by-one regression.

=============== Diff against FFI-Kernel-mt.120 ===============

Item was changed:
  ----- Method: ExternalData>>from:to: (in category 'accessing') -----
  from: firstIndex to: lastIndex
  "Only copy data if already in object memory, that is, as byte array. Only check size if configured."
 
  | byteOffset numElements byteSize newType |
  ((1 > firstIndex) or: [size notNil and: [lastIndex > size]])
  ifTrue: [^ self errorSubscriptBounds: lastIndex].
 
  byteOffset := ((firstIndex-1) * self contentType byteSize)+1.
  numElements := lastIndex - firstIndex + 1.
  byteSize := numElements * self contentType byteSize.
 
  "For portions of a null-terminated C string, change the type from char* to byte* to avoid confusion."
  newType := self containerType = ExternalType string
  ifTrue: [ExternalType byte asPointerType]
  ifFalse: [self containerType "No change"].
 
  ^ lastIndex < firstIndex
  ifTrue: [
  handle isExternalAddress
  ifTrue: [(ExternalData
  fromHandle: handle + (byteOffset - 1) "Keep pointer."
  type: newType) size: 0; yourself]
  ifFalse: [(ExternalData
  fromHandle: #[] "Empty memory"
  type: newType) size: 0; yourself]]
  ifFalse: [
  handle isExternalAddress
  ifTrue: [(ExternalData
  fromHandle: handle + (byteOffset - 1)
  type: newType) size: numElements; yourself]
  ifFalse: [(ExternalData
+ fromHandle: (handle copyFrom: byteOffset to: byteOffset+byteSize-1)
- fromHandle: (handle copyFrom: byteOffset to: byteOffset+byteSize)
  type: newType) size: numElements; yourself]]!