v8toolkit  0.0.1
Utility library for embedding V8 Javascript engine in a c++ program
annotations.cpp
Go to the documentation of this file.
1 
2 #include "annotations.h"
3 #include "helper_functions.h"
4 
5 map<const ClassTemplateDecl *, Annotations> Annotations::annotations_for_class_templates;
6 
7 // any annotations on 'using' statements should be applied to the actual CXXRecordDecl being aliased (the right side)
8 map<const CXXRecordDecl *, Annotations> Annotations::annotations_for_record_decls;
9 
10 
11 // if a template instantiation is named with a 'using' statement, use that alias for the type isntead of the template/class name itself
12 // this stops them all from being named the same thing - aka CppFactory, CppFactory, ... instead of MyThingFactory, MyOtherThingFactory, ...
13 map<const CXXRecordDecl *, string> Annotations::names_for_record_decls;
14 
15 Annotations::Annotations(const CXXRecordDecl *decl_to_check) {
16  auto name = get_canonical_name_for_decl(decl_to_check);
17  get_annotations_for_decl(decl_to_check);
18  cerr << "Making annotations object for " << name << endl;
19  if (auto spec_decl = dyn_cast<ClassTemplateSpecializationDecl>(decl_to_check)) {
20  cerr << fmt::format("{} is a template, getting any tmeplate annotations available", name) << endl;
21  cerr << annotations_for_class_templates[spec_decl->getSpecializedTemplate()].get().size()
22  << " annotations available" << endl;
23  merge(annotations_for_class_templates[spec_decl->getSpecializedTemplate()]);
24  } else {
25  cerr << "Not a template" << endl;
26  }
27 
28 }
static map< const ClassTemplateDecl *, Annotations > annotations_for_class_templates
Definition: annotations.h:80
void merge(const Annotations &other)
Definition: annotations.h:71
std::string get_canonical_name_for_decl(const TypeDecl *decl)
static map< const CXXRecordDecl *, string > names_for_record_decls
Definition: annotations.h:88
static map< const CXXRecordDecl *, Annotations > annotations_for_record_decls
Definition: annotations.h:83
Annotations()=default