62 lines
1.6 KiB
Smalltalk
62 lines
1.6 KiB
Smalltalk
"
|
|
I wrap an owned buffer (which must be freed by the recipient) and a command string. The command string is valid forever and does not need to be freed, as Gomuks will reuse the same string pointers.
|
|
"
|
|
Class {
|
|
#name : 'GmksFFIResponse',
|
|
#superclass : 'FFIStructure',
|
|
#classVars : [
|
|
'OFFSET_BUF',
|
|
'OFFSET_COMMAND'
|
|
],
|
|
#category : 'Gomuks-FFI',
|
|
#package : 'Gomuks',
|
|
#tag : 'FFI'
|
|
}
|
|
|
|
{ #category : 'field definition' }
|
|
GmksFFIResponse class >> fieldsDesc [
|
|
^ #(
|
|
GmksFFIOwnedBuffer buf
|
|
uint8* command
|
|
)
|
|
]
|
|
|
|
{ #category : 'accessing - structure variables' }
|
|
GmksFFIResponse >> buf [
|
|
"This method was automatically generated"
|
|
^ GmksFFIOwnedBuffer fromHandle: (handle referenceStructAt: OFFSET_BUF length: GmksFFIOwnedBuffer byteSize)
|
|
]
|
|
|
|
{ #category : 'accessing - structure variables' }
|
|
GmksFFIResponse >> buf: anObject [
|
|
"This method was automatically generated"
|
|
handle structAt: OFFSET_BUF put: anObject getHandle length: GmksFFIOwnedBuffer byteSize
|
|
]
|
|
|
|
{ #category : 'accessing' }
|
|
GmksFFIResponse >> bufString [
|
|
^ self buf toString
|
|
]
|
|
|
|
{ #category : 'accessing - structure variables' }
|
|
GmksFFIResponse >> command [
|
|
"This method was automatically generated"
|
|
^ExternalData fromHandle: (handle pointerAt: OFFSET_COMMAND) type: ExternalType byte asPointerType
|
|
]
|
|
|
|
{ #category : 'accessing - structure variables' }
|
|
GmksFFIResponse >> command: anObject [
|
|
"This method was automatically generated"
|
|
handle pointerAt: OFFSET_COMMAND put: anObject getHandle.
|
|
]
|
|
|
|
{ #category : 'accessing' }
|
|
GmksFFIResponse >> commandString [
|
|
^ self command bytesFromCString asString
|
|
]
|
|
|
|
{ #category : 'deleting' }
|
|
GmksFFIResponse >> destroy [
|
|
self buf destroy.
|
|
^ nil
|
|
]
|