Skip to content

Commit

Permalink
Formatting...
Browse files Browse the repository at this point in the history
  • Loading branch information
InsertCreativityHere committed Dec 16, 2024
1 parent 3ed45ad commit bbe9493
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 24 deletions.
28 changes: 14 additions & 14 deletions cpp/src/slice2cs/CsUtil.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1869,18 +1869,18 @@ Slice::CsGenerator::validateMetadata(const UnitPtr& u)

// "cs:attribute"
MetadataInfo attributeInfo = {
.validOn = {
typeid(Unit),
typeid(Module),
typeid(InterfaceDecl),
typeid(ClassDecl),
typeid(Operation),
typeid(Slice::Exception),
typeid(Struct),
typeid(Enum),
typeid(Const),
typeid(Parameter),
typeid(DataMember)},
.validOn =
{typeid(Unit),
typeid(Module),
typeid(InterfaceDecl),
typeid(ClassDecl),
typeid(Operation),
typeid(Slice::Exception),
typeid(Struct),
typeid(Enum),
typeid(Const),
typeid(Parameter),
typeid(DataMember)},
.acceptedArgumentKind = MetadataArgumentKind::RequiredTextArgument,
.mustBeUnique = false,
};
Expand All @@ -1905,15 +1905,15 @@ Slice::CsGenerator::validateMetadata(const UnitPtr& u)
if (argument == "LinkedList" || argument == "Queue" || argument == "Stack")
{
return "'cs:generic:" + argument +
"' is not supported on sequences of objects; only 'List' is supported for object sequences";
"' is not supported on sequences of objects; only 'List' is supported for object sequences";
}
}
else if (dynamic_pointer_cast<Dictionary>(p))
{
if (argument != "SortedDictionary" && argument != "SortedList")
{
return "the 'cs:generic' metadata only supports 'SortedDictionary' and 'SortedList' as arguments "
"when applied to a dictionary";
"when applied to a dictionary";
}
}
return nullopt;
Expand Down
15 changes: 13 additions & 2 deletions cpp/src/slice2java/JavaUtil.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,16 @@ Slice::isValidMethodParameterList(const DataMemberList& members, int additionalU
return length <= 255;
}

bool
Slice::mapsToJavaBuiltinType(const TypePtr& p)
{
if (auto builtin = dynamic_pointer_cast<Builtin>(p))
{
return builtin->kind() < Builtin::KindObject;
}
return false;
}

Slice::JavaOutput::JavaOutput() {}

Slice::JavaOutput::JavaOutput(ostream& os) : Output(os) {}
Expand Down Expand Up @@ -1991,12 +2001,13 @@ Slice::JavaGenerator::validateMetadata(const UnitPtr& u)
const string& value = meta->arguments();
try
{
std::stoll(value, nullptr, 0);
[[maybe_unused]] auto _ = std::stoll(value, nullptr, 0);
}
catch (const std::exception&)
{
return "serialVersionUID '" + value + "' is not a valid integer literal; using default value instead";
}
return nullopt;
},
};
knownMetadata.emplace("java:serialVersionUID", std::move(serialVersionUIDInfo));
Expand All @@ -2013,7 +2024,7 @@ Slice::JavaGenerator::validateMetadata(const UnitPtr& u)
if (seq->hasMetadata("java:serializable"))
{
return "the 'java:type' metadata cannot be used alongside 'java:serializable' - both change the "
"mapped type of this sequence";
"mapped type of this sequence";
}
}
// This metadata conflicts with 'java:buffer', but we let the validation functions for that metadata
Expand Down
9 changes: 1 addition & 8 deletions cpp/src/slice2java/JavaUtil.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,7 @@ namespace Slice
bool isValidMethodParameterList(const DataMemberList&, int additionalUnits = 0);

/// Returns true if and only if 'p' maps to one of the builtin Java types (ie. a primitive type or a string).
bool mapsToJavaBuiltinType(const TypePtr& p)
{
if (auto builtin = dynamic_pointer_cast<Builtin>(p))
{
return builtin->kind() < Builtin::KindObject;
}
return false;
}
bool mapsToJavaBuiltinType(const TypePtr& p);

class JavaOutput final : public ::IceInternal::Output
{
Expand Down

0 comments on commit bbe9493

Please sign in to comment.