From 96e87cedfa3e86756f70c2a298ed1ffbbf0fcffe Mon Sep 17 00:00:00 2001 From: Julius Pfrommer Date: Wed, 28 Jun 2017 12:46:52 +0200 Subject: [PATCH] restore old UA_Job API and mark as deprecated --- CMakeLists.txt | 1 + include/ua_config.h.in | 8 +++++ include/ua_server.h | 3 ++ include/ua_server_deprecated.h | 60 ++++++++++++++++++++++++++++++++++ 4 files changed, 72 insertions(+) create mode 100644 include/ua_server_deprecated.h diff --git a/CMakeLists.txt b/CMakeLists.txt index f14ea2788..d9490ddcf 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -238,6 +238,7 @@ set(exported_headers ${PROJECT_BINARY_DIR}/src_generated/ua_config.h ${PROJECT_SOURCE_DIR}/include/ua_plugin_log.h ${PROJECT_SOURCE_DIR}/include/ua_plugin_access_control.h ${PROJECT_SOURCE_DIR}/include/ua_server.h + ${PROJECT_SOURCE_DIR}/include/ua_server_deprecated.h ${PROJECT_SOURCE_DIR}/include/ua_client.h ${PROJECT_SOURCE_DIR}/include/ua_client_highlevel.h ${PROJECT_SOURCE_DIR}/plugins/ua_network_tcp.h diff --git a/include/ua_config.h.in b/include/ua_config.h.in index f44b2a33f..8c3403ec4 100644 --- a/include/ua_config.h.in +++ b/include/ua_config.h.in @@ -172,6 +172,14 @@ typedef uint8_t bool; # define UA_FUNC_ATTR_WARN_UNUSED_RESULT #endif +#ifdef __GNUC__ +# define UA_DEPRECATED __attribute__((deprecated)) +#elif defined(_MSC_VER) +# define UA_DEPRECATED __declspec(deprecated) +#else +# define UA_DEPRECATED +#endif + /** * String Manipulation * ------------------- diff --git a/include/ua_server.h b/include/ua_server.h index 78f235feb..be8d3fc60 100644 --- a/include/ua_server.h +++ b/include/ua_server.h @@ -962,4 +962,7 @@ UA_UInt16 UA_EXPORT UA_Server_addNamespace(UA_Server *server, const char* name); } #endif +/* Old interfaces kept for API compatibility */ +#include "ua_server_deprecated.h" + #endif /* UA_SERVER_H_ */ diff --git a/include/ua_server_deprecated.h b/include/ua_server_deprecated.h new file mode 100644 index 000000000..1b0d51ae1 --- /dev/null +++ b/include/ua_server_deprecated.h @@ -0,0 +1,60 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +#ifndef UA_SERVER_DEPRECATED_H_ +#define UA_SERVER_DEPRECATED_H_ + +#ifdef __cplusplus +extern "C" { +#endif + +#include "ua_server.h" + +/** + * Deprecated API + * ============== + * This file contains outdated API definitions that are kept for backwards + * compatibility. Please switch to the new API, as the following definitions + * will be removed eventually. */ + +/** + * UA_Job API + * ---------- + * UA_Job was replaced since it unneccessarily exposed server internals to the + * end-user. Please use plain UA_ServerCallbacks instead. The following UA_Job + * definition contains just the fraction of the original struct that was useful + * to end-users. */ + +typedef enum { + UA_JOBTYPE_METHODCALL +} UA_JobType; + +typedef struct { + UA_JobType type; + union { + struct { + void *data; + UA_ServerCallback method; + } methodCall; + } job; +} UA_Job; + +UA_DEPRECATED static UA_INLINE UA_StatusCode +UA_Server_addRepeatedJob(UA_Server *server, UA_Job job, + UA_UInt32 interval, UA_Guid *jobId) { + return UA_Server_addRepeatedCallback(server, job.job.methodCall.method, + job.job.methodCall.data, interval, + (UA_UInt64*)jobId); +} + +UA_DEPRECATED static UA_INLINE UA_StatusCode +UA_Server_removeRepeatedJob(UA_Server *server, UA_Guid jobId) { + return UA_Server_removeRepeatedCallback(server, *(UA_UInt64*)&jobId); +} + +#ifdef __cplusplus +} +#endif + +#endif /* UA_SERVER_DEPRECATED_H_ */