src/: New function `reify-variable-argument-tail'.
authorMark Wooding <mdw@distorted.org.uk>
Wed, 16 Dec 2015 04:03:46 +0000 (04:03 +0000)
committerMark Wooding <mdw@distorted.org.uk>
Sun, 29 May 2016 14:09:03 +0000 (15:09 +0100)
This does the work behind `sod-message-no-varargs-tail' (only I've
simplified it by using `substitute' rather than pointlessly doing the
work by hand like an idiot).

Heads up: `sod-message-no-varargs-tail' is going to be abolished
entirely soon.

doc/SYMBOLS
doc/clang.tex
src/c-types-impl.lisp
src/method-impl.lisp
src/sod.asd.in

index f8029fd..eb668a8 100644 (file)
@@ -95,6 +95,7 @@ c-types-impl.lisp
   pprint-c-function-type                        function
   ptr                                           c-type
   ptrdiff-t                                     c-type
+  reify-variable-argument-tail                  function
   cl:schar                                      function setf c-type
   short                                         c-type
   short-int                                     c-type
index 38e4b20..26d5a4d 100644 (file)
@@ -756,6 +756,13 @@ function type is the type of the function's return value.
   @|commentify-argument-names| to the argument list of the given type.
 \end{describe}
 
+\begin{describe}{fun}{reify-variable-argument-tail @<arguments> @> @<list>}
+  If the @<argument> list contains an @|:ellipsis| marker, then replace it
+  with a @|va_list|.  The name for the new argument, if any, is taken from
+  the \descref{*sod-ap*}[variable]{var}.  The new list is returned; the
+  original list is not modified, but may share structure with the new list.
+\end{describe}
+
 \begin{describe}{fun}
     {pprint-c-function-type @<return-type> @<stream>
                             @<print-args> @<print-kernel>}
index 5bd9703..032e432 100644 (file)
                      (commentify-argument-names
                       (c-function-arguments type))))
 
+(export 'reify-variable-argument-tail)
+(defun reify-variable-argument-tail (arguments)
+  "Replace any `:ellipsis' item in ARGUMENTS with a `va_list' argument.
+
+   The argument's name is taken from the variable `*sod-ap*'."
+  (substitute (make-argument *sod-ap* c-type-va-list) :ellipsis arguments))
+
 ;;;----- That's all, folks --------------------------------------------------
index 3857b46..0564d81 100644 (file)
            (c-function-arguments (sod-message-type message)))))
 
 (define-on-demand-slot basic-message no-varargs-tail (message)
-  (mapcar (lambda (arg)
-           (if (eq arg :ellipsis)
-               (make-argument *sod-ap* c-type-va-list)
-               arg))
-         (sod-message-argument-tail message)))
+  (reify-variable-argument-tail (sod-message-argument-tail message)))
 
 (defmethod sod-message-method-class
     ((message basic-message) (class sod-class) pset)
index 862053f..c09a622 100644 (file)
 
    ;; C type representation protocol.
    (:file "c-types-proto" :depends-on ("package"))
-   (:file "c-types-impl" :depends-on ("c-types-proto"))
+   (:file "c-types-impl" :depends-on ("c-types-proto" "codegen-proto"))
    (:file "c-types-parse" :depends-on
          ("c-types-proto" "c-types-class-impl" "fragment-parse"))