v8toolkit
0.0.1
Utility library for embedding V8 Javascript engine in a c++ program
|
#include <wrapped_class.h>
Public Types | |
enum | EnumClass { EnumClass::A, EnumClass::B, EnumClass::C, EnumClass::D } |
Public Member Functions | |
WrappedClass (int a, int b=2, int c=3, WrappedClass *wc_ptr=nullptr) | |
int | simple_member_function (char const *some_string="asdf") |
void | std_function_default_parameter (std::function< void()> some_function=std::function< void()>()) |
template<class A = int, int b = 4> | |
void | templated_method () |
void | after_templated_method () |
void | parse_all_methods () |
set< unique_ptr< MemberFunction > > const & | get_member_functions () |
set< unique_ptr< StaticFunction > > const & | get_static_functions () |
set< unique_ptr< DataMember > > & | get_members () |
set< unique_ptr< ConstructorFunction > > const & | get_constructors () |
void | set_error (string const &error_message) |
std::string | get_short_name () const |
bool | has_static_method () |
bool | is_template_specialization () |
void | foreach_inheritance_level (function< void(WrappedClass &)> callback) |
void | add_member_name (string const &name) |
void | add_static_name (string const &name) |
void | update_data () |
std::string | make_sfinae_to_match_wrapped_class () const |
bool | should_be_wrapped () const |
bool | ready_for_wrapping (set< WrappedClass * > dumped_classes) const |
std::set< string > | get_base_type_includes () |
std::set< string > | get_derived_type_includes () |
WrappedClass (const WrappedClass &)=delete | |
WrappedClass & | operator= (const WrappedClass &)=delete |
WrappedClass (const std::string class_name, CompilerInstance &compiler_instance) | |
WrappedClass (const CXXRecordDecl *decl, CompilerInstance &compiler_instance, FOUND_METHOD found_method) | |
std::string | generate_js_stub () |
std::string | get_derived_classes_string (int level=0, const std::string indent="") |
std::string | get_base_class_string () |
std::string | get_bindings () |
bool | found_method_means_wrapped () |
WrappedClass ()=default | |
WrappedClass (WrappedClass const &)=default | |
WrappedClass (WrappedClass &&)=default | |
virtual | ~WrappedClass () |
int | takes_int_5 (int x) |
int | takes_const_int_6 (int const x) const |
void | default_parameters (int j=1, char const *s="asdf", vector< std::string > &&={}, CopyableWrappedClass={}, CopyableWrappedClass &&={}, CopyableWrappedClass *=nullptr) |
Static Public Member Functions | |
static V8TOOLKIT_EXTEND_WRAPPER void | extend_wrapper () |
static V8TOOLKIT_CUSTOM_EXTENSION void | custom_extension () |
static std::string | simple_static_function (double some_double) |
static void | insert_wrapped_class (WrappedClass *wrapped_class) |
static WrappedClass * | get_if_exists (const CXXRecordDecl *decl) |
static WrappedClass & | get_or_insert_wrapped_class (const CXXRecordDecl *decl, CompilerInstance &compiler_instance, FOUND_METHOD found_method) |
static std::string | static_method () |
Public Attributes | |
double | double_member_readwrite |
V8TOOLKIT_READONLY double | double_member_readonly1 |
double const | double_member_readonly2 |
std::vector< std::string > | vector_of_ints |
std::vector< WrappedClass * > | vector_of_selfs |
CXXRecordDecl const * | decl = nullptr |
CXXRecordDecl const * | instantiation_pattern = nullptr |
string | class_name |
string | name_alias |
this is the possibly shortened javascript name of the type - not necessarily valid in generated c++ More... | |
set< string > | include_files |
int | declaration_count = 3 |
string | my_header_filename = "" |
set< string > | used_member_names |
set< string > | used_static_names |
vector< string > | data_errors |
set< WrappedClass * > | derived_types |
set< WrappedClass * > | base_types |
tracked base_types - if it's more than one, that's a data error because javascript only allows one More... | |
set< string > | wrapper_extension_methods |
set< string > | wrapper_custom_extensions |
CompilerInstance & | compiler_instance |
string | my_include |
bool | done = false |
bool | valid = false |
Annotations | annotations |
bool | dumped = false |
set< WrappedClass * > | used_classes |
FOUND_METHOD | found_method |
bool | force_no_constructors = false |
bool | bidirectional = false |
CXXConstructorDecl const * | bidirectional_constructor = nullptr |
int | i = 5 |
int | ci = 5 |
std::unique_ptr< float > | upf = std::make_unique<float>(3.5) |
std::unique_ptr< float > | cupf = std::make_unique<float>(4.5) |
std::string | string = "string value" |
bool | default_parameters_called = false |
CopyableWrappedClass | copyable_wrapped_class |
std::unique_ptr< WrappedClass > | up_wrapped_class |
Static Public Attributes | |
static vector< WrappedClass * > | wrapped_classes |
Definition at line 55 of file sample.cpp.
|
strong |
Enumerator | |
---|---|
A | |
B | |
C | |
D |
Definition at line 72 of file sample.cpp.
WrappedClass::WrappedClass | ( | int | a, |
int | b = 2 , |
||
int | c = 3 , |
||
WrappedClass * | wc_ptr = nullptr |
||
) |
|
delete |
WrappedClass::WrappedClass | ( | const std::string | class_name, |
CompilerInstance & | compiler_instance | ||
) |
Definition at line 488 of file wrapped_class.cpp.
References wrapped_classes.
WrappedClass::WrappedClass | ( | const CXXRecordDecl * | decl, |
CompilerInstance & | compiler_instance, | ||
FOUND_METHOD | found_method | ||
) |
Definition at line 10 of file wrapped_class.cpp.
References annotations, base_types, base_types_to_ignore, bidirectional, bidirectional_constructor, class_name, data_error(), decl, derived_types, foreach_constructor(), FOUND_BASE_CLASS, found_method_means_wrapped(), FOUND_UNSPECIFIED, Annotations::get(), get_canonical_name_for_decl(), get_include_for_type_decl(), get_or_insert_wrapped_class(), Annotations::get_regex(), Annotations::has(), include_files, insert_wrapped_class(), Annotations::merge(), my_include, name_alias, Annotations::names_for_record_decls, print_logging, print_vector(), set_error(), template_instantiations, update_wrapped_class_for_type(), V8TOOLKIT_BIDIRECTIONAL_CLASS_STRING, V8TOOLKIT_BIDIRECTIONAL_CONSTRUCTOR_STRING, V8TOOLKIT_IGNORE_BASE_TYPE_PREFIX, V8TOOLKIT_USE_BASE_TYPE_PREFIX, and WrappedClass().
|
default |
Referenced by get_or_insert_wrapped_class(), make_sfinae_to_match_wrapped_class(), and WrappedClass().
|
default |
|
default |
|
inlinevirtual |
Definition at line 27 of file wrapped_types_test.cpp.
|
static |
|
static |
int WrappedClass::simple_member_function | ( | char const * | some_string = "asdf" | ) |
|
static |
void WrappedClass::std_function_default_parameter | ( | std::function< void()> | some_function = std::function< void()>() | ) |
void WrappedClass::templated_method | ( | ) |
void WrappedClass::after_templated_method | ( | ) |
void WrappedClass::parse_all_methods | ( | ) |
Builds data structures associated with the methods of this class
Definition at line 251 of file wrapped_class.cpp.
References annotations, data_error(), decl, EXPORT_ALL, EXPORT_EXCEPT, force_no_constructors, get_export_type(), get_type_string(), Annotations::has(), i, testing::internal::move(), print_logging, PRINT_SKIPPED_EXPORT_REASONS, V8TOOLKIT_CUSTOM_EXTENSION_STRING, V8TOOLKIT_DO_NOT_WRAP_CONSTRUCTORS_STRING, V8TOOLKIT_EXTEND_WRAPPER_STRING, wrapper_custom_extensions, and wrapper_extension_methods.
Referenced by get_constructors(), get_member_functions(), and get_static_functions().
set< unique_ptr< MemberFunction > > const & WrappedClass::get_member_functions | ( | ) |
Definition at line 239 of file wrapped_class.cpp.
References parse_all_methods().
Referenced by generate_js_stub(), and get_bindings().
set< unique_ptr< StaticFunction > > const & WrappedClass::get_static_functions | ( | ) |
Definition at line 245 of file wrapped_class.cpp.
References parse_all_methods().
Referenced by generate_js_stub(), and get_bindings().
set< unique_ptr< DataMember > > & WrappedClass::get_members | ( | ) |
Definition at line 456 of file wrapped_class.cpp.
References decl, EXPORT_ALL, EXPORT_EXCEPT, foreach_inheritance_level(), get_export_type(), and PRINT_SKIPPED_EXPORT_REASONS.
Referenced by generate_js_stub().
set< unique_ptr< ConstructorFunction > > const & WrappedClass::get_constructors | ( | ) |
Definition at line 233 of file wrapped_class.cpp.
References parse_all_methods().
Referenced by generate_js_stub(), and get_bindings().
void WrappedClass::set_error | ( | string const & | error_message | ) |
Definition at line 729 of file wrapped_class.cpp.
References data_errors, and valid.
Referenced by add_member_name(), add_static_name(), and WrappedClass().
|
inline |
Definition at line 88 of file wrapped_class.h.
Referenced by ClassHandler::run().
|
inline |
Definition at line 95 of file wrapped_class.h.
References add_member_name(), add_static_name(), foreach_inheritance_level(), and is_template_specialization().
Referenced by get_bindings(), and ClassHandler::run().
bool WrappedClass::is_template_specialization | ( | ) |
Definition at line 779 of file wrapped_class.cpp.
References decl.
Referenced by has_static_method().
void WrappedClass::foreach_inheritance_level | ( | function< void(WrappedClass &)> | callback | ) |
callback | called on each parameterized type for this template specialization |
Definition at line 442 of file wrapped_class.cpp.
References base_types.
Referenced by get_members(), and has_static_method().
void WrappedClass::add_member_name | ( | string const & | name | ) |
Sets a member name as being in use and sets valid = false if it was already in use For member functions and data members (not constructors or static methods)
name | name to add |
Definition at line 710 of file wrapped_class.cpp.
References set_error(), and used_member_names.
Referenced by DataMember::DataMember(), has_static_method(), and MemberFunction::MemberFunction().
void WrappedClass::add_static_name | ( | string const & | name | ) |
Definition at line 718 of file wrapped_class.cpp.
References set_error(), and used_static_names.
Referenced by has_static_method(), and StaticFunction::StaticFunction().
|
inline |
Definition at line 118 of file wrapped_class.h.
References decl, Annotations::get(), and Annotations::names_for_record_decls.
|
inline |
Definition at line 132 of file wrapped_class.h.
References FOUND_ANNOTATION, generate_js_stub(), get_base_type_includes(), get_derived_type_includes(), operator=(), ready_for_wrapping(), should_be_wrapped(), and WrappedClass().
bool WrappedClass::should_be_wrapped | ( | ) | const |
Definition at line 547 of file wrapped_class.cpp.
References annotations, base_types, class_name, data_error(), FOUND_ANNOTATION, FOUND_BASE_CLASS, FOUND_GENERATED, FOUND_INHERITANCE, found_method, FOUND_UNSPECIFIED, Annotations::get(), Annotations::has(), join(), name_alias, V8TOOLKIT_ALL_STRING, and V8TOOLKIT_NONE_STRING.
Referenced by make_sfinae_to_match_wrapped_class(), and ready_for_wrapping().
bool WrappedClass::ready_for_wrapping | ( | set< WrappedClass * > | dumped_classes | ) | const |
Definition at line 617 of file wrapped_class.cpp.
References base_types, class_name, and should_be_wrapped().
Referenced by make_sfinae_to_match_wrapped_class().
std::set< string > WrappedClass::get_base_type_includes | ( | ) |
Definition at line 737 of file wrapped_class.cpp.
References base_types, include_files, and my_include.
Referenced by make_sfinae_to_match_wrapped_class().
std::set< string > WrappedClass::get_derived_type_includes | ( | ) |
Definition at line 757 of file wrapped_class.cpp.
References derived_types, join(), my_include, and name_alias.
Referenced by make_sfinae_to_match_wrapped_class().
|
delete |
std::string WrappedClass::generate_js_stub | ( | ) |
Definition at line 501 of file wrapped_class.cpp.
References base_types, get_constructors(), get_member_functions(), get_members(), get_static_functions(), and name_alias.
Referenced by make_sfinae_to_match_wrapped_class().
|
inline |
Definition at line 166 of file wrapped_class.h.
References join().
Referenced by get_bindings().
|
inline |
Definition at line 178 of file wrapped_class.h.
References base_types_to_ignore, data_error(), get_bindings(), and i.
Referenced by get_bindings().
std::string WrappedClass::get_bindings | ( | ) |
Definition at line 656 of file wrapped_class.cpp.
References class_name, derived_types, get_base_class_string(), get_constructors(), get_derived_classes_string(), get_member_functions(), get_static_functions(), has_static_method(), name_alias, wrapper_custom_extensions, and wrapper_extension_methods.
Referenced by get_base_class_string().
|
inlinestatic |
Definition at line 197 of file wrapped_class.h.
References wrapped_classes.
Referenced by ClassHandler::run(), and WrappedClass().
|
inlinestatic |
Returns the wrapped class corresponding to the decl if it exists
decl | the decl to search for in existing wrapped classes |
Definition at line 206 of file wrapped_class.h.
References wrapped_classes.
Referenced by ClassHandler::run().
|
inlinestatic |
Definition at line 218 of file wrapped_class.h.
References FOUND_BASE_CLASS, found_method_means_wrapped(), get_canonical_name_for_decl(), wrapped_classes, and WrappedClass().
Referenced by ClassHandler::run(), update_wrapped_class_for_type(), and WrappedClass().
bool WrappedClass::found_method_means_wrapped | ( | ) |
Definition at line 788 of file wrapped_class.cpp.
References FOUND_ANNOTATION, FOUND_BASE_CLASS, FOUND_GENERATED, FOUND_INHERITANCE, and found_method.
Referenced by get_or_insert_wrapped_class(), and WrappedClass().
|
inline |
Definition at line 36 of file wrapped_types_test.cpp.
References EXPECT_EQ.
Referenced by WrappedClassFixture::WrappedClassFixture().
|
inline |
Definition at line 40 of file wrapped_types_test.cpp.
References EXPECT_EQ.
Referenced by WrappedClassFixture::WrappedClassFixture().
|
inline |
Definition at line 47 of file wrapped_types_test.cpp.
References EXPECT_EQ, and EXPECT_STREQ.
Referenced by WrappedClassFixture::WrappedClassFixture().
|
inlinestatic |
Definition at line 58 of file wrapped_types_test.cpp.
Referenced by WrappedClassFixture::WrappedClassFixture().
double WrappedClass::double_member_readwrite |
Definition at line 58 of file sample.cpp.
V8TOOLKIT_READONLY double WrappedClass::double_member_readonly1 |
Definition at line 59 of file sample.cpp.
double const WrappedClass::double_member_readonly2 |
Definition at line 60 of file sample.cpp.
std::vector<std::string> WrappedClass::vector_of_ints |
Definition at line 61 of file sample.cpp.
std::vector<WrappedClass *> WrappedClass::vector_of_selfs |
Definition at line 62 of file sample.cpp.
|
static |
Definition at line 29 of file wrapped_class.h.
Referenced by generate_bidirectional_classes(), generate_bindings(), generate_javascript_stub(), get_if_exists(), get_or_insert_wrapped_class(), insert_wrapped_class(), and WrappedClass().
CXXRecordDecl const* WrappedClass::decl = nullptr |
Definition at line 31 of file wrapped_class.h.
Referenced by get_members(), is_template_specialization(), parse_all_methods(), ClassHandler::run(), update_data(), and WrappedClass().
CXXRecordDecl const* WrappedClass::instantiation_pattern = nullptr |
Definition at line 34 of file wrapped_class.h.
string WrappedClass::class_name |
Definition at line 43 of file wrapped_class.h.
Referenced by get_bindings(), ClassHandler::onEndOfTranslationUnit(), ready_for_wrapping(), ClassHandler::run(), should_be_wrapped(), update_wrapped_class_for_type(), and WrappedClass().
string WrappedClass::name_alias |
this is the possibly shortened javascript name of the type - not necessarily valid in generated c++
Definition at line 46 of file wrapped_class.h.
Referenced by ConstructorFunction::ConstructorFunction(), generate_js_stub(), get_bindings(), get_derived_type_includes(), ClassHandler::onEndOfTranslationUnit(), ClassFunction::ParameterInfo::ParameterInfo(), ClassHandler::run(), should_be_wrapped(), update_wrapped_class_for_type(), and WrappedClass().
set<string> WrappedClass::include_files |
Definition at line 48 of file wrapped_class.h.
Referenced by get_base_type_includes(), ClassHandler::run(), update_wrapped_class_for_type(), and WrappedClass().
int WrappedClass::declaration_count = 3 |
Definition at line 52 of file wrapped_class.h.
Referenced by ClassFunction::ClassFunction(), and DataMember::DataMember().
string WrappedClass::my_header_filename = "" |
Definition at line 54 of file wrapped_class.h.
set<string> WrappedClass::used_member_names |
Definition at line 61 of file wrapped_class.h.
Referenced by add_member_name().
set<string> WrappedClass::used_static_names |
Definition at line 62 of file wrapped_class.h.
Referenced by add_static_name().
vector<string> WrappedClass::data_errors |
Definition at line 63 of file wrapped_class.h.
Referenced by set_error().
set<WrappedClass *> WrappedClass::derived_types |
Definition at line 64 of file wrapped_class.h.
Referenced by get_bindings(), get_derived_type_includes(), ClassHandler::run(), and WrappedClass().
set<WrappedClass *> WrappedClass::base_types |
tracked base_types - if it's more than one, that's a data error because javascript only allows one
Definition at line 67 of file wrapped_class.h.
Referenced by foreach_inheritance_level(), generate_js_stub(), get_base_type_includes(), ready_for_wrapping(), should_be_wrapped(), and WrappedClass().
set<string> WrappedClass::wrapper_extension_methods |
Definition at line 69 of file wrapped_class.h.
Referenced by get_bindings(), and parse_all_methods().
set<string> WrappedClass::wrapper_custom_extensions |
Definition at line 70 of file wrapped_class.h.
Referenced by get_bindings(), and parse_all_methods().
CompilerInstance& WrappedClass::compiler_instance |
Definition at line 71 of file wrapped_class.h.
Referenced by update_wrapped_class_for_type().
string WrappedClass::my_include |
Definition at line 73 of file wrapped_class.h.
Referenced by get_base_type_includes(), get_derived_type_includes(), and WrappedClass().
bool WrappedClass::done = false |
Definition at line 74 of file wrapped_class.h.
bool WrappedClass::valid = false |
Definition at line 75 of file wrapped_class.h.
Referenced by set_error().
Annotations WrappedClass::annotations |
Definition at line 76 of file wrapped_class.h.
Referenced by parse_all_methods(), ClassHandler::run(), should_be_wrapped(), and WrappedClass().
bool WrappedClass::dumped = false |
Definition at line 77 of file wrapped_class.h.
set<WrappedClass *> WrappedClass::used_classes |
Definition at line 78 of file wrapped_class.h.
Referenced by update_wrapped_class_for_type().
FOUND_METHOD WrappedClass::found_method |
Definition at line 79 of file wrapped_class.h.
Referenced by found_method_means_wrapped(), ClassHandler::run(), and should_be_wrapped().
bool WrappedClass::force_no_constructors = false |
Definition at line 80 of file wrapped_class.h.
Referenced by parse_all_methods(), and ClassHandler::run().
bool WrappedClass::bidirectional = false |
Definition at line 85 of file wrapped_class.h.
Referenced by WrappedClass().
CXXConstructorDecl const* WrappedClass::bidirectional_constructor = nullptr |
Definition at line 86 of file wrapped_class.h.
Referenced by WrappedClass().
int WrappedClass::i = 5 |
Definition at line 29 of file wrapped_types_test.cpp.
Referenced by get_base_class_string(), parse_all_methods(), and WrappedClassFixture::WrappedClassFixture().
int WrappedClass::ci = 5 |
Definition at line 30 of file wrapped_types_test.cpp.
Referenced by WrappedClassFixture::WrappedClassFixture().
std::unique_ptr<float> WrappedClass::upf = std::make_unique<float>(3.5) |
Definition at line 31 of file wrapped_types_test.cpp.
Referenced by WrappedClassFixture::WrappedClassFixture().
std::unique_ptr<float> WrappedClass::cupf = std::make_unique<float>(4.5) |
Definition at line 32 of file wrapped_types_test.cpp.
Referenced by WrappedClassFixture::WrappedClassFixture().
std::string WrappedClass::string = "string value" |
Definition at line 34 of file wrapped_types_test.cpp.
Referenced by WrappedClassFixture::WrappedClassFixture().
bool WrappedClass::default_parameters_called = false |
Definition at line 45 of file wrapped_types_test.cpp.
Referenced by TEST_F().
CopyableWrappedClass WrappedClass::copyable_wrapped_class |
Definition at line 60 of file wrapped_types_test.cpp.
Referenced by WrappedClassFixture::WrappedClassFixture().
std::unique_ptr<WrappedClass> WrappedClass::up_wrapped_class |
Definition at line 61 of file wrapped_types_test.cpp.
Referenced by WrappedClassFixture::WrappedClassFixture().