aboutsummaryrefslogtreecommitdiffstats
path: root/tools/asn2wrs.py
diff options
context:
space:
mode:
authorTomas Kukosa <tomas.kukosa@siemens.com>2010-08-24 05:53:17 +0000
committerTomas Kukosa <tomas.kukosa@siemens.com>2010-08-24 05:53:17 +0000
commit7c60d30dc5b6cd5d797ec6515344c20bb1dbaa04 (patch)
tree619158b1d745fce7241aeb46cafede72869327ae /tools/asn2wrs.py
parent95901a9b76835d9a01ed615b521561e1d2a4595d (diff)
- fix using hex values as constraint
- avoid crash if unknown type is used in type assignment svn path=/trunk/; revision=33905
Diffstat (limited to 'tools/asn2wrs.py')
-rwxr-xr-xtools/asn2wrs.py16
1 files changed, 14 insertions, 2 deletions
diff --git a/tools/asn2wrs.py b/tools/asn2wrs.py
index e0cb891b06..feaf9f8e11 100755
--- a/tools/asn2wrs.py
+++ b/tools/asn2wrs.py
@@ -1125,13 +1125,23 @@ class EthCtx:
self.type[tt]['val'].sel_req(t, self.sel_req[t]['sel'], self)
#--- types -------------------
- for t in self.type_imp:
+ for t in self.type_imp: # imported types
nm = asn2c(t)
self.eth_type[nm] = { 'import' : self.type[t]['import'],
'proto' : asn2c(self.type[t]['proto']),
'attr' : {}, 'ref' : []}
self.eth_type[nm]['attr'].update(self.conform.use_item('ETYPE_ATTR', nm))
self.type[t]['ethname'] = nm
+ for t in self.type_ord: # dummy import for missing type reference
+ tp = self.type[t]['val']
+ #print "X : %s %s " % (t, tp.type)
+ if isinstance(tp, TaggedType):
+ #print "%s : %s " % (tp.type, t)
+ tp = tp.val
+ if isinstance(tp, Type_Ref):
+ #print "%s : %s ::= %s " % (tp.type, t, tp.val)
+ if tp.val not in self.type:
+ self.dummy_import_type(tp.val)
for t in self.type_ord:
nm = self.type[t]['tname']
if ((nm.find('#') >= 0) or
@@ -3490,7 +3500,7 @@ class Constraint (Node):
if (int(val) < 0):
return 'M' + str(-int(val))
else:
- return str(val)
+ return str(int(val))
except (ValueError, TypeError):
return asn2c(str(val))
@@ -5398,6 +5408,8 @@ class HStringValue (Value):
vv = '0x'
vv += self.val[1:-2]
return vv
+ def __int__(self):
+ return int(self.val[1:-2], 16)
#--- FieldSpec ----------------------------------------------------------------
class FieldSpec (Node):