diff --git a/.efrocachemap b/.efrocachemap index 873034ca..bee3b976 100644 --- a/.efrocachemap +++ b/.efrocachemap @@ -4060,26 +4060,26 @@ "build/assets/windows/Win32/ucrtbased.dll": "2def5335207d41b21b9823f6805997f1", "build/assets/windows/Win32/vc_redist.x86.exe": "b08a55e2e77623fe657bea24f223a3ae", "build/assets/windows/Win32/vcruntime140d.dll": "865b2af4d1e26a1a8073c89acb06e599", - "build/prefab/full/linux_arm64_gui/debug/ballisticakit": "d1d989de9e44829ce7adc6348cad34f1", - "build/prefab/full/linux_arm64_gui/release/ballisticakit": "d27e236d62e3db407c61902f0768b209", - "build/prefab/full/linux_arm64_server/debug/dist/ballisticakit_headless": "148a0c692fd30c3027158866a1c6c157", - "build/prefab/full/linux_arm64_server/release/dist/ballisticakit_headless": "0836f235c538b20dd2187071dc82a9c0", - "build/prefab/full/linux_x86_64_gui/debug/ballisticakit": "c928cdc074b9cb8f752ca049fb30fcf9", - "build/prefab/full/linux_x86_64_gui/release/ballisticakit": "b66bd051975628898fb66d291188824f", - "build/prefab/full/linux_x86_64_server/debug/dist/ballisticakit_headless": "7b3579d629ad99f032c4b2d821f7e348", - "build/prefab/full/linux_x86_64_server/release/dist/ballisticakit_headless": "08d11c347fed9b4d2b6f582c92321ed0", - "build/prefab/full/mac_arm64_gui/debug/ballisticakit": "f51e6dbccdeb8b64163029d58168d6d3", - "build/prefab/full/mac_arm64_gui/release/ballisticakit": "5c250868de853f0bcdbfd671e5863e0b", - "build/prefab/full/mac_arm64_server/debug/dist/ballisticakit_headless": "bc49209413eacf23bd6aa8cae47f7324", - "build/prefab/full/mac_arm64_server/release/dist/ballisticakit_headless": "40f7edd3b8e2d5cf2869cdaf12459fbe", - "build/prefab/full/mac_x86_64_gui/debug/ballisticakit": "9530446001824359b438d64054a4fa39", - "build/prefab/full/mac_x86_64_gui/release/ballisticakit": "5db3cac8a2cfdb5d56cb7579d32f17c6", - "build/prefab/full/mac_x86_64_server/debug/dist/ballisticakit_headless": "db8d6083d7bbdf78855c70affc3792df", - "build/prefab/full/mac_x86_64_server/release/dist/ballisticakit_headless": "c4d5c5387cc15f9c83dd41ce75e5cba5", - "build/prefab/full/windows_x86_gui/debug/BallisticaKit.exe": "2accd53f262abd82afcc9f9b73f26f2e", - "build/prefab/full/windows_x86_gui/release/BallisticaKit.exe": "3e2d7f9d4c7c350af1e21a8acbb3dec6", - "build/prefab/full/windows_x86_server/debug/dist/BallisticaKitHeadless.exe": "4d629a6f6029e191dd341e0a2a21d50b", - "build/prefab/full/windows_x86_server/release/dist/BallisticaKitHeadless.exe": "feeeb28a230759fb5283474f82fc2451", + "build/prefab/full/linux_arm64_gui/debug/ballisticakit": "4061f6114403c60ce1553d2b95c6fd7f", + "build/prefab/full/linux_arm64_gui/release/ballisticakit": "c73d4beea86082419fa0dee9cf8e93be", + "build/prefab/full/linux_arm64_server/debug/dist/ballisticakit_headless": "928c17c937e26d2fdc9edc8bc1e07659", + "build/prefab/full/linux_arm64_server/release/dist/ballisticakit_headless": "07a90a9ee49ccfcf4cb0fcbccd0e1a04", + "build/prefab/full/linux_x86_64_gui/debug/ballisticakit": "aa4929306878a5e757be36bbd80cb3b3", + "build/prefab/full/linux_x86_64_gui/release/ballisticakit": "6579bfe457770767a35ce69513433273", + "build/prefab/full/linux_x86_64_server/debug/dist/ballisticakit_headless": "0eb96f2dfd3798621dd35d3693e596f7", + "build/prefab/full/linux_x86_64_server/release/dist/ballisticakit_headless": "21ff8796c4e459d4087a68d02b998576", + "build/prefab/full/mac_arm64_gui/debug/ballisticakit": "a69ade336e8d9574919debda154ca2ec", + "build/prefab/full/mac_arm64_gui/release/ballisticakit": "ce625368b6392bc3d9c6f033b1255c6f", + "build/prefab/full/mac_arm64_server/debug/dist/ballisticakit_headless": "0b606c6c6f4774dc9cfebfab347d6271", + "build/prefab/full/mac_arm64_server/release/dist/ballisticakit_headless": "56878ae9435c3b99a62319e016418dff", + "build/prefab/full/mac_x86_64_gui/debug/ballisticakit": "461c5e567f8bf9726a1b7f5ced7e7418", + "build/prefab/full/mac_x86_64_gui/release/ballisticakit": "c6a85daf172fee978c7deafb3b50fc21", + "build/prefab/full/mac_x86_64_server/debug/dist/ballisticakit_headless": "42121063ca6dc6a446a331b2ea4dc707", + "build/prefab/full/mac_x86_64_server/release/dist/ballisticakit_headless": "94a0a0bec30f85b0397fb1925ef54e33", + "build/prefab/full/windows_x86_gui/debug/BallisticaKit.exe": "f9f983439f6b2a5cc92e2c8c575b66bb", + "build/prefab/full/windows_x86_gui/release/BallisticaKit.exe": "ec5f0294584602e88e071eb336b671fd", + "build/prefab/full/windows_x86_server/debug/dist/BallisticaKitHeadless.exe": "6c49a9829024ff91e2d07dbaf2c75184", + "build/prefab/full/windows_x86_server/release/dist/BallisticaKitHeadless.exe": "f82d8ed05ca2fa9a3bef869e3ce6ac4b", "build/prefab/lib/linux_arm64_gui/debug/libballisticaplus.a": "8709ad96140d71760c2f493ee8bd7c43", "build/prefab/lib/linux_arm64_gui/release/libballisticaplus.a": "ee829cd5488e9750570dc6f602d65589", "build/prefab/lib/linux_arm64_server/debug/libballisticaplus.a": "8709ad96140d71760c2f493ee8bd7c43", diff --git a/CHANGELOG.md b/CHANGELOG.md index 7be40ad5..151e25aa 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,4 @@ -### 1.7.33 (build 21763, api 8, 2024-01-31) +### 1.7.33 (build 21764, api 8, 2024-01-31) - Stress test input-devices are now a bit smarter; they won't press any buttons while UIs are up (this could cause lots of chaos if it happened). - Added a 'Show Demos When Idle' option in advanced settings. If enabled, the diff --git a/src/assets/ba_data/python/baenv.py b/src/assets/ba_data/python/baenv.py index 8a4b85c3..b61f151a 100644 --- a/src/assets/ba_data/python/baenv.py +++ b/src/assets/ba_data/python/baenv.py @@ -52,7 +52,7 @@ if TYPE_CHECKING: # Build number and version of the ballistica binary we expect to be # using. -TARGET_BALLISTICA_BUILD = 21763 +TARGET_BALLISTICA_BUILD = 21764 TARGET_BALLISTICA_VERSION = '1.7.33' diff --git a/src/ballistica/shared/ballistica.cc b/src/ballistica/shared/ballistica.cc index f88717ed..b1201f9b 100644 --- a/src/ballistica/shared/ballistica.cc +++ b/src/ballistica/shared/ballistica.cc @@ -39,7 +39,7 @@ auto main(int argc, char** argv) -> int { namespace ballistica { // These are set automatically via script; don't modify them here. -const int kEngineBuildNumber = 21763; +const int kEngineBuildNumber = 21764; const char* kEngineVersion = "1.7.33"; const int kEngineApiVersion = 8; diff --git a/tests/test_efro/test_dataclassio.py b/tests/test_efro/test_dataclassio.py index 427ffff3..20e603cd 100644 --- a/tests/test_efro/test_dataclassio.py +++ b/tests/test_efro/test_dataclassio.py @@ -1093,7 +1093,8 @@ class MTTestBase(IOMultiType[MTTestTypeID]): that know about all of their child classes and how to serialize & deserialize them using explicit type ids. We can then use the parent class in annotations and dataclassio will do the right thing. - Useful for stuff like Message classes. + Useful for stuff like Message classes where we may want to store a + bunch of different types of them into one place. """ @override diff --git a/tools/efro/dataclassio/_base.py b/tools/efro/dataclassio/_base.py index abcb24a7..c1ba8841 100644 --- a/tools/efro/dataclassio/_base.py +++ b/tools/efro/dataclassio/_base.py @@ -61,42 +61,42 @@ class IOExtendedData: """ -KeyT = TypeVar('KeyT', bound=Enum) +EnumT = TypeVar('EnumT', bound=Enum) -class IOMultiType(Generic[KeyT]): +class IOMultiType(Generic[EnumT]): """A base class for types that can map to multiple dataclass types. - This allows construction of high level base classes (for example - a 'Message' type). These types can then be used as annotations in - dataclasses, and dataclassio will serialize/deserialize instances - based on their subtype plus simple embedded type-id values. + This enables usage of high level base classes (for example + a 'Message' type) in dataclasses, with dataclassio automatically + serializing/deserializing subclass instances using provided + per-class type-ids. See tests/test_efro/test_dataclassio.py for an example of this. """ - # Serialized data will store individual object ids to this key. If - # this value is ever problematic, it should be possible to override - # it in a subclass. + # Dataclasses inheriting from an IOMultiType will store a type-id + # with this key in their serialized data. This value can be + # overridden in IOMultiType subclasses in case of conflicts. ID_STORAGE_NAME = '_iotype' @classmethod - def get_key_type(cls) -> type[Enum]: - """Return the enum type we use as a key.""" - out: type[Enum] = cls.__orig_bases__[0].__args__[0] # type: ignore + def get_type(cls, type_id: EnumT) -> type[Self]: + """Return a specific subclass given a type-id.""" + raise NotImplementedError() + + @classmethod + def get_type_id(cls) -> EnumT: + """Return the type-id for this subclass.""" + raise NotImplementedError() + + @classmethod + def get_type_id_type(cls) -> type[EnumT]: + """Return the Enum type this class uses as its type-id.""" + out: type[EnumT] = cls.__orig_bases__[0].__args__[0] # type: ignore assert issubclass(out, Enum) return out - @classmethod - def get_type_id(cls) -> KeyT: - """Return the type id for this subclass.""" - raise NotImplementedError() - - @classmethod - def get_type(cls, type_id: KeyT) -> type[Self]: - """Return a specific subclass given an id.""" - raise NotImplementedError() - class IOAttrs: """For specifying io behavior in annotations. @@ -332,6 +332,6 @@ def _get_multitype_type( raise ValueError( f"Expected a '{storename}'" f" value for object at '{fieldpath}'." ) - id_enum_type = cls.get_key_type() + id_enum_type = cls.get_type_id_type() id_enum = id_enum_type(id_val) return cls.get_type(id_enum) diff --git a/tools/efro/dataclassio/_inputter.py b/tools/efro/dataclassio/_inputter.py index 4c41582f..d6627b25 100644 --- a/tools/efro/dataclassio/_inputter.py +++ b/tools/efro/dataclassio/_inputter.py @@ -73,7 +73,7 @@ class _Inputter: f'No type id value present for multi-type object:' f' {values}.' ) - type_id_enum = self._cls.get_key_type() + type_id_enum = self._cls.get_type_id_type() enum_val = type_id_enum(type_id_val) outcls = self._cls.get_type(enum_val) else: