-
-
Notifications
You must be signed in to change notification settings - Fork 3
Unique function and method signature instances in metadata. #62
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
|
||
cmake-build/ | ||
# Mac | ||
.DS_Store | ||
#ignore thumbnails created by windows | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,6 +6,32 @@ | |
#include <map> | ||
|
||
namespace binary { | ||
|
||
enum FFIType : uint8_t { | ||
FFIVoid, | ||
FFIPointer, | ||
FFISint8, | ||
FFIUint8, | ||
FFIUint16, | ||
FFISint16, | ||
FFIUint32, | ||
FFISint32, | ||
FFIUint64, | ||
FFISint64, | ||
FFIUshort, | ||
FFIDouble, | ||
FFIStruct, | ||
FFIFloat | ||
}; | ||
|
||
struct CachedSignature { | ||
|
||
MetaFileOffset offset; | ||
std::vector<FFIType> types; | ||
|
||
}; | ||
|
||
|
||
/* | ||
* \class BinarySerializer | ||
* \brief Applies the Visitor pattern for serializing \c Meta::Meta objects in binary format. | ||
|
@@ -15,6 +41,10 @@ class BinarySerializer : public ::Meta::MetaVisitor { | |
MetaFile* file; | ||
BinaryWriter heapWriter; | ||
BinaryTypeEncodingSerializer typeEncodingSerializer; | ||
|
||
std::vector<CachedSignature> cachedSignatures; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Wouldn't it be more efficient to use |
||
|
||
binary::MetaFileOffset checkForExistingSignature(std::vector<::Meta::Type*> signature); | ||
|
||
void serializeBase(::Meta::Meta* Meta, binary::Meta& binaryMetaStruct); | ||
|
||
|
@@ -66,4 +96,4 @@ class BinarySerializer : public ::Meta::MetaVisitor { | |
|
||
virtual void visit(::Meta::MethodMeta* Meta) override; | ||
}; | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since we are mapping
Meta::Type
objects toFFIType
values for a second time in the same method I suggest extracting the mapping logic outside of the binary serialization. The mapping logic is not directly related to the binary serialization, it is a property of theMeta::Type
itself. I suggest introducing an instance method of theMeta::Type
structure, mapping the type to aFFIType
:Then a
MethodMeta
can have a method that converts a vector ofMeta::Type
s to vector ofFFIType
s e.g.:This way the mapping logic will not be extracted from the binary serializer and can be used in other modules without code repetition e.g. it is a good idea to print the FFI signature of a method in the Yaml output.