v8toolkit  0.0.1
Utility library for embedding V8 Javascript engine in a c++ program
Classes | Enumerations | Functions | Variables
helper_functions.h File Reference
#include <map>
#include <vector>
#include <string>
#include <sstream>
#include <iostream>
#include "clang.h"
#include "annotations.h"
Include dependency graph for helper_functions.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

class  PrintLoggingGuard
 

Enumerations

enum  FOUND_METHOD {
  FOUND_UNSPECIFIED = 0, FOUND_ANNOTATION, FOUND_INHERITANCE, FOUND_GENERATED,
  FOUND_BASE_CLASS, FOUND_NEVER_WRAP
}
 
enum  EXPORT_TYPE {
  EXPORT_UNSPECIFIED = 0, EXPORT_NONE, EXPORT_SOME, EXPORT_EXCEPT,
  EXPORT_ALL
}
 

Functions

bool has_wrapped_class (const CXXRecordDecl *decl)
 
EXPORT_TYPE get_export_type (const NamedDecl *decl, EXPORT_TYPE previous=EXPORT_UNSPECIFIED)
 
template<class T >
std::string join (const T &source, const std::string &between=", ", bool leading_between=false)
 
void data_error (const string &error)
 
void data_warning (const string &warning)
 
QualType get_plain_type (QualType qual_type)
 
std::string get_include_for_type_decl (CompilerInstance &compiler_instance, const TypeDecl *type_decl)
 
void print_vector (const vector< string > &vec, const string &header="", const string &indentation="", bool ignore_empty=true)
 
std::string get_source_for_source_range (SourceManager &sm, SourceRange source_range)
 
std::string get_canonical_name_for_decl (const TypeDecl *decl)
 
bool is_good_record_decl (const CXXRecordDecl *decl)
 
std::string get_include_string_for_fileid (CompilerInstance &compiler_instance, FileID &file_id)
 
std::string get_method_parameters (CompilerInstance &compiler_instance, WrappedClass &wrapped_class, const CXXMethodDecl *method, bool add_leading_comma=false, bool insert_variable_names=false, const string &annotation="")
 
void update_wrapped_class_for_type (WrappedClass &wrapped_class, QualType qual_type)
 
void write_classes (int file_count, vector< WrappedClass * > &classes, bool last_one)
 
vector< QualType > get_method_param_qual_types (CompilerInstance &compiler_instance, const CXXMethodDecl *method, string const &annotation="")
 
vector< string > generate_variable_names (vector< QualType > qual_types, bool with_std_move=false)
 
void print_specialization_info (const CXXRecordDecl *decl)
 
std::string get_type_string (QualType qual_type, const std::string &indentation="")
 
template<class Callback >
void foreach_constructor (const CXXRecordDecl *klass, Callback &&callback, const std::string &annotation="")
 
std::string get_method_string (CompilerInstance &compiler_instance, WrappedClass &wrapped_class, const CXXMethodDecl *method)
 
void generate_javascript_stub (string const &)
 
void generate_bidirectional_classes (CompilerInstance &compiler_instance)
 
void generate_bindings ()
 

Variables

map< string, string > cpp_to_js_type_conversions
 
vector< string > base_types_to_ignore
 
int print_logging
 
map< string, string > static_method_renames
 
map< string, int > template_instantiations
 
vector< string > types_to_ignore_regex
 
std::vector< std::string > used_constructor_names
 
int matched_classes_returned
 
vector< string > data_warnings
 
vector< string > data_errors
 
std::string js_api_header
 
vector< string > never_include_for_any_file
 
string header_for_every_class_wrapper_file
 
vector< string > includes_for_every_class_wrapper_file
 

Enumeration Type Documentation

Enumerator
FOUND_UNSPECIFIED 
FOUND_ANNOTATION 
FOUND_INHERITANCE 
FOUND_GENERATED 
FOUND_BASE_CLASS 
FOUND_NEVER_WRAP 

Definition at line 39 of file helper_functions.h.

Enumerator
EXPORT_UNSPECIFIED 
EXPORT_NONE 
EXPORT_SOME 
EXPORT_EXCEPT 
EXPORT_ALL 

Definition at line 49 of file helper_functions.h.

Function Documentation

bool has_wrapped_class ( const CXXRecordDecl *  decl)

Definition at line 429 of file class_parser.cpp.

References get_canonical_name_for_decl().

Referenced by update_wrapped_class_for_type().

Here is the call graph for this function:

Here is the caller graph for this function:

EXPORT_TYPE get_export_type ( const NamedDecl *  decl,
EXPORT_TYPE  previous = EXPORT_UNSPECIFIED 
)
template<class T >
std::string join ( const T &  source,
const std::string &  between = ", ",
bool  leading_between = false 
)
void data_error ( const string &  error)
void data_warning ( const string &  warning)

Definition at line 208 of file helper_functions.cpp.

Referenced by ClassFunction::ClassFunction(), and ClassFunction::ParameterInfo::ParameterInfo().

Here is the caller graph for this function:

QualType get_plain_type ( QualType  qual_type)

Definition at line 213 of file helper_functions.cpp.

std::string get_include_for_type_decl ( CompilerInstance &  compiler_instance,
const TypeDecl *  type_decl 
)

Definition at line 277 of file class_parser.cpp.

References get_include_for_source_location().

Referenced by update_wrapped_class_for_type(), and WrappedClass::WrappedClass().

Here is the call graph for this function:

Here is the caller graph for this function:

void print_vector ( const vector< string > &  vec,
const string &  header = "",
const string &  indentation = "",
bool  ignore_empty = true 
)

Definition at line 200 of file class_parser.cpp.

Referenced by ClassFunction::TypeInfo::get_jsdoc_type_name(), print_specialization_info(), and WrappedClass::WrappedClass().

Here is the caller graph for this function:

std::string get_source_for_source_range ( SourceManager &  sm,
SourceRange  source_range 
)

Definition at line 295 of file class_parser.cpp.

References print_logging.

Referenced by ClassFunction::ClassFunction(), get_default_argument_values(), and ClassFunction::ParameterInfo::ParameterInfo().

Here is the caller graph for this function:

std::string get_canonical_name_for_decl ( const TypeDecl *  decl)
bool is_good_record_decl ( const CXXRecordDecl *  decl)

Definition at line 221 of file class_parser.cpp.

References is_good_record_decl().

Referenced by is_good_record_decl(), and ClassHandler::run().

Here is the call graph for this function:

Here is the caller graph for this function:

std::string get_include_string_for_fileid ( CompilerInstance &  compiler_instance,
FileID &  file_id 
)

Definition at line 244 of file class_parser.cpp.

Referenced by get_include_for_source_location(), and ClassHandler::run().

Here is the caller graph for this function:

std::string get_method_parameters ( CompilerInstance &  compiler_instance,
WrappedClass wrapped_class,
const CXXMethodDecl *  method,
bool  add_leading_comma = false,
bool  insert_variable_names = false,
const string &  annotation = "" 
)
void update_wrapped_class_for_type ( WrappedClass wrapped_class,
QualType  qual_type 
)
void write_classes ( int  file_count,
vector< WrappedClass * > &  classes,
bool  last_one 
)

Definition at line 14 of file ast_action.cpp.

References header_for_every_class_wrapper_file, includes_for_every_class_wrapper_file, never_include_for_any_file, and print_logging.

Referenced by generate_bindings().

Here is the caller graph for this function:

vector<QualType> get_method_param_qual_types ( CompilerInstance &  compiler_instance,
const CXXMethodDecl *  method,
string const &  annotation = "" 
)

Definition at line 763 of file class_parser.cpp.

References Annotations::has(), and print_logging.

Referenced by generate_bidirectional_classes().

Here is the call graph for this function:

Here is the caller graph for this function:

vector<string> generate_variable_names ( vector< QualType >  qual_types,
bool  with_std_move = false 
)

Definition at line 783 of file class_parser.cpp.

Referenced by generate_bidirectional_classes().

Here is the caller graph for this function:

void print_specialization_info ( const CXXRecordDecl *  decl)

Definition at line 800 of file class_parser.cpp.

References get_canonical_name_for_decl(), and print_vector().

Referenced by ClassHandler::run().

Here is the call graph for this function:

Here is the caller graph for this function:

std::string get_type_string ( QualType  qual_type,
const std::string &  indentation = "" 
)

Definition at line 557 of file class_parser.cpp.

References get_type_string(), and print_logging.

Referenced by ClassFunction::get_default_argument_tuple_string(), get_type_string(), ClassHandler::onEndOfTranslationUnit(), and WrappedClass::parse_all_methods().

Here is the call graph for this function:

Here is the caller graph for this function:

template<class Callback >
void foreach_constructor ( const CXXRecordDecl *  klass,
Callback &&  callback,
const std::string &  annotation = "" 
)

Definition at line 161 of file helper_functions.h.

References EXPORT_NONE, get_export_type(), Annotations::has(), and print_logging.

Referenced by WrappedClass::WrappedClass().

Here is the call graph for this function:

Here is the caller graph for this function:

std::string get_method_string ( CompilerInstance &  compiler_instance,
WrappedClass wrapped_class,
const CXXMethodDecl *  method 
)
void generate_javascript_stub ( string const &  )

Definition at line 343 of file helper_functions.cpp.

References js_api_header, and WrappedClass::wrapped_classes.

Referenced by ClassHandler::onEndOfTranslationUnit().

Here is the caller graph for this function:

void generate_bidirectional_classes ( CompilerInstance &  compiler_instance)
void generate_bindings ( )

Definition at line 223 of file helper_functions.cpp.

References matched_classes_returned, MAX_DECLARATIONS_PER_FILE, WrappedClass::wrapped_classes, and write_classes().

Referenced by ClassHandler::onEndOfTranslationUnit().

Here is the call graph for this function:

Here is the caller graph for this function:

Variable Documentation

map<string, string> cpp_to_js_type_conversions

Definition at line 82 of file class_parser.cpp.

Referenced by ClassFunction::TypeInfo::TypeInfo().

vector<string> base_types_to_ignore
int print_logging
map<string, string> static_method_renames

Definition at line 79 of file class_parser.cpp.

Referenced by StaticFunction::StaticFunction().

map<string, int> template_instantiations

Definition at line 896 of file class_parser.cpp.

Referenced by WrappedClass::WrappedClass().

vector<string> types_to_ignore_regex

Definition at line 66 of file class_parser.cpp.

std::vector<std::string> used_constructor_names

Definition at line 410 of file class_parser.cpp.

Referenced by ConstructorFunction::ConstructorFunction().

int matched_classes_returned

Definition at line 172 of file class_parser.cpp.

Referenced by generate_bindings(), and ClassHandler::run().

vector<string> data_warnings

Definition at line 207 of file helper_functions.cpp.

Referenced by ClassHandler::onEndOfTranslationUnit().

vector<string> data_errors

Definition at line 201 of file helper_functions.cpp.

Referenced by ClassHandler::onEndOfTranslationUnit().

std::string js_api_header

Definition at line 96 of file class_parser.cpp.

Referenced by generate_javascript_stub().

vector<string> never_include_for_any_file

Definition at line 75 of file class_parser.cpp.

Referenced by write_classes().

string header_for_every_class_wrapper_file

Definition at line 72 of file class_parser.cpp.

Referenced by write_classes().

vector<string> includes_for_every_class_wrapper_file

Definition at line 68 of file class_parser.cpp.

Referenced by write_classes().