Generating types



I'm thinking about a Tny-type generator. It should have features like:

   o. Generate a type that will inherit an existing tinymail type and
      implement zero or more interfaces

   o. Generate a type that will implement one or more interfaces

The generator would read the .h files of the interfaces and would create
a _info structure, methods, etc etc and would set things like the
inheritance right.

I know generators sound icky, GObject code however *is* icky do to all
of it manually over and over again. Tinymail is a framework that is
suppose to help the developer. Not to burden him with GObject crap.

I'm not into C macros. C macros and therefore also cpp are pure evil,
bad, insanity, sick, depressing, etc etc. Let us not make it worse by
doing template-like things with ###cpp ###Mytype(o)(x). I, for example,
really don't like GObject boilerplate-code macros. It's sickening to
read such code (try it).

Problems with all of the ones that I have seen: 

   o. Very difficult to implement more than one interface (if the macro
      junk sub language supports interfaces to start with) or (as said)
      simply impossible (which makes it per definition unusable)

   o. Extremely, insanely, very difficult to debug (incorrect #line
      usage)

   o. Doesn't make it more easy to read the code (it's not because there
      are less lines of code, that it's also more easy to read)

   o. Adds an extra dependency on cpp 

   o. Needs a fancy cpp with fancy features. Therefore: makes it more
      difficult to target alternative compilers and environments


That's why I'm less icky about generating code than I am about creating
a bunch of C macros that will make GObject suck even more: The generated
code will have NONE of the problems above. Since you are not going to
regenerate types .. it allows the developer to change everything
including indentation and other whatevers he wants to change (generate
once, then start coding).

The generator can be a small script that doesn't influence the code
itself at all.

ps. If you want to see what the result of macros on top of code gives,
check out m4, autotools and Makefile.am files. One word for it: sucks.


Anyway ... who's interested in creating such code generating scripts?



-- 
Philip Van Hoof, software developer
home: me at pvanhoof dot be
gnome: pvanhoof at gnome dot org
work: vanhoof at x-tend dot be
blog: http://pvanhoof.be/blog




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]