From: ········@my-deja.com
Subject: Going Bald Due to Franz Documentation
Date:
Message-ID: <8fh4aa$9p$1@nnrp1.deja.com>
I am starting to pull my hair out with the Franz Foreign Function
Interface/ Foreign Types documentation.
For example, the foreign types documentation section 10.0 states that
you can create a pointer to an integer, then set/get the value of what
it points to by
doing:
USER(270): (setq x (ff:allocate-fobject '(* :int)))
#(#(25625354 T 901 NIL NIL 4 NIL) 0)
[8c] USER(271): (setf (ff:fslot-value-typed '(* :int) nil x) 1321231)
1321231
(I'm not sure why you'd set the address.. seems to me you'd just want to
get the address)
USER(272): (setf (ff:fslot-value-typed '(* :int) nil x '*) 1231)
Error: Received signal number 11 (Segmentation violation)
[condition type: SYNCHRONOUS-OPERATING-SYSTEM-SIGNAL]
OR...
(setf (ff:fslot-value x '*) 1231)
Error: No methods applicable for generic function
#<STANDARD-GENERIC-FUNCTION FOREIGN-FUNCTIONS::IFOREIGN-TYPE>
with args
(NIL) of classes (NULL)
(can't set what x points to by using rules shown in documentation).
Anybody who knows how to resolve this disconnect in the documentation
and what I am doing please help!!
Dave Linenberg
Sent via Deja.com http://www.deja.com/
Before you buy.
From: Joe Marshall
Subject: Re: Going Bald Due to Franz Documentation
Date:
Message-ID: <r9b7ke1o.fsf@alum.mit.edu>
········@my-deja.com writes:
> I am starting to pull my hair out with the Franz Foreign Function
> Interface/ Foreign Types documentation.
What are you trying to accomplish? I don't think that allocating
pointers to integers and dereferencing them at random is going to get
you too far.
~jrm
From: ········@my-deja.com
Subject: Re: Going Bald Due to Franz Documentation
Date:
Message-ID: <8fhql3$p2q$1@nnrp1.deja.com>
I simply can NOT get the documented de-referencing syntax to work and
was just trying to repeat the Franz documented example.
Dave Linenberg
Sent via Deja.com http://www.deja.com/
Before you buy.
From: Joe Marshall
Subject: Re: Going Bald Due to Franz Documentation
Date:
Message-ID: <og6beah9.fsf@alum.mit.edu>
········@my-deja.com writes:
> I simply can NOT get the documented de-referencing syntax to work and
> was just trying to repeat the Franz documented example.
Yes. The Franz Documentation *is* confusing. However, I regularly
write calls to foreign functions, so if you can offer a concrete
example of what you want to do, perhaps I can give a little advice.
From: dave linenberg
Subject: Re: Going Bald Due to Franz Documentation
Date:
Message-ID: <391C8F92.3781F4A7@home.com>
Joe Marshall wrote:
>Yes. The Franz Documentation *is* confusing. However, I regularly
>write calls to foreign functions, so if you can offer a concrete
>example of what you want to do, perhaps I can give a little advice.
Thanks, Joe. I finally *did* manage to get the toy example/ syntax to
work. Here it is:
// ---- c code which defines & allocates members of a structure
typedef struct {
double* x;
double* y;
} structPoint;
void allocatepoint(structPoint* point)
{
point->x = (double*)malloc(sizeof(double));
point->y = (double*)malloc(sizeof(double));
*(point->x) = 3.1415926;
*(point->y) = 1.23456;
}
..... deallocatepoint etc...
;; and the associated lisp.......
(ff:def-foreign-type point
(:struct
(x (* :double))
(y (* :double ))))
[1] USER(63): #<FOREIGN-FUNCTIONS::FOREIGN-STRUCTURE POINT>
[1] USER(64): (setq point-1 (ff:allocate-fobject 'point))
#<foreign object of class POINT>
[1] USER(65): (ff:def-foreign-call allocatepoint ((in point)))
ALLOCATEPOINT
[1] USER(66): (allocatepoint point-1)
541117616
[1] USER(67): (ff:fslot-value-typed 'point nil point-1 :x)
134543344
[1] USER(68): (ff:fslot-value-typed 'point nil point-1 :x '*)
3.1415926d0 ;; yeah!!, finally got the allocation
syntax to work!!!
[1] USER(69): (ff:fslot-value-typed 'point nil point-1 :y)
134543360
[1] USER(70): (ff:fslot-value-typed 'point nil point-1 :y '*)
1.23456d0 ;; y is properly assigned as well...
If Franz put a number of small, complete, toy code example like the above
in their documentation, I would, as a lisp neophyte, be much better off.
Or maybe not... I never had good instruction in engineering school (RPI),
and learned how to learn in *spite* of the teaching. :)
Dave Linenberg