<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <meta content="text/html; charset=ISO-8859-1"
      http-equiv="Content-Type">
    <title></title>
  </head>
  <body text="#000000" bgcolor="#ffffff">
    On 24.03.2011 20:10, Eliot Miranda wrote:
    <blockquote
      cite="mid:AANLkTi=0PXue5RHo-CsnqDZV4oVnH8JL7M8uaBO79DKq@mail.gmail.com"
      type="cite">
      <pre wrap=""> </pre>
      <br>
      <fieldset class="mimeAttachmentHeader"></fieldset>
      <br>
      <br>
      <br>
      <div class="gmail_quote">On Thu, Mar 24, 2011 at 12:02 PM, Igor
        Stasenko <span dir="ltr">&lt;<a moz-do-not-send="true"
            href="mailto:siguctua@gmail.com">siguctua@gmail.com</a>&gt;</span>
        wrote:<br>
        <blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt
          0.8ex; border-left: 1px solid rgb(204, 204, 204);
          padding-left: 1ex;">
          <div class="im"><br>
            On 24 March 2011 19:43, Eliot Miranda &lt;<a
              moz-do-not-send="true"
              href="mailto:eliot.miranda@gmail.com">eliot.miranda@gmail.com</a>&gt;
            wrote:<br>
            &gt;<br>
            &gt;<br>
            &gt;<br>
            &gt; 2011/3/24 Levente Uzonyi &lt;<a moz-do-not-send="true"
              href="mailto:leves@elte.hu">leves@elte.hu</a>&gt;<br>
            &gt;&gt;<br>
            &gt;&gt;<br>
            &gt;&gt; On Thu, 24 Mar 2011, Eliot Miranda wrote:<br>
            &gt;&gt;<br>
            &gt;&gt; (pine can't quote your mail, sorry)<br>
            &gt;<br>
            &gt; :) &nbsp;No problem.<br>
            &gt;<br>
            &gt;&gt;<br>
            &gt;&gt; "I have some image-level changes that I'll try and
            commit asap, or at least give you as some inbox packages<br>
            &gt;&gt; - parsing FFI method annotations to discover the
            #threaded keyword that sets the "go ahead and thread this
            call" bit in an FFI spec<br>
            &gt;&gt; - an additional inst var in ExternalFunction (IIRC)
            that allows the VM to record how much stack space to reserve
            when marshalling an FFI call<br>
            &gt;&gt; - the new callback marshalling machinery that
            provides platform-independence<br>
            &gt;&gt;<br>
            &gt;&gt; I just need to fid the time to push the code to
            you.<br>
            &gt;&gt;<br>
            &gt;&gt; Now on testing I use<br>
            &gt;&gt; a) an image with a "listener" that reads and writes
            from/to stdin/out while allowing one to interact with the
            image<br>
            &gt;&gt; b) a native Mac OS file dialog that uses a threaded
            call to invoke without blocking the image and threaded
            callbacks to determine which files to<br>
            &gt;&gt; show (filter callback) and what the accept action
            is. &nbsp;I've of course lost my workspace containing this and so
            have to ferret out the doits from my<br>
            &gt;&gt; changes file (I feel such a fool!). &nbsp;Alas this will
            need work as it used an extension to a Teleplace native file
            dialog plugin. &nbsp;But posting it to<br>
            &gt;&gt; FFI will be good; it will test the FFI further.<br>
            &gt;&gt; c) a threaded version of the ODBC connect that
            hasn't really been tested<br>
            &gt;&gt;<br>
            &gt;&gt; etting you and others to start pounding on these
            would be fantastic. &nbsp;Just a matter of finding time. &nbsp;f
            you're happy for me to push inbox packages,<br>
            &gt;&gt; changesets, workspace contents then I can provide
            something quickly. &nbsp;If you want me to commit canges that
            I've made sure are backward compatible<br>
            &gt;&gt; and don't break trunk I'm going ot be much slower.<br>
            &gt;&gt;<br>
            &gt;&gt; best regards (albeit feeling a little frazzled :-)
            ),<br>
            &gt;&gt; Eliot"<br>
            &gt;&gt;<br>
            &gt;&gt; Isn't it the best time to migrate the syntax of FFI
            calls to Pragmas? I know it takes some time to implement the
            pragma support, but IIRC Lukas did that a few years ago, so
            dusting it off and adding support for threaded calls (which
            I didn't see yet) shouldn't be that hard.<br>
            &gt;<br>
          </div>
          +1000.<br>
          <div class="im"><br>
            &gt; SPunds good. &nbsp;Got any URLs? &nbsp;Lukas, got any code?<br>
            &gt;<br>
            &gt;&gt;<br>
            &gt;&gt; Both formats could be supported for a while, then
            we could leave the current format behind and simplify the
            parsers/compilers, etc.<br>
            &gt;<br>
          </div>
          +1<br>
          <div class="im"><br>
            &gt; Indeed. &nbsp;In fact, nothing is set in stone here. &nbsp;I
            desperately want an accurate C signature, not the quick hack
            we have now (a good thing we have a quick hack, but its a
            long way short of copy/pasting C into the pragma). &nbsp;The
            interpreted marshalling scheme Andreas did (ffi specs etc)
            can serve for the moment. &nbsp;The main thing before getting rid
            of that is a design for e.g. a NativeBoost based marshalling
            code generator that is cross-platform, cross-ABI and works
            with the interpreted VMs. &nbsp;I think this is therefore a good
            way off, and there are people like Esteban who need to get
            going now, so we can't let the perfect be the enemy of the
            good and need to provide something functional asap, and that
            may mean living with the current ffi annotation for a few
            months.<br>
            <br>
          </div>
          In NativeBoost i made a separate class for parsing a C
          function<br>
          declaration. It supports two forms of declaration:<br>
          &nbsp;- named function, i.e.<br>
          &nbsp; int foo (int bar, float zork)<br>
          and anonymous one:<br>
          &nbsp;int (int bar, float zork)<br>
          <br>
          as input, parser takes a literal array.<br>
          <br>
          So its quite easy to integrate it into compiler/pragma parser,
          we only<br>
          need to find out what format will work for us.<br>
          <br>
          so, it could be something like:<br>
          <br>
          &lt;cdecl: #( int foo (int bar , float baz )) module:
          #myModule&gt;<br>
          <br>
          or:<br>
          &lt;ffi: #( cdecl int foo ... ) module: ... &gt;<br>
        </blockquote>
        <div><br>
        </div>
        <div>This is such a fascinating hack. &nbsp;e.g.</div>
        <div><br>
        </div>
        <div>#(int (*compar)(const void *, const void *))</div>
        <div>&nbsp;&nbsp; &nbsp;#(#int #(#* #compar) #(#const #void #*, #const #void
          #*))</div>
        <div><br>
        </div>
        <div>#(int (struct { field : 8; fence : 8; gate: 16; } arg))</div>
        <div>&nbsp;&nbsp; &nbsp;#(#int #(#struct #'{' #field #':' 8 #';' #fence #':' 8
          #';' #gate: 16 #';' #'}' #arg))</div>
        <div><br>
        </div>
        <div>Can anyone prove that Igor's approach works for all C
          signatures? &nbsp;What about other languages?</div>
        <div><br>
        </div>
        <div>I find this is like really dirty sex, repellent and
          irresistible at one and the same time.</div>
      </div>
    </blockquote>
    Thank you for putting words to my feeling at the time I suggested it
    :)<br>
    Don't know if it works for every signature though, only the examples
    he gave of the old format :/<br>
    <br>
    Cheers,<br>
    Henry<br>
  </body>
</html>