<?xml version="1.0" encoding="ISO-8859-1"?>

<!DOCTYPE message PUBLIC
  "-//MLarc//DTD MLarc output files//EN"
  "../../mlarc.dtd"[
  <!ATTLIST message
    listname CDATA #REQUIRED
    title CDATA #REQUIRED
  >
]>

  <?xml-stylesheet href="../../mlarc.xsl" type="text/xsl"?>


<message 
  url="2002/07/c7b19622fa8d83e32adb0e632a0eb2ae"
  from="Michael Tucker &lt;mtucker@e...&gt;"
  author="Michael Tucker"
  date="2002-07-24T15:00:58"
  subject="Re: [Caml-list] CamlIDL and function pointers"
  prev="2002/07/d2430a228176c32b53caed6da8161d5d"
  next="2002/07/afdae4d1f06daa7ae47c33e60fc72dbf"
  prev-in-thread="2002/07/a7e0cdd9dfa5e79f251fa9a3482ba382"
  next-in-thread="2002/07/c80262d8a5079c5a0ef409a674edce6f"
  prev-thread="2002/07/71c26b67baafe720885c555fc4a75f00"
  next-thread="2002/07/ed6e258ddd3082e1de940b5ff3b369ea"
  root="../../"
  period="month"
  listname="caml-list"
  title="Archives of the Caml mailing list">

<thread subject="[Caml-list] Caml productivity.">
<msg 
  url="2002/07/1ba7258845ed8bd9491c0456e7a05b1e"
  from="Pal-Kristian Engstad &lt;mrengstad@y...&gt;"
  author="Pal-Kristian Engstad"
  date="2002-07-20T13:48:44"
  subject="[Caml-list] Caml productivity.">
<msg 
  url="2002/07/509362a68506d7ed09d0be89b9c9e4f6"
  from="William Chesters &lt;williamc@p...&gt;"
  author="William Chesters"
  date="2002-07-20T15:14:05"
  subject="[Caml-list] Caml productivity.">
<msg 
  url="2002/07/141365db2b93dfaff20df60620a672c4"
  from="Pal-Kristian Engstad &lt;engstad@n...&gt;"
  author="Pal-Kristian Engstad"
  date="2002-07-22T18:08:37"
  subject="RE: [Caml-list] Caml productivity.">
<msg 
  url="2002/07/70d8fb7b01ce74769871069813828d50"
  from="achrist@e..."
  author="achrist@e..."
  date="2002-07-22T18:40:54"
  subject="Re: [Caml-list] Caml productivity.">
<msg 
  url="2002/07/1929e85adb2dce6bd413f9c176c9d282"
  from="Pal-Kristian Engstad &lt;engstad@n...&gt;"
  author="Pal-Kristian Engstad"
  date="2002-07-22T19:08:59"
  subject="RE: [Caml-list] Caml productivity.">
<msg 
  url="2002/07/a479967b0001a3186b117aad08de5bf4"
  from="Michael Tucker &lt;mtucker@e...&gt;"
  author="Michael Tucker"
  date="2002-07-22T21:13:43"
  subject="[Caml-list] CamlIDL and function pointers">
<msg 
  url="2002/07/78b04a2826c047ba4cdd21788624fcae"
  from="Xavier Leroy &lt;xavier.leroy@i...&gt;"
  author="Xavier Leroy"
  date="2002-07-23T08:39:19"
  subject="Re: [Caml-list] CamlIDL and function pointers">
<msg 
  url="2002/07/a7e0cdd9dfa5e79f251fa9a3482ba382"
  from="Dmitry Bely &lt;dbely@m...&gt;"
  author="Dmitry Bely"
  date="2002-07-23T13:15:38"
  subject="Re: [Caml-list] CamlIDL and function pointers">
</msg>
<msg 
  url="2002/07/c7b19622fa8d83e32adb0e632a0eb2ae"
  from="Michael Tucker &lt;mtucker@e...&gt;"
  author="Michael Tucker"
  date="2002-07-24T15:00:58"
  subject="Re: [Caml-list] CamlIDL and function pointers">
<msg 
  url="2002/07/c80262d8a5079c5a0ef409a674edce6f"
  from="Xavier Leroy &lt;xavier.leroy@i...&gt;"
  author="Xavier Leroy"
  date="2002-07-25T09:36:15"
  subject="Re: [Caml-list] CamlIDL and function pointers">
</msg>
</msg>
</msg>
</msg>
</msg>
</msg>
<msg 
  url="2002/07/e3ce9c7cf91bf6db61d44124f79a98f5"
  from="Oleg &lt;oleg_inconnu@m...&gt;"
  author="Oleg"
  date="2002-07-22T21:24:19"
  subject="Games (Re: [Caml-list] Caml productivity.)">
<msg 
  url="2002/07/8a5ec6fb7a11d61c196ce24b8ffb906d"
  from="Issac Trotts &lt;issac@m...&gt;"
  author="Issac Trotts"
  date="2002-07-23T02:57:07"
  subject="Re: Games (Re: [Caml-list] Caml productivity.)">
<msg 
  url="2002/07/e42b072cfbe92ebadd7aa6957e1eab4f"
  from="eijiro_sumii@a..."
  author="eijiro_sumii@a..."
  date="2002-07-23T11:03:32"
  subject="Re: Games (Re: [Caml-list] Caml productivity.)">
<msg 
  url="2002/07/7c0a72b352be55944287390245b75756"
  from="Charles Martin &lt;caml.list@g...&gt;"
  author="Charles Martin"
  date="2002-07-23T16:17:12"
  subject="Re: Games (Re: [Caml-list] Caml productivity.)">
</msg>
<msg 
  url="2002/07/9922f6f9613f2b6e0ba1c17ad7d199fd"
  from="Andrei de A. Formiga &lt;andreif@i...&gt;"
  author="Andrei de A. Formiga"
  date="2002-07-29T03:33:30"
  subject="Re: Games (Re: [Caml-list] Caml productivity.)">
<msg 
  url="2002/07/7d49d2bb4f0f8d0da011582d590f1f5d"
  from="Florian Hars &lt;florian@h...&gt;"
  author="Florian Hars"
  date="2002-07-29T06:33:15"
  subject="Re: Games (Re: [Caml-list] Caml productivity.)">
</msg>
<msg 
  url="2002/07/ffef81171738879a74f9340fe64c5163"
  from="eijiro_sumii@a..."
  author="eijiro_sumii@a..."
  date="2002-07-29T10:23:23"
  subject="Re: Games (Re: [Caml-list] Caml productivity.)">
<msg 
  url="2002/07/e5ad30ad3d085e195c5e4d8b7ad94acd"
  from="eijiro_sumii@a..."
  author="eijiro_sumii@a..."
  date="2002-07-30T16:50:19"
  subject="Re: Games (Re: [Caml-list] Caml productivity.)">
<msg 
  url="2002/07/25f7863b64a6f6263bbd7d137a563d91"
  from="Jonathan Coupe &lt;jonathan@m...&gt;"
  author="Jonathan Coupe"
  date="2002-07-30T18:08:36"
  subject="Re: Games (Re: [Caml-list] Caml productivity.)">
<msg 
  url="2002/08/43f12f51de81c774b505f143cf807619"
  from="John Max Skaller &lt;skaller@o...&gt;"
  author="John Max Skaller"
  date="2002-08-01T15:39:57"
  subject="Re: Games (Re: [Caml-list] Caml productivity.)">
<msg 
  url="2002/08/0052e34d5ed2c650be1c71bf603dfd84"
  from="Markus Mottl &lt;markus@o...&gt;"
  author="Markus Mottl"
  date="2002-08-01T16:00:17"
  subject="Re: Games (Re: [Caml-list] Caml productivity.)">
</msg>
<msg 
  url="2002/08/fb054c8450791b2ff36f144d26f6ad13"
  from="Jonathan Coupe &lt;jonathan@m...&gt;"
  author="Jonathan Coupe"
  date="2002-08-02T09:02:46"
  subject="Re: Games (Re: [Caml-list] Caml productivity.)">
<msg 
  url="2002/08/d0fd4f4b272f5851effd2c41d20936c3"
  from="Jonathan Coupe &lt;jonathan@m...&gt;"
  author="Jonathan Coupe"
  date="2002-08-02T12:44:46"
  subject="Re: Games (Re: [Caml-list] Caml productivity.)">
</msg>
<msg 
  url="2002/08/93c02d1b6710aa1b7b69bd8f3f88181b"
  from="John Max Skaller &lt;skaller@o...&gt;"
  author="John Max Skaller"
  date="2002-08-02T14:51:20"
  subject="Re: Games (Re: [Caml-list] Caml productivity.)">
</msg>
</msg>
</msg>
<msg 
  url="2002/07/212b6a76b1fb65f098665099a02647f7"
  from="eijiro_sumii@a..."
  author="eijiro_sumii@a..."
  date="2002-07-31T01:11:47"
  subject="Re: Games (Re: [Caml-list] Caml productivity.)">
</msg>
</msg>
</msg>
</msg>
</msg>
</msg>
</msg>
<msg 
  url="2002/07/d13acda5053494df37964bb408085bad"
  from="Chris Hecker &lt;checker@d...&gt;"
  author="Chris Hecker"
  date="2002-07-25T03:23:14"
  subject="Re: Games (Re: [Caml-list] Caml productivity.)">
<msg 
  url="2002/07/fd3e6d80be919abc06bcfd0ee2ffadda"
  from="Jonathan Coupe &lt;jonathan@m...&gt;"
  author="Jonathan Coupe"
  date="2002-07-28T13:40:44"
  subject="Re: Games (Re: [Caml-list] Caml productivity.)">
<msg 
  url="2002/07/0c819bf6e19d28995f6ef2036db39e5f"
  from="Michael Vanier &lt;mvanier@c...&gt;"
  author="Michael Vanier"
  date="2002-07-29T15:49:35"
  subject="Re: Games (Re: [Caml-list] Caml productivity.)">
</msg>
</msg>
</msg>
</msg>
<msg 
  url="2002/07/7e19da946c160f365e8f4fe6773374dd"
  from="Alexander V.Voinov &lt;avv@q...&gt;"
  author="Alexander V.Voinov"
  date="2002-07-22T22:06:37"
  subject="Re: [Caml-list] Caml productivity.">
</msg>
</msg>
</msg>
<msg 
  url="2002/07/e6c3d1cb6aed17c094cbe8798d5b73e9"
  from="Oleg &lt;oleg_inconnu@m...&gt;"
  author="Oleg"
  date="2002-07-20T15:24:38"
  subject="Re: [Caml-list] Caml productivity.">
</msg>
<msg 
  url="2002/07/7a65a2a07ceccfa4e53d0f1c228dbd4f"
  from="Tom &lt;tom7ca@y...&gt;"
  author="Tom"
  date="2002-07-22T06:42:01"
  subject="Re: [Caml-list] Caml productivity.">
</msg>
<msg 
  url="2002/07/9ce195764ef654a5dfb7205f3c85a290"
  from="Nicolas Cannasse &lt;warplayer@f...&gt;"
  author="Nicolas Cannasse"
  date="2002-07-22T10:47:05"
  subject="Re: [Caml-list] Caml productivity.">
<msg 
  url="2002/07/c1d27612820e9d845f7a8b7c0a41d2aa"
  from="Pal-Kristian Engstad &lt;mrengstad@y...&gt;"
  author="Pal-Kristian Engstad"
  date="2002-07-23T20:56:10"
  subject="Re: [Caml-list] Caml productivity.">
<msg 
  url="2002/07/0c313e90b642f8f12bb25f25ea9fbcfd"
  from="Travis Bemann &lt;bemann@e...&gt;"
  author="Travis Bemann"
  date="2002-07-24T04:20:33"
  subject="Re: [Caml-list] Caml productivity.">
<msg 
  url="2002/07/5d55e595caac57c62e5dc2e86b63de1e"
  from="Pal-Kristian Engstad &lt;mrengstad@y...&gt;"
  author="Pal-Kristian Engstad"
  date="2002-07-26T21:07:18"
  subject="Re: [Caml-list] Caml productivity.">
<msg 
  url="2002/07/b212f6e35c549581b16b6624a1a56abb"
  from="Chris Hecker &lt;checker@d...&gt;"
  author="Chris Hecker"
  date="2002-07-26T21:46:45"
  subject="Re: [Caml-list] Caml productivity.">
<msg 
  url="2002/07/d7dbdd3a140874d79a422a0b80cbdf63"
  from="Issac Trotts &lt;issac@m...&gt;"
  author="Issac Trotts"
  date="2002-07-27T04:42:05"
  subject="Re: [Caml-list] Caml productivity.">
<msg 
  url="2002/07/522d76f4ddafad8c4f1e0778ad37a4f1"
  from="Chris Hecker &lt;checker@d...&gt;"
  author="Chris Hecker"
  date="2002-07-27T05:53:17"
  subject="Re: [Caml-list] Caml productivity.">
<msg 
  url="2002/07/c2850575bbf44763e83d5c50f6d5159b"
  from="John Max Skaller &lt;skaller@o...&gt;"
  author="John Max Skaller"
  date="2002-07-27T14:49:36"
  subject="Re: [Caml-list] Caml productivity.">
</msg>
</msg>
</msg>
<msg 
  url="2002/07/251d81ff74aa60825afd904604b8c5d3"
  from="Oleg &lt;oleg_inconnu@m...&gt;"
  author="Oleg"
  date="2002-07-27T09:06:23"
  subject="Re: [Caml-list] Caml productivity.">
<msg 
  url="2002/07/1965eaa1e57e08ccf423e4415d99cd48"
  from="Chris Hecker &lt;checker@d...&gt;"
  author="Chris Hecker"
  date="2002-07-28T00:10:49"
  subject="Re: [Caml-list] Caml productivity.">
</msg>
</msg>
</msg>
<msg 
  url="2002/07/12e4dec5bbe67f35890781b7b85d03ce"
  from="Nicolas Cannasse &lt;warplayer@f...&gt;"
  author="Nicolas Cannasse"
  date="2002-07-29T08:13:59"
  subject="Re: [Caml-list] Caml productivity.">
<msg 
  url="2002/07/53a818fc3a885dc850b4e8564b4c81f4"
  from="Travis Bemann &lt;bemann@e...&gt;"
  author="Travis Bemann"
  date="2002-07-30T05:46:54"
  subject="Re: [Caml-list] Caml productivity.">
</msg>
</msg>
</msg>
</msg>
<msg 
  url="2002/07/b94153a499cfb8e624d1b8a1e738c808"
  from="Nicolas Cannasse &lt;warplayer@f...&gt;"
  author="Nicolas Cannasse"
  date="2002-07-24T08:02:55"
  subject="Re: [Caml-list] Caml productivity.">
<msg 
  url="2002/07/d8be09893e051cef83916581376ca7b6"
  from="Jérôme_Marant &lt;marant.logatique@f...&gt;"
  author="Jérôme_Marant"
  date="2002-07-24T08:28:04"
  subject="Re: [Caml-list] Caml productivity.">
</msg>
<msg 
  url="2002/07/0d311d854b7f7713630895700b3b416b"
  from="Pal-Kristian Engstad &lt;mrengstad@y...&gt;"
  author="Pal-Kristian Engstad"
  date="2002-07-26T21:06:52"
  subject="Re: [Caml-list] Caml productivity.">
<msg 
  url="2002/07/e80e9e57f434ec7a846466c3cb92003c"
  from="Oleg &lt;oleg_inconnu@m...&gt;"
  author="Oleg"
  date="2002-07-27T09:06:15"
  subject="Re: [Caml-list] Caml productivity.">
</msg>
</msg>
</msg>
</msg>
</msg>
</msg>
</thread>

<contents>
Hi,

 Thanks for the help. I have seen another approach mentioned, but have not
been able to get it to work. I thought I could rewrite my struct for the
IDL as:

typedef strcut funp {
   int i;
} funp_t;

But leave the C version intact. Supposedly it would just ignore the other
field when passing it through to Caml. If that's the case, I was thinking
it might be possible to write the following in the IDL:

void myfun ([in, unique] funp_t* f)
   quote(call,
     " _res = f-&gt;funp_fun ();");

So, I guess I would like to be able to ignore a field when converting from
C to Caml (and vice versa), but would like to be able to access the field
from all code on the C side (even that generated by camlidl). I naively
tried adding the function pointer field to the structure in the generated
header file, so that my stub code would compile, but that didn't solve my
problem.

When I call myfun, I got a segmentation fault if I pass it a valid
structure. I also tried editing the custom call to check for NULL and
failwith a string, but the only change was that after calling with None it
would raise an exception -- any valid structure still segfaults. I assume
that is because I'm accessing an invalid field in the string, however a
simple C program including the same header file can access it without a
problem. Any ideas on what is going wrong or how I can fix it?

Thanks,
Mike


On Tue, 23 Jul 2002, Xavier Leroy wrote:

&gt; &gt;   How would one annotate the following C struct for camlidl:
&gt; &gt;
&gt; &gt; typedef struct funp {
&gt; &gt;    int i;
&gt; &gt;    void (*funp_fun) ();
&gt; &gt; } funp_t;
&gt; &gt;
&gt; &gt;   Is it possible? Looking at the specs I don't see how one can have a
&gt; &gt; field that is a pointer to a function. Any ideas, or pointers (no pun
&gt; &gt; intended) to examples?
&gt;
&gt; CamlIDL, like the DCE and Microsoft IDL from which it derives, doesn't
&gt; support exchanging function pointers between C and Caml.  Your best
&gt; bet is to declare funp_t as an abstract type in the IDL file:
&gt;
&gt;         typedef [abstract] struct funp * funp_t;
&gt;
&gt; and export C functions that do what you need to do on this funp_t
&gt; type, e.g.
&gt;
&gt;         void invoke(funp_t arg);
&gt;
&gt; where "invoke" is defined directly in C somewhere else:
&gt;
&gt;         void invoke(funp_t arg) { arg-&gt;funp_fun(arg-&gt;i); }
&gt;
&gt; Of course, you won't be able to, say, construct a funp_t where the
&gt; function part is actually a Caml function.  If you need that kind of
&gt; callback mechanism, you'll have to write some of the stub code by hand,
&gt; using Caml's callback functions.  Alternatively, if you can re-shape
&gt; your struct funp till it looks like a COM interface, you could then use
&gt; the CamlIDL "interface" declaration and get Caml-&gt;C and C-&gt;Caml calls.
&gt;
&gt; Hope this helps,
&gt;
&gt; - Xavier Leroy
&gt; -------------------
&gt; To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
&gt; Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
&gt; Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
&gt;

-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners

</contents>

</message>

