Generating C++ code

Etienne Robillard animelovin at gmail.com
Wed Oct 10 06:36:12 EDT 2012


On Wed, 10 Oct 2012 11:59:50 +0200 (CEST)
Jean-Michel Pichavant <jeanmichel at sequans.com> wrote:

> Well, the C++ code will end up running on a MIPS on a SOC, unfortunately, python is not an option here. 
> The xml to C++ makes a lot of sense, because only a small part of the code is generated that way (everything related to log & fatal events). Everything else is written directly in C++.

sorry but i don't get what you mean with a "MIPS on a SOC". Is not Python well supported on MIPS ?
 
> Currently we already have a python script that translate this xml file to C++, but it's done in a way that is difficult to maintain. Basically, when parsing the xml file, it writes the generated C++ code. Something like:
> if 'blabla' in xml:
>   h_file.write("#define blabla 55", append="top")
>   c_file.write("someglobal = blabla", append="bottom")

Don't do that! This is a good example of ambigous coding (to say the least..) and you'll make C++ programmers eyes to bleed
at this. 

> This is working, but the python code is quite difficult to maintain, there's a lot of escaping going on, it's almost impossible to see the structure of the c files unless generating one and hopping it's successful. It's also quite difficult to insert code exactly where you want, because you do not know the order in which the xml trees are defined then parsed.

Its maybe working but why then are you stuck asking for help ? I suggest you either write plain C++ code or learn to 
use Python more efficiently...


> JM
> -- 
> http://mail.python.org/mailman/listinfo/python-list

Kind regards,
Etienne



More information about the Python-list mailing list