summaryrefslogtreecommitdiffhomepage
path: root/Public/Developer
diff options
context:
space:
mode:
authorAmlal El Mahrouss <amlal.elmahrouss@icloud.com>2024-05-07 14:46:11 +0200
committerAmlal El Mahrouss <amlal.elmahrouss@icloud.com>2024-05-07 14:47:44 +0200
commite80b274a23cb6bbe83bc48058c779624b16dd556 (patch)
tree905578ee29d9c5bad03b28b8381a2c29fb715f0f /Public/Developer
parentc4f3bfd671ad8ec5721c3d2c45de4806f34ebb75 (diff)
MHR-23: ErrorID error codes are now deprecated in favor of HError.
- Cleanup done in SystemLib. - Refactor system API. Signed-off-by: Amlal El Mahrouss <amlal.elmahrouss@icloud.com>
Diffstat (limited to 'Public/Developer')
-rw-r--r--Public/Developer/CxxRuntimeLib/.gitkeep (renamed from Public/Developer/CxxLib/.gitkeep)0
-rw-r--r--Public/Developer/CxxRuntimeLib/Sources/New+Delete.cxx (renamed from Public/Developer/CxxLib/Sources/New+Delete.cxx)0
-rw-r--r--Public/Developer/PDFLib/.gitkeep0
-rw-r--r--Public/Developer/PEFRuntimeLib/.gitkeep (renamed from Public/Developer/FragLib/.gitkeep)0
-rw-r--r--Public/Developer/PEFRuntimeLib/Sources/PEFStart.c (renamed from Public/Developer/FragLib/Sources/ImageStart.c)0
-rw-r--r--Public/Developer/SystemLib/Headers/Alert.h (renamed from Public/Developer/SystemLib/Headers/2D.h)14
-rw-r--r--Public/Developer/SystemLib/Headers/Defines.h32
-rw-r--r--Public/Developer/SystemLib/Headers/Dialog.h46
-rw-r--r--Public/Developer/SystemLib/Headers/Intl.h (renamed from Public/Developer/SystemLib/Headers/l18n.h)0
-rw-r--r--Public/Developer/SystemLib/Headers/TrueType.h38
-rw-r--r--Public/Developer/SystemLib/Headers/Wm.h171
-rw-r--r--Public/Developer/SystemLib/Sources/App.c2
-rw-r--r--Public/Developer/SystemLib/Sources/TrueType.c42
-rw-r--r--Public/Developer/SystemLib/Sources/Wm.c100
14 files changed, 26 insertions, 419 deletions
diff --git a/Public/Developer/CxxLib/.gitkeep b/Public/Developer/CxxRuntimeLib/.gitkeep
index e69de29b..e69de29b 100644
--- a/Public/Developer/CxxLib/.gitkeep
+++ b/Public/Developer/CxxRuntimeLib/.gitkeep
diff --git a/Public/Developer/CxxLib/Sources/New+Delete.cxx b/Public/Developer/CxxRuntimeLib/Sources/New+Delete.cxx
index 5ff3612f..5ff3612f 100644
--- a/Public/Developer/CxxLib/Sources/New+Delete.cxx
+++ b/Public/Developer/CxxRuntimeLib/Sources/New+Delete.cxx
diff --git a/Public/Developer/PDFLib/.gitkeep b/Public/Developer/PDFLib/.gitkeep
deleted file mode 100644
index e69de29b..00000000
--- a/Public/Developer/PDFLib/.gitkeep
+++ /dev/null
diff --git a/Public/Developer/FragLib/.gitkeep b/Public/Developer/PEFRuntimeLib/.gitkeep
index e69de29b..e69de29b 100644
--- a/Public/Developer/FragLib/.gitkeep
+++ b/Public/Developer/PEFRuntimeLib/.gitkeep
diff --git a/Public/Developer/FragLib/Sources/ImageStart.c b/Public/Developer/PEFRuntimeLib/Sources/PEFStart.c
index 31b0d7bd..31b0d7bd 100644
--- a/Public/Developer/FragLib/Sources/ImageStart.c
+++ b/Public/Developer/PEFRuntimeLib/Sources/PEFStart.c
diff --git a/Public/Developer/SystemLib/Headers/2D.h b/Public/Developer/SystemLib/Headers/Alert.h
index ad7ba9fe..443b6829 100644
--- a/Public/Developer/SystemLib/Headers/2D.h
+++ b/Public/Developer/SystemLib/Headers/Alert.h
@@ -4,16 +4,18 @@
------------------------------------------- */
-#pragma once
-
-#include <Headers/Wm.h>
-
/*************************************************************
*
- * File: Draw.h
- * Purpose: Xtrem Composer API for NewOS.
+ * File: Alert.h
+ * Purpose: New OS alert dialog.
* Date: 3/26/24
*
* Copyright Mahrouss Logic, all rights reserved.
*
*************************************************************/
+
+#pragma once
+
+#include <Headers/Defines.h>
+
+CA_EXTERN_C VoidType Alert(const CharacterTypeUTF8* fmt, ...);
diff --git a/Public/Developer/SystemLib/Headers/Defines.h b/Public/Developer/SystemLib/Headers/Defines.h
index 8272213e..db2e1884 100644
--- a/Public/Developer/SystemLib/Headers/Defines.h
+++ b/Public/Developer/SystemLib/Headers/Defines.h
@@ -15,7 +15,7 @@
{ \
if (!e) \
{ \
- DlgMsgBox("Sorry, an assertion failed.\nFile: %s\nLine: %i", __FILE__, __LINE__) RtAssertTriggerInterrupt() \
+ Alert("Sorry, an assertion failed.\nFile: %s\nLine: %i", __FILE__, __LINE__) RtAssertTriggerInterrupt() \
} \
}
#else
@@ -32,7 +32,7 @@
#endif
-struct Application;
+struct ApplicationInterface;
struct GUID;
CA_EXTERN_C void RtAssertTriggerInterrupt(void);
@@ -45,6 +45,8 @@ CA_EXTERN_C void RtAssertTriggerInterrupt(void);
#define CA_PASCAL CA_STDCALL
+#include <Headers/Hint.h>
+
typedef __UINT8_TYPE__ ByteType;
typedef __UINT16_TYPE__ WordType;
typedef __UINT32_TYPE__ DWordType;
@@ -127,7 +129,8 @@ enum RtProcessCall
kCallSizePtr,
kCallCheckPtr,
kCallAllocStack,
- /// @brief Open a specific handle (can be used as sel to call methods related to it.)
+ /// @brief Open a specific handle
+ /// (can be used as sel to call methods related to it.)
kCallOpenFile,
kCallCloseFile,
kCallOpenDir,
@@ -145,9 +148,6 @@ enum RtProcessCall
kCallsCount,
};
-#include <Headers/Hint.h>
-#include <Headers/Dialog.h>
-
/**
* @brief GUID type, something you can also find in CFKit.
* @author Amlal El Mahrouss
@@ -162,12 +162,12 @@ typedef struct GUID
/// \brief Application Interface.
/// \author Amlal El Mahrouss
-typedef struct Application
+typedef struct ApplicationInterface
{
- VoidType (*Release)(struct Application* Self, DWordType ExitCode);
- IntPtrType (*Invoke)(struct Application* Self, DWordType Sel, ...);
- VoidType (*Query)(struct Application* Self, PtrVoidType* Dst, SizeType SzDst, struct GUID* GuidOf);
-} Application, *ApplicationRef;
+ VoidType (*Release)(struct ApplicationInterface* Self, DWordType ExitCode);
+ IntPtrType (*Invoke)(struct ApplicationInterface* Self, DWordType Sel, ...);
+ VoidType (*Query)(struct ApplicationInterface* Self, PtrVoidType* Dst, SizeType SzDst, struct GUID* GuidOf);
+} ApplicationInterface, *ApplicationInterfaceRef;
#ifdef __cplusplus
@@ -187,21 +187,21 @@ typedef struct Application
KLASS& operator=(KLASS&&) = default; \
KLASS(KLASS&&) = default;
-#define app_cast reinterpret_cast<ApplicationRef>
+#define app_cast reinterpret_cast<ApplicationInterfaceRef>
template <SizeType N>
using StrType = CharacterTypeUTF8[N];
#else
-#define app_cast (ApplicationRef)
+#define app_cast (ApplicationInterfaceRef)
#endif // ifdef C++
/// @brief Get app singleton.
/// @param
/// @return
-CA_EXTERN_C ApplicationRef RtGetAppPointer(VoidType);
+CA_EXTERN_C ApplicationInterfaceRef RtGetAppPointer(VoidType);
/// @brief Get argument count
/// @param
@@ -213,7 +213,7 @@ CA_EXTERN_C SizeType RtGetAppArgumentsCount(VoidType);
/// @return
CA_EXTERN_C CharacterTypeUTF8** RtGetAppArgumentsPtr(VoidType);
-CA_EXTERN_C ApplicationRef kSharedApplication;
+CA_EXTERN_C ApplicationInterfaceRef kSharedApplication;
typedef CharacterTypeUTF8 StrType255[255];
@@ -226,3 +226,5 @@ typedef CharacterTypeUTF8 StrType255[255];
#ifndef kInvalidRef
#define kInvalidRef 0
#endif
+
+#include <Headers/Alert.h>
diff --git a/Public/Developer/SystemLib/Headers/Dialog.h b/Public/Developer/SystemLib/Headers/Dialog.h
deleted file mode 100644
index 14e3d3a7..00000000
--- a/Public/Developer/SystemLib/Headers/Dialog.h
+++ /dev/null
@@ -1,46 +0,0 @@
-/* -------------------------------------------
-
- Copyright Mahrouss Logic
-
-------------------------------------------- */
-
-#pragma once
-
-#include <Headers/Wm.h>
-
-struct _DialogPort;
-struct _DialogPoint;
-
-/// @brief Dialog procedure type.
-typedef VoidType (*WmDialogFn)(struct _DialogPort* port, UInt32Type msg, UIntPtrType pParam, UIntPtrType iParam);
-
-/// @brief A point, can represent the size, position of a window.
-typedef struct _DialogPoint
-{
- PositionType X, Y;
-} DialogPoint;
-
-typedef struct _DialogPort
-{
- WordType dlgPort;
- WordType dlgKind;
- BooleanType dlgVisible : 1;
- BooleanType dlgMoving : 1;
- DialogPoint dlgPosition;
- WmDialogFn dlgProc;
- struct _WmGFX* dlgGfx;
- struct _WmWindowPort* parentPort;
-} DialogPort;
-
-/// @brief Creates a new dialog from a rsrc fork id.
-/// @param rsrcId the resource id.
-/// @return the dialog port.
-CA_EXTERN_C DialogPort* DlgCreateFromRsrc(QWordType rsrcId);
-
-/// @brief Shows an message box according to format.
-/// @param title the message box title
-/// @param format the format
-/// @param va_list the va args, that goes along with it.
-/// @return 0: the user clicked Ok
-/// @return > 0: User clicked on specific button.
-CA_EXTERN_C Int32Type DlgMsgBox(const CharacterTypeUTF8* title, const CharacterTypeUTF8* format, ...);
diff --git a/Public/Developer/SystemLib/Headers/l18n.h b/Public/Developer/SystemLib/Headers/Intl.h
index 1cd5ea64..1cd5ea64 100644
--- a/Public/Developer/SystemLib/Headers/l18n.h
+++ b/Public/Developer/SystemLib/Headers/Intl.h
diff --git a/Public/Developer/SystemLib/Headers/TrueType.h b/Public/Developer/SystemLib/Headers/TrueType.h
deleted file mode 100644
index 49b111cc..00000000
--- a/Public/Developer/SystemLib/Headers/TrueType.h
+++ /dev/null
@@ -1,38 +0,0 @@
-/* -------------------------------------------
-
- Copyright Mahrouss Logic
-
-------------------------------------------- */
-
-#pragma once
-
-#include <Headers/Wm.h>
-
-/*************************************************************
- *
- * File: TrueType.h
- * Purpose: TrueType font implementation for NewOS.
- * Date: 3/26/24
- *
- * Copyright Mahrouss Logic, all rights reserved.
- *
- *************************************************************/
-
-typedef QWordType TTFFontRef;
-
-/// @brief Loads a new font into app's memory.
-/// @param name
-/// @return
-CA_EXTERN_C TTFFontRef FnCreateFont(const CharacterTypeUTF8* name);
-
-/// @brief Dispose an allocated font.
-/// @param fon
-/// @return
-CA_EXTERN_C VoidType FnDisposeFont(TTFFontRef fon);
-
-/// @brief Gets the font gylph for character.
-/// @param fon
-/// @return
-CA_EXTERN_C PtrVoidType FnGetGlyph(TTFFontRef fon, UInt32Type utfCh);
-
-/// TODO: Get font metadata. \ No newline at end of file
diff --git a/Public/Developer/SystemLib/Headers/Wm.h b/Public/Developer/SystemLib/Headers/Wm.h
deleted file mode 100644
index e0333310..00000000
--- a/Public/Developer/SystemLib/Headers/Wm.h
+++ /dev/null
@@ -1,171 +0,0 @@
-/* -------------------------------------------
-
- Copyright Mahrouss Logic
-
-------------------------------------------- */
-
-#pragma once
-
-#include <Headers/Defines.h>
-#include <Headers/Dialog.h>
-
-/*************************************************************
- *
- * File: Wm.h
- * Purpose: Window Manager API for NewOS.
- * Date: 3/26/24
- *
- * Copyright Mahrouss Logic, all rights reserved.
- *
- *************************************************************/
-
-struct _WmPoint;
-struct _WmWindowPort;
-struct _WmGFX;
-struct _WmControlPort;
-struct _WmPoint;
-
-/// @brief Window Graphics type.
-typedef struct _WmGFX
-{
- UInt32Type Depth;
- UInt32Type* DataFrame;
- SizeType DataFrameWidth;
- SizeType DataFrameHeight;
-} WmGFX, *WmGFXRef;
-
-/// @brief Window procedure type.
-typedef VoidType (*WmWindowFn)(struct _WmWindowPort* port, UInt32Type msg, UIntPtrType pParam, UIntPtrType iParam);
-
-/// @brief A point, can represent the size, position of a window.
-typedef struct _WmPoint
-{
- PositionType X, Y;
-} WmPoint;
-
-/// @brief Window port type, can be used to control the window.
-typedef struct _WmWindowPort
-{
- WordType windowPort;
- WordType windowKind;
- BooleanType windowVisible : 1;
- BooleanType windowMaximized : 1;
- BooleanType windowMinimized : 1;
- BooleanType windowMoving : 1; // Set if the window is moving.
- BooleanType windowDisableClose : 1; // Set if user or app request a close action.
- BooleanType windowDisableMinimize : 1; // Set if user request a minimize action.
- BooleanType windowInvalidate : 1; // Set if invalidation action is done.
- WmPoint windowPosition;
- WmPoint windowSize;
- WmGFXRef windowGfx;
- WmWindowFn windowProc;
- struct _WmWindowPort* windowMenuPort; ///! Attached menu to it.
- struct _WmWindowPort* windowParentPort;
-} WindowPort;
-
-/// @brief Control port type.
-typedef struct _WmControlPort
-{
- WordType controlPort;
- WordType controlKind;
- BooleanType controlVisible : 1;
- BooleanType controlMoving : 1;
- WmPoint controlPosition;
- WmWindowFn controlProc;
- WmGFXRef controlGfx;
- WindowPort* parentPort;
-} WmControlPort;
-
-enum
-{
- kWmErrIncompatible = 0x74,
- kWmErrOutOfMemory,
- kWmErrInvalidArg,
- kWmErrNotImplemented,
-};
-
-/// @brief Color reference.
-typedef UInt32Type ColorRef;
-
-/***********************************************************************************/
-/// Color utils.
-/***********************************************************************************/
-
-CA_EXTERN_C const ColorRef kRgbRed;
-CA_EXTERN_C const ColorRef kRgbGreen;
-CA_EXTERN_C const ColorRef kRgbBlue;
-CA_EXTERN_C const ColorRef kRgbBlack;
-CA_EXTERN_C const ColorRef kRgbWhite;
-
-/***********************************************************************************/
-/// Color macro.
-/***********************************************************************************/
-
-#define WmMakeColorRef(R, G, B) (ColorRef)(0x##R##G##B)
-
-#define kControlKindWindow 0
-#define kControlKindDialog 1
-#define kControlKindMenu 2
-#define kControlKindButton 3
-#define kControlKindLabel 4
-#define kControlKindDropdownMenu 5
-#define kControlKindIcon 6
-#define kControlKindRadioBox 7
-#define kControlKindCheckBox 8
-#define kControlKindUserDefined 9
-
-/// @brief Creates a new control
-/// @param id the control rsrc fork.
-/// @return
-CA_EXTERN_C WmControlPort* WmCreateControl(DWordType id);
-
-/// @brief Releases the control
-/// @param ctrlPort the control ref.
-/// @return
-CA_EXTERN_C VoidType WmReleaseControl(WmControlPort* ctrlPort);
-
-/// @brief Moves a control inside a WmControlPort.
-/// @param ctrlPort the control ref.
-/// @param where where to move at.
-/// @return
-CA_EXTERN_C Int32Type WmSetControlPosition(WmControlPort* ctrlPort, WmPoint where);
-
-/// @brief Enable control.
-/// @param ctrlPort
-/// @param enabled
-/// @return
-CA_EXTERN_C Int32Type WmSetControlEnabled(WmControlPort* ctrlPort, BooleanType enabled);
-
-/// @brief Make control visible.
-/// @param ctrlPort
-/// @param visible
-/// @return
-CA_EXTERN_C Int32Type WmSetControlVisible(WmControlPort* ctrlPort, BooleanType visible);
-
-/// @brief Creates a new window.
-/// @param name the window name
-/// @param rsrcId the window fork rsrc ctrlPort.
-/// @return the window graphics port.
-CA_EXTERN_C WindowPort* WmCreateWindow(const CharacterTypeUTF8* name, const DWordType rsrcId);
-
-/// @brief Creates a new menu
-/// @param name the menu's name
-/// @param rsrcId the menu fork rsrc ctrlPort.
-/// @return the menu graphics port.
-CA_EXTERN_C WindowPort* WmCreateMenu(const CharacterTypeUTF8* name, const DWordType rsrcId);
-
-/// @brief Releases the window.
-/// @param port the window port.
-/// @return void
-CA_EXTERN_C VoidType WmReleaseWindow(WindowPort* port);
-
-/// @brief Releases the menu
-/// @param port the menu port.
-/// @return void
-CA_EXTERN_C VoidType WmReleaseMenu(WindowPort* port);
-
-/// @brief Moves a window on the desktop. (menu arent movable, will return kErrIncompatible if menu is provided.)
-/// @param wndPort the gfx port.
-/// @param where to move.
-/// @return error code.
-CA_EXTERN_C Int32Type WmMoveWindow(WindowPort* wndPort, WmPoint where);
diff --git a/Public/Developer/SystemLib/Sources/App.c b/Public/Developer/SystemLib/Sources/App.c
index c85b2dd8..7778c064 100644
--- a/Public/Developer/SystemLib/Sources/App.c
+++ b/Public/Developer/SystemLib/Sources/App.c
@@ -7,7 +7,7 @@
#include <Headers/Defines.h>
/// @brief Main Application object, retrieved from the RtGetAppPointer symbol.
-ApplicationRef kSharedApplication = NullPtr;
+ApplicationInterfaceRef kSharedApplication = NullPtr;
/// @brief Gets the app arguments count.
/// @param void no arguments.
diff --git a/Public/Developer/SystemLib/Sources/TrueType.c b/Public/Developer/SystemLib/Sources/TrueType.c
deleted file mode 100644
index 49b1c2e8..00000000
--- a/Public/Developer/SystemLib/Sources/TrueType.c
+++ /dev/null
@@ -1,42 +0,0 @@
-/* -------------------------------------------
-
- Copyright Mahrouss Logic
-
-------------------------------------------- */
-
-#include <Headers/Defines.h>
-#include <Headers/TrueType.h>
-#include <Headers/File.h>
-#include <Headers/Heap.h>
-
-#define kTTFFork "fon " /* TrueType */
-
-/// @brief TrueType container reader
-typedef struct TTFReader
-{
- FSForkRef fFork;
- FSRef fFile;
- PtrVoidType fBlob; // cached blob
- SizeType fBlobSize; // cached blob size
- VoidType (*__fReadBytes)(SizeType count);
- VoidType (*__fSkipBytes)(SizeType count);
-} TTFReader;
-
-/// @brief Grab a TTF reader reference.
-/// @param fs filesystem reference.
-/// @return TTFReader* the new TTFReader type.
-CA_STATIC TTFReader* GrabTTFReader(FSRef fs)
-{
- FSForkRef forkRef = FsGetFork(fs, kTTFFork);
-
- if (forkRef = kInvalidRef)
- return NullPtr;
-
- TTFReader* reader = RtTlsAllocate(sizeof(TTFReader), kStandardAllocation);
-
- reader->fFile = fs;
- reader->fFork = forkRef;
-
- return reader;
-}
-/// EOF.
diff --git a/Public/Developer/SystemLib/Sources/Wm.c b/Public/Developer/SystemLib/Sources/Wm.c
deleted file mode 100644
index 607e7dcf..00000000
--- a/Public/Developer/SystemLib/Sources/Wm.c
+++ /dev/null
@@ -1,100 +0,0 @@
-/* -------------------------------------------
-
- Copyright Mahrouss Logic
-
-------------------------------------------- */
-
-#include <Headers/Wm.h>
-#include <Headers/Math.h>
-
-/// invalid resource handle, they always start from 1.
-#define kInvalidRsrc (0U)
-
-/// @brief Color refs.
-
-const ColorRef kRgbRed = 0x000000FF;
-const ColorRef kRgbGreen = 0x0000FF00;
-const ColorRef kRgbBlue = 0x00FF0000;
-const ColorRef kRgbBlack = 0x00000000;
-const ColorRef kRgbWhite = 0xFFFFFFFF;
-
-/////////////////////////////////////////////////////////////////////////
-
-CA_EXTERN_C WindowPort* WmCreateWindow(const CharacterTypeUTF8* name,
- const DWordType rsrcId)
-{
- CA_MUST_PASS(name);
- CA_MUST_PASS(rsrcId != kInvalidRsrc);
-
- if (!name)
- return NullPtr;
- if (rsrcId == kInvalidRsrc)
- return NullPtr;
-
- return (WindowPort*)kSharedApplication->Invoke(
- kSharedApplication, kCallCreateWindow, name, rsrcId);
-}
-
-/////////////////////////////////////////////////////////////////////////
-
-CA_EXTERN_C VoidType WmReleaseWindow(WindowPort* winPort)
-{
- CA_MUST_PASS(winPort);
- if (!winPort)
- return;
-
- kSharedApplication->Invoke(kSharedApplication, kCallCloseWindow, winPort);
-}
-
-/////////////////////////////////////////////////////////////////////////
-
-CA_EXTERN_C WindowPort* WmCreateMenu(const CharacterTypeUTF8* name,
- const DWordType rsrcId)
-{
- CA_MUST_PASS(name);
- CA_MUST_PASS(rsrcId != kInvalidRsrc);
-
- if (!name)
- return NullPtr;
- if (rsrcId == kInvalidRsrc)
- return NullPtr;
-
- return (WindowPort*)kSharedApplication->Invoke(kSharedApplication,
- kCallCreateMenu, name, rsrcId);
-}
-
-/////////////////////////////////////////////////////////////////////////
-
-CA_EXTERN_C VoidType WmReleaseMenu(WindowPort* winPort)
-{
- CA_MUST_PASS(winPort);
-
- if (!winPort)
- return;
- kSharedApplication->Invoke(kSharedApplication, kCallCloseMenu, winPort);
-}
-
-/////////////////////////////////////////////////////////////////////////
-
-CA_EXTERN_C Int32Type WmMoveWindow(WindowPort* wndPort, WmPoint where)
-{
- if (!wndPort)
- return kWmErrInvalidArg;
-
- wndPort->windowPosition.X = where.X;
- wndPort->windowPosition.Y = where.Y;
- wndPort->windowMoving = True;
-
- return 0;
-}
-
-/// @brief Causes the window to invalidate and redraw.
-/// @param wndPort The Window port.
-/// @return nothing.
-CA_EXTERN_C VoidType WmInvalidateGfx(WindowPort* wndPort)
-{
- if (wndPort)
- {
- wndPort->windowInvalidate = Yes;
- }
-}