[Ecls-list] Tighter c/c++ integration, toplevel inline c/c++ code ???
Seth Burleigh
seth at tewebs.com
Mon May 3 14:56:46 UTC 2010
>
> * If the use your prototypes is going to span multiple lisp files then
> create a C/C++ library. Compile and link the FASL files against it and
> you're done.
The goal is to incorporate all the c/c++ code into the lisp files, not
to create a c/c++ library. As i said, tight integration. The c++ library
should be able to call the lisp code, and the lisp code should be able
to call the c++ code. This is certainly possible but involves compiling
the library to a library file each time a change is made, and then you
have to worry about initializing the ecl compiler, initializing the
packages so you can use them in the c++ library, etc. In other words, a
task which should be simple has just been made much more difficult. What
should be an integrated experience has just become a separate one, one
on the c++ side and one on the lisp side.
>Normally one has a C/C++ library with headers ...
I know this, though i dont know much more. I guess i should rephrase my
quesiton. How does ecl do this:
The code below was created from the lisp code:
(defun test2 ()
(ffi:c-inline nil nil :void "
CRectangle rect;
rect.set_values (3,4);
cout << \"area: \" << rect.area();"
))
How is the below function 'used' by the ecl compiler so that i can load
'foo.fas' from the repl and access the lisp function 'test2'? If the ecl
compiler can create a c function which it tells the compiler about and
which can then be loaded, can i somehow hack the ecl internals so that i
can do the same for my own c function?
static cl_object L1test()
{ VT2 VLEX2 CLSR2 STCK2
const cl_env_ptr cl_env_copy = ecl_process_env();
cl_object value0;
ecl_cs_check(cl_env_copy,value0);
{
TTL:
{int V1; /* X */
V1= foo(((int)1),((int)2));
value0=ecl_print(ecl_make_int(V1),Cnil); cl_env_copy->nvalues=1;
return value0;
}
}}
More information about the ecl-devel
mailing list