From 074650bcd2b5de617c4d6e7566557bef8358b5f3 Mon Sep 17 00:00:00 2001 Message-Id: <074650bcd2b5de617c4d6e7566557bef8358b5f3.1716263671.git.mdw@distorted.org.uk> From: Mark Wooding Date: Wed, 16 Dec 2015 04:03:46 +0000 Subject: [PATCH] src/: New function `reify-variable-argument-tail'. Organization: Straylight/Edgeware From: Mark Wooding 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 | 1 + doc/clang.tex | 7 +++++++ src/c-types-impl.lisp | 7 +++++++ src/method-impl.lisp | 6 +----- src/sod.asd.in | 2 +- 5 files changed, 17 insertions(+), 6 deletions(-) diff --git a/doc/SYMBOLS b/doc/SYMBOLS index f8029fd..eb668a8 100644 --- a/doc/SYMBOLS +++ b/doc/SYMBOLS @@ -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 diff --git a/doc/clang.tex b/doc/clang.tex index 38e4b20..26d5a4d 100644 --- a/doc/clang.tex +++ b/doc/clang.tex @@ -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 @ @> @} + If the @ 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 @ @ @ @} diff --git a/src/c-types-impl.lisp b/src/c-types-impl.lisp index 5bd9703..032e432 100644 --- a/src/c-types-impl.lisp +++ b/src/c-types-impl.lisp @@ -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 -------------------------------------------------- diff --git a/src/method-impl.lisp b/src/method-impl.lisp index 3857b46..0564d81 100644 --- a/src/method-impl.lisp +++ b/src/method-impl.lisp @@ -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) diff --git a/src/sod.asd.in b/src/sod.asd.in index 862053f..c09a622 100644 --- a/src/sod.asd.in +++ b/src/sod.asd.in @@ -112,7 +112,7 @@ ;; 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")) -- [mdw]