amulet-core 2.0a8__cp311-cp311-win_amd64.whl → 2.0.1a3.post250529101324__cp311-cp311-win_amd64.whl
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.
Potentially problematic release.
This version of amulet-core might be problematic. Click here for more details.
- amulet/core/__init__.py +36 -0
- amulet/core/__pyinstaller/hook-amulet.core.py +4 -0
- amulet/core/_amulet_core.cp311-win_amd64.pyd +0 -0
- amulet/core/_amulet_core.pyi +7 -0
- amulet/{_version.py → core/_version.py} +3 -3
- amulet/core/amulet_core.dll +0 -0
- amulet/core/amulet_core.lib +0 -0
- amulet/core/amulet_coreConfig.cmake +18 -0
- amulet/{biome.pyi → core/biome/__init__.pyi} +3 -3
- amulet/core/biome/biome.hpp +53 -0
- amulet/{block.pyi → core/block/__init__.pyi} +25 -26
- amulet/core/block/block.hpp +156 -0
- amulet/{block_entity.pyi → core/block_entity/__init__.pyi} +7 -7
- amulet/core/block_entity/block_entity.hpp +84 -0
- amulet/{errors.py → core/chunk/__init__.pyi} +37 -33
- amulet/core/chunk/chunk.hpp +126 -0
- amulet/core/chunk/component/__init__.pyi +18 -0
- amulet/core/chunk/component/biome_3d_component.hpp +96 -0
- amulet/core/chunk/component/block_component.hpp +101 -0
- amulet/core/chunk/component/block_component.pyi +28 -0
- amulet/core/chunk/component/block_entity_component.hpp +119 -0
- amulet/core/chunk/component/section_array_map.hpp +129 -0
- amulet/{chunk_components.pyi → core/chunk/component/section_array_map.pyi} +4 -24
- amulet/core/dll.hpp +21 -0
- amulet/core/entity/__init__.pyi +105 -0
- amulet/core/entity/entity.hpp +100 -0
- amulet/{palette → core/palette}/__init__.pyi +2 -2
- amulet/core/palette/biome_palette.hpp +65 -0
- amulet/{palette → core/palette}/biome_palette.pyi +8 -8
- amulet/core/palette/block_palette.hpp +71 -0
- amulet/{palette → core/palette}/block_palette.pyi +12 -10
- amulet/core/selection/__init__.pyi +8 -0
- amulet/core/selection/box.hpp +86 -0
- amulet/core/selection/box.pyi +215 -0
- amulet/core/selection/group.hpp +80 -0
- amulet/core/selection/group.pyi +213 -0
- amulet/{version.pyi → core/version/__init__.pyi} +58 -10
- amulet/core/version/version.hpp +204 -0
- {amulet_core-2.0a8.dist-info → amulet_core-2.0.1a3.post250529101324.dist-info}/METADATA +25 -20
- amulet_core-2.0.1a3.post250529101324.dist-info/RECORD +45 -0
- {amulet_core-2.0a8.dist-info → amulet_core-2.0.1a3.post250529101324.dist-info}/WHEEL +1 -1
- amulet_core-2.0.1a3.post250529101324.dist-info/entry_points.txt +2 -0
- amulet/__init__.cp311-win_amd64.pyd +0 -0
- amulet/__init__.py.cpp +0 -45
- amulet/__init__.pyi +0 -30
- amulet/__pyinstaller/hook-amulet.py +0 -4
- amulet/_init.py +0 -26
- amulet/biome.cpp +0 -36
- amulet/biome.hpp +0 -43
- amulet/biome.py.cpp +0 -122
- amulet/block.cpp +0 -435
- amulet/block.hpp +0 -119
- amulet/block.py.cpp +0 -377
- amulet/block_entity.cpp +0 -12
- amulet/block_entity.hpp +0 -56
- amulet/block_entity.py.cpp +0 -115
- amulet/chunk.cpp +0 -16
- amulet/chunk.hpp +0 -100
- amulet/chunk.py.cpp +0 -80
- amulet/chunk.pyi +0 -28
- amulet/chunk_components/biome_3d_component.cpp +0 -5
- amulet/chunk_components/biome_3d_component.hpp +0 -79
- amulet/chunk_components/block_component.cpp +0 -41
- amulet/chunk_components/block_component.hpp +0 -88
- amulet/chunk_components/block_entity_component.cpp +0 -5
- amulet/chunk_components/block_entity_component.hpp +0 -147
- amulet/chunk_components/section_array_map.cpp +0 -129
- amulet/chunk_components/section_array_map.hpp +0 -147
- amulet/collections/eq.py.hpp +0 -37
- amulet/collections/hash.py.hpp +0 -27
- amulet/collections/holder.py.hpp +0 -37
- amulet/collections/iterator.py.hpp +0 -80
- amulet/collections/mapping.py.hpp +0 -199
- amulet/collections/mutable_mapping.py.hpp +0 -226
- amulet/collections/sequence.py.hpp +0 -163
- amulet/collections.pyi +0 -40
- amulet/data_types.py +0 -29
- amulet/entity.py +0 -182
- amulet/game/__init__.py +0 -7
- amulet/game/_game.py +0 -152
- amulet/game/_universal/__init__.py +0 -1
- amulet/game/_universal/_biome.py +0 -17
- amulet/game/_universal/_block.py +0 -47
- amulet/game/_universal/_version.py +0 -68
- amulet/game/abc/__init__.py +0 -22
- amulet/game/abc/_block_specification.py +0 -150
- amulet/game/abc/biome.py +0 -213
- amulet/game/abc/block.py +0 -331
- amulet/game/abc/game_version_container.py +0 -25
- amulet/game/abc/json_interface.py +0 -27
- amulet/game/abc/version.py +0 -44
- amulet/game/bedrock/__init__.py +0 -1
- amulet/game/bedrock/_biome.py +0 -35
- amulet/game/bedrock/_block.py +0 -42
- amulet/game/bedrock/_version.py +0 -165
- amulet/game/java/__init__.py +0 -2
- amulet/game/java/_biome.py +0 -35
- amulet/game/java/_block.py +0 -60
- amulet/game/java/_version.py +0 -176
- amulet/game/translate/__init__.py +0 -12
- amulet/game/translate/_functions/__init__.py +0 -15
- amulet/game/translate/_functions/_code_functions/__init__.py +0 -0
- amulet/game/translate/_functions/_code_functions/_text.py +0 -553
- amulet/game/translate/_functions/_code_functions/banner_pattern.py +0 -67
- amulet/game/translate/_functions/_code_functions/bedrock_chest_connection.py +0 -152
- amulet/game/translate/_functions/_code_functions/bedrock_moving_block_pos.py +0 -88
- amulet/game/translate/_functions/_code_functions/bedrock_sign.py +0 -152
- amulet/game/translate/_functions/_code_functions/bedrock_skull_rotation.py +0 -16
- amulet/game/translate/_functions/_code_functions/custom_name.py +0 -146
- amulet/game/translate/_functions/_frozen.py +0 -66
- amulet/game/translate/_functions/_state.py +0 -54
- amulet/game/translate/_functions/_typing.py +0 -98
- amulet/game/translate/_functions/abc.py +0 -123
- amulet/game/translate/_functions/carry_nbt.py +0 -160
- amulet/game/translate/_functions/carry_properties.py +0 -80
- amulet/game/translate/_functions/code.py +0 -143
- amulet/game/translate/_functions/map_block_name.py +0 -66
- amulet/game/translate/_functions/map_nbt.py +0 -111
- amulet/game/translate/_functions/map_properties.py +0 -93
- amulet/game/translate/_functions/multiblock.py +0 -112
- amulet/game/translate/_functions/new_block.py +0 -42
- amulet/game/translate/_functions/new_entity.py +0 -43
- amulet/game/translate/_functions/new_nbt.py +0 -206
- amulet/game/translate/_functions/new_properties.py +0 -64
- amulet/game/translate/_functions/sequence.py +0 -51
- amulet/game/translate/_functions/walk_input_nbt.py +0 -331
- amulet/game/translate/_translator.py +0 -433
- amulet/img/__init__.py +0 -10
- amulet/img/missing_no.png +0 -0
- amulet/img/missing_pack.png +0 -0
- amulet/img/missing_world.png +0 -0
- amulet/io/binary_reader.hpp +0 -45
- amulet/io/binary_writer.hpp +0 -30
- amulet/item.py +0 -75
- amulet/level/__init__.pyi +0 -23
- amulet/level/_load.py +0 -100
- amulet/level/abc/__init__.py +0 -12
- amulet/level/abc/_chunk_handle.py +0 -358
- amulet/level/abc/_dimension.py +0 -86
- amulet/level/abc/_history/__init__.py +0 -1
- amulet/level/abc/_history/_cache.py +0 -224
- amulet/level/abc/_history/_history_manager.py +0 -291
- amulet/level/abc/_level/__init__.py +0 -5
- amulet/level/abc/_level/_compactable_level.py +0 -10
- amulet/level/abc/_level/_creatable_level.py +0 -28
- amulet/level/abc/_level/_disk_level.py +0 -17
- amulet/level/abc/_level/_level.py +0 -449
- amulet/level/abc/_level/_loadable_level.py +0 -42
- amulet/level/abc/_player_storage.py +0 -7
- amulet/level/abc/_raw_level.py +0 -187
- amulet/level/abc/_registry.py +0 -40
- amulet/level/java/__init__.pyi +0 -16
- amulet/level/java/_chunk_handle.py +0 -17
- amulet/level/java/_dimension.py +0 -20
- amulet/level/java/_level.py +0 -184
- amulet/level/java/_raw/__init__.pyi +0 -15
- amulet/level/java/_raw/_chunk.pyi +0 -23
- amulet/level/java/_raw/_constant.py +0 -9
- amulet/level/java/_raw/_data_pack/__init__.py +0 -2
- amulet/level/java/_raw/_data_pack/data_pack.py +0 -241
- amulet/level/java/_raw/_data_pack/data_pack_manager.py +0 -77
- amulet/level/java/_raw/_dimension.py +0 -86
- amulet/level/java/_raw/_level.py +0 -507
- amulet/level/java/_raw/_typing.py +0 -3
- amulet/level/java/_raw/java_chunk_decode.cpp +0 -531
- amulet/level/java/_raw/java_chunk_decode.hpp +0 -23
- amulet/level/java/_raw/java_chunk_encode.cpp +0 -25
- amulet/level/java/_raw/java_chunk_encode.hpp +0 -23
- amulet/level/java/anvil/__init__.py +0 -2
- amulet/level/java/anvil/_dimension.py +0 -170
- amulet/level/java/anvil/_region.py +0 -421
- amulet/level/java/anvil/_sector_manager.py +0 -223
- amulet/level/java/chunk.pyi +0 -81
- amulet/level/java/chunk_/_chunk.py +0 -260
- amulet/level/java/chunk_/components/inhabited_time.py +0 -12
- amulet/level/java/chunk_/components/last_update.py +0 -12
- amulet/level/java/chunk_/components/legacy_version.py +0 -12
- amulet/level/java/chunk_/components/light_populated.py +0 -12
- amulet/level/java/chunk_/components/named_height_2d.py +0 -37
- amulet/level/java/chunk_/components/status.py +0 -11
- amulet/level/java/chunk_/components/terrain_populated.py +0 -12
- amulet/level/java/chunk_components/data_version_component.cpp +0 -32
- amulet/level/java/chunk_components/data_version_component.hpp +0 -31
- amulet/level/java/chunk_components/java_raw_chunk_component.cpp +0 -56
- amulet/level/java/chunk_components/java_raw_chunk_component.hpp +0 -45
- amulet/level/java/chunk_components.pyi +0 -22
- amulet/level/java/java_chunk.cpp +0 -170
- amulet/level/java/java_chunk.hpp +0 -141
- amulet/level/java/long_array.hpp +0 -175
- amulet/level/java/long_array.pyi +0 -39
- amulet/level/temporary_level/__init__.py +0 -1
- amulet/level/temporary_level/_level.py +0 -16
- amulet/mesh/__init__.py +0 -0
- amulet/mesh/block/__init__.pyi +0 -301
- amulet/mesh/block/_cube.py +0 -198
- amulet/mesh/block/_missing_block.py +0 -20
- amulet/mesh/block/block_mesh.cpp +0 -107
- amulet/mesh/block/block_mesh.hpp +0 -207
- amulet/mesh/util.py +0 -17
- amulet/palette/biome_palette.hpp +0 -85
- amulet/palette/block_palette.cpp +0 -32
- amulet/palette/block_palette.hpp +0 -93
- amulet/player.py +0 -62
- amulet/pybind11/collections.hpp +0 -118
- amulet/pybind11/numpy.hpp +0 -26
- amulet/pybind11/py_module.hpp +0 -34
- amulet/pybind11/type_hints.hpp +0 -51
- amulet/pybind11/types.hpp +0 -25
- amulet/pybind11/typing.hpp +0 -7
- amulet/resource_pack/__init__.py +0 -63
- amulet/resource_pack/abc/__init__.py +0 -2
- amulet/resource_pack/abc/resource_pack.py +0 -38
- amulet/resource_pack/abc/resource_pack_manager.py +0 -85
- amulet/resource_pack/java/__init__.py +0 -2
- amulet/resource_pack/java/download_resources.py +0 -212
- amulet/resource_pack/java/java_vanilla_fix/assets/minecraft/textures/block/banner/banner_black.png +0 -0
- amulet/resource_pack/java/java_vanilla_fix/assets/minecraft/textures/block/banner/banner_blue.png +0 -0
- amulet/resource_pack/java/java_vanilla_fix/assets/minecraft/textures/block/banner/banner_brown.png +0 -0
- amulet/resource_pack/java/java_vanilla_fix/assets/minecraft/textures/block/banner/banner_cyan.png +0 -0
- amulet/resource_pack/java/java_vanilla_fix/assets/minecraft/textures/block/banner/banner_gray.png +0 -0
- amulet/resource_pack/java/java_vanilla_fix/assets/minecraft/textures/block/banner/banner_green.png +0 -0
- amulet/resource_pack/java/java_vanilla_fix/assets/minecraft/textures/block/banner/banner_light_blue.png +0 -0
- amulet/resource_pack/java/java_vanilla_fix/assets/minecraft/textures/block/banner/banner_light_gray.png +0 -0
- amulet/resource_pack/java/java_vanilla_fix/assets/minecraft/textures/block/banner/banner_lime.png +0 -0
- amulet/resource_pack/java/java_vanilla_fix/assets/minecraft/textures/block/banner/banner_magenta.png +0 -0
- amulet/resource_pack/java/java_vanilla_fix/assets/minecraft/textures/block/banner/banner_orange.png +0 -0
- amulet/resource_pack/java/java_vanilla_fix/assets/minecraft/textures/block/banner/banner_pink.png +0 -0
- amulet/resource_pack/java/java_vanilla_fix/assets/minecraft/textures/block/banner/banner_purple.png +0 -0
- amulet/resource_pack/java/java_vanilla_fix/assets/minecraft/textures/block/banner/banner_red.png +0 -0
- amulet/resource_pack/java/java_vanilla_fix/assets/minecraft/textures/block/banner/banner_white.png +0 -0
- amulet/resource_pack/java/java_vanilla_fix/assets/minecraft/textures/block/banner/banner_yellow.png +0 -0
- amulet/resource_pack/java/java_vanilla_fix/assets/minecraft/textures/block/barrier.png +0 -0
- amulet/resource_pack/java/java_vanilla_fix/assets/minecraft/textures/block/end_portal.png +0 -0
- amulet/resource_pack/java/java_vanilla_fix/assets/minecraft/textures/block/grass.png +0 -0
- amulet/resource_pack/java/java_vanilla_fix/assets/minecraft/textures/block/lava.png +0 -0
- amulet/resource_pack/java/java_vanilla_fix/assets/minecraft/textures/block/structure_void.png +0 -0
- amulet/resource_pack/java/java_vanilla_fix/assets/minecraft/textures/block/water.png +0 -0
- amulet/resource_pack/java/java_vanilla_fix/pack.png +0 -0
- amulet/resource_pack/java/resource_pack.py +0 -44
- amulet/resource_pack/java/resource_pack_manager.py +0 -563
- amulet/resource_pack/unknown_resource_pack.py +0 -10
- amulet/selection/__init__.py +0 -2
- amulet/selection/abstract_selection.py +0 -342
- amulet/selection/box.py +0 -852
- amulet/selection/group.py +0 -481
- amulet/utils/__init__.pyi +0 -23
- amulet/utils/call_spec/__init__.py +0 -24
- amulet/utils/call_spec/_call_spec.py +0 -257
- amulet/utils/cast.py +0 -10
- amulet/utils/comment_json.py +0 -188
- amulet/utils/format_utils.py +0 -41
- amulet/utils/generator.py +0 -18
- amulet/utils/matrix.py +0 -243
- amulet/utils/numpy.hpp +0 -36
- amulet/utils/numpy.pyi +0 -11
- amulet/utils/numpy_helpers.py +0 -19
- amulet/utils/shareable_lock.py +0 -335
- amulet/utils/signal/__init__.py +0 -10
- amulet/utils/signal/_signal.py +0 -228
- amulet/utils/task_manager.py +0 -235
- amulet/utils/typed_property.py +0 -111
- amulet/utils/weakref.py +0 -70
- amulet/utils/world_utils.py +0 -102
- amulet/version.cpp +0 -136
- amulet/version.hpp +0 -142
- amulet/version.py.cpp +0 -281
- amulet_core-2.0a8.dist-info/RECORD +0 -241
- amulet_core-2.0a8.dist-info/entry_points.txt +0 -2
- /amulet/{__pyinstaller → core/__pyinstaller}/__init__.py +0 -0
- /amulet/{py.typed → core/py.typed} +0 -0
- {amulet_core-2.0a8.dist-info → amulet_core-2.0.1a3.post250529101324.dist-info}/top_level.txt +0 -0
amulet/utils/world_utils.py
DELETED
|
@@ -1,102 +0,0 @@
|
|
|
1
|
-
from __future__ import annotations
|
|
2
|
-
|
|
3
|
-
import math
|
|
4
|
-
from typing import Optional
|
|
5
|
-
import numpy
|
|
6
|
-
from numpy import ndarray, zeros, uint8
|
|
7
|
-
from amulet.data_types import ChunkCoordinates
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
def block_coords_to_chunk_coords(
|
|
11
|
-
*args: int, sub_chunk_size: int = 16
|
|
12
|
-
) -> tuple[int, ...]:
|
|
13
|
-
"""
|
|
14
|
-
Converts the supplied block coordinates into chunk coordinates
|
|
15
|
-
|
|
16
|
-
:param args: The coordinate of the block(s)
|
|
17
|
-
:param sub_chunk_size: The dimension of the chunk (Optional. Default 16)
|
|
18
|
-
:return: The resulting chunk coordinates in (x, z) order
|
|
19
|
-
"""
|
|
20
|
-
return tuple(int(math.floor(coord / sub_chunk_size)) for coord in args)
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
def chunk_coords_to_block_coords(
|
|
24
|
-
x: int, z: int, chunk_x_size: int = 16, chunk_z_size: int = 16
|
|
25
|
-
) -> ChunkCoordinates:
|
|
26
|
-
"""
|
|
27
|
-
Converts the supplied chunk coordinates into block coordinates
|
|
28
|
-
|
|
29
|
-
:param x: The x coordinate of the chunk
|
|
30
|
-
:param z: The z coordinate of the chunk
|
|
31
|
-
:param chunk_x_size: The dimension of the chunk in the x direction (Optional. Default 16)
|
|
32
|
-
:param chunk_z_size: The dimension of the chunk in the z direction (Optional. Default 16)
|
|
33
|
-
:return: The resulting block coordinates in (x, z) order
|
|
34
|
-
"""
|
|
35
|
-
return x * chunk_x_size, z * chunk_z_size
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
def chunk_coords_to_region_coords(cx: int, cz: int) -> ChunkCoordinates:
|
|
39
|
-
"""
|
|
40
|
-
Converts the supplied chunk coordinates into region coordinates
|
|
41
|
-
|
|
42
|
-
:param cx: The x coordinate of the chunk
|
|
43
|
-
:param cz: The z coordinate of the chunk
|
|
44
|
-
:return: The resulting region coordinates in (x, z) order
|
|
45
|
-
"""
|
|
46
|
-
return cx >> 5, cz >> 5
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
def region_coords_to_chunk_coords(rx: int, rz: int) -> ChunkCoordinates:
|
|
50
|
-
"""
|
|
51
|
-
Converts the supplied region coordinates into the minimum chunk coordinates of that region
|
|
52
|
-
|
|
53
|
-
:param rx: The x coordinate of the region
|
|
54
|
-
:param rz: The y coordinate of the region
|
|
55
|
-
:return: The resulting minimum chunk coordinates of that region in (x, z) order
|
|
56
|
-
"""
|
|
57
|
-
return rx << 5, rz << 5
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
def blocks_slice_to_chunk_slice(
|
|
61
|
-
blocks_slice: slice, chunk_shape: int, chunk_coord: int
|
|
62
|
-
) -> slice:
|
|
63
|
-
"""
|
|
64
|
-
Converts the supplied blocks slice into chunk slice
|
|
65
|
-
|
|
66
|
-
:param blocks_slice: The slice of the blocks
|
|
67
|
-
:param chunk_shape: The shape of the chunk in this direction
|
|
68
|
-
:param chunk_coord: The coordinate of the chunk in this direction
|
|
69
|
-
:return: The resulting chunk slice
|
|
70
|
-
"""
|
|
71
|
-
return slice(
|
|
72
|
-
min(max(0, blocks_slice.start - chunk_coord * chunk_shape), chunk_shape),
|
|
73
|
-
min(max(0, blocks_slice.stop - chunk_coord * chunk_shape), chunk_shape),
|
|
74
|
-
)
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
def from_nibble_array(arr: ndarray) -> ndarray:
|
|
78
|
-
"""
|
|
79
|
-
Unpacks a flat nibble array into a full size numpy array
|
|
80
|
-
|
|
81
|
-
:param arr: The nibble array
|
|
82
|
-
:return: The resulting array
|
|
83
|
-
"""
|
|
84
|
-
shape = arr.size
|
|
85
|
-
|
|
86
|
-
new_arr = zeros((shape * 2), dtype=uint8)
|
|
87
|
-
|
|
88
|
-
new_arr[::2] = arr & 0xF
|
|
89
|
-
new_arr[1::2] = arr >> 4
|
|
90
|
-
|
|
91
|
-
return new_arr
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
def to_nibble_array(arr: ndarray) -> ndarray:
|
|
95
|
-
"""
|
|
96
|
-
packs a full size numpy array into a nibble array.
|
|
97
|
-
|
|
98
|
-
:param arr: Full numpy array
|
|
99
|
-
:return: The nibble array
|
|
100
|
-
"""
|
|
101
|
-
arr = arr.ravel()
|
|
102
|
-
return (arr[::2] + (arr[1::2] << 4)).astype(uint8) # type: ignore
|
amulet/version.cpp
DELETED
|
@@ -1,136 +0,0 @@
|
|
|
1
|
-
#include <stdexcept>
|
|
2
|
-
#include <cstdint>
|
|
3
|
-
#include <compare>
|
|
4
|
-
|
|
5
|
-
#include <amulet/version.hpp>
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
namespace Amulet {
|
|
9
|
-
void VersionNumber::serialise(BinaryWriter& writer) const {
|
|
10
|
-
writer.writeNumeric<std::uint8_t>(1);
|
|
11
|
-
writer.writeNumeric<std::uint64_t>(vec.size());
|
|
12
|
-
for (const std::int64_t& v : vec){
|
|
13
|
-
writer.writeNumeric<std::int64_t>(v);
|
|
14
|
-
}
|
|
15
|
-
}
|
|
16
|
-
std::shared_ptr<VersionNumber> VersionNumber::deserialise(BinaryReader& reader){
|
|
17
|
-
auto version_number = reader.readNumeric<std::uint8_t>();
|
|
18
|
-
switch (version_number) {
|
|
19
|
-
case 1:
|
|
20
|
-
{
|
|
21
|
-
std::uint64_t count;
|
|
22
|
-
reader.readNumericInto(count);
|
|
23
|
-
std::vector<std::int64_t> vec(count);
|
|
24
|
-
for (size_t i = 0; i < count; i++) {
|
|
25
|
-
reader.readNumericInto<std::int64_t>(vec[i]);
|
|
26
|
-
}
|
|
27
|
-
return std::make_shared<VersionNumber>(vec);
|
|
28
|
-
}
|
|
29
|
-
default:
|
|
30
|
-
throw std::invalid_argument("Unsupported version " + std::to_string(version_number));
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
std::int64_t VersionNumber::operator[](size_t index) const {
|
|
35
|
-
if (index >= vec.size()) {
|
|
36
|
-
return 0;
|
|
37
|
-
}
|
|
38
|
-
return vec[index];
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
std::string VersionNumber::toString() const {
|
|
42
|
-
std::ostringstream oss;
|
|
43
|
-
for (size_t i = 0; i < vec.size(); ++i) {
|
|
44
|
-
if (i > 0){
|
|
45
|
-
oss << '.';
|
|
46
|
-
}
|
|
47
|
-
oss << vec[i];
|
|
48
|
-
}
|
|
49
|
-
return oss.str();
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
std::vector<std::int64_t> VersionNumber::cropped_version() const {
|
|
53
|
-
bool found_non_zero = false;
|
|
54
|
-
std::vector<std::int64_t> out;
|
|
55
|
-
for (auto it = vec.rbegin(); it != vec.rend(); ++it) {
|
|
56
|
-
if (found_non_zero){
|
|
57
|
-
out.push_back(*it);
|
|
58
|
-
} else if (*it != 0) {
|
|
59
|
-
found_non_zero = true;
|
|
60
|
-
out.push_back(*it);
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
std::reverse(out.begin(), out.end());
|
|
64
|
-
return out;
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
std::vector<std::int64_t> VersionNumber::padded_version(size_t len) const {
|
|
68
|
-
std::vector<std::int64_t> out(len);
|
|
69
|
-
for (size_t i = 0; i < len; i++){
|
|
70
|
-
out[i] = (*this)[i];
|
|
71
|
-
}
|
|
72
|
-
return out;
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
void PlatformVersionContainer::serialise(BinaryWriter& writer) const {
|
|
76
|
-
writer.writeNumeric<std::uint8_t>(1);
|
|
77
|
-
writer.writeSizeAndBytes(platform);
|
|
78
|
-
version->serialise(writer);
|
|
79
|
-
}
|
|
80
|
-
std::shared_ptr<PlatformVersionContainer> PlatformVersionContainer::deserialise(BinaryReader& reader){
|
|
81
|
-
auto version_number = reader.readNumeric<std::uint8_t>();
|
|
82
|
-
switch (version_number) {
|
|
83
|
-
case 1:
|
|
84
|
-
{
|
|
85
|
-
std::string platform = reader.readSizeAndBytes();
|
|
86
|
-
auto version = VersionNumber::deserialise(reader);
|
|
87
|
-
return std::make_shared<PlatformVersionContainer>(platform, version);
|
|
88
|
-
}
|
|
89
|
-
default:
|
|
90
|
-
throw std::invalid_argument("Unsupported version " + std::to_string(version_number));
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
void VersionRange::serialise(BinaryWriter& writer) const {
|
|
95
|
-
writer.writeNumeric<std::uint8_t>(1);
|
|
96
|
-
writer.writeSizeAndBytes(platform);
|
|
97
|
-
min_version->serialise(writer);
|
|
98
|
-
max_version->serialise(writer);
|
|
99
|
-
}
|
|
100
|
-
std::shared_ptr<VersionRange> VersionRange::deserialise(BinaryReader& reader) {
|
|
101
|
-
auto version_number = reader.readNumeric<std::uint8_t>();
|
|
102
|
-
switch (version_number) {
|
|
103
|
-
case 1:
|
|
104
|
-
{
|
|
105
|
-
std::string platform = reader.readSizeAndBytes();
|
|
106
|
-
auto min_version = VersionNumber::deserialise(reader);
|
|
107
|
-
auto max_version = VersionNumber::deserialise(reader);
|
|
108
|
-
return std::make_shared<VersionRange>(platform, min_version, max_version);
|
|
109
|
-
}
|
|
110
|
-
default:
|
|
111
|
-
throw std::invalid_argument("Unsupported version " + std::to_string(version_number));
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
bool VersionRange::contains(const PlatformType& platform_, const VersionNumber& version) const {
|
|
116
|
-
return platform == platform_ && *min_version <= version && version <= *max_version;
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
void VersionRangeContainer::serialise(BinaryWriter& writer) const {
|
|
120
|
-
writer.writeNumeric<std::uint8_t>(1);
|
|
121
|
-
version_range->serialise(writer);
|
|
122
|
-
}
|
|
123
|
-
std::shared_ptr<VersionRangeContainer> VersionRangeContainer::deserialise(BinaryReader& reader) {
|
|
124
|
-
auto version_number = reader.readNumeric<std::uint8_t>();
|
|
125
|
-
switch (version_number) {
|
|
126
|
-
case 1:
|
|
127
|
-
{
|
|
128
|
-
return std::make_shared<VersionRangeContainer>(
|
|
129
|
-
VersionRange::deserialise(reader)
|
|
130
|
-
);
|
|
131
|
-
}
|
|
132
|
-
default:
|
|
133
|
-
throw std::invalid_argument("Unsupported version " + std::to_string(version_number));
|
|
134
|
-
}
|
|
135
|
-
}
|
|
136
|
-
}
|
amulet/version.hpp
DELETED
|
@@ -1,142 +0,0 @@
|
|
|
1
|
-
#pragma once
|
|
2
|
-
|
|
3
|
-
#include <cstdint>
|
|
4
|
-
#include <vector>
|
|
5
|
-
#include <string>
|
|
6
|
-
#include <sstream>
|
|
7
|
-
#include <memory>
|
|
8
|
-
#include <algorithm>
|
|
9
|
-
#include <initializer_list>
|
|
10
|
-
|
|
11
|
-
#include <amulet/io/binary_reader.hpp>
|
|
12
|
-
#include <amulet/io/binary_writer.hpp>
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
namespace Amulet {
|
|
16
|
-
typedef std::string PlatformType;
|
|
17
|
-
class VersionNumber {
|
|
18
|
-
private:
|
|
19
|
-
std::vector<std::int64_t> vec;
|
|
20
|
-
public:
|
|
21
|
-
const std::vector<std::int64_t>& get_vector() const { return vec; }
|
|
22
|
-
|
|
23
|
-
VersionNumber(std::initializer_list<std::int64_t> vec) : vec(vec) {};
|
|
24
|
-
VersionNumber(const std::vector<std::int64_t>& vec) : vec(vec) {};
|
|
25
|
-
|
|
26
|
-
void serialise(BinaryWriter&) const;
|
|
27
|
-
static std::shared_ptr<VersionNumber> deserialise(BinaryReader&);
|
|
28
|
-
|
|
29
|
-
std::vector<std::int64_t>::const_iterator begin() const { return vec.begin(); };
|
|
30
|
-
std::vector<std::int64_t>::const_iterator end() const { return vec.end(); };
|
|
31
|
-
std::vector<std::int64_t>::const_reverse_iterator rbegin() const { return vec.rbegin(); };
|
|
32
|
-
std::vector<std::int64_t>::const_reverse_iterator rend() const { return vec.rend(); };
|
|
33
|
-
size_t size() const { return vec.size(); };
|
|
34
|
-
std::int64_t operator[](size_t index) const;
|
|
35
|
-
auto operator<=>(const VersionNumber& other) const {
|
|
36
|
-
size_t max_len = std::max(vec.size(), other.size());
|
|
37
|
-
std::int64_t v1, v2;
|
|
38
|
-
for (size_t i = 0; i < max_len; i++) {
|
|
39
|
-
v1 = (*this)[i];
|
|
40
|
-
v2 = other[i];
|
|
41
|
-
if (v1 < v2) {
|
|
42
|
-
// Less than
|
|
43
|
-
return std::strong_ordering::less;
|
|
44
|
-
}
|
|
45
|
-
if (v1 > v2) {
|
|
46
|
-
// Greater than
|
|
47
|
-
return std::strong_ordering::greater;
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
// equal
|
|
51
|
-
return std::strong_ordering::equal;
|
|
52
|
-
}
|
|
53
|
-
bool operator==(const VersionNumber& other) const {
|
|
54
|
-
return (*this <=> other) == 0;
|
|
55
|
-
};
|
|
56
|
-
std::string toString() const;
|
|
57
|
-
std::vector<std::int64_t> cropped_version() const;
|
|
58
|
-
std::vector<std::int64_t> padded_version(size_t len) const;
|
|
59
|
-
};
|
|
60
|
-
|
|
61
|
-
class PlatformVersionContainer {
|
|
62
|
-
private:
|
|
63
|
-
PlatformType platform;
|
|
64
|
-
std::shared_ptr<VersionNumber> version;
|
|
65
|
-
public:
|
|
66
|
-
const PlatformType& get_platform() const { return platform; }
|
|
67
|
-
std::shared_ptr<VersionNumber> get_version() const { return version; }
|
|
68
|
-
|
|
69
|
-
template <typename versionT>
|
|
70
|
-
PlatformVersionContainer(
|
|
71
|
-
const PlatformType& platform,
|
|
72
|
-
const versionT& version
|
|
73
|
-
) :
|
|
74
|
-
platform(platform),
|
|
75
|
-
version([&]{
|
|
76
|
-
if constexpr (std::is_same_v<versionT, std::shared_ptr<VersionNumber>>){
|
|
77
|
-
if (!version) { throw std::runtime_error("Version is nullptr"); }
|
|
78
|
-
return version;
|
|
79
|
-
}
|
|
80
|
-
else {
|
|
81
|
-
return std::make_shared<VersionNumber>(version);
|
|
82
|
-
}
|
|
83
|
-
}())
|
|
84
|
-
{};
|
|
85
|
-
|
|
86
|
-
void serialise(BinaryWriter&) const;
|
|
87
|
-
static std::shared_ptr<PlatformVersionContainer> deserialise(BinaryReader&);
|
|
88
|
-
|
|
89
|
-
auto operator<=>(const PlatformVersionContainer& other) const {
|
|
90
|
-
auto cmp = platform <=> other.platform;
|
|
91
|
-
if (cmp != 0) { return cmp; }
|
|
92
|
-
return *version <=> *other.version;
|
|
93
|
-
}
|
|
94
|
-
bool operator==(const PlatformVersionContainer& other) const {
|
|
95
|
-
return (*this <=> other) == 0;
|
|
96
|
-
};
|
|
97
|
-
};
|
|
98
|
-
|
|
99
|
-
class VersionRange {
|
|
100
|
-
private:
|
|
101
|
-
PlatformType platform;
|
|
102
|
-
std::shared_ptr<VersionNumber> min_version;
|
|
103
|
-
std::shared_ptr<VersionNumber> max_version;
|
|
104
|
-
public:
|
|
105
|
-
const PlatformType& get_platform() const { return platform; }
|
|
106
|
-
std::shared_ptr<VersionNumber> get_min_version() const { return min_version; }
|
|
107
|
-
std::shared_ptr<VersionNumber> get_max_version() const { return max_version; }
|
|
108
|
-
|
|
109
|
-
VersionRange(
|
|
110
|
-
const PlatformType& platform,
|
|
111
|
-
std::shared_ptr<VersionNumber> min_version,
|
|
112
|
-
std::shared_ptr<VersionNumber> max_version
|
|
113
|
-
) :
|
|
114
|
-
platform(platform),
|
|
115
|
-
min_version(min_version),
|
|
116
|
-
max_version(max_version)
|
|
117
|
-
{
|
|
118
|
-
if (*min_version > *max_version) {
|
|
119
|
-
throw std::invalid_argument("min_version must be less than or equal to max_version");
|
|
120
|
-
}
|
|
121
|
-
};
|
|
122
|
-
|
|
123
|
-
void serialise(BinaryWriter&) const;
|
|
124
|
-
static std::shared_ptr<VersionRange> deserialise(BinaryReader&);
|
|
125
|
-
|
|
126
|
-
bool contains(const PlatformType& platform_, const VersionNumber& version) const;
|
|
127
|
-
};
|
|
128
|
-
|
|
129
|
-
class VersionRangeContainer {
|
|
130
|
-
private:
|
|
131
|
-
std::shared_ptr<const VersionRange> version_range;
|
|
132
|
-
public:
|
|
133
|
-
std::shared_ptr<const VersionRange> get_version_range() const { return version_range; }
|
|
134
|
-
|
|
135
|
-
VersionRangeContainer(
|
|
136
|
-
std::shared_ptr<VersionRange> version_range
|
|
137
|
-
): version_range(version_range) {}
|
|
138
|
-
|
|
139
|
-
void serialise(BinaryWriter&) const;
|
|
140
|
-
static std::shared_ptr<VersionRangeContainer> deserialise(BinaryReader&);
|
|
141
|
-
};
|
|
142
|
-
}
|
amulet/version.py.cpp
DELETED
|
@@ -1,281 +0,0 @@
|
|
|
1
|
-
#include <sstream>
|
|
2
|
-
|
|
3
|
-
#include <pybind11/pybind11.h>
|
|
4
|
-
#include <pybind11/stl.h>
|
|
5
|
-
#include <pybind11/operators.h>
|
|
6
|
-
|
|
7
|
-
#include <amulet/collections/eq.py.hpp>
|
|
8
|
-
#include <amulet/version.hpp>
|
|
9
|
-
|
|
10
|
-
namespace py = pybind11;
|
|
11
|
-
|
|
12
|
-
void init_version(py::module m_parent) {
|
|
13
|
-
auto m = m_parent.def_submodule("version");
|
|
14
|
-
py::options options;
|
|
15
|
-
|
|
16
|
-
m.attr("PlatformType") = py::module::import("builtins").attr("str");
|
|
17
|
-
|
|
18
|
-
py::class_<Amulet::VersionNumber, std::shared_ptr<Amulet::VersionNumber>> VersionNumber(m, "VersionNumber",
|
|
19
|
-
"This class is designed to store semantic versions and data versions and allow comparisons between them.\n"
|
|
20
|
-
"\n"
|
|
21
|
-
">>> v1 = VersionNumber(1, 0, 0)\n"
|
|
22
|
-
">>> v2 = VersionNumber(1, 0)\n"
|
|
23
|
-
">>> assert v2 == v1\n"
|
|
24
|
-
"\n"
|
|
25
|
-
"This class should also be used to store single number data versions.\n"
|
|
26
|
-
">>> v3 = VersionNumber(3578)"
|
|
27
|
-
);
|
|
28
|
-
options.disable_function_signatures();
|
|
29
|
-
VersionNumber.def(
|
|
30
|
-
py::init(
|
|
31
|
-
[](py::args v){
|
|
32
|
-
return std::make_shared<Amulet::VersionNumber>(
|
|
33
|
-
v.cast<std::vector<std::int64_t>>()
|
|
34
|
-
);
|
|
35
|
-
}
|
|
36
|
-
),
|
|
37
|
-
py::doc("__init__(self: amulet.version.VersionNumber, *args: typing.SupportsInt) -> None")
|
|
38
|
-
);
|
|
39
|
-
|
|
40
|
-
// Start collections.abc.Sequence
|
|
41
|
-
VersionNumber.def(
|
|
42
|
-
"__getitem__",
|
|
43
|
-
&Amulet::VersionNumber::operator[],
|
|
44
|
-
py::doc(
|
|
45
|
-
"__getitem__(*args, **kwargs)\n"
|
|
46
|
-
"Overloaded function.\n"
|
|
47
|
-
"1. __getitem__(self: amulet.version.VersionNumber, item: typing.SupportsInt) -> int\n"
|
|
48
|
-
"2. __getitem__(self: amulet.version.VersionNumber, item: slice) -> list[int]"
|
|
49
|
-
)
|
|
50
|
-
);
|
|
51
|
-
VersionNumber.def(
|
|
52
|
-
"__getitem__",
|
|
53
|
-
[](const Amulet::VersionNumber& self, const py::slice &slice) -> std::vector<std::int64_t> {
|
|
54
|
-
size_t start = 0, stop = 0, step = 0, slicelength = 0;
|
|
55
|
-
if (!slice.compute(self.size(), &start, &stop, &step, &slicelength)) {
|
|
56
|
-
throw py::error_already_set();
|
|
57
|
-
}
|
|
58
|
-
std::vector<std::int64_t> out(slicelength);
|
|
59
|
-
for (size_t i = 0; i < slicelength; ++i) {
|
|
60
|
-
out[i] = self[start];
|
|
61
|
-
start += step;
|
|
62
|
-
}
|
|
63
|
-
return out;
|
|
64
|
-
}
|
|
65
|
-
);
|
|
66
|
-
options.enable_function_signatures();
|
|
67
|
-
|
|
68
|
-
VersionNumber.def(
|
|
69
|
-
"__repr__",
|
|
70
|
-
[](const Amulet::VersionNumber& self){
|
|
71
|
-
std::ostringstream oss;
|
|
72
|
-
auto& vec = self.get_vector();
|
|
73
|
-
oss << "VersionNumber(";
|
|
74
|
-
for (size_t i = 0; i < vec.size(); i++){
|
|
75
|
-
if (i != 0){
|
|
76
|
-
oss << ", ";
|
|
77
|
-
}
|
|
78
|
-
oss << vec[i];
|
|
79
|
-
}
|
|
80
|
-
oss << ")";
|
|
81
|
-
return oss.str();
|
|
82
|
-
}
|
|
83
|
-
);
|
|
84
|
-
VersionNumber.def(
|
|
85
|
-
py::pickle(
|
|
86
|
-
[](const Amulet::VersionNumber& self) {
|
|
87
|
-
return py::bytes(Amulet::serialise(self));
|
|
88
|
-
},
|
|
89
|
-
[](py::bytes state){
|
|
90
|
-
return Amulet::deserialise<Amulet::VersionNumber>(state.cast<std::string>());
|
|
91
|
-
}
|
|
92
|
-
)
|
|
93
|
-
);
|
|
94
|
-
|
|
95
|
-
VersionNumber.def(
|
|
96
|
-
"__len__",
|
|
97
|
-
&Amulet::VersionNumber::size
|
|
98
|
-
);
|
|
99
|
-
|
|
100
|
-
VersionNumber.def(
|
|
101
|
-
"__contains__",
|
|
102
|
-
[](const Amulet::VersionNumber& self, std::int64_t value) {
|
|
103
|
-
for (auto it = self.begin(); it != self.end(); it++){
|
|
104
|
-
if (*it == value) return true;
|
|
105
|
-
}
|
|
106
|
-
return false;
|
|
107
|
-
}
|
|
108
|
-
);
|
|
109
|
-
|
|
110
|
-
VersionNumber.def(
|
|
111
|
-
"__iter__",
|
|
112
|
-
[](const Amulet::VersionNumber& self) {return py::make_iterator(self.begin(), self.end());},
|
|
113
|
-
py::keep_alive<0, 1>() /* Essential: keep object alive while iterator exists */
|
|
114
|
-
);
|
|
115
|
-
|
|
116
|
-
VersionNumber.def(
|
|
117
|
-
"__reversed__",
|
|
118
|
-
[](const Amulet::VersionNumber& self) {return py::make_iterator(self.rbegin(), self.rend());},
|
|
119
|
-
py::keep_alive<0, 1>() /* Essential: keep object alive while iterator exists */
|
|
120
|
-
);
|
|
121
|
-
|
|
122
|
-
VersionNumber.def(
|
|
123
|
-
"index",
|
|
124
|
-
[](const Amulet::VersionNumber& self, std::int64_t value, size_t start, size_t stop) {
|
|
125
|
-
start = std::min(start, self.size());
|
|
126
|
-
stop = std::min(stop, self.size());
|
|
127
|
-
for (size_t i = start; i < stop; i++){
|
|
128
|
-
if (self[i] == value) return i;
|
|
129
|
-
}
|
|
130
|
-
throw py::value_error(std::to_string(value) + " is not in VersionNumber.");
|
|
131
|
-
},
|
|
132
|
-
py::arg("value"), py::arg("start") = 0, py::arg("stop") = std::numeric_limits<size_t>::max()
|
|
133
|
-
);
|
|
134
|
-
|
|
135
|
-
VersionNumber.def(
|
|
136
|
-
"count",
|
|
137
|
-
[](const Amulet::VersionNumber& self, std::int64_t value) {
|
|
138
|
-
size_t count = 0;
|
|
139
|
-
for (size_t i = 0; i < self.size(); i++){
|
|
140
|
-
if (self[i] == value) ++count;
|
|
141
|
-
}
|
|
142
|
-
return count;
|
|
143
|
-
},
|
|
144
|
-
py::arg("value")
|
|
145
|
-
);
|
|
146
|
-
|
|
147
|
-
// End collections.abc.Sequence
|
|
148
|
-
|
|
149
|
-
VersionNumber.def(
|
|
150
|
-
"__str__",
|
|
151
|
-
&Amulet::VersionNumber::toString
|
|
152
|
-
);
|
|
153
|
-
|
|
154
|
-
Eq(VersionNumber);
|
|
155
|
-
Eq_default(VersionNumber);
|
|
156
|
-
VersionNumber.def(pybind11::self < pybind11::self);
|
|
157
|
-
VersionNumber.def(pybind11::self > pybind11::self);
|
|
158
|
-
VersionNumber.def(pybind11::self <= pybind11::self);
|
|
159
|
-
VersionNumber.def(pybind11::self >= pybind11::self);
|
|
160
|
-
|
|
161
|
-
VersionNumber.def(
|
|
162
|
-
"cropped_version",
|
|
163
|
-
[](const Amulet::VersionNumber& self) -> py::tuple {return py::cast(self.cropped_version());},
|
|
164
|
-
py::doc("The version number with trailing zeros cut off.")
|
|
165
|
-
);
|
|
166
|
-
|
|
167
|
-
VersionNumber.def(
|
|
168
|
-
"padded_version",
|
|
169
|
-
[](const Amulet::VersionNumber& self, size_t len) -> py::tuple {return py::cast(self.padded_version(len));},
|
|
170
|
-
py::doc("Get the version number padded with zeros to the given length."),
|
|
171
|
-
py::arg("len")
|
|
172
|
-
);
|
|
173
|
-
|
|
174
|
-
VersionNumber.def(
|
|
175
|
-
"__hash__",
|
|
176
|
-
[](const Amulet::VersionNumber& self) {
|
|
177
|
-
py::tuple py_tuple = py::cast(self.cropped_version());
|
|
178
|
-
return py::hash(py_tuple);
|
|
179
|
-
}
|
|
180
|
-
);
|
|
181
|
-
|
|
182
|
-
py::module::import("collections.abc").attr("Sequence").attr("register")(VersionNumber);
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
py::class_<Amulet::PlatformVersionContainer, std::shared_ptr<Amulet::PlatformVersionContainer>> PlatformVersionContainer(m, "PlatformVersionContainer");
|
|
186
|
-
PlatformVersionContainer.def(
|
|
187
|
-
py::init<
|
|
188
|
-
const Amulet::PlatformType&,
|
|
189
|
-
std::shared_ptr<Amulet::VersionNumber>
|
|
190
|
-
>(),
|
|
191
|
-
py::arg("platform"),
|
|
192
|
-
py::arg("version")
|
|
193
|
-
);
|
|
194
|
-
PlatformVersionContainer.def_property_readonly("platform", &Amulet::PlatformVersionContainer::get_platform);
|
|
195
|
-
PlatformVersionContainer.def_property_readonly("version", &Amulet::PlatformVersionContainer::get_version);
|
|
196
|
-
PlatformVersionContainer.def(
|
|
197
|
-
"__repr__",
|
|
198
|
-
[](const Amulet::PlatformVersionContainer& self){
|
|
199
|
-
return "PlatformVersionContainer(" +
|
|
200
|
-
py::repr(py::cast(self.get_platform())).cast<std::string>() + ", " +
|
|
201
|
-
py::repr(py::cast(self.get_version())).cast<std::string>() +
|
|
202
|
-
")";
|
|
203
|
-
}
|
|
204
|
-
);
|
|
205
|
-
PlatformVersionContainer.def(
|
|
206
|
-
py::pickle(
|
|
207
|
-
[](const Amulet::PlatformVersionContainer& self) -> py::bytes {
|
|
208
|
-
return py::bytes(Amulet::serialise(self));
|
|
209
|
-
},
|
|
210
|
-
[](py::bytes state){
|
|
211
|
-
return Amulet::deserialise<Amulet::PlatformVersionContainer>(state.cast<std::string>());
|
|
212
|
-
}
|
|
213
|
-
)
|
|
214
|
-
);
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
py::class_<Amulet::VersionRange, std::shared_ptr<Amulet::VersionRange>> VersionRange(m, "VersionRange");
|
|
218
|
-
VersionRange.def(
|
|
219
|
-
py::init<
|
|
220
|
-
const Amulet::PlatformType&,
|
|
221
|
-
std::shared_ptr<Amulet::VersionNumber>,
|
|
222
|
-
std::shared_ptr<Amulet::VersionNumber>
|
|
223
|
-
>(),
|
|
224
|
-
py::arg("platform"),
|
|
225
|
-
py::arg("min_version"),
|
|
226
|
-
py::arg("max_version")
|
|
227
|
-
);
|
|
228
|
-
VersionRange.def_property_readonly("platform", &Amulet::VersionRange::get_platform);
|
|
229
|
-
VersionRange.def_property_readonly("min_version", &Amulet::VersionRange::get_min_version);
|
|
230
|
-
VersionRange.def_property_readonly("max_version", &Amulet::VersionRange::get_max_version);
|
|
231
|
-
VersionRange.def(
|
|
232
|
-
"contains",
|
|
233
|
-
&Amulet::VersionRange::contains
|
|
234
|
-
);
|
|
235
|
-
VersionRange.def(
|
|
236
|
-
"__repr__",
|
|
237
|
-
[](const Amulet::VersionRange& self){
|
|
238
|
-
return "VersionRange(" +
|
|
239
|
-
py::repr(py::cast(self.get_platform())).cast<std::string>() + ", " +
|
|
240
|
-
py::repr(py::cast(self.get_min_version())).cast<std::string>() + ", " +
|
|
241
|
-
py::repr(py::cast(self.get_max_version())).cast<std::string>() +
|
|
242
|
-
")";
|
|
243
|
-
}
|
|
244
|
-
);
|
|
245
|
-
VersionRange.def(
|
|
246
|
-
py::pickle(
|
|
247
|
-
[](const Amulet::VersionRange& self) -> py::bytes {
|
|
248
|
-
return py::bytes(Amulet::serialise(self));
|
|
249
|
-
},
|
|
250
|
-
[](py::bytes state){
|
|
251
|
-
return Amulet::deserialise<Amulet::VersionRange>(state.cast<std::string>());
|
|
252
|
-
}
|
|
253
|
-
)
|
|
254
|
-
);
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
py::class_<Amulet::VersionRangeContainer, std::shared_ptr<Amulet::VersionRangeContainer>> VersionRangeContainer(m, "VersionRangeContainer");
|
|
258
|
-
VersionRangeContainer.def(
|
|
259
|
-
py::init<
|
|
260
|
-
std::shared_ptr<Amulet::VersionRange>
|
|
261
|
-
>(),
|
|
262
|
-
py::arg("version_range")
|
|
263
|
-
);
|
|
264
|
-
VersionRangeContainer.def_property_readonly("version_range", &Amulet::VersionRangeContainer::get_version_range);
|
|
265
|
-
VersionRangeContainer.def(
|
|
266
|
-
"__repr__",
|
|
267
|
-
[](const Amulet::VersionRangeContainer& self){
|
|
268
|
-
return "VersionRangeContainer(" + py::repr(py::cast(self.get_version_range())).cast<std::string>() + ")";
|
|
269
|
-
}
|
|
270
|
-
);
|
|
271
|
-
VersionRangeContainer.def(
|
|
272
|
-
py::pickle(
|
|
273
|
-
[](const Amulet::VersionRangeContainer& self) -> py::bytes {
|
|
274
|
-
return py::bytes(Amulet::serialise(self));
|
|
275
|
-
},
|
|
276
|
-
[](py::bytes state){
|
|
277
|
-
return Amulet::deserialise<Amulet::VersionRangeContainer>(state.cast<std::string>());
|
|
278
|
-
}
|
|
279
|
-
)
|
|
280
|
-
);
|
|
281
|
-
}
|