bitfield.hh (4259:ca1ca13665ba) bitfield.hh (4260:cb8a68017b41)
1/*
2 * Copyright (c) 2003-2005 The Regents of The University of Michigan
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are
7 * met: redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer;

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

182 }
183 };
184
185 //Similar to the above, but only allows writing.
186 template<class Type, class Base>
187 class _BitfieldWO : public Base
188 {
189 public:
1/*
2 * Copyright (c) 2003-2005 The Regents of The University of Michigan
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are
7 * met: redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer;

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

182 }
183 };
184
185 //Similar to the above, but only allows writing.
186 template<class Type, class Base>
187 class _BitfieldWO : public Base
188 {
189 public:
190 const Type operator = (const Type & _data)
190 const Type operator=(const Type & _data)
191 {
192 *((Base *)this) = _data;
193 return _data;
194 }
195 };
196
197 //This class implements ordinary bitfields, that is a span of bits
198 //who's msb is "first", and who's lsb is "last".
199 template<class Data, int first, int last=first>
200 class _Bitfield : public BitfieldBase<Data>
201 {
202 public:
203 operator const Data ()
204 {
205 return this->getBits(first, last);
206 }
207
208 const Data
191 {
192 *((Base *)this) = _data;
193 return _data;
194 }
195 };
196
197 //This class implements ordinary bitfields, that is a span of bits
198 //who's msb is "first", and who's lsb is "last".
199 template<class Data, int first, int last=first>
200 class _Bitfield : public BitfieldBase<Data>
201 {
202 public:
203 operator const Data ()
204 {
205 return this->getBits(first, last);
206 }
207
208 const Data
209 operator = (const Data & _data)
209 operator=(const Data & _data)
210 {
211 this->setBits(first, last, _data);
212 return _data;
213 }
214 };
215
216 //When a BitUnion is set up, an underlying class is created which holds
217 //the actual union. This class then inherits from it, and provids the

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

224 {
225 public:
226 operator const Type ()
227 {
228 return Base::__data;
229 }
230
231 const Type
210 {
211 this->setBits(first, last, _data);
212 return _data;
213 }
214 };
215
216 //When a BitUnion is set up, an underlying class is created which holds
217 //the actual union. This class then inherits from it, and provids the

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

224 {
225 public:
226 operator const Type ()
227 {
228 return Base::__data;
229 }
230
231 const Type
232 operator = (const Type & _data)
232 operator=(const Type & _data)
233 {
234 Base::__data = _data;
235 }
236
237 bool
233 {
234 Base::__data = _data;
235 }
236
237 bool
238 operator < (const Base & base)
238 operator<(const Base & base)
239 {
240 return Base::__data < base.__data;
241 }
242
243 bool
239 {
240 return Base::__data < base.__data;
241 }
242
243 bool
244 operator == (const Base & base)
244 operator==(const Base & base)
245 {
246 return Base::__data == base.__data;
247 }
248 };
249}
250
251//This macro is a backend for other macros that specialize it slightly.
252//First, it creates/extends a namespace "BitfieldUnderlyingClasses" and

--- 102 unchanged lines hidden ---
245 {
246 return Base::__data == base.__data;
247 }
248 };
249}
250
251//This macro is a backend for other macros that specialize it slightly.
252//First, it creates/extends a namespace "BitfieldUnderlyingClasses" and

--- 102 unchanged lines hidden ---