From 8ece0e448f1905c36ce5aaad498c5565550c0021 Mon Sep 17 00:00:00 2001 From: Fred Hornsey Date: Tue, 20 Jul 2021 00:15:00 -0500 Subject: Header File for TAO_IDL Supported IDL Features Get information about what IDL features the IDL compiler has, similarly to the "version" standard header in C++. In C++ it can be used like this if you want to be compatible with older versions of TAO: ```c++ #include "tao/orbconf.h" #if defined TAO_HAS_IDL_FEATURES && TAO_HAS_IDL_FEATURES // Use this macro if you are using something that's not the max possible // version. # define TAO_IDL_IDL_VERSION 0x50000 # include "tao/idl_features.h" # define USE_FEATURE defined TAO_IDL_HAS_FEATURE && TAO_IDL_HAS_FEATURE #else # define USE_FEATURE 0 #endif ``` In IDL it can be used like this if you want to be compatible with older versions of TAO: ```c++ #if defined __TAO_IDL_FEATURES # include __TAO_IDL_FEATURES # define USE_FEATURE defined TAO_IDL_HAS_FEATURE && TAO_IDL_HAS_FEATURE #else # define USE_FEATURE 0 #endif ``` --- TAO/NEWS | 3 ++ TAO/TAO_IDL/driver/drv_preproc.cpp | 7 +++ TAO/TAO_IDL/include/idl_version.h | 5 +++ TAO/TAO_IDL/util/idl_version.cpp | 26 ++++++++--- TAO/tao/idl_features.h | 75 ++++++++++++++++++++++++++++++++ TAO/tao/orbconf.h | 4 ++ TAO/tao/tao.mpc | 1 + TAO/tests/IDLv4/anonymous_types/test.idl | 9 ++++ TAO/tests/IDLv4/explicit_ints/main.cpp | 9 ++++ TAO/tests/IDLv4/explicit_ints/test.idl | 9 ++++ 10 files changed, 143 insertions(+), 5 deletions(-) create mode 100644 TAO/tao/idl_features.h diff --git a/TAO/NEWS b/TAO/NEWS index eaa44155c4a..c8903aefc78 100644 --- a/TAO/NEWS +++ b/TAO/NEWS @@ -6,6 +6,9 @@ USER VISIBLE CHANGES BETWEEN TAO-3.0.2 and TAO-3.0.3 these are new distinct types that are not aliases of existing types covered by the CORBA specification. +. Added the `tao/idl_features.h` header file for getting the IDL features + supported by IDL. See the file for example usage. + USER VISIBLE CHANGES BETWEEN TAO-3.0.1 and TAO-3.0.2 ==================================================== diff --git a/TAO/TAO_IDL/driver/drv_preproc.cpp b/TAO/TAO_IDL/driver/drv_preproc.cpp index 1943bbdf9d3..f512dc7fd79 100644 --- a/TAO/TAO_IDL/driver/drv_preproc.cpp +++ b/TAO/TAO_IDL/driver/drv_preproc.cpp @@ -582,6 +582,13 @@ DRV_add_include_path (ACE_CString& include_path, void DRV_cpp_post_init () { + char idl_version_arg[128]; + ACE_OS::sprintf (idl_version_arg, "-D__TAO_IDL_IDL_VERSION=%s", + idl_global->idl_version_.to_macro ()); + DRV_cpp_putarg (idl_version_arg); + + DRV_cpp_putarg ("-D__TAO_IDL_FEATURES=\"tao/idl_features.h\""); + // Add include path for TAO_ROOT/orbsvcs. char* TAO_ROOT = ACE_OS::getenv ("TAO_ROOT"); diff --git a/TAO/TAO_IDL/include/idl_version.h b/TAO/TAO_IDL/include/idl_version.h index 03255a88962..3d47ec5cfe2 100644 --- a/TAO/TAO_IDL/include/idl_version.h +++ b/TAO/TAO_IDL/include/idl_version.h @@ -94,6 +94,11 @@ public: */ void from_string (const char * version); + /** + * Get the value for the __TAO_IDL_IDL_VERSION preprocessor macro. + */ + const char * to_macro () const; + /** * Compare a IdlVersion to a SpecificIdlVersion or another IdlVersion */ diff --git a/TAO/TAO_IDL/util/idl_version.cpp b/TAO/TAO_IDL/util/idl_version.cpp index 2ab8a542b24..a5499d663e6 100644 --- a/TAO/TAO_IDL/util/idl_version.cpp +++ b/TAO/TAO_IDL/util/idl_version.cpp @@ -7,11 +7,22 @@ #include "ace/OS_NS_string.h" #include "idl_version.h" -static const char * idlVersionNames[IDL_VERSION_COUNT] = { - "Invalid", - "3", - "4" -}; +namespace { + const char * idlVersionNames[IDL_VERSION_COUNT] = { + "Invalid", + "3", + "4" + }; + + /** + * Values for __TAO_IDL_IDL_VERSION. Should work like __TAO_IDL does. + */ + const char * idl_version_macros[IDL_VERSION_COUNT] = { + "0x0", + "0x030000", + "0x040000" + }; +} IdlVersion::IdlVersion () : version_(DEFAULT_DEFAULT_IDL_VERSION) { @@ -58,6 +69,11 @@ void IdlVersion::from_string (const char * version) version_ = IDL_VERSION_INVALID; } +const char * IdlVersion::to_macro () const +{ + return idl_version_macros[version_]; +} + IdlVersion::operator SpecificIdlVersion () const { return version_; diff --git a/TAO/tao/idl_features.h b/TAO/tao/idl_features.h new file mode 100644 index 00000000000..40cc7d951b8 --- /dev/null +++ b/TAO/tao/idl_features.h @@ -0,0 +1,75 @@ +/** + * @file idl_features.h + * + * Get information about what IDL features the IDL compiler has, similarly to + * the "version" standard header in C++. + * + * In C++ it can be used like this if you want to be compatible with older + * versions of TAO: + * + * #include "tao/orbconf.h" + * #if defined TAO_HAS_IDL_FEATURES && TAO_HAS_IDL_FEATURES + * // Use this macro if you are using something that's not the max possible + * // version. + * # define TAO_IDL_IDL_VERSION 0x30000 + * # include "tao/idl_features.h" + * # define USE_FEATURE defined TAO_IDL_HAS_FEATURE && TAO_IDL_HAS_FEATURE + * #else + * # define USE_FEATURE 0 + * #endif + * + * In IDL it can be used like this if you want to be compatible with older + * versions of TAO: + * + * #if defined __TAO_IDL_FEATURES + * # include __TAO_IDL_FEATURES + * # define USE_FEATURE defined TAO_IDL_HAS_FEATURE && TAO_IDL_HAS_FEATURE + * #else + * # define USE_FEATURE 0 + * #endif + */ + +#ifndef TAO_IDL_FEATURES_H +#define TAO_IDL_FEATURES_H + +#ifndef TAO_IDL_IDL_VERSION +# ifdef __TAO_IDL_IDL_VERSION +# define TAO_IDL_IDL_VERSION __TAO_IDL_IDL_VERSION +# else +# define TAO_IDL_IDL_VERSION 0xffffffff +# endif +#endif + +#ifndef TAO_IDL_HAS_ANNOTATIONS +# define TAO_IDL_HAS_ANNOTATIONS TAO_IDL_IDL_VERSION >= 0x40000 +#endif + +#ifndef TAO_IDL_HAS_ANONYMOUS_TYPES +# define TAO_IDL_HAS_ANONYMOUS_TYPES TAO_IDL_IDL_VERSION >= 0x40000 +#endif + +#ifndef TAO_IDL_HAS_EXPLICIT_INTS +# define TAO_IDL_HAS_EXPLICIT_INTS TAO_IDL_IDL_VERSION >= 0x40000 +#endif + +#ifndef TAO_IDL_HAS_OCTET_AND_WCHAR_UNION_DISCS +# define TAO_IDL_HAS_OCTET_AND_WCHAR_UNION_DISCS 0 +#endif + +#ifndef TAO_IDL_HAS_STRUCT_INHERITANCE +# define TAO_IDL_HAS_STRUCT_INHERITANCE 0 +#endif + +#ifndef TAO_IDL_HAS_MAP +# define TAO_IDL_HAS_MAP 0 +#endif + +#ifndef TAO_IDL_HAS_BITSET +# define TAO_IDL_HAS_BITSET 0 +#endif + +#ifndef TAO_IDL_HAS_BITMASK +# define TAO_IDL_HAS_BITMASK 0 +#endif + +#endif diff --git a/TAO/tao/orbconf.h b/TAO/tao/orbconf.h index de5905aea50..7559a8b8e14 100644 --- a/TAO/tao/orbconf.h +++ b/TAO/tao/orbconf.h @@ -857,6 +857,10 @@ enum TAO_Policy_Scope # define TAO_DEFAULT_COLLOCATION_STRATEGY TAO_COLLOCATION_THRU_POA #endif +#ifndef TAO_HAS_IDL_FEATURES +# define TAO_HAS_IDL_FEATURES 1 +#endif + TAO_END_VERSIONED_NAMESPACE_DECL #include /**/ "ace/post.h" diff --git a/TAO/tao/tao.mpc b/TAO/tao/tao.mpc index 64f85080969..14f122ee9d7 100644 --- a/TAO/tao/tao.mpc +++ b/TAO/tao/tao.mpc @@ -448,6 +448,7 @@ project(TAO) : acelib, install, tao_output, taodefaults, pidl, extra_core, taoid HTTP_Client.h HTTP_Handler.h HTTP_Parser.h + idl_features.h IFR_Client_Adapter.h IIOP_Acceptor.h IIOPC.h diff --git a/TAO/tests/IDLv4/anonymous_types/test.idl b/TAO/tests/IDLv4/anonymous_types/test.idl index eee64242483..d8e95fee31e 100644 --- a/TAO/tests/IDLv4/anonymous_types/test.idl +++ b/TAO/tests/IDLv4/anonymous_types/test.idl @@ -3,6 +3,15 @@ * there is already a test file at tests/IDL_Test/anonymous.idl. */ +#include __TAO_IDL_FEATURES +#ifdef TAO_IDL_HAS_ANONYMOUS_TYPES +# if !TAO_IDL_HAS_ANONYMOUS_TYPES +# error "Expecting macro to be true" +# endif +#else +# error "Expecting macro to be defined" +#endif + struct TestStruct { short short_array[10]; short another_short_array[10]; diff --git a/TAO/tests/IDLv4/explicit_ints/main.cpp b/TAO/tests/IDLv4/explicit_ints/main.cpp index 7aaa38a8d9c..43ff6583975 100644 --- a/TAO/tests/IDLv4/explicit_ints/main.cpp +++ b/TAO/tests/IDLv4/explicit_ints/main.cpp @@ -1,5 +1,14 @@ #include "testC.h" +#include "tao/idl_features.h" +#ifdef TAO_IDL_HAS_EXPLICIT_INTS +# if !TAO_IDL_HAS_EXPLICIT_INTS +# error "Expecting macro to be true" +# endif +#else +# error "Expecting macro to be defined" +#endif + #include "ace/OS_NS_stdlib.h" #include "ace/OS_main.h" #include "ace/streams.h" diff --git a/TAO/tests/IDLv4/explicit_ints/test.idl b/TAO/tests/IDLv4/explicit_ints/test.idl index 5cf247fba6d..426a962d857 100644 --- a/TAO/tests/IDLv4/explicit_ints/test.idl +++ b/TAO/tests/IDLv4/explicit_ints/test.idl @@ -1,3 +1,12 @@ +#include __TAO_IDL_FEATURES +#ifdef TAO_IDL_HAS_EXPLICIT_INTS +# if !TAO_IDL_HAS_EXPLICIT_INTS +# error "Expecting macro to be true" +# endif +#else +# error "Expecting macro to be defined" +#endif + #include "tao/Int8Seq.pidl" #include "tao/UInt8Seq.pidl" #include "tao/OctetSeq.pidl" -- cgit v1.2.1 From 9956106ce26e3c53de6e9cf2d19e3a6d6ca7559c Mon Sep 17 00:00:00 2001 From: Fred Hornsey Date: Tue, 20 Jul 2021 15:37:50 -0500 Subject: Correct NEWS and Examples --- TAO/NEWS | 2 +- TAO/tao/idl_features.h | 16 ++++++++++------ 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/TAO/NEWS b/TAO/NEWS index c8903aefc78..6c676ae41df 100644 --- a/TAO/NEWS +++ b/TAO/NEWS @@ -7,7 +7,7 @@ USER VISIBLE CHANGES BETWEEN TAO-3.0.2 and TAO-3.0.3 by the CORBA specification. . Added the `tao/idl_features.h` header file for getting the IDL features - supported by IDL. See the file for example usage. + supported by TAO_IDL. See the file for example usage. USER VISIBLE CHANGES BETWEEN TAO-3.0.1 and TAO-3.0.2 ==================================================== diff --git a/TAO/tao/idl_features.h b/TAO/tao/idl_features.h index 40cc7d951b8..c9453aede18 100644 --- a/TAO/tao/idl_features.h +++ b/TAO/tao/idl_features.h @@ -13,9 +13,9 @@ * // version. * # define TAO_IDL_IDL_VERSION 0x30000 * # include "tao/idl_features.h" - * # define USE_FEATURE defined TAO_IDL_HAS_FEATURE && TAO_IDL_HAS_FEATURE - * #else - * # define USE_FEATURE 0 + * # if defined TAO_IDL_HAS_FEATURE && TAO_IDL_HAS_FEATURE + * # define USE_FEATURE + * # endif * #endif * * In IDL it can be used like this if you want to be compatible with older @@ -23,10 +23,14 @@ * * #if defined __TAO_IDL_FEATURES * # include __TAO_IDL_FEATURES - * # define USE_FEATURE defined TAO_IDL_HAS_FEATURE && TAO_IDL_HAS_FEATURE - * #else - * # define USE_FEATURE 0 + * # if defined TAO_IDL_HAS_FEATURE && TAO_IDL_HAS_FEATURE + * # define USE_FEATURE + * # endif * #endif + * + * Note that support for annotations and anonymous types in IDL4 predate this + * file, so they are a potential special case depending on what ACE/TAO is + * being used. */ #ifndef TAO_IDL_FEATURES_H -- cgit v1.2.1 From c9568bca8c9520c7cad3aeedfba24d6232ce703a Mon Sep 17 00:00:00 2001 From: Fred Hornsey Date: Tue, 20 Jul 2021 17:52:30 -0500 Subject: Prevent Possible Redefinition Warnings --- TAO/TAO_IDL/include/idl_defines.h | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/TAO/TAO_IDL/include/idl_defines.h b/TAO/TAO_IDL/include/idl_defines.h index e7be19f038d..037f9c26d3c 100644 --- a/TAO/TAO_IDL/include/idl_defines.h +++ b/TAO/TAO_IDL/include/idl_defines.h @@ -65,6 +65,8 @@ trademarks or registered trademarks of Sun Microsystems, Inc. #ifndef _IDL_DEFINES_IDL_DEFINES_HH #define _IDL_DEFINES_IDL_DEFINES_HH +#include "tao/idl_features.h" + #include "ace/os_include/os_limits.h" /* @@ -111,11 +113,6 @@ trademarks or registered trademarks of Sun Microsystems, Inc. */ #define TAO_IDL_HAS_PARSE_ARGS_EXIT -/** - * Defined if TAO_IDL has support for annotations - */ -#define TAO_IDL_HAS_ANNOTATIONS - #define NAMEBUFSIZE 1024 // Maximum length of static buffers used to store names. -- cgit v1.2.1