Book a Demo

Author Topic: Modeling bitfields  (Read 4926 times)

EricP

  • EA User
  • **
  • Posts: 122
  • Karma: +0/-0
    • View Profile
Modeling bitfields
« on: August 13, 2009, 01:05:41 am »
Consider the following code:

struct junk
{
  unsigned char junk1 : 1;
  unsigned char junk2 : 3;
  unsigned char junk3 : 4;
};

When I code-sync that into a model, I get a class diagram with the <<struct>> stereotype, and:

+junk1: unsigned char
+junk2: unsigned char
+junk3: unsigned char

... with no indication of the bitfield assignments.  I looked all through the Properties for the class diagram and the attributes and found nothing that indicates the bitfields.

Then I generated code from the class diagram and got:

struct junk
{
public:
  unsigned char junk1:1;
  unsigned char junk2:3;
  unsigned char junk3:4;
};

... with the bitfield designators restored (along with the superfluous "public:" which I'd be just as happy not to have in a struct but since it's not incorrect I guess I can leave it alone).

My question is, where are the bitfield designators stored in the model?  Obviously they're there someplace or the code generation wouldn't restore them.  I'd like to be able to model them from the diagram without having to create the code and then import it.

EA version is 7.1 build 831 (as noted in other posts, I don't like to upgrade my tools in the middle of a project unless there is a good reason).

jkorman

  • EA User
  • **
  • Posts: 99
  • Karma: +0/-0
    • View Profile
Re: Modeling bitfields
« Reply #1 on: August 13, 2009, 02:54:48 am »
The "bitfield" info is being stored in the attribute's "Tagged Values" tab, and you can create a new "bit" attribute there by adding a new Tagged Value "bitfield", number.

Jim

EricP

  • EA User
  • **
  • Posts: 122
  • Karma: +0/-0
    • View Profile
Re: Modeling bitfields
« Reply #2 on: August 13, 2009, 03:15:50 am »
Thanks, Jim.  Took a while, but I found it. :-)