63 lines
1.6 KiB
Smalltalk
63 lines
1.6 KiB
Smalltalk
"
|
|
I am a byte array whose ownership is transferred to the recipient.
|
|
The recipient MUST free me using #destroy when done.
|
|
"
|
|
Class {
|
|
#name : 'GmksFFIOwnedBuffer',
|
|
#superclass : 'FFIStructure',
|
|
#classVars : [
|
|
'OFFSET_BASE',
|
|
'OFFSET_LENGTH'
|
|
],
|
|
#category : 'Gomuks-FFI',
|
|
#package : 'Gomuks',
|
|
#tag : 'FFI'
|
|
}
|
|
|
|
{ #category : 'field definition' }
|
|
GmksFFIOwnedBuffer class >> fieldsDesc [
|
|
^ #(
|
|
uint8* base
|
|
size_t length
|
|
)
|
|
]
|
|
|
|
{ #category : 'accessing - structure variables' }
|
|
GmksFFIOwnedBuffer >> base [
|
|
"This method was automatically generated"
|
|
^ExternalData fromHandle: (handle pointerAt: OFFSET_BASE) type: ExternalType byte asPointerType
|
|
]
|
|
|
|
{ #category : 'accessing - structure variables' }
|
|
GmksFFIOwnedBuffer >> base: anObject [
|
|
"This method was automatically generated"
|
|
handle pointerAt: OFFSET_BASE put: anObject getHandle.
|
|
]
|
|
|
|
{ #category : 'operations' }
|
|
GmksFFIOwnedBuffer >> destroy [
|
|
self primGomuksFreeBuffer: self.
|
|
^ nil
|
|
]
|
|
|
|
{ #category : 'accessing - structure variables' }
|
|
GmksFFIOwnedBuffer >> length [
|
|
"This method was automatically generated"
|
|
^handle platformSizeTAt: OFFSET_LENGTH
|
|
]
|
|
|
|
{ #category : 'accessing - structure variables' }
|
|
GmksFFIOwnedBuffer >> length: anObject [
|
|
"This method was automatically generated"
|
|
^handle platformSizeTAt: OFFSET_LENGTH put: anObject
|
|
]
|
|
|
|
{ #category : 'private - primitives' }
|
|
GmksFFIOwnedBuffer >> primGomuksFreeBuffer: buf [
|
|
^ self ffiCall: #( void GomuksFreeBuffer(GmksFFIOwnedBuffer buf) ) library: GmksFFILibrary
|
|
]
|
|
|
|
{ #category : 'printing' }
|
|
GmksFFIOwnedBuffer >> toString [
|
|
^ (self base copyFrom: 1 to: self length) asString
|
|
]
|