2
0

ObjectStream.cpp 1.3 KB

12345678910111213141516171819202122232425262728293031323334
  1. // Jolt Physics Library (https://github.com/jrouwe/JoltPhysics)
  2. // SPDX-FileCopyrightText: 2021 Jorrit Rouwe
  3. // SPDX-License-Identifier: MIT
  4. #include <Jolt/Jolt.h>
  5. #include <Jolt/ObjectStream/ObjectStream.h>
  6. JPH_NAMESPACE_BEGIN
  7. // Define macro to declare functions for a specific primitive type
  8. #define JPH_DECLARE_PRIMITIVE(name) \
  9. bool OSIsType(name *, int inArrayDepth, EOSDataType inDataType, const char *inClassName) \
  10. { \
  11. return inArrayDepth == 0 && inDataType == EOSDataType::T_##name; \
  12. } \
  13. bool OSReadData(IObjectStreamIn &ioStream, name &outPrimitive) \
  14. { \
  15. return ioStream.ReadPrimitiveData(outPrimitive); \
  16. } \
  17. void OSWriteDataType(IObjectStreamOut &ioStream, name *) \
  18. { \
  19. ioStream.WriteDataType(EOSDataType::T_##name); \
  20. } \
  21. void OSWriteData(IObjectStreamOut &ioStream, const name &inPrimitive) \
  22. { \
  23. ioStream.HintNextItem(); \
  24. ioStream.WritePrimitiveData(inPrimitive); \
  25. }
  26. // This file uses the JPH_DECLARE_PRIMITIVE macro to define all types
  27. #include <Jolt/ObjectStream/ObjectStreamTypes.h>
  28. JPH_NAMESPACE_END