Re: help with automatic code generation



"JoshforRefugee" <ankitks@xxxxxxxxx> writes:

This is not more of a C++/code question, it is more like OOP question.
But as I mentioned above, I am trying to figure out way to register
construction and register few method in class with my env class. Now,
my question is can I do this with macros? if yes can you someone can
give me some pseudo code or some idea on how to do this..I am actually
blank and think that it is not possible since you have to append this
methods in your env class all the time, and not sure I can do that in C
++.
so if my env already has
myA.reset();
myB.reset();
myA.execute();
myB.execute()
I have to append myC so that
myA.reset();
myB.reset();
myrC.reset()
myA.execute();
myB.execute();
myC.execute();

if macros are not right way to do this..what else are my options?

I already did web search and didn't find any help, may be looking for
wrong help. Problem is I am not educated enough about macros, so I am
hoping I can find some help here.
I mean, I don't even know if macros are right thing to start with.

-------(declarations.h)--------------
DECLARE(myA)
DECLARE(myB)
-------(source.c)--------------------
#define DECLARE(x) x.reset();
#include "declarations.h"
#define DECLARE(x) x.execute();
#include "declarations.h"
#define DECLARE(x)
-------------------------------------

Then if you add a DECLARE(myC) in declarations.h, when you recompile
source.c it will expand to what you want.

--
__Pascal Bourguignon__ http://www.informatimago.com/

"Specifications are for the weak and timid!"
.



Relevant Pages

  • Re: help with automatic code generation
    ... I am trying to figure out way to register ... methods in your env class all the time, and not sure I can do that in C ... I have to append myC so that ... if macros are not right way to do this..what else are my options? ...
    (comp.programming)
  • Re: help with automatic code generation
    ... I am trying to figure out way to register ... methods in your env class all the time, and not sure I can do that in C ... I have to append myC so that ... Problem is I am not educated enough about macros, ...
    (comp.programming)
  • Re: help with automatic code generation
    ... I am trying to figure out way to register ... methods in your env class all the time, and not sure I can do that in C ... I have to append myC so that ... You should revisit the design decision that has ...
    (comp.programming)
  • Coding style question
    ... I have question if next style of macros definitions ... prevents mistakes, when field defined for one register ... is used with incorrect register by mistake. ... is some commonly available alternative in Linux kernel ...
    (Linux-Kernel)
  • Re: Any difference of WRITE_PORT_USHORT(p, v) and directly *p=v?
    ... Generically, PORT!= REGISTER. ... On x86 architectures for example there is IO ... space (which uses ports) and memory space. ... architectures do not have IO space, and the macros both do the same thing. ...
    (microsoft.public.windowsce.embedded)