[Uml-user] ANSI-C code generation?

Jean Vittor jean.vittor at wanadoo.fr
Fri Oct 25 03:48:02 UTC 2002


Fabio,

Classes is a central concept in UML. If you don't use classes, a 
UML-tool (I mean a tool using UML semantics) could only help you for 
dynamic behaviour and I don't think that Umbrello generates codes from 
dynamic diagrams (am I wrong ?).

But some object oriented programming features can be used when 
developping in C.
If you try to implement a class in C, you can use a struct for data 
members, and define in this struct some function pointers that will be 
called like methods in C (first parameter of functions should be "this" 
for non-static methods). Then, a constructor function should be 
implemented, that assigns the function pointers. If you want to use 
inheritance, it's up to you to decide how (e.g. daughter-struct can have 
a pointer to mother-struct but overiding  methods can be a little more 
complicated).
Function names should be prefixed by the struct name (no context in C).
Concerning encapsulation (I mean access to private or protected 
methods), I don't know anything in C that allows that.

If you want a example of an object project developped in C, just take a 
look at GTK : I think it's a good example.

Hope it helps,

Jean


Hanna Italy - R&D SW wrote:

>Thank you for the replies.
>Now, I know nearly nothing of UML and my knowledge of C++
>has been fading over the last 6 years spent in programming in C, assembly
>and Visual Basic (!!!).
>My next question is:
>is there a (possible) way to limit the UML functionalities in Umbrello so
>that it does not use classes?
>Actually there exists some commercial tools like I-Logix Rhapsody,
>SmartState or IAR VisualState which generate C, but I do not know if
>they have a way to translate C++ structures in C or if they limit the UML
>possibilities when generating C.
>Thanks,
>
>Fabio
>
>
>
>----- Original Message -----
>From: "Luis De la Parra Blum" <lparrab at gmx.net>
>To: "Jonathan Riddell" <jr at jriddell.org>; <umbrello at kde.org>
>Cc: "Hanna Italy - R&D SW" <r&d.sw at hanna.it>
>Sent: Thursday, October 24, 2002 7:53 PM
>Subject: Re: [Uml-user] ANSI-C code generation?
>
>
>  
>
>>On Thursday 24 October 2002 19:24, Jonathan Riddell wrote:
>>    
>>
>>>>is it possible to generate plain ANSI-C code (not C++) with Umbrello?
>>>>I would like to use it for embedded systems, with small
>>>>        
>>>>
>microprocessors
>  
>
>>>>for which only C compilers are available.
>>>>        
>>>>
>>>This isn't currently possible.  It wouldn't be very difficult to write a
>>>plugin library to do this if you had a logical way to munge the object's
>>>into C features.
>>>      
>>>
>>I think also think it should not be too dificult --if you have a very
>>    
>>
>simple
>  
>
>>modell, that is.--. you just have to make a strucutre with all the data
>>members of the class, and at the the code generator has to insert an extra
>>parameter to the function (the "this" pointer)
>>You'd only have to prefix all function names with the class (because of
>>    
>>
>name
>  
>
>>conflicts)
>>
>>the problem is that now the C++ compiler takes care of inherited
>>    
>>
>functions,
>  
>
>>and if you want to generate C code you would have to and examine the whole
>>clase hierarchie to generate the code.
>>
>>luis.
>>    
>>
>
>
>
>-------------------------------------------------------
>This sf.net email is sponsored by: Influence the future 
>of Java(TM) technology. Join the Java Community 
>Process(SM) (JCP(SM)) program now. 
>http://ads.sourceforge.net/cgi-bin/redirect.pl?sunm0004en
>_______________________________________________
>Uml-user mailing list
>umbrello at kde.org
>https://mail.kde.org/mailman/listinfo/umbrello
>
>  
>






More information about the umbrello mailing list