Skip to content

Commit

Permalink
Mark Nonmutating enumerator deprecated (#2978)
Browse files Browse the repository at this point in the history
  • Loading branch information
bernardnormier authored Oct 28, 2024
1 parent 93ed7f7 commit eafc03c
Show file tree
Hide file tree
Showing 7 changed files with 32 additions and 19 deletions.
20 changes: 6 additions & 14 deletions cpp/include/Ice/PushDisableWarnings.h
Original file line number Diff line number Diff line change
@@ -1,13 +1,10 @@
//
// Copyright (c) ZeroC, Inc. All rights reserved.
//
// Copyright (c) ZeroC, Inc.

/*! \file
\hideincludedbygraph
*/

// No pragma once as this file can be included several times in a translation
// unit
// This file can be included several times in a translation unit.

#if defined(_MSC_VER)
# pragma warning(push)
Expand All @@ -19,15 +16,10 @@

#elif defined(__clang__)
# pragma clang diagnostic push
# pragma clang diagnostic ignored "-Wredundant-decls" // expected when using forward Slice declarations
# pragma clang diagnostic ignored "-Wdocumentation-deprecated-sync" // see zeroc-ice/ice issue #211
# pragma clang diagnostic ignored "-Wdeprecated-declarations" // allow referencing deprecated Slice definitions

# if (__clang_major__ >= 4)
# pragma clang diagnostic ignored "-Wshadow-field-in-constructor" // expected in some generated header files
# else
# pragma clang diagnostic ignored "-Wshadow-all" // expected in some generated header files
# endif
# pragma clang diagnostic ignored "-Wredundant-decls" // expected when using forward Slice declarations
# pragma clang diagnostic ignored "-Wshadow-field-in-constructor" // expected in some generated header files
# pragma clang diagnostic ignored "-Wdeprecated-declarations" // allow referencing deprecated Slice definitions
# pragma clang diagnostic ignored "-Wdocumentation-deprecated-sync"

#elif defined(__GNUC__)
# pragma GCC diagnostic push
Expand Down
4 changes: 4 additions & 0 deletions cpp/src/Ice/Object.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,9 @@ namespace
case OperationMode::Normal:
return "::Ice::Normal";

#include "PushDisableDeprecatedWarnings.h"
case OperationMode::Nonmutating:
#include "Ice/PopDisableWarnings.h"
return "::Ice::Nonmutating";

case OperationMode::Idempotent:
Expand All @@ -171,6 +173,7 @@ Ice::Object::_iceCheckMode(OperationMode expected, OperationMode received)
{
if (expected != received)
{
#include "PushDisableDeprecatedWarnings.h"
assert(expected != OperationMode::Nonmutating); // We never expect Nonmutating
if (expected == OperationMode::Idempotent && received == OperationMode::Nonmutating)
{
Expand All @@ -183,6 +186,7 @@ Ice::Object::_iceCheckMode(OperationMode expected, OperationMode received)
<< " received = " << operationModeToString(received);
throw Ice::MarshalException(__FILE__, __LINE__, reason.str());
}
#include "Ice/PopDisableWarnings.h"
}
}

Expand Down
3 changes: 1 addition & 2 deletions cpp/src/Ice/OutgoingAsync.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -573,8 +573,7 @@ ProxyOutgoingAsyncBase::handleRetryAfterException(std::exception_ptr ex)
}
catch (const Ice::LocalException& localEx)
{
if (!_sent || _mode == OperationMode::Nonmutating || _mode == OperationMode::Idempotent ||
dynamic_cast<const CloseConnectionException*>(&localEx) ||
if (!_sent || _mode != OperationMode::Normal || dynamic_cast<const CloseConnectionException*>(&localEx) ||
dynamic_cast<const ObjectNotExistException*>(&localEx))
{
try
Expand Down
15 changes: 15 additions & 0 deletions cpp/src/Ice/PushDisableDeprecatedWarnings.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
// Copyright (c) ZeroC, Inc.

// This file can be included several times in a translation unit.

#if defined(_MSC_VER)
# pragma warning(push)
# pragma warning(disable : 4996) // ... was declared deprecated

#elif defined(__clang__)
# pragma clang diagnostic push
# pragma clang diagnostic ignored "-Wdeprecated-declarations"

#elif defined(__GNUC__)
# pragma GCC diagnostic ignored "-Wdeprecated-declarations"
#endif
2 changes: 2 additions & 0 deletions cpp/src/Ice/TraceUtil.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -83,11 +83,13 @@ printRequestHeader(ostream& s, InputStream& stream)
break;
}

#include "PushDisableDeprecatedWarnings.h"
case OperationMode::Nonmutating:
{
s << "(nonmutating)";
break;
}
#include "Ice/PopDisableWarnings.h"

case OperationMode::Idempotent:
{
Expand Down
2 changes: 2 additions & 0 deletions python/modules/IcePy/Current.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,9 @@ IcePy::createCurrent(const Ice::Current& current)
case Ice::OperationMode::Normal:
enumerator = "Normal";
break;
#include "Ice/PushDisableDeprecatedWarnings.h"
case Ice::OperationMode::Nonmutating:
#include "Ice/PopDisableWarnings.h"
enumerator = "Nonmutating";
break;
case Ice::OperationMode::Idempotent:
Expand Down
5 changes: 2 additions & 3 deletions slice/Ice/OperationMode.ice
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,8 @@ module Ice

/// Operations that are <code>nonmutating</code> must not modify object state.
/// The Ice run-time no longer makes a distinction between nonmutating operations and idempotent operations.
/// <p class="Deprecated"><code>Nonmutating</code> is deprecated; Use the <code>idempotent</code> keyword
/// instead.
Nonmutating,
/// Use the <code>idempotent</code> keyword instead.
["deprecated:Use Idempotent instead."] Nonmutating,

/// Operations that use the Slice <code>idempotent</code> keyword can modify object state, but invoking an
/// operation twice in a row must result in the same object state as invoking it once. For example,
Expand Down

0 comments on commit eafc03c

Please sign in to comment.