summaryrefslogtreecommitdiffhomepage
path: root/Public/Developer/System.Core
diff options
context:
space:
mode:
Diffstat (limited to 'Public/Developer/System.Core')
-rw-r--r--Public/Developer/System.Core/AMD64/HCoreAssemblyRoutines.s4
-rw-r--r--Public/Developer/System.Core/Headers/Containers/ODF.hxx41
-rw-r--r--Public/Developer/System.Core/Headers/Containers/XIFF.hxx63
-rw-r--r--Public/Developer/System.Core/Headers/Defines.hxx84
-rw-r--r--Public/Developer/System.Core/Headers/File.hxx120
-rw-r--r--Public/Developer/System.Core/Headers/Heap.hxx70
-rw-r--r--Public/Developer/System.Core/Headers/Window/Window.hxx31
-rw-r--r--Public/Developer/System.Core/Makefile2
-rw-r--r--Public/Developer/System.Core/Sources/CRT0.cxx (renamed from Public/Developer/System.Core/Sources/LibEntrypoint.cxx)4
-rw-r--r--Public/Developer/System.Core/Sources/Heap.cxx45
-rw-r--r--Public/Developer/System.Core/Sources/New+Delete.cxx14
11 files changed, 65 insertions, 413 deletions
diff --git a/Public/Developer/System.Core/AMD64/HCoreAssemblyRoutines.s b/Public/Developer/System.Core/AMD64/HCoreAssemblyRoutines.s
index a61d6d1f..3876175b 100644
--- a/Public/Developer/System.Core/AMD64/HCoreAssemblyRoutines.s
+++ b/Public/Developer/System.Core/AMD64/HCoreAssemblyRoutines.s
@@ -4,12 +4,12 @@
.section .text
-.globl HcGetInstanceObject
+.globl HcGetAppObject
.globl __assert_chk_fail
/* @brief Process object getter */
/* @throws: ApptError: appartement error. */
-HcGetInstanceObject:
+HcGetAppObject:
mov $0x10, %rcx /* sysGetProcessObject */
int $0x21
diff --git a/Public/Developer/System.Core/Headers/Containers/ODF.hxx b/Public/Developer/System.Core/Headers/Containers/ODF.hxx
deleted file mode 100644
index 266726bf..00000000
--- a/Public/Developer/System.Core/Headers/Containers/ODF.hxx
+++ /dev/null
@@ -1,41 +0,0 @@
-/** ===========================================
- (C) Mahrouss Logic
- ===========================================*/
-
-#ifndef __ODF__
-#define __ODF__
-
-#include <System.Core/Headers/Defines.hxx>
-
-/**
- * @brief Open Document Format
- * @file ODF.hxx
- */
-
-/// @brief four-character code for ODF.
-#define kFourCCLength_ODF 4
-
-/// @brief Document file header.
-typedef struct ODFFileHeader {
- CharacterTypeUTF8 f_Ident[kFourCCLength_ODF];
-
- Int32Type f_DocumentKind;
- Int32Type f_DocumentSize;
-
- Int64Type f_MetaForkOffset;
- Int64Type f_DocumentForkOffset;
-
- CharacterTypeUTF8 f_Padding[4];
-} PACKED ODFFileHeader;
-
-/// @brief ODF Fork header
-typedef struct ODFForkHeader {
- CharacterTypeUTF8 f_MetadataName[255];
-
- Int32Type f_MetadataKind;
- Int32Type f_MetadataSize;
-
- CharacterTypeUTF8 f_Padding;
-} PACKED ODFForkHeader;
-
-#endif // !__ODF__ \ No newline at end of file
diff --git a/Public/Developer/System.Core/Headers/Containers/XIFF.hxx b/Public/Developer/System.Core/Headers/Containers/XIFF.hxx
deleted file mode 100644
index 4c97e2a3..00000000
--- a/Public/Developer/System.Core/Headers/Containers/XIFF.hxx
+++ /dev/null
@@ -1,63 +0,0 @@
-/** ===========================================
- (C) Mahrouss Logic
- ===========================================*/
-
-#ifndef __XIFF__
-#define __XIFF__
-
-/** ---------------------------------------------------
-
- * THIS FILE CONTAINS CODE FOR THE eXtended Information File Format.
- * XIFF is used to make setup programs/audio/video files.
-
-------------------------------------------------------- */
-
-#include <System.Core/Headers/Defines.hxx>
-
-/// @brief four-character code for XIFF.
-#define kFourCCLength_XIFF 4
-#define kXIFFNameLength 255
-
-#define kXIFFContainerVideo "XVFF"
-#define kXIFFContainerAudio "XAFF"
-#define kXIFFContainerInstaller "XNFF"
-#define kXIFFContainerGeneric "XIFF"
-#define kXIFFContainerBinary "XBFF"
-
-/***
- * @brief Generic XIFF header
- * Used by XIFF based containers.
- */
-
-struct PACKED XiffHeader final {
- ByteType f_Magic[kFourCCLength_XIFF]; // XIFF string (includes \0)
- DWordType f_Size; // overall size of header (XiffHeader) in bytes
- DWordType f_FormatType; // format type. generic
- ByteType f_SpecificMag[kFourCCLength_XIFF]; // The sub header magic
- DWordType f_SpecificSize; // length of the format data
- DWordType f_SpecificFormatType; // format type. generic
-};
-
-typedef struct XiffHeader XiffHeader;
-
-/// @brief XIFF metadata header, either located in forks or in file directly.
-/// @author Amlal EL Mahrouss
-struct ML_PACKED XiffMetadataHeader final {
- ByteType f_Name[kXIFFNameLength];
- DWordType f_Flags;
- DWordType f_Type;
- QWordType f_Offset;
- SizeType f_Size;
-};
-
-/// Pascal string
-#define kXIFFStringMetadata4CC "strp"
-
-/// TrueType font
-#define kXIFFFontMetadata4CC "font"
-
-/// UI resource
-#define kXIFFResourceMetadata4CC "resx"
-
-
-#endif // ifndef __XIFF__
diff --git a/Public/Developer/System.Core/Headers/Defines.hxx b/Public/Developer/System.Core/Headers/Defines.hxx
index 867dac76..9d6d84ee 100644
--- a/Public/Developer/System.Core/Headers/Defines.hxx
+++ b/Public/Developer/System.Core/Headers/Defines.hxx
@@ -136,77 +136,6 @@ enum HcProcessCall {
#include <System.Core/Headers/Hint.hxx>
-class SystemException {
- public:
- explicit SystemException() = default;
- virtual ~SystemException() = default;
-
- public:
- CA_COPY_DEFAULT(SystemException);
-
- public:
- virtual const char *Name() = 0;
- virtual const char *Reason() = 0;
-
-};
-
-/// @brief Object exception
-/// Throws when the object isn't found.
-class ObjectNotFoundException : public SystemException {
- public:
- explicit ObjectNotFoundException() = default;
- virtual ~ObjectNotFoundException() = default;
-
- public:
- CA_COPY_DEFAULT(ObjectNotFoundException);
-
- public:
- const char *Name() override { return "ObjectNotFoundException"; }
- const char *Reason() override { return mReason; }
-
- private:
- const char *mReason{
- "System.Core: ObjectNotFoundException: Catastrophic failure!"};
-};
-
-/// @brief pointer exception
-/// Throws when the object isn't found.
-class PointerException : public SystemException {
- public:
- explicit PointerException() = default;
- virtual ~PointerException() = default;
-
- public:
- CA_COPY_DEFAULT(PointerException);
-
- public:
- const char *Name() override { return "PointerException"; }
- const char *Reason() override { return mReason; }
-
- private:
- const char *mReason{
- "System.Core: PointerException: Catastrophic failure!"};
-};
-
-/// @brief pointer exception
-/// Throws when the object isn't found.
-class NullPointerException : public SystemException {
- public:
- explicit NullPointerException() = default;
- virtual ~NullPointerException() = default;
-
- public:
- CA_COPY_DEFAULT(NullPointerException);
-
- public:
- const char *Name() override { return "NullPointerException"; }
- const char *Reason() override { return mReason; }
-
- private:
- const char *mReason{
- "System.Core: NullPointerException: Catastrophic failure!"};
-};
-
#define kObjectGlobalNamespaceSystem "HCORE_ROOT\\"
#define kObjectGlobalNamespaceUser "HCORE_USER_ROOT\\"
@@ -241,10 +170,15 @@ typedef struct Object final {
VoidType(*Release)(struct Object* Self);
IntPtrType(*Invoke)(struct Object* Self, DWordType Sel, ...);
VoidType(*Query)(struct Object* Self, PtrVoidType* Dst, SizeType SzDst, struct GUID* GuidOf);
-} Object, *ObjectPtr;
+} *ObjectRef;
+
+#define object_cast reinterpret_cast<ObjectRef>
+
+CA_EXTERN_C ObjectRef HcGetAppObject(VoidType);
-#define object_cast reinterpret_cast<ObjectPtr>
+CA_INLINE ObjectRef kApplicationObject;
-CA_EXTERN_C ObjectPtr HcGetInstanceObject(void);
+typedef CharacterTypeUTF8 Str255Type[255];
-CA_INLINE ObjectPtr kApplicationObject;
+template <SizeType N>
+using StrType = CharacterTypeUTF8[N];
diff --git a/Public/Developer/System.Core/Headers/File.hxx b/Public/Developer/System.Core/Headers/File.hxx
deleted file mode 100644
index 3d3abf13..00000000
--- a/Public/Developer/System.Core/Headers/File.hxx
+++ /dev/null
@@ -1,120 +0,0 @@
-/* -------------------------------------------
-
- Copyright Mahrouss Logic
-
-------------------------------------------- */
-
-#ifndef __FILE_API__
-#define __FILE_API__
-
-#include <System.Core/Headers/Defines.hxx>
-
-#define kFileOpenInterface 10
-#define kFileAliasInterface 11
-
-namespace System {
-class FileInterface;
-class DirectoryInterface;
-
-typedef IntPtrType FSRef;
-
-enum {
- kErrorNoSuchPath = -44,
- kErrorNotAFile = -45,
- kErrorNotADirectory = -46,
- kErrorDirectory = -47,
- kErrorBrokenSymlink = -48,
-};
-
-/// @brief System file interface
-
-class FileInterface final {
- public:
- explicit FileInterface(const char *path) {
- CA_MUST_PASS(path);
-
- mHandle = kApplicationObject->Invoke(
- kApplicationObject, kProcessCallOpenHandle, kFileOpenInterface, path);
- }
-
- ~FileInterface() {
- CA_MUST_PASS(kApplicationObject);
-
- kApplicationObject->Invoke(kApplicationObject, kProcessCallCloseHandle,
- kFileOpenInterface, mHandle);
- }
-
- public:
- CA_COPY_DEFAULT(FileInterface);
-
- public:
- PtrVoidType ReadFork(const CharacterTypeUTF8* name, UIntPtrType off, SizeType sz) {
- return (PtrVoidType)kApplicationObject->Invoke(kApplicationObject, mHandle,
- 2, name, off, sz);
- }
-
- PtrVoidType ReadFork(const CharacterTypeUTF8* name, SizeType sz) {
- return (PtrVoidType)kApplicationObject->Invoke(kApplicationObject, mHandle,
- name, 3, sz);
- }
-
- void WriteFork(const CharacterTypeUTF8* name, PtrVoidType buf, UIntPtrType off, SizeType sz) {
- kApplicationObject->Invoke(kApplicationObject, mHandle, 4, name, buf, off, sz);
- }
-
- void WriteFork(const CharacterTypeUTF8* name, PtrVoidType buf, SizeType sz) {
- kApplicationObject->Invoke(kApplicationObject, mHandle, 5, name, buf, sz);
- }
-
- void SeekFork(const CharacterTypeUTF8* name) {
- kApplicationObject->Invoke(kApplicationObject, mHandle, 6, name);
- }
-
- void RewindFork() { kApplicationObject->Invoke(kApplicationObject, mHandle, 7); }
-
- public:
- const CharacterTypeUTF8 *MIME() {
- return (const char *)kApplicationObject->Invoke(kApplicationObject, mHandle,
- 8);
- }
-
- void MIME(const CharacterTypeUTF8 *mime) {
- CA_MUST_PASS(mime);
-
- kApplicationObject->Invoke(kApplicationObject, mHandle, 9, mime);
- }
-
- private:
- FSRef mHandle;
-};
-
-typedef FileInterface *FilePtr;
-
-/// @brief file exception
-/// Throws when the file isn't found or invalid.
-class FileException : public SystemException {
- public:
- explicit FileException() = default;
- virtual ~FileException() = default;
-
- public:
- CA_COPY_DEFAULT(FileException);
-
- public:
- const char *Name() override { return "FileException"; }
- const char *Reason() override { return mReason; }
-
- private:
- const char *mReason{"System.Core: FileException: Catastrophic failure!"};
-};
-
-inline IntPtrType FSMakeAlias(const char *from, const char *outputWhere) {
- CA_MUST_PASS(from);
- CA_MUST_PASS(outputWhere);
-
- return kApplicationObject->Invoke(kApplicationObject, kProcessCallOpenHandle,
- kFileAliasInterface, from);
-}
-} // namespace System
-
-#endif // ifndef __FILE_API__
diff --git a/Public/Developer/System.Core/Headers/Heap.hxx b/Public/Developer/System.Core/Headers/Heap.hxx
index 8fea34d4..98ee5bd2 100644
--- a/Public/Developer/System.Core/Headers/Heap.hxx
+++ b/Public/Developer/System.Core/Headers/Heap.hxx
@@ -8,57 +8,25 @@
#include <System.Core/Headers/Defines.hxx>
-namespace System {
-class HeapException;
-class HeapInterface;
+#define kAllocationTypes 2
-typedef PtrVoidType HeapRef;
-
-enum {
- kHeapExpandable = 2,
- kHeapNoExecute = 4,
- kHeapShared = 6,
- kHeapReadOnly = 8,
- kHeapNoFlags = 0
-};
-
-class HeapInterface final {
- private:
- explicit HeapInterface();
-
- public:
- ~HeapInterface();
-
- public:
- CA_COPY_DEFAULT(HeapInterface);
-
- public:
- static HeapInterface *Shared() noexcept;
-
- public:
- void Delete(HeapRef me) noexcept;
- SizeType Size(HeapRef me) noexcept;
- HeapRef New(const SizeType &sz,
- const DWordType flags = kHeapNoFlags);
-};
-
-
-/// @brief heap exception
-/// Throws when the heap pointer isn't found or invalid.
-class HeapException : public SystemException {
- public:
- explicit HeapException() = default;
- virtual ~HeapException() = default;
-
- public:
- CA_COPY_DEFAULT(HeapException);
-
- public:
- const char *Name() override { return "HeapException"; }
- const char *Reason() override { return mReason; }
-
- private:
- const char *mReason{"System.Core: HeapException: Catastrophic failure!"};
+enum HcAllocationKind {
+ kStandardAllocation = 0xC,
+ kArrayAllocation = 0xD,
};
-} // namespace System
+/// @brief Allocates a new heap from process pool.
+/// @param refObj
+/// @param sz
+/// @param flags
+/// @return
+CA_EXTERN_C PtrVoidType HcAllocateProcessHeap(ObjectRef refObj, QWordType sz,
+ DWordType flags);
+
+/// @brief Check if pointer exists.
+/// @param refObj
+/// @param ptr
+/// @return
+CA_EXTERN_C BooleanType HcProcessHeapExists(ObjectRef refObj, PtrVoidType ptr);
+CA_EXTERN_C QWordType HcProcessHeapSize(ObjectRef refObj, PtrVoidType ptr);
+CA_EXTERN_C VoidType HcFreeProcessHeap(ObjectRef refObj, PtrVoidType ptr);
diff --git a/Public/Developer/System.Core/Headers/Window/Window.hxx b/Public/Developer/System.Core/Headers/Window/Window.hxx
index 5eb1b3ce..4c79d50b 100644
--- a/Public/Developer/System.Core/Headers/Window/Window.hxx
+++ b/Public/Developer/System.Core/Headers/Window/Window.hxx
@@ -77,11 +77,23 @@ CA_EXTERN_C ControlRef CreateControl(const DWordType id);
/// @return
CA_EXTERN_C VoidType ReleaseControl(const ControlRef id);
-CA_EXTERN_C BooleanType MoveControl(const ControlRef id, GraphicsPoint where);
+/// @brief Moves a control inside a GraphicsPort.
+/// @param id the control ref.
+/// @param where where to move at.
+/// @return
+CA_EXTERN_C Int32Type SetControlPosition(const ControlRef id, GraphicsPoint where);
-CA_EXTERN_C BooleanType EnableControl(const ControlRef id, BooleanType visible);
+/// @brief Enable control.
+/// @param id
+/// @param enabled
+/// @return
+CA_EXTERN_C Int32Type SetControlEnabled(const ControlRef id, BooleanType enabled);
-CA_EXTERN_C BooleanType VisibleControl(const ControlRef id, BooleanType visible);
+/// @brief Make control visible.
+/// @param id
+/// @param visible
+/// @return
+CA_EXTERN_C Int32Type MakeControlVisible(const ControlRef id, BooleanType visible);
/// @brief Creates a new window.
/// @param name the window name
@@ -104,3 +116,16 @@ CA_EXTERN_C VoidType ReleaseWindow(GraphicsPort* port);
/// @param port the menu port.
/// @return void
CA_EXTERN_C VoidType ReleaseMenu(GraphicsPort* port);
+
+/// @brief Moves a window on the desktop. (menu arent movable, will return kErrIncompatible is menu is provided.)
+/// @param id the gfx port.
+/// @param where to move.
+/// @return error code.
+CA_EXTERN_C Int32Type MoveWindow(const GraphicsPort* id, GraphicsPoint where);
+
+enum {
+ kWinErrIncompatible = 0x74,
+ kWinErrOutOfMemory,
+ kWinErrInvalidArg,
+ kWinErrNotImplemented,
+};
diff --git a/Public/Developer/System.Core/Makefile b/Public/Developer/System.Core/Makefile
index 28ce0bea..c4a97c30 100644
--- a/Public/Developer/System.Core/Makefile
+++ b/Public/Developer/System.Core/Makefile
@@ -1,5 +1,5 @@
##################################################
-# (C) Mahrouss Logic, 2024, all rights reserved.
+# (C) Mahrouss Logic, all rights reserved.
# This is the System.Graphics Makefile.
##################################################
diff --git a/Public/Developer/System.Core/Sources/LibEntrypoint.cxx b/Public/Developer/System.Core/Sources/CRT0.cxx
index b874ef55..a0235e68 100644
--- a/Public/Developer/System.Core/Sources/LibEntrypoint.cxx
+++ b/Public/Developer/System.Core/Sources/CRT0.cxx
@@ -6,8 +6,8 @@
/// @brief Inits the DLL.
/// @return if it was succesful or not.
-DWordType __DllMain(VoidType) {
- kApplicationObject = HcGetInstanceObject();
+CA_EXTERN_C DWordType __DllMain(VoidType) {
+ kApplicationObject = HcGetAppObject();
CA_MUST_PASS(kApplicationObject);
return 0;
diff --git a/Public/Developer/System.Core/Sources/Heap.cxx b/Public/Developer/System.Core/Sources/Heap.cxx
index 370693cc..fcd80a7f 100644
--- a/Public/Developer/System.Core/Sources/Heap.cxx
+++ b/Public/Developer/System.Core/Sources/Heap.cxx
@@ -11,7 +11,7 @@
/// @param sz size of object.
/// @param flags flags.
/// @return
-CA_EXTERN_C PtrVoidType HcAllocateProcessHeap(ObjectPtr refObj, QWordType sz,
+CA_EXTERN_C PtrVoidType HcAllocateProcessHeap(ObjectRef refObj, QWordType sz,
DWordType flags) {
CA_MUST_PASS(sz);
CA_MUST_PASS(flags);
@@ -22,7 +22,7 @@ CA_EXTERN_C PtrVoidType HcAllocateProcessHeap(ObjectPtr refObj, QWordType sz,
/// @brief Free pointer from the user's heap.
/// @param refObj Process object.
/// @param ptr the pointer to free.
-CA_EXTERN_C VoidType HcFreeProcessHeap(ObjectPtr refObj, PtrVoidType ptr) {
+CA_EXTERN_C VoidType HcFreeProcessHeap(ObjectRef refObj, PtrVoidType ptr) {
CA_MUST_PASS(ptr);
CA_UNREFERENCED_PARAMETER(refObj->Invoke(refObj, kProcessCallFreePtr, ptr));
}
@@ -31,7 +31,7 @@ CA_EXTERN_C VoidType HcFreeProcessHeap(ObjectPtr refObj, PtrVoidType ptr) {
/// @param refObj Process object.
/// @param ptr the pointer to find.
/// @return the size.
-CA_EXTERN_C QWordType HcProcessHeapSize(ObjectPtr refObj, PtrVoidType ptr) {
+CA_EXTERN_C QWordType HcProcessHeapSize(ObjectRef refObj, PtrVoidType ptr) {
CA_MUST_PASS(ptr);
return refObj->Invoke(refObj, kProcessCallSizePtr, ptr);
}
@@ -40,44 +40,7 @@ CA_EXTERN_C QWordType HcProcessHeapSize(ObjectPtr refObj, PtrVoidType ptr) {
/// @param refObj Process object.
/// @param ptr the pointer to check.
/// @return if it exists
-CA_EXTERN_C BooleanType HcProcessHeapExists(ObjectPtr refObj, PtrVoidType ptr) {
+CA_EXTERN_C BooleanType HcProcessHeapExists(ObjectRef refObj, PtrVoidType ptr) {
CA_MUST_PASS(ptr);
return refObj->Invoke(refObj, kProcessCallCheckPtr, ptr);
}
-
-using namespace System;
-
-/// @brief Shared instance of the heap.
-/// @return
-HeapInterface* HeapInterface::Shared() noexcept {
- static HeapInterface* heap = nullptr;
-
- if (!heap) {
- heap = new HeapInterface();
- }
-
- return heap;
-}
-
-HeapInterface::HeapInterface() {
- CA_MUST_PASS(HcProcessHeapExists(kApplicationObject, (PtrVoidType)this));
-}
-
-HeapInterface::~HeapInterface() { delete this; }
-
-void HeapInterface::Delete(HeapRef me) noexcept {
- CA_MUST_PASS(me);
- HcFreeProcessHeap(kApplicationObject, me);
-}
-
-SizeType HeapInterface::Size(HeapRef me) noexcept {
- CA_MUST_PASS(me);
- return HcProcessHeapSize(kApplicationObject, me);
-}
-
-HeapRef HeapInterface::New(const SizeType& sz, const DWordType flags) {
- SizeType _sz = sz;
- if (!_sz) ++_sz;
-
- return HcAllocateProcessHeap(kApplicationObject, _sz, flags);
-}
diff --git a/Public/Developer/System.Core/Sources/New+Delete.cxx b/Public/Developer/System.Core/Sources/New+Delete.cxx
index 98674a73..6e40aa06 100644
--- a/Public/Developer/System.Core/Sources/New+Delete.cxx
+++ b/Public/Developer/System.Core/Sources/New+Delete.cxx
@@ -5,20 +5,6 @@
------------------------------------------- */
#include <System.Core/Headers/Heap.hxx>
-#include <System.Core/Headers/Heap.hxx>
-
-#define kAllocationTypes 2
-
-enum HcAllocationKind {
- kStandardAllocation = 0xC,
- kArrayAllocation = 0xD,
-};
-
-CA_EXTERN_C PtrVoidType HcAllocateProcessHeap(ObjectPtr refObj, QWordType sz,
- DWordType flags);
-CA_EXTERN_C BooleanType HcProcessHeapExists(ObjectPtr refObj, PtrVoidType ptr);
-CA_EXTERN_C QWordType HcProcessHeapSize(ObjectPtr refObj, PtrVoidType ptr);
-CA_EXTERN_C VoidType HcFreeProcessHeap(ObjectPtr refObj, PtrVoidType ptr);
typedef SizeType size_t;