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

[Backport release-2.18] Add an aspect template argument to class CAPIFunction. (#4430) #4463

Merged
merged 1 commit into from
Oct 26, 2023

Conversation

KiterLuc
Copy link
Contributor

@KiterLuc KiterLuc commented Oct 26, 2023

Backport ea7e8ef from #4430.


TYPE: NO_HISTORY

This PR makes two changes to the template signature of `class
CAPIFunction`. The central one is to add an aspect argument that can
provide hooks into `CAPIFunction::function`. In this initial version
there's a single aspect point (the aspect member function `call`) that
is only an observer. The `call` of the default aspect does nothing. The
second change in template signature is to infer the return value of the
wrapper function and to suppress return statements if that type is
`void`. This allows the elimination of subsidiary wrapper for `void`
functions to give them a (constant) return value.

Tests for the aspect implement `class LoggingAspect`, a primitive
call-logger sufficient for testing, and provide an override header to
activate it. The override header also generates a traits class for each
C API implementation function that provides data for `LoggingAspect`.
These elements are exercised by two new test runners that share a common
set of tests; only the results differ depending on whether the hook is
active or not.

In order to automatically generate metadata for API functions, the PR
introduces a set of macros to define the C API interface functions.
These functions are already essentially boilerplate, but they cannot be
defined with function templates because they must have "C" linkage. The
macros provide a pair of macro hooks for generating code either before
or after the function definition.

---
TYPE: IMPROVEMENT
DESC: Add an aspect template argument to `class CAPIFunction`

(cherry picked from commit ea7e8ef)
@KiterLuc KiterLuc merged commit e65202e into release-2.18 Oct 26, 2023
@KiterLuc KiterLuc deleted the backport-4430-to-release-2.18 branch October 26, 2023 14:11
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.

2 participants