Skip to content

Commit

Permalink
C++: fix translation of large integers in the set of enum values
Browse files Browse the repository at this point in the history
Fixes test EnumLongRangeS for
`cpp_stl_11/{clang3.4,clang11}-linux-x86_64`

Probably also fixes EnumLongRangeS for `cpp_stl_11/clang14-macos-x86_64` -
untested, but seems very likely, given that the build error looks
exactly the same as in `cpp_stl_11/clang11-linux-x86_64`.

Hopefully also fixes the Enum{Int,Long}Range{S,U} tests for
`cpp_stl_11/msvc141-windows-x64` - I haven't tested that locally, so
let's see the result in CI.
  • Loading branch information
generalmimon committed Aug 24, 2024
1 parent 793ba60 commit 5929d44
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -905,7 +905,7 @@ class CppCompiler(
outHdr.puts(s"static const std::set<std::underlying_type<$enumClass>::type> _values_$enumClass;")
val enumClassAbs = types2class(curClass ++ List(enumName))
val valuesSetAbsRef = s"${types2class(curClass)}::_values_$enumClass"
val setEntriesStr = enumColl.map { case (id, _) => s"$id" }.mkString(", ")
val setEntriesStr = enumColl.map { case (id, _) => translator.doIntLiteral(id) }.mkString(", ")
outSrc.puts(s"const std::set<std::underlying_type<$enumClassAbs>::type> $valuesSetAbsRef{$setEntriesStr};")
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -440,7 +440,7 @@ class PHPCompiler(typeProvider: ClassTypeProvider, config: RuntimeConfig)
out.puts(s"const ${value2Const(label.name)} = ${translator.doIntLiteral(id)};")
}
out.puts
val arrayEntriesStr = enumColl.map { case (id, _) => s"$id => true" }.mkString(", ")
val arrayEntriesStr = enumColl.map { case (id, _) => s"${translator.doIntLiteral(id)} => true" }.mkString(", ")
out.puts(s"private const _VALUES = [$arrayEntriesStr];")
out.puts
out.puts("public static function isDefined(int $v): bool {")
Expand Down

0 comments on commit 5929d44

Please sign in to comment.