From c697a0268ad5be74add8ec0aecd77f4fb2573969 Mon Sep 17 00:00:00 2001 From: asfernandes Date: Sun, 18 Jan 2015 14:53:06 +0000 Subject: [PATCH] Fixed problem of local templates being not allowed in pre-C++-11 code. --- examples/udr/UdrCppExample.cpp | 14 +++++++------- src/include/firebird/Message.h | 18 ++++++++---------- src/include/firebird/UdrCppEngine.h | 7 +++++++ 3 files changed, 22 insertions(+), 17 deletions(-) diff --git a/examples/udr/UdrCppExample.cpp b/examples/udr/UdrCppExample.cpp index 99ba981eb6..b741d8f462 100644 --- a/examples/udr/UdrCppExample.cpp +++ b/examples/udr/UdrCppExample.cpp @@ -196,11 +196,11 @@ create function wait_event ( engine udr; ***/ FB_UDR_BEGIN_FUNCTION(wait_event) - FB_MESSAGE(InMessage, + FB_UDR_MESSAGE(InMessage, (FB_VARCHAR(31 * 4), name) ); - FB_MESSAGE(OutMessage, + FB_UDR_MESSAGE(OutMessage, (FB_INTEGER, result) ); @@ -391,12 +391,12 @@ create procedure gen_rows2 ( engine udr; ***/ FB_UDR_BEGIN_PROCEDURE(gen_rows2) - FB_MESSAGE(InMessage, + FB_UDR_MESSAGE(InMessage, (FB_INTEGER, start) (FB_INTEGER, end) ); - FB_MESSAGE(OutMessage, + FB_UDR_MESSAGE(OutMessage, (FB_INTEGER, result) ); @@ -431,11 +431,11 @@ create procedure inc ( // metadata object. // n3 and n4 are on the ResultSet scope, i.e., each procedure execution have they own instances. FB_UDR_BEGIN_PROCEDURE(inc) - FB_MESSAGE(InMessage, + FB_UDR_MESSAGE(InMessage, (FB_INTEGER, count) ); - FB_MESSAGE(OutMessage, + FB_UDR_MESSAGE(OutMessage, (FB_INTEGER, n0) (FB_INTEGER, n1) (FB_INTEGER, n2) @@ -682,7 +682,7 @@ FB_UDR_END_TRIGGER FB_UDR_BEGIN_TRIGGER(replicate_persons) // Order of fields does not need to match the fields order in the table, but it should match // the order of fields in the SQL command constructed in the initialization. - FB_TRIGGER_MESSAGE(FieldsMessage, + FB_UDR_TRIGGER_MESSAGE(FieldsMessage, (FB_INTEGER, id, "ID") (FB_BLOB, info, "INFO") ///(FB_VARCHAR(60 * 4), address, "ADDRESS") diff --git a/src/include/firebird/Message.h b/src/include/firebird/Message.h index 71c551de83..d5a0b19f30 100644 --- a/src/include/firebird/Message.h +++ b/src/include/firebird/Message.h @@ -29,16 +29,16 @@ #include #include -#define FB_MESSAGE(name, fields) \ - FB__MESSAGE_I(name, 2, FB_BOOST_PP_CAT(FB__MESSAGE_X fields, 0), ) +#define FB_MESSAGE(name, statusType, fields) \ + FB__MESSAGE_I(name, statusType, 2, FB_BOOST_PP_CAT(FB__MESSAGE_X fields, 0), ) #define FB__MESSAGE_X(x, y) ((x, y)) FB__MESSAGE_Y #define FB__MESSAGE_Y(x, y) ((x, y)) FB__MESSAGE_X #define FB__MESSAGE_X0 #define FB__MESSAGE_Y0 -#define FB_TRIGGER_MESSAGE(name, fields) \ - FB__MESSAGE_I(name, 3, FB_BOOST_PP_CAT(FB_TRIGGER_MESSAGE_X fields, 0), \ +#define FB_TRIGGER_MESSAGE(name, statusType, fields) \ + FB__MESSAGE_I(name, statusType, 3, FB_BOOST_PP_CAT(FB_TRIGGER_MESSAGE_X fields, 0), \ FB_TRIGGER_MESSAGE_MOVE_NAMES(name, fields)) #define FB_TRIGGER_MESSAGE_X(x, y, z) ((x, y, z)) FB_TRIGGER_MESSAGE_Y @@ -46,7 +46,7 @@ #define FB_TRIGGER_MESSAGE_X0 #define FB_TRIGGER_MESSAGE_Y0 -#define FB__MESSAGE_I(name, size, fields, moveNames) \ +#define FB__MESSAGE_I(name, statusType, size, fields, moveNames) \ struct name \ { \ struct Type \ @@ -54,17 +54,15 @@ FB_BOOST_PP_SEQ_FOR_EACH_I(FB__MESSAGE_FIELD, size, fields) \ }; \ \ - template \ - static void setup(StatusType* status, ::Firebird::IMetadataBuilder* builder) \ + static void setup(statusType* status, ::Firebird::IMetadataBuilder* builder) \ { \ unsigned index = 0; \ moveNames \ FB_BOOST_PP_SEQ_FOR_EACH_I(FB__MESSAGE_META, size, fields) \ } \ \ - template \ - name(StatusType* status, ::Firebird::IMaster* master) \ - : desc(master, status, FB_BOOST_PP_SEQ_SIZE(fields), &setup) \ + name(statusType* status, ::Firebird::IMaster* master) \ + : desc(master, status, FB_BOOST_PP_SEQ_SIZE(fields), setup) \ { \ } \ \ diff --git a/src/include/firebird/UdrCppEngine.h b/src/include/firebird/UdrCppEngine.h index 9e2bdca8d4..6c4dfb5ec5 100644 --- a/src/include/firebird/UdrCppEngine.h +++ b/src/include/firebird/UdrCppEngine.h @@ -150,6 +150,13 @@ namespace Firebird ~Impl() +#define FB_UDR_MESSAGE(name, fields) \ + FB_MESSAGE(name, FB_UDR_STATUS_TYPE, fields) + +#define FB_UDR_TRIGGER_MESSAGE(name, fields) \ + FB_TRIGGER_MESSAGE(name, FB_UDR_STATUS_TYPE, fields) + + #define FB__UDR_COMMON_IMPL \ Impl(const void* const, ::Firebird::IExternalContext* const context, \ ::Firebird::IRoutineMetadata* const aMetadata) \