diff options
author | rtk0c <[email protected]> | 2022-06-02 21:34:16 -0700 |
---|---|---|
committer | rtk0c <[email protected]> | 2022-06-02 21:34:16 -0700 |
commit | bd07ae3f4e1bcdedc3e373460671ca9713a03de5 (patch) | |
tree | 15c897891474a97983f247196923f8e4f2184083 /source/20-codegen-runtime | |
parent | 8a0f2cd0b398ee0b7740e44a0e5fb2f75d090ccb (diff) |
Changeset: 60 Add struct/class scanning to codegen
Diffstat (limited to 'source/20-codegen-runtime')
-rw-r--r-- | source/20-codegen-runtime/MacrosCodegen.hpp | 9 | ||||
-rw-r--r-- | source/20-codegen-runtime/Metadata.cpp | 44 | ||||
-rw-r--r-- | source/20-codegen-runtime/Metadata.hpp | 29 | ||||
-rw-r--r-- | source/20-codegen-runtime/MetadataBase.cpp | 4 | ||||
-rw-r--r-- | source/20-codegen-runtime/MetadataBase.hpp | 43 | ||||
-rw-r--r-- | source/20-codegen-runtime/MetadataDetails.hpp | 7 |
6 files changed, 131 insertions, 5 deletions
diff --git a/source/20-codegen-runtime/MacrosCodegen.hpp b/source/20-codegen-runtime/MacrosCodegen.hpp index 6803023..956123c 100644 --- a/source/20-codegen-runtime/MacrosCodegen.hpp +++ b/source/20-codegen-runtime/MacrosCodegen.hpp @@ -1,7 +1,10 @@ -// NOTE: contents of this file is coupled with buildtools/codegen/ -// when updating, change both sides at the same time +// NOTE: Contents of this file is coupled with the codegen compiler. +// When updating, change both sides at the same time. #pragma once -#define BRUSSEL_CLASS(name, options) +#define BRUSSEL_CLASS(...) +#define BRUSSEL_PROPERTY(...) +#define BRUSSEL_METHOD(...) + #define BRUSSEL_ENUM(name, options) diff --git a/source/20-codegen-runtime/Metadata.cpp b/source/20-codegen-runtime/Metadata.cpp index ee32054..0d640da 100644 --- a/source/20-codegen-runtime/Metadata.cpp +++ b/source/20-codegen-runtime/Metadata.cpp @@ -1 +1,45 @@ #include "Metadata.hpp" + +auto Metadata::TypeInfoList::Iterator::operator*() const -> const TypeInfo& { + // TODO +} + +auto Metadata::TypeInfoList::Iterator::operator++() -> Iterator& { + // TODO +} + +auto Metadata::TypeInfoList::Iterator::operator++(int) -> Iterator { + auto copy = *this; + ++copy; + return copy; +} + +bool Metadata::TypeInfoList::Iterator::operator==(const Iterator& that) const { + return this->data == that.data; +} + +bool Metadata::TypeInfoList::Iterator::operator==(const Sentinel&) const { + // TODO +} + +auto Metadata::TypeInfoList::begin() const -> Iterator { + return Iterator(); +} + +auto Metadata::TypeInfoList::end() const -> Sentinel { + return Sentinel(); +} + +auto Metadata::GetTypeInfoList() -> const TypeInfoList& { + // TODO +} + +auto Metadata::QueryTypeInfo(TypeId id) -> const TypeInfo* { + // TODO + return nullptr; +} + +auto Metadata::QueryTypeInfo(std::string_view id) -> const TypeInfo* { + // TODO + return nullptr; +} diff --git a/source/20-codegen-runtime/Metadata.hpp b/source/20-codegen-runtime/Metadata.hpp index a038c15..e89fd8f 100644 --- a/source/20-codegen-runtime/Metadata.hpp +++ b/source/20-codegen-runtime/Metadata.hpp @@ -2,3 +2,32 @@ #include "MacrosCodegen.hpp" #include "MetadataBase.hpp" + +namespace Metadata { + +struct TypeInfoList { + struct Sentinel { + }; + + struct Iterator { + void* data; + + const TypeInfo& operator*() const; + Iterator& operator++(); + Iterator operator++(int); + + bool operator==(const Iterator&) const; + bool operator==(const Sentinel&) const; + }; + + Iterator begin() const; + Sentinel end() const; +}; + +/// Get a list of all type infos present. +const TypeInfoList& GetTypeInfoList(); + +const TypeInfo* QueryTypeInfo(TypeId id); +const TypeInfo* QueryTypeInfo(std::string_view name); + +} // namespace Metadata diff --git a/source/20-codegen-runtime/MetadataBase.cpp b/source/20-codegen-runtime/MetadataBase.cpp index 3ccf870..2f2ef94 100644 --- a/source/20-codegen-runtime/MetadataBase.cpp +++ b/source/20-codegen-runtime/MetadataBase.cpp @@ -1 +1,5 @@ #include "MetadataBase.hpp" + +bool Metadata::TypePropertyInfo::IsDirectAccess() const { + return getterName.empty() && setterName.empty(); +} diff --git a/source/20-codegen-runtime/MetadataBase.hpp b/source/20-codegen-runtime/MetadataBase.hpp index 8be668d..c1ad894 100644 --- a/source/20-codegen-runtime/MetadataBase.hpp +++ b/source/20-codegen-runtime/MetadataBase.hpp @@ -1,14 +1,53 @@ #pragma once +#include <cstddef> #include <optional> +#include <span> #include <string_view> namespace Metadata { -template <class TEnum> +struct TypeId { + size_t id; +}; + +struct TypeInfo; + +struct TypePropertyInfo { + std::string_view name; + const TypeInfo* type; + std::string_view getterName; + std::string_view setterName; + + bool IsDirectAccess() const; +}; + +struct TypeMethodInfo { + std::string_view name; + // TODO +}; + +struct TypeInfo { + TypeId typeId; + std::string_view name; + std::span<const TypeInfo*> parents; + std::span<const TypePropertyInfo> properties; + std::span<const TypeMethodInfo> methods; + + /// Whether this object is registered at runtime or statically compiled + bool dynamic = false; +}; + +// NOTE: implemented by generating specializations; not-generated ones should generated an error in the linking phase +template <typename T> +const TypeInfo* GetTypeInfo(); + +// NOTE: implemented by generating specializations; not-generated ones should generated an error in the linking phase +template <typename TEnum> std::string_view EnumToString(TEnum value); -template <class TEnum> +// NOTE: implemented by generating specializations; not-generated ones should generated an error in the linking phase +template <typename TEnum> std::optional<TEnum> EnumFromString(std::string_view str); } // namespace Metadata diff --git a/source/20-codegen-runtime/MetadataDetails.hpp b/source/20-codegen-runtime/MetadataDetails.hpp new file mode 100644 index 0000000..09b71ff --- /dev/null +++ b/source/20-codegen-runtime/MetadataDetails.hpp @@ -0,0 +1,7 @@ +// This file contains implementation details used by the outputs of the code generaetor. Consumers do not use. +#pragma once + +#include "MetadataBase.hpp" + +namespace Metadata::Details { +} // namespace Metadata::Details |