[squeak-dev] FFI: FFI-Kernel-mt.119.mcz

commits at source.squeak.org commits at source.squeak.org
Tue Jul 28 11:34:04 UTC 2020


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

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

Name: FFI-Kernel-mt.119
Author: mt
Time: 28 July 2020, 1:34:03.494011 pm
UUID: ad1bfdeb-3a7f-bb49-a61d-199918835891
Ancestors: FFI-Kernel-nice.118

Adds parser hook for callback pragmas. Simplifies loading of FFI-Callback.

=============== Diff against FFI-Kernel-nice.118 ===============

Item was added:
+ ----- Method: Parser>>callback (in category '*FFI-Kernel') -----
+ callback
+ 	<pragmaParser>
+ 	
+ 	| descriptorClass retType externalName args argType |
+ 	descriptorClass := ExternalFunction.
+ 	"Parse return type"
+ 	self advance.
+ 	here = 'const' ifTrue: [self advance].
+ 	retType := self externalType: descriptorClass.
+ 	retType == nil ifTrue:[^self expected:'return type'].
+ 	"Parse function name or index"
+ 	externalName := here.
+ 
+ 	(self match: #leftParenthesis) ifFalse:[^self expected:'function pointer (*)'].
+ 	(self matchToken: #*) ifFalse:[^self expected:'function pointer (*)'].
+ 	(self match: #rightParenthesis) ifFalse:[^self expected:'function pointer (*)'].
+ 
+ 	(self match: #leftParenthesis) ifFalse:[^self expected:'argument list'].
+ 	args := WriteStream on: Array new.
+ 	[self match: #rightParenthesis] whileFalse:[
+ 		here = 'const' ifTrue: [self advance].
+ 		here = ',' ifTrue: [self advance].
+ 		argType := self externalType: descriptorClass.
+ 		argType == nil ifTrue:[^self expected:'argument'].
+ 		argType isVoid & argType isPointerType not ifFalse:[args nextPut: argType]].
+ 
+ 	self addPragma: (Pragma keyword: #callback: arguments: {{retType}, args contents}).
+ 	^true!



More information about the Squeak-dev mailing list