params.py (3624:aaba7e06ece4) params.py (3714:5e54b860fd45)
1# Copyright (c) 2004-2006 The Regents of The University of Michigan
2# All rights reserved.
3#
4# Redistribution and use in source and binary forms, with or without
5# modification, are permitted provided that the following conditions are
6# met: redistributions of source code must retain the above copyright
7# notice, this list of conditions and the following disclaimer;
8# redistributions in binary form must reproduce the above copyright

--- 223 unchanged lines hidden (view full) ---

232# a new Latency object.
233class NumericParamValue(ParamValue):
234 def __str__(self):
235 return str(self.value)
236
237 def __float__(self):
238 return float(self.value)
239
1# Copyright (c) 2004-2006 The Regents of The University of Michigan
2# All rights reserved.
3#
4# Redistribution and use in source and binary forms, with or without
5# modification, are permitted provided that the following conditions are
6# met: redistributions of source code must retain the above copyright
7# notice, this list of conditions and the following disclaimer;
8# redistributions in binary form must reproduce the above copyright

--- 223 unchanged lines hidden (view full) ---

232# a new Latency object.
233class NumericParamValue(ParamValue):
234 def __str__(self):
235 return str(self.value)
236
237 def __float__(self):
238 return float(self.value)
239
240 def __long__(self):
241 return long(self.value)
242
243 def __int__(self):
244 return int(self.value)
245
240 # hook for bounds checking
241 def _check(self):
242 return
243
244 def __mul__(self, other):
245 newobj = self.__class__(self)
246 newobj.value *= other
247 newobj._check()

--- 55 unchanged lines hidden (view full) ---

303 def _check(self):
304 if not self.min <= self.value <= self.max:
305 raise TypeError, 'Integer param out of bounds %d < %d < %d' % \
306 (self.min, self.value, self.max)
307
308 def __init__(self, value):
309 if isinstance(value, str):
310 self.value = convert.toInteger(value)
246 # hook for bounds checking
247 def _check(self):
248 return
249
250 def __mul__(self, other):
251 newobj = self.__class__(self)
252 newobj.value *= other
253 newobj._check()

--- 55 unchanged lines hidden (view full) ---

309 def _check(self):
310 if not self.min <= self.value <= self.max:
311 raise TypeError, 'Integer param out of bounds %d < %d < %d' % \
312 (self.min, self.value, self.max)
313
314 def __init__(self, value):
315 if isinstance(value, str):
316 self.value = convert.toInteger(value)
311 elif isinstance(value, (int, long, float)):
317 elif isinstance(value, (int, long, float, NumericParamValue)):
312 self.value = long(value)
318 self.value = long(value)
319 else:
320 raise TypeError, "Can't convert object of type %s to CheckedInt" \
321 % type(value).__name__
313 self._check()
314
315class Int(CheckedInt): cxx_type = 'int'; size = 32; unsigned = False
316class Unsigned(CheckedInt): cxx_type = 'unsigned'; size = 32; unsigned = True
317
318class Int8(CheckedInt): cxx_type = 'int8_t'; size = 8; unsigned = False
319class UInt8(CheckedInt): cxx_type = 'uint8_t'; size = 8; unsigned = True
320class Int16(CheckedInt): cxx_type = 'int16_t'; size = 16; unsigned = False

--- 654 unchanged lines hidden ---
322 self._check()
323
324class Int(CheckedInt): cxx_type = 'int'; size = 32; unsigned = False
325class Unsigned(CheckedInt): cxx_type = 'unsigned'; size = 32; unsigned = True
326
327class Int8(CheckedInt): cxx_type = 'int8_t'; size = 8; unsigned = False
328class UInt8(CheckedInt): cxx_type = 'uint8_t'; size = 8; unsigned = True
329class Int16(CheckedInt): cxx_type = 'int16_t'; size = 16; unsigned = False

--- 654 unchanged lines hidden ---