Add preamble and postamble code hooks
This commit is contained in:
@ -532,6 +532,14 @@ def p_code(p):
|
||||
| CODE code_type id_or_str EQUALS LBRACE tcl_code_block RBRACE
|
||||
| CODE code_type id_or_str EQUALS TCL_BEG code_block TCL_END
|
||||
'''
|
||||
if p[3].lower() == 'preamble':
|
||||
name = 'preamble'
|
||||
elif p[3].lower() == 'postamble':
|
||||
name = 'postamble'
|
||||
elif p[3].lower() == 'mkdriver':
|
||||
name = 'mkDriver'
|
||||
elif p[3].lower() == 'mkwrapper':
|
||||
name = 'mkWrapper'
|
||||
p[0] = { 'Code' : { 'name' : p[3], 'type' : p[2], 'text' : p[6] }}
|
||||
|
||||
def p_code_type(p):
|
||||
@ -930,6 +938,11 @@ def put_preamble(MyDriver):
|
||||
txt += [' if { ![info exists ::scobj::permlink_device_counter]} {']
|
||||
txt += [' set ::scobj::permlink_device_counter 0']
|
||||
txt += [' }']
|
||||
func = 'preamble'
|
||||
if func in MyDriver['Funcs']:
|
||||
txt += ['# %s hook code starts' % func]
|
||||
txt += MyDriver['Funcs'][func]['text']
|
||||
txt += ['# %s hook code ends' % func]
|
||||
txt += ['}']
|
||||
txt += ['']
|
||||
txt += ['proc %s::debug_log {tc_root debug_level debug_string} {' % MyDriver['namespace']]
|
||||
@ -1513,6 +1526,11 @@ def put_postamble(MyDriver):
|
||||
txt += [' namespace export sics_log']
|
||||
txt += [' namespace export mkDriver']
|
||||
txt += [' namespace export add_driver']
|
||||
func = 'postamble'
|
||||
if func in MyDriver['Funcs']:
|
||||
txt += ['# %s hook code starts' % func]
|
||||
txt += MyDriver['Funcs'][func]['text']
|
||||
txt += ['# %s hook code ends' % func]
|
||||
txt += ['}']
|
||||
txt += ['']
|
||||
if 'add_args' in MyDriver:
|
||||
|
Reference in New Issue
Block a user