Book a Demo

Author Topic: C code generator  (Read 6529 times)

A_Gallo

  • EA Novice
  • *
  • Posts: 4
  • Karma: +0/-0
  • SW Manager
    • View Profile
C code generator
« on: May 15, 2005, 12:40:06 am »
Until now we have been working in C++ and we are now on a C project based on Linux. As we are integrating our code inside an existing environment, it would be usefull to have a C code engineering process and support.

Classes can be mapped onto individual header files (as already done) with public and private attributes being grouped into typedef struct and methods into API.

Constructor and Destructors shall be mapped onto malloc and free of the struct.

Each API call shall have the pointer to the typedef struct, to support multiple instantiated objects.

It would be nice to have this feature available in EA.

thanks

fwoolz

  • EA User
  • **
  • Posts: 435
  • Karma: +0/-0
  • We have met the enemy, and he is us.<Pogo, 1970>
    • View Profile
Re: C code generator
« Reply #1 on: May 15, 2005, 04:35:02 pm »
I agree wholeheartedly. Rhapsody by ILogix has shown the way with its "Rhapsody in C."

I have worked with C code in EA by wrapping C files in a fake class definition, but the Sparxians should come up with a built-in C code generator that doesn't require such clunky work-arounds.

Cheers,
Fred Woolsey
Interfleet Technology Inc.

Always be ready to laugh at yourself; that way, you beat everyone else to the punch.


A_Gallo

  • EA Novice
  • *
  • Posts: 4
  • Karma: +0/-0
  • SW Manager
    • View Profile
Re: C code generator
« Reply #2 on: May 15, 2005, 09:17:32 pm »
Hi again,

concerning inheritance, I would propose that in its typedef struct the derived C class has the inherited original typedef struct as first element and then adds all newly added attributes.

This would also allow "cast" and use of API from the parent class to work also on the child class structure.

The big issue is on how to manage for methods to be inherited...

Maybe the solution is to work with enum's and look-up table for function call through pointers. In this way, the derived class could add its newly added methods by extending the table after the original methods from the parent class.

If Sparx Systems have room for this C code generator, I am available for beta testing and for providing some hints or C code from my suggestions above.

thanks and regards

ufechner

  • EA User
  • **
  • Posts: 85
  • Karma: +0/-0
  • I love YaBB 1 Gold!
    • View Profile
Re: C code generator
« Reply #3 on: May 16, 2005, 09:36:02 am »
This was requested more than once before in this forum, so I doubt that sparx system will do anything in this direction.

A code generator could easily added by a third party (open or closed source).
More difficult is reverse engineering.

Some links:

A commercial code generator:
http://www.methodpark.de/en/products/oo2c/
(Perhaps sparx could cooperate with these people to increase compatibility.)

UML-Tool with C code generation support:
http://www.gentleware.com/index.php?id=51

In the pdf documents on this page you find some examples, how mapping from uml to c can be done.

Generally speaking, there are two kind of mappings, that help much for
embedded and realtime developers:

- mapping of classes to c structs
- code generation of state maschines from state diagrams

There is also an open source tool, that works quite well with the first
part of the job:

http://dia2code.sourceforge.net/

It doesn't except xmi input, but if you look at the examples, you get an
idea how the uml2c conversion can be done.

Regards:

Uwe Fechner
« Last Edit: May 16, 2005, 10:36:54 am by ufechner »

A_Gallo

  • EA Novice
  • *
  • Posts: 4
  • Karma: +0/-0
  • SW Manager
    • View Profile
Re: C code generator
« Reply #4 on: May 17, 2005, 03:22:19 am »
Thank you, I did search for "C code generator" before posting in the forum but I could not find it :(

Regards

ufechner

  • EA User
  • **
  • Posts: 85
  • Karma: +0/-0
  • I love YaBB 1 Gold!
    • View Profile
Re: C code generator
« Reply #5 on: May 18, 2005, 12:54:46 am »
Hello,

I was talking to these people:

http://www.methodpark.de/en/products/oo2c/

and they said, it would take two weeks of work, to adapt
there code generator to enterprise architect.

Is anybody else interested, to get this work done?

They would do it, if someone pays for it (its a little bit
too expensive just for our company).

Regards:

Uwe Fechner

PS:
I think it would be a really good move by sparx systems to
make a good C code generator available for EA users.

50% of all software development in the world is development for embedded systems, mostly done in C for processors with 2k .. 256k bytes of program memory.

And complexity and safety requirements in this area are increasing, so UML is used even in this area more and more. (E.G. for automobile and medical systems.)

If this market would be supported by EA, you could sell twice as much licences as today.
« Last Edit: May 18, 2005, 01:24:41 am by ufechner »

Paolo F Cantoni

  • EA Guru
  • *****
  • Posts: 8617
  • Karma: +257/-129
  • Inconsistently correct systems DON'T EXIST!
    • View Profile
Re: C code generator
« Reply #6 on: May 18, 2005, 01:36:43 am »
We do a lot of embedded work in C also.  I'll ask around in my company.

Paolo
Inconsistently correct systems DON'T EXIST!
... Therefore, aim for consistency; in the expectation of achieving correctness....
-Semantica-
Helsinki Principle Rules!

ufechner

  • EA User
  • **
  • Posts: 85
  • Karma: +0/-0
  • I love YaBB 1 Gold!
    • View Profile
Re: C code generator
« Reply #7 on: July 08, 2005, 06:27:29 pm »
Hello,
I just started to write my own C code generator, :) using delphi and the automation interface of EA.

First steps:

- create code for enums (DONE)
- create code for singletons (DONE)
- create code for state diagrams (next week)

It creates three files (header, private header and .c) and parses
these files and replaces the right section, if they already exist.

So if anybody is interested, just ask.

Regards:

Uwe Fechner

« Last Edit: July 11, 2005, 12:07:56 pm by ufechner »

A_Gallo

  • EA Novice
  • *
  • Posts: 4
  • Karma: +0/-0
  • SW Manager
    • View Profile
Re: C code generator
« Reply #8 on: July 11, 2005, 01:35:52 am »
Thanks, it is really interesting and I can volunteer in alpha-testing it, if it helps  you  ;)

Best regards

Andrea