Split A Macro (mockpp)

S

Steven Woody

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)
 
V

Victor Bazarov

Steven said:
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
 
S

Steven Woody

Victor Bazarov said:
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)
 
V

Victor Bazarov

Steven said:
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...
 
S

Steven Woody

Victor Bazarov said:
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.
If 'myDo' is a member of a class, you don't have a choice. A declaration
and an initialiser _have_to_ be separate.



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)
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,764
Messages
2,569,567
Members
45,041
Latest member
RomeoFarnh

Latest Threads

Top