bitunion.hh (5136:53c8a5da3d65) | bitunion.hh (5442:0552284c5b8b) |
---|---|
1/* | 1/* |
2 * Copyright (c) 2003-2005 The Regents of The University of Michigan | 2 * Copyright (c) 2007-2008 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; 9 * redistributions in binary form must reproduce the above copyright 10 * notice, this list of conditions and the following disclaimer in the --- 226 unchanged lines hidden (view full) --- 237//the type to propagate outside of the macro itself in a controlled way. 238//Finally, the base storage is defined which BitfieldOperators will refer to 239//in the operators it defines. This macro is intended to be followed by 240//bitfield definitions which will end up inside it's union. As explained 241//above, these is overlayed the __data member in its entirety by each of the 242//bitfields which are defined in the union, creating shared storage with no 243//overhead. 244#define __BitUnion(type, name) \ | 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; 9 * redistributions in binary form must reproduce the above copyright 10 * notice, this list of conditions and the following disclaimer in the --- 226 unchanged lines hidden (view full) --- 237//the type to propagate outside of the macro itself in a controlled way. 238//Finally, the base storage is defined which BitfieldOperators will refer to 239//in the operators it defines. This macro is intended to be followed by 240//bitfield definitions which will end up inside it's union. As explained 241//above, these is overlayed the __data member in its entirety by each of the 242//bitfields which are defined in the union, creating shared storage with no 243//overhead. 244#define __BitUnion(type, name) \ |
245 namespace BitfieldUnderlyingClasses \ 246 { \ 247 class name; \ 248 } \ 249 class BitfieldUnderlyingClasses::name : \ | 245 class BitfieldUnderlyingClasses##name : \ |
250 public BitfieldBackend::BitfieldTypes<type> \ 251 { \ 252 public: \ 253 typedef type __DataType; \ 254 union { \ 255 type __data;\ 256 257//This closes off the class and union started by the above macro. It is 258//followed by a typedef which makes "name" refer to a BitfieldOperator 259//class inheriting from the class and union just defined, which completes 260//building up the type for the user. 261#define EndBitUnion(name) \ 262 }; \ 263 }; \ 264 typedef BitfieldBackend::BitUnionOperators< \ | 246 public BitfieldBackend::BitfieldTypes<type> \ 247 { \ 248 public: \ 249 typedef type __DataType; \ 250 union { \ 251 type __data;\ 252 253//This closes off the class and union started by the above macro. It is 254//followed by a typedef which makes "name" refer to a BitfieldOperator 255//class inheriting from the class and union just defined, which completes 256//building up the type for the user. 257#define EndBitUnion(name) \ 258 }; \ 259 }; \ 260 typedef BitfieldBackend::BitUnionOperators< \ |
265 BitfieldUnderlyingClasses::name::__DataType, \ 266 BitfieldUnderlyingClasses::name> name; | 261 BitfieldUnderlyingClasses##name::__DataType, \ 262 BitfieldUnderlyingClasses##name> name; |
267 268//This sets up a bitfield which has other bitfields nested inside of it. The 269//__data member functions like the "underlying storage" of the top level 270//BitUnion. Like everything else, it overlays with the top level storage, so 271//making it a regular bitfield type makes the entire thing function as a 272//regular bitfield when referred to by itself. 273#define __SubBitUnion(fieldType, first, last, name) \ 274 class : public BitfieldBackend::BitfieldTypes<__DataType> \ --- 39 unchanged lines hidden --- | 263 264//This sets up a bitfield which has other bitfields nested inside of it. The 265//__data member functions like the "underlying storage" of the top level 266//BitUnion. Like everything else, it overlays with the top level storage, so 267//making it a regular bitfield type makes the entire thing function as a 268//regular bitfield when referred to by itself. 269#define __SubBitUnion(fieldType, first, last, name) \ 270 class : public BitfieldBackend::BitfieldTypes<__DataType> \ --- 39 unchanged lines hidden --- |