annotate lisp/tooltalk/tooltalk-util.el @ 123:c77884c6318d

Added tag r20-1b14 for changeset d2f30a177268
author cvs
date Mon, 13 Aug 2007 09:26:04 +0200
parents 360340f9fd5f
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1 ;;; -*- Mode: Emacs-Lisp -*-
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3 ;;; Emacs Tooltalk Utility Functions
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5 ;;; @(#)tooltalk-util.el 1.7 93/12/07
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
8 (defun initialize-tooltalk-message-arg (msg n mode value vtype)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
9 "Initialize the Nth tooltalk message argument of MSG.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
10 A new argument is created if necessary. No attempt to distinguish
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
11 between strings that contain binary data and ordinary strings is made;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
12 all non integer argument values are converted to a string (if not a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
13 string already) and loaded with tt_message_arg_val_set().
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
14 Applications that need to put binary data into a ToolTalk message
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
15 argument should initialize the argument with:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
16
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
17 (set-tooltalk-message-attribute bin-string msg 'arg_bval arg-n)"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
18 (let ((n-args-needed
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
19 (- (1+ n) (get-tooltalk-message-attribute msg 'args_count))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
20 (while (> n-args-needed 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
21 (add-tooltalk-message-arg msg mode vtype)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
22 (setq n-args-needed (1- n-args-needed))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
23
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
24 (cond
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
25 ((integerp value)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
26 (set-tooltalk-message-attribute value msg 'arg_ival n))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
27 ((stringp value)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
28 (set-tooltalk-message-attribute value msg 'arg_val n))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
29 (t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
30 (error "The value specified for msg %s argument %d, %s, must be a string or an integer"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
31 (prin1-to-string msg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
32 n
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
33 (prin1-to-string value)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
34
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
35
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
36
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
37 (defconst tooltalk-arg-mode-ids
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
38 (list 'TT_IN 'TT_OUT 'TT_INOUT TT_IN TT_OUT TT_INOUT))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
39
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
40 (defun initialize-tooltalk-message/pattern-args (initfn msg args)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
41 "Apply INITFN to each the position mode value and type of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
42 each argument in the list. The value of INITFN should be either
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
43 'initialize-tooltalk-message-arg or 'initialize-tooltalk-pattern-arg.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
44 See `make-tooltalk-message' for a description of how arguments are specified.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
45 We distinguish the short form for arguments, e.g. \"just-a-value\",
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
46 from the long form by checking to see if the argument is a list whose
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
47 car is one of the ToolTalk mode values like TT_INOUT."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
48 (let ((n 0))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
49 (while args
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
50 (let* ((arg (car args))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
51 (long-form
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
52 (and (consp arg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
53 (member (car arg) tooltalk-arg-mode-ids)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
54 (mode
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
55 (if long-form (car arg) TT_IN))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
56 (value
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
57 (cond
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
58 ((not long-form) arg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
59 ((cdr arg) (car (cdr arg)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
60 (t "")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
61 (type
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
62 (cond
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
63 ((and long-form
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
64 (cdr (cdr arg))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
65 (stringp (car (cdr (cdr arg)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
66 (car (cdr (cdr arg))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
67 ((integerp value) "int")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
68 (t "string"))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
69 (funcall initfn msg n mode value type))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
70 (setq args (cdr args))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
71 (setq n (1+ n)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
72
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
73
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
74 (defun initialize-tooltalk-message-attributes (msg attributes)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
75 "Initialize the tooltalk message attributes. The value of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
76 attributes must be a property list in the same form as for
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
77 make-tooltalk-message. This function can be used to reset
108
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 70
diff changeset
78 an existing message or to initialize a new one. See
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
79 initialize-tooltalk-message-args for a description of how
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
80 arguments are initialized."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
81 (let ((args attributes)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
82 (initfn 'initialize-tooltalk-message-arg))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
83 (while (and args (cdr args))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
84 (let ((indicator (car args))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
85 (value (car (cdr args))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
86 (if (eq indicator 'args)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
87 (initialize-tooltalk-message/pattern-args initfn msg value)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
88 (set-tooltalk-message-attribute value msg indicator)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
89 (setq args (cdr (cdr args))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
90
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
91
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
92 (defun make-tooltalk-message (attributes &optional no-callback)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
93 "Create a tooltalk message and initialize its attributes.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
94 The value of attributes must be a list of alternating keyword/values,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
95 where keywords are symbols that name valid message attributes.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
96 For example:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
97
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
98 (make-tooltalk-message
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
99 '(class TT_NOTICE
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
100 scope TT_SESSION
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
101 address TT_PROCEDURE
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
102 op \"do-something\"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
103 args (\"arg1\" 12345 (TT_INOUT \"arg3\" \"string\"))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
104
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
105 Values must always be strings, integers, or symbols that
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
106 represent Tooltalk constants. Attribute names are the same as
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
107 those supported by set-tooltalk-message-attribute, plus 'args.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
108
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
109 The value of args should be a list of message arguments where
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
110 each message argument has the following form:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
111
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
112 (mode [value [type]]) or just value
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
113
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
114 Where mode is one of TT_IN, TT_OUT, TT_INOUT and type is a string.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
115 If type isn't specified then \"int\" is used if the value is a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
116 number otherwise \"string\" is used. If only a value is specified
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
117 then mode defaults to TT_IN. If mode is TT_OUT then value and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
118 type don't need to be specified. You can find out more about the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
119 semantics and uses of ToolTalk message arguments in chapter 4 of the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
120 Tooltalk Programmer's Guide.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
121
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
122 The no-callback arg is a hack to prevent the registration of the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
123 C-level callback. This hack is needed by the current SPARCworks
108
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 70
diff changeset
124 tool startup mechanism. Yucko."
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
125 (let ((msg (create-tooltalk-message no-callback)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
126 (initialize-tooltalk-message-attributes msg attributes)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
127 msg))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
128
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
129
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
130 (defun describe-tooltalk-message (msg &optional stream)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
131 "Print tooltalk message MSG's attributes and arguments to STREAM.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
132 This is often useful for debugging."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
133 (let ((attrs
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
134 '(address
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
135 class
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
136 disposition
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
137 file
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
138 gid
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
139 handler
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
140 handler_ptype
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
141 object
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
142 op
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
143 opnum
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
144 otype
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
145 scope
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
146 sender
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
147 sender_ptype
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
148 session
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
149 state
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
150 status
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
151 status_string
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
152 uid
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
153 callback)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
154 (terpri stream)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
155 (while attrs
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
156 (princ (car attrs) stream)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
157 (princ " " stream)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
158 (prin1 (get-tooltalk-message-attribute msg (car attrs)) stream)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
159 (terpri stream)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
160 (setq attrs (cdr attrs))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
161
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
162 (let ((n (get-tooltalk-message-attribute msg 'args_count))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
163 (i 0))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
164 (while (< i n)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
165 (princ "Argument " stream)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
166 (princ i stream)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
167 (princ " " stream)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
168 (let ((type (get-tooltalk-message-attribute msg 'arg_type i)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
169 (princ
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
170 (prin1-to-string
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
171 (list
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
172 (get-tooltalk-message-attribute msg 'arg_mode i)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
173 (if (equal type "int")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
174 (get-tooltalk-message-attribute msg 'arg_ival i)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
175 (get-tooltalk-message-attribute msg 'arg_val i))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
176 type))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
177 stream))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
178 (terpri stream)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
179 (setq i (1+ i)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
180
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
181
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
182 (defun initialize-tooltalk-pattern-arg (pat n mode value vtype)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
183 "Add one argument to tooltalk pattern PAT.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
184 No support for specifying pattern arguments whose value is a vector
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
185 of binary data is provided."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
186 (let ((converted-value
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
187 (if (or (integerp value) (stringp value))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
188 value
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
189 (prin1-to-string value))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
190 (add-tooltalk-pattern-arg pat mode vtype converted-value)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
191
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
192
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
193 (defun initialize-tooltalk-pattern-attributes (pat attributes)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
194 "Initialize tooltalk pattern PAT's attributes.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
195 ATTRIBUTES must be a property list in the same form as for
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
196 `make-tooltalk-pattern'. The value of each attribute (except 'category)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
197 can either be a single value or a list of values. If a list of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
198 values is provided then the pattern will match messages with
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
199 a corresponding attribute that matches any member of the list.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
200
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
201 This function can be used to add attribute values to an existing
108
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 70
diff changeset
202 pattern or to initialize a new one. See
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
203 `initialize-tooltalk-message/pattern-args' for a description of how
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
204 arguments are initialized."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
205 (let ((args attributes)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
206 (initfn 'initialize-tooltalk-pattern-arg))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
207 (while (and args (cdr args))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
208 (let ((indicator (car args))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
209 (value (car (cdr args))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
210 (cond
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
211 ((eq indicator 'args)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
212 (initialize-tooltalk-message/pattern-args initfn pat value))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
213 ((eq indicator 'plist)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
214 (let ((values value))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
215 (while values
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
216 (let ((prop (car values))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
217 (propval (car (cdr values))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
218 (tooltalk-pattern-prop-set pat prop propval))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
219 (setq values (cdr (cdr values))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
220 ((consp value)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
221 (let ((values value))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
222 (while values
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
223 (add-tooltalk-pattern-attribute (car values) pat indicator)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
224 (setq values (cdr values)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
225 (t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
226 (add-tooltalk-pattern-attribute value pat indicator))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
227 (setq args (cdr (cdr args))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
228
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
229
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
230
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
231 (defun make-tooltalk-pattern (attributes)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
232 "Create a tooltalk pattern and initialize its attributes.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
233 The value of attributes must be a list of alternating keyword/values,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
234 where keywords are symbols that name valid pattern attributes
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
235 or lists of valid attributes. For example:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
236
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
237 (make-tooltalk-pattern
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
238 '(category TT_OBSERVE
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
239 scope TT_SESSION
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
240 op (\"operation1\" \"operation2\")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
241 args (\"arg1\" 12345 (TT_INOUT \"arg3\" \"string\"))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
242
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
243
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
244 Values must always be strings, integers, or symbols that
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
245 represent Tooltalk constants or lists of same. When a list
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
246 of values is provided all of the list elements are added to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
247 the attribute. In the example above, messages whose op
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
248 attribute is \"operation1\" or \"operation2\" would match the pattern.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
249
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
250 The value of args should be a list of pattern arguments where
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
251 each pattern argument has the following form:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
252
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
253 (mode [value [type]]) or just value
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
254
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
255 Where mode is one of TT_IN, TT_OUT, TT_INOUT and type is a string.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
256 If type isn't specified then \"int\" is used if the value is a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
257 number otherwise \"string\" is used. If only a value is specified
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
258 then mode defaults to TT_IN. If mode is TT_OUT then value and type
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
259 don't need to be specified. You can find out more about the semantics
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
260 and uses of ToolTalk pattern arguments in chapter 3 of the Tooltalk
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
261 Programmers Guide.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
262 "
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
263 (let ((pat (create-tooltalk-pattern)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
264 (initialize-tooltalk-pattern-attributes pat attributes)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
265 pat))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
266
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
267
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
268