[squeak-dev] FFI: FFI-Tools-mt.29.mcz
commits at source.squeak.org
commits at source.squeak.org
Fri May 7 09:55:56 UTC 2021
Marcel Taeumel uploaded a new version of FFI-Tools to project FFI:
http://source.squeak.org/FFI/FFI-Tools-mt.29.mcz
==================== Summary ====================
Name: FFI-Tools-mt.29
Author: mt
Time: 7 May 2021, 11:55:55.901725 am
UUID: 80be7cad-4657-4446-b564-15c92683b1b9
Ancestors: FFI-Tools-mt.28
Complements FFI-Kernel-mt.139 and FFI-Kernel-mt.140.
=============== Diff against FFI-Tools-mt.28 ===============
Item was changed:
----- Method: ExternalData>>explorerContentsStructFields (in category '*FFI-Tools') -----
explorerContentsStructFields
"In case some data interpretation omitted to convert char*, which is a (null-terminated) C string, to Smalltalk string."
size notNil ifTrue: [
^ self withIndexCollect: [:each :index |
ObjectExplorerWrapper
with: each
name: index printString
model: self]].
+ ^ (ExternalStructureInspector readCStrings and: [self mightBeCString]) ifFalse: [#()] ifTrue: [
- ^ (self isNull not and: [self containerType = ExternalType string]) ifFalse: [#()] ifTrue: [
{ObjectExplorerWrapper
+ with: ([self fromCString] ifError: [:msg | '<', msg, '>'])
- with: self fromCString
name: 'as C string'
model: self}]!
Item was changed:
----- Method: ExternalData>>hasContentsInExplorer (in category '*FFI-Tools') -----
hasContentsInExplorer
^ super hasContentsInExplorer
+ or: [size notNil or: [ExternalStructureInspector readCStrings and: [self mightBeCString]]]!
- or: [self isNull not and: [self containerType = ExternalType string]]!
Item was changed:
----- Method: ExternalStructure>>explorerOkToClose (in category '*FFI-Tools') -----
explorerOkToClose
"We are being explored and that explorer wants to close. If we point to external memory, ask the user whether we should free it to avoid leaks."
+ | byteSize |
(handle isExternalAddress and: [handle isNull not]) ifTrue: [
(Project uiManager
confirm: ('There are <b>{1}</b> bytes addressed.<br>Do you want to <b>free</b> the allocated memory?'
translated format: {
+ (byteSize := self externalType byteSize) > 0
+ ifTrue: [byteSize] ifFalse: ['an unknown number of']. }) asTextFromHtml
- [self byteSize] ifError: ['an unknown number of']. }) asTextFromHtml
orCancel: [^ false]
title: 'External Address Detected' translated)
ifTrue: [self free]].
^ true!
Item was changed:
Inspector subclass: #ExternalStructureInspector
instanceVariableNames: ''
+ classVariableNames: 'ReadCStrings'
- classVariableNames: ''
poolDictionaries: ''
category: 'FFI-Tools'!
Item was added:
+ ----- Method: ExternalStructureInspector class>>readCStrings (in category 'preferences') -----
+ readCStrings
+ <preference: 'Read C strings'
+ categoryList: #('FFI Tools')
+ description: 'When true, reads for the type char* will automatically continue to read the memory up to the NUL character and answer a Smalltalk string. CAN BE DANGEROUS!! ... but convenient in explorers and inspector tools.'
+ type: #Boolean>
+ ^ReadCStrings ifNil:[false]!
Item was added:
+ ----- Method: ExternalStructureInspector class>>readCStrings: (in category 'preferences') -----
+ readCStrings: aBoolean
+
+ ReadCStrings := aBoolean.!
More information about the Squeak-dev
mailing list
|