@@ -95,6 +95,13 @@ def __init__(self, filename, parentParser):
9595 self .cmdcnt = 0
9696 self .enumNamespace = ''
9797 self .scopeMap = {}
98+ self .dfl_location = ''
99+ self .dfl_subsystem = ''
100+ self .dfl_group = ''
101+ self .dl_name = ''
102+ self .dl_path = ''
103+ self .lproc_name = ''
104+ self .lproc_port = ''
98105 kw = P .Keyword
99106 s = P .Suppress
100107 lit = P .Literal
@@ -194,6 +201,17 @@ def __init__(self, filename, parentParser):
194201 P .Optional (g (kw ("false_label" ) + P .QuotedString ('"' ) + s (";" ))) \
195202 ) + s ("}" )
196203
204+ namespacedefaults = \
205+ s ("{" ) + ( \
206+ P .Optional (g (kw ("location" ) + P .QuotedString ('"' ) + s (";" ))) & \
207+ P .Optional (g (kw ("subsystem" ) + P .QuotedString ('"' ) + s (";" ))) & \
208+ P .Optional (g (kw ("group" ) + P .QuotedString ('"' ) + s (";" ))) & \
209+ P .Optional (g (kw ("dl_name" ) + P .QuotedString ('"' ) + s (";" ))) & \
210+ P .Optional (g (kw ("dl_path" ) + P .QuotedString ('"' ) + s (";" ))) & \
211+ P .Optional (g (kw ("lproc_name" ) + P .QuotedString ('"' ) + s (";" ))) & \
212+ P .Optional (g (kw ("lproc_port" ) + decimal_literal + s (";" ))) \
213+ ) + s ("}" )
214+
197215 bitfield_member = bitfield_declaration + g (P .Optional (fielddocumentation ))
198216
199217 declaration = \
@@ -219,10 +237,10 @@ def __init__(self, filename, parentParser):
219237 struct_body << s ("{" ) + P .OneOrMore (struct_member ) + s ("}" )
220238
221239 constant_def = kw ("const" ) - scopedUpperIdentifier - s ("=" ) - numeric_literal - s (";" )
222- namespace_def = kw ("namespace" ) - identifier - s (";" )
240+ namespace_def = kw ("namespace" ) - identifier - P . Optional ( namespacedefaults ) - s (";" )
223241 namespace_def .setParseAction (self .namespaceParse )
224242
225- nonamespace_def = kw ("nonamespace" ) + s (";" )
243+ nonamespace_def = kw ("nonamespace" ) + P . Optional ( namespacedefaults ) + s (";" )
226244 nonamespace_def .setParseAction (self .nonamespace )
227245
228246 struct_def = kw ("struct" ) - newscopedidentifier - g (struct_body ) + P .Optional (s ('=' ) - type_name ) - s (";" )
@@ -238,6 +256,12 @@ def __init__(self, filename, parentParser):
238256
239257 command_def = kw ("command" ) - P .QuotedString ('"' ) - g (command_body ) - P .Optional (s ('=' ) + type_name ) - s (";" )
240258
259+ event_options = \
260+ P .Optional (g (kw ("summary" ) + P .QuotedString ('"' ) + s (";" )))
261+
262+ event_body = s ("{" ) + event_options + s ("}" )
263+ event_def = kw ("event" ) - P .QuotedString ('"' ) - g (event_body ) - P .Optional (s ('=' ) + type_name ) - s (";" )
264+
241265 union_def = kw ("union" ) - newscopedidentifier - s ('{' ) + s ('}' ) - s (";" )
242266
243267 error_def = kw ("error" ) - type_name - s ('=' ) + P .QuotedString ('"' ) + s (";" )
@@ -247,6 +271,7 @@ def __init__(self, filename, parentParser):
247271 union_def | \
248272 struct_def | \
249273 command_def | \
274+ event_def | \
250275 error_def
251276
252277 import_def = kw ("import" ) - P .QuotedString ('"' ) - s (";" )
@@ -287,9 +312,9 @@ def xdr_parse_fielddoc(self, x):
287312 offset = 0
288313 true_label = ''
289314 false_label = ''
290- location = ''
291- subsystem = ''
292- group = ''
315+ location = self . dfl_location
316+ subsystem = self . dfl_subsystem
317+ group = self . dfl_group
293318 export = True
294319 for field in x :
295320 if field [0 ] == 'key' :
@@ -424,7 +449,36 @@ def xdr_parse_declaration(self, x):
424449
425450 def xdr_parse_definition (self , x ):
426451 if x [0 ] == 'namespace' :
427- return [XDRNamespace (x [1 ])]
452+ location = ''
453+ subsystem = ''
454+ group = ''
455+ dl_name = ''
456+ dl_path = ''
457+ lproc_name = ''
458+ lproc_port = ''
459+ for i in x [2 :]:
460+ if i [0 ] == 'location' :
461+ location = i [1 ]
462+ self .dfl_location = location
463+ if i [0 ] == 'subsystem' :
464+ subsystem = i [1 ]
465+ self .dfl_subsystem = subsystem
466+ if i [0 ] == 'group' :
467+ group = i [1 ]
468+ self .dfl_group = group
469+ if i [0 ] == 'dl_name' :
470+ dl_name = i [1 ]
471+ self .dl_name = dl_name
472+ if i [0 ] == 'dl_path' :
473+ dl_path = i [1 ]
474+ self .dl_path = dl_path
475+ if i [0 ] == 'lproc_name' :
476+ lproc_name = i [1 ]
477+ self .lproc_name = lproc_name
478+ if i [0 ] == 'lproc_port' :
479+ lproc_port = i [1 ]
480+ self .lproc_port = lproc_port
481+ return [XDRNamespace (x [1 ], location , subsystem , group , dl_name , dl_path , lproc_name , lproc_port )]
428482 elif x [0 ] == 'nonamespace' :
429483 return []
430484 elif x [0 ] == 'import' :
@@ -450,7 +504,15 @@ def xdr_parse_definition(self, x):
450504# [XDRUnionMember(y[0], self.xdr_parse_declaration(y[1])) for y in x[3]])
451505 elif x [0 ] == 'error' :
452506 return [XDRError (x [1 ], x [1 ].split ('::' )[- 1 ], x [2 ])]
453-
507+ elif x [0 ] == 'event' :
508+ summary = ''
509+ num = '0'
510+ for field in x [2 ]:
511+ if field [0 ] == 'summary' :
512+ summary = field [1 ]
513+ if len (x ) >= 4 :
514+ num = x [3 ]
515+ return [XDREvent (x [1 ], num , summary , self .lproc_name , self .lproc_port )]
454516 elif x [0 ] == 'command' :
455517 summary = None
456518 param = '0'
0 commit comments