winrt-runtime 4.0.0__tar.gz → 4.0.1__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (138) hide show
  1. {winrt_runtime-4.0.0/python/winrt_runtime.egg-info → winrt_runtime-4.0.1}/PKG-INFO +1 -1
  2. {winrt_runtime-4.0.0 → winrt_runtime-4.0.1/python/winrt_runtime.egg-info}/PKG-INFO +1 -1
  3. {winrt_runtime-4.0.0 → winrt_runtime-4.0.1}/src/structs.cpp +28 -12
  4. {winrt_runtime-4.0.0 → winrt_runtime-4.0.1}/src/table.cpp +40 -7
  5. {winrt_runtime-4.0.0 → winrt_runtime-4.0.1}/src/table.h +18 -2
  6. winrt_runtime-4.0.1/version.txt +1 -0
  7. winrt_runtime-4.0.0/version.txt +0 -1
  8. {winrt_runtime-4.0.0 → winrt_runtime-4.0.1}/LICENSE +0 -0
  9. {winrt_runtime-4.0.0 → winrt_runtime-4.0.1}/MANIFEST.in +0 -0
  10. {winrt_runtime-4.0.0 → winrt_runtime-4.0.1}/README.md +0 -0
  11. {winrt_runtime-4.0.0 → winrt_runtime-4.0.1}/pyproject.toml +0 -0
  12. {winrt_runtime-4.0.0 → winrt_runtime-4.0.1}/python/winrt/__pyinstaller/__init__.py +0 -0
  13. {winrt_runtime-4.0.0 → winrt_runtime-4.0.1}/python/winrt/__pyinstaller/hook-winrt.py +0 -0
  14. {winrt_runtime-4.0.0 → winrt_runtime-4.0.1}/python/winrt/_winrt.pyi +0 -0
  15. {winrt_runtime-4.0.0 → winrt_runtime-4.0.1}/python/winrt/py.typed +0 -0
  16. {winrt_runtime-4.0.0 → winrt_runtime-4.0.1}/python/winrt/runtime/__init__.py +0 -0
  17. {winrt_runtime-4.0.0 → winrt_runtime-4.0.1}/python/winrt/runtime/_internals.py +0 -0
  18. {winrt_runtime-4.0.0 → winrt_runtime-4.0.1}/python/winrt/runtime/interop.py +0 -0
  19. {winrt_runtime-4.0.0 → winrt_runtime-4.0.1}/python/winrt/runtime/py.typed +0 -0
  20. {winrt_runtime-4.0.0 → winrt_runtime-4.0.1}/python/winrt/system/__init__.py +0 -0
  21. {winrt_runtime-4.0.0 → winrt_runtime-4.0.1}/python/winrt/system/hresult.py +0 -0
  22. {winrt_runtime-4.0.0 → winrt_runtime-4.0.1}/python/winrt/system/py.typed +0 -0
  23. {winrt_runtime-4.0.0 → winrt_runtime-4.0.1}/python/winrt_runtime.egg-info/SOURCES.txt +0 -0
  24. {winrt_runtime-4.0.0 → winrt_runtime-4.0.1}/python/winrt_runtime.egg-info/dependency_links.txt +0 -0
  25. {winrt_runtime-4.0.0 → winrt_runtime-4.0.1}/python/winrt_runtime.egg-info/entry_points.txt +0 -0
  26. {winrt_runtime-4.0.0 → winrt_runtime-4.0.1}/python/winrt_runtime.egg-info/requires.txt +0 -0
  27. {winrt_runtime-4.0.0 → winrt_runtime-4.0.1}/python/winrt_runtime.egg-info/top_level.txt +0 -0
  28. {winrt_runtime-4.0.0 → winrt_runtime-4.0.1}/requirements.txt +0 -0
  29. {winrt_runtime-4.0.0 → winrt_runtime-4.0.1}/setup.cfg +0 -0
  30. {winrt_runtime-4.0.0 → winrt_runtime-4.0.1}/setup.py +0 -0
  31. {winrt_runtime-4.0.0 → winrt_runtime-4.0.1}/src/_winrt.cpp +0 -0
  32. {winrt_runtime-4.0.0 → winrt_runtime-4.0.1}/src/_winrt_array.cpp +0 -0
  33. {winrt_runtime-4.0.0 → winrt_runtime-4.0.1}/src/_winrt_array.h +0 -0
  34. {winrt_runtime-4.0.0 → winrt_runtime-4.0.1}/src/_winrt_box.cpp +0 -0
  35. {winrt_runtime-4.0.0 → winrt_runtime-4.0.1}/src/_winrt_buffer.cpp +0 -0
  36. {winrt_runtime-4.0.0 → winrt_runtime-4.0.1}/src/_winrt_buffer.h +0 -0
  37. {winrt_runtime-4.0.0 → winrt_runtime-4.0.1}/src/arrays.cpp +0 -0
  38. {winrt_runtime-4.0.0 → winrt_runtime-4.0.1}/src/arrays.h +0 -0
  39. {winrt_runtime-4.0.0 → winrt_runtime-4.0.1}/src/async.cpp +0 -0
  40. {winrt_runtime-4.0.0 → winrt_runtime-4.0.1}/src/async.h +0 -0
  41. {winrt_runtime-4.0.0 → winrt_runtime-4.0.1}/src/callbacks.cpp +0 -0
  42. {winrt_runtime-4.0.0 → winrt_runtime-4.0.1}/src/callbacks.h +0 -0
  43. {winrt_runtime-4.0.0 → winrt_runtime-4.0.1}/src/collections.cpp +0 -0
  44. {winrt_runtime-4.0.0 → winrt_runtime-4.0.1}/src/collections.h +0 -0
  45. {winrt_runtime-4.0.0 → winrt_runtime-4.0.1}/src/compose.cpp +0 -0
  46. {winrt_runtime-4.0.0 → winrt_runtime-4.0.1}/src/compose.h +0 -0
  47. {winrt_runtime-4.0.0 → winrt_runtime-4.0.1}/src/delegates.cpp +0 -0
  48. {winrt_runtime-4.0.0 → winrt_runtime-4.0.1}/src/delegates.h +0 -0
  49. {winrt_runtime-4.0.0 → winrt_runtime-4.0.1}/src/enums.cpp +0 -0
  50. {winrt_runtime-4.0.0 → winrt_runtime-4.0.1}/src/enums.h +0 -0
  51. {winrt_runtime-4.0.0 → winrt_runtime-4.0.1}/src/errors.cpp +0 -0
  52. {winrt_runtime-4.0.0 → winrt_runtime-4.0.1}/src/generics.cpp +0 -0
  53. {winrt_runtime-4.0.0 → winrt_runtime-4.0.1}/src/generics.h +0 -0
  54. {winrt_runtime-4.0.0 → winrt_runtime-4.0.1}/src/implements.cpp +0 -0
  55. {winrt_runtime-4.0.0 → winrt_runtime-4.0.1}/src/implements.h +0 -0
  56. {winrt_runtime-4.0.0 → winrt_runtime-4.0.1}/src/include/cppwinrt/winrt/Windows.Foundation.Collections.h +0 -0
  57. {winrt_runtime-4.0.0 → winrt_runtime-4.0.1}/src/include/cppwinrt/winrt/Windows.Foundation.Metadata.h +0 -0
  58. {winrt_runtime-4.0.0 → winrt_runtime-4.0.1}/src/include/cppwinrt/winrt/Windows.Foundation.h +0 -0
  59. {winrt_runtime-4.0.0 → winrt_runtime-4.0.1}/src/include/cppwinrt/winrt/Windows.Storage.Streams.h +0 -0
  60. {winrt_runtime-4.0.0 → winrt_runtime-4.0.1}/src/include/cppwinrt/winrt/Windows.Storage.h +0 -0
  61. {winrt_runtime-4.0.0 → winrt_runtime-4.0.1}/src/include/cppwinrt/winrt/base.h +0 -0
  62. {winrt_runtime-4.0.0 → winrt_runtime-4.0.1}/src/include/cppwinrt/winrt/base_macros.h +0 -0
  63. {winrt_runtime-4.0.0 → winrt_runtime-4.0.1}/src/include/cppwinrt/winrt/impl/Windows.Devices.Geolocation.0.h +0 -0
  64. {winrt_runtime-4.0.0 → winrt_runtime-4.0.1}/src/include/cppwinrt/winrt/impl/Windows.Devices.Geolocation.1.h +0 -0
  65. {winrt_runtime-4.0.0 → winrt_runtime-4.0.1}/src/include/cppwinrt/winrt/impl/Windows.Foundation.0.h +0 -0
  66. {winrt_runtime-4.0.0 → winrt_runtime-4.0.1}/src/include/cppwinrt/winrt/impl/Windows.Foundation.1.h +0 -0
  67. {winrt_runtime-4.0.0 → winrt_runtime-4.0.1}/src/include/cppwinrt/winrt/impl/Windows.Foundation.2.h +0 -0
  68. {winrt_runtime-4.0.0 → winrt_runtime-4.0.1}/src/include/cppwinrt/winrt/impl/Windows.Foundation.Collections.0.h +0 -0
  69. {winrt_runtime-4.0.0 → winrt_runtime-4.0.1}/src/include/cppwinrt/winrt/impl/Windows.Foundation.Collections.1.h +0 -0
  70. {winrt_runtime-4.0.0 → winrt_runtime-4.0.1}/src/include/cppwinrt/winrt/impl/Windows.Foundation.Collections.2.h +0 -0
  71. {winrt_runtime-4.0.0 → winrt_runtime-4.0.1}/src/include/cppwinrt/winrt/impl/Windows.Foundation.Metadata.0.h +0 -0
  72. {winrt_runtime-4.0.0 → winrt_runtime-4.0.1}/src/include/cppwinrt/winrt/impl/Windows.Foundation.Metadata.1.h +0 -0
  73. {winrt_runtime-4.0.0 → winrt_runtime-4.0.1}/src/include/cppwinrt/winrt/impl/Windows.Foundation.Metadata.2.h +0 -0
  74. {winrt_runtime-4.0.0 → winrt_runtime-4.0.1}/src/include/cppwinrt/winrt/impl/Windows.Storage.0.h +0 -0
  75. {winrt_runtime-4.0.0 → winrt_runtime-4.0.1}/src/include/cppwinrt/winrt/impl/Windows.Storage.1.h +0 -0
  76. {winrt_runtime-4.0.0 → winrt_runtime-4.0.1}/src/include/cppwinrt/winrt/impl/Windows.Storage.2.h +0 -0
  77. {winrt_runtime-4.0.0 → winrt_runtime-4.0.1}/src/include/cppwinrt/winrt/impl/Windows.Storage.FileProperties.0.h +0 -0
  78. {winrt_runtime-4.0.0 → winrt_runtime-4.0.1}/src/include/cppwinrt/winrt/impl/Windows.Storage.FileProperties.1.h +0 -0
  79. {winrt_runtime-4.0.0 → winrt_runtime-4.0.1}/src/include/cppwinrt/winrt/impl/Windows.Storage.FileProperties.2.h +0 -0
  80. {winrt_runtime-4.0.0 → winrt_runtime-4.0.1}/src/include/cppwinrt/winrt/impl/Windows.Storage.Provider.0.h +0 -0
  81. {winrt_runtime-4.0.0 → winrt_runtime-4.0.1}/src/include/cppwinrt/winrt/impl/Windows.Storage.Provider.1.h +0 -0
  82. {winrt_runtime-4.0.0 → winrt_runtime-4.0.1}/src/include/cppwinrt/winrt/impl/Windows.Storage.Provider.2.h +0 -0
  83. {winrt_runtime-4.0.0 → winrt_runtime-4.0.1}/src/include/cppwinrt/winrt/impl/Windows.Storage.Search.0.h +0 -0
  84. {winrt_runtime-4.0.0 → winrt_runtime-4.0.1}/src/include/cppwinrt/winrt/impl/Windows.Storage.Search.1.h +0 -0
  85. {winrt_runtime-4.0.0 → winrt_runtime-4.0.1}/src/include/cppwinrt/winrt/impl/Windows.Storage.Search.2.h +0 -0
  86. {winrt_runtime-4.0.0 → winrt_runtime-4.0.1}/src/include/cppwinrt/winrt/impl/Windows.Storage.Streams.0.h +0 -0
  87. {winrt_runtime-4.0.0 → winrt_runtime-4.0.1}/src/include/cppwinrt/winrt/impl/Windows.Storage.Streams.1.h +0 -0
  88. {winrt_runtime-4.0.0 → winrt_runtime-4.0.1}/src/include/cppwinrt/winrt/impl/Windows.Storage.Streams.2.h +0 -0
  89. {winrt_runtime-4.0.0 → winrt_runtime-4.0.1}/src/include/cppwinrt/winrt/impl/Windows.System.0.h +0 -0
  90. {winrt_runtime-4.0.0 → winrt_runtime-4.0.1}/src/include/cppwinrt/winrt/impl/Windows.System.1.h +0 -0
  91. {winrt_runtime-4.0.0 → winrt_runtime-4.0.1}/src/include/cppwinrt/winrt/impl/Windows.System.2.h +0 -0
  92. {winrt_runtime-4.0.0 → winrt_runtime-4.0.1}/src/include/cppwinrt/winrt/impl/Windows.System.RemoteSystems.0.h +0 -0
  93. {winrt_runtime-4.0.0 → winrt_runtime-4.0.1}/src/include/cppwinrt/winrt/impl/Windows.System.RemoteSystems.1.h +0 -0
  94. {winrt_runtime-4.0.0 → winrt_runtime-4.0.1}/src/include/pythoncapi_compat.h +0 -0
  95. {winrt_runtime-4.0.0 → winrt_runtime-4.0.1}/src/include/pywinrt/abi.h +0 -0
  96. {winrt_runtime-4.0.0 → winrt_runtime-4.0.1}/src/include/pywinrt/array.h +0 -0
  97. {winrt_runtime-4.0.0 → winrt_runtime-4.0.1}/src/include/pywinrt/async.h +0 -0
  98. {winrt_runtime-4.0.0 → winrt_runtime-4.0.1}/src/include/pywinrt/base.h +0 -0
  99. {winrt_runtime-4.0.0 → winrt_runtime-4.0.1}/src/include/pywinrt/buffer.h +0 -0
  100. {winrt_runtime-4.0.0 → winrt_runtime-4.0.1}/src/include/pywinrt/convert.h +0 -0
  101. {winrt_runtime-4.0.0 → winrt_runtime-4.0.1}/src/include/pywinrt/errors.h +0 -0
  102. {winrt_runtime-4.0.0 → winrt_runtime-4.0.1}/src/include/pywinrt/handles.h +0 -0
  103. {winrt_runtime-4.0.0 → winrt_runtime-4.0.1}/src/include/pywinrt/prelude.h +0 -0
  104. {winrt_runtime-4.0.0 → winrt_runtime-4.0.1}/src/include/pywinrt/throw_helpers.h +0 -0
  105. {winrt_runtime-4.0.0 → winrt_runtime-4.0.1}/src/include/pywinrt/traits.h +0 -0
  106. {winrt_runtime-4.0.0 → winrt_runtime-4.0.1}/src/include/pywinrt/wrappers.h +0 -0
  107. {winrt_runtime-4.0.0 → winrt_runtime-4.0.1}/src/interp.cpp +0 -0
  108. {winrt_runtime-4.0.0 → winrt_runtime-4.0.1}/src/interp.h +0 -0
  109. {winrt_runtime-4.0.0 → winrt_runtime-4.0.1}/src/members.cpp +0 -0
  110. {winrt_runtime-4.0.0 → winrt_runtime-4.0.1}/src/members.h +0 -0
  111. {winrt_runtime-4.0.0 → winrt_runtime-4.0.1}/src/metaclass.h +0 -0
  112. {winrt_runtime-4.0.0 → winrt_runtime-4.0.1}/src/module_state.h +0 -0
  113. {winrt_runtime-4.0.0 → winrt_runtime-4.0.1}/src/numerics-buffer.cpp +0 -0
  114. {winrt_runtime-4.0.0 → winrt_runtime-4.0.1}/src/numerics-buffer.h +0 -0
  115. {winrt_runtime-4.0.0 → winrt_runtime-4.0.1}/src/numerics-statics.cpp +0 -0
  116. {winrt_runtime-4.0.0 → winrt_runtime-4.0.1}/src/numerics-statics.h +0 -0
  117. {winrt_runtime-4.0.0 → winrt_runtime-4.0.1}/src/numerics-traits.h +0 -0
  118. {winrt_runtime-4.0.0 → winrt_runtime-4.0.1}/src/numerics-values.h +0 -0
  119. {winrt_runtime-4.0.0 → winrt_runtime-4.0.1}/src/numerics.cpp +0 -0
  120. {winrt_runtime-4.0.0 → winrt_runtime-4.0.1}/src/numerics.h +0 -0
  121. {winrt_runtime-4.0.0 → winrt_runtime-4.0.1}/src/objects.cpp +0 -0
  122. {winrt_runtime-4.0.0 → winrt_runtime-4.0.1}/src/objects.h +0 -0
  123. {winrt_runtime-4.0.0 → winrt_runtime-4.0.1}/src/protocols.cpp +0 -0
  124. {winrt_runtime-4.0.0 → winrt_runtime-4.0.1}/src/protocols.h +0 -0
  125. {winrt_runtime-4.0.0 → winrt_runtime-4.0.1}/src/pycollections.cpp +0 -0
  126. {winrt_runtime-4.0.0 → winrt_runtime-4.0.1}/src/pycollections.h +0 -0
  127. {winrt_runtime-4.0.0 → winrt_runtime-4.0.1}/src/pymapping.cpp +0 -0
  128. {winrt_runtime-4.0.0 → winrt_runtime-4.0.1}/src/pymapping.h +0 -0
  129. {winrt_runtime-4.0.0 → winrt_runtime-4.0.1}/src/pysequence.cpp +0 -0
  130. {winrt_runtime-4.0.0 → winrt_runtime-4.0.1}/src/pysequence.h +0 -0
  131. {winrt_runtime-4.0.0 → winrt_runtime-4.0.1}/src/runtime.cpp +0 -0
  132. {winrt_runtime-4.0.0 → winrt_runtime-4.0.1}/src/runtime.h +0 -0
  133. {winrt_runtime-4.0.0 → winrt_runtime-4.0.1}/src/shapes-generated.h +0 -0
  134. {winrt_runtime-4.0.0 → winrt_runtime-4.0.1}/src/shapes.cpp +0 -0
  135. {winrt_runtime-4.0.0 → winrt_runtime-4.0.1}/src/shapes.h +0 -0
  136. {winrt_runtime-4.0.0 → winrt_runtime-4.0.1}/src/structs.h +0 -0
  137. {winrt_runtime-4.0.0 → winrt_runtime-4.0.1}/src/types.cpp +0 -0
  138. {winrt_runtime-4.0.0 → winrt_runtime-4.0.1}/src/types.h +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: winrt-runtime
3
- Version: 4.0.0
3
+ Version: 4.0.1
4
4
  Summary: The runtime that every PyWinRT projection package runs on
5
5
  License-Expression: MIT
6
6
  Project-URL: Documentation, https://pywinrt.readthedocs.io
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: winrt-runtime
3
- Version: 4.0.0
3
+ Version: 4.0.1
4
4
  Summary: The runtime that every PyWinRT projection package runs on
5
5
  License-Expression: MIT
6
6
  Project-URL: Documentation, https://pywinrt.readthedocs.io
@@ -995,7 +995,34 @@ namespace py::interp
995
995
  bool make_struct_type(
996
996
  projection& proj, type_entry& entry, table::type_view const& record)
997
997
  {
998
- auto const layout = proj.table->get_struct_layout(record);
998
+ entry.fields.resize(record.field_count());
999
+
1000
+ // A struct in a struct is resolved into the field before anything is
1001
+ // laid out. Releasing one has to know what it holds and is not a place
1002
+ // that can import a package, and the table cannot measure a struct of
1003
+ // another namespace: it holds only an external record naming it, with
1004
+ // no fields, so the size has to come from the entry that defines it.
1005
+ for (uint32_t i = 0; i < record.field_count(); i++)
1006
+ {
1007
+ auto& field = entry.fields[i];
1008
+
1009
+ field.code = record.field(i).code();
1010
+ field.type = record.field(i).type();
1011
+
1012
+ if (field.code == table::type_code::struct_
1013
+ && !resolve(proj, field.type, field.info))
1014
+ {
1015
+ return false;
1016
+ }
1017
+ }
1018
+
1019
+ auto const layout = proj.table->get_struct_layout(
1020
+ record,
1021
+ [&entry](uint32_t position)
1022
+ {
1023
+ auto const& info = *entry.fields[position].info;
1024
+ return table::value_layout{info.size, info.align};
1025
+ });
999
1026
 
1000
1027
  entry.numerics_kind = numerics::classify(entry.winrt_name);
1001
1028
 
@@ -1012,7 +1039,6 @@ namespace py::interp
1012
1039
  entry.align = layout.align;
1013
1040
  entry.blob_offset
1014
1041
  = align_up(static_cast<uint32_t>(sizeof(PyObject)), layout.align);
1015
- entry.fields.resize(record.field_count());
1016
1042
 
1017
1043
  std::vector<PyGetSetDef> getsets;
1018
1044
 
@@ -1021,9 +1047,7 @@ namespace py::interp
1021
1047
  auto const record_field = record.field(i);
1022
1048
  auto& field = entry.fields[i];
1023
1049
 
1024
- field.code = record_field.code();
1025
1050
  field.offset = layout.offsets[i];
1026
- field.type = record_field.type();
1027
1051
  field.declaring = &entry;
1028
1052
 
1029
1053
  pyobj_handle interned{
@@ -1048,14 +1072,6 @@ namespace py::interp
1048
1072
  entry.owns_resources = true;
1049
1073
  break;
1050
1074
  case table::type_code::struct_:
1051
- // A struct in a struct is resolved into the field now rather
1052
- // than on first use, because releasing one has to know what
1053
- // it holds and is not a place that can import a package.
1054
- if (!resolve(proj, field.type, field.info))
1055
- {
1056
- return false;
1057
- }
1058
-
1059
1075
  if (field.info->owns_resources)
1060
1076
  {
1061
1077
  entry.owns_resources = true;
@@ -359,9 +359,10 @@ namespace py::table
359
359
  return type_view{this, index};
360
360
  }
361
361
 
362
- struct_layout file::get_struct_layout(type_view type) const
362
+ struct_layout file::get_struct_layout(
363
+ type_view type, struct_field_measure const& measure_struct) const
363
364
  {
364
- struct_layout result{0, 1, {}};
365
+ struct_layout result{0, 1, {}, true};
365
366
  uint32_t offset = 0;
366
367
  auto const count = type.field_count();
367
368
 
@@ -372,9 +373,29 @@ namespace py::table
372
373
  auto const field = type.field(i);
373
374
  value_layout layout;
374
375
 
375
- if (field.code() == type_code::struct_)
376
+ if (field.code() == type_code::struct_ && measure_struct)
376
377
  {
377
- auto const nested = get_struct_layout(this->type(field.type()));
378
+ layout = measure_struct(i);
379
+ }
380
+ else if (field.code() == type_code::struct_)
381
+ {
382
+ auto const record = this->type(field.type());
383
+
384
+ // An external record is a name and nothing else, so measuring
385
+ // it here would find no fields and call the struct empty.
386
+ if (record.is_external())
387
+ {
388
+ result.measured = false;
389
+ return result;
390
+ }
391
+
392
+ auto const nested = get_struct_layout(record);
393
+ if (!nested.measured)
394
+ {
395
+ result.measured = false;
396
+ return result;
397
+ }
398
+
378
399
  layout = {nested.size, nested.align};
379
400
  }
380
401
  else
@@ -1097,10 +1118,14 @@ namespace py::cpp::_winrt
1097
1118
  return pyobj_handle{};
1098
1119
  }
1099
1120
 
1121
+ // A field at or after one this table cannot measure has no
1122
+ // offset that the table alone can say.
1100
1123
  if (!set_item(
1101
1124
  item.get(),
1102
1125
  "offset",
1103
- PyLong_FromUnsignedLong(layout.offsets[i])))
1126
+ i < layout.offsets.size()
1127
+ ? PyLong_FromUnsignedLong(layout.offsets[i])
1128
+ : Py_NewRef(Py_None)))
1104
1129
  {
1105
1130
  return pyobj_handle{};
1106
1131
  }
@@ -1290,12 +1315,20 @@ namespace py::cpp::_winrt
1290
1315
  return pyobj_handle{};
1291
1316
  }
1292
1317
 
1293
- if (!set_item(result.get(), "size", PyLong_FromUnsignedLong(layout.size)))
1318
+ if (!set_item(
1319
+ result.get(),
1320
+ "size",
1321
+ layout.measured ? PyLong_FromUnsignedLong(layout.size)
1322
+ : Py_NewRef(Py_None)))
1294
1323
  {
1295
1324
  return pyobj_handle{};
1296
1325
  }
1297
1326
 
1298
- if (!set_item(result.get(), "align", PyLong_FromUnsignedLong(layout.align)))
1327
+ if (!set_item(
1328
+ result.get(),
1329
+ "align",
1330
+ layout.measured ? PyLong_FromUnsignedLong(layout.align)
1331
+ : Py_NewRef(Py_None)))
1299
1332
  {
1300
1333
  return pyobj_handle{};
1301
1334
  }
@@ -15,6 +15,7 @@
15
15
 
16
16
  #include <cstddef>
17
17
  #include <cstdint>
18
+ #include <functional>
18
19
  #include <stdexcept>
19
20
  #include <string>
20
21
  #include <string_view>
@@ -441,14 +442,26 @@ namespace py::table
441
442
  * Offsets are never written into the table, because a pointer is not the
442
443
  * same width on every architecture the same table serves, so they are
443
444
  * computed here from the field type codes.
445
+ *
446
+ * A struct field whose struct belongs to another namespace cannot be
447
+ * measured from this table, which holds only an external record naming
448
+ * it. Without a measure for it the layout stops there: @c measured is
449
+ * false, and @c offsets has an entry only for the fields before it.
444
450
  */
445
451
  struct struct_layout
446
452
  {
447
453
  uint32_t size;
448
454
  uint32_t align;
449
455
  std::vector<uint32_t> offsets;
456
+ bool measured;
450
457
  };
451
458
 
459
+ /**
460
+ * The size and alignment of the struct field at @p position of the struct
461
+ * being laid out, from what knows the field's type better than the table.
462
+ */
463
+ using struct_field_measure = std::function<value_layout(uint32_t position)>;
464
+
452
465
  /**
453
466
  * One namespace's table, over bytes it does not own.
454
467
  */
@@ -541,8 +554,11 @@ namespace py::table
541
554
  return guid_count_;
542
555
  }
543
556
 
544
- /// Computes the layout of the struct @p type declares.
545
- struct_layout get_struct_layout(type_view type) const;
557
+ /// Computes the layout of the struct @p type declares, measuring each
558
+ /// struct field with @p measure_struct if one is given and from this
559
+ /// table otherwise.
560
+ struct_layout get_struct_layout(
561
+ type_view type, struct_field_measure const& measure_struct = {}) const;
546
562
 
547
563
  // The accessors below are what the views are made of. They are public
548
564
  // because the views are separate classes, not because anything outside
@@ -0,0 +1 @@
1
+ 4.0.1
@@ -1 +0,0 @@
1
- 4.0.0
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes