19 bool methods_parsed =
false;
20 set<unique_ptr<MemberFunction>> member_functions;
21 set<unique_ptr<StaticFunction>> static_functions;
23 bool members_parsed =
false;
24 set<unique_ptr<DataMember>> members;
25 set<unique_ptr<ConstructorFunction>> constructors;
31 CXXRecordDecl
const *
decl =
nullptr;
83 void set_error(
string const & error_message);
89 if (decl ==
nullptr) {
90 llvm::report_fatal_error(fmt::format(
"Tried to get_short_name on 'fake' WrappedClass {}", class_name).c_str());
92 return decl->getNameAsString();
119 cerr <<
"Updating wrapped class data for " << class_name << endl;
121 if (!new_name.empty()) {
122 cerr <<
"Got type alias: " << new_name << endl;
123 name_alias = new_name;
125 cerr <<
"no type alias" << endl;
127 cerr <<
"Went from " << this->annotations.
get().size() <<
" annotations to ";
129 cerr << this->annotations.
get().size() << endl;
137 return fmt::format(
"std::is_same<T, {}>::value", class_name);
167 vector<string> results;
170 results.push_back(derived_class->class_name);
175 return join(results);
179 auto i = base_types.begin();
180 while(
i != base_types.end()) {
183 base_types.erase(
i++);
188 if (base_types.size() > 1) {
189 data_error(fmt::format(
"Type {} has more than one base class - this isn't supported because javascript doesn't support MI\n", class_name));
192 return base_types.size() ? (*base_types.begin())->class_name :
"";
207 if (decl ==
nullptr) {
211 if (wrapped_class->decl == decl) {
212 return wrapped_class;
219 CompilerInstance & compiler_instance,
222 if (decl->isDependentType()) {
223 llvm::report_fatal_error(
"unpexpected dependent type");
229 if (!decl->isThisDeclarationADefinition()) {
231 cerr << class_name <<
" is not a definition - getting definition..." << endl;
232 if (!decl->hasDefinition()) {
234 llvm::report_fatal_error(fmt::format(
"{} doesn't have a definition", class_name).c_str());
237 decl = decl->getDefinition();
243 for (
auto & wrapped_class : wrapped_classes) {
245 if (wrapped_class->class_name == class_name) {
252 if (!wrapped_class->should_be_wrapped()) {
253 wrapped_class->force_no_constructors =
true;
258 return *wrapped_class;
261 auto new_wrapped_class =
new WrappedClass(decl, compiler_instance, found_method);
263 return *new_wrapped_class;
void set_error(string const &error_message)
void add_member_name(string const &name)
set< WrappedClass * > used_classes
vector< string > data_errors
static WrappedClass & get_or_insert_wrapped_class(const CXXRecordDecl *decl, CompilerInstance &compiler_instance, FOUND_METHOD found_method)
string name_alias
this is the possibly shortened javascript name of the type - not necessarily valid in generated c++ ...
std::string get_derived_classes_string(int level=0, const std::string indent="")
void data_error(const string &error)
const vector< string > get() const
std::string get_base_class_string()
bool found_method_means_wrapped()
bool should_be_wrapped() const
static vector< WrappedClass * > wrapped_classes
set< string > wrapper_extension_methods
set< string > used_static_names
set< string > include_files
bool is_template_specialization()
set< string > wrapper_custom_extensions
bool force_no_constructors
CXXConstructorDecl const * bidirectional_constructor
std::string generate_js_stub()
FOUND_METHOD found_method
int MAX_DECLARATIONS_PER_FILE
std::string make_sfinae_to_match_wrapped_class() const
set< unique_ptr< StaticFunction > > const & get_static_functions()
set< WrappedClass * > base_types
tracked base_types - if it's more than one, that's a data error because javascript only allows one ...
std::set< string > get_derived_type_includes()
void foreach_inheritance_level(function< void(WrappedClass &)> callback)
static WrappedClass * get_if_exists(const CXXRecordDecl *decl)
CXXRecordDecl const * instantiation_pattern
set< WrappedClass * > derived_types
static void insert_wrapped_class(WrappedClass *wrapped_class)
set< unique_ptr< DataMember > > & get_members()
void add_static_name(string const &name)
WrappedClass & operator=(const WrappedClass &)=delete
std::string get_canonical_name_for_decl(const TypeDecl *decl)
CXXRecordDecl const * decl
set< unique_ptr< ConstructorFunction > > const & get_constructors()
static map< const CXXRecordDecl *, string > names_for_record_decls
set< string > used_member_names
std::string get_bindings()
vector< string > base_types_to_ignore
set< unique_ptr< MemberFunction > > const & get_member_functions()
std::set< string > get_base_type_includes()
std::string join(const T &source, const std::string &between=", ", bool leading_between=false)
CompilerInstance & compiler_instance
string my_header_filename
bool ready_for_wrapping(set< WrappedClass * > dumped_classes) const
std::string get_short_name() const