chiark / gitweb /
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 f8029fd3556ab8ece51ef0395b4676c86f735ae2..eb668a81532a5f13d0b997cba6973821d961046d 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 38e4b208ec24b076cd61f83d53cd08b87723b56f..26d5a4daff7aec37c0c7de99883484a4e41809c2 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 5bd97034d94091ad0574ad130ab20709fd86473e..032e432534a0c5c6826ceaf3129d3e3ef1aabe29 100644 (file)
@@ -584,4 +584,11 @@ (defun commentify-function-type (type)
                      (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 3857b461f5a30b5cb2f34ff7eab256070eb0df84..0564d814cfc4cc10a8a2e9efd53045075e4cfd01 100644 (file)
@@ -53,11 +53,7 @@ (define-on-demand-slot basic-message argument-tail (message)
            (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 862053ff89009fd5e6e8064bf51a1bdef029ac4c..c09a622037790c3207ac081b5517a55d6bf90924 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"))