From 60ccc62f4934e44ad5b905fdbcf458302b8d8a09 Mon Sep 17 00:00:00 2001 From: rtk0c Date: Fri, 3 Jun 2022 23:26:44 -0700 Subject: Changeset: 63 [WIP] Rename directories --- source/CodegenRuntime/MacrosCodegen.hpp | 10 ++++++ source/CodegenRuntime/Metadata.cpp | 45 ++++++++++++++++++++++++++ source/CodegenRuntime/Metadata.hpp | 33 +++++++++++++++++++ source/CodegenRuntime/MetadataBase.cpp | 5 +++ source/CodegenRuntime/MetadataBase.hpp | 53 +++++++++++++++++++++++++++++++ source/CodegenRuntime/MetadataDetails.hpp | 7 ++++ source/CodegenRuntime/buildfile | 1 + 7 files changed, 154 insertions(+) create mode 100644 source/CodegenRuntime/MacrosCodegen.hpp create mode 100644 source/CodegenRuntime/Metadata.cpp create mode 100644 source/CodegenRuntime/Metadata.hpp create mode 100644 source/CodegenRuntime/MetadataBase.cpp create mode 100644 source/CodegenRuntime/MetadataBase.hpp create mode 100644 source/CodegenRuntime/MetadataDetails.hpp create mode 100644 source/CodegenRuntime/buildfile (limited to 'source/CodegenRuntime') diff --git a/source/CodegenRuntime/MacrosCodegen.hpp b/source/CodegenRuntime/MacrosCodegen.hpp new file mode 100644 index 0000000..956123c --- /dev/null +++ b/source/CodegenRuntime/MacrosCodegen.hpp @@ -0,0 +1,10 @@ +// 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(...) +#define BRUSSEL_PROPERTY(...) +#define BRUSSEL_METHOD(...) + +#define BRUSSEL_ENUM(name, options) diff --git a/source/CodegenRuntime/Metadata.cpp b/source/CodegenRuntime/Metadata.cpp new file mode 100644 index 0000000..0d640da --- /dev/null +++ b/source/CodegenRuntime/Metadata.cpp @@ -0,0 +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/CodegenRuntime/Metadata.hpp b/source/CodegenRuntime/Metadata.hpp new file mode 100644 index 0000000..e89fd8f --- /dev/null +++ b/source/CodegenRuntime/Metadata.hpp @@ -0,0 +1,33 @@ +#pragma once + +#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/CodegenRuntime/MetadataBase.cpp b/source/CodegenRuntime/MetadataBase.cpp new file mode 100644 index 0000000..2f2ef94 --- /dev/null +++ b/source/CodegenRuntime/MetadataBase.cpp @@ -0,0 +1,5 @@ +#include "MetadataBase.hpp" + +bool Metadata::TypePropertyInfo::IsDirectAccess() const { + return getterName.empty() && setterName.empty(); +} diff --git a/source/CodegenRuntime/MetadataBase.hpp b/source/CodegenRuntime/MetadataBase.hpp new file mode 100644 index 0000000..c1ad894 --- /dev/null +++ b/source/CodegenRuntime/MetadataBase.hpp @@ -0,0 +1,53 @@ +#pragma once + +#include +#include +#include +#include + +namespace Metadata { + +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 parents; + std::span properties; + std::span 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 +const TypeInfo* GetTypeInfo(); + +// NOTE: implemented by generating specializations; not-generated ones should generated an error in the linking phase +template +std::string_view EnumToString(TEnum value); + +// NOTE: implemented by generating specializations; not-generated ones should generated an error in the linking phase +template +std::optional EnumFromString(std::string_view str); + +} // namespace Metadata diff --git a/source/CodegenRuntime/MetadataDetails.hpp b/source/CodegenRuntime/MetadataDetails.hpp new file mode 100644 index 0000000..09b71ff --- /dev/null +++ b/source/CodegenRuntime/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 diff --git a/source/CodegenRuntime/buildfile b/source/CodegenRuntime/buildfile new file mode 100644 index 0000000..8d1c8b6 --- /dev/null +++ b/source/CodegenRuntime/buildfile @@ -0,0 +1 @@ + -- cgit v1.2.3-70-g09d2