From 9e52243831ceffced1e9f0ef27041770fe13a85a Mon Sep 17 00:00:00 2001 From: Neil Date: Thu, 17 Jun 2021 09:28:05 +1000 Subject: Add SciFnDirectStatus, a direct access function which also returns status so can improve performance for client code that called SCI_GETSTATUS after every API to check for failure. --- cocoa/ScintillaCocoa.h | 1 + cocoa/ScintillaCocoa.mm | 29 ++++++++++++++++++++++++++++- 2 files changed, 29 insertions(+), 1 deletion(-) (limited to 'cocoa') diff --git a/cocoa/ScintillaCocoa.h b/cocoa/ScintillaCocoa.h index 40c389f5f..00a0fbc03 100644 --- a/cocoa/ScintillaCocoa.h +++ b/cocoa/ScintillaCocoa.h @@ -189,6 +189,7 @@ public: std::string EncodedFromUTF8(std::string_view utf8) const override; static sptr_t DirectFunction(sptr_t ptr, unsigned int iMessage, uptr_t wParam, sptr_t lParam); + static sptr_t DirectStatusFunction(sptr_t ptr, unsigned int iMessage, uptr_t wParam, sptr_t lParam, int *pStatus); NSTimer *timers[static_cast(TickReason::platform)+1]; void TimerFired(NSTimer *timer); diff --git a/cocoa/ScintillaCocoa.mm b/cocoa/ScintillaCocoa.mm index 81e31d9aa..242cd4162 100644 --- a/cocoa/ScintillaCocoa.mm +++ b/cocoa/ScintillaCocoa.mm @@ -811,7 +811,31 @@ void ScintillaCocoa::Redraw() { */ sptr_t ScintillaCocoa::DirectFunction(sptr_t ptr, unsigned int iMessage, uptr_t wParam, sptr_t lParam) { - return reinterpret_cast(ptr)->WndProc(static_cast(iMessage), wParam, lParam); + ScintillaCocoa *sci = reinterpret_cast(ptr); + return sci->WndProc(static_cast(iMessage), wParam, lParam); +} + +//-------------------------------------------------------------------------------------------------- + +/** + * A function to directly execute code that would usually go the long way via window messages. + * Similar to DirectFunction but also returns the status. + * However this is a Windows metaphor and not used here, hence we just call our fake + * window proc. The given parameters directly reflect the message parameters used on Windows. + * + * @param ptr The target which is to be called. + * @param iMessage A code that indicates which message was sent. + * @param wParam One of the two free parameters for the message. Traditionally a word sized parameter + * (hence the w prefix). + * @param lParam The other of the two free parameters. A signed long. + * @param pStatus Return the status to the caller. A pointer to an int. + */ +sptr_t ScintillaCocoa::DirectStatusFunction(sptr_t ptr, unsigned int iMessage, uptr_t wParam, + sptr_t lParam, int *pStatus) { + ScintillaCocoa *sci = reinterpret_cast(ptr); + const sptr_t returnValue = sci->WndProc(static_cast(iMessage), wParam, lParam); + *pStatus = static_cast(sci->errorStatus); + return returnValue; } //-------------------------------------------------------------------------------------------------- @@ -856,6 +880,9 @@ sptr_t ScintillaCocoa::WndProc(Message iMessage, uptr_t wParam, sptr_t lParam) { case Message::GetDirectFunction: return reinterpret_cast(DirectFunction); + case Message::GetDirectStatusFunction: + return reinterpret_cast(DirectStatusFunction); + case Message::GetDirectPointer: return reinterpret_cast(this); -- cgit v1.2.3