home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1993 #1 / NN_1993_1.iso / spool / comp / sys / next / programm / 7999 < prev    next >
Encoding:
Internet Message Format  |  1993-01-06  |  1.7 KB

  1. Path: sparky!uunet!gatech!usenet.ins.cwru.edu!agate!usenet
  2. From: izumi@pinoko.berkeley.edu (Izumi Ohzawa)
  3. Newsgroups: comp.sys.next.programmer
  4. Subject: Re: Pointers to functions in method definitions
  5. Date: 6 Jan 1993 09:49:24 GMT
  6. Organization: University of California, Berkeley
  7. Lines: 32
  8. Distribution: world
  9. Message-ID: <1ie9v4INNhvl@agate.berkeley.edu>
  10. References: <6164@rosie.NeXT.COM>
  11. Reply-To: izumi@pinoko.berkeley.edu
  12. NNTP-Posting-Host: moica.berkeley.edu
  13.  
  14. In article <6164@rosie.NeXT.COM> sam_s@NeXT.com (Sam Streeper) writes:
  15. >alastair@hecate.phy.queensu.ca (A.B. McLean) writes:
  16. >> I want to write a method that will accept a pointer to a C function.
  17. >
  18. >I would guess that this isn't directly possible; it looks like the Objective-C  
  19. >runtime doesn't have the ability to encode data of type function pointer.
  20.  
  21. In NextDeveloper/Examples/AppKit/Graph/Expression.h, there is an example
  22. that uses typedefs.  It may not cover all situations, but at least
  23. the code can remain comprehensible if you can use it.
  24.  
  25.  
  26. /* function supplied by term implementor for evaluation */
  27. typedef float EXPTermEvalFunc(int numArgs, float *args);
  28.  
  29.  .....
  30.  
  31. - addFuncTerm:(const char *)name minArgs:(int)min maxArgs:(int)max
  32.                     evalFunc:(EXPTermEvalFunc *)func;
  33.  /*
  34.   * Adds a function to the set of functions this Expression can parse.
  35.   * Functions look like "name(arg1, arg2,...)" in the text that is
  36.   * parsed.  At evaluation time the C function func() will be called with
  37.   * the values of the arguments. ....
  38.   */
  39.  
  40.  
  41. --
  42. Izumi Ohzawa             [ $@Bg_78^=;(J ]
  43. USMail: University of California, 360 Minor Hall, Berkeley, CA 94720
  44. Telephone: (510) 642-6440     Fax:  (510) 642-3323
  45. Internet: izumi@pinoko.berkeley.edu (NeXT Mail OK)
  46.