-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[v0.0.3] Big refactoring! See message for details.
So, it was a long refactoring session, but now we have a few breaking changes: 1. Removed type alias. Now RG3 will try to expand whole type as separated (from original type) with all information. 2. Added 'annotations' method to annotate type (like comments but in place where extra comments not available) 3. Refactored global routing system: now logic divided between CxxRouterVisitor (root visitor), CxxClassTypeVisitor (non-templated classes), CxxTemplateSpecializationVisitor (template specialization) and CxxTypeVisitor (trivial, enum types and aliases) 4. Removed template specialization type kind. Now all templates are part of TK_STRUCT_OR_CLASS. NOTE: In future I'll add flag into type base to check is type templated or not. 5. Fixed sOwnerClassName field in class member methods. Now this field contains pretty name of owner class (with template view when it's templated) 6. Added tests to support unsigned enum
- Loading branch information
Showing
32 changed files
with
1,247 additions
and
1,469 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
#pragma once | ||
|
||
#include <clang/AST/Decl.h> | ||
|
||
#include <RG3/Cpp/Tag.h> | ||
#include <RG3/Cpp/TypeClass.h> | ||
|
||
#include <algorithm> | ||
#include <optional> | ||
#include <string> | ||
#include <vector> | ||
|
||
|
||
namespace rg3::llvm | ||
{ | ||
struct PropertyDescription | ||
{ | ||
std::string propertyRefName {}; // A reference name to property (original) | ||
std::string propertyAliasName {}; // A new name of property (alias) | ||
}; | ||
|
||
struct ExtraPropertiesFilter | ||
{ | ||
const std::vector<PropertyDescription>& vKnownProperties; | ||
|
||
bool operator()(const std::string& sPropertyName) const | ||
{ | ||
auto it = std::find_if(vKnownProperties.begin(), vKnownProperties.end(), [&sPropertyName](const PropertyDescription& pd) -> bool { | ||
return pd.propertyRefName == sPropertyName; | ||
}); | ||
|
||
return it != vKnownProperties.end(); | ||
} | ||
|
||
/** | ||
* @brief Mutator overflow: this method return true if property acceptable and modified for future use | ||
*/ | ||
bool operator()(cpp::ClassProperty& sProperty) | ||
{ | ||
auto it = std::find_if(vKnownProperties.begin(), vKnownProperties.end(), [&sProperty](const PropertyDescription& pd) -> bool { | ||
return pd.propertyRefName == sProperty.sName; | ||
}); | ||
|
||
if (it != vKnownProperties.end()) | ||
{ | ||
sProperty.sAlias = it->propertyAliasName; | ||
return true; | ||
} | ||
|
||
return false; | ||
} | ||
}; | ||
|
||
struct ExtraFunctionsFilter | ||
{ | ||
const std::vector<std::string>& vKnownFunctions; | ||
|
||
bool operator()(const std::string& sFuncName) const | ||
{ | ||
return std::find(vKnownFunctions.begin(), vKnownFunctions.end(), sFuncName) != vKnownFunctions.end(); | ||
} | ||
}; | ||
|
||
struct Annotations | ||
{ | ||
bool bIsRuntime { false }; | ||
std::optional<std::string> overrideLocation {}; | ||
std::vector<PropertyDescription> knownProperties {}; | ||
std::vector<std::string> knownFunctions {}; | ||
cpp::Tags additionalTags {}; | ||
|
||
[[nodiscard]] bool isRuntime() const { return bIsRuntime; } | ||
|
||
void collectFromDecl(clang::Decl* pDecl); | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
#pragma once | ||
|
||
#include <clang/AST/RecursiveASTVisitor.h> | ||
#include <clang/AST/ASTConsumer.h> | ||
|
||
#include <RG3/LLVM/CompilerConfig.h> | ||
#include <RG3/LLVM/Annotations.h> | ||
#include <RG3/Cpp/TypeBase.h> | ||
|
||
#include <vector> | ||
|
||
|
||
namespace rg3::llvm::visitors | ||
{ | ||
/** | ||
* @brief This class handle all types and understand which visitor should handle this type. | ||
* | ||
*/ | ||
class CxxRouterVisitor : public clang::RecursiveASTVisitor<CxxRouterVisitor> | ||
{ | ||
public: | ||
CxxRouterVisitor(std::vector<rg3::cpp::TypeBasePtr>& vFoundTypes, const CompilerConfig& compilerConfig); | ||
|
||
public: // visitors | ||
bool VisitCXXRecordDecl(clang::CXXRecordDecl* cxxRecordDecl); // For C++ types (struct, class) | ||
bool VisitEnumDecl(clang::EnumDecl* enumDecl); // For enumerations | ||
bool VisitTypedefNameDecl(clang::TypedefNameDecl* typedefNameDecl); // For aliases (typedef, using) | ||
|
||
private: | ||
bool handleAnnotationBasedType(const clang::Type* pType, | ||
const rg3::llvm::Annotations& annotation, | ||
const clang::ASTContext& ctx, | ||
bool bDirectInvoke); | ||
|
||
private: | ||
const CompilerConfig& m_compilerConfig; | ||
std::vector<rg3::cpp::TypeBasePtr>& m_vFoundTypes; | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.