[squeak-dev] FFI: FFI-Kernel-mt.134.mcz
commits at source.squeak.org
commits at source.squeak.org
Wed May 5 17:00:03 UTC 2021
Marcel Taeumel uploaded a new version of FFI-Kernel to project FFI:
http://source.squeak.org/FFI/FFI-Kernel-mt.134.mcz
==================== Summary ====================
Name: FFI-Kernel-mt.134
Author: mt
Time: 5 May 2021, 7:00:01.584784 pm
UUID: 2737ad22-4c7e-9645-9837-93f0319dc31c
Ancestors: FFI-Kernel-mt.133
Allocate! Clarify what is actually possible to allocate through an external type.
(I think it would be nice to have some kind of mapping between atomic types and a representative. Maybe a mapping to a class to call #zero on.)
=============== Diff against FFI-Kernel-mt.133 ===============
Item was added:
+ ----- Method: ExternalArrayType>>allocate (in category 'external data') -----
+ allocate
+
+ ^ self contentType allocate: self size!
Item was added:
+ ----- Method: ExternalArrayType>>allocate: (in category 'external data') -----
+ allocate: anInteger
+ "No support for n-dimensional containers."
+ self notYetImplemented.!
Item was added:
+ ----- Method: ExternalArrayType>>allocateExternal (in category 'external data') -----
+ allocateExternal
+
+ ^ self contentType allocateExternal: self size!
Item was added:
+ ----- Method: ExternalArrayType>>allocateExternal: (in category 'external data') -----
+ allocateExternal: anInteger
+ "No support for n-dimensional containers."
+ self notYetImplemented.!
Item was added:
+ ----- Method: ExternalType>>allocate (in category 'external data') -----
+ allocate
+ "Allocate a single representative for this type."
+
+ referentClass ifNotNil: [
+ "Allocate bytes for the struct."
+ ^ referentClass new].
+
+ self isPointerType ifTrue: [
+ "Allocate bytes for a pointer."
+ ^ ExternalType void asPointerType allocate: 1].
+
+ "Answer an object representing the atomic type."
+ self notYetImplemented.!
Item was changed:
----- Method: ExternalType>>allocate: (in category 'external data') -----
allocate: anInteger
"Allocate space for containing an array of size anInteger of this dataType"
| handle |
+ self
+ assert: [self isPointerType not or: [self isVoid]]
+ description: 'No support for n-dimensional containers. Allocate for void* as workaround.';
+ assert: [self byteSize > 0]
+ description: 'Invalid byte size.'.
+
handle := ByteArray new: self byteSize * anInteger.
^(ExternalData fromHandle: handle type: self) size: anInteger!
Item was added:
+ ----- Method: ExternalType>>allocateExternal (in category 'external data') -----
+ allocateExternal
+ "Allocate a single representative for this type."
+
+ referentClass ifNotNil: [
+ "Allocate bytes for the struct."
+ ^ referentClass externalNew].
+
+ self isPointerType ifTrue: [
+ "Allocate bytes for a pointer."
+ ^ ExternalType void asPointerType allocateExternal: 1].
+
+ "Answer an object representing the atomic type."
+ self notYetImplemented.!
Item was changed:
----- Method: ExternalType>>allocateExternal: (in category 'external data') -----
allocateExternal: anInteger
"Allocate space for containing an array of size anInteger of this dataType"
| handle |
+ self
+ assert: [self isPointerType not or: [self isVoid]]
+ description: 'No support for n-dimensional containers. Allocate for void* as workaround.';
+ assert: [self byteSize > 0]
+ description: 'Invalid byte size.'.
+
handle := ExternalAddress allocate: self byteSize * anInteger.
^(ExternalData fromHandle: handle type: self) size: anInteger!
More information about the Squeak-dev
mailing list
|