MayaFlux 1.0.0
Digital-First Multimedia Processing Framework
Loading...
Searching...
No Matches
FunctionCollector.hpp
Go to the documentation of this file.
1#pragma once
2
3#include "FunctionRequest.hpp"
4
6
7/**
8 * @class FunctionCollector
9 * @brief Turns each MF_DESCRIBE_FUNCTION variable in the scanned translation unit into a FunctionRequest.
10 *
11 * Attach it to a MatchFinder, run the finder, then read requests() and errors(). Requests are
12 * grouped by the header holding the marker. A function that is a member, still a template, or
13 * has a parameter without a name is an error, since a parameter name is what a caller refers to.
14 *
15 * The scan switches sidecars off, so a header that holds requests must not use what its own
16 * sidecar generates. Keep the described functions in a header of their own.
17 */
18class FunctionCollector : public clang::ast_matchers::MatchFinder::MatchCallback {
19public:
20 /** @brief Registers the matcher for the marker variables on @p finder. */
21 void attach(clang::ast_matchers::MatchFinder& finder);
22
23 void run(const clang::ast_matchers::MatchFinder::MatchResult& result) override;
24
25 [[nodiscard]] const FunctionMap& requests() const noexcept { return m_requests; }
26 [[nodiscard]] const std::vector<std::string>& errors() const noexcept { return m_errors; }
27
28 /** @brief Marker variables the matcher reached, before any filtering. */
29 [[nodiscard]] std::size_t matched() const noexcept { return m_matched; }
30
31private:
33 std::vector<std::string> m_errors;
34 std::size_t m_matched {};
35};
36
37}
const FunctionMap & requests() const noexcept
void attach(clang::ast_matchers::MatchFinder &finder)
Registers the matcher for the marker variables on finder.
std::size_t matched() const noexcept
Marker variables the matcher reached, before any filtering.
const std::vector< std::string > & errors() const noexcept
Turns each MF_DESCRIBE_FUNCTION variable in the scanned translation unit into a FunctionRequest.
void run()
Definition main.cpp:21
std::map< std::filesystem::path, HeaderFunctions > FunctionMap