| 1 |
From 57a213434cc843f7783f12157a9a46ab1a2c1e06 Mon Sep 17 00:00:00 2001 |
| 2 |
From: Alexis Mousset <[email protected]> |
| 3 |
Date: Wed, 9 Oct 2024 20:43:29 +0200 |
| 4 |
Subject: [PATCH 1/2] Fix 32bits support |
| 5 |
|
| 6 |
Forwarded: https://gitlab.com/volian/rust-apt/-/merge_requests/57 |
| 7 |
--- |
| 8 |
apt-pkg-c/package.h | 8 ++++++++ |
| 9 |
src/iterators/dependency.rs | 3 +-- |
| 10 |
src/iterators/files.rs | 9 +++------ |
| 11 |
src/iterators/package.rs | 3 +-- |
| 12 |
src/iterators/provider.rs | 3 +-- |
| 13 |
src/iterators/version.rs | 3 +-- |
| 14 |
src/records.rs | 4 ++-- |
| 15 |
7 files changed, 17 insertions(+), 16 deletions(-) |
| 16 |
|
| 17 |
--- a/apt-pkg-c/package.h |
| 18 |
+++ b/apt-pkg-c/package.h |
| 19 |
@@ -17,6 +17,7 @@ |
| 20 |
u8 dep_type() const { return (*this)->Type; } |
| 21 |
str comp_type() const { return handle_str(this->CompType()); } |
| 22 |
str target_ver() const { return handle_str(this->TargetVer()); } |
| 23 |
+ std::size_t index() const { return this->Index(); } |
| 24 |
|
| 25 |
inline bool or_dep() const { |
| 26 |
return ((*this)->CompareOp & pkgCache::Dep::Or) == pkgCache::Dep::Or; |
| 27 |
@@ -35,6 +36,7 @@ |
| 28 |
|
| 29 |
str name() const { return this->Name(); } |
| 30 |
str version_str() const { return handle_str(this->ProvideVersion()); } |
| 31 |
+ std::size_t index() const { return this->Index(); } |
| 32 |
|
| 33 |
UniquePtr<PkgIterator> target_pkg() const; |
| 34 |
UniquePtr<VerIterator> target_ver() const; |
| 35 |
@@ -56,6 +58,7 @@ |
| 36 |
str component() const { return handle_str(this->Component()); } |
| 37 |
str arch() const { return handle_str(this->Architecture()); } |
| 38 |
str index_type() const { return handle_str(this->IndexType()); } |
| 39 |
+ std::size_t index() const { return this->Index(); } |
| 40 |
|
| 41 |
bool is_downloadable() const { return !this->Flagged(pkgCache::Flag::NotSource); } |
| 42 |
|
| 43 |
@@ -66,6 +69,7 @@ |
| 44 |
|
| 45 |
struct VerFileIterator : public pkgCache::VerFileIterator { |
| 46 |
void raw_next() { (*this)++; } |
| 47 |
+ std::size_t index() const { return this->Index(); } |
| 48 |
|
| 49 |
UniquePtr<VerFileIterator> unique() const { return std::make_unique<VerFileIterator>(*this); } |
| 50 |
|
| 51 |
@@ -78,6 +82,7 @@ |
| 52 |
|
| 53 |
struct DescIterator : public pkgCache::DescIterator { |
| 54 |
void raw_next() { (*this)++; } |
| 55 |
+ std::size_t index() const { return this->Index(); } |
| 56 |
|
| 57 |
UniquePtr<DescIterator> unique() const { return std::make_unique<DescIterator>(*this); } |
| 58 |
|
| 59 |
@@ -97,6 +102,7 @@ |
| 60 |
u64 installed_size() const { return (*this)->InstalledSize; } |
| 61 |
// TODO: Move this into rust? |
| 62 |
bool is_installed() const { return this->ParentPkg().CurrentVer() == *this; } |
| 63 |
+ std::size_t index() const { return this->Index(); } |
| 64 |
|
| 65 |
UniquePtr<PkgIterator> parent_pkg() const; |
| 66 |
|
| 67 |
@@ -124,6 +130,7 @@ |
| 68 |
VerIterator(const pkgCache::VerIterator& base) : pkgCache::VerIterator(base){}; |
| 69 |
}; |
| 70 |
|
| 71 |
+ |
| 72 |
struct PkgIterator : public pkgCache::PkgIterator { |
| 73 |
void raw_next() { (*this)++; } |
| 74 |
|
| 75 |
@@ -133,6 +140,7 @@ |
| 76 |
u8 current_state() const { return (*this)->CurrentState; } |
| 77 |
u8 inst_state() const { return (*this)->InstState; } |
| 78 |
u8 selected_state() const { return (*this)->SelectedState; } |
| 79 |
+ std::size_t index() const { return this->Index(); } |
| 80 |
|
| 81 |
/// True if the package is essential. |
| 82 |
bool is_essential() const { return ((*this)->Flags & pkgCache::Flag::Essential) != 0; } |
| 83 |
--- a/src/iterators/dependency.rs |
| 84 |
+++ b/src/iterators/dependency.rs |
| 85 |
@@ -330,8 +330,7 @@ |
| 86 |
/// or group will return False. |
| 87 |
pub fn or_dep(self: &DepIterator) -> bool; |
| 88 |
|
| 89 |
- #[cxx_name = "Index"] |
| 90 |
- pub fn index(self: &DepIterator) -> u64; |
| 91 |
+ pub fn index(self: &DepIterator) -> usize; |
| 92 |
/// Clone the pointer. |
| 93 |
/// |
| 94 |
/// # Safety |
| 95 |
--- a/src/iterators/files.rs |
| 96 |
+++ b/src/iterators/files.rs |
| 97 |
@@ -120,8 +120,7 @@ |
| 98 |
pub fn is_downloadable(self: &PkgFileIterator) -> bool; |
| 99 |
|
| 100 |
/// The Index number of the PackageFile |
| 101 |
- #[cxx_name = "Index"] |
| 102 |
- pub fn index(self: &PkgFileIterator) -> u64; |
| 103 |
+ pub fn index(self: &PkgFileIterator) -> usize; |
| 104 |
/// Clone the pointer. |
| 105 |
/// |
| 106 |
/// # Safety |
| 107 |
@@ -148,8 +147,7 @@ |
| 108 |
/// The returned UniquePtr cannot outlive the cache. |
| 109 |
unsafe fn package_file(self: &VerFileIterator) -> UniquePtr<PkgFileIterator>; |
| 110 |
|
| 111 |
- #[cxx_name = "Index"] |
| 112 |
- pub fn index(self: &VerFileIterator) -> u64; |
| 113 |
+ pub fn index(self: &VerFileIterator) -> usize; |
| 114 |
/// Clone the pointer. |
| 115 |
/// |
| 116 |
/// # Safety |
| 117 |
@@ -164,8 +162,7 @@ |
| 118 |
pub fn raw_next(self: Pin<&mut VerFileIterator>); |
| 119 |
pub fn end(self: &VerFileIterator) -> bool; |
| 120 |
|
| 121 |
- #[cxx_name = "Index"] |
| 122 |
- pub fn index(self: &DescIterator) -> u64; |
| 123 |
+ pub fn index(self: &DescIterator) -> usize; |
| 124 |
/// Clone the pointer. |
| 125 |
/// |
| 126 |
/// # Safety |
| 127 |
--- a/src/iterators/package.rs |
| 128 |
+++ b/src/iterators/package.rs |
| 129 |
@@ -451,8 +451,7 @@ |
| 130 |
/// The returned UniquePtr cannot outlive the cache. |
| 131 |
unsafe fn rdepends(self: &PkgIterator) -> UniquePtr<DepIterator>; |
| 132 |
|
| 133 |
- #[cxx_name = "Index"] |
| 134 |
- pub fn index(self: &PkgIterator) -> u64; |
| 135 |
+ pub fn index(self: &PkgIterator) -> usize; |
| 136 |
/// Clone the pointer. |
| 137 |
/// |
| 138 |
/// # Safety |
| 139 |
--- a/src/iterators/provider.rs |
| 140 |
+++ b/src/iterators/provider.rs |
| 141 |
@@ -91,8 +91,7 @@ |
| 142 |
/// The returned UniquePtr cannot outlive the cache. |
| 143 |
unsafe fn target_ver(self: &PrvIterator) -> UniquePtr<VerIterator>; |
| 144 |
|
| 145 |
- #[cxx_name = "Index"] |
| 146 |
- pub fn index(self: &PrvIterator) -> u64; |
| 147 |
+ pub fn index(self: &PrvIterator) -> usize; |
| 148 |
/// Clone the pointer. |
| 149 |
/// |
| 150 |
/// # Safety |
| 151 |
--- a/src/iterators/version.rs |
| 152 |
+++ b/src/iterators/version.rs |
| 153 |
@@ -329,8 +329,7 @@ |
| 154 |
/// The returned UniquePtr cannot outlive the cache. |
| 155 |
unsafe fn translated_desc(self: &VerIterator) -> UniquePtr<DescIterator>; |
| 156 |
|
| 157 |
- #[cxx_name = "Index"] |
| 158 |
- pub fn index(self: &VerIterator) -> u64; |
| 159 |
+ pub fn index(self: &VerIterator) -> usize; |
| 160 |
/// Clone the pointer. |
| 161 |
/// |
| 162 |
/// # Safety |
| 163 |
--- a/src/records.rs |
| 164 |
+++ b/src/records.rs |
| 165 |
@@ -132,7 +132,7 @@ |
| 166 |
pub struct PackageRecords { |
| 167 |
pub(crate) ptr: UniquePtr<raw::PkgRecords>, |
| 168 |
parser: RefCell<UniquePtr<raw::Parser>>, |
| 169 |
- index: RefCell<u64>, |
| 170 |
+ index: RefCell<usize>, |
| 171 |
} |
| 172 |
|
| 173 |
impl PackageRecords { |
| 174 |
@@ -144,7 +144,7 @@ |
| 175 |
} |
| 176 |
} |
| 177 |
|
| 178 |
- fn replace_index(&self, index: u64) -> bool { |
| 179 |
+ fn replace_index(&self, index: usize) -> bool { |
| 180 |
if self.index.borrow().eq(&index) { |
| 181 |
return false; |
| 182 |
} |