<html><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;"><br>On Mar 30, 2014, at 20:26 , Joeish W <<a href="mailto:joeish80829@yahoo.com">joeish80829@yahoo.com</a>> wrote:<br><br><blockquote type="cite">Here is the definition, but thanks for the HELambdaP idea<br>Trust me the opinion of a CFFI expert does matter...could you also show me what a HELambdaP definition would look like for this defcfun.<br><br>;; double RNG::uniform(double a, double b) ;; C++<br>;; double cv_RNG_uniform_double(RNG* self, double a, double b) ;; C <br>(defcfun ("cv_RNG_uniform_double" uniform-d) :double <br> "Returns the next random number sampled from the uniform distribution." <br> (self (:pointer rng)) <br> (a :double) <br> (b :double))<br></blockquote><div><br></div><div><br></div><div>What you need is to define (I can actually define it for a next release) a specialized DOC-BIT for CFFI “cfun”s and a EXTRACT-FORM-DOCUMENTATION method.</div><div><br></div><div>I first stab (untested) could be</div><div><br></div><div><font face="Courier New">(in-package “HELAMBDA”)</font></div><div><font face="Courier New"><br></font></div><div><font face="Courier New">(defstruct (cffi-cfun-doc-bit (:include function-doc-bit (kind-tag “C Function”)))</font></div><div><font face="Courier New"> (c-name "" :read-only t :type string)</font></div><div><font face="Courier New"> (cffi-argument-types () :read-only t :type list))</font></div><div><font face="Courier New"><br></font></div><div><font face="Courier New"><br></font></div><div><font face="Courier New">(defmethod extract-form-documentation ((fk (eql 'cffi:defcfun)) (form cons))</font></div><div><font face="Courier New"> (destructuring-bind (defcfun name-and-options return-type &rest spec)</font></div><div><font face="Courier New"> form</font></div><div><font face="Courier New"> (declare (ignore defcfun))</font></div><div><font face="Courier New"> (let ((name (munge-name-and-option-for-name name-and-options))</font></div><div><div><font face="Courier New"> (c-name (munge-name-and-option-for-c-name name-and-options))</font></div></div><div><font face="Courier New"> )</font></div><div><font face="Courier New"> (make-cffi-cfun-doc-bit</font></div><div><font face="Courier New"> :name name</font></div><div><font face="Courier New"> :c-name c-name</font></div><div><font face="Courier New"> :lambda-list (mapcar #’first (spec-sans-docstring spec))</font></div><div><font face="Courier New"> :doc-string (if (stringp (first spec)) (first spec))</font></div><div><font face="Courier New"> :values return-type</font></div><div><font face="Courier New"> :cffi-argument-types (munge-cffi-spec spec)</font></div><div><font face="Courier New"> #| other keys here … |#</font></div><div><font face="Courier New"> )))</font></div><div><font face="Courier New"> </font></div><div><font face="Courier New"> </font></div><div>Note that the missing functions are needed to munge the DEFCFUN encoded information. At this point, from your example, HELAMBDAP will happily produce a documentation like the following:</div><div><br></div><div><font face="Verdana"><b><i>Function</i> uniform-d</b></font></div><div><font face="Verdana"><b><br></b></font></div><div><font face="Verdana"><b>Package:</b></font></div><div><font face="Verdana"><br></font></div><div><font face="Courier New">CV_RNG</font></div><div><font face="Verdana"><br></font></div><div><font face="Verdana"><b>Syntax:</b></font></div><div><font face="Verdana"><br></font></div><div><font face="Courier New"><b>uniform-d</b> self a b</font></div><div><font face="Verdana"><br></font></div><div><font face="Verdana"><b>Arguments and Values:</b></font></div><div><font face="Verdana"><br></font></div><div><font face="Verdana">SELF : a T</font></div><div><font face="Verdana">A : a T</font></div><div><font face="Verdana">B : a T</font></div><div><font face="Verdana">RESULT : a T</font></div><div><font face="Verdana"><br></font></div><div><font face="Verdana"><b>Description:</b></font></div><div><font face="Verdana"><br></font></div><div><div><font face="Verdana">Returns the next random number sampled from the uniform distribution.</font></div></div><div><br></div><div>If your doc string were the following:</div><div><br></div><div><font face="Courier New">"Returns the next random number sampled from the uniform distribution.</font></div><div><font face="Courier New"><br></font></div><div><font face="Courier New">Arguments and Values:</font></div><div><font face="Courier New"><br></font></div><div><font face="Courier New">SELF : a pointer to a RNG</font></div><div><font face="Courier New">A : a DOUBLE</font></div><div><font face="Courier New">B : a DOUBLE</font></div><div><font face="Courier New">RESULT : a DOUBLE</font></div><div><font face="Courier New">"</font></div><div>then the “Arguments and Values:” section would be copied as is (more or less).</div><div><br></div><div><br></div><div>Of course, you could define a specialized method to produce the DEFCFUN documentation.</div><div><br></div><div><font face="Courier New">(defmethod produce-documentation ((format (eql 'html))</font></div><div><font face="Courier New"> (doc-bit cffi-cfun-doc-bit)</font></div><div><font face="Courier New"> (out file-stream)</font></div><div><font face="Courier New"> doc-bits</font></div><div><font face="Courier New"> &key</font></div><div><font face="Courier New"> documentation-title</font></div><div><font face="Courier New"> &allow-other-keys)</font></div><div><font face="Courier New"> #| … |#</font></div><div><font face="Courier New"> )</font></div><div><br></div><div><br></div><div><br></div><div>Of course, YMMV… As I said, I will be very happy to provide a HELambdaP extension for CFFI. Actually, let me rephrase it: I will be happy to coordinate a HELambdaP extension for CFFI :)</div><div><br></div><div>Cheers</div><div>—</div><div>MA</div><div><br></div><div><br></div><div><br></div><br><blockquote type="cite">On Sunday, March 30, 2014 9:44 AM, Marco Antoniotti <<a href="mailto:marcoxa@cs.nyu.edu">marcoxa@cs.nyu.edu</a>> wrote:<br>What is the CFFI actual definition?<br><br>I - but that is a very selfish proposal :) - would just write a proper handler for HELambdaP.<br><br>Cheers<br><br>MA<br><br><br><br><br><br>On Mar 30, 2014, at 17:11 , Joeish W <<a href="mailto:joeish80829@yahoo.com">joeish80829@yahoo.com</a>> wrote:<br><br>> Which is the better way do write documentation for functions for a CFFI library<br>> <br>> like this?<br>> <br>> C++: int RNG::uniform(int a, int b)<br>> <br>> Common Lisp: (UNIFORM-D (RNG (:POINTER RNG)) (A :DOUBLE) (B :DOUBLE)) => :DOUBLE<br>> <br>> or like this without the parenthesis<br>> <br>> C++: float RNG::uniform(float a, float b)<br>> <br>> Common Lisp: (UNIFORM-F (RNG :POINTER RNG) A :FLOAT B :FLOAT) => :FLOAT<br>> <br>> _______________________________________________<br>> Cffi-devel mailing list<br>> Cffi-devel@common-lisp.net<br>> http://common-lisp.net/cgi-bin/mailman/listinfo/cffi-devel<br><br>--<br>Marco Antoniotti<br><br><br><br><br>_______________________________________________<br>Cffi-devel mailing list<br>Cffi-devel@common-lisp.net<br>http://common-lisp.net/cgi-bin/mailman/listinfo/cffi-devel<br><br><br>_______________________________________________<br>Cffi-devel mailing list<br>Cffi-devel@common-lisp.net<br>http://common-lisp.net/cgi-bin/mailman/listinfo/cffi-devel<br></blockquote><br><div>--<br>Marco Antoniotti<br><br></div><br></body></html>