diff options
| author | Amlal El Mahrouss <amlal.elmahrouss@icloud.com> | 2024-01-31 09:42:54 +0100 |
|---|---|---|
| committer | Amlal El Mahrouss <amlal.elmahrouss@icloud.com> | 2024-01-31 09:42:54 +0100 |
| commit | fc55f0d69d24fb4908cbd811681f2c3fac53614d (patch) | |
| tree | ba09a2cdbb225df7ba1a9ec5a12bcbb90b673ead /Public/Kits/GKit | |
| parent | 7bed9287589293bd9d712d152539591dee0b28c0 (diff) | |
kernel: add GKit, improve AMD64 HAL.
Signed-off-by: Amlal El Mahrouss <amlal.elmahrouss@icloud.com>
Diffstat (limited to 'Public/Kits/GKit')
| -rw-r--r-- | Public/Kits/GKit/.gitkeep | 0 | ||||
| -rw-r--r-- | Public/Kits/GKit/Core.cxx | 14 | ||||
| -rw-r--r-- | Public/Kits/GKit/Core.hpp | 112 | ||||
| -rw-r--r-- | Public/Kits/GKit/Dim2d.cxx | 20 | ||||
| -rw-r--r-- | Public/Kits/GKit/Dim2d.hpp | 37 | ||||
| -rw-r--r-- | Public/Kits/GKit/GFrame.cxx | 16 | ||||
| -rw-r--r-- | Public/Kits/GKit/GFrame.hpp | 59 | ||||
| -rw-r--r-- | Public/Kits/GKit/Makefile | 21 | ||||
| -rw-r--r-- | Public/Kits/GKit/compile_flags.txt | 4 |
9 files changed, 283 insertions, 0 deletions
diff --git a/Public/Kits/GKit/.gitkeep b/Public/Kits/GKit/.gitkeep new file mode 100644 index 00000000..e69de29b --- /dev/null +++ b/Public/Kits/GKit/.gitkeep diff --git a/Public/Kits/GKit/Core.cxx b/Public/Kits/GKit/Core.cxx new file mode 100644 index 00000000..1e694734 --- /dev/null +++ b/Public/Kits/GKit/Core.cxx @@ -0,0 +1,14 @@ +/* ------------------------------------------- + + Copyright Mahrouss Logic + + File: Core.cpp + Purpose: + + Revision History: + + 31/01/24: Added file (amlel) + +------------------------------------------- */ + +#include <GKit/Core.hpp> diff --git a/Public/Kits/GKit/Core.hpp b/Public/Kits/GKit/Core.hpp new file mode 100644 index 00000000..5fcf6546 --- /dev/null +++ b/Public/Kits/GKit/Core.hpp @@ -0,0 +1,112 @@ +/* ------------------------------------------- + + Copyright Mahrouss Logic + + File: Core.hpp + Purpose: + + Revision History: + + 31/01/24: Added file (amlel) + +------------------------------------------- */ + +#pragma once + +#include <NewKit/Array.hpp> +#include <NewKit/Defines.hpp> +#include <NewKit/Ref.hpp> +#include <NewKit/String.hpp> + +namespace HCore { +template <typename... T> +class GAction; + +class GString; +class GNumber; +class GVector2; +class GBoolean; + +class GBoolean { + private: + explicit GBoolean() : m_Value(false) {} + + HCore::Boolean m_Value; + + friend class Form; + + public: + static const GBoolean Construct(HCore::StringView& sw, HCore::Boolean value) { + GBoolean boolean; + boolean.m_Value = value; + + return boolean; + } +}; + +template <typename... T> +class GAction { + explicit GAction(HCore::StringView& sw) { m_Name = sw; } + + HCore::StringView m_Name; + void (*m_Action)(T&&... args); + + friend class Form; + + public: + static const GAction Construct(HCore::StringView& sw, + void (*action)(T&&... args)) { + GAction actcls{sw}; + actcls.m_Action = action; + + return actcls; + } +}; + +class GVector2 { + explicit GVector2(HCore::StringView& sw) : m_Vec2() {} + + HCore::Array<HCore::Int, 3> m_Vec2; + + friend class Form; + + public: + static const GVector2 Construct(HCore::StringView& sw, + HCore::Array<HCore::Int, 3>& vec2) { + GVector2 vec{sw}; + vec.m_Vec2 = vec2; + + return vec; + } +}; + +class GNumber { + HCore::Int m_Number{0}; + friend class Form; + + public: + static const GNumber Construct(HCore::Int& number) { + GNumber num; + num.m_Number = number; + + return num; + } +}; + +class GString { + explicit GString(HCore::StringView& content) { + m_Content = new HCore::StringView(); + *m_Content = content; + } + + HCore::StringView* m_Content; + + friend class Form; + + public: + static const GString Construct(HCore::StringView& value) { + GString str{value}; + return str; + } +}; +} // namespace HCore diff --git a/Public/Kits/GKit/Dim2d.cxx b/Public/Kits/GKit/Dim2d.cxx new file mode 100644 index 00000000..9d791ba2 --- /dev/null +++ b/Public/Kits/GKit/Dim2d.cxx @@ -0,0 +1,20 @@ +/* ------------------------------------------- + + Copyright Mahrouss Logic + + File: Dim2d.cpp + Purpose: + + Revision History: + + 31/01/24: Added file (amlel) + +------------------------------------------- */ + +#include <GKit/Dim2d.hpp> + +namespace HCore { +HCore::UInt& Dim2d::X() { return m_X; } + +HCore::UInt& Dim2d::Y() { return m_Y; } +} // namespace HCore diff --git a/Public/Kits/GKit/Dim2d.hpp b/Public/Kits/GKit/Dim2d.hpp new file mode 100644 index 00000000..39d441d4 --- /dev/null +++ b/Public/Kits/GKit/Dim2d.hpp @@ -0,0 +1,37 @@ +/* ------------------------------------------- + + Copyright Mahrouss Logic + + File: Dim2d.hpp + Purpose: + + Revision History: + + 31/01/24: Added file (amlel) + +------------------------------------------- */ + +#ifndef __GORG__DIM2D_HPP__ +#define __GORG__DIM2D_HPP__ + +#include <GKit/Core.hpp> + +namespace HCore { +class Dim2d final { + public: + Dim2d() = delete; + Dim2d(const HCore::UInt& x, const HCore::UInt& y) : m_X(x), m_Y(y) {} + + Dim2d& operator=(const Dim2d&) = default; + Dim2d(const Dim2d&) = default; + + HCore::UInt& X(); + HCore::UInt& Y(); + + private: + HCore::UInt m_X{0}; + HCore::UInt m_Y{0}; +}; +} // namespace HCore + +#endif /* ifndef __GORG__DIM2D_HPP__ */ diff --git a/Public/Kits/GKit/GFrame.cxx b/Public/Kits/GKit/GFrame.cxx new file mode 100644 index 00000000..427c95ba --- /dev/null +++ b/Public/Kits/GKit/GFrame.cxx @@ -0,0 +1,16 @@ +/* ------------------------------------------- + + Copyright Mahrouss Logic + + File: GFrame.cpp + Purpose: + + Revision History: + + 31/01/24: Added file (amlel) + +------------------------------------------- */ + +#include <GKit/GFrame.hpp> + +namespace HCore {} diff --git a/Public/Kits/GKit/GFrame.hpp b/Public/Kits/GKit/GFrame.hpp new file mode 100644 index 00000000..e1262e3f --- /dev/null +++ b/Public/Kits/GKit/GFrame.hpp @@ -0,0 +1,59 @@ +/* ------------------------------------------- + + Copyright Mahrouss Logic + + File: GFrame.hpp + Purpose: + + Revision History: + + 31/01/24: Added file (amlel) + +------------------------------------------- */ + +#pragma once + +#include <GKit/Core.hpp> +#include <GKit/Dim2d.hpp> +#include <NewKit/MutableArray.hpp> + +namespace HCore { +class GFrame { + public: + explicit GFrame(GFrame* parent = nullptr) : m_ParentFrame(parent) {} + ~GFrame() {} + + GFrame& operator=(const GFrame&) = default; + GFrame(const GFrame&) = default; + + virtual void Update() { + if (m_Frames.Count() == 0) return; + + for (int x = 0; x < m_Frames.Count(); ++x) { + if (!m_Frames[x]->ShouldBeUpdated()) continue; + + m_Frames[x]->Update(); + } + + this->Paint(); + } + + virtual void UpdateInput() { + if (m_Frames.Count() == 0) return; + + for (int x = 0; x < m_Frames.Count(); ++x) { + if (!m_Frames[x]->ShouldBeUpdated()) continue; + + m_Frames[x]->UpdateInput(); + } + } + + virtual bool ShouldBeUpdated() { return false; } + + virtual void Paint() = 0; + + private: + HCore::MutableArray<GFrame*> m_Frames; + GFrame* m_ParentFrame; +}; +} // namespace HCore diff --git a/Public/Kits/GKit/Makefile b/Public/Kits/GKit/Makefile new file mode 100644 index 00000000..95ab0ee2 --- /dev/null +++ b/Public/Kits/GKit/Makefile @@ -0,0 +1,21 @@ +################################################## +# ; (C) Mahrouss Logic, 2024, all rights reserved. +# This is the GKit Makefile. +################################################## + +CC=x86_64-w64-mingw32-g++ +CCFLAGS=-c -ffreestanding -fno-rtti -fno-exceptions -std=c++20 +ASM=nasm +ASMFLAGS=-f elf64 + +.PHONY: build-gkit +build-gkit: + $(CC) -I../ -I../../../Private/ $(CCFLAGS) *.cxx + +.PHONY: all +all: build-gkit + @echo "[GKit] done." + +.PHONY: clean +clean: + rm -f *.o diff --git a/Public/Kits/GKit/compile_flags.txt b/Public/Kits/GKit/compile_flags.txt new file mode 100644 index 00000000..6e721e73 --- /dev/null +++ b/Public/Kits/GKit/compile_flags.txt @@ -0,0 +1,4 @@ +-I./ +-I../ +-I../../../Private +-std=c++20 |
