Path: utzoo!utgpu!watserv1!watmath!att!rutgers!cs.utexas.edu!rice!uupsi!kepler1!fcaggian From: fcaggian@kepler.com (Frank Caggiano) Newsgroups: comp.lang.eiffel Subject: eiffel and external c routines Message-ID: <444@kepler1.kepler.com> Date: 18 Oct 90 03:09:45 GMT Organization: Kepler Financial Mgmt., Setuket, NY Lines: 75 I have been trying to access an Eiffel object from a C routine and am having no luck. What I need to do is access a fixed list of intergers from the C routine. I have tried all the ways I can think of using the routines shown on pages 220-221 of Eiffel the language. They don't specifically show the object being passed in however so is this possible? Also while I've ben going through this I thought that if I created the object in C passed it back to eiffel and then passed it back to C maybe it would work then. GHowever when I went to write the C call to eif_create I bummped up afgainst the fact that FIXD_LIST is a constrained type. How do you create a constrained type in C ? All I could comme up with was: eif_create("fixed_list[integer]",some-number) but seems a bit far fechted. I haven't had time to try it out. Anyone have any ideas? Below is an example of code for my first problem: The Eiffel part: class CEIF feature Create is external foo: language "C" local x: FIXED_LIST[INTEGER] do x.Create(3); x.put_i_th(1,1); x.put_i_th(2,2); x.put_i_th(3,3); x.start; io.putint(x.item); io.new_line; x.forth; io.putint(x.item); io.new_line; x.forth; io.putint(x.item); io.new_line; x.start; foo(x); end; end; The C part: #include "/usr/local/Eiffel/files/_eiffel.h" foo(x) OBJPTR x; { int i; extern int eif_err; for (i = 1; i <= 3; i++) { printf("i = %d (%d) {%d} [%d]\n",i,eif_err,eif_attr(x,"count"), eif_attr(x, "item")); eif_rout(x,"forth"); } } what prints out (from the C part): i = 1 (-1) [0] [0] i = 2 (-1) [0] [0] i = 3 (-1) [0] [0] The printout in Eiffel is ok. -- Frank Caggiano INTERNET: fcaggian@kepler.com Kepler Financial Management, Ltd. UUCP: ..!uunet!kepler1!fcaggian 100 North Country Rd. fax: (516) 751-8678 Sekauket, NY 11733 voice: (516) 689-6300