Book a Demo

Author Topic: Code generation - extern, typedef, volitile, macro  (Read 3729 times)

johnm9

  • EA User
  • **
  • Posts: 52
  • Karma: +0/-0
    • View Profile
Code generation - extern, typedef, volitile, macro
« on: June 19, 2008, 08:15:48 pm »
How EA support the generation of these C constructs?

Eve

  • EA Administrator
  • EA Guru
  • *****
  • Posts: 8110
  • Karma: +119/-20
    • View Profile
Re: Code generation - extern, typedef, volitile, m
« Reply #1 on: June 20, 2008, 09:31:40 am »
Look at http://www.sparxsystems.com/EAUserGuide/index.html?modeling_conventions.htm and try reverse engineering some examples, make sure you look at tagged values.
« Last Edit: June 20, 2008, 09:32:16 am by simonm »

johnm9

  • EA User
  • **
  • Posts: 52
  • Karma: +0/-0
    • View Profile
Re: Code generation - extern, typedef, volitile, m
« Reply #2 on: June 20, 2008, 12:10:22 pm »
That section doesn't mentioned about how to generate extern and #define.

I have tried to write a *.h file carrying those syntax and imported to the EA. Then, I cleared up the files content and asked EA to generate the code. The generated code doesn't carry the extern and #define any more... I guess it proves EA's inability to support those syntax, right?

Is there any work around?

Eve

  • EA Administrator
  • EA Guru
  • *****
  • Posts: 8110
  • Karma: +119/-20
    • View Profile
Re: Code generation - extern, typedef, volitile, m
« Reply #3 on: June 20, 2008, 12:52:25 pm »
You could always modify the code templates to generate them, probably from a stereotype override.

For #define, have a look at the C options.  There is an option for importing them.

For the extern, try emailing sparx support.  I think they are intentionally skipped over but I'm not sure.

johnm9

  • EA User
  • **
  • Posts: 52
  • Karma: +0/-0
    • View Profile
Re: Code generation - extern, typedef, volitile, m
« Reply #4 on: June 20, 2008, 12:55:50 pm »
I have tried to import a file having #define in C language.

#define MJ 23

The defined type become a static const attribute with a initial value 23 of the class.

However, when I mimic the same settings to another attributes (KB) in the class through the EA class diagram, the generated code is a static const but not #define KB 8. What did i left behind??

If I want to make a C #define through the model, how can I make it?

Eve

  • EA Administrator
  • EA Guru
  • *****
  • Posts: 8110
  • Karma: +119/-20
    • View Profile
Re: Code generation - extern, typedef, volitile, m
« Reply #5 on: June 20, 2008, 01:07:48 pm »
I don't know what you left behind.  I haven't done much with the C code engineering.

C# #defines can't be modeled in EA as they are not part of the object oriented language.

johnm9

  • EA User
  • **
  • Posts: 52
  • Karma: +0/-0
    • View Profile
Re: Code generation - extern, typedef, volitile, m
« Reply #6 on: June 20, 2008, 02:00:49 pm »
I don't quite understand the user guide instruction in making typedef in class diagram. I'm trying to generate C language.

I have a ClassA (carrying the main) and ClassB. I want to generate a C statement like:

typedef int ClassB in the ClassA.h, how can I do it?

I've tried to follow the guidance by making a <<typedef>> ClassB and put it as inner class of ClassA. It doesn't work. What's left behind?