From cdaf8e9379f1756a9416f455ff5552fb8871c16d Mon Sep 17 00:00:00 2001 From: Amlal El Mahrouss Date: Tue, 27 Aug 2024 22:27:57 +0200 Subject: [IMP] Updated SCM API, add XPCOM interface. + XPCOM is a product of ZKA's which helps developers make portable code. Signed-off-by: Amlal El Mahrouss --- dev/SCI/SCM.drawio | 28 --------------- dev/SCI/sci_base.hxx | 21 +++++++----- dev/SCI/scm-design.drawio | 28 +++++++++++++++ dev/SCI/scm.idlparser.inl | 21 ------------ dev/SCI/scm.internal.inl | 84 --------------------------------------------- dev/SCI/scm_core.hxx | 87 +++++++++++++++++++++++++++++++++++++++++++++++ dev/SCI/scm_xpcom.inl | 30 ++++++++++++++++ dev/SCI/source_deploy.xml | 4 ++- 8 files changed, 160 insertions(+), 143 deletions(-) delete mode 100644 dev/SCI/SCM.drawio create mode 100644 dev/SCI/scm-design.drawio delete mode 100644 dev/SCI/scm.idlparser.inl delete mode 100644 dev/SCI/scm.internal.inl create mode 100644 dev/SCI/scm_core.hxx create mode 100644 dev/SCI/scm_xpcom.inl (limited to 'dev') diff --git a/dev/SCI/SCM.drawio b/dev/SCI/SCM.drawio deleted file mode 100644 index 403d6642..00000000 --- a/dev/SCI/SCM.drawio +++ /dev/null @@ -1,28 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/dev/SCI/sci_base.hxx b/dev/SCI/sci_base.hxx index 1d69a56b..a6719500 100644 --- a/dev/SCI/sci_base.hxx +++ b/dev/SCI/sci_base.hxx @@ -37,9 +37,9 @@ typedef char Char; #include #ifdef __SCI_IMPL__ -#include +#include #else -class UnknownInterface; // Refrenced from an IDB entry. +class IUnknown; // Refrenced from an IDB entry. class UnknownUCLSID; // From the IDB, the constructor of the object, e.g: WordUCLSID. class UUID; @@ -49,7 +49,10 @@ class UUID; /// @param uclsidOfCls /// @return template -TCLS* RtlQueryInterface(UCLSID uclsidOfCls, Args... args); +TCLS* ScmQueryInterface(UCLSID uclsidOfCls, Args... args); + +template +SInt32 ScmReleaseClass(TCLS** cls); /// @brief Release SCM class. /// @tparam TCLS @@ -58,18 +61,18 @@ TCLS* RtlQueryInterface(UCLSID uclsidOfCls, Args... args); template SInt32 RtlReleaseClass(TCLS* cls); -class __attribute__((uuid("d7c144b6-0792-44b8-b06b-02b227b547df"))) UnknownInterface +class __attribute__((uuid("d7c144b6-0792-44b8-b06b-02b227b547df"))) IUnknown { public: - explicit UnknownInterface() = default; - virtual ~UnknownInterface() = default; + explicit IUnknown() = default; + virtual ~IUnknown() = default; - UnknownInterface& operator=(const UnknownInterface&) = default; - UnknownInterface(const UnknownInterface&) = default; + IUnknown& operator=(const IUnknown&) = default; + IUnknown(const IUnknown&) = default; virtual SInt32 Release() = 0; virtual void RemoveRef() = 0; - virtual UnknownInterface* AddRef() = 0; + virtual IUnknown* AddRef() = 0; virtual VoidPtr QueryInterface(UUID* p_uuid) = 0; }; diff --git a/dev/SCI/scm-design.drawio b/dev/SCI/scm-design.drawio new file mode 100644 index 00000000..a8abf083 --- /dev/null +++ b/dev/SCI/scm-design.drawio @@ -0,0 +1,28 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/dev/SCI/scm.idlparser.inl b/dev/SCI/scm.idlparser.inl deleted file mode 100644 index 6189eab6..00000000 --- a/dev/SCI/scm.idlparser.inl +++ /dev/null @@ -1,21 +0,0 @@ -/* ------------------------------------------- - -Copyright ZKA Technologies. - -File: rt.internal.inl -Purpose: Base code of SCM. - -------------------------------------------- */ - -/// @internal - -#ifndef __NDK__ -#define object class -#define protocol class -#define clsid(X) __attribute__((uuid(X))) - -#warning ! you may be using the clang version of the newos kit, please be cautious that some thing mayn't be present. ! -#endif // !__NDK__ - -protocol IDLParserInterface; -protocol IDLInterface; \ No newline at end of file diff --git a/dev/SCI/scm.internal.inl b/dev/SCI/scm.internal.inl deleted file mode 100644 index af87230d..00000000 --- a/dev/SCI/scm.internal.inl +++ /dev/null @@ -1,84 +0,0 @@ -/* ------------------------------------------- - -Copyright ZKA Technologies. - -File: rt.internal.inl -Purpose: Base code of SCM. - -------------------------------------------- */ - -/// @internal - -#ifndef __NDK__ -#define object class -#define protocol class -#define clsid(X) __attribute__((uuid(X))) - -#warning ! you may be using the clang version of the newos kit, please be cautious that some thing mayn't be present. ! -#endif // !__NDK__ - -// Interfaces are divided between classes. -// So that they aren't too big. - -protocol UnknownInterface; // Refrenced from an IDB entry. -class UnknownUCLSID; // From the IDB, the constructor of the object, e.g: TextUCLSID. -object UUID; - -protocol clsid("d7c144b6-0792-44b8-b06b-02b227b547df") UnknownInterface -{ -public: - explicit UnknownInterface() = default; - virtual ~UnknownInterface() = default; - - UnknownInterface& operator=(const UnknownInterface&) = default; - UnknownInterface(const UnknownInterface&) = default; - - virtual SInt32 Release() = 0; - virtual void RemoveRef() = 0; - virtual UnknownInterface* AddRef() = 0; - virtual VoidPtr QueryInterface(UUID* p_uuid) = 0; -}; - -/// @brief Allocate new SCM object. -/// @tparam TCLS the class type. -/// @tparam UCLSID UCLS factory class type. -/// @param uclsidOfCls UCLS factory class -/// @return TCLS interface -template -inline TCLS* ScmQueryInterface(UCLSID* uclsidOfCls, Args&&... args) -{ - return uclsidOfCls->QueryInterfaceWithArgs(args...); -} - -/// @brief Release SCM object. -/// @tparam TCLS the class type. -/// @param cls the class to release. -/// @return status code. -template -inline SInt32 ScmReleaseClass(TCLS* cls) -{ - if (!cls) - return -1; - - cls->DecrementRef(); - cls->Release(); - - return 0; -} - -template -protocol EventListenerInterface : public ClsID -{ -public: - explicit EventListenerInterface() = default; - virtual ~EventListenerInterface() = default; - - EventListenerInterface& operator=(const EventListenerInterface&) = default; - EventListenerInterface(const EventListenerInterface&) = default; - - virtual EventListenerInterface& operator +=(FnSign arg) - { - this->AddEventListener(arg); - return *this; - } -}; diff --git a/dev/SCI/scm_core.hxx b/dev/SCI/scm_core.hxx new file mode 100644 index 00000000..5b4c26f4 --- /dev/null +++ b/dev/SCI/scm_core.hxx @@ -0,0 +1,87 @@ +/* ------------------------------------------- + +Copyright ZKA Technologies. + +File: rt.internal.inl +Purpose: Base code of SCM. + +------------------------------------------- */ + +/// @internal + +#ifndef __NDK__ +#define object class +#define protocol class +#define clsid(X) + +#warning ! you may be using the clang version of the newos kit, please be cautious that some thing mayn't be present. ! +#endif // !__NDK__ + +// Interfaces are divided between classes. +// So that they aren't too big. + +protocol IUnknown; // Refrenced from an IDB entry. +protocol UnknownUCLSID; // From the IDB, the constructor of the object, e.g: TextUCLSID. +object UUID; + +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 QueryInterface(UUID* p_uuid) = 0; +}; + +/// @brief Allocate new SCM object. +/// @tparam TCLS the class type. +/// @tparam UCLSID UCLS factory class type. +/// @param uclsidOfCls UCLS factory class +/// @return TCLS interface +template +inline TCLS* ScmQueryInterface(UCLSID* uclsidOfCls, Args&&... args) +{ + uclsidOfCls->AddRef(); + return uclsidOfCls->QueryInterfaceWithArgs(args...); +} + +/// @brief Release SCM object. +/// @tparam TCLS the class type. +/// @param cls the class to release. +/// @return status code. +template +inline SInt32 ScmReleaseClass(TCLS** cls) +{ + if (!cls) + return -1; + + cls->RemoveRef(); + cls->Release(); + + cls = nullptr; + + return 0; +} + +template +protocol EventListenerInterface : public ClsID +{ +public: + explicit EventListenerInterface() = default; + virtual ~EventListenerInterface() = default; + + EventListenerInterface& operator=(const EventListenerInterface&) = default; + EventListenerInterface(const EventListenerInterface&) = default; + + virtual EventListenerInterface& operator +=(FnSign arg) + { + this->AddEventListener(arg); + return *this; + } +}; diff --git a/dev/SCI/scm_xpcom.inl b/dev/SCI/scm_xpcom.inl new file mode 100644 index 00000000..9c63f041 --- /dev/null +++ b/dev/SCI/scm_xpcom.inl @@ -0,0 +1,30 @@ +/* ------------------------------------------- + +Copyright ZKA Technologies. + +File: rt.internal.inl +Purpose: Base code of SCM. + +------------------------------------------- */ + +/// @internal + +#ifndef __NDK__ +#define object class +#define protocol class +#define interface private +#define method +#define clsid(X) + +#warning ! you may be using the clang version of the newos kit, please be cautious that some thing mayn't be present. ! +#endif // !__NDK__ + +protocol IPXCOMSocket; + +clsid("0943A614-0201-4107-8F8D-E909DF7F53C9") +protocol IPXCOMSocket +{ +interface: + method SInt32 SendMessage(const Char* bytes, SizeT bytes_size); + method SInt32 RecvMessage(_Output const Char** bytes_in, _Input SizeT bytes_size); +}; diff --git a/dev/SCI/source_deploy.xml b/dev/SCI/source_deploy.xml index 5c8090f1..128ec570 100644 --- a/dev/SCI/source_deploy.xml +++ b/dev/SCI/source_deploy.xml @@ -2,6 +2,8 @@ Sources/*.cxx *.drawio - *.internal.inl + *.hxx + *.inl + *.idl -- cgit v1.2.3