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

Ported upb to C89, for greater portability. #27

Merged
merged 1 commit into from Jun 3, 2015

Conversation

haberman
Copy link
Member

A large part of this change contains surface-level
porting, like moving variable declarations to the
top of the block.

However there are a few more substantial things too:

  • moved internal-only struct definitions to a separate
    file, for greater encapsulation and ABI compatibility.
  • removed the UPB_UPCAST macro, since it requires access
    to the internal-only struct definitions. Replaced uses
    with calls to inline, type-safe casting functions.
  • removed the UPB_DEFINE_CLASS/UPB_DEFINE_STRUCT macros.
    Class and struct definitions are now more explicit.
    The casting convenience functions have been moved into
    UPB_DECLARE_DERIVED_TYPE() and UPB_DECLARE_DERIVED_TYPE2().
  • the way that we duplicate base methods in derived types
    is also more convenient and requires less duplication.
    It is also less greppable, but hopefully that is not
    too big a problem.

I started converting comments in this CL to C89 style, but
realized it would be better to leave the rest of it for
another CL.

Compiler flags (-std=c89 -pedantic) should help to rigorously
enforce that the code is free of C99-isms.

A few functions are not available in C89 (strtoll). There
are temporary, hacky solutions in place.

@haberman haberman force-pushed the c89 branch 9 times, most recently from c487a52 to e20f48a Compare June 2, 2015 19:10
@coveralls
Copy link

Coverage Status

Coverage increased (+0.09%) to 77.7% when pulling e20f48a on haberman:c89 into 6650b3c on google:master.

A large part of this change contains surface-level
porting, like moving variable declarations to the
top of the block.

However there are a few more substantial things too:

- moved internal-only struct definitions to a separate
  file (structdefs.int.h), for greater encapsulation
  and ABI compatibility.

- removed the UPB_UPCAST macro, since it requires access
  to the internal-only struct definitions.  Replaced uses
  with calls to inline, type-safe casting functions.

- removed the UPB_DEFINE_CLASS/UPB_DEFINE_STRUCT macros.
  Class and struct definitions are now more explicit -- you
  get to see the actual class/struct keywords in the source.
  The casting convenience functions have been moved into
  UPB_DECLARE_DERIVED_TYPE() and UPB_DECLARE_DERIVED_TYPE2().

- the new way that we duplicate base methods in derived types
  is also more convenient and requires less duplication.
  It is also less greppable, but hopefully that is not
  too big a problem.

Compiler flags (-std=c89 -pedantic) should help to rigorously
enforce that the code is free of C99-isms.

A few functions are not available in C89 (strtoll).  There
are temporary, hacky solutions in place.
@coveralls
Copy link

Coverage Status

Coverage increased (+0.09%) to 77.71% when pulling 919fea4 on haberman:c89 into 6650b3c on google:master.

haberman added a commit that referenced this pull request Jun 3, 2015
Ported upb to C89, for greater portability.
@haberman haberman merged commit 97eeb57 into protocolbuffers:master Jun 3, 2015
@haberman haberman deleted the c89 branch February 18, 2016 21:18
@coveralls
Copy link

Coverage Status

Coverage increased (+21.8%) to 99.368% when pulling 919fea4 on haberman:c89 into 6650b3c on google:master.

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