Merge branch 'RELEASE-3_1' into RELEASE-3_2

This commit is contained in:
Douglas Clowes
2014-08-18 13:34:56 +10:00
16 changed files with 470 additions and 190 deletions

View File

@@ -80,6 +80,7 @@ reserved = {
'DEVICE' : 'DEVICE',
'PROTOCOL' : 'PROTOCOL',
'DRIVER_PROPERTY' : 'DRIVER_PROPERTY',
'WRAPPER_PROPERTY' : 'WRAPPER_PROPERTY',
'CLASS' : 'CLASS',
'SIMULATION_GROUP' : 'SIMULATION_GROUP',
'DEBUG_THRESHOLD' : 'DEBUG_THRESHOLD',
@@ -155,6 +156,8 @@ tokens = [
'ID',
'TCL_BEG',
'TCL_END',
'AT_TCL',
'AT_END',
] + list(reserved.values())
#
@@ -166,6 +169,20 @@ t_LBRACE = r'{'
t_RBRACE = r'}'
t_SLASH = r'/'
def t_AT_TCL(t):
r'@TCL'
if Verbose:
print 'AT_TCL'
t.lexer.begin('tcl')
#return t
def t_tcl_AT_END(t):
r'[ \t]*@END'
if Verbose:
print 'AT_END'
t.lexer.begin('INITIAL')
#return t
def t_TCL_BEG(t):
r'{%%'
if Verbose:
@@ -303,6 +320,7 @@ def p_driver_statement(p):
| group
| code
| driver_property
| wrapper_property
'''
p[0] = p[1]
@@ -446,6 +464,12 @@ def p_driver_property(p):
'''
p[0] = { 'DriverProperty' : ( p[2], p[4] ) }
def p_wrapper_property(p):
'''
wrapper_property : WRAPPER_PROPERTY id_or_str EQUALS value
'''
p[0] = { 'WrapperProperty' : ( p[2], p[4] ) }
def p_group_property(p):
'''
group_property : GROUP_PROPERTY id_or_str EQUALS value
@@ -505,6 +529,7 @@ def p_true_false(p):
def p_code(p):
'''
code : CODE code_type id_or_str EQUALS LBRACE code_block RBRACE
| 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
'''
p[0] = { 'Code' : { 'name' : p[3], 'type' : p[2], 'text' : p[6] }}
@@ -524,6 +549,12 @@ def p_code_type(p):
'''
p[0] = p[1]
def p_tcl_code_block(p):
'''
tcl_code_block : AT_TCL code_block AT_END
'''
p[0] = p[2]
def p_code_block(p):
'''code_block : empty
| code_block CODE_STRING
@@ -794,6 +825,11 @@ def build_driver(MyDriver, TheTree):
MyDriver['DriverProperty'] = {}
MyDriver['DriverProperty'][item['DriverProperty'][0]] = item['DriverProperty'][1]
continue
if 'WrapperProperty' in item:
if 'WrapperProperty' not in MyDriver:
MyDriver['WrapperProperty'] = {}
MyDriver['WrapperProperty'][item['WrapperProperty'][0]] = item['WrapperProperty'][1]
continue
for key in item:
MyDriver[key] = item[key]
for item in MyDriver['Permlink']:
@@ -1368,45 +1404,51 @@ def put_mkDriver(MyDriver):
txt += [' set ns "[namespace current]"']
txt += [' set catch_status [ catch {']
txt += ['']
if len(MyDriver['Permlink']) > 0:
if 'make_args' in MyDriver and 'id' in MyDriver['make_args'].split():
pass
else:
txt += [' set permlink_device_number [format "%02d" [incr ::scobj::permlink_device_counter]]']
txt += ['']
if 'sobj_priv_type' in MyDriver:
priv_type = MyDriver['sobj_priv_type'].split()
ms_line = ' MakeSICSObj ${name} SCT_OBJECT %s %s' % (priv_type[0], priv_type[1])
else:
ms_line = ' MakeSICSObj ${name} SCT_OBJECT'
txt += [ms_line]
txt += ['']
txt += [' sicslist setatt ${name} klass %s' % MyDriver['class']]
txt += [' sicslist setatt ${name} long_name ${name}']
if 'DriverProperty' in MyDriver:
for key in MyDriver['DriverProperty']:
txt += [' sicslist setatt ${name} %s "%s"' % (key, MyDriver['DriverProperty'][key])]
txt += ['']
txt += [' set scobj_hpath /sics/${name}']
for group in sorted(MyDriver['Groups']):
txt += put_group(MyDriver, MyDriver['Groups'][group])
txt += [' hsetprop ${scobj_hpath} klass %s' % MyDriver['class']]
txt += [' hsetprop ${scobj_hpath} data true']
txt += [' hsetprop ${scobj_hpath} debug_threshold %s' % str(MyDriver['debug_threshold'])]
if len(MyDriver['Deferred']) > 0:
txt += [' if {[string equal -nocase [SplitReply [%s]] "false"]} {' % MyDriver['simulation_group']]
for line in MyDriver['Deferred']:
txt += [' ' + line]
txt += [' }']
func = 'mkDriver'
func = 'mkWrapper'
if func in MyDriver['Funcs']:
txt += ['# %s hook code starts' % func]
txt += MyDriver['Funcs'][func]['text']
txt += ['# %s hook code ends' % func]
else:
txt += ['# %s hook code goes here' % func]
if len(MyDriver['Permlink']) > 0:
if 'make_args' in MyDriver and 'id' in MyDriver['make_args'].split():
pass
else:
txt += [' set permlink_device_number [format "%02d" [incr ::scobj::permlink_device_counter]]']
txt += ['']
if 'sobj_priv_type' in MyDriver:
priv_type = MyDriver['sobj_priv_type'].split()
ms_line = ' MakeSICSObj ${name} SCT_OBJECT %s %s' % (priv_type[0], priv_type[1])
else:
ms_line = ' MakeSICSObj ${name} SCT_OBJECT'
txt += [ms_line]
txt += ['']
txt += [' sicslist setatt ${name} klass %s' % MyDriver['class']]
txt += [' sicslist setatt ${name} long_name ${name}']
if 'DriverProperty' in MyDriver:
for key in MyDriver['DriverProperty']:
txt += [' sicslist setatt ${name} %s "%s"' % (key, MyDriver['DriverProperty'][key])]
txt += ['']
txt += [' set scobj_hpath /sics/${name}']
for group in sorted(MyDriver['Groups']):
txt += put_group(MyDriver, MyDriver['Groups'][group])
txt += [' hsetprop ${scobj_hpath} klass %s' % MyDriver['class']]
txt += [' hsetprop ${scobj_hpath} data true']
txt += [' hsetprop ${scobj_hpath} debug_threshold %s' % str(MyDriver['debug_threshold'])]
if len(MyDriver['Deferred']) > 0:
txt += [' if {[string equal -nocase [SplitReply [%s]] "false"]} {' % MyDriver['simulation_group']]
for line in MyDriver['Deferred']:
txt += [' ' + line]
txt += [' }']
func = 'mkDriver'
if func in MyDriver['Funcs']:
txt += ['# %s hook code starts' % func]
txt += MyDriver['Funcs'][func]['text']
txt += ['# %s hook code ends' % func]
else:
txt += ['# %s hook code goes here' % func]
txt += [' } catch_message ]']
txt += [' handle_exception ${catch_status} ${catch_message}']
txt += ['}']
@@ -1432,22 +1474,25 @@ def put_postamble(MyDriver):
txt += [' %s::sics_log 9 "add_%s ${name} ${IP} ${port} %s"' % (MyDriver['namespace'], MyDriver['name'], make_args)]
else:
txt += [' %s::sics_log 9 "add_%s ${name} ${IP} ${port}"' % (MyDriver['namespace'], MyDriver['name'])]
txt += [' if {[string equal -nocase [SplitReply [%s]] "false"]} {' % MyDriver['simulation_group']]
txt += [' if {[string equal -nocase "aqadapter" "${IP}"]} {']
txt += [' %s::sics_log 9 "makesctcontroller sct_${name} aqadapter ${port}"' % MyDriver['namespace']]
txt += [' makesctcontroller sct_${name} aqadapter ${port}']
txt += [' } else {']
if 'protocol_args' in MyDriver:
protocol_args = MyDriver['protocol_args'].replace('\\', '\\\\').replace('"', '\\"')
txt += [' %s::sics_log 9 "makesctcontroller sct_${name} %s ${IP}:${port} %s"' % (MyDriver['namespace'], MyDriver['protocol'], protocol_args)]
txt += [' makesctcontroller sct_${name} %s ${IP}:${port} %s' % (MyDriver['protocol'], MyDriver['protocol_args'])]
if ('WrapperProperty' in MyDriver) and ('nosctcontroller' in MyDriver['WrapperProperty']):
txt += [' %s::sics_log 9 "No sctcontroller for %s"' % (MyDriver['namespace'], MyDriver['name'])]
else:
txt += [' %s::sics_log 9 "makesctcontroller sct_${name} %s ${IP}:${port}"' % (MyDriver['namespace'], MyDriver['protocol'])]
txt += [' makesctcontroller sct_${name} %s ${IP}:${port}' % MyDriver['protocol']]
txt += [' }']
txt += [' } else {']
txt += [' %s::sics_log 9 "[%s] => No sctcontroller for %s"' % (MyDriver['namespace'], MyDriver['simulation_group'], MyDriver['name'])]
txt += [' }']
txt += [' if {[string equal -nocase [SplitReply [%s]] "false"]} {' % MyDriver['simulation_group']]
txt += [' if {[string equal -nocase "aqadapter" "${IP}"]} {']
txt += [' %s::sics_log 9 "makesctcontroller sct_${name} aqadapter ${port}"' % MyDriver['namespace']]
txt += [' makesctcontroller sct_${name} aqadapter ${port}']
txt += [' } else {']
if 'protocol_args' in MyDriver:
protocol_args = MyDriver['protocol_args'].replace('\\', '\\\\').replace('"', '\\"')
txt += [' %s::sics_log 9 "makesctcontroller sct_${name} %s ${IP}:${port} %s"' % (MyDriver['namespace'], MyDriver['protocol'], protocol_args)]
txt += [' makesctcontroller sct_${name} %s ${IP}:${port} %s' % (MyDriver['protocol'], MyDriver['protocol_args'])]
else:
txt += [' %s::sics_log 9 "makesctcontroller sct_${name} %s ${IP}:${port}"' % (MyDriver['namespace'], MyDriver['protocol'])]
txt += [' makesctcontroller sct_${name} %s ${IP}:${port}' % MyDriver['protocol']]
txt += [' }']
txt += [' } else {']
txt += [' %s::sics_log 9 "[%s] => No sctcontroller for %s"' % (MyDriver['namespace'], MyDriver['simulation_group'], MyDriver['name'])]
txt += [' }']
if 'make_args' in MyDriver:
make_args = ' '.join(["${%s}"%arg for arg in MyDriver['make_args'].split()])
txt += [' %s::sics_log 1 "%s::mkDriver sct_${name} ${name} %s"' % (MyDriver['namespace'], MyDriver['namespace'], make_args)]