Created
November 8, 2012 08:22
-
-
Save michahoiting/4037531 to your computer and use it in GitHub Desktop.
Concept of using variable arguments operator '...' with limit functionality in the Fake Function Framework
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/******************* | |
* | |
* fff.h | |
* | |
*******************/ | |
#define DECLARE_FAKE_VOID_FUNC3_VARARG(FUNCNAME, ARG0_TYPE, ARG1_TYPE, VARARG2_TYPE) \ | |
EXTERN_C \ | |
typedef struct FUNCNAME##_Fake { \ | |
DECLARE_ARG(ARG0_TYPE, 0, FUNCNAME) \ | |
DECLARE_ARG(ARG1_TYPE, 1, FUNCNAME) \ | |
/* DECLARE_ARG(VARARG2_TYPE, 2, FUNCNAME) */ \ | |
DECLARE_ALL_FUNC_COMMON \ | |
void(*custom_fake)(ARG0_TYPE arg0, ARG1_TYPE arg1 /*, VARARG2_TYPE arg2 */); \ | |
} FUNCNAME##_Fake;\ | |
extern FUNCNAME##_Fake FUNCNAME##_fake;\ | |
void FUNCNAME##_reset(); \ | |
END_EXTERN_C \ | |
#define DEFINE_FAKE_VOID_FUNC3_VARARG(FUNCNAME, ARG0_TYPE, ARG1_TYPE, VARARG2_TYPE) \ | |
EXTERN_C \ | |
FUNCNAME##_Fake FUNCNAME##_fake;\ | |
void FUNCNAME(ARG0_TYPE arg0, ARG1_TYPE arg1, VARARG2_TYPE arg2){ \ | |
SAVE_ARG(FUNCNAME, 0); \ | |
SAVE_ARG(FUNCNAME, 1); \ | |
/* SAVE_ARG(FUNCNAME, 2); */ \ | |
if(ROOM_FOR_MORE_HISTORY(FUNCNAME)){\ | |
SAVE_ARG_HISTORY(FUNCNAME, 0); \ | |
SAVE_ARG_HISTORY(FUNCNAME, 1); \ | |
/* SAVE_ARG_HISTORY(FUNCNAME, 2); */ \ | |
}\ | |
else{\ | |
HISTORY_DROPPED(FUNCNAME);\ | |
}\ | |
INCREMENT_CALL_COUNT(FUNCNAME); \ | |
REGISTER_CALL(FUNCNAME); \ | |
if (FUNCNAME##_fake.custom_fake) FUNCNAME##_fake.custom_fake(arg0, arg1 /*, vararg2 */); \ | |
} \ | |
DEFINE_RESET_FUNCTION(FUNCNAME) \ | |
END_EXTERN_C \ | |
#define FAKE_VOID_FUNC3_VARARG(FUNCNAME, ARG0_TYPE, ARG1_TYPE, VARARG2_TYPE) \ | |
DECLARE_FAKE_VOID_FUNC3_VARARG(FUNCNAME, ARG0_TYPE, ARG1_TYPE, VARARG2_TYPE) \ | |
DEFINE_FAKE_VOID_FUNC3_VARARG(FUNCNAME, ARG0_TYPE, ARG1_TYPE, VARARG2_TYPE) \ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/******************* | |
* | |
* global_fakes.c | |
* | |
*******************/ | |
DECLARE_FAKE_VOID_FUNC3_VARARG( | |
trace, | |
const char * /* func_name */, | |
const char * /* format */, | |
...); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/******************* | |
* | |
* global_fakes.h | |
* | |
*******************/ | |
DECLARE_FAKE_VOID_FUNC3_VARARG( | |
trace, | |
const char * /* func_name */, | |
const char * /* format */, | |
...); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment