Simplified ba.enum_by_value()

This commit is contained in:
Eric Froemling 2020-11-06 20:39:14 -08:00
parent 6f0e8b68a3
commit b1d5c273c1
5 changed files with 35 additions and 31 deletions

View File

@ -3932,24 +3932,24 @@
"assets/build/windows/Win32/ucrtbased.dll": "https://files.ballistica.net/cache/ba1/b5/85/f8b6d0558ddb87267f34254b1450",
"assets/build/windows/Win32/vc_redist.x86.exe": "https://files.ballistica.net/cache/ba1/1c/e1/4a1a2eddda2f4aebd5f8b64ab08e",
"assets/build/windows/Win32/vcruntime140d.dll": "https://files.ballistica.net/cache/ba1/50/8d/bc2600ac9491f1b14d659709451f",
"build/prefab/full/linux_x86_64/debug/ballisticacore": "https://files.ballistica.net/cache/ba1/45/dc/e839d976e8de4f76d3b54de5d797",
"build/prefab/full/linux_x86_64/release/ballisticacore": "https://files.ballistica.net/cache/ba1/39/a5/b43c4782cc1b4029cc37f3fdbdad",
"build/prefab/full/linux_x86_64_server/debug/dist/ballisticacore_headless": "https://files.ballistica.net/cache/ba1/4a/a6/9b997730074eff9d6777710c501c",
"build/prefab/full/linux_x86_64_server/release/dist/ballisticacore_headless": "https://files.ballistica.net/cache/ba1/00/2c/2c9d82ff6c3962392f38f82ef306",
"build/prefab/full/mac_x86_64/debug/ballisticacore": "https://files.ballistica.net/cache/ba1/22/f6/ffbb34a757725377ff0ee50b7d54",
"build/prefab/full/mac_x86_64/release/ballisticacore": "https://files.ballistica.net/cache/ba1/5d/7e/3569e77c80b0a38a3cc890961fd8",
"build/prefab/full/mac_x86_64_server/debug/dist/ballisticacore_headless": "https://files.ballistica.net/cache/ba1/e6/ed/96b82e2fc1e13dc278f959339939",
"build/prefab/full/mac_x86_64_server/release/dist/ballisticacore_headless": "https://files.ballistica.net/cache/ba1/27/8b/f9685e24a250fc4621bd4a54f2fe",
"build/prefab/full/windows_x86/debug/BallisticaCore.exe": "https://files.ballistica.net/cache/ba1/ce/c9/91f4c6d5ae4c24e6b8a1abe101e7",
"build/prefab/full/windows_x86/release/BallisticaCore.exe": "https://files.ballistica.net/cache/ba1/a3/c5/90f0dce06938303187a1c0e553d1",
"build/prefab/full/windows_x86_server/debug/dist/ballisticacore_headless.exe": "https://files.ballistica.net/cache/ba1/61/d3/57b9f6d3aa937e2b6946e8c04a95",
"build/prefab/full/windows_x86_server/release/dist/ballisticacore_headless.exe": "https://files.ballistica.net/cache/ba1/cb/d6/6c57d5c6c62ba62b689bcb0ec2d2",
"build/prefab/full/linux_x86_64/debug/ballisticacore": "https://files.ballistica.net/cache/ba1/cd/51/3d1c5e13f0cb6035a3d4a8106231",
"build/prefab/full/linux_x86_64/release/ballisticacore": "https://files.ballistica.net/cache/ba1/05/b4/d527fcc8fe53c60a0bbc76083eef",
"build/prefab/full/linux_x86_64_server/debug/dist/ballisticacore_headless": "https://files.ballistica.net/cache/ba1/4c/92/d17f56c69c7aa80a47b55a44df8b",
"build/prefab/full/linux_x86_64_server/release/dist/ballisticacore_headless": "https://files.ballistica.net/cache/ba1/09/4f/73ac4884969f83fcc18c88d34675",
"build/prefab/full/mac_x86_64/debug/ballisticacore": "https://files.ballistica.net/cache/ba1/a3/18/a7b638e474a248a08bfecf1b151a",
"build/prefab/full/mac_x86_64/release/ballisticacore": "https://files.ballistica.net/cache/ba1/20/15/82b7b054396d70f3ef51d8bf525a",
"build/prefab/full/mac_x86_64_server/debug/dist/ballisticacore_headless": "https://files.ballistica.net/cache/ba1/f3/e1/4545a85cc86be1b5049a8ac51102",
"build/prefab/full/mac_x86_64_server/release/dist/ballisticacore_headless": "https://files.ballistica.net/cache/ba1/1f/ab/40bffe1f994caf1e0b19d45f2784",
"build/prefab/full/windows_x86/debug/BallisticaCore.exe": "https://files.ballistica.net/cache/ba1/cc/f8/0c1587462b04588fba9f2f9b7f76",
"build/prefab/full/windows_x86/release/BallisticaCore.exe": "https://files.ballistica.net/cache/ba1/9b/9f/60617e5848ffae2742db7d1a288e",
"build/prefab/full/windows_x86_server/debug/dist/ballisticacore_headless.exe": "https://files.ballistica.net/cache/ba1/a7/c0/b6e232e2192f2ea9e5b9b57e67c1",
"build/prefab/full/windows_x86_server/release/dist/ballisticacore_headless.exe": "https://files.ballistica.net/cache/ba1/0d/f0/5ef106a9d14b267b91f6e1c4bc2d",
"build/prefab/lib/linux_x86_64/debug/libballisticacore_internal.a": "https://files.ballistica.net/cache/ba1/c3/d7/627d518a92951cf7fe9fc0b9b3a0",
"build/prefab/lib/linux_x86_64/release/libballisticacore_internal.a": "https://files.ballistica.net/cache/ba1/de/49/2cfc34ac856737d903954db5571b",
"build/prefab/lib/linux_x86_64_server/debug/libballisticacore_internal.a": "https://files.ballistica.net/cache/ba1/e8/9a/67cf9ece361ca2f5d338009bdbfc",
"build/prefab/lib/linux_x86_64_server/release/libballisticacore_internal.a": "https://files.ballistica.net/cache/ba1/86/de/7d9c9a2b7bba34c630130ed759c9",
"build/prefab/lib/mac_x86_64/debug/libballisticacore_internal.a": "https://files.ballistica.net/cache/ba1/e9/a4/5810e89715c82ca695bc274fd10a",
"build/prefab/lib/mac_x86_64/release/libballisticacore_internal.a": "https://files.ballistica.net/cache/ba1/b2/4b/335f5a189ae793aff0f3da439804",
"build/prefab/lib/mac_x86_64_server/debug/libballisticacore_internal.a": "https://files.ballistica.net/cache/ba1/9a/87/5e76ab68086ea0c2a15b53da11c0",
"build/prefab/lib/mac_x86_64_server/release/libballisticacore_internal.a": "https://files.ballistica.net/cache/ba1/77/f2/35f10f6ad8349e3fe9817de342f0"
"build/prefab/lib/mac_x86_64/debug/libballisticacore_internal.a": "https://files.ballistica.net/cache/ba1/1b/cc/995e13831e0a99cfe04b45a58e4e",
"build/prefab/lib/mac_x86_64/release/libballisticacore_internal.a": "https://files.ballistica.net/cache/ba1/3e/67/c6d0cd2428d94243e0f8954d0f71",
"build/prefab/lib/mac_x86_64_server/debug/libballisticacore_internal.a": "https://files.ballistica.net/cache/ba1/b2/bc/fc4d9ccae2fe3199375481a9a3d6",
"build/prefab/lib/mac_x86_64_server/release/libballisticacore_internal.a": "https://files.ballistica.net/cache/ba1/9e/33/70f3dd7b087627cc69520cc31402"
}

View File

@ -1,3 +1,6 @@
### 1.5.28 (20239)
- Simplified ba.enum_by_value()
### 1.5.27 (20238)
- Language functionality has been consolidated into a LanguageSubsystem object at ba.app.lang
- ba.get_valid_languages() is now an attr: ba.app.lang.available_languages

View File

@ -418,16 +418,19 @@ def enum_by_value(cls: Type[ET], value: Any) -> ET:
that it works around an issue where a reference loop is created
if an exception is thrown due to an invalid value. Since we disable
the cyclic garbage collector for most of the time, such loops can lead
to our objects sticking around longer than we want. This workaround is
not perfect in that the destruction happens in the next cycle, but it is
better than never.
to our objects sticking around longer than we want.
This issue has been submitted to Python as a bug so hopefully we can
remove this eventually if it gets fixed: https://bugs.python.org/issue42248
"""
# Note: we don't recreate *ALL* the functionality of the Enum constructor
# such as the _missing_ hook; but this should cover our basic needs.
value2member_map = getattr(cls, '_value2member_map_')
assert value2member_map is not None
try:
return cls(value)
except Exception as exc:
# Blow away all stack frames in the exception which will break the
# cycle and allow it to be destroyed.
_ba.pushcall(_Call(_gut_exception, exc))
raise
out = value2member_map[value]
assert isinstance(out, cls)
return out
except KeyError:
raise ValueError('%r is not a valid %s' %
(value, cls.__name__)) from None

View File

@ -1,5 +1,5 @@
<!-- THIS FILE IS AUTO GENERATED; DO NOT EDIT BY HAND -->
<h4><em>last updated on 2020-11-06 for Ballistica version 1.5.27 build 20238</em></h4>
<h4><em>last updated on 2020-11-06 for Ballistica version 1.5.28 build 20239</em></h4>
<p>This page documents the Python classes and functions in the 'ba' module,
which are the ones most relevant to modding in Ballistica. If you come across something you feel should be included here or could be better explained, please <a href="mailto:support@froemling.net">let me know</a>. Happy modding!</p>
<hr>
@ -6591,9 +6591,7 @@ settings, exiting element counts, or other factors.</p>
that it works around an issue where a reference loop is created
if an exception is thrown due to an invalid value. Since we disable
the cyclic garbage collector for most of the time, such loops can lead
to our objects sticking around longer than we want. This workaround is
not perfect in that the destruction happens in the next cycle, but it is
better than never.
to our objects sticking around longer than we want.
This issue has been submitted to Python as a bug so hopefully we can
remove this eventually if it gets fixed: https://bugs.python.org/issue42248</p>

View File

@ -21,8 +21,8 @@
namespace ballistica {
// These are set automatically via script; don't change here.
const int kAppBuildNumber = 20239;
const char* kAppVersion = "1.5.27";
const int kAppBuildNumber = 20240;
const char* kAppVersion = "1.5.28";
// Our standalone globals.
// These are separated out for easy access.