[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
deffcfun & MathLink
- To: info-mcl-digest@digitool.com
- Subject: deffcfun & MathLink
- From: clefort@unix1.sncc.lsu.edu (Clinton R Lefort)
- Date: Thu, 8 Dec 1994 01:48:49 -0600
- Sender: owner-info-mcl@digitool.com
Hello,
Below I have both the MCL code and the C code in which I am trying to complete a foreign function call (thru MPW-which the MCL doc' says this allows me to use the deffcfun in the format of a high-level function call). At present I am baffled, because I am not sure Ishould call both arguments of MLPutSymbol(MLLink, ml_charp) or just one. ;;below is the prototype as writen in the MathLInk header files writtenin ANSI C;;; . Could someone lend me a hand with this--that is someone who isfamiliar with deffcfun.
Thanks
CRL
P.S. Please feel free to respond to me personally.
;;;deffcfun (lisp-name entry-name {option}*) ({argspec}*) {result-flag}*;;;;;;;
(deffcfun ml-put-symbol "MLPutSymbol") (int ) :long)
;;;;; extern int MLAPI MLPutSymbol P(( MLINK, ml_charp));;;;
;;;;; the prototype of MLPutSymbol ;;;;
;;;;; typedef char FAR * ml_charp ;;;the typedef of ml_charp
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(deffcfun (digit-value "digitval") (character) :long)
(deffcfun (setchar "setchar") ((string :by-reference) fixnum character)
:novalue)
(deffcfun (flt-incr "flt_incr")
((float :double :by-reference)
(float :extended))
:novalue)
*/
/* Examples of the Macintosh Common Lisp Foreign Function Interface, */
/* C component. */
#include <ctype.h>
#include <memory.h>
#include "mathlink.h" ;mathlink headers
#include <stdio.h>
int main(argc,argv) ;main arguments
int argc;
char *argv[];
{
MLINK alink; ;declare a link variable
char *response;
alink = MLOpen(argc,argv); ; open a link
if(alink == NULL) return 1;
MLPutSymbol(alink, "$Version"); ;put data on the link
MLEndPacket(alink); ; terminate link after the last
; packet is thru
while (MLNextPacket9alink) != RETURNPKT); ;check incoming expressions
MLNewPacket(alink);
if (MLGetType(alink) == MLKSTR) { ;check the type of the
;current data element
MLGetString(alink, &response); ;Get data from the link
printf( "%s\n", response);
} else{
printf("Error--output is not a string. \n");
}
MLPutFunction(alink, "Exit, 0);
MLEndPacket(alink);
MLClose(alink); ; Close the link
return 0;
addtwo (i , j)
int i;
int j;
{
return i+j;
}
{ return MLMain(argc,argv);
}
plus_one (i)
int i;
{
return i+1;
}
;;;;;;;;;;;;;;;;;;;;;;
(defcfun)
Thanks
Clint
*****************
****** *************
******** ****************************
******************
*************
****** ***************