diff options
| author | Amlal El Mahrouss <amlal@el-mahrouss-logic.com> | 2024-04-02 21:35:34 +0200 |
|---|---|---|
| committer | Amlal El Mahrouss <amlal@el-mahrouss-logic.com> | 2024-04-02 21:35:34 +0200 |
| commit | efc6b5d169d2b6eaabe7384141cec6054ae622a0 (patch) | |
| tree | 056fb3f24bcf0be7fb372106676349a1f5b644b8 /Public/Developer | |
| parent | 96d7e324ae1657216e6bb49a82466977d43d9a89 (diff) | |
OS: Changes related to System API, breaking changes, also added HTMLLib.
Signed-off-by: Amlal El Mahrouss <amlal@el-mahrouss-logic.com>
Diffstat (limited to 'Public/Developer')
| -rw-r--r-- | Public/Developer/CxxLib/Sources/New+Delete.cxx | 6 | ||||
| -rw-r--r-- | Public/Developer/HTMLLib/.gitkeep | 0 | ||||
| -rw-r--r-- | Public/Developer/HTMLLib/Headers/.gitkeep | 0 | ||||
| -rw-r--r-- | Public/Developer/HTMLLib/Headers/HTML.h | 50 | ||||
| -rw-r--r-- | Public/Developer/HTMLLib/Sources/.gitkeep | 0 | ||||
| -rw-r--r-- | Public/Developer/SystemLib/Headers/Defines.h | 47 | ||||
| -rw-r--r-- | Public/Developer/SystemLib/Headers/Heap.h | 8 | ||||
| -rw-r--r-- | Public/Developer/SystemLib/Headers/Rsrc.h | 9 | ||||
| -rw-r--r-- | Public/Developer/SystemLib/Headers/Window.h | 34 | ||||
| -rw-r--r-- | Public/Developer/SystemLib/Sources/Heap.c | 8 |
10 files changed, 114 insertions, 48 deletions
diff --git a/Public/Developer/CxxLib/Sources/New+Delete.cxx b/Public/Developer/CxxLib/Sources/New+Delete.cxx index c95da3e1..e065e1ed 100644 --- a/Public/Developer/CxxLib/Sources/New+Delete.cxx +++ b/Public/Developer/CxxLib/Sources/New+Delete.cxx @@ -11,17 +11,17 @@ typedef SizeType size_t; void* operator new[](size_t sz) { if (sz == 0) ++sz; - return RtAllocateProcessPtr(sz, kStandardAllocation); + return RtTlsAllocate(sz, kStandardAllocation); } void* operator new(size_t sz) { if (sz == 0) ++sz; - return RtAllocateProcessPtr(sz, kArrayAllocation); + return RtTlsAllocate(sz, kArrayAllocation); } void operator delete[](void* ptr) { if (ptr == nullptr) return; - RtFreeProcessPtr(ptr); + RtTlsFree(ptr); }
\ No newline at end of file diff --git a/Public/Developer/HTMLLib/.gitkeep b/Public/Developer/HTMLLib/.gitkeep new file mode 100644 index 00000000..e69de29b --- /dev/null +++ b/Public/Developer/HTMLLib/.gitkeep diff --git a/Public/Developer/HTMLLib/Headers/.gitkeep b/Public/Developer/HTMLLib/Headers/.gitkeep new file mode 100644 index 00000000..e69de29b --- /dev/null +++ b/Public/Developer/HTMLLib/Headers/.gitkeep diff --git a/Public/Developer/HTMLLib/Headers/HTML.h b/Public/Developer/HTMLLib/Headers/HTML.h new file mode 100644 index 00000000..6618f99f --- /dev/null +++ b/Public/Developer/HTMLLib/Headers/HTML.h @@ -0,0 +1,50 @@ +/* ------------------------------------------- + + Copyright Mahrouss Logic + +------------------------------------------- */ + +#pragma once + +#include <Headers/Defines.h> +#include <Headers/Window.h> + +struct _HtmlBody; +struct _HtmlDOMElement; + +CA_EXTERN_C VoidType HtmlLoadFile(const char* filePath, WindowPort* port, + BooleanType enforceJavascript, + BooleanType enforceHTTPS); + +CA_EXTERN_C VoidType HtmlLoadURL(const char* filePath, WindowPort* port, + BooleanType enforceJavascript, + BooleanType enforceHTTPS); + +CA_EXTERN_C VoidType HtmlLoadJavaScript(const char* code, WindowPort* port); + +CA_EXTERN_C VoidType HtmlLoadTypeScript(const char* code, WindowPort* port); + +typedef PtrVoidType HtmlPlugin; + +CA_EXTERN_C HtmlPlugin HtmlLoadPlugin(const char* pluginPath, WindowPort* port); + +CA_EXTERN_C VoidType HtmlUnloadPlugin(HtmlPlugin pluginHandle); + +typedef struct _HtmlBody { + CharacterTypeUTF8* Body; + SizeType BodyLength; +} HtmlBody, *HtmlBodyRef; + +/// @brief HTML Document, part of the DOM. +typedef struct _HtmlDOMElement { + StrType255 fNameElement; + struct _HtmlBody* fBodyElement; + + struct _HtmlDOMElement* fNextElement; + struct _HtmlDOMElement* fPrevElement; + struct _HtmlDOMElement* fChildElement; + struct _HtmlDOMElement* fParentElement; +} HtmlDOMElement, *HtmlDOMElementRef; + + +#define kHtmlRootElement "document" diff --git a/Public/Developer/HTMLLib/Sources/.gitkeep b/Public/Developer/HTMLLib/Sources/.gitkeep new file mode 100644 index 00000000..e69de29b --- /dev/null +++ b/Public/Developer/HTMLLib/Sources/.gitkeep diff --git a/Public/Developer/SystemLib/Headers/Defines.h b/Public/Developer/SystemLib/Headers/Defines.h index c4cc552b..6ab27497 100644 --- a/Public/Developer/SystemLib/Headers/Defines.h +++ b/Public/Developer/SystemLib/Headers/Defines.h @@ -26,6 +26,9 @@ #endif +struct Application; +struct GUID; + CA_EXTERN_C void __assert_chk_fail(void); #define CA_STDCALL __attribute__((stdcall)) @@ -57,26 +60,6 @@ typedef __INT32_TYPE__ Int32Type; typedef CharacterTypeUTF8 BooleanType; -#define CA_COPY_DELETE(KLASS) \ - KLASS &operator=(const KLASS &) = delete; \ - KLASS(const KLASS &) = delete; - - -#define CA_COPY_DEFAULT(KLASS) \ - KLASS &operator=(const KLASS &) = default; \ - KLASS(const KLASS &) = default; - - -#define CA_MOVE_DELETE(KLASS) \ - KLASS &operator=(KLASS &&) = delete; \ - KLASS(KLASS &&) = delete; - - -#define CA_MOVE_DEFAULT(KLASS) \ - KLASS &operator=(KLASS &&) = default; \ - KLASS(KLASS &&) = default; - - #define Yes 1 #define No 0 @@ -166,14 +149,34 @@ typedef struct Application { #ifdef __cplusplus -#define object_cast reinterpret_cast<ApplicationRef> +#define CA_COPY_DELETE(KLASS) \ + KLASS &operator=(const KLASS &) = delete; \ + KLASS(const KLASS &) = delete; + + +#define CA_COPY_DEFAULT(KLASS) \ + KLASS &operator=(const KLASS &) = default; \ + KLASS(const KLASS &) = default; + + +#define CA_MOVE_DELETE(KLASS) \ + KLASS &operator=(KLASS &&) = delete; \ + KLASS(KLASS &&) = delete; + + +#define CA_MOVE_DEFAULT(KLASS) \ + KLASS &operator=(KLASS &&) = default; \ + KLASS(KLASS &&) = default; + + +#define app_cast reinterpret_cast<ApplicationRef> template <SizeType N> using StrType = CharacterTypeUTF8[N]; #else -#define object_cast (ApplicationRef) +#define app_cast (ApplicationRef) #endif // ifdef C++ diff --git a/Public/Developer/SystemLib/Headers/Heap.h b/Public/Developer/SystemLib/Headers/Heap.h index 2dc13b0f..1c8873bd 100644 --- a/Public/Developer/SystemLib/Headers/Heap.h +++ b/Public/Developer/SystemLib/Headers/Heap.h @@ -19,20 +19,20 @@ enum RtAllocationKind { /// @param sz the size /// @param flags the allocation flags. /// @return -CA_EXTERN_C PtrVoidType RtAllocateProcessPtr(QWordType sz, +CA_EXTERN_C PtrVoidType RtTlsAllocate(QWordType sz, DWordType flags); /// @brief Check if the pointer exists. /// @param ptr the pointer to free. /// @return -CA_EXTERN_C BooleanType RtProcessPtrExists(PtrVoidType ptr); +CA_EXTERN_C BooleanType RtTlsPtrExists(PtrVoidType ptr); /// @brief Gets the size of the process' pointer. /// @param ptr the pointer to free. /// @return -CA_EXTERN_C QWordType RtProcessPtrSize(PtrVoidType ptr); +CA_EXTERN_C QWordType RtTlsGetSize(PtrVoidType ptr); /// @brief Frees the process pointer. /// @param ptr the pointer to free. /// @return -CA_EXTERN_C VoidType RtFreeProcessPtr(PtrVoidType ptr); +CA_EXTERN_C VoidType RtTlsFree(PtrVoidType ptr); diff --git a/Public/Developer/SystemLib/Headers/Rsrc.h b/Public/Developer/SystemLib/Headers/Rsrc.h new file mode 100644 index 00000000..1ff71332 --- /dev/null +++ b/Public/Developer/SystemLib/Headers/Rsrc.h @@ -0,0 +1,9 @@ +/* ------------------------------------------- + + Copyright Mahrouss Logic + +------------------------------------------- */ + +#pragma once + +#include <Headers/Defines.h> diff --git a/Public/Developer/SystemLib/Headers/Window.h b/Public/Developer/SystemLib/Headers/Window.h index 786197d5..1fd9e9e3 100644 --- a/Public/Developer/SystemLib/Headers/Window.h +++ b/Public/Developer/SystemLib/Headers/Window.h @@ -27,6 +27,10 @@ typedef float PositionType; typedef double PositionType; #endif +struct _ControlPort; +struct _WmPoint; +struct _WindowPort; + typedef QWordType DCRef; /// @brief A point, can represent the size, position of a window. @@ -48,8 +52,8 @@ typedef struct _WindowPort { WmPoint windowSize; BooleanType windowInvalidate; DWordType windowClearColor; - struct _WindowPort* menuPort; - struct _WindowPort* parentPort; + struct _WindowPort* windowMenuPort; ///! Attached menu to it. + struct _WindowPort* windowParentPort; } WindowPort; /// @brief Control port type. @@ -94,72 +98,72 @@ CA_EXTERN_C const ColorRef kRgbWhite; /// @brief Creates a new control /// @param id the control rsrc fork. /// @return -CA_EXTERN_C ControlPort* WmCreateControl(DWordType id); +CA_EXTERN_C ControlPort* WmCreateControl(DWordType id); /// @brief Releases the control /// @param id the control ref. /// @return -CA_EXTERN_C VoidType WmReleaseControl(ControlPort* id); +CA_EXTERN_C VoidType WmReleaseControl(ControlPort* id); /// @brief Moves a control inside a ControlPort. /// @param id the control ref. /// @param where where to move at. /// @return -CA_EXTERN_C Int32Type WmSetControlPosition(ControlPort* id, WmPoint where); +CA_EXTERN_C Int32Type WmSetControlPosition(ControlPort* id, WmPoint where); /// @brief Enable control. /// @param id /// @param enabled /// @return -CA_EXTERN_C Int32Type WmSetControlEnabled(ControlPort* id, BooleanType enabled); +CA_EXTERN_C Int32Type WmSetControlEnabled(ControlPort* id, BooleanType enabled); /// @brief Make control visible. /// @param id /// @param visible /// @return -CA_EXTERN_C Int32Type WmMakeControlVisible(ControlPort* id, BooleanType visible); +CA_EXTERN_C Int32Type WmMakeControlVisible(ControlPort* id, BooleanType visible); /// @brief Creates a new window. /// @param name the window name /// @param rsrcId the window fork rsrc id. /// @return the window graphics port. -CA_EXTERN_C WindowPort* WmCreateWindow(const CharacterTypeUTF8* name, const DWordType rsrcId); +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 id. /// @return the menu graphics port. -CA_EXTERN_C WindowPort* WmCreateMenu(const CharacterTypeUTF8* name, const DWordType rsrcId); +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); +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); +CA_EXTERN_C VoidType WmReleaseMenu(WindowPort* 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 WmMoveWindow(WindowPort* id, WmPoint where); +CA_EXTERN_C Int32Type WmMoveWindow(WindowPort* id, WmPoint where); /// @brief Get last message. /// @param id /// @return -CA_EXTERN_C Int64Type WmGetMessage(WindowPort* id); +CA_EXTERN_C Int64Type WmGetMessage(WindowPort* id); /// @brief Translate message internally. /// @return -CA_EXTERN_C VoidType WmTranslateMessage(WindowPort* port, Int64Type msg); +CA_EXTERN_C VoidType WmTranslateMessage(WindowPort* port, Int64Type msg); /// @brief Dispatch message to event queue. /// @param id /// @return -CA_EXTERN_C Int32Type WmDispatchMessage(WindowPort* id); +CA_EXTERN_C Int32Type WmDispatchMessage(WindowPort* id); enum { kWmErrIncompatible = 0x74, diff --git a/Public/Developer/SystemLib/Sources/Heap.c b/Public/Developer/SystemLib/Sources/Heap.c index c9b2b938..c866ef5d 100644 --- a/Public/Developer/SystemLib/Sources/Heap.c +++ b/Public/Developer/SystemLib/Sources/Heap.c @@ -10,7 +10,7 @@ /// @param sz size of object. /// @param flags flags. /// @return -CA_EXTERN_C PtrVoidType RtAllocateProcessPtr(QWordType sz, +CA_EXTERN_C PtrVoidType RtTlsAllocate(QWordType sz, DWordType flags) { CA_MUST_PASS(sz); CA_MUST_PASS(flags); @@ -20,7 +20,7 @@ CA_EXTERN_C PtrVoidType RtAllocateProcessPtr(QWordType sz, /// @brief Free pointer from the user's heap. /// @param ptr the pointer to free. -CA_EXTERN_C VoidType RtFreeProcessPtr(PtrVoidType ptr) { +CA_EXTERN_C VoidType RtTlsFree(PtrVoidType ptr) { CA_MUST_PASS(ptr); CA_UNREFERENCED_PARAMETER(kSharedApplication->Invoke(kSharedApplication, kCallFreePtr, ptr)); } @@ -28,7 +28,7 @@ CA_EXTERN_C VoidType RtFreeProcessPtr(PtrVoidType ptr) { /// @brief Get pointer size. /// @param ptr the pointer to find. /// @return the size. -CA_EXTERN_C QWordType RtProcessPtrSize(PtrVoidType ptr) { +CA_EXTERN_C QWordType RtTlsGetSize(PtrVoidType ptr) { CA_MUST_PASS(ptr); return kSharedApplication->Invoke(kSharedApplication, kCallSizePtr, ptr); } @@ -36,7 +36,7 @@ CA_EXTERN_C QWordType RtProcessPtrSize(PtrVoidType ptr) { /// @brief Check if the pointer exists. /// @param ptr the pointer to check. /// @return if it exists -CA_EXTERN_C BooleanType RtProcessPtrExists(PtrVoidType ptr) { +CA_EXTERN_C BooleanType RtTlsPtrExists(PtrVoidType ptr) { CA_MUST_PASS(ptr); return kSharedApplication->Invoke(kSharedApplication, kCallCheckPtr, ptr); } |
