🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.sys.next.programmer
Article #2195

Re: Pointers to functions in method definitions

#2195
From: Izumi Ohzawa
Date: Wed, 06 Jan 1993 09:49
32 lines
1772 bytes
In article <6164@rosie.NeXT.COM> sam_s@NeXT.com (Sam Streeper) writes:
>alastair@hecate.phy.queensu.ca (A.B. McLean) writes:
>> I want to write a method that will accept a pointer to a C function.
>
>I would guess that this isn't directly possible; it looks like the Objective-C  
>runtime doesn't have the ability to encode data of type function pointer.

In NextDeveloper/Examples/AppKit/Graph/Expression.h, there is an example
that uses typedefs.  It may not cover all situations, but at least
the code can remain comprehensible if you can use it.


/* function supplied by term implementor for evaluation */
typedef float EXPTermEvalFunc(int numArgs, float *args);

 .....

- addFuncTerm:(const char *)name minArgs:(int)min maxArgs:(int)max
					evalFunc:(EXPTermEvalFunc *)func;
 /*
  * Adds a function to the set of functions this Expression can parse.
  * Functions look like "name(arg1, arg2,...)" in the text that is
  * parsed.  At evaluation time the C function func() will be called with
  * the values of the arguments. ....
  */


--
Izumi Ohzawa             [ $@Bg_78^=;(J ]
USMail: University of California, 360 Minor Hall, Berkeley, CA 94720
Telephone: (510) 642-6440     Fax:  (510) 642-3323
Internet: izumi@pinoko.berkeley.edu (NeXT Mail OK)
Technical Details
Message-ID: <1ie9v4INNhvl@agate.berkeley.edu>
Path: arc1-ca.pugleaf.net!sparky!uunet!gatech!usenet.ins.cwru.edu!agate!usenet
References: <6164@rosie.NeXT.COM>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!sparky!uunet!gatech!usenet.ins.cwru.edu!agate!usenet
From: izumi@pinoko.berkeley.edu (Izumi Ohzawa)
Newsgroups: comp.sys.next.programmer
Subject: Re: Pointers to functions in method definitions
Date: 6 Jan 1993 09:49:24 GMT
Organization: University of California, Berkeley
Lines: 32
Distribution: world
Message-ID: <1ie9v4INNhvl@agate.berkeley.edu>
References: <6164@rosie.NeXT.COM>
Reply-To: izumi@pinoko.berkeley.edu
NNTP-Posting-Host: moica.berkeley.edu