-
Notifications
You must be signed in to change notification settings - Fork 360
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
.NET: Initial support for creating ValueTypes
- Loading branch information
Showing
4 changed files
with
76 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
#include "Proxy.hpp" | ||
#include "TDB.hpp" | ||
#include "ValueType.hpp" | ||
|
||
namespace REFrameworkNET { | ||
generic <typename T> | ||
T ValueType::As() { | ||
return AnyProxy<T>::Create(this); | ||
} | ||
|
||
generic <typename T> | ||
T ValueType::New() { | ||
auto t = TDB::TypeCacher<T>::GetCachedType(); | ||
auto valueType = gcnew ValueType(t); | ||
return valueType->As<T>(); | ||
} | ||
} |
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,42 @@ | ||
#pragma once | ||
|
||
#include "UnifiedObject.hpp" | ||
#include "TypeDefinition.hpp" | ||
|
||
namespace REFrameworkNET { | ||
public ref class ValueType : public UnifiedObject { | ||
public: | ||
ValueType(TypeDefinition^ t) | ||
{ | ||
m_data = gcnew array<uint8_t>(t->ValueTypeSize); | ||
pin_ptr<uint8_t> data = &m_data[0]; | ||
} | ||
|
||
/// <returns>The type of the object</returns> | ||
virtual TypeDefinition^ GetTypeDefinition() override { | ||
return m_type; | ||
} | ||
|
||
/// <returns>The address of the object as a void* pointer</returns> | ||
virtual void* Ptr() override { | ||
pin_ptr<uint8_t> data = &m_data[0]; | ||
return data; | ||
} | ||
|
||
/// <returns>The address of the object</returns> | ||
virtual uintptr_t GetAddress() override { | ||
return (uintptr_t)Ptr(); | ||
} | ||
|
||
generic <typename T> | ||
virtual T As() override; | ||
|
||
generic <typename T> | ||
where T : ref class | ||
static T New(); | ||
|
||
private: | ||
array<uint8_t>^ m_data{}; | ||
TypeDefinition^ m_type{}; | ||
}; | ||
} |
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