From d48cbe75ef29a9c67c9d176bf58e56ea6448fb9e Mon Sep 17 00:00:00 2001 From: Amlal El Mahrouss Date: Mon, 21 Oct 2024 20:23:36 +0200 Subject: IMP: Major refactor of header and source files extensions. Signed-off-by: Amlal El Mahrouss --- dev/sci/makefile | 2 +- dev/sci/sci.json | 2 +- dev/sci/sci_base.h | 322 ++++++++++++++++++++++++++++++++++++++++++++++ dev/sci/sci_base.hxx | 322 ---------------------------------------------- dev/sci/sci_hint.h | 23 ++++ dev/sci/sci_hint.hxx | 23 ---- dev/sci/sci_lpc.h | 48 +++++++ dev/sci/sci_lpc.hxx | 48 ------- dev/sci/source_deploy.xml | 2 +- dev/sci/src/sci_mm.cc | 45 +++++++ dev/sci/src/sci_mm.cxx | 45 ------- dev/sci/xpcom_core.h | 99 ++++++++++++++ dev/sci/xpcom_core.hxx | 99 -------------- 13 files changed, 540 insertions(+), 540 deletions(-) create mode 100644 dev/sci/sci_base.h delete mode 100644 dev/sci/sci_base.hxx create mode 100644 dev/sci/sci_hint.h delete mode 100644 dev/sci/sci_hint.hxx create mode 100644 dev/sci/sci_lpc.h delete mode 100644 dev/sci/sci_lpc.hxx create mode 100644 dev/sci/src/sci_mm.cc delete mode 100644 dev/sci/src/sci_mm.cxx create mode 100644 dev/sci/xpcom_core.h delete mode 100644 dev/sci/xpcom_core.hxx (limited to 'dev/sci') diff --git a/dev/sci/makefile b/dev/sci/makefile index 05593216..f18fbeff 100644 --- a/dev/sci/makefile +++ b/dev/sci/makefile @@ -9,4 +9,4 @@ OUTPUT=sci.dll .PHONY: build-sci build-sci: - $(CC) $(wildcard *.cxx) $(FLAGS) -o $(OUTPUT) + $(CC) $(wildcard .cc) $(FLAGS) -o $(OUTPUT) diff --git a/dev/sci/sci.json b/dev/sci/sci.json index 32a9238b..104be044 100644 --- a/dev/sci/sci.json +++ b/dev/sci/sci.json @@ -2,7 +2,7 @@ "compiler_path": "x86_64-w64-mingw32-g++", "compiler_std": "c++20", "headers_path": ["../"], - "sources_path": ["src/*.cxx"], + "sources_path": ["src/*.cc"], "output_name": "sci.dll", "compiler_flags": [ "-fPIC", diff --git a/dev/sci/sci_base.h b/dev/sci/sci_base.h new file mode 100644 index 00000000..f9babe13 --- /dev/null +++ b/dev/sci/sci_base.h @@ -0,0 +1,322 @@ +/* ------------------------------------------- + +Copyright ZKA Web Services Co. + +File: sci_base.h +Purpose: SCI core header file (C++ only). + +------------------------------------------- */ + +#ifndef __SCI_BASE_HXX__ +#define __SCI_BASE_HXX__ + +#include + +#define ATTRIBUTE(X) __attribute__((X)) + +#define IMPORT_XPCOM extern "XPCOM" +#define IMPORT_CXX extern "C++" +#define IMPORT_C extern "C" + +typedef bool Bool; +typedef void Void; + +typedef __UINT64_TYPE__ UInt64; +typedef __UINT32_TYPE__ UInt32; +typedef __UINT16_TYPE__ UInt16; +typedef __UINT8_TYPE__ UInt8; + +typedef __SIZE_TYPE__ SizeT; + +typedef __INT64_TYPE__ SInt64; +typedef __INT32_TYPE__ SInt32; +typedef __INT16_TYPE__ SInt16; +typedef __INT8_TYPE__ SInt8; + +typedef void* VoidPtr; +typedef __UINTPTR_TYPE__ UIntPtr; +typedef char Char; + +#include + +#ifdef __XPCOM_IMPL__ +#include +#else +class IUnknown; // Refrenced from an IDB entry. +class ICLSID; // From the IDB, the constructor of the object, e.g: IAppCLSID. +class UUID; + +class ATTRIBUTE(uuid("d7c144b6-0792-44b8-b06b-02b227b547df")) IUnknown +{ +public: + explicit IUnknown() = default; + virtual ~IUnknown() = default; + + IUnknown& operator=(const IUnknown&) = default; + IUnknown(const IUnknown&) = default; + + virtual SInt32 Release() = 0; + virtual void RemoveRef() = 0; + virtual IUnknown* AddRef() = 0; + virtual VoidPtr QueryClass(UUID* p_uuid) = 0; +}; + +template +class IEventListener : public ClsID +{ + friend ClsID; + + explicit IEventListener() = default; + virtual ~IEventListener() = default; + + IEventListener& operator=(const IEventListener&) = default; + IEventListener(const IEventListener&) = default; + + virtual IEventListener& operator-=(const Char* event_name); + virtual IEventListener& operator+=(FnSign arg) = 0; +}; +#endif + +// ------------------------------------------------------------------------------------------ // +/// @note Handle typedefs. +// ------------------------------------------------------------------------------------------ // + +typedef VoidPtr Object; + +typedef Object DLLObject; +typedef Object IOObject; +typedef Object SCMObject; +typedef Object ThreadObject; +typedef Object SocketObject; +typedef Object ShellObject; +typedef Object UIObject; + +// ------------------------------------------------------------------------------------------ // + +// ------------------------------------------------------------------------------------------ // +/// @note Dynamic Loader API. +// ------------------------------------------------------------------------------------------ // + +/// @brief Get function which is part of the DLL. +/// @param symbol the symbol to look for +/// @param dll_handle the DLL handle. +/// @return the proc pointer. +IMPORT_C Object LdrGetDLLSymbolFromHandle(_Input const Char* symbol, _Input Object dll_handle); + +/// @brief Open DLL handle. +/// @param path +/// @param drv +/// @return +IMPORT_C Object LdrOpenDLLHandle(_Input const Char* path, _Input const Char* drive_letter); + +/// @brief Close DLL handle +/// @param dll_handle +/// @return +IMPORT_C Void LdrCloseDLLHandle(_Input Object* dll_handle); + +// ------------------------------------------------------------------------------------------ // +// File API. +// ------------------------------------------------------------------------------------------ // + +/// @brief Opens a file from a drive. +/// @param fs_path the filesystem path. +/// @param drive_letter drive name, use NULL to use default one. +/// @return the file descriptor of the file. +IMPORT_C Object IoOpenFile(const Char* fs_path, const Char* drive_letter); + +/// @brief Closes a file and flushes its content. +/// @param file_desc the file descriptor. +/// @return void. +IMPORT_C Void IoCloseFile(_Input Object file_desc); + +/// @brief Write data to a file. +/// @param file_desc the file descriptor. +/// @param out_data the data to write. +/// @param sz_data the size of the data to write. +/// @return the number of bytes written. +IMPORT_C UInt32 IoWriteFile(_Input Object file_desc, _Output VoidPtr out_data, SizeT sz_data); + +/// @brief Read data from a file. +/// @param file_desc the file descriptor. +/// @param out_data the data to read. +/// @param sz_data the size of the data to read. +IMPORT_C UInt32 IoReadFile(_Input Object file_desc, _Output VoidPtr* out_data, SizeT sz_data); + +/// @brief Rewind the file pointer to the beginning of the file. +/// @param file_desc the file descriptor. +/// @return the number of bytes read. +IMPORT_C UInt64 IoRewindFile(_Input Object file_desc); + +/// @brief Tell the current position of the file pointer. +/// @param file_desc the file descriptor. +/// @return the current position of the file pointer. +IMPORT_C UInt64 IoTellFile(_Input Object file_desc); + +IMPORT_C UInt64 IoSeekFile(_Input Object file_desc, UInt64 file_offset); + +// ------------------------------------------------------------------------ +// TLS API. +// ------------------------------------------------------------------------ + +/// @brief Installs the Thread Information Block and Global Information Block inside the current process. +/// @param void. +/// @return > 0 error ocurred or already present, = 0 success. +IMPORT_C UInt32 RtlTlsInstall(Void); + +#ifndef __XPCOM_IMPL__ + +// ------------------------------------------------------------------------ +// XPCOM API. +// ------------------------------------------------------------------------ + +/// @brief Allocate new XPCOM object. +/// @tparam TCLS the class type. +/// @tparam UCLSID UCLS factory class type. +/// @param uclsidOfCls UCLS factory class +/// @return TCLS interface +template +TCLS* XPCOMQueryClass(_Input UCLSID* uclsidOfCls, _Input Args&&... args); + +/// @brief Release XPCOM object. +/// @tparam TCLS the class type. +/// @param cls the class to release. +/// @return status code. +template +SInt32 XPCOMReleaseClass(_Input TCLS* cls); + +/// @brief Creates an XPCOM instance in the process. +/// @param handle_instance the XPCOM handle. +/// @param flags the XPCOM flags. +IMPORT_C SInt32 XPCOMCreateInstance(_Input UInt32 flags, _Output Object* handle_instance); + +/// @brief Destroys an XPCOM instance of the process. +/// @param handle_instance the XPCOM handle. +IMPORT_C Void XPCOMDestroyInstance(_Input Object handle_instance); + +#endif // !__XPCOM_IMPL__ + +// ------------------------------------------------------------------------ +// Memory Management API. +// ------------------------------------------------------------------------ + +/// @brief Creates a new heap from the process's address space. +/// @param len the length of it. +/// @param flags the flags of it. +/// @return heap pointer. +IMPORT_C VoidPtr MmCreateHeap(_Input SizeT len, _Input UInt32 flags); + +/// @brief Destroys the pointer +/// @param heap the heap itself. +/// @return void. +IMPORT_C Void MmDestroyHeap(_Input VoidPtr heap); + +/// @brief Change protection flags of a memory region. +IMPORT_C Void MmSetHeapFlags(_Input VoidPtr heap, _Input UInt32 flags); + +/// @brief Change protection flags of a memory region. +IMPORT_C UInt32 MmGetHeapFlags(_Input VoidPtr heap); + +/// @brief Fill memory region with CRC32. +IMPORT_C UInt32 MmFillCRC32Heap(_Input VoidPtr heap); + +/// @brief Copy memory region. +IMPORT_C VoidPtr MmCopyMemory(_Input VoidPtr dest, _Input VoidPtr src, _Input SizeT len); + +/// @brief Fill memory region. +IMPORT_C VoidPtr MmFillMemory(_Input VoidPtr dest, _Input SizeT len, _Input UInt8 value); + +// ------------------------------------------------------------------------ +// Error handling API. +// ------------------------------------------------------------------------ + +IMPORT_C SInt32 ErrGetLastError(Void); + +// ------------------------------------------------------------------------ +// Threading API. +// ------------------------------------------------------------------------ + +/// @brief Exit the current thread. +/// @param exit_code the exit code. +IMPORT_C Void ThrExitCurrentThread(_Input SInt32 exit_code); + +/// @brief Exit the main thread. +/// @param exit_code the exit code. +IMPORT_C Void ThrExitMainThread(_Input SInt32 exit_code); + +/// @brief Exit a thread. +/// @param thread the thread to exit. +/// @param exit_code the exit code. +IMPORT_C Void ThrExitThread(_Input ThreadObject thread, _Input SInt32 exit_code); + +typedef Void (*ThreadProc)(Void); + +/// @brief Create a thread. +/// @param procedure the thread procedure. +/// @param argument_count number of arguments inside that thread. +/// @param flags Thread flags. +/// @return the thread object. +IMPORT_C ThreadObject ThrCreateThread(ThreadProc procedure, SInt32 argument_count, SInt32 flags); + +/// @brief Yield the current thread. +/// @param thread the thread to yield. +IMPORT_C Void ThrExitYieldThread(Void); + +/// @brief Join a thread. +/// @param thread the thread to join. +IMPORT_C Void ThrExitJoinThread(Void); + +/// @brief Detach a thread. +/// @param thread the thread to detach. +IMPORT_C Void ThrExitDetachThread(Void); + +// ------------------------------------------------------------------------ +// Drive Management API. +// ------------------------------------------------------------------------ + +/// @brief Get the default drive letter. +/// @param void. +/// @return the drive letter. +IMPORT_C Char* DrvGetDefaultDriveLetter(Void); + +/// @brief Get the drive letter from a path. +/// @param path the path. +/// @return the drive letter. +IMPORT_C Char* DrvGetDriveLetterFromPath(_Input const Char* path); + +/// @brief Get a mounted drive from a letter. +/// @param letter the letter (A..Z). +/// @return the drive object. +IMPORT_C Object DrvGetMountedDrive(_Input const Char letter); + +/// @brief Mount a drive. +/// @param path the path to mount. +/// @param letter the letter to mount. +IMPORT_C Void DrvMountDrive(_Input const Char* path, _Input const Char* letter); + +/// @brief Unmount a drive. +/// @param letter the letter to unmount. +IMPORT_C Void DrvUnmountDrive(_Input const Char letter); + +// ------------------------------------------------------------------------ +// Event handling API, use to listen to OS specific events. +// ------------------------------------------------------------------------ + +/// @brief Add an event listener. +/// @param event_name the event name. +/// @param listener the listener to add. +/// @return the event listener. +IMPORT_C Void EvtAddListener(_Input const Char* event_name, _Input Object listener); + +/// @brief Remove an event listener. +/// @param event_name the event name. +/// @param listener the listener to remove. +/// @return the event listener. +IMPORT_C Void EvtRemoveListener(_Input const Char* event_name, _Input Object listener); + +/// @brief Dispatch an event. +/// @param event_name the event name. +/// @param event_data the event data. +/// @return the event data. +IMPORT_C VoidPtr EvtDispatchEvent(_Input const Char* event_name, _Input VoidPtr event_data); + +#endif // ifndef __SCI_BASE_HXX__ diff --git a/dev/sci/sci_base.hxx b/dev/sci/sci_base.hxx deleted file mode 100644 index de87318b..00000000 --- a/dev/sci/sci_base.hxx +++ /dev/null @@ -1,322 +0,0 @@ -/* ------------------------------------------- - -Copyright ZKA Web Services Co. - -File: sci_base.hxx -Purpose: SCI core header file (C++ only). - -------------------------------------------- */ - -#ifndef __SCI_BASE_HXX__ -#define __SCI_BASE_HXX__ - -#include - -#define ATTRIBUTE(X) __attribute__((X)) - -#define IMPORT_XPCOM extern "XPCOM" -#define IMPORT_CXX extern "C++" -#define IMPORT_C extern "C" - -typedef bool Bool; -typedef void Void; - -typedef __UINT64_TYPE__ UInt64; -typedef __UINT32_TYPE__ UInt32; -typedef __UINT16_TYPE__ UInt16; -typedef __UINT8_TYPE__ UInt8; - -typedef __SIZE_TYPE__ SizeT; - -typedef __INT64_TYPE__ SInt64; -typedef __INT32_TYPE__ SInt32; -typedef __INT16_TYPE__ SInt16; -typedef __INT8_TYPE__ SInt8; - -typedef void* VoidPtr; -typedef __UINTPTR_TYPE__ UIntPtr; -typedef char Char; - -#include - -#ifdef __XPCOM_IMPL__ -#include -#else -class IUnknown; // Refrenced from an IDB entry. -class ICLSID; // From the IDB, the constructor of the object, e.g: IAppCLSID. -class UUID; - -class ATTRIBUTE(uuid("d7c144b6-0792-44b8-b06b-02b227b547df")) IUnknown -{ -public: - explicit IUnknown() = default; - virtual ~IUnknown() = default; - - IUnknown& operator=(const IUnknown&) = default; - IUnknown(const IUnknown&) = default; - - virtual SInt32 Release() = 0; - virtual void RemoveRef() = 0; - virtual IUnknown* AddRef() = 0; - virtual VoidPtr QueryClass(UUID* p_uuid) = 0; -}; - -template -class IEventListener : public ClsID -{ - friend ClsID; - - explicit IEventListener() = default; - virtual ~IEventListener() = default; - - IEventListener& operator=(const IEventListener&) = default; - IEventListener(const IEventListener&) = default; - - virtual IEventListener& operator-=(const Char* event_name); - virtual IEventListener& operator+=(FnSign arg) = 0; -}; -#endif - -// ------------------------------------------------------------------------------------------ // -/// @note Handle typedefs. -// ------------------------------------------------------------------------------------------ // - -typedef VoidPtr Object; - -typedef Object DLLObject; -typedef Object IOObject; -typedef Object SCMObject; -typedef Object ThreadObject; -typedef Object SocketObject; -typedef Object ShellObject; -typedef Object UIObject; - -// ------------------------------------------------------------------------------------------ // - -// ------------------------------------------------------------------------------------------ // -/// @note Dynamic Loader API. -// ------------------------------------------------------------------------------------------ // - -/// @brief Get function which is part of the DLL. -/// @param symbol the symbol to look for -/// @param dll_handle the DLL handle. -/// @return the proc pointer. -IMPORT_C Object LdrGetDLLSymbolFromHandle(_Input const Char* symbol, _Input Object dll_handle); - -/// @brief Open DLL handle. -/// @param path -/// @param drv -/// @return -IMPORT_C Object LdrOpenDLLHandle(_Input const Char* path, _Input const Char* drive_letter); - -/// @brief Close DLL handle -/// @param dll_handle -/// @return -IMPORT_C Void LdrCloseDLLHandle(_Input Object* dll_handle); - -// ------------------------------------------------------------------------------------------ // -// File API. -// ------------------------------------------------------------------------------------------ // - -/// @brief Opens a file from a drive. -/// @param fs_path the filesystem path. -/// @param drive_letter drive name, use NULL to use default one. -/// @return the file descriptor of the file. -IMPORT_C Object IoOpenFile(const Char* fs_path, const Char* drive_letter); - -/// @brief Closes a file and flushes its content. -/// @param file_desc the file descriptor. -/// @return void. -IMPORT_C Void IoCloseFile(_Input Object file_desc); - -/// @brief Write data to a file. -/// @param file_desc the file descriptor. -/// @param out_data the data to write. -/// @param sz_data the size of the data to write. -/// @return the number of bytes written. -IMPORT_C UInt32 IoWriteFile(_Input Object file_desc, _Output VoidPtr out_data, SizeT sz_data); - -/// @brief Read data from a file. -/// @param file_desc the file descriptor. -/// @param out_data the data to read. -/// @param sz_data the size of the data to read. -IMPORT_C UInt32 IoReadFile(_Input Object file_desc, _Output VoidPtr* out_data, SizeT sz_data); - -/// @brief Rewind the file pointer to the beginning of the file. -/// @param file_desc the file descriptor. -/// @return the number of bytes read. -IMPORT_C UInt64 IoRewindFile(_Input Object file_desc); - -/// @brief Tell the current position of the file pointer. -/// @param file_desc the file descriptor. -/// @return the current position of the file pointer. -IMPORT_C UInt64 IoTellFile(_Input Object file_desc); - -IMPORT_C UInt64 IoSeekFile(_Input Object file_desc, UInt64 file_offset); - -// ------------------------------------------------------------------------ -// TLS API. -// ------------------------------------------------------------------------ - -/// @brief Installs the Thread Information Block and Global Information Block inside the current process. -/// @param void. -/// @return > 0 error ocurred or already present, = 0 success. -IMPORT_C UInt32 RtlTlsInstall(Void); - -#ifndef __XPCOM_IMPL__ - -// ------------------------------------------------------------------------ -// XPCOM API. -// ------------------------------------------------------------------------ - -/// @brief Allocate new XPCOM object. -/// @tparam TCLS the class type. -/// @tparam UCLSID UCLS factory class type. -/// @param uclsidOfCls UCLS factory class -/// @return TCLS interface -template -TCLS* XPCOMQueryClass(_Input UCLSID* uclsidOfCls, _Input Args&&... args); - -/// @brief Release XPCOM object. -/// @tparam TCLS the class type. -/// @param cls the class to release. -/// @return status code. -template -SInt32 XPCOMReleaseClass(_Input TCLS* cls); - -/// @brief Creates an XPCOM instance in the process. -/// @param handle_instance the XPCOM handle. -/// @param flags the XPCOM flags. -IMPORT_C SInt32 XPCOMCreateInstance(_Input UInt32 flags, _Output Object* handle_instance); - -/// @brief Destroys an XPCOM instance of the process. -/// @param handle_instance the XPCOM handle. -IMPORT_C Void XPCOMDestroyInstance(_Input Object handle_instance); - -#endif // !__XPCOM_IMPL__ - -// ------------------------------------------------------------------------ -// Memory Management API. -// ------------------------------------------------------------------------ - -/// @brief Creates a new heap from the process's address space. -/// @param len the length of it. -/// @param flags the flags of it. -/// @return heap pointer. -IMPORT_C VoidPtr MmCreateHeap(_Input SizeT len, _Input UInt32 flags); - -/// @brief Destroys the pointer -/// @param heap the heap itself. -/// @return void. -IMPORT_C Void MmDestroyHeap(_Input VoidPtr heap); - -/// @brief Change protection flags of a memory region. -IMPORT_C Void MmSetHeapFlags(_Input VoidPtr heap, _Input UInt32 flags); - -/// @brief Change protection flags of a memory region. -IMPORT_C UInt32 MmGetHeapFlags(_Input VoidPtr heap); - -/// @brief Fill memory region with CRC32. -IMPORT_C UInt32 MmFillCRC32Heap(_Input VoidPtr heap); - -/// @brief Copy memory region. -IMPORT_C VoidPtr MmCopyMemory(_Input VoidPtr dest, _Input VoidPtr src, _Input SizeT len); - -/// @brief Fill memory region. -IMPORT_C VoidPtr MmFillMemory(_Input VoidPtr dest, _Input SizeT len, _Input UInt8 value); - -// ------------------------------------------------------------------------ -// Error handling API. -// ------------------------------------------------------------------------ - -IMPORT_C SInt32 ErrGetLastError(Void); - -// ------------------------------------------------------------------------ -// Threading API. -// ------------------------------------------------------------------------ - -/// @brief Exit the current thread. -/// @param exit_code the exit code. -IMPORT_C Void ThrExitCurrentThread(_Input SInt32 exit_code); - -/// @brief Exit the main thread. -/// @param exit_code the exit code. -IMPORT_C Void ThrExitMainThread(_Input SInt32 exit_code); - -/// @brief Exit a thread. -/// @param thread the thread to exit. -/// @param exit_code the exit code. -IMPORT_C Void ThrExitThread(_Input ThreadObject thread, _Input SInt32 exit_code); - -typedef Void (*ThreadProc)(Void); - -/// @brief Create a thread. -/// @param procedure the thread procedure. -/// @param argument_count number of arguments inside that thread. -/// @param flags Thread flags. -/// @return the thread object. -IMPORT_C ThreadObject ThrCreateThread(ThreadProc procedure, SInt32 argument_count, SInt32 flags); - -/// @brief Yield the current thread. -/// @param thread the thread to yield. -IMPORT_C Void ThrExitYieldThread(Void); - -/// @brief Join a thread. -/// @param thread the thread to join. -IMPORT_C Void ThrExitJoinThread(Void); - -/// @brief Detach a thread. -/// @param thread the thread to detach. -IMPORT_C Void ThrExitDetachThread(Void); - -// ------------------------------------------------------------------------ -// Drive Management API. -// ------------------------------------------------------------------------ - -/// @brief Get the default drive letter. -/// @param void. -/// @return the drive letter. -IMPORT_C Char* DrvGetDefaultDriveLetter(Void); - -/// @brief Get the drive letter from a path. -/// @param path the path. -/// @return the drive letter. -IMPORT_C Char* DrvGetDriveLetterFromPath(_Input const Char* path); - -/// @brief Get a mounted drive from a letter. -/// @param letter the letter (A..Z). -/// @return the drive object. -IMPORT_C Object DrvGetMountedDrive(_Input const Char letter); - -/// @brief Mount a drive. -/// @param path the path to mount. -/// @param letter the letter to mount. -IMPORT_C Void DrvMountDrive(_Input const Char* path, _Input const Char* letter); - -/// @brief Unmount a drive. -/// @param letter the letter to unmount. -IMPORT_C Void DrvUnmountDrive(_Input const Char letter); - -// ------------------------------------------------------------------------ -// Event handling API, use to listen to OS specific events. -// ------------------------------------------------------------------------ - -/// @brief Add an event listener. -/// @param event_name the event name. -/// @param listener the listener to add. -/// @return the event listener. -IMPORT_C Void EvtAddListener(_Input const Char* event_name, _Input Object listener); - -/// @brief Remove an event listener. -/// @param event_name the event name. -/// @param listener the listener to remove. -/// @return the event listener. -IMPORT_C Void EvtRemoveListener(_Input const Char* event_name, _Input Object listener); - -/// @brief Dispatch an event. -/// @param event_name the event name. -/// @param event_data the event data. -/// @return the event data. -IMPORT_C VoidPtr EvtDispatchEvent(_Input const Char* event_name, _Input VoidPtr event_data); - -#endif // ifndef __SCI_BASE_HXX__ diff --git a/dev/sci/sci_hint.h b/dev/sci/sci_hint.h new file mode 100644 index 00000000..967d0ad0 --- /dev/null +++ b/dev/sci/sci_hint.h @@ -0,0 +1,23 @@ +/* ------------------------------------------- + + Copyright ZKA Web Services Co. + +------------------------------------------- */ + +#ifndef __SCI_HINT_HXX__ +#define __SCI_HINT_HXX__ + +#pragma compiler(hint_manifest) + +#define _Input +#define _Output + +#define _Optional + +#define _StrictCheckInput +#define _StrictCheckOutput + +#define _InOut +#define _StrictInOut + +#endif // ifndef __SCI_HINT_HXX__ diff --git a/dev/sci/sci_hint.hxx b/dev/sci/sci_hint.hxx deleted file mode 100644 index 967d0ad0..00000000 --- a/dev/sci/sci_hint.hxx +++ /dev/null @@ -1,23 +0,0 @@ -/* ------------------------------------------- - - Copyright ZKA Web Services Co. - -------------------------------------------- */ - -#ifndef __SCI_HINT_HXX__ -#define __SCI_HINT_HXX__ - -#pragma compiler(hint_manifest) - -#define _Input -#define _Output - -#define _Optional - -#define _StrictCheckInput -#define _StrictCheckOutput - -#define _InOut -#define _StrictInOut - -#endif // ifndef __SCI_HINT_HXX__ diff --git a/dev/sci/sci_lpc.h b/dev/sci/sci_lpc.h new file mode 100644 index 00000000..c634b790 --- /dev/null +++ b/dev/sci/sci_lpc.h @@ -0,0 +1,48 @@ +/* ------------------------------------------- + + Copyright ZKA Web Services Co. + +------------------------------------------- */ + +#pragma once + +#define ErrLocalIsOk() (kLastError == kErrorSuccess) +#define ErrLocalFailed() (kLastError != kErrorSuccess) +#define ErrLocal() (kLastError) + +typedef SInt32 ErrObject; + +inline constexpr ErrObject kErrorSuccess = 0; +inline constexpr ErrObject kErrorExecutable = 33; +inline constexpr ErrObject kErrorExecutableLib = 34; +inline constexpr ErrObject kErrorFileNotFound = 35; +inline constexpr ErrObject kErrorDirectoryNotFound = 36; +inline constexpr ErrObject kErrorDiskReadOnly = 37; +inline constexpr ErrObject kErrorDiskIsFull = 38; +inline constexpr ErrObject kErrorProcessFault = 39; +inline constexpr ErrObject kErrorSocketHangUp = 40; +inline constexpr ErrObject kErrorThreadLocalStorage = 41; +inline constexpr ErrObject kErrorMath = 42; +inline constexpr ErrObject kErrorNoNetwork = 43; +inline constexpr ErrObject kErrorHeapOutOfMemory = 44; +inline constexpr ErrObject kErrorNoSuchDisk = 45; +inline constexpr ErrObject kErrorFileExists = 46; +inline constexpr ErrObject kErrorFormatFailed = 47; +inline constexpr ErrObject kErrorNetworkTimeout = 48; +inline constexpr ErrObject kErrorInternal = 49; +inline constexpr ErrObject kErrorForkAlreadyExists = 50; +inline constexpr ErrObject kErrorOutOfTeamSlot = 51; +inline constexpr ErrObject kErrorHeapNotPresent = 52; +inline constexpr ErrObject kErrorNoEntrypoint = 53; +inline constexpr ErrObject kErrorDiskIsCorrupted = 54; +inline constexpr ErrObject kErrorDisk = 55; +inline constexpr ErrObject kErrorInvalidData = 56; +inline constexpr ErrObject kErrorAsync = 57; +inline constexpr ErrObject kErrorNonBlocking = 58; +inline constexpr ErrObject kErrorIPC = 59; +inline constexpr ErrObject kErrorSign = 60; +inline constexpr ErrObject kErrorInvalidCreds = 61; +inline constexpr ErrObject kErrorUnimplemented = 0; + +/// @brief The last error reported by the system to the process. +IMPORT_C ErrObject kLastError; diff --git a/dev/sci/sci_lpc.hxx b/dev/sci/sci_lpc.hxx deleted file mode 100644 index c634b790..00000000 --- a/dev/sci/sci_lpc.hxx +++ /dev/null @@ -1,48 +0,0 @@ -/* ------------------------------------------- - - Copyright ZKA Web Services Co. - -------------------------------------------- */ - -#pragma once - -#define ErrLocalIsOk() (kLastError == kErrorSuccess) -#define ErrLocalFailed() (kLastError != kErrorSuccess) -#define ErrLocal() (kLastError) - -typedef SInt32 ErrObject; - -inline constexpr ErrObject kErrorSuccess = 0; -inline constexpr ErrObject kErrorExecutable = 33; -inline constexpr ErrObject kErrorExecutableLib = 34; -inline constexpr ErrObject kErrorFileNotFound = 35; -inline constexpr ErrObject kErrorDirectoryNotFound = 36; -inline constexpr ErrObject kErrorDiskReadOnly = 37; -inline constexpr ErrObject kErrorDiskIsFull = 38; -inline constexpr ErrObject kErrorProcessFault = 39; -inline constexpr ErrObject kErrorSocketHangUp = 40; -inline constexpr ErrObject kErrorThreadLocalStorage = 41; -inline constexpr ErrObject kErrorMath = 42; -inline constexpr ErrObject kErrorNoNetwork = 43; -inline constexpr ErrObject kErrorHeapOutOfMemory = 44; -inline constexpr ErrObject kErrorNoSuchDisk = 45; -inline constexpr ErrObject kErrorFileExists = 46; -inline constexpr ErrObject kErrorFormatFailed = 47; -inline constexpr ErrObject kErrorNetworkTimeout = 48; -inline constexpr ErrObject kErrorInternal = 49; -inline constexpr ErrObject kErrorForkAlreadyExists = 50; -inline constexpr ErrObject kErrorOutOfTeamSlot = 51; -inline constexpr ErrObject kErrorHeapNotPresent = 52; -inline constexpr ErrObject kErrorNoEntrypoint = 53; -inline constexpr ErrObject kErrorDiskIsCorrupted = 54; -inline constexpr ErrObject kErrorDisk = 55; -inline constexpr ErrObject kErrorInvalidData = 56; -inline constexpr ErrObject kErrorAsync = 57; -inline constexpr ErrObject kErrorNonBlocking = 58; -inline constexpr ErrObject kErrorIPC = 59; -inline constexpr ErrObject kErrorSign = 60; -inline constexpr ErrObject kErrorInvalidCreds = 61; -inline constexpr ErrObject kErrorUnimplemented = 0; - -/// @brief The last error reported by the system to the process. -IMPORT_C ErrObject kLastError; diff --git a/dev/sci/source_deploy.xml b/dev/sci/source_deploy.xml index fda225db..30c64973 100644 --- a/dev/sci/source_deploy.xml +++ b/dev/sci/source_deploy.xml @@ -1,6 +1,6 @@ - *.hxx + *.h *.idl diff --git a/dev/sci/src/sci_mm.cc b/dev/sci/src/sci_mm.cc new file mode 100644 index 00000000..a776fe4a --- /dev/null +++ b/dev/sci/src/sci_mm.cc @@ -0,0 +1,45 @@ +/* ------------------------------------------- + + Copyright ZKA Web Services Co. + +------------------------------------------- */ + +#include + +/// @file sci_base.cxx +/// @brief Base Memory Manager functions for SCI.dll + +/// @brief Copy memory region. +IMPORT_C VoidPtr MmCopyMemory(_Input VoidPtr dest, _Input VoidPtr src, _Input SizeT len) +{ + if (!len || + !dest || + !src) + { + return nullptr; + } + + for (SizeT i = 0; i < len; i++) + { + ((Char*)dest)[i] = ((Char*)src)[i]; + } + + return dest; +} + +/// @brief Fill memory region with **value**. +IMPORT_C VoidPtr MmFillMemory(_Input VoidPtr dest, _Input SizeT len, _Input UInt8 value) +{ + if (!len || + !dest) + { + return nullptr; + } + + for (SizeT i = 0; i < len; i++) + { + ((Char*)dest)[i] = value; + } + + return dest; +} diff --git a/dev/sci/src/sci_mm.cxx b/dev/sci/src/sci_mm.cxx deleted file mode 100644 index 9d000d91..00000000 --- a/dev/sci/src/sci_mm.cxx +++ /dev/null @@ -1,45 +0,0 @@ -/* ------------------------------------------- - - Copyright ZKA Web Services Co. - -------------------------------------------- */ - -#include - -/// @file sci_base.cxx -/// @brief Base Memory Manager functions for SCI.dll - -/// @brief Copy memory region. -IMPORT_C VoidPtr MmCopyMemory(_Input VoidPtr dest, _Input VoidPtr src, _Input SizeT len) -{ - if (!len || - !dest || - !src) - { - return nullptr; - } - - for (SizeT i = 0; i < len; i++) - { - ((Char*)dest)[i] = ((Char*)src)[i]; - } - - return dest; -} - -/// @brief Fill memory region with **value**. -IMPORT_C VoidPtr MmFillMemory(_Input VoidPtr dest, _Input SizeT len, _Input UInt8 value) -{ - if (!len || - !dest) - { - return nullptr; - } - - for (SizeT i = 0; i < len; i++) - { - ((Char*)dest)[i] = value; - } - - return dest; -} diff --git a/dev/sci/xpcom_core.h b/dev/sci/xpcom_core.h new file mode 100644 index 00000000..c86210b5 --- /dev/null +++ b/dev/sci/xpcom_core.h @@ -0,0 +1,99 @@ +/* ------------------------------------------- + +Copyright ZKA Web Services Co. + +File: rt.internal.inl +Purpose: Base code of XPCOM. + +------------------------------------------- */ + +/// @internal Reserved for internal definitions only. + +#ifndef __NDK__ +#define object class +#define protocol class +#define clsid(X) + +#warning ! You may be using the clang compiler, please be cautious that some features mayn't be present. ! +#endif // !__NDK__ + +protocol IUnknown; // Refrenced from an IDB entry. +protocol ICLSID; // From the IDB, the constructor of the object, e.g: TextUCLSID. +object UUID; +object IStr; + +/// @brief Unknown XPCOM interface +protocol clsid("d7c144b6-0792-44b8-b06b-02b227b547df") IUnknown +{ +public: + explicit IUnknown() = default; + virtual ~IUnknown() = default; + + IUnknown& operator=(const IUnknown&) = default; + IUnknown(const IUnknown&) = default; + + virtual SInt32 Release() = 0; + virtual Void RemoveRef() = 0; + virtual IUnknown* AddRef() = 0; + virtual VoidPtr QueryClass(UUID * p_uuid) = 0; +}; + +/// @brief Allocate new XPCOM object. +/// @tparam TCLS the class type. +/// @tparam UCLSID UCLS factory class type. +/// @param uclsidOfCls UCLS factory class +/// @return TCLS interface +template +inline TCLS* XPCOMQueryInterface(UCLSID* uclsidOfCls, Args&&... args) +{ + if (uclsidOfCls == nullptr) + return nullptr; + + uclsidOfCls->AddRef(); + return uclsidOfCls->QueryInterfaceWithArgs(args...); +} + +/// @brief Release XPCOM object. +/// @tparam TCLS the class type. +/// @param cls the class to release. +/// @return status code. +template +inline SInt32 XPCOMReleaseClass(TCLS** cls) +{ + if (!*cls) + return -kErrorInvalidData; + + (*cls)->RemoveRef(); + (*cls)->Release(); + + *cls = nullptr; + + return kErrorSuccess; +} + +/// @brief Event listener interface. +/// @tparam FnSign the event listener function type. +/// @tparam ClsID the event listener class ID. +template +protocol IEventListener : public ClsID +{ + friend ClsID; + + explicit IEventListener() = default; + virtual ~IEventListener() = default; + + IEventListener& operator=(const IEventListener&) = default; + IEventListener(const IEventListener&) = default; + + virtual IEventListener& operator-=(const IStr* event_name) + { + this->RemoveEventListener(event_name); + return *this; + } + + virtual IEventListener& operator+=(FnSign arg) + { + this->AddEventListener(arg); + return *this; + } +}; diff --git a/dev/sci/xpcom_core.hxx b/dev/sci/xpcom_core.hxx deleted file mode 100644 index c86210b5..00000000 --- a/dev/sci/xpcom_core.hxx +++ /dev/null @@ -1,99 +0,0 @@ -/* ------------------------------------------- - -Copyright ZKA Web Services Co. - -File: rt.internal.inl -Purpose: Base code of XPCOM. - -------------------------------------------- */ - -/// @internal Reserved for internal definitions only. - -#ifndef __NDK__ -#define object class -#define protocol class -#define clsid(X) - -#warning ! You may be using the clang compiler, please be cautious that some features mayn't be present. ! -#endif // !__NDK__ - -protocol IUnknown; // Refrenced from an IDB entry. -protocol ICLSID; // From the IDB, the constructor of the object, e.g: TextUCLSID. -object UUID; -object IStr; - -/// @brief Unknown XPCOM interface -protocol clsid("d7c144b6-0792-44b8-b06b-02b227b547df") IUnknown -{ -public: - explicit IUnknown() = default; - virtual ~IUnknown() = default; - - IUnknown& operator=(const IUnknown&) = default; - IUnknown(const IUnknown&) = default; - - virtual SInt32 Release() = 0; - virtual Void RemoveRef() = 0; - virtual IUnknown* AddRef() = 0; - virtual VoidPtr QueryClass(UUID * p_uuid) = 0; -}; - -/// @brief Allocate new XPCOM object. -/// @tparam TCLS the class type. -/// @tparam UCLSID UCLS factory class type. -/// @param uclsidOfCls UCLS factory class -/// @return TCLS interface -template -inline TCLS* XPCOMQueryInterface(UCLSID* uclsidOfCls, Args&&... args) -{ - if (uclsidOfCls == nullptr) - return nullptr; - - uclsidOfCls->AddRef(); - return uclsidOfCls->QueryInterfaceWithArgs(args...); -} - -/// @brief Release XPCOM object. -/// @tparam TCLS the class type. -/// @param cls the class to release. -/// @return status code. -template -inline SInt32 XPCOMReleaseClass(TCLS** cls) -{ - if (!*cls) - return -kErrorInvalidData; - - (*cls)->RemoveRef(); - (*cls)->Release(); - - *cls = nullptr; - - return kErrorSuccess; -} - -/// @brief Event listener interface. -/// @tparam FnSign the event listener function type. -/// @tparam ClsID the event listener class ID. -template -protocol IEventListener : public ClsID -{ - friend ClsID; - - explicit IEventListener() = default; - virtual ~IEventListener() = default; - - IEventListener& operator=(const IEventListener&) = default; - IEventListener(const IEventListener&) = default; - - virtual IEventListener& operator-=(const IStr* event_name) - { - this->RemoveEventListener(event_name); - return *this; - } - - virtual IEventListener& operator+=(FnSign arg) - { - this->AddEventListener(arg); - return *this; - } -}; -- cgit v1.2.3