8
0
mirror of https://github.com/FirebirdSQL/firebird.git synced 2025-01-23 00:43:02 +01:00

Make UDR StatusType customizable.

This commit is contained in:
asfernandes 2015-01-13 14:43:24 +00:00
parent 76df787334
commit 7f7887e895
3 changed files with 48 additions and 44 deletions

View File

@ -20,6 +20,8 @@
* Contributor(s): ______________________________________. * Contributor(s): ______________________________________.
*/ */
#define FB_UDR_STATUS_TYPE ::Firebird::ThrowStatusWrapper
#include "ibase.h" #include "ibase.h"
#include "firebird/UdrCppEngine.h" #include "firebird/UdrCppEngine.h"
#include <assert.h> #include <assert.h>

View File

@ -23,6 +23,10 @@
#ifndef FIREBIRD_UDR_CPP_ENGINE #ifndef FIREBIRD_UDR_CPP_ENGINE
#define 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 "./UdrEngine.h"
#include "./Message.h" #include "./Message.h"
#ifndef JRD_IBASE_H #ifndef JRD_IBASE_H
@ -32,7 +36,6 @@
#include <string.h> #include <string.h>
//// TODO: Make StatusType customizable.
namespace Firebird namespace Firebird
{ {
namespace Udr namespace Udr
@ -45,9 +48,9 @@ namespace Firebird
{ \ { \
class Impl; \ class Impl; \
\ \
static ::Firebird::Udr::FunctionFactoryImpl<Impl> factory(#name); \ static ::Firebird::Udr::FunctionFactoryImpl<Impl, FB_UDR_STATUS_TYPE> factory(#name); \
\ \
class Impl : public ::Firebird::Udr::Function<Impl> \ class Impl : public ::Firebird::Udr::Function<Impl, FB_UDR_STATUS_TYPE> \
{ \ { \
public: \ public: \
FB__UDR_COMMON_IMPL FB__UDR_COMMON_IMPL
@ -57,13 +60,13 @@ namespace Firebird
} }
#define FB_UDR_EXECUTE_FUNCTION \ #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) \ void* in, void* out) \
{ \ { \
internalExecute(status, context, (InMessage::Type*) in, (OutMessage::Type*) 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) InMessage::Type* in, OutMessage::Type* out)
@ -72,9 +75,9 @@ namespace Firebird
{ \ { \
class Impl; \ class Impl; \
\ \
static ::Firebird::Udr::ProcedureFactoryImpl<Impl> factory(#name); \ static ::Firebird::Udr::ProcedureFactoryImpl<Impl, FB_UDR_STATUS_TYPE> factory(#name); \
\ \
class Impl : public ::Firebird::Udr::Procedure<Impl> \ class Impl : public ::Firebird::Udr::Procedure<Impl, FB_UDR_STATUS_TYPE> \
{ \ { \
public: \ public: \
FB__UDR_COMMON_IMPL FB__UDR_COMMON_IMPL
@ -85,27 +88,27 @@ namespace Firebird
} }
#define FB_UDR_EXECUTE_PROCEDURE \ #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) \ ::Firebird::IExternalContext* context, void* in, void* out) \
{ \ { \
return new ResultSet(status, context, this, (InMessage::Type*) in, (OutMessage::Type*) out); \ return new ResultSet(status, context, this, (InMessage::Type*) in, (OutMessage::Type*) out); \
} \ } \
\ \
class ResultSet : public ::Firebird::Udr::ResultSet<ResultSet, Impl, InMessage, OutMessage> \ class ResultSet : public ::Firebird::Udr::ResultSet<ResultSet, Impl, InMessage, OutMessage, FB_UDR_STATUS_TYPE> \
{ \ { \
public: \ 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) \ Impl* const procedure, InMessage::Type* const in, OutMessage::Type* const out) \
: ::Firebird::Udr::ResultSet<ResultSet, Impl, InMessage, OutMessage>( \ : ::Firebird::Udr::ResultSet<ResultSet, Impl, InMessage, OutMessage, FB_UDR_STATUS_TYPE>( \
context, procedure, in, out) context, procedure, in, out)
#define FB_UDR_FETCH_PROCEDURE \ #define FB_UDR_FETCH_PROCEDURE \
FB_BOOLEAN fetch(::Firebird::ThrowStatusWrapper* status) \ FB_BOOLEAN fetch(FB_UDR_STATUS_TYPE* status) \
{ \ { \
return (FB_BOOLEAN) internalFetch(status); \ return (FB_BOOLEAN) internalFetch(status); \
} \ } \
\ \
bool internalFetch(::Firebird::ThrowStatusWrapper* status) bool internalFetch(FB_UDR_STATUS_TYPE* status)
#define FB_UDR_BEGIN_TRIGGER(name) \ #define FB_UDR_BEGIN_TRIGGER(name) \
@ -113,9 +116,9 @@ namespace Firebird
{ \ { \
class Impl; \ class Impl; \
\ \
static ::Firebird::Udr::TriggerFactoryImpl<Impl> factory(#name); \ static ::Firebird::Udr::TriggerFactoryImpl<Impl, FB_UDR_STATUS_TYPE> factory(#name); \
\ \
class Impl : public ::Firebird::Udr::Trigger<Impl> \ class Impl : public ::Firebird::Udr::Trigger<Impl, FB_UDR_STATUS_TYPE> \
{ \ { \
public: \ public: \
FB__UDR_COMMON_IMPL FB__UDR_COMMON_IMPL
@ -125,20 +128,20 @@ namespace Firebird
} }
#define FB_UDR_EXECUTE_TRIGGER \ #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) \ unsigned int action, void* oldFields, void* newFields) \
{ \ { \
internalExecute(status, context, action, \ internalExecute(status, context, action, \
(FieldsMessage::Type*) oldFields, (FieldsMessage::Type*) newFields); \ (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, \ unsigned int action, \
FieldsMessage::Type* oldFields, FieldsMessage::Type* newFields) FieldsMessage::Type* oldFields, FieldsMessage::Type* newFields)
#define FB_UDR_CONSTRUCTOR \ #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__) \ ::Firebird::IRoutineMetadata* const metadata__) \
: master(context->getMaster()), \ : master(context->getMaster()), \
metadata(metadata__) metadata(metadata__)
@ -162,11 +165,11 @@ namespace Firebird
struct name \ struct name \
{ \ { \
typedef unsigned char Type; \ typedef unsigned char Type; \
static void setup(::Firebird::ThrowStatusWrapper*, ::Firebird::IMetadataBuilder*) {} \ static void setup(FB_UDR_STATUS_TYPE*, ::Firebird::IMetadataBuilder*) {} \
} }
template <typename T> class Procedure; template <typename T, typename StatusType> class Procedure;
class Helper class Helper
@ -218,8 +221,8 @@ public:
}; };
template <typename This, typename Procedure, typename InMessage, typename OutMessage> template <typename This, typename Procedure, typename InMessage, typename OutMessage, typename StatusType>
class ResultSet : public IExternalResultSetImpl<This, ThrowStatusWrapper>, public Helper class ResultSet : public IExternalResultSetImpl<This, StatusType>, public Helper
{ {
public: public:
ResultSet(IExternalContext* aContext, Procedure* aProcedure, ResultSet(IExternalContext* aContext, Procedure* aProcedure,
@ -245,8 +248,8 @@ protected:
}; };
template <typename This> template <typename This, typename StatusType>
class Function : public IExternalFunctionImpl<This, ThrowStatusWrapper>, public Helper class Function : public IExternalFunctionImpl<This, StatusType>, public Helper
{ {
public: public:
FB__UDR_COMMON_TYPE(InMessage); FB__UDR_COMMON_TYPE(InMessage);
@ -257,15 +260,15 @@ public:
delete static_cast<This*>(this); delete static_cast<This*>(this);
} }
void getCharSet(ThrowStatusWrapper* /*status*/, IExternalContext* /*context*/, void getCharSet(StatusType* /*status*/, IExternalContext* /*context*/,
char* /*name*/, unsigned /*nameSize*/) char* /*name*/, unsigned /*nameSize*/)
{ {
} }
}; };
template <typename This> template <typename This, typename StatusType>
class Procedure : public IExternalProcedureImpl<This, ThrowStatusWrapper>, public Helper class Procedure : public IExternalProcedureImpl<This, StatusType>, public Helper
{ {
public: public:
FB__UDR_COMMON_TYPE(InMessage); FB__UDR_COMMON_TYPE(InMessage);
@ -276,15 +279,15 @@ public:
delete static_cast<This*>(this); delete static_cast<This*>(this);
} }
void getCharSet(ThrowStatusWrapper* /*status*/, IExternalContext* /*context*/, void getCharSet(StatusType* /*status*/, IExternalContext* /*context*/,
char* /*name*/, unsigned /*nameSize*/) char* /*name*/, unsigned /*nameSize*/)
{ {
} }
}; };
template <typename This> template <typename This, typename StatusType>
class Trigger : public IExternalTriggerImpl<This, ThrowStatusWrapper>, public Helper class Trigger : public IExternalTriggerImpl<This, StatusType>, public Helper
{ {
public: public:
FB__UDR_COMMON_TYPE(FieldsMessage); FB__UDR_COMMON_TYPE(FieldsMessage);
@ -294,15 +297,15 @@ public:
delete static_cast<This*>(this); delete static_cast<This*>(this);
} }
void getCharSet(ThrowStatusWrapper* /*status*/, IExternalContext* /*context*/, void getCharSet(StatusType* /*status*/, IExternalContext* /*context*/,
char* /*name*/, unsigned /*nameSize*/) char* /*name*/, unsigned /*nameSize*/)
{ {
} }
}; };
template <typename T> class FunctionFactoryImpl : template <typename T, typename StatusType> class FunctionFactoryImpl :
public IUdrFunctionFactoryImpl<FunctionFactoryImpl<T>, ThrowStatusWrapper> public IUdrFunctionFactoryImpl<FunctionFactoryImpl<T, StatusType>, StatusType>
{ {
public: public:
explicit FunctionFactoryImpl(const char* name) explicit FunctionFactoryImpl(const char* name)
@ -310,14 +313,14 @@ public:
fbUdrRegFunction(name, this); fbUdrRegFunction(name, this);
} }
void setup(ThrowStatusWrapper* status, IExternalContext* /*context*/, void setup(StatusType* status, IExternalContext* /*context*/,
IRoutineMetadata* /*metadata*/, IMetadataBuilder* in, IMetadataBuilder* out) IRoutineMetadata* /*metadata*/, IMetadataBuilder* in, IMetadataBuilder* out)
{ {
T::InMessage::setup(status, in); T::InMessage::setup(status, in);
T::OutMessage::setup(status, out); T::OutMessage::setup(status, out);
} }
IExternalFunction* newItem(ThrowStatusWrapper* status, IExternalContext* context, IExternalFunction* newItem(StatusType* status, IExternalContext* context,
IRoutineMetadata* metadata) IRoutineMetadata* metadata)
{ {
return new T(status, context, metadata); return new T(status, context, metadata);
@ -325,8 +328,8 @@ public:
}; };
template <typename T> class ProcedureFactoryImpl : template <typename T, typename StatusType> class ProcedureFactoryImpl :
public IUdrProcedureFactoryImpl<ProcedureFactoryImpl<T>, ThrowStatusWrapper> public IUdrProcedureFactoryImpl<ProcedureFactoryImpl<T, StatusType>, StatusType>
{ {
public: public:
explicit ProcedureFactoryImpl(const char* name) explicit ProcedureFactoryImpl(const char* name)
@ -334,14 +337,14 @@ public:
fbUdrRegProcedure(name, this); fbUdrRegProcedure(name, this);
} }
void setup(ThrowStatusWrapper* status, IExternalContext* /*context*/, void setup(StatusType* status, IExternalContext* /*context*/,
IRoutineMetadata* /*metadata*/, IMetadataBuilder* in, IMetadataBuilder* out) IRoutineMetadata* /*metadata*/, IMetadataBuilder* in, IMetadataBuilder* out)
{ {
T::InMessage::setup(status, in); T::InMessage::setup(status, in);
T::OutMessage::setup(status, out); T::OutMessage::setup(status, out);
} }
IExternalProcedure* newItem(ThrowStatusWrapper* status, IExternalContext* context, IExternalProcedure* newItem(StatusType* status, IExternalContext* context,
IRoutineMetadata* metadata) IRoutineMetadata* metadata)
{ {
return new T(status, context, metadata); return new T(status, context, metadata);
@ -349,8 +352,8 @@ public:
}; };
template <typename T> class TriggerFactoryImpl : template <typename T, typename StatusType> class TriggerFactoryImpl :
public IUdrTriggerFactoryImpl<TriggerFactoryImpl<T>, ThrowStatusWrapper> public IUdrTriggerFactoryImpl<TriggerFactoryImpl<T, StatusType>, StatusType>
{ {
public: public:
explicit TriggerFactoryImpl(const char* name) explicit TriggerFactoryImpl(const char* name)
@ -358,13 +361,13 @@ public:
fbUdrRegTrigger(name, this); fbUdrRegTrigger(name, this);
} }
void setup(ThrowStatusWrapper* status, IExternalContext* /*context*/, void setup(StatusType* status, IExternalContext* /*context*/,
IRoutineMetadata* /*metadata*/, IMetadataBuilder* fields) IRoutineMetadata* /*metadata*/, IMetadataBuilder* fields)
{ {
T::FieldsMessage::setup(status, fields); T::FieldsMessage::setup(status, fields);
} }
IExternalTrigger* newItem(ThrowStatusWrapper* status, IExternalContext* context, IExternalTrigger* newItem(StatusType* status, IExternalContext* context,
IRoutineMetadata* metadata) IRoutineMetadata* metadata)
{ {
return new T(status, context, metadata); return new T(status, context, metadata);

View File

@ -23,7 +23,6 @@
#include "firebird.h" #include "firebird.h"
#include "../jrd/ibase.h" #include "../jrd/ibase.h"
#include "firebird/UdrEngine.h" #include "firebird/UdrEngine.h"
#include "firebird/UdrCppEngine.h"
#include "firebird/Interface.h" #include "firebird/Interface.h"
#include "../common/classes/alloc.h" #include "../common/classes/alloc.h"
#include "../common/classes/array.h" #include "../common/classes/array.h"