MayaFlux 1.0.0
Digital-First Multimedia Processing Framework
Loading...
Searching...
No Matches

◆ run()

void MayaFlux::Reflect::Tool::RequestCollector::run ( const clang::ast_matchers::MatchFinder::MatchResult & result)
override

Definition at line 176 of file Collector.cpp.

177{
178 const auto* alias = result.Nodes.getNodeAs<clang::TypeAliasDecl>(request_id);
179 if (alias == nullptr) {
180 return;
181 }
182
183 ++m_matched;
184
185 const clang::SourceManager& manager = *result.SourceManager;
186 const clang::SourceLocation location = manager.getExpansionLoc(alias->getBeginLoc());
187 if (!location.isValid() || manager.isInSystemHeader(location)) {
188 ++m_skipped;
189 return;
190 }
191
192 const std::filesystem::path header = real_path(manager.getFilename(location));
193 const unsigned line = manager.getSpellingLineNumber(location);
194 const std::string where = header.string() + ":" + std::to_string(line) + ": ";
195 const std::string spelling = alias->getUnderlyingType().getAsString();
196
197 if (!alias->getDeclContext()->getRedeclContext()->isFileContext()) {
198 m_errors.push_back(where + "MF_DESCRIBE must appear at namespace scope");
199 return;
200 }
201
202 const clang::CXXRecordDecl* record = alias->getUnderlyingType()->getAsCXXRecordDecl();
203 if (record != nullptr) {
204 record = record->getDefinition();
205 }
206 if (record == nullptr) {
207 m_errors.push_back(where + spelling + ": request must name a complete struct or class");
208 return;
209 }
210 if (llvm::isa<clang::ClassTemplateSpecializationDecl>(record) || record->isUnion() || !nameable(record)) {
211 m_errors.push_back(where + spelling + ": template, union, anonymous and inaccessible records are unsupported");
212 return;
213 }
214
215 unsigned anchor = line;
216 const clang::NamespaceDecl* outermost = nullptr;
217 for (const clang::DeclContext* context = alias->getLexicalDeclContext();
218 context != nullptr && !context->isTranslationUnit(); context = context->getLexicalParent()) {
219 if (const auto* space = llvm::dyn_cast<clang::NamespaceDecl>(context)) {
220 outermost = space;
221 }
222 }
223 if (outermost != nullptr && outermost->getRBraceLoc().isValid()) {
224 anchor = manager.getSpellingLineNumber(manager.getExpansionLoc(outermost->getRBraceLoc()));
225 }
226
227 RecordRequest request;
228 request.name = record->getQualifiedNameAsString();
229 request.line = anchor;
230
231 std::vector<const clang::CXXRecordDecl*> nested;
232 std::string error;
233 if (!collect_members(record, request.members, nested, error)) {
234 m_errors.push_back(where + request.name + ": " + error);
235 return;
236 }
237 if (!store(header, std::move(request), where)) {
238 return;
239 }
240 for (const clang::CXXRecordDecl* child : nested) {
241 if (file_of(manager, child->getLocation()) == header) {
242 describe_nested(child, header, anchor, manager);
243 }
244 }
245}
std::vector< std::string > m_errors
Definition Collector.hpp:37
bool store(const std::filesystem::path &header, RecordRequest request, const std::string &where)
void describe_nested(const clang::CXXRecordDecl *record, const std::filesystem::path &header, unsigned line, const clang::SourceManager &manager)
void error(Component component, Context context, std::source_location location, std::string_view message)
Log an error message and optionally throw an exception.
Vruta::SoundRoutine line(float start_value, float end_value, float duration_seconds, uint32_t step_duration, bool restartable)
Creates a continuous interpolation generator between two values over time.
Definition Tasks.cpp:60
std::pair< std::shared_ptr< Kriya::BufferPipeline >, std::shared_ptr< Buffers::AudioBuffer > > record(const std::shared_ptr< Kakshya::DynamicSoundStream > &stream, uint32_t input_channel, double seconds, std::optional< uint32_t > monitor, uint32_t channel)
Record a live input channel into a stream for a number of seconds.
Definition Rigs.cpp:262

References describe_nested(), MayaFlux::Reflect::Tool::RecordRequest::line, m_errors, m_matched, m_skipped, MayaFlux::Reflect::Tool::RecordRequest::members, MayaFlux::Reflect::Tool::RecordRequest::name, MayaFlux::record(), and store().

Here is the call graph for this function: