Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix C++ generated code #3425

Merged
merged 2 commits into from
Jan 25, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions cpp/src/Ice/Object.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#include "Ice/SlicedData.h"

#include <algorithm>
#include <array>
#include <sstream>

using namespace std;
Expand Down Expand Up @@ -110,19 +111,18 @@ Ice::Object::_iceD_ice_id(
void
Ice::Object::dispatch(IncomingRequest& request, std::function<void(OutgoingResponse)> sendResponse)
{
static constexpr string_view allOperations[] = {"ice_id", "ice_ids", "ice_isA", "ice_ping"};
static constexpr std::array<string_view, 4> allOperations{"ice_id", "ice_ids", "ice_isA", "ice_ping"};

const Current& current = request.current();

pair<const string_view*, const string_view*> r = equal_range(allOperations, allOperations + 4, current.operation);
auto r = equal_range(allOperations.begin(), allOperations.end(), current.operation);

if (r.first == r.second)
{
sendResponse(makeOutgoingResponse(make_exception_ptr(OperationNotExistException{__FILE__, __LINE__}), current));
return;
}

switch (r.first - allOperations)
switch (r.first - allOperations.begin())
{
case 0:
{
Expand Down
20 changes: 10 additions & 10 deletions cpp/src/slice2cpp/CPlusPlusUtil.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -497,9 +497,9 @@ Slice::typeToString(
"float",
"double",
"****", // string or wstring, see below
"::Ice::ValuePtr",
"::std::optional<::Ice::ObjectPrx>",
"::Ice::ValuePtr"};
"Ice::ValuePtr",
"::std::optional<Ice::ObjectPrx>",
"Ice::ValuePtr"};

BuiltinPtr builtin = dynamic_pointer_cast<Builtin>(type);
if (builtin)
Expand All @@ -512,11 +512,11 @@ Slice::typeToString(
{
if (builtin->kind() == Builtin::KindObject)
{
return getUnqualified(string{builtinTable[Builtin::KindValue]}, scope);
return string{builtinTable[Builtin::KindValue]};
}
else
{
return getUnqualified(string{builtinTable[builtin->kind()]}, scope);
return string{builtinTable[builtin->kind()]};
}
}
}
Expand Down Expand Up @@ -605,12 +605,12 @@ Slice::operationModeToString(Operation::Mode mode)
{
case Operation::Normal:
{
return "::Ice::OperationMode::Normal";
return "Ice::OperationMode::Normal";
}

case Operation::Idempotent:
{
return "::Ice::OperationMode::Idempotent";
return "Ice::OperationMode::Idempotent";
}
default:
{
Expand All @@ -630,9 +630,9 @@ Slice::opFormatTypeToString(const OperationPtr& op)
switch (*opFormat)
{
case CompactFormat:
return "::Ice::FormatType::CompactFormat";
return "Ice::FormatType::CompactFormat";
case SlicedFormat:
return "::Ice::FormatType::SlicedFormat";
return "Ice::FormatType::SlicedFormat";

default:
assert(false);
Expand Down Expand Up @@ -768,7 +768,7 @@ Slice::writeDataMembers(Output& out, const DataMemberList& dataMembers)
}

void
Slice::writeIceTuple(::IceInternal::Output& out, const DataMemberList& dataMembers, TypeContext typeCtx)
Slice::writeIceTuple(IceInternal::Output& out, const DataMemberList& dataMembers, TypeContext typeCtx)
{
// Use an empty scope to get full qualified names from calls to typeToString.
const string scope = "";
Expand Down
20 changes: 8 additions & 12 deletions cpp/src/slice2cpp/CPlusPlusUtil.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ namespace Slice
char operator()(char);
};

void printHeader(::IceInternal::Output&);
void printVersionCheck(::IceInternal::Output&);
void printDllExportStuff(::IceInternal::Output&, const std::string&);
void printHeader(IceInternal::Output&);
void printVersionCheck(IceInternal::Output&);
void printDllExportStuff(IceInternal::Output&, const std::string&);

bool isMovable(const TypePtr&);

Expand Down Expand Up @@ -53,14 +53,10 @@ namespace Slice
std::string operationModeToString(Operation::Mode);
std::string opFormatTypeToString(const OperationPtr&);

void writeMarshalCode(::IceInternal::Output&, const ParameterList&, const OperationPtr&);
void writeUnmarshalCode(::IceInternal::Output&, const ParameterList&, const OperationPtr&);
void writeAllocateCode(
::IceInternal::Output&,
const ParameterList&,
const OperationPtr&,
const std::string&,
TypeContext);
void writeMarshalCode(IceInternal::Output&, const ParameterList&, const OperationPtr&);
void writeUnmarshalCode(IceInternal::Output&, const ParameterList&, const OperationPtr&);
void
writeAllocateCode(IceInternal::Output&, const ParameterList&, const OperationPtr&, const std::string&, TypeContext);

// TODO: remove from header file.
void writeMarshalUnmarshalAllInHolder(IceInternal::Output&, const std::string&, const DataMemberList&, bool, bool);
Expand All @@ -72,7 +68,7 @@ namespace Slice
void readDataMembers(IceInternal::Output&, const DataMemberList&);
void writeDataMembers(IceInternal::Output&, const DataMemberList&);

void writeIceTuple(::IceInternal::Output&, const DataMemberList&, TypeContext);
void writeIceTuple(IceInternal::Output&, const DataMemberList&, TypeContext);

std::string findMetadata(const MetadataList&, TypeContext = TypeContext::None);
bool inWstringModule(const SequencePtr&);
Expand Down
Loading
Loading