From 7f7887e8951b00f20420d5184a4477bfb46df1e3 Mon Sep 17 00:00:00 2001 From: asfernandes Date: Tue, 13 Jan 2015 14:43:24 +0000 Subject: [PATCH] Make UDR StatusType customizable. --- examples/udr/UdrCppExample.cpp | 2 + src/include/firebird/UdrCppEngine.h | 89 ++++++++++++++-------------- src/plugins/udr_engine/UdrEngine.cpp | 1 - 3 files changed, 48 insertions(+), 44 deletions(-) diff --git a/examples/udr/UdrCppExample.cpp b/examples/udr/UdrCppExample.cpp index c0fb537d46..99ba981eb6 100644 --- a/examples/udr/UdrCppExample.cpp +++ b/examples/udr/UdrCppExample.cpp @@ -20,6 +20,8 @@ * Contributor(s): ______________________________________. */ +#define FB_UDR_STATUS_TYPE ::Firebird::ThrowStatusWrapper + #include "ibase.h" #include "firebird/UdrCppEngine.h" #include diff --git a/src/include/firebird/UdrCppEngine.h b/src/include/firebird/UdrCppEngine.h index 9504c6606d..9e2bdca8d4 100644 --- a/src/include/firebird/UdrCppEngine.h +++ b/src/include/firebird/UdrCppEngine.h @@ -23,6 +23,10 @@ #ifndef FIREBIRD_UDR_CPP_ENGINE #define FIREBIRD_UDR_CPP_ENGINE +#ifndef FB_UDR_STATUS_TYPE +#error FB_UDR_STATUS_TYPE must be defined with the Status class before UdrCppEngine.h inclusion. +#endif + #include "./UdrEngine.h" #include "./Message.h" #ifndef JRD_IBASE_H @@ -32,7 +36,6 @@ #include -//// TODO: Make StatusType customizable. namespace Firebird { namespace Udr @@ -45,9 +48,9 @@ namespace Firebird { \ class Impl; \ \ - static ::Firebird::Udr::FunctionFactoryImpl factory(#name); \ + static ::Firebird::Udr::FunctionFactoryImpl factory(#name); \ \ - class Impl : public ::Firebird::Udr::Function \ + class Impl : public ::Firebird::Udr::Function \ { \ public: \ FB__UDR_COMMON_IMPL @@ -57,13 +60,13 @@ namespace Firebird } #define FB_UDR_EXECUTE_FUNCTION \ - void execute(::Firebird::ThrowStatusWrapper* status, ::Firebird::IExternalContext* context, \ + void execute(FB_UDR_STATUS_TYPE* status, ::Firebird::IExternalContext* context, \ void* in, void* out) \ { \ internalExecute(status, context, (InMessage::Type*) in, (OutMessage::Type*) out); \ } \ \ - void internalExecute(::Firebird::ThrowStatusWrapper* status, ::Firebird::IExternalContext* context, \ + void internalExecute(FB_UDR_STATUS_TYPE* status, ::Firebird::IExternalContext* context, \ InMessage::Type* in, OutMessage::Type* out) @@ -72,9 +75,9 @@ namespace Firebird { \ class Impl; \ \ - static ::Firebird::Udr::ProcedureFactoryImpl factory(#name); \ + static ::Firebird::Udr::ProcedureFactoryImpl factory(#name); \ \ - class Impl : public ::Firebird::Udr::Procedure \ + class Impl : public ::Firebird::Udr::Procedure \ { \ public: \ FB__UDR_COMMON_IMPL @@ -85,27 +88,27 @@ namespace Firebird } #define FB_UDR_EXECUTE_PROCEDURE \ - ::Firebird::IExternalResultSet* open(::Firebird::ThrowStatusWrapper* status, \ + ::Firebird::IExternalResultSet* open(FB_UDR_STATUS_TYPE* status, \ ::Firebird::IExternalContext* context, void* in, void* out) \ { \ return new ResultSet(status, context, this, (InMessage::Type*) in, (OutMessage::Type*) out); \ } \ \ - class ResultSet : public ::Firebird::Udr::ResultSet \ + class ResultSet : public ::Firebird::Udr::ResultSet \ { \ public: \ - ResultSet(::Firebird::ThrowStatusWrapper* status, ::Firebird::IExternalContext* context, \ + ResultSet(FB_UDR_STATUS_TYPE* status, ::Firebird::IExternalContext* context, \ Impl* const procedure, InMessage::Type* const in, OutMessage::Type* const out) \ - : ::Firebird::Udr::ResultSet( \ + : ::Firebird::Udr::ResultSet( \ context, procedure, in, out) #define FB_UDR_FETCH_PROCEDURE \ - FB_BOOLEAN fetch(::Firebird::ThrowStatusWrapper* status) \ + FB_BOOLEAN fetch(FB_UDR_STATUS_TYPE* status) \ { \ return (FB_BOOLEAN) internalFetch(status); \ } \ \ - bool internalFetch(::Firebird::ThrowStatusWrapper* status) + bool internalFetch(FB_UDR_STATUS_TYPE* status) #define FB_UDR_BEGIN_TRIGGER(name) \ @@ -113,9 +116,9 @@ namespace Firebird { \ class Impl; \ \ - static ::Firebird::Udr::TriggerFactoryImpl factory(#name); \ + static ::Firebird::Udr::TriggerFactoryImpl factory(#name); \ \ - class Impl : public ::Firebird::Udr::Trigger \ + class Impl : public ::Firebird::Udr::Trigger \ { \ public: \ FB__UDR_COMMON_IMPL @@ -125,20 +128,20 @@ namespace Firebird } #define FB_UDR_EXECUTE_TRIGGER \ - void execute(::Firebird::ThrowStatusWrapper* status, ::Firebird::IExternalContext* context, \ + void execute(FB_UDR_STATUS_TYPE* status, ::Firebird::IExternalContext* context, \ unsigned int action, void* oldFields, void* newFields) \ { \ internalExecute(status, context, action, \ (FieldsMessage::Type*) oldFields, (FieldsMessage::Type*) newFields); \ } \ \ - void internalExecute(::Firebird::ThrowStatusWrapper* status, ::Firebird::IExternalContext* context, \ + void internalExecute(FB_UDR_STATUS_TYPE* status, ::Firebird::IExternalContext* context, \ unsigned int action, \ FieldsMessage::Type* oldFields, FieldsMessage::Type* newFields) #define FB_UDR_CONSTRUCTOR \ - Impl(::Firebird::ThrowStatusWrapper* const status, ::Firebird::IExternalContext* const context, \ + Impl(FB_UDR_STATUS_TYPE* const status, ::Firebird::IExternalContext* const context, \ ::Firebird::IRoutineMetadata* const metadata__) \ : master(context->getMaster()), \ metadata(metadata__) @@ -162,11 +165,11 @@ namespace Firebird struct name \ { \ typedef unsigned char Type; \ - static void setup(::Firebird::ThrowStatusWrapper*, ::Firebird::IMetadataBuilder*) {} \ + static void setup(FB_UDR_STATUS_TYPE*, ::Firebird::IMetadataBuilder*) {} \ } -template class Procedure; +template class Procedure; class Helper @@ -218,8 +221,8 @@ public: }; -template -class ResultSet : public IExternalResultSetImpl, public Helper +template +class ResultSet : public IExternalResultSetImpl, public Helper { public: ResultSet(IExternalContext* aContext, Procedure* aProcedure, @@ -245,8 +248,8 @@ protected: }; -template -class Function : public IExternalFunctionImpl, public Helper +template +class Function : public IExternalFunctionImpl, public Helper { public: FB__UDR_COMMON_TYPE(InMessage); @@ -257,15 +260,15 @@ public: delete static_cast(this); } - void getCharSet(ThrowStatusWrapper* /*status*/, IExternalContext* /*context*/, + void getCharSet(StatusType* /*status*/, IExternalContext* /*context*/, char* /*name*/, unsigned /*nameSize*/) { } }; -template -class Procedure : public IExternalProcedureImpl, public Helper +template +class Procedure : public IExternalProcedureImpl, public Helper { public: FB__UDR_COMMON_TYPE(InMessage); @@ -276,15 +279,15 @@ public: delete static_cast(this); } - void getCharSet(ThrowStatusWrapper* /*status*/, IExternalContext* /*context*/, + void getCharSet(StatusType* /*status*/, IExternalContext* /*context*/, char* /*name*/, unsigned /*nameSize*/) { } }; -template -class Trigger : public IExternalTriggerImpl, public Helper +template +class Trigger : public IExternalTriggerImpl, public Helper { public: FB__UDR_COMMON_TYPE(FieldsMessage); @@ -294,15 +297,15 @@ public: delete static_cast(this); } - void getCharSet(ThrowStatusWrapper* /*status*/, IExternalContext* /*context*/, + void getCharSet(StatusType* /*status*/, IExternalContext* /*context*/, char* /*name*/, unsigned /*nameSize*/) { } }; -template class FunctionFactoryImpl : - public IUdrFunctionFactoryImpl, ThrowStatusWrapper> +template class FunctionFactoryImpl : + public IUdrFunctionFactoryImpl, StatusType> { public: explicit FunctionFactoryImpl(const char* name) @@ -310,14 +313,14 @@ public: fbUdrRegFunction(name, this); } - void setup(ThrowStatusWrapper* status, IExternalContext* /*context*/, + void setup(StatusType* status, IExternalContext* /*context*/, IRoutineMetadata* /*metadata*/, IMetadataBuilder* in, IMetadataBuilder* out) { T::InMessage::setup(status, in); T::OutMessage::setup(status, out); } - IExternalFunction* newItem(ThrowStatusWrapper* status, IExternalContext* context, + IExternalFunction* newItem(StatusType* status, IExternalContext* context, IRoutineMetadata* metadata) { return new T(status, context, metadata); @@ -325,8 +328,8 @@ public: }; -template class ProcedureFactoryImpl : - public IUdrProcedureFactoryImpl, ThrowStatusWrapper> +template class ProcedureFactoryImpl : + public IUdrProcedureFactoryImpl, StatusType> { public: explicit ProcedureFactoryImpl(const char* name) @@ -334,14 +337,14 @@ public: fbUdrRegProcedure(name, this); } - void setup(ThrowStatusWrapper* status, IExternalContext* /*context*/, + void setup(StatusType* status, IExternalContext* /*context*/, IRoutineMetadata* /*metadata*/, IMetadataBuilder* in, IMetadataBuilder* out) { T::InMessage::setup(status, in); T::OutMessage::setup(status, out); } - IExternalProcedure* newItem(ThrowStatusWrapper* status, IExternalContext* context, + IExternalProcedure* newItem(StatusType* status, IExternalContext* context, IRoutineMetadata* metadata) { return new T(status, context, metadata); @@ -349,8 +352,8 @@ public: }; -template class TriggerFactoryImpl : - public IUdrTriggerFactoryImpl, ThrowStatusWrapper> +template class TriggerFactoryImpl : + public IUdrTriggerFactoryImpl, StatusType> { public: explicit TriggerFactoryImpl(const char* name) @@ -358,13 +361,13 @@ public: fbUdrRegTrigger(name, this); } - void setup(ThrowStatusWrapper* status, IExternalContext* /*context*/, + void setup(StatusType* status, IExternalContext* /*context*/, IRoutineMetadata* /*metadata*/, IMetadataBuilder* fields) { T::FieldsMessage::setup(status, fields); } - IExternalTrigger* newItem(ThrowStatusWrapper* status, IExternalContext* context, + IExternalTrigger* newItem(StatusType* status, IExternalContext* context, IRoutineMetadata* metadata) { return new T(status, context, metadata); diff --git a/src/plugins/udr_engine/UdrEngine.cpp b/src/plugins/udr_engine/UdrEngine.cpp index 4551391c1a..6a90bd4a85 100644 --- a/src/plugins/udr_engine/UdrEngine.cpp +++ b/src/plugins/udr_engine/UdrEngine.cpp @@ -23,7 +23,6 @@ #include "firebird.h" #include "../jrd/ibase.h" #include "firebird/UdrEngine.h" -#include "firebird/UdrCppEngine.h" #include "firebird/Interface.h" #include "../common/classes/alloc.h" #include "../common/classes/array.h"