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

Convert macros in op.h to static inline functions. #32

Open
schwern opened this issue Dec 2, 2015 · 0 comments
Open

Convert macros in op.h to static inline functions. #32

schwern opened this issue Dec 2, 2015 · 0 comments

Comments

@schwern
Copy link
Contributor

schwern commented Dec 2, 2015

Same as #18, but for the macros in op.h.

The main difference is most of these are publicly documented. Even if they're not documented, some 3rd party Perl module might be using them. That means _the name, signature and functionality cannot change_.

To preserve their visibility, and to allow inlining...

  • Put the new function directly in op.h.
  • Declare it static inline.
  • Retain the exact name and signature.
    • If you you think you can improve the code, write a compatibility wrapper.
  • Change references to "macro" in the api documentation to "function".
    • The documentation is =for apidoc in op.h.
  • (Optional) Move the documentation to be above the function

For example...

#define OP_TYPE_IS(o, type) ((o) && (o)->op_type == (type))

Is replaced, _directly in op.h_, with...

static inline bool OP_TYPE_IS(OP *o, Optype type) {
    return o && o->op_type == type;
}

The documentation is changed to remove the mention of a macro...

=for apidoc Am|bool|OP_TYPE_IS|OP *o|Optype type
Returns true if the given OP is not a NULL pointer
and if it is of the given type.

The negation of this, C<OP_TYPE_ISNT> is also available
as well as C<OP_TYPE_IS_NN> and C<OP_TYPE_ISNT_NN> which elide
the NULL pointer check.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant