Skip to content

Commit 1566996

Browse files
committed
the last one
1 parent 00acadb commit 1566996

File tree

2 files changed

+16
-13
lines changed

2 files changed

+16
-13
lines changed

src/_macros.rs

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -103,26 +103,27 @@ macro_rules! unsafe_tsk_ragged_column_access {
103103
// to pass clippy checks
104104
#[allow(unused_macros)]
105105
macro_rules! unsafe_tsk_ragged_char_column_access {
106-
($i: expr, $lo: expr, $hi: expr, $array: expr, $offset_array: expr, $offset_array_len: expr) => {{
107-
unimplemented!("have to refactor this macro");
106+
($i: expr, $lo: expr, $hi: expr, $owner: expr, $array: ident, $offset_array: ident, $offset_array_len: ident) => {{
108107
let i = $crate::SizeType::try_from($i)?;
109108
if $i < $lo || i >= $hi {
110109
Err(TskitError::IndexError {})
111-
} else if $offset_array_len == 0 {
110+
} else if $owner.$offset_array_len == 0 {
112111
Ok(None)
113112
} else {
114-
let start = unsafe { *$offset_array.offset($i as isize) };
113+
assert!(!$owner.$array.is_null());
114+
assert!(!$owner.$offset_array.is_null());
115+
let start = unsafe { *$owner.$offset_array.offset($i as isize) };
115116
let stop = if i < $hi {
116-
unsafe { *$offset_array.offset(($i + 1) as isize) }
117+
unsafe { *$owner.$offset_array.offset(($i + 1) as isize) }
117118
} else {
118-
$offset_array_len as tsk_size_t
119+
$owner.$offset_array_len as tsk_size_t
119120
};
120121
if start == stop {
121122
Ok(None)
122123
} else {
123124
let mut buffer = String::new();
124125
for i in start..stop {
125-
buffer.push(unsafe { *$array.offset(i as isize) as u8 as char });
126+
buffer.push(unsafe { *$owner.$array.offset(i as isize) as u8 as char });
126127
}
127128
Ok(Some(buffer))
128129
}

src/provenance.rs

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -111,9 +111,10 @@ impl<'a> ProvenanceTable<'a> {
111111
row.into().0,
112112
0,
113113
self.num_rows(),
114-
self.table_.timestamp,
115-
self.table_.timestamp_offset,
116-
self.table_.timestamp_length
114+
self.table_,
115+
timestamp,
116+
timestamp_offset,
117+
timestamp_length
117118
) {
118119
Ok(Some(string)) => Ok(string),
119120
Ok(None) => Err(crate::TskitError::ValueError {
@@ -134,9 +135,10 @@ impl<'a> ProvenanceTable<'a> {
134135
row.into().0,
135136
0,
136137
self.num_rows(),
137-
self.table_.record,
138-
self.table_.record_offset,
139-
self.table_.record_length
138+
self.table_,
139+
record,
140+
record_offset,
141+
record_length
140142
) {
141143
Ok(Some(string)) => Ok(string),
142144
Ok(None) => Ok(String::from("")),

0 commit comments

Comments
 (0)