Conversation
Changed code style for whole solution.
There is circular dependency error.
…n-experiments # Conflicts: # applications/reflection-experiments/src/reflection_parsers/ast_source_parser.cpp # applications/reflection-experiments/src/reflection_parsers/ast_source_parser.h
Still circular issue.
| generated_path = std::filesystem::path(generate_folder) / compile_file.name.data(); | ||
|
|
||
| rsl::dynamic_string final = get_gen_source_file( | ||
| rsl::dynamic_string::from_buffer( |
There was a problem hiding this comment.
This should probably be a string_view instead. no need to dynamically allocate a string and copy over the data from the filesystem::path
There was a problem hiding this comment.
String view cannot be passed into ofstream file() as a parameter, so cannot exchange it into string_view
|
|
||
| // Probably should consider different identifier, as name can be repeated in different namespaces. | ||
| std::string extracted_name = extract_name(compile_file.name.data()); | ||
| file << "void register_reflection_file_" << extracted_name << "()\n"; |
There was a problem hiding this comment.
you could just do file << "void register_reflection_file_" << extract_name(compile_file.name.data()) << "()\n";
The compiler would probably optimize extracted_name away anyways, but currently the compiler is forced to actually create the std::string on the stack in debug mode.
by putting the extract_name function call inline you don't create a named variable. and thus the std::string can be created in-place in the file write stream operator call in debug as well.
There was a problem hiding this comment.
It needs to be used second time that function, so i think making it into a variable is usable
libraries/rythe/reflection-core/src/impl/code_gen/reflection_code_generator.cpp
Outdated
Show resolved
Hide resolved
libraries/rythe/reflection-core/src/impl/code_gen/reflection_code_generator.cpp
Outdated
Show resolved
Hide resolved
| char buffer[256]; | ||
| std::memcpy(buffer, source_location.data(), source_location.size()); | ||
| buffer[source_location.size()] = '\0'; | ||
|
|
||
| char* last_dot = std::strrchr(buffer, '.'); | ||
| if(last_dot != nullptr) { *last_dot = '\0'; } | ||
|
|
||
| strcat_s(buffer, "_generated.cpp"); | ||
|
|
||
| return rsl::dynamic_string::from_buffer(buffer, std::strlen(buffer) + 1); |
There was a problem hiding this comment.
using rsl::operator""_sv;
source_location = source_location.subview(0ull, rsl::reverse_linear_search(source_location, '.'));
return rsl::dynamic_string::from_view(source_location) + "_generated.cpp"_sv
libraries/rythe/reflection-core/src/impl/code_gen/reflection_code_generator.cpp
Outdated
Show resolved
Hide resolved
libraries/rythe/reflection-core/src/impl/code_gen/reflection_code_generator.cpp
Outdated
Show resolved
Hide resolved
libraries/rythe/reflection-core/src/impl/code_gen/reflection_code_generator.cpp
Outdated
Show resolved
Hide resolved
libraries/rythe/reflection-core/src/impl/code_gen/reflection_code_generator.h
Show resolved
Hide resolved
| [[nodiscard]] const std::vector<std::unique_ptr<compile_reflected_class>>& | ||
| get_class_container() const; |
There was a problem hiding this comment.
This function name would logically to me return a compile_reflection_container<compile_reflected_class> so maybe get_sub_classes would be a better name.
It's probably also better to return a std::span<const std::unique_ptr<compile_reflected_class>> instead if you want to give read access without giving implementation details.
There was a problem hiding this comment.
I believe that that the name should stay consistent with different functions like that, like get_function container and get_variable_container.
Have changed into spans
No description provided.