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

◆ run()

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

Definition at line 254 of file SignatureCollector.cpp.

255{
256 const auto* record = result.Nodes.getNodeAs<clang::CXXRecordDecl>(record_id);
257 if (record == nullptr || record->getIdentifier() == nullptr || record->isDependentContext()
258 || !m_simple_names.contains(record->getName().str())) {
259 return;
260 }
261
262 const std::string qualified = record->getQualifiedNameAsString();
263 const auto entry = std::ranges::find(m_entries, qualified, &SignatureEntry::type_name);
264 if (entry == m_entries.end()) {
265 return;
266 }
267 std::optional<SignatureClass>& slot = m_found[static_cast<std::size_t>(entry - m_entries.begin())];
268 if (slot) {
269 return;
270 }
271
272 const clang::ASTContext& context = *result.Context;
273 const clang::SourceManager& manager = *result.SourceManager;
274
275 SignatureClass info;
276 info.entry = *entry;
277 info.entry.header = file_of(manager, record->getLocation());
278 info.abstract = record->isAbstract();
279 if (info.abstract) {
280 slot = std::move(info);
281 return;
282 }
283
284 const std::set<std::string> nested = nested_names(record);
285 HeaderCollector headers(manager, m_source_root, m_excluded, info.includes);
286
287 for (const clang::Decl* declaration : record->decls()) {
288 if (const auto* declared_template = llvm::dyn_cast<clang::FunctionTemplateDecl>(declaration)) {
289 if (llvm::isa<clang::CXXConstructorDecl>(declared_template->getTemplatedDecl())) {
290 m_errors.push_back(entry->name + ": constructor template needs explicit generator support");
291 return;
292 }
293 continue;
294 }
295 const auto* constructor = llvm::dyn_cast<clang::CXXConstructorDecl>(declaration);
296 if (constructor == nullptr || constructor->isImplicit() || constructor->isDeleted()
297 || constructor->getAccess() != clang::AS_public) {
298 continue;
299 }
300
301 ConstructorSignature built;
302 unsigned number = 0;
303 for (const clang::ParmVarDecl* parameter : constructor->parameters()) {
304 SignatureParameter item;
305 item.type = spell(parameter->getType(), context);
306 if (item.type.find("(*)") != std::string::npos || item.type.find("(&)") != std::string::npos) {
307 m_errors.push_back(entry->name + ": cannot spell parameter " + std::to_string(number)
308 + " as a method parameter");
309 return;
310 }
311 item.name = parameter->getNameAsString();
312 if (item.name.empty()) {
313 item.name = "arg" + std::to_string(number);
314 }
315
316 headers.add_type(parameter->getType());
317 if (parameter->hasDefaultArg() && !parameter->hasUnparsedDefaultArg()
318 && !parameter->hasUninstantiatedDefaultArg()) {
319 const std::string text = argument_text(parameter, context);
320 if (text.empty()) {
321 m_errors.push_back(entry->name + ": cannot recover default for parameter " + std::to_string(number));
322 return;
323 }
324 item.default_value = qualify_nested(text, relative_to_root(qualified), nested);
325 DefaultArgumentVisitor visitor(headers);
326 visitor.TraverseStmt(const_cast<clang::Expr*>(parameter->getDefaultArg()));
327 }
328 built.parameters.push_back(std::move(item));
329 ++number;
330 }
331 info.constructors.push_back(std::move(built));
332 }
333
334 if (info.constructors.empty()) {
335 m_errors.push_back(entry->name + ": no public source-declared constructor found");
336 return;
337 }
338 slot = std::move(info);
339}
std::unordered_set< std::string > m_simple_names
std::vector< std::optional< SignatureClass > > m_found
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 MayaFlux::Reflect::Tool::SignatureClass::abstract, MayaFlux::Reflect::Tool::SignatureClass::constructors, MayaFlux::Reflect::Tool::SignatureParameter::default_value, MayaFlux::Reflect::Tool::SignatureClass::entry, MayaFlux::Reflect::Tool::SignatureEntry::header, MayaFlux::Reflect::Tool::SignatureClass::includes, m_entries, m_errors, m_excluded, m_found, m_simple_names, m_source_root, MayaFlux::Reflect::Tool::SignatureParameter::name, MayaFlux::Reflect::Tool::ConstructorSignature::parameters, MayaFlux::record(), MayaFlux::Reflect::Tool::SignatureParameter::type, and MayaFlux::Reflect::Tool::SignatureEntry::type_name.

Here is the call graph for this function: