FFI: FFI-Kernel-mt.111.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.111.mcz

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

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

Name: FFI-Kernel-mt.111
Author: mt
Time: 17 June 2020, 7:56:43.540384 pm
UUID: 4421e4eb-4ac9-5f4b-9fcc-64c57a034587
Ancestors: FFI-Kernel-mt.110

Adds a simple interface to use ExternalData as representative of an external global/shared variable.

(We could add an extra subclass to make it more clear. Like ExternalTypeAlias.)

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

Item was added:
+ ----- Method: ExternalData>>value (in category 'accessing - external globals') -----
+ value
+ "For convenience. Assume that the external data is just one global variable. Answer the value of that global variable."
+
+ ^ self at: 1!

Item was added:
+ ----- Method: ExternalData>>value: (in category 'accessing - external globals') -----
+ value: aValue
+ "For convenience. Assume that the external data is just one global variable. Set the value of that global variable."
+
+ self at: 1 put: aValue.!

Item was changed:
  ----- Method: ExternalType class>>c_ulong (in category 'type constants - extra') -----
  c_ulong
  "Try to approximate a fitting type for 'usigned long' in a C interface. See comment in #c_long."
 
+ ^ self c_long asUnsigned!
- ^ self typeNamed: 'u', self c_long atomicTypeName!

Item was added:
+ ----- Method: ExternalType>>asSigned (in category 'converting') -----
+ asSigned
+
+ self isSigned ifTrue: [^ self].
+ ^ AtomicTypes at: (AtomicTypeNames at: self atomicType + 1)!

Item was added:
+ ----- Method: ExternalType>>asUnsigned (in category 'converting') -----
+ asUnsigned
+
+ self isUnsigned ifTrue: [^ self].
+ ^ AtomicTypes at: (AtomicTypeNames at: self atomicType - 1)!

Item was added:
+ ----- Method: ExternalType>>checkIntegerType (in category 'private') -----
+ checkIntegerType
+
+ self isIntegerType
+ ifFalse: [self error: 'Test is only defined on integer types!!'].!

Item was changed:
  ----- Method: ExternalType>>isIntegerType (in category 'testing') -----
  isIntegerType
  "Return true if the receiver is a built-in integer type"
  | type |
  type := self atomicType.
+ ^type > FFITypeBool and:[type <= FFITypeSignedChar]!
- ^type > FFITypeBool and:[type <= FFITypeUnsignedLongLong]!

Item was changed:
  ----- Method: ExternalType>>isSigned (in category 'testing') -----
  isSigned
+ "Return true if the receiver is a signed integer type."
+
+ self checkIntegerType.
- "Return true if the receiver is a signed type.
- Note: Only useful for integer types."
  ^self atomicType anyMask: 1!

Item was changed:
  ----- Method: ExternalType>>isUnsigned (in category 'testing') -----
  isUnsigned
+ "Return true if the receiver is an unsigned integer type."
+
+ self checkIntegerType.
- "Return true if the receiver is an unsigned type.
- Note: Only useful for integer types."
  ^self isSigned not!