Skip to content

More relaxed parsing of preprocessed qstr header #546

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

Merged
merged 1 commit into from
May 3, 2014

Conversation

stinos
Copy link
Contributor

@stinos stinos commented May 2, 2014

The original parsing would error out on any C declarations that are not typedefs
or extern variables. This limits what can go in mpconfig.h and mpconfigport.h,
as they are included in qstr.h. For instance even a function declaration would be
rejected and including system headers is a complete no-go.
That seems too limiting for a global config header, so makeqstrdata now
ignores everything that does not match a qstr definition.
The regex is set to match Q(.+) and just that on a line which I think should be strict enough.

The original parsing would error out on any C declarations that are not typedefs
or extern variables. This limits what can go in mpconfig.h and mpconfigport.h,
as they are included in qstr.h. For instance even a function declaration would be
rejected and including system headers is a complete no-go.
That seems too limiting for a global config header, so makeqstrdata now
ignores everything that does not match a qstr definition.
@dpgeorge
Copy link
Member

dpgeorge commented May 3, 2014

I'm am okay with this change, but have a few related comments:

  1. It's actually qstrdefs.h that is parsed by this script (not qstr.h). And it really isn't a header file as such, since qstrdefs.h is never included in any C code (.c or .h file). Only the generated version (genhdr/qstrdefs.generated.h) is. But, I can't think of a better file extension, so probably just stick with what we already have.
  2. mpconfig.h should not include any other headers except mpconfigport.h. And the latter should ideally not include system headers. I know that stmhal breaks this convention, but would be nice fix that.

dpgeorge added a commit that referenced this pull request May 3, 2014
More relaxed parsing of preprocessed qstr header
@dpgeorge dpgeorge merged commit c12242e into micropython:master May 3, 2014
@stinos
Copy link
Contributor Author

stinos commented May 3, 2014

  1. My mistake, I did mean qstrdefs.h
  2. But it is ok for mpconfigport.h to define functions (or include port specific headers defining functions), right?

@stinos stinos deleted the relax-makeqstrdata branch May 3, 2014 12:43
@dpgeorge
Copy link
Member

dpgeorge commented May 3, 2014

But it is ok for mpconfigport.h to define functions (or include port specific headers defining functions), right?

Yes. It needs to declare types and functions for inclusion in the module list, etc. So in principal it's okay for it to include headers. But so far the unix/, windows/ and stmhal/ ports don't need to include anything in mpconfigport.h.

@pfalcon
Copy link
Contributor

pfalcon commented May 3, 2014

Well, @stinos smartly worked around need to #include something in windows/mpconfigport.h, but we apparently should just accept that it's better to let port's mpconfigport.h include whatever it wants, than add #ifdef's in py/*.

@dpgeorge
Copy link
Member

dpgeorge commented May 3, 2014

we apparently should just accept that it's better to let port's mpconfigport.h include whatever it wants, than add #ifdef's in py/*.

Good idea. Leave the ugly stuff for mpconfigport.h, so that py/* is as clean as possible.

@pfalcon
Copy link
Contributor

pfalcon commented May 4, 2014

@stinos, I'm now getting "fatal: No names found, cannot describe anything." during make (unix), though it seems to build fine. Can you look into that?

@pfalcon
Copy link
Contributor

pfalcon commented May 4, 2014

Oops, please ignore, I thought it's related to makeqstrdata.py , but it's not.

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

Successfully merging this pull request may close these issues.

3 participants