Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Preprocessor disabled code-section leads to generated MockClass code #32

Open
jenisys opened this issue Jul 25, 2020 · 1 comment
Open

Comments

@jenisys
Copy link
Contributor

jenisys commented Jul 25, 2020

Describe the bug
If the C++ ClassToMock header contains code-sections that are disabled by using the C preprocessor idiom #if 0 ... #endif, the disabled code-section causes generated ClassA::method1 code in FSeamMockData.hpp:

class ClassToMock
{
public:
   ...
#if 0
    // -- DISABLED CODE SECTION: NotImplementedYet / NotSupportedYet
    void method1(UnknownClass value);
#endif

WORK-AROUND: Use comments instead of preprocessor to disable the code-section (comment it out).

To Reproduce
Described above.
If the disabled code-section causes problems with FSeam, compile-time errors are caused.

Expected behavior
Disabled code-section (especially with this simple-idiom that requires no knowledge of preprocessor-defines) should not lead to code in generated MockData.

@FreeYourSoul
Copy link
Owner

Code generation is based on the c++ header parser https://github.com/robotpy/robotpy-cppheaderparser.

It is unfortunately, a naive approach that may not give the code generator the appropriate informations to decide which preprocessor condition is true or not.

The graal of this code generator would be to use a libclang and actually not have a naive python parser but something working directly with the AST, I will update the documentation and try to think how we could solve this issue in a naive way.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants