[Uml-devel] codegenerators

Luis De la Parra Blum lparrab at gmx.net
Thu Apr 3 11:26:38 UTC 2003


> - generate code in Umbrello
> - edit the code with an editor/IDE
> - Umbrello notices the code changes and updates the entire modell (maybe
> add a new class or rename something)
>
> I'm not if we could do this, I think it might be impossible.

it woud not be *too* difficult, once we have a good parser architecture and 
some code readers... till then we can forget about it.

> Another solution:
>
> - generate code in Umbrello
> - start an editor through Umbrello

I think this is a very a good idea. we only need an entrie in the properties 
dialog:  "command for editor = kate %f "

....

speaking of code generation and such...
last night I was thinking that it'd be great to have umbrello update the files 
it generates instead of overwriting (what else is new?), but I do *not* want 
umbrello to insert "marks" in the code because of serveral reasons:

- doesnt look good
- it would mean the user cannot touch the marked sections, or else he'll loose 
everything.
-others

so, I tought that if CVS can merge files, so can we....
$man merge

I did a small experiment: the code generator's output stream is not connected 
to the file, but to a string, and when it finishes it calls a method 
"writeOutput" which checks if the file exists: if no, then it writes the 
whole thing to the target file, but if it exists, it writes it to a temp. 
file and then calls merge to do the work.

the problem is that merge expects 3 files... where one of them should be the 
common ancestor of the other two. I did some tests with only two files --the 
one existing and the one being generated-- , using one of the files as both 
ancestor and merge,  and altough some parts were merged, some others just got 
overwritten (depending one which one you use as the original, the 
manually-written code, or the code being generated has preference in case of 
conflicts)

I think merge can do all that we need, but for it to work ok, we'd need to 
keep a copy of the old files some where so that we can compare them later... 
I know, this is not optimal, but it'd be a way.
I was thinking, everytime we generate a file, we could save a copy in the 
user's umbrello dir (compressed, of course). so the next time we generate the 
file, we merge the differences between the new model, and the user changes 
with respect to the previously generated file. -- conficts ( you change the 
parameter list manually in the file, and change it in the model as well) 
would have to be resolved manually, like in CVS--

since the files being generated are mostly just the interfaces, they are 
small, and if compressed with bizip2, the space needed would be really small.
what do you think? if you like the idea I could implement it
the only problem is that we'd need to think of a way to map the files..  maybe 
we could replicate the dir. strucutre in the umbrello dir... 

for example, if I generate the file "class.h" to the directory 
/home/luis/Desktop, then I would put a copy in 
/home/luis/.kde/../umbrello/generated/home/luis/Desktop

that would be easy, but if you move the file we'd have no file to compare 
against to... the other way I can think of, is to have a small database, 
where you map the umbrello file and generated file name to the generated 
file..
something like 
"mydesign.xmi + theclass.cpp" -->  (file containing theclass.cpp code)
this would be even easier, and we would not lose a file when it's moved, but 
if you store the map in a flat file, it could become slow after you'd 
generated a lot of files.

comments?

luis




More information about the umbrello-devel mailing list