FFI: FFI-MacOS-mt.7.mcz

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

FFI: FFI-MacOS-mt.7.mcz

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

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

Name: FFI-MacOS-mt.7
Author: mt
Time: 27 May 2021, 9:38:37.994843 am
UUID: c98e6ccf-2976-e641-9e41-5677a927e82c
Ancestors: FFI-MacOS-mt.6

Empty commit. Package superseded by "FFI-Libraries"

=============== Diff against FFI-MacOS-mt.6 ===============

Item was removed:
- SystemOrganization addCategory: #'FFI-MacOS-Examples'!

Item was removed:
- ExternalObject subclass: #MacOSShell
- instanceVariableNames: ''
- classVariableNames: ''
- poolDictionaries: ''
- category: 'FFI-MacOS-Examples'!
-
- !MacOSShell commentStamp: 'spd 5/16/2010 22:33' prior: 0!
- I show how system functions can be called from within the image.
-
- WARNING: Under Snow Leopard, the VM (as of 4.2.4 beta) only searches its Resources folder for external libraries.
-
- See http://wiki.squeak.org/squeak/5846 for workarounds.!

Item was removed:
- ----- Method: MacOSShell class>>escapeFileName: (in category 'utilities') -----
- escapeFileName: aFileName
-
- "Try to make the argument suitable for use in 'system'.  
- Just the simple stuff - backlash-prefix for obvious problems - quotes and white space."
-
- ^ String streamContents: [ : stream |
- aFileName do: [ : char |
- ('''" ()[]{}$&' includes: char) ifTrue: [
- stream nextPut: $\
- ].
- stream nextPut: char.
- ]].!

Item was removed:
- ----- Method: MacOSShell>>getenv: (in category 'basics') -----
- getenv: aString
- <apicall: char* 'getenv' (char*) module: 'libSystem.dylib'>
- self externalCallFailed!

Item was removed:
- ----- Method: MacOSShell>>system: (in category 'basics') -----
- system: aString
- "Note that the command will foreground-block the VM unless it ends with &"
- <apicall: long 'system' (char*) module: 'libSystem.dylib'>
- self externalCallFailed.!

Item was removed:
- ExternalStructure subclass: #MacPixPatPtr
- instanceVariableNames: ''
- classVariableNames: ''
- poolDictionaries: ''
- category: 'FFI-MacOS-Examples'!
-
- !MacPixPatPtr commentStamp: 'spd 5/16/2010 22:32' prior: 0!
- See class comment for MacRect.!

Item was removed:
- ----- Method: MacPixPatPtr class>>fields (in category 'field definition') -----
- fields
- "MacPixPatPtr defineFields"
- "The following really means
- typedef void* MacPixPatPtr;
- "
- ^#(nil 'void*') "For now this is just an opaque handle"!

Item was removed:
- ----- Method: MacPixPatPtr class>>newPixPat (in category 'instance creation') -----
- newPixPat
- <apicall: MacPixPatPtr* 'NewPixPat' (void) module:'ApplicationServices'>
- ^self externalCallFailed!

Item was removed:
- ----- Method: MacPixPatPtr>>apiDisposePixPat: (in category 'api calls') -----
- apiDisposePixPat: aPixPat
- <apicall: void 'DisposePixPat' (MacPixPatPtr*) module:'ApplicationServices'>
- ^self externalCallFailed!

Item was removed:
- ----- Method: MacPixPatPtr>>apiMakeRGBPat:with: (in category 'api calls') -----
- apiMakeRGBPat: aPixPat with: aRGBColor
- <apicall: void 'MakeRGBPat' (MacPixPatPtr* MacRGBColor*) module: 'ApplicationServices'>
- ^self externalCallFailed!

Item was removed:
- ----- Method: MacPixPatPtr>>dispose (in category 'initialize-release') -----
- dispose
- handle == nil ifFalse:[
- self apiDisposePixPat: self.
- handle := nil.
- ].!

Item was removed:
- ----- Method: MacPixPatPtr>>makeRGBPattern: (in category 'accessing') -----
- makeRGBPattern: aColor
- ^self apiMakeRGBPat: self with: (MacRGBColor fromColor: aColor)!

Item was removed:
- ExternalStructure subclass: #MacPoint
- instanceVariableNames: ''
- classVariableNames: ''
- poolDictionaries: ''
- category: 'FFI-MacOS-Examples'!
-
- !MacPoint commentStamp: 'spd 5/16/2010 22:32' prior: 0!
- See class comment for MacRect.!

Item was removed:
- ----- Method: MacPoint class>>apiLineTo:with: (in category 'api calls') -----
- apiLineTo: x with: y
- <apicall: void 'LineTo' (short short) module:'ApplicationServices'>
- ^self externalCallFailed!

Item was removed:
- ----- Method: MacPoint class>>apiMoveTo:with: (in category 'api calls') -----
- apiMoveTo: x with: y
- <apicall: void 'MoveTo' (short short) module:'ApplicationServices'>
- ^self externalCallFailed!

Item was removed:
- ----- Method: MacPoint class>>fields (in category 'field definition') -----
- fields
- "MacPoint defineFields"
- ^#(
- (v 'short')
- (h 'short')
- )!

Item was removed:
- ----- Method: MacPoint class>>lineTo: (in category 'examples') -----
- lineTo: aPoint
- "MacPoint moveTo: 0@0; lineTo: 100@100"
- ^self apiLineTo: aPoint x with: aPoint y
- !

Item was removed:
- ----- Method: MacPoint class>>macDraw (in category 'examples') -----
- macDraw
- "MacPoint macDraw"
- | pt |
- pt := self new.
- pt getMousePoint.
- self moveTo: pt.
- [Sensor anyButtonPressed] whileFalse:[
- pt getMousePoint.
- self lineTo: pt.
- ].
- Display forceToScreen.!

Item was removed:
- ----- Method: MacPoint class>>moveTo: (in category 'examples') -----
- moveTo: aPoint
- "MacPoint moveTo: 0@0; lineTo: 100@100"
- ^self apiMoveTo: aPoint x with: aPoint y
- !

Item was removed:
- ----- Method: MacPoint>>apiGetMousePoint: (in category 'api calls') -----
- apiGetMousePoint: aMacPoint
- <apicall: void 'GetMouse' (MacPoint*) module:'Carbon.framework'>
- ^self externalCallFailed!

Item was removed:
- ----- Method: MacPoint>>getMousePoint (in category 'accessing') -----
- getMousePoint
- ^self apiGetMousePoint: self!

Item was removed:
- ----- Method: MacPoint>>h (in category 'accessing') -----
- h
- "This method was automatically generated. See MacPoint class>>fields."
- <generated>
- ^handle signedShortAt: 3!

Item was removed:
- ----- Method: MacPoint>>h: (in category 'accessing') -----
- h: anInteger
- "This method was automatically generated. See MacPoint class>>fields."
- <generated>
- handle signedShortAt: 3 put: anInteger!

Item was removed:
- ----- Method: MacPoint>>v (in category 'accessing') -----
- v
- "This method was automatically generated. See MacPoint class>>fields."
- <generated>
- ^handle signedShortAt: 1!

Item was removed:
- ----- Method: MacPoint>>v: (in category 'accessing') -----
- v: anInteger
- "This method was automatically generated. See MacPoint class>>fields."
- <generated>
- handle signedShortAt: 1 put: anInteger!

Item was removed:
- ----- Method: MacPoint>>x (in category 'accessing') -----
- x
- ^self h!

Item was removed:
- ----- Method: MacPoint>>x: (in category 'accessing') -----
- x: anObject
- ^self h: anObject!

Item was removed:
- ----- Method: MacPoint>>y (in category 'accessing') -----
- y
- ^self v!

Item was removed:
- ----- Method: MacPoint>>y: (in category 'accessing') -----
- y: anObject
- ^self v: anObject!

Item was removed:
- ExternalStructure subclass: #MacRGBColor
- instanceVariableNames: ''
- classVariableNames: ''
- poolDictionaries: ''
- category: 'FFI-MacOS-Examples'!
-
- !MacRGBColor commentStamp: 'spd 5/16/2010 22:31' prior: 0!
- See class comment for MacRect.!

Item was removed:
- ----- Method: MacRGBColor class>>fields (in category 'field definition') -----
- fields
- "MacRGBColor defineFields"
- ^#(
- (red 'ushort')
- (green 'ushort')
- (blue 'ushort')
- )!

Item was removed:
- ----- Method: MacRGBColor class>>fromColor: (in category 'instance creation') -----
- fromColor: aColor
- ^(self new)
- red: (aColor red * 16rFFFF) rounded;
- green: (aColor green * 16rFFFF) rounded;
- blue: (aColor blue * 16rFFFF) rounded;
- yourself!

Item was removed:
- ----- Method: MacRGBColor>>blue (in category 'accessing') -----
- blue
- "This method was automatically generated. See MacRGBColor class>>fields."
- <generated>
- ^handle unsignedShortAt: 5!

Item was removed:
- ----- Method: MacRGBColor>>blue: (in category 'accessing') -----
- blue: anInteger
- "This method was automatically generated. See MacRGBColor class>>fields."
- <generated>
- handle unsignedShortAt: 5 put: anInteger!

Item was removed:
- ----- Method: MacRGBColor>>green (in category 'accessing') -----
- green
- "This method was automatically generated. See MacRGBColor class>>fields."
- <generated>
- ^handle unsignedShortAt: 3!

Item was removed:
- ----- Method: MacRGBColor>>green: (in category 'accessing') -----
- green: anInteger
- "This method was automatically generated. See MacRGBColor class>>fields."
- <generated>
- handle unsignedShortAt: 3 put: anInteger!

Item was removed:
- ----- Method: MacRGBColor>>red (in category 'accessing') -----
- red
- "This method was automatically generated. See MacRGBColor class>>fields."
- <generated>
- ^handle unsignedShortAt: 1!

Item was removed:
- ----- Method: MacRGBColor>>red: (in category 'accessing') -----
- red: anInteger
- "This method was automatically generated. See MacRGBColor class>>fields."
- <generated>
- handle unsignedShortAt: 1 put: anInteger!

Item was removed:
- ExternalStructure subclass: #MacRect
- instanceVariableNames: ''
- classVariableNames: ''
- poolDictionaries: ''
- category: 'FFI-MacOS-Examples'!
-
- !MacRect commentStamp: 'spd 5/16/2010 22:42' prior: 0!
- I, with my friends (MacPixPatPtr, MacPoint and MacRGBColor), show how to make calls into a Mac OS framework.
-
- The particular library I use in my examples, QuickDraw, is depreciated in OS X 10.4, but the examples still run as of OS X 10.6.2
- See http://developer.apple.com/legacy/mac/library/documentation/Carbon/Reference/QuickDraw_Ref/Reference/reference.html for more information.
-
- WARNING: for Snow Leopard, see warning in MacOSShell!

Item was removed:
- ----- Method: MacRect class>>apiFillCOval:with: (in category 'api calls') -----
- apiFillCOval: r with: pat
- <apicall: void 'FillCOval' (MacRect* MacPixPatPtr*) module:'ApplicationServices'>
- ^self externalCallFailed!

Item was removed:
- ----- Method: MacRect class>>apiFillCRect:with: (in category 'api calls') -----
- apiFillCRect: r with: pat
- <apicall: void 'FillCRect' (MacRect* MacPixPatPtr*) module:'ApplicationServices'>
- ^self externalCallFailed!

Item was removed:
- ----- Method: MacRect class>>apiFrameOval: (in category 'api calls') -----
- apiFrameOval: r
- <apicall: void 'FrameOval' (MacRect*) module:'ApplicationServices'>
- ^self externalCallFailed!

Item was removed:
- ----- Method: MacRect class>>apiFrameRect: (in category 'api calls') -----
- apiFrameRect: r
- <apicall: void 'FrameRect' (MacRect*) module:'ApplicationServices'>
- ^self externalCallFailed!

Item was removed:
- ----- Method: MacRect class>>coloredEllipses (in category 'examples') -----
- coloredEllipses "MacRect coloredEllipses"
- | rnd w h colors n r pat v0 v1 |
- colors := Color colorNames collect:[:cName| (Color perform: cName)].
- "convert to PixPats"
- colors := colors collect:[:c| MacPixPatPtr newPixPat makeRGBPattern: c].
- rnd := Random new.
- w := Display width.
- h := Display height.
- n := 0.
- r := MacRect new.
- [Sensor anyButtonPressed] whileFalse:[
- pat := colors atRandom.
- v0 := (rnd next * w) asInteger.
- v1 := (rnd next * w) asInteger.
- v0 < v1 ifTrue:[r left: v0; right: v1] ifFalse:[r left: v1; right: v0].
- v0 := (rnd next * h) asInteger.
- v1 := (rnd next * h) asInteger.
- v0 < v1 ifTrue:[r top: v0; bottom: v1] ifFalse:[r top: v1; bottom: v0].
- self apiFillCOval: r with: pat.
- self apiFrameOval: r.
- n := n + 1.
- (n \\ 10) = 0 ifTrue:[n printString displayAt: 0@0].
- ].
- colors do:[:c| c dispose].
- Display forceToScreen.!

Item was removed:
- ----- Method: MacRect class>>coloredRectangles (in category 'examples') -----
- coloredRectangles "MacRect coloredRectangles"
- | rnd w h colors n r pat v0 v1 nPixels time |
- colors := Color colorNames collect:[:cName| (Color perform: cName)].
- "convert to PixPats"
- colors := colors collect:[:c| MacPixPatPtr newPixPat makeRGBPattern: c].
- rnd := Random new.
- w := Display width.
- h := Display height.
- n := 0.
- r := MacRect new.
- nPixels := 0.
- time := Time millisecondClockValue.
- [Sensor anyButtonPressed] whileFalse:[
- pat := colors atRandom.
- v0 := (rnd next * w) asInteger.
- v1 := (rnd next * w) asInteger.
- v0 < v1 ifTrue:[r left: v0; right: v1] ifFalse:[r left: v1; right: v0].
- v0 := (rnd next * h) asInteger.
- v1 := (rnd next * h) asInteger.
- v0 < v1 ifTrue:[r top: v0; bottom: v1] ifFalse:[r top: v1; bottom: v0].
- self apiFillCRect: r with: pat.
- self apiFrameRect: r.
- n := n + 1.
- nPixels := nPixels + ((r right - r left) * (r bottom - r top)).
- (n \\ 100) = 0 ifTrue:[
- 'Pixel fillRate: ', (nPixels * 1000 // (Time millisecondClockValue - time))
- asStringWithCommas displayAt: 0@0].
- ].
- colors do:[:c| c dispose].
- Display forceToScreen.!

Item was removed:
- ----- Method: MacRect class>>fields (in category 'field definition') -----
- fields
- "MacRect defineFields"
- ^#(
- (top 'short')
- (left 'short')
- (bottom 'short')
- (right 'short')
- )!

Item was removed:
- ----- Method: MacRect class>>macDraw (in category 'examples') -----
- macDraw
- "MacRect macDraw"
- ^MacPoint macDraw!

Item was removed:
- ----- Method: MacRect>>bottom (in category 'accessing') -----
- bottom
- "This method was automatically generated. See MacRect class>>fields."
- <generated>
- ^handle signedShortAt: 5!

Item was removed:
- ----- Method: MacRect>>bottom: (in category 'accessing') -----
- bottom: anInteger
- "This method was automatically generated. See MacRect class>>fields."
- <generated>
- handle signedShortAt: 5 put: anInteger!

Item was removed:
- ----- Method: MacRect>>left (in category 'accessing') -----
- left
- "This method was automatically generated. See MacRect class>>fields."
- <generated>
- ^handle signedShortAt: 3!

Item was removed:
- ----- Method: MacRect>>left: (in category 'accessing') -----
- left: anInteger
- "This method was automatically generated. See MacRect class>>fields."
- <generated>
- handle signedShortAt: 3 put: anInteger!

Item was removed:
- ----- Method: MacRect>>right (in category 'accessing') -----
- right
- "This method was automatically generated. See MacRect class>>fields."
- <generated>
- ^handle signedShortAt: 7!

Item was removed:
- ----- Method: MacRect>>right: (in category 'accessing') -----
- right: anInteger
- "This method was automatically generated. See MacRect class>>fields."
- <generated>
- handle signedShortAt: 7 put: anInteger!

Item was removed:
- ----- Method: MacRect>>top (in category 'accessing') -----
- top
- "This method was automatically generated. See MacRect class>>fields."
- <generated>
- ^handle signedShortAt: 1!

Item was removed:
- ----- Method: MacRect>>top: (in category 'accessing') -----
- top: anInteger
- "This method was automatically generated. See MacRect class>>fields."
- <generated>
- handle signedShortAt: 1 put: anInteger!