[Pharo-project] FFI number of arguments

Levente Uzonyi leves at elte.hu
Tue Oct 5 22:26:28 EDT 2010

On Tue, 5 Oct 2010, Schwab,Wilhelm K wrote:

> Hello all,
> I have been bumping into some functions with large numbers of arguments.  One in particular would be best handled in the image if at all possible.  The following might be the answer:
>   http://thread.gmane.org/gmane.comp.lang.smalltalk.squeak.general/98538/focus=98543
> Have any of you done this with >15 (or whatever the cutoff is) arguments?

You can create your own function object and invoke it with an array. 
Here's an fprintf example on windows:

fprintf := ExternalLibraryFunction
  	name: 'fprintf'
  	module: 'msvcrt.dll'
  	callType: ExternalFunction callTypeCDecl
  	returnType: ExternalType signedLong
  	argumentTypes: {
  		(ExternalType structTypeNamed: #FILE) asPointerType.
  		ExternalType string.
  		ExternalType signedLong }.
file := Stdio default fopenWith: 'test.txt' with: 'w'.
fprintf invokeWithArguments: { file. 'Your number is %d.'. 42 }.
Stdio default fcloseWith: file.


P.S.: Note that you need the FILE and Stdio classes to run this example.

> Bill
> _______________________________________________
> Pharo-project mailing list
> Pharo-project at lists.gforge.inria.fr
> http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project

More information about the Pharo-dev mailing list