Skip to content

Commit

Permalink
Merge c19aa31
Browse files Browse the repository at this point in the history
  • Loading branch information
tinchodias committed Sep 15, 2023
2 parents 0aabaf4 + c19aa31 commit ed326d4
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 13 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
# Default value means that a failure in one OS cancels all
fail-fast: false
matrix:
smalltalk: [ Pharo64-11 ]
smalltalk: [ Pharo64-11, Pharo64-12 ]
os: [ ubuntu-latest, macos-latest, windows-latest ]
ston: [ .ci.ston ]
runs-on: ${{ matrix.os }}
Expand Down
15 changes: 3 additions & 12 deletions src/Alexandrie-Base/AeTExternalFree.trait.st
Original file line number Diff line number Diff line change
Expand Up @@ -13,23 +13,13 @@ AeTExternalFree classSide >> externallyFree: aHandle [
]

{ #category : #finalization }
AeTExternalFree classSide >> finalizeResourceData: anObject [
AeTExternalFree classSide >> finalizeResourceData: aHandle [

| aHandle |
aHandle := self resourceDataFrom: anObject.
aHandle isNull ifTrue: [ ^ self ].
self externallyFree: aHandle.
aHandle beNull
]

{ #category : #finalization }
AeTExternalFree classSide >> resourceDataFrom: anObject [
"Answer the handle from the resource data received as parameter.
This is the inverse of the `resourceData` as implemented in instance-side."

^ anObject
]

{ #category : #finalization }
AeTExternalFree >> autoRelease [
"Add to finalization system so GC frees me when there are no more references.
Expand All @@ -47,7 +37,8 @@ AeTExternalFree >> externallyFree [

{ #category : #finalization }
AeTExternalFree >> resourceData [
"Answer an object that doesn't point to self and that is used in `resourceDataFrom:` to obtain the handle at freeing time."
"Answer an object to be received in `finalizeResourceData:` to free external resources.
Such object will be stored in a finalization registry, so shouldn't point directly or indirectly to myself."

^ self getHandle
]
20 changes: 20 additions & 0 deletions src/Alexandrie-FreeType/AeFTFace.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,19 @@ AeFTFace class >> fieldsDesc [
"... we ignore remaining fields"
]

{ #category : #finalization }
AeFTFace class >> finalizeResourceData: anArray [
"Free a face, with an exception: If library was already freed, then all faces were already freed."

| libraryHandle aHandle |
aHandle := anArray first.
libraryHandle := anArray second.
libraryHandle isNull ifFalse: [
aHandle isNull ifTrue: [ ^ self ].
self externallyFree: aHandle ].
aHandle beNull
]

{ #category : #accessing }
AeFTFace >> charHeight: aNumber [
"Request nominal height, taking resolution of 72 dpi."
Expand Down Expand Up @@ -253,6 +266,13 @@ AeFTFace >> printOn: aStream [
self printFaceFlagsOn: aStream
]

{ #category : #finalization }
AeFTFace >> resourceData [
"Answer an object that doesn't point to self and that is used in `resourceDataFrom:` to obtain the handle at freeing time."

^ { self getHandle. library getHandle }
]

{ #category : #'accessing - structure variables' }
AeFTFace >> styleFlags [
"This method was automatically generated"
Expand Down
2 changes: 2 additions & 0 deletions src/Alexandrie-FreeType/AeFTLibrary.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ AeFTLibrary >> newFaceFromBytes: aByteArray index: aZeroBasedIndex [
AeFreeTypeError signalForCode: returnCode ].

^ (AeFTFace fromHandle: aPointer)
library: self;
autoRelease;
yourself
]
Expand All @@ -138,6 +139,7 @@ AeFTLibrary >> newFaceFromFile: aFileReference index: aZeroBasedIndex [
AeFreeTypeError signalForCode: returnCode ].

^ (AeFTFace fromHandle: aPointer)
library: self;
autoRelease;
yourself
]
Expand Down

0 comments on commit ed326d4

Please sign in to comment.