| 1 |
{%- call py::docstring_value(ci.namespace_docstring(), 0) %} |
| 2 |
|
| 3 |
# This file was autogenerated by some hot garbage in the `uniffi` crate. |
| 4 |
# Trust me, you don't want to mess with it! |
| 5 |
|
| 6 |
# Common helper code. |
| 7 |
# |
| 8 |
# Ideally this would live in a separate .py file where it can be unittested etc |
| 9 |
# in isolation, and perhaps even published as a re-useable package. |
| 10 |
# |
| 11 |
# However, it's important that the details of how this helper code works (e.g. the |
| 12 |
# way that different builtin types are passed across the FFI) exactly match what's |
| 13 |
# expected by the rust code on the other side of the interface. In practice right |
| 14 |
# now that means coming from the exact some version of `uniffi` that was used to |
| 15 |
# compile the rust component. The easiest way to ensure this is to bundle the Python |
| 16 |
# helpers directly inline like we're doing here. |
| 17 |
|
| 18 |
from __future__ import annotations |
| 19 |
import os |
| 20 |
import sys |
| 21 |
import ctypes |
| 22 |
import enum |
| 23 |
import struct |
| 24 |
import contextlib |
| 25 |
import datetime |
| 26 |
import threading |
| 27 |
import itertools |
| 28 |
import traceback |
| 29 |
import typing |
| 30 |
{%- if ci.has_async_fns() %} |
| 31 |
import asyncio |
| 32 |
{%- endif %} |
| 33 |
import platform |
| 34 |
{%- for req in self.imports() %} |
| 35 |
{{ req.render() }} |
| 36 |
{%- endfor %} |
| 37 |
|
| 38 |
# Used for default argument values |
| 39 |
_DEFAULT = object() # type: typing.Any |
| 40 |
|
| 41 |
{% include "RustBufferTemplate.py" %} |
| 42 |
{% include "Helpers.py" %} |
| 43 |
{% include "HandleMap.py" %} |
| 44 |
{% include "RustBufferHelper.py" %} |
| 45 |
|
| 46 |
# Contains loading, initialization code, and the FFI Function declarations. |
| 47 |
{% include "NamespaceLibraryTemplate.py" %} |
| 48 |
|
| 49 |
# Public interface members begin here. |
| 50 |
{{ type_helper_code }} |
| 51 |
|
| 52 |
# Async support |
| 53 |
{%- if ci.has_async_fns() %} |
| 54 |
{%- include "Async.py" %} |
| 55 |
{%- endif %} |
| 56 |
|
| 57 |
{%- for func in ci.function_definitions() %} |
| 58 |
{%- include "TopLevelFunctionTemplate.py" %} |
| 59 |
{%- endfor %} |
| 60 |
|
| 61 |
__all__ = [ |
| 62 |
"InternalError", |
| 63 |
{%- for e in ci.enum_definitions() %} |
| 64 |
"{{ e.name() }}", |
| 65 |
{%- endfor %} |
| 66 |
{%- for record in ci.record_definitions() %} |
| 67 |
"{{ record.name() }}", |
| 68 |
{%- endfor %} |
| 69 |
{%- for func in ci.function_definitions() %} |
| 70 |
"{{ func.name() }}", |
| 71 |
{%- endfor %} |
| 72 |
{%- for obj in ci.object_definitions() %} |
| 73 |
"{{ obj.name() }}", |
| 74 |
{%- endfor %} |
| 75 |
{%- for c in ci.callback_interface_definitions() %} |
| 76 |
"{{ c.name() }}", |
| 77 |
{%- endfor %} |
| 78 |
] |
| 79 |
|
| 80 |
{% import "macros.py" as py %} |