@@ -546,50 +546,33 @@ def pack_value(self, val):
546546
547547
548548class Object (ValueField ):
549- structcode = None
550-
551549 def __init__ (self , name , type , default = None ):
552550 ValueField .__init__ (self , name , default )
553551 self .type = type
554552 self .structcode = self .type .structcode
555553 self .structvalues = self .type .structvalues
556554
557555 def parse_binary_value (self , data , display , length , format ):
558- if self .type .structcode is None :
559- return self .type .parse_binary (data , display )
560-
561- else :
562- scode = '=' + self .type .structcode
563- slen = struct .calcsize (scode )
564-
565- v = struct .unpack (scode , data [:slen ])
566- if self .type .structvalues == 1 :
567- v = v [0 ]
568-
569- if self .type .parse_value is not None :
570- v = self .type .parse_value (v , display )
571-
572- return v , buffer (data , slen )
556+ return self .type .parse_binary (data , display )
573557
574558 def parse_value (self , val , display ):
575- if self .type .parse_value is None :
576- return val
577- else :
578- return self .type .parse_value (val , display )
559+ return self .type .parse_value (val , display )
579560
580561 def pack_value (self , val ):
581- # Single-char values, we'll assume that mean an integer
582- if self .type .structcode and len (self .type .structcode ) == 1 :
583- return struct .pack ('=' + self .type .structcode , val ), None , None
584- else :
585- return self .type .pack_value (val )
562+ return self .type .pack_value (val )
586563
587564 def check_value (self , val ):
588- if self .type .structcode is None :
589- return val
590-
591565 if type (val ) is types .TupleType :
592- return val
566+ vals = []
567+ i = 0
568+ for f in self .type .fields :
569+ if f .name :
570+ if f .check_value is None :
571+ vals .append (val [i ])
572+ else :
573+ vals .append (f .check_value (val [i ]))
574+ i = i + 1
575+ return vals
593576
594577 if type (val ) is types .DictType :
595578 data = val
@@ -601,7 +584,10 @@ def check_value(self, val):
601584 vals = []
602585 for f in self .type .fields :
603586 if f .name :
604- vals .append (data [f .name ])
587+ if f .check_value is None :
588+ vals .append (data [f .name ])
589+ else :
590+ vals .append (f .check_value (data [f .name ]))
605591
606592 return vals
607593
0 commit comments