pycapnp 2.0.0b2__tar.gz → 2.2.0__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 (103) hide show
  1. {pycapnp-2.0.0b2 → pycapnp-2.2.0}/CHANGELOG.md +22 -1
  2. {pycapnp-2.0.0b2 → pycapnp-2.2.0}/MANIFEST.in +1 -0
  3. {pycapnp-2.0.0b2/pycapnp.egg-info → pycapnp-2.2.0}/PKG-INFO +39 -7
  4. {pycapnp-2.0.0b2 → pycapnp-2.2.0}/README.md +1 -1
  5. pycapnp-2.2.0/_custom_build/backend.py +31 -0
  6. {pycapnp-2.0.0b2 → pycapnp-2.2.0}/capnp/__init__.py +2 -0
  7. {pycapnp-2.0.0b2 → pycapnp-2.2.0}/capnp/helpers/capabilityHelper.cpp +6 -6
  8. {pycapnp-2.0.0b2 → pycapnp-2.2.0}/capnp/helpers/helpers.pxd +3 -6
  9. {pycapnp-2.0.0b2 → pycapnp-2.2.0}/capnp/helpers/rpcHelper.h +4 -4
  10. pycapnp-2.2.0/capnp/includes/PyCustomMessageBuilder.cpp +50 -0
  11. {pycapnp-2.0.0b2 → pycapnp-2.2.0}/capnp/includes/capnp_cpp.pxd +4 -18
  12. {pycapnp-2.0.0b2 → pycapnp-2.2.0}/capnp/includes/schema_cpp.pxd +11 -6
  13. {pycapnp-2.0.0b2 → pycapnp-2.2.0}/capnp/lib/capnp.cpp +79833 -47582
  14. {pycapnp-2.0.0b2 → pycapnp-2.2.0}/capnp/lib/capnp.pxd +14 -14
  15. {pycapnp-2.0.0b2 → pycapnp-2.2.0}/capnp/lib/capnp.pyx +307 -115
  16. {pycapnp-2.0.0b2 → pycapnp-2.2.0}/capnp/lib/capnp_api.h +27 -42
  17. {pycapnp-2.0.0b2 → pycapnp-2.2.0}/capnp/version.py +2 -2
  18. {pycapnp-2.0.0b2 → pycapnp-2.2.0}/examples/async_calculator_client.py +0 -1
  19. {pycapnp-2.0.0b2 → pycapnp-2.2.0}/examples/async_calculator_server.py +0 -2
  20. {pycapnp-2.0.0b2 → pycapnp-2.2.0}/examples/async_ssl_calculator_client.py +0 -1
  21. {pycapnp-2.0.0b2 → pycapnp-2.2.0}/examples/async_ssl_calculator_server.py +0 -2
  22. pycapnp-2.2.0/examples/py_custom_message_builder.py +48 -0
  23. pycapnp-2.2.0/examples/selfsigned.cert +29 -0
  24. pycapnp-2.2.0/examples/selfsigned.key +52 -0
  25. {pycapnp-2.0.0b2 → pycapnp-2.2.0/pycapnp.egg-info}/PKG-INFO +39 -7
  26. {pycapnp-2.0.0b2 → pycapnp-2.2.0}/pycapnp.egg-info/SOURCES.txt +8 -0
  27. {pycapnp-2.0.0b2 → pycapnp-2.2.0}/pyproject.toml +1 -1
  28. {pycapnp-2.0.0b2 → pycapnp-2.2.0}/requirements.txt +1 -1
  29. {pycapnp-2.0.0b2 → pycapnp-2.2.0}/setup.py +4 -4
  30. pycapnp-2.2.0/test/blob_test.capnp +5 -0
  31. pycapnp-2.2.0/test/test_blob_to_dict_base64.py +20 -0
  32. pycapnp-2.2.0/test/test_py_custom_message_builder.py +51 -0
  33. {pycapnp-2.0.0b2 → pycapnp-2.2.0}/test/test_serialization.py +2 -6
  34. pycapnp-2.2.0/test/test_structs_sequence.capnp +27 -0
  35. pycapnp-2.2.0/test/test_structs_sequence.py +93 -0
  36. {pycapnp-2.0.0b2 → pycapnp-2.2.0}/tox.ini +1 -1
  37. pycapnp-2.0.0b2/examples/selfsigned.cert +0 -17
  38. pycapnp-2.0.0b2/examples/selfsigned.key +0 -28
  39. {pycapnp-2.0.0b2 → pycapnp-2.2.0}/LICENSE.md +0 -0
  40. {pycapnp-2.0.0b2 → pycapnp-2.2.0}/Pipfile +0 -0
  41. {pycapnp-2.0.0b2 → pycapnp-2.2.0}/buildutils/__init__.py +0 -0
  42. {pycapnp-2.0.0b2 → pycapnp-2.2.0}/buildutils/build.py +0 -0
  43. {pycapnp-2.0.0b2 → pycapnp-2.2.0}/buildutils/bundle.py +0 -0
  44. {pycapnp-2.0.0b2 → pycapnp-2.2.0}/capnp/__init__.pxd +0 -0
  45. {pycapnp-2.0.0b2 → pycapnp-2.2.0}/capnp/_gen.py +0 -0
  46. {pycapnp-2.0.0b2 → pycapnp-2.2.0}/capnp/helpers/__init__.pxd +0 -0
  47. {pycapnp-2.0.0b2 → pycapnp-2.2.0}/capnp/helpers/capabilityHelper.h +0 -0
  48. {pycapnp-2.0.0b2 → pycapnp-2.2.0}/capnp/helpers/checkCompiler.h +0 -0
  49. {pycapnp-2.0.0b2 → pycapnp-2.2.0}/capnp/helpers/deserialize.h +0 -0
  50. {pycapnp-2.0.0b2 → pycapnp-2.2.0}/capnp/helpers/fixMaybe.h +0 -0
  51. {pycapnp-2.0.0b2 → pycapnp-2.2.0}/capnp/helpers/non_circular.pxd +0 -0
  52. {pycapnp-2.0.0b2 → pycapnp-2.2.0}/capnp/helpers/serialize.h +0 -0
  53. {pycapnp-2.0.0b2 → pycapnp-2.2.0}/capnp/includes/__init__.pxd +0 -0
  54. {pycapnp-2.0.0b2 → pycapnp-2.2.0}/capnp/includes/types.pxd +0 -0
  55. {pycapnp-2.0.0b2 → pycapnp-2.2.0}/capnp/lib/__init__.pxd +0 -0
  56. {pycapnp-2.0.0b2 → pycapnp-2.2.0}/capnp/lib/__init__.py +0 -0
  57. {pycapnp-2.0.0b2 → pycapnp-2.2.0}/capnp/lib/pickle_helper.py +0 -0
  58. {pycapnp-2.0.0b2 → pycapnp-2.2.0}/capnp/templates/module.pyx +0 -0
  59. {pycapnp-2.0.0b2 → pycapnp-2.2.0}/capnp/templates/setup.py.tmpl +0 -0
  60. {pycapnp-2.0.0b2 → pycapnp-2.2.0}/examples/addressbook.capnp +0 -0
  61. {pycapnp-2.0.0b2 → pycapnp-2.2.0}/examples/addressbook.py +0 -0
  62. {pycapnp-2.0.0b2 → pycapnp-2.2.0}/examples/async_client.py +0 -0
  63. {pycapnp-2.0.0b2 → pycapnp-2.2.0}/examples/async_reconnecting_ssl_client.py +0 -0
  64. {pycapnp-2.0.0b2 → pycapnp-2.2.0}/examples/async_server.py +0 -0
  65. {pycapnp-2.0.0b2 → pycapnp-2.2.0}/examples/async_socket_message_client.py +0 -0
  66. {pycapnp-2.0.0b2 → pycapnp-2.2.0}/examples/async_socket_message_server.py +0 -0
  67. {pycapnp-2.0.0b2 → pycapnp-2.2.0}/examples/async_ssl_client.py +0 -0
  68. {pycapnp-2.0.0b2 → pycapnp-2.2.0}/examples/async_ssl_server.py +0 -0
  69. {pycapnp-2.0.0b2 → pycapnp-2.2.0}/examples/calculator.capnp +0 -0
  70. {pycapnp-2.0.0b2 → pycapnp-2.2.0}/examples/thread.capnp +0 -0
  71. {pycapnp-2.0.0b2 → pycapnp-2.2.0}/pycapnp.egg-info/dependency_links.txt +0 -0
  72. {pycapnp-2.0.0b2 → pycapnp-2.2.0}/pycapnp.egg-info/entry_points.txt +0 -0
  73. {pycapnp-2.0.0b2 → pycapnp-2.2.0}/pycapnp.egg-info/top_level.txt +0 -0
  74. {pycapnp-2.0.0b2 → pycapnp-2.2.0}/setup.cfg +0 -0
  75. {pycapnp-2.0.0b2 → pycapnp-2.2.0}/test/addressbook with spaces.capnp +0 -0
  76. {pycapnp-2.0.0b2 → pycapnp-2.2.0}/test/addressbook-with-dashes.capnp +0 -0
  77. {pycapnp-2.0.0b2 → pycapnp-2.2.0}/test/addressbook.capnp +0 -0
  78. {pycapnp-2.0.0b2 → pycapnp-2.2.0}/test/all-types.binary +0 -0
  79. {pycapnp-2.0.0b2 → pycapnp-2.2.0}/test/all-types.packed +0 -0
  80. {pycapnp-2.0.0b2 → pycapnp-2.2.0}/test/all-types.txt +0 -0
  81. {pycapnp-2.0.0b2 → pycapnp-2.2.0}/test/all_types.capnp +0 -0
  82. {pycapnp-2.0.0b2 → pycapnp-2.2.0}/test/annotations.capnp +0 -0
  83. {pycapnp-2.0.0b2 → pycapnp-2.2.0}/test/bar.capnp +0 -0
  84. {pycapnp-2.0.0b2 → pycapnp-2.2.0}/test/foo.capnp +0 -0
  85. {pycapnp-2.0.0b2 → pycapnp-2.2.0}/test/schemas/child.capnp +0 -0
  86. {pycapnp-2.0.0b2 → pycapnp-2.2.0}/test/schemas/parent.capnp +0 -0
  87. {pycapnp-2.0.0b2 → pycapnp-2.2.0}/test/test_capability.capnp +0 -0
  88. {pycapnp-2.0.0b2 → pycapnp-2.2.0}/test/test_capability.py +0 -0
  89. {pycapnp-2.0.0b2 → pycapnp-2.2.0}/test/test_capability_context.py +0 -0
  90. {pycapnp-2.0.0b2 → pycapnp-2.2.0}/test/test_context_manager.py +0 -0
  91. {pycapnp-2.0.0b2 → pycapnp-2.2.0}/test/test_examples.py +0 -0
  92. {pycapnp-2.0.0b2 → pycapnp-2.2.0}/test/test_large_read.capnp +0 -0
  93. {pycapnp-2.0.0b2 → pycapnp-2.2.0}/test/test_large_read.py +0 -0
  94. {pycapnp-2.0.0b2 → pycapnp-2.2.0}/test/test_load.py +0 -0
  95. {pycapnp-2.0.0b2 → pycapnp-2.2.0}/test/test_memory_handling.py +0 -0
  96. {pycapnp-2.0.0b2 → pycapnp-2.2.0}/test/test_object.py +0 -0
  97. {pycapnp-2.0.0b2 → pycapnp-2.2.0}/test/test_regression.py +0 -0
  98. {pycapnp-2.0.0b2 → pycapnp-2.2.0}/test/test_response.capnp +0 -0
  99. {pycapnp-2.0.0b2 → pycapnp-2.2.0}/test/test_response.py +0 -0
  100. {pycapnp-2.0.0b2 → pycapnp-2.2.0}/test/test_rpc.py +0 -0
  101. {pycapnp-2.0.0b2 → pycapnp-2.2.0}/test/test_rpc_calculator.py +0 -0
  102. {pycapnp-2.0.0b2 → pycapnp-2.2.0}/test/test_schema.py +0 -0
  103. {pycapnp-2.0.0b2 → pycapnp-2.2.0}/test/test_struct.py +0 -0
@@ -1,7 +1,28 @@
1
+ ## v2.2.0 (2025-09-12)
2
+ - Add binary support in dictionaries via base64 encoding (#351)
3
+ - Add structure-free read_multiple_bytes_packed (#378)
4
+ - Support python custom message builder and make Data field's type return MemoryView (#380)
5
+
6
+ ## v2.1.0 (2025-09-04)
7
+ - Add Python 3.13 support
8
+ * Python 3.8 is still enabled but will be disabled if changes are needed that prevent compatibility with newer versions of Python (e.g. 3.14)
9
+ * Disabling experimental Python 3.14 build as it currently causes build issues
10
+ - Upgrade to Cython version 3
11
+ - Include \_custom_build in sdist
12
+ - Remove usage of deprecated kj::mvCapture functions
13
+ - Make license information SPDX-compatible
14
+ - Generate a new certificate that is compatible with strict x509 checking
15
+ - Avoid storm of 'warning: moving a temporary object prevents copy elision'
16
+ - cibuildwheel updates
17
+ - Fix deprecation warning when importing a schema
18
+
19
+ ## v2.0.0 (2024-01-19)
20
+ - Updated link for mailing list in README
21
+
1
22
  ## v2.0.0b2 (2023-11-25)
2
23
  - Fix broken test in test_load (#329)
3
24
  - Update README example to async code (#331)
4
- - Fix 'AttributeError: '_UnixSelectorEventLoop' object has no attribute 'call_soon'
25
+ - Fix 'AttributeError: '\_UnixSelectorEventLoop' object has no attribute 'call_soon'
5
26
  - Delete and update some Python 3.7-specific todo notes
6
27
  - Make a server fail early when the KJ loop is not running
7
28
  - Update documentation to async code (#331) (#332)
@@ -3,6 +3,7 @@ include LICENSE.md
3
3
  include CHANGELOG.md
4
4
  include requirements.txt
5
5
  include buildutils/*
6
+ include _custom_build/*
6
7
  include capnp/lib/capnp_api.h
7
8
  include Pipfile
8
9
  include tox.ini
@@ -1,16 +1,15 @@
1
- Metadata-Version: 2.1
1
+ Metadata-Version: 2.4
2
2
  Name: pycapnp
3
- Version: 2.0.0b2
3
+ Version: 2.2.0
4
4
  Summary: A cython wrapping of the C++ Cap'n Proto library
5
5
  Home-page: https://github.com/capnproto/pycapnp
6
- Download-URL: https://github.com/haata/pycapnp/archive/v2.0.0b2.zip
6
+ Download-URL: https://github.com/haata/pycapnp/archive/v2.2.0.zip
7
7
  Author: Jacob Alexander
8
8
  Author-email: haata@kiibohd.com
9
- License: BSD
9
+ License: BSD-2-Clause
10
10
  Keywords: capnp,capnproto,Cap'n Proto,pycapnp
11
11
  Classifier: Development Status :: 5 - Production/Stable
12
12
  Classifier: Intended Audience :: Developers
13
- Classifier: License :: OSI Approved :: BSD License
14
13
  Classifier: Operating System :: MacOS :: MacOS X
15
14
  Classifier: Operating System :: Microsoft :: Windows :: Windows 10
16
15
  Classifier: Operating System :: POSIX
@@ -26,6 +25,18 @@ Classifier: Topic :: Communications
26
25
  Requires-Python: >=3.8
27
26
  Description-Content-Type: text/markdown
28
27
  License-File: LICENSE.md
28
+ Dynamic: author
29
+ Dynamic: author-email
30
+ Dynamic: classifier
31
+ Dynamic: description
32
+ Dynamic: description-content-type
33
+ Dynamic: download-url
34
+ Dynamic: home-page
35
+ Dynamic: keywords
36
+ Dynamic: license
37
+ Dynamic: license-file
38
+ Dynamic: requires-python
39
+ Dynamic: summary
29
40
 
30
41
  # pycapnp
31
42
 
@@ -33,7 +44,7 @@ License-File: LICENSE.md
33
44
  [![manylinux2014 Status](https://github.com/capnproto/pycapnp/workflows/manylinux2014/badge.svg)](https://github.com/capnproto/pycapnp/actions)
34
45
  [![PyPI version](https://badge.fury.io/py/pycapnp.svg)](https://badge.fury.io/py/pycapnp)
35
46
 
36
- [Cap'n'proto Mailing List](https://groups.google.com/forum/#!forum/capnproto) [Documentation](https://capnproto.github.io/pycapnp)
47
+ [Cap'n'proto Mailing List](https://github.com/capnproto/capnproto/discussions) [Documentation](https://capnproto.github.io/pycapnp)
37
48
 
38
49
 
39
50
  ## Requirements
@@ -248,10 +259,31 @@ if __name__ == '__main__':
248
259
 
249
260
  Changelog
250
261
  =============
262
+ ## v2.2.0 (2025-09-12)
263
+ - Add binary support in dictionaries via base64 encoding (#351)
264
+ - Add structure-free read_multiple_bytes_packed (#378)
265
+ - Support python custom message builder and make Data field's type return MemoryView (#380)
266
+
267
+ ## v2.1.0 (2025-09-04)
268
+ - Add Python 3.13 support
269
+ * Python 3.8 is still enabled but will be disabled if changes are needed that prevent compatibility with newer versions of Python (e.g. 3.14)
270
+ * Disabling experimental Python 3.14 build as it currently causes build issues
271
+ - Upgrade to Cython version 3
272
+ - Include \_custom_build in sdist
273
+ - Remove usage of deprecated kj::mvCapture functions
274
+ - Make license information SPDX-compatible
275
+ - Generate a new certificate that is compatible with strict x509 checking
276
+ - Avoid storm of 'warning: moving a temporary object prevents copy elision'
277
+ - cibuildwheel updates
278
+ - Fix deprecation warning when importing a schema
279
+
280
+ ## v2.0.0 (2024-01-19)
281
+ - Updated link for mailing list in README
282
+
251
283
  ## v2.0.0b2 (2023-11-25)
252
284
  - Fix broken test in test_load (#329)
253
285
  - Update README example to async code (#331)
254
- - Fix 'AttributeError: '_UnixSelectorEventLoop' object has no attribute 'call_soon'
286
+ - Fix 'AttributeError: '\_UnixSelectorEventLoop' object has no attribute 'call_soon'
255
287
  - Delete and update some Python 3.7-specific todo notes
256
288
  - Make a server fail early when the KJ loop is not running
257
289
  - Update documentation to async code (#331) (#332)
@@ -4,7 +4,7 @@
4
4
  [![manylinux2014 Status](https://github.com/capnproto/pycapnp/workflows/manylinux2014/badge.svg)](https://github.com/capnproto/pycapnp/actions)
5
5
  [![PyPI version](https://badge.fury.io/py/pycapnp.svg)](https://badge.fury.io/py/pycapnp)
6
6
 
7
- [Cap'n'proto Mailing List](https://groups.google.com/forum/#!forum/capnproto) [Documentation](https://capnproto.github.io/pycapnp)
7
+ [Cap'n'proto Mailing List](https://github.com/capnproto/capnproto/discussions) [Documentation](https://capnproto.github.io/pycapnp)
8
8
 
9
9
 
10
10
  ## Requirements
@@ -0,0 +1,31 @@
1
+ import sys
2
+
3
+ from setuptools.build_meta import * # noqa: F401, F403
4
+ from setuptools.build_meta import build_wheel
5
+
6
+ backend_class = build_wheel.__self__.__class__
7
+
8
+
9
+ class _CustomBuildMetaBackend(backend_class):
10
+ def run_setup(self, setup_script="setup.py"):
11
+ if self.config_settings:
12
+ flags = []
13
+ if self.config_settings.get("force-bundled-libcapnp"):
14
+ flags.append("--force-bundled-libcapnp")
15
+ if self.config_settings.get("force-system-libcapnp"):
16
+ flags.append("--force-system-libcapnp")
17
+ if self.config_settings.get("libcapnp-url"):
18
+ flags.append("--libcapnp-url")
19
+ flags.append(self.config_settings["libcapnp-url"])
20
+ if flags:
21
+ sys.argv = sys.argv[:1] + ["build_ext"] + flags + sys.argv[1:]
22
+ return super().run_setup(setup_script)
23
+
24
+ def build_wheel(
25
+ self, wheel_directory, config_settings=None, metadata_directory=None
26
+ ):
27
+ self.config_settings = config_settings
28
+ return super().build_wheel(wheel_directory, config_settings, metadata_directory)
29
+
30
+
31
+ build_wheel = _CustomBuildMetaBackend().build_wheel
@@ -31,6 +31,7 @@ Example Usage::
31
31
  for phone in person.phones:
32
32
  print(phone.type, ':', phone.number)
33
33
  """
34
+
34
35
  # flake8: noqa F401 F403 F405
35
36
  from .version import version as __version__
36
37
  from .lib.capnp import *
@@ -47,6 +48,7 @@ from .lib.capnp import (
47
48
  _InterfaceModule,
48
49
  _ListSchema,
49
50
  _MallocMessageBuilder,
51
+ _PyCustomMessageBuilder,
50
52
  _PackedFdMessageReader,
51
53
  _StreamFdMessageReader,
52
54
  _StructModule,
@@ -68,14 +68,14 @@ kj::Promise<kj::Own<PyRefCounter>> wrapPyFunc(kj::Own<PyRefCounter> func, kj::Ow
68
68
  ::kj::Promise<kj::Own<PyRefCounter>> then(kj::Promise<kj::Own<PyRefCounter>> promise,
69
69
  kj::Own<PyRefCounter> func, kj::Own<PyRefCounter> error_func) {
70
70
  if(error_func->obj == Py_None)
71
- return promise.then(kj::mvCapture(func, [](auto func, kj::Own<PyRefCounter> arg) {
72
- return wrapPyFunc(kj::mv(func), kj::mv(arg)); } ));
71
+ return promise.then([func=kj::mv(func)](kj::Own<PyRefCounter> arg) mutable {
72
+ return wrapPyFunc(kj::mv(func), kj::mv(arg)); } );
73
73
  else
74
74
  return promise.then
75
- (kj::mvCapture(func, [](auto func, kj::Own<PyRefCounter> arg) {
76
- return wrapPyFunc(kj::mv(func), kj::mv(arg)); }),
77
- kj::mvCapture(error_func, [](auto error_func, kj::Exception arg) {
78
- return wrapPyFunc(kj::mv(error_func), stealPyRef(wrap_kj_exception(arg))); } ));
75
+ ([func=kj::mv(func)](kj::Own<PyRefCounter> arg) mutable {
76
+ return wrapPyFunc(kj::mv(func), kj::mv(arg)); },
77
+ [error_func=kj::mv(error_func)](kj::Exception arg) mutable {
78
+ return wrapPyFunc(kj::mv(error_func), stealPyRef(wrap_kj_exception(arg))); } );
79
79
  }
80
80
 
81
81
  kj::Promise<void> PythonInterfaceDynamicImpl::call(capnp::InterfaceSchema::Method method,
@@ -16,9 +16,6 @@ cdef extern from "capnp/helpers/fixMaybe.h":
16
16
 
17
17
  cdef extern from "capnp/helpers/capabilityHelper.h":
18
18
  PyPromise then(PyPromise promise, Own[PyRefCounter] func, Own[PyRefCounter] error_func)
19
- DynamicCapability.Client new_client(InterfaceSchema&, PyObject *)
20
- DynamicValue.Reader new_server(InterfaceSchema&, PyObject *)
21
- Capability.Client server_to_client(InterfaceSchema&, PyObject *)
22
19
  PyPromise convert_to_pypromise(RemotePromise)
23
20
  PyPromise convert_to_pypromise(VoidPromise)
24
21
  VoidPromise taskToPromise(Own[PyRefCounter] coroutine, PyObject* callback)
@@ -26,11 +23,11 @@ cdef extern from "capnp/helpers/capabilityHelper.h":
26
23
  void init_capnp_api()
27
24
 
28
25
  cdef extern from "capnp/helpers/rpcHelper.h":
29
- Capability.Client bootstrapHelper(RpcSystem&)
30
- Capability.Client bootstrapHelperServer(RpcSystem&)
26
+ Own[Capability.Client] bootstrapHelper(RpcSystem&) except +reraise_kj_exception
27
+ Own[Capability.Client] bootstrapHelperServer(RpcSystem&) except +reraise_kj_exception
31
28
 
32
29
  cdef extern from "capnp/helpers/serialize.h":
33
- ByteArray messageToPackedBytes(MessageBuilder &, size_t wordCount)
30
+ ByteArray messageToPackedBytes(MessageBuilder &, size_t wordCount) except +reraise_kj_exception
34
31
 
35
32
  cdef extern from "capnp/helpers/deserialize.h":
36
33
  Node.Reader toReader(DynamicStruct.Reader reader) except +reraise_kj_exception
@@ -6,16 +6,16 @@
6
6
  #include "Python.h"
7
7
  #include "capabilityHelper.h"
8
8
 
9
- capnp::Capability::Client bootstrapHelper(capnp::RpcSystem<capnp::rpc::twoparty::SturdyRefHostId>& client) {
9
+ kj::Own<capnp::Capability::Client> bootstrapHelper(capnp::RpcSystem<capnp::rpc::twoparty::SturdyRefHostId>& client) {
10
10
  capnp::MallocMessageBuilder hostIdMessage(8);
11
11
  auto hostId = hostIdMessage.initRoot<capnp::rpc::twoparty::SturdyRefHostId>();
12
12
  hostId.setSide(capnp::rpc::twoparty::Side::SERVER);
13
- return client.bootstrap(hostId);
13
+ return kj::heap<capnp::Capability::Client>(client.bootstrap(hostId));
14
14
  }
15
15
 
16
- capnp::Capability::Client bootstrapHelperServer(capnp::RpcSystem<capnp::rpc::twoparty::SturdyRefHostId>& client) {
16
+ kj::Own<capnp::Capability::Client> bootstrapHelperServer(capnp::RpcSystem<capnp::rpc::twoparty::SturdyRefHostId>& client) {
17
17
  capnp::MallocMessageBuilder hostIdMessage(8);
18
18
  auto hostId = hostIdMessage.initRoot<capnp::rpc::twoparty::SturdyRefHostId>();
19
19
  hostId.setSide(capnp::rpc::twoparty::Side::CLIENT);
20
- return client.bootstrap(hostId);
20
+ return kj::heap<capnp::Capability::Client>(client.bootstrap(hostId));
21
21
  }
@@ -0,0 +1,50 @@
1
+ #include "PyCustomMessageBuilder.h"
2
+ #include <stdexcept>
3
+
4
+ namespace capnp {
5
+
6
+ PyCustomMessageBuilder::PyCustomMessageBuilder(
7
+ PyObject* allocateSegmentCallable, uint firstSegmentWords)
8
+ : allocateSegmentCallable(allocateSegmentCallable), firstSize(firstSegmentWords)
9
+ {
10
+ KJ_REQUIRE(PyCallable_Check(allocateSegmentCallable),
11
+ "allocateSegmentCallable must be callable");
12
+ Py_INCREF(allocateSegmentCallable);
13
+ }
14
+
15
+ PyCustomMessageBuilder::~PyCustomMessageBuilder() noexcept(false) {
16
+ PyGILState_STATE gstate = PyGILState_Ensure();
17
+
18
+ for (auto* obj : allocatedBuffers) {
19
+ Py_DECREF(obj);
20
+ }
21
+ allocatedBuffers.clear();
22
+
23
+ Py_DECREF(allocateSegmentCallable);
24
+ PyGILState_Release(gstate);
25
+ }
26
+
27
+ kj::ArrayPtr<capnp::word> PyCustomMessageBuilder::allocateSegment(capnp::uint minimumSize) {
28
+ PyGILState_STATE gstate = PyGILState_Ensure();
29
+ KJ_DEFER({ PyGILState_Release(gstate); });
30
+ if (curSize == 0) {
31
+ minimumSize = kj::max(minimumSize, firstSize);
32
+ }
33
+ PyObject* pyBufObj = PyObject_CallFunction(allocateSegmentCallable, "I", minimumSize);
34
+ KJ_REQUIRE(pyBufObj, "PyCustomMessageBuilder: allocateSegment failed");
35
+ allocatedBuffers.push_back(pyBufObj);
36
+
37
+
38
+ Py_buffer view;
39
+ int bufRes = PyObject_GetBuffer(pyBufObj, &view, PyBUF_SIMPLE);
40
+ KJ_REQUIRE(bufRes == 0, "PyCustomMessageBuilder: object does not support buffer protocol");
41
+ KJ_DEFER({ PyBuffer_Release(&view); });
42
+
43
+ size_t byteCount = view.len;
44
+ size_t wordCount = byteCount / sizeof(capnp::word);
45
+ KJ_REQUIRE(wordCount >= minimumSize, "PyCustomMessageBuilder: buffer too small for minimumSize");
46
+ curSize += wordCount;
47
+ return kj::arrayPtr(reinterpret_cast<capnp::word*>(view.buf), wordCount);
48
+ }
49
+
50
+ }
@@ -57,26 +57,12 @@ cdef extern from "kj/async.h" namespace " ::kj":
57
57
  cdef cppclass Promise[T] nogil:
58
58
  Promise(Promise)
59
59
  Promise(T)
60
- T wait(WaitScope) except +reraise_kj_exception
61
- bool poll(WaitScope) except +reraise_kj_exception
62
- # ForkedPromise<T> fork()
63
- # Promise<T> exclusiveJoin(Promise<T>&& other)
64
- # Promise[T] eagerlyEvaluate()
65
- # void detach(ErrorFunc)
66
60
  String trace()
67
61
  Promise[T] attach(Own[PyRefCounter] &)
68
62
  Promise[T] attach(Own[PyRefCounter] &, Own[PyRefCounter] &)
69
63
  Promise[T] attach(Own[PyRefCounter] &, Own[PyRefCounter] &, Own[PyRefCounter] &)
70
64
  Promise[T] attach(Own[PyRefCounter] &, Own[PyRefCounter] &, Own[PyRefCounter] &, Own[PyRefCounter] &)
71
65
 
72
- cdef cppclass Canceler nogil:
73
- Canceler()
74
- Promise[T] wrap[T](Promise[T] promise)
75
- void cancel(StringPtr cancelReason)
76
- void cancel(Exception& exception)
77
- void release()
78
- bool isEmpty()
79
-
80
66
  ctypedef Promise[Own[PyRefCounter]] PyPromise
81
67
  ctypedef Promise[void] VoidPromise
82
68
 
@@ -109,8 +95,8 @@ cdef extern from "kj/array.h" namespace " ::kj":
109
95
 
110
96
  cdef extern from "kj/async-io.h" namespace " ::kj":
111
97
  cdef cppclass AsyncIoStream nogil:
112
- Promise[size_t] read(void*, size_t, size_t)
113
- Promise[void] write(const void*, size_t)
98
+ Promise[size_t] read(void*, size_t, size_t) except +reraise_kj_exception
99
+ Promise[void] write(const void*, size_t) except +reraise_kj_exception
114
100
 
115
101
  cdef extern from "capnp/schema.capnp.h" namespace " ::capnp":
116
102
  enum TypeWhich" ::capnp::schema::Type::Which":
@@ -297,7 +283,7 @@ cdef extern from "capnp/dynamic.h" namespace " ::capnp":
297
283
  Client()
298
284
  Client(Client&)
299
285
  Client(Own[PythonInterfaceDynamicImpl])
300
- Client upcast(InterfaceSchema requestedSchema)
286
+ Client upcast(InterfaceSchema requestedSchema) except +reraise_kj_exception
301
287
  DynamicCapability.Client castAs"castAs< ::capnp::DynamicCapability>"(InterfaceSchema)
302
288
  InterfaceSchema getSchema()
303
289
  Request newRequest(char * methodName)
@@ -448,7 +434,7 @@ cdef extern from "capnp/dynamic.h" namespace " ::capnp":
448
434
  Type getType()
449
435
 
450
436
  cdef extern from "capnp/schema-loader.h" namespace " ::capnp":
451
- cdef cppclass SchemaLoader:
437
+ cdef cppclass SchemaLoader nogil:
452
438
  SchemaLoader()
453
439
  Schema load(Node.Reader reader) except +reraise_kj_exception
454
440
  Schema get(uint64_t id_) except +reraise_kj_exception
@@ -673,7 +673,7 @@ cdef extern from "capnp/message.h" namespace " ::capnp":
673
673
  Annotation.Builder getRootAnnotation'getRoot< ::capnp::schema::Annotation>'()
674
674
  Annotation.Builder initRootAnnotation'initRoot< ::capnp::schema::Annotation>'()
675
675
 
676
- DynamicStruct_Builder getRootDynamicStruct'getRoot< ::capnp::DynamicStruct>'(StructSchema)
676
+ DynamicStruct_Builder getRootDynamicStruct'getRoot< ::capnp::DynamicStruct>'(StructSchema) except +reraise_kj_exception
677
677
  DynamicStruct_Builder initRootDynamicStruct'initRoot< ::capnp::DynamicStruct>'(StructSchema)
678
678
  void setRootDynamicStruct'setRoot< ::capnp::DynamicStruct::Reader>'(DynamicStruct.Reader)
679
679
 
@@ -696,7 +696,7 @@ cdef extern from "capnp/message.h" namespace " ::capnp":
696
696
  StructNode.Reader getRootStructNode'getRoot< ::capnp::schema::StructNode>'()
697
697
  Annotation.Reader getRootAnnotation'getRoot< ::capnp::schema::Annotation>'()
698
698
 
699
- DynamicStruct.Reader getRootDynamicStruct'getRoot< ::capnp::DynamicStruct>'(StructSchema)
699
+ DynamicStruct.Reader getRootDynamicStruct'getRoot< ::capnp::DynamicStruct>'(StructSchema) except +reraise_kj_exception
700
700
  AnyPointer.Reader getRootAnyPointer'getRoot< ::capnp::AnyPointer>'()
701
701
 
702
702
  cdef cppclass MallocMessageBuilder(MessageBuilder) nogil:
@@ -714,6 +714,11 @@ cdef extern from "capnp/message.h" namespace " ::capnp":
714
714
  enum Void:
715
715
  VOID
716
716
 
717
+ cdef extern from "PyCustomMessageBuilder.h" namespace " ::capnp":
718
+ cdef cppclass PyCustomMessageBuilder(MessageBuilder):
719
+ PyCustomMessageBuilder(PyObject* allocateSegmentCallable)
720
+ PyCustomMessageBuilder(PyObject* allocateSegmentCallable, int firstSegmentSize)
721
+
717
722
  cdef extern from "capnp/common.h" namespace " ::capnp":
718
723
  cdef cppclass word nogil:
719
724
  pass
@@ -798,7 +803,7 @@ cdef extern from "capnp/serialize.h" namespace " ::capnp":
798
803
  FlatArrayMessageReader(WordArrayPtr array, ReaderOptions) except +reraise_kj_exception
799
804
  const word* getEnd() const
800
805
 
801
- void writeMessageToFd(int, MessageBuilder&) nogil except +reraise_kj_exception
806
+ void writeMessageToFd(int, MessageBuilder&) except +reraise_kj_exception nogil
802
807
 
803
808
  WordArray messageToFlatArray(MessageBuilder &) nogil
804
809
 
@@ -816,6 +821,6 @@ cdef extern from "capnp/serialize-packed.h" namespace " ::capnp":
816
821
  PackedFdMessageReader(int) except +reraise_kj_exception
817
822
  PackedFdMessageReader(int, ReaderOptions) except +reraise_kj_exception
818
823
 
819
- void writePackedMessage(BufferedOutputStream&, MessageBuilder&) nogil except +reraise_kj_exception
820
- void writePackedMessage(OutputStream&, MessageBuilder&) nogil except +reraise_kj_exception
821
- void writePackedMessageToFd(int, MessageBuilder&) nogil except +reraise_kj_exception
824
+ void writePackedMessage(BufferedOutputStream&, MessageBuilder&) except +reraise_kj_exception nogil
825
+ void writePackedMessage(OutputStream&, MessageBuilder&) except +reraise_kj_exception nogil
826
+ void writePackedMessageToFd(int, MessageBuilder&) except +reraise_kj_exception nogil