1 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
2 ;;; Date: Wed Dec 16 17:40:58 1992
3 ;;; File: tooltalk-macros.el
4 ;;; Title: Useful macros for ToolTalk/elisp interface
5 ;;; SCCS: @(#)tooltalk-macros.el 1.5 21 Jan 1993 19:09:24
6 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
8 (defmacro destructuring-bind-tooltalk-message (variables
13 arglist: (variables args-count message &rest body)
15 Binds VARIABLES to the ARG_VALs and ARG_IVALs of MESSAGE,
16 starting from N = 0, and executes BODY in that context.
17 Binds actual number of message args to ARGS-COUNT.
19 VARIABLES is a list of local variables to bind.
20 Each item in VARIABLES is either nil, a symbol, or a list of the form:
24 If the item is nil, the nth ARG_VAL or ARG_IVAL of MESSAGE is skipped.
25 If the item is a symbol, the nth ARG_VAL of MESSAGE is bound.
27 If type = \"int\" the nth ARG_IVAL of MESSAGE is bound,
28 otherwise the nth ARG_VAL of MESSAGE is bound.
30 If there are more items than actual arguments in MESSAGE, the extra
31 items are bound to nil.
35 (destructuring-bind-tooltalk-message (a (b \"int\") nil d) foo msg
40 (let* ((foo (get-tooltalk-message-attribute msg 'args_count))
42 (get-tooltalk-message-attribute msg 'arg_val 0)))
44 (get-tooltalk-message-attribute msg 'arg_val 1)))
46 (get-tooltalk-message-attribute msg 'arg_val 3))))
49 See GET-TOOLTALK-MESSAGE-ATTRIBUTE for more information.
51 (let* ((var-list variables)
63 'get-tooltalk-message-attribute
68 (setq var-item (car var-list)
69 var-list (cdr var-list))
70 (if (eq 'nil var-item)
74 (setq var (car var-item)
75 type (car (cdr var-item)))
80 'get-tooltalk-message-attribute
82 (if (equal "int" type)
92 (nconc (list 'let* (nreverse bindings)) body)))