Split A Macro (mockpp)

Discussion in 'C++' started by Steven Woody, Oct 29, 2005.

  1. Steven Woody

    Steven Woody Guest

    i am using a third-party library (mockpp), which comes in many macro for
    use. for example

    MOCKPP_CHAINER_FOR_EXT(MyMock, do, ext) myDo (&myMock);

    it declared and initialized a 'myDo' object in a combined form. but i want to
    seperate the declaration from initialization for some purpose. what will the
    syntax likely be?


    --
    steven woody (id: narke)

    Angelica Bell: What happens to us when we die?
    Virginia Woolf: ... We return to the place we came from.
    Angelica Bell: I don't remember where I came from.
    Virginia Woolf: Neither do I.

    - The Hours (2002)
     
    Steven Woody, Oct 29, 2005
    #1
    1. Advertising

  2. Steven Woody wrote:
    > i am using a third-party library (mockpp), which comes in many macro
    > for
    > use. for example
    >
    > MOCKPP_CHAINER_FOR_EXT(MyMock, do, ext) myDo (&myMock);
    >
    > it declared and initialized a 'myDo' object in a combined form. but i
    > want to seperate the declaration from initialization for some
    > purpose. what will the syntax likely be?


    Have you tried looking at the headers to see how the macro is defined?
    That would help, you know...

    Try dropping the parentheses with the address of the 'myMock' thing.

    MOCKPP_CHAINRE_FOR_EXT(MyMock, do, ext) myDo;

    (that might create a declaration). If 'myDo' is a member, you will
    need to initialise it in the c-tor's initialiser list. If it's not,
    there is no initialisation, only assignment, after this.

    V
     
    Victor Bazarov, Oct 29, 2005
    #2
    1. Advertising

  3. Steven Woody

    Steven Woody Guest

    "Victor Bazarov" <> writes:

    > Steven Woody wrote:
    >> i am using a third-party library (mockpp), which comes in many macro
    >> for
    >> use. for example
    >>
    >> MOCKPP_CHAINER_FOR_EXT(MyMock, do, ext) myDo (&myMock);
    >>
    >> it declared and initialized a 'myDo' object in a combined form. but i
    >> want to seperate the declaration from initialization for some
    >> purpose. what will the syntax likely be?

    >
    > Have you tried looking at the headers to see how the macro is defined?
    > That would help, you know...
    >
    > Try dropping the parentheses with the address of the 'myMock' thing.
    >
    > MOCKPP_CHAINRE_FOR_EXT(MyMock, do, ext) myDo;
    >
    > (that might create a declaration). If 'myDo' is a member, you will
    > need to initialise it in the c-tor's initialiser list. If it's not,
    > there is no initialisation, only assignment, after this.
    >


    MOCKPP_CHAINER_FOR_EXT(...) is a #define, the above expanded to:

    MyMock::FooBar myDo(&myMock);

    so it seems clear the FooBar has to be constructed with a &myMock. if i
    delcared it and initialize later, then the FooBar has to provide some method
    leting me set in the &myMock. but i failed finding this information because
    the library is toooooo complex and full of macro definitions.

    --
    steven woody (id: narke)

    How Far You Fall Doesn't Matter, It's How You Land

    - Haine, La (1995)
     
    Steven Woody, Oct 29, 2005
    #3
  4. Steven Woody wrote:
    > "Victor Bazarov" <> writes:
    >
    >> Steven Woody wrote:
    >>> i am using a third-party library (mockpp), which comes in many macro
    >>> for
    >>> use. for example
    >>>
    >>> MOCKPP_CHAINER_FOR_EXT(MyMock, do, ext) myDo (&myMock);
    >>>
    >>> it declared and initialized a 'myDo' object in a combined form. but
    >>> i want to seperate the declaration from initialization for some
    >>> purpose. what will the syntax likely be?

    >>
    >> Have you tried looking at the headers to see how the macro is
    >> defined? That would help, you know...
    >>
    >> Try dropping the parentheses with the address of the 'myMock' thing.
    >>
    >> MOCKPP_CHAINRE_FOR_EXT(MyMock, do, ext) myDo;
    >>
    >> (that might create a declaration). If 'myDo' is a member, you will
    >> need to initialise it in the c-tor's initialiser list. If it's not,
    >> there is no initialisation, only assignment, after this.
    >>

    >
    > MOCKPP_CHAINER_FOR_EXT(...) is a #define, the above expanded to:
    >
    > MyMock::FooBar myDo(&myMock);


    How do you know? Did you look at the preprocessor output? What do
    'do' and 'ext' mean?

    > so it seems clear the FooBar has to be constructed with a &myMock. if
    > i delcared it and initialize later, then the FooBar has to provide
    > some method leting me set in the &myMock.


    If 'myDo' is a member of a class, you don't have a choice. A declaration
    and an initialiser _have_to_ be separate.

    > but i failed finding this
    > information because the library is toooooo complex and full of macro
    > definitions.



    My crystal ball is under the weather today, so I can't help you look it
    up either. Sorry...
     
    Victor Bazarov, Oct 29, 2005
    #4
  5. Steven Woody

    Steven Woody Guest

    "Victor Bazarov" <> writes:

    > Steven Woody wrote:
    >> "Victor Bazarov" <> writes:
    >>
    >>> Steven Woody wrote:
    >>>> i am using a third-party library (mockpp), which comes in many macro
    >>>> for
    >>>> use. for example
    >>>>
    >>>> MOCKPP_CHAINER_FOR_EXT(MyMock, do, ext) myDo (&myMock);
    >>>>
    >>>> it declared and initialized a 'myDo' object in a combined form. but
    >>>> i want to seperate the declaration from initialization for some
    >>>> purpose. what will the syntax likely be?
    >>>
    >>> Have you tried looking at the headers to see how the macro is
    >>> defined? That would help, you know...
    >>>
    >>> Try dropping the parentheses with the address of the 'myMock' thing.
    >>>
    >>> MOCKPP_CHAINRE_FOR_EXT(MyMock, do, ext) myDo;
    >>>
    >>> (that might create a declaration). If 'myDo' is a member, you will
    >>> need to initialise it in the c-tor's initialiser list. If it's not,
    >>> there is no initialisation, only assignment, after this.
    >>>

    >>
    >> MOCKPP_CHAINER_FOR_EXT(...) is a #define, the above expanded to:
    >>
    >> MyMock::FooBar myDo(&myMock);

    >
    > How do you know? Did you look at the preprocessor output? What do
    > 'do' and 'ext' mean?


    i checked the headers for the difinition. MyMock is a mock class which was
    gernerated to mocking a real object. so, the 'do' is a mehtod in the interface
    of the real class. MOCKPP_CHAINER_FOR_EXE(...) used to create a object which
    control how the mock object will behavior when the 'do' is called. and 'ext' is
    just a text extension to prevent any possible name conflicts.

    >
    >> so it seems clear the FooBar has to be constructed with a &myMock. if
    >> i delcared it and initialize later, then the FooBar has to provide
    >> some method leting me set in the &myMock.

    >
    > If 'myDo' is a member of a class, you don't have a choice. A declaration
    > and an initialiser _have_to_ be separate.
    >
    >> but i failed finding this
    >> information because the library is toooooo complex and full of macro
    >> definitions.

    >
    >
    > My crystal ball is under the weather today, so I can't help you look it
    > up either. Sorry...
    >


    might there are someone who know the MOCKPP ...


    --
    steven woody (id: narke)

    Pepper...is hot and scorches, just like the sun

    - Politiki kouzina (2003)
     
    Steven Woody, Oct 30, 2005
    #5
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Dead RAM
    Replies:
    20
    Views:
    1,116
    John Harrison
    Jul 14, 2004
  2. D Senthil Kumar

    macro name from macro?

    D Senthil Kumar, Sep 20, 2003, in forum: C Programming
    Replies:
    1
    Views:
    582
    Jack Klein
    Sep 21, 2003
  3. sounak

    to get macro name from macro value

    sounak, Nov 22, 2005, in forum: C Programming
    Replies:
    17
    Views:
    504
    Mark McIntyre
    Nov 22, 2005
  4. Patrick Kowalzick
    Replies:
    5
    Views:
    477
    Patrick Kowalzick
    Mar 14, 2006
  5. Mike Manilone

    macro inside macro

    Mike Manilone, Oct 3, 2011, in forum: C Programming
    Replies:
    8
    Views:
    462
    Mike Manilone
    Oct 6, 2011
Loading...

Share This Page