1 /* $XConsortium: Message.C /main/1 1996/07/29 16:56:53 cde-hp $ */
2 // Copyright (c) 1994 James Clark
3 // See the file COPYING for copying permission.
11 #include "MessageArg.h"
14 namespace SP_NAMESPACE {
17 MessageFragment::MessageFragment(unsigned module, unsigned number, const char *
18 #ifndef SP_NO_MESSAGE_TEXT
23 #ifndef SP_NO_MESSAGE_TEXT
30 MessageType::MessageType(Severity severity, unsigned module, unsigned number,
31 const char *text, const char *
32 #ifndef SP_NO_MESSAGE_TEXT
37 #ifndef SP_NO_MESSAGE_TEXT
40 MessageFragment(module, number, text)
45 MessageType0::MessageType0(Severity severity, unsigned module, unsigned number,
47 : MessageType(severity, module, number, text)
51 MessageType1::MessageType1(Severity severity, unsigned module, unsigned number,
53 : MessageType(severity, module, number, text)
57 MessageType2::MessageType2(Severity severity, unsigned module, unsigned number,
59 : MessageType(severity, module, number, text)
63 MessageType3::MessageType3(Severity severity, unsigned module, unsigned number,
65 : MessageType(severity, module, number, text)
69 MessageType4::MessageType4(Severity severity, unsigned module, unsigned number,
71 : MessageType(severity, module, number, text)
75 MessageType5::MessageType5(Severity severity, unsigned module, unsigned number,
77 : MessageType(severity, module, number, text)
81 MessageType6::MessageType6(Severity severity, unsigned module, unsigned number,
83 : MessageType(severity, module, number, text)
87 MessageType0L::MessageType0L(Severity severity, unsigned module, unsigned number,
88 const char *text, const char *auxText)
89 : MessageType(severity, module, number, text, auxText)
93 MessageType1L::MessageType1L(Severity severity, unsigned module, unsigned number,
94 const char *text, const char *auxText)
95 : MessageType(severity, module, number, text, auxText)
99 OpenElementInfo::OpenElementInfo()
100 : included(0), matchIndex(0)
108 Message::Message(int nArgs)
113 void Message::swap(Message &to)
115 const MessageType *tem = type;
119 to.auxLoc.swap(auxLoc);
121 openElementInfo.swap(to.openElementInfo);
124 Messenger::Messenger()
125 : haveNextLocation_(0)
129 Messenger::~Messenger()
133 void Messenger::dispatchMessage(Message &msg)
135 const Message &tem = msg;
136 dispatchMessage(tem);
139 void Messenger::message(const MessageType0 &type)
144 dispatchMessage(msg);
147 void Messenger::message(const MessageType1 &type, const MessageArg &arg0)
151 msg.args[0] = arg0.copy();
153 dispatchMessage(msg);
156 void Messenger::message(const MessageType2 &type,
157 const MessageArg &arg0,
158 const MessageArg &arg1)
162 msg.args[0] = arg0.copy();
163 msg.args[1] = arg1.copy();
165 dispatchMessage(msg);
168 void Messenger::message(const MessageType3 &type,
169 const MessageArg &arg0,
170 const MessageArg &arg1,
171 const MessageArg &arg2)
175 msg.args[0] = arg0.copy();
176 msg.args[1] = arg1.copy();
177 msg.args[2] = arg2.copy();
179 dispatchMessage(msg);
182 void Messenger::message(const MessageType4 &type,
183 const MessageArg &arg0,
184 const MessageArg &arg1,
185 const MessageArg &arg2,
186 const MessageArg &arg3)
190 msg.args[0] = arg0.copy();
191 msg.args[1] = arg1.copy();
192 msg.args[2] = arg2.copy();
193 msg.args[3] = arg3.copy();
195 dispatchMessage(msg);
198 void Messenger::message(const MessageType5 &type,
199 const MessageArg &arg0,
200 const MessageArg &arg1,
201 const MessageArg &arg2,
202 const MessageArg &arg3,
203 const MessageArg &arg4)
207 msg.args[0] = arg0.copy();
208 msg.args[1] = arg1.copy();
209 msg.args[2] = arg2.copy();
210 msg.args[3] = arg3.copy();
211 msg.args[4] = arg4.copy();
213 dispatchMessage(msg);
216 void Messenger::message(const MessageType6 &type,
217 const MessageArg &arg0,
218 const MessageArg &arg1,
219 const MessageArg &arg2,
220 const MessageArg &arg3,
221 const MessageArg &arg4,
222 const MessageArg &arg5)
226 msg.args[0] = arg0.copy();
227 msg.args[1] = arg1.copy();
228 msg.args[2] = arg2.copy();
229 msg.args[3] = arg3.copy();
230 msg.args[4] = arg4.copy();
231 msg.args[5] = arg5.copy();
233 dispatchMessage(msg);
236 void Messenger::message(const MessageType0L &type, const Location &loc)
242 dispatchMessage(msg);
245 void Messenger::message(const MessageType1L &type, const MessageArg &arg0,
250 msg.args[0] = arg0.copy();
253 dispatchMessage(msg);
257 void Messenger::setNextLocation(const Location &loc)
259 haveNextLocation_ = 1;
263 void Messenger::initMessage(Message &)
267 void Messenger::doInitMessage(Message &msg)
270 if (haveNextLocation_) {
271 msg.loc = nextLocation_;
272 haveNextLocation_ = 0;
276 ForwardingMessenger::ForwardingMessenger(Messenger &to)
281 void ForwardingMessenger::dispatchMessage(Message &msg)
283 to_->dispatchMessage(msg);
286 void ForwardingMessenger::dispatchMessage(const Message &msg)
288 to_->dispatchMessage(msg);
291 void ForwardingMessenger::initMessage(Message &msg)
293 to_->initMessage(msg);
296 ParentLocationMessenger::ParentLocationMessenger(Messenger &mgr)
297 : ForwardingMessenger(mgr)
301 void ParentLocationMessenger::initMessage(Message &msg)
303 ForwardingMessenger::initMessage(msg);
304 if (!msg.loc.origin().isNull())
305 msg.loc = msg.loc.origin()->parent();
308 NullMessenger::NullMessenger()
312 void NullMessenger::dispatchMessage(Message &)
316 void NullMessenger::dispatchMessage(const Message &)