Skip to content

Commit 37c8525

Browse files
committed
Public headers and ptr --> xptr
1 parent e9cc6fe commit 37c8525

17 files changed

Lines changed: 999 additions & 806 deletions

RcppTskit/DESCRIPTION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
Type: Package
22
Package: RcppTskit
33
Title: 'R' Access to the 'tskit C' API
4-
Version: 0.2.0.9000
4+
Version: 0.3.0
55
Date: 2026-01-27
66
Authors@R: c(
77
person("Gregor", "Gorjanc", , "gregor.gorjanc@gmail.com", role = c("aut", "cre", "cph"),

RcppTskit/NEWS.md

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
# RcppTskit news
22

3-
All notable changes to RcppTskit are documented in this file.
3+
All notable changes to `RcppTskit` are documented in this file.
44
The file format is based on [Keep a Changelog](https://keepachangelog.com),
55
and releases adhere to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
66

7-
## [Unreleased]
7+
## [0.3.0] 2026-MM-DD
88

99
### Added (new features)
1010

@@ -23,7 +23,15 @@ and releases adhere to [Semantic Versioning](https://semver.org/spec/v2.0.0.html
2323
- `TableCollection$sequence_length()` to query the sequence length.
2424
- `TableCollection$time_units()` to query the time units.
2525
- `TableCollection$has_index()` to query whether edge indexes are present.
26-
- TODO
26+
- Added a public header and defaults for downstream use of `C++` functions in
27+
`inst/include/RcppTskit_public.hpp`, included by `inst/include/RcppTskit.hpp`.
28+
- TODO
29+
30+
### Changed
31+
32+
- Renamed low-level external-pointer API names from `*_ptr_*` to `*_xptr_*`
33+
(for example, `ts_ptr_load()` to `ts_xptr_load()`) to make external-pointer
34+
vs standard/raw-pointer semantics explicit.
2735

2836
## [0.2.0] - 2026-02-22
2937

RcppTskit/R/Class-TableCollection.R

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ TableCollection <- R6Class(
4444
skip_tables = skip_tables,
4545
skip_reference_sequence = skip_reference_sequence
4646
)
47-
self$pointer <- tc_ptr_load(file = file, options = options)
47+
self$pointer <- tc_xptr_load(file = file, options = options)
4848
} else {
4949
if (!is.null(pointer) && !is(pointer, "externalptr")) {
5050
stop("pointer must be an object of externalptr class!")
@@ -67,7 +67,7 @@ TableCollection <- R6Class(
6767
#' tc$write(dump_file) # alias
6868
#' \dontshow{file.remove(dump_file)}
6969
dump = function(file) {
70-
tc_ptr_dump(self$pointer, file = file, options = 0L)
70+
tc_xptr_dump(self$pointer, file = file, options = 0L)
7171
},
7272

7373
#' @description Alias for \code{\link[=TableCollection]{TableCollection$dump}}.
@@ -91,8 +91,8 @@ TableCollection <- R6Class(
9191
# TODO: Should we also use TSK_TS_INIT_COMPUTE_MUTATION_PARENTS in TableCollection$tree_sequence()? #65
9292
# https://github.com/HighlanderLab/RcppTskit/issues/65
9393
init_options <- bitwShiftL(1L, 0)
94-
ts_ptr <- tc_ptr_to_ts_ptr(self$pointer, options = init_options)
95-
TreeSequence$new(pointer = ts_ptr)
94+
ts_xptr <- tc_xptr_to_ts_xptr(self$pointer, options = init_options)
95+
TreeSequence$new(pointer = ts_xptr)
9696
},
9797

9898
#' @description Get the sequence length.
@@ -101,7 +101,7 @@ TableCollection <- R6Class(
101101
#' tc <- tc_load(tc_file)
102102
#' tc$sequence_length()
103103
sequence_length = function() {
104-
tc_ptr_sequence_length(self$pointer)
104+
tc_xptr_sequence_length(self$pointer)
105105
},
106106

107107
#' @description Get the time units string.
@@ -110,7 +110,7 @@ TableCollection <- R6Class(
110110
#' tc <- tc_load(tc_file)
111111
#' tc$time_units()
112112
time_units = function() {
113-
tc_ptr_time_units(self$pointer)
113+
tc_xptr_time_units(self$pointer)
114114
},
115115

116116
#' @description Get whether the table collection has edge indexes.
@@ -119,7 +119,7 @@ TableCollection <- R6Class(
119119
#' tc <- tc_load(tc_file)
120120
#' tc$has_index()
121121
has_index = function() {
122-
tc_ptr_has_index(self$pointer)
122+
tc_xptr_has_index(self$pointer)
123123
},
124124

125125
#' @description Get whether the table collection has a reference genome sequence.
@@ -131,7 +131,7 @@ TableCollection <- R6Class(
131131
#' tc2 <- tc_load(tc_file2)
132132
#' tc2$has_reference_sequence()
133133
has_reference_sequence = function() {
134-
tc_ptr_has_reference_sequence(self$pointer)
134+
tc_xptr_has_reference_sequence(self$pointer)
135135
},
136136

137137
#' @description Get the file UUID string.
@@ -142,7 +142,7 @@ TableCollection <- R6Class(
142142
#' tc <- tc_load(tc_file)
143143
#' tc$file_uuid()
144144
file_uuid = function() {
145-
tc_ptr_file_uuid(self$pointer)
145+
tc_xptr_file_uuid(self$pointer)
146146
},
147147

148148
#' @description This function saves a table collection from R to disk and
@@ -175,7 +175,7 @@ TableCollection <- R6Class(
175175
#' }
176176
#' }
177177
r_to_py = function(tskit_module = get_tskit_py(), cleanup = TRUE) {
178-
tc_ptr_r_to_py(
178+
tc_xptr_r_to_py(
179179
self$pointer,
180180
tskit_module = tskit_module,
181181
cleanup = cleanup
@@ -192,7 +192,7 @@ TableCollection <- R6Class(
192192
#' tc$print()
193193
#' tc
194194
print = function() {
195-
ret <- tc_ptr_print(self$pointer)
195+
ret <- tc_xptr_print(self$pointer)
196196
# These are not hit since testing is not interactive
197197
# nocov start
198198
if (interactive()) {

RcppTskit/R/Class-TreeSequence.R

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ TreeSequence <- R6Class(
5050
skip_tables = skip_tables,
5151
skip_reference_sequence = skip_reference_sequence
5252
)
53-
self$pointer <- ts_ptr_load(file = file, options = options)
53+
self$pointer <- ts_xptr_load(file = file, options = options)
5454
} else {
5555
if (!is.null(pointer) && !is(pointer, "externalptr")) {
5656
stop("pointer must be an object of externalptr class!")
@@ -73,7 +73,7 @@ TreeSequence <- R6Class(
7373
#' ts$write(dump_file) # alias
7474
#' \dontshow{file.remove(dump_file)}
7575
dump = function(file) {
76-
ts_ptr_dump(self$pointer, file = file, options = 0L)
76+
ts_xptr_dump(self$pointer, file = file, options = 0L)
7777
},
7878

7979
#' @description Alias for \code{\link[=TreeSequence]{TreeSequence$dump}}.
@@ -92,8 +92,8 @@ TreeSequence <- R6Class(
9292
#' tc <- ts$dump_tables()
9393
#' is(tc)
9494
dump_tables = function() {
95-
tc_ptr <- ts_ptr_to_tc_ptr(self$pointer)
96-
TableCollection$new(pointer = tc_ptr)
95+
tc_xptr <- ts_xptr_to_tc_xptr(self$pointer)
96+
TableCollection$new(pointer = tc_xptr)
9797
},
9898

9999
#' @description Print a summary of a tree sequence and its contents.
@@ -106,7 +106,7 @@ TreeSequence <- R6Class(
106106
#' ts$print()
107107
#' ts
108108
print = function() {
109-
ret <- ts_ptr_print(self$pointer)
109+
ret <- ts_xptr_print(self$pointer)
110110
# These are not hit since testing is not interactive
111111
# nocov start
112112
if (interactive()) {
@@ -146,7 +146,7 @@ TreeSequence <- R6Class(
146146
#' }
147147
#' }
148148
r_to_py = function(tskit_module = get_tskit_py(), cleanup = TRUE) {
149-
ts_ptr_r_to_py(
149+
ts_xptr_r_to_py(
150150
self$pointer,
151151
tskit_module = tskit_module,
152152
cleanup = cleanup
@@ -159,7 +159,7 @@ TreeSequence <- R6Class(
159159
#' ts <- ts_load(ts_file)
160160
#' ts$num_provenances()
161161
num_provenances = function() {
162-
ts_ptr_num_provenances(self$pointer)
162+
ts_xptr_num_provenances(self$pointer)
163163
},
164164

165165
#' @description Get the number of populations in a tree sequence.
@@ -168,7 +168,7 @@ TreeSequence <- R6Class(
168168
#' ts <- ts_load(ts_file)
169169
#' ts$num_populations()
170170
num_populations = function() {
171-
ts_ptr_num_populations(self$pointer)
171+
ts_xptr_num_populations(self$pointer)
172172
},
173173

174174
#' @description Get the number of migrations in a tree sequence.
@@ -177,7 +177,7 @@ TreeSequence <- R6Class(
177177
#' ts <- ts_load(ts_file)
178178
#' ts$num_migrations()
179179
num_migrations = function() {
180-
ts_ptr_num_migrations(self$pointer)
180+
ts_xptr_num_migrations(self$pointer)
181181
},
182182

183183
#' @description Get the number of individuals in a tree sequence.
@@ -186,7 +186,7 @@ TreeSequence <- R6Class(
186186
#' ts <- ts_load(ts_file)
187187
#' ts$num_individuals()
188188
num_individuals = function() {
189-
ts_ptr_num_individuals(self$pointer)
189+
ts_xptr_num_individuals(self$pointer)
190190
},
191191

192192
#' @description Get the number of samples (of nodes) in a tree sequence.
@@ -195,7 +195,7 @@ TreeSequence <- R6Class(
195195
#' ts <- ts_load(ts_file)
196196
#' ts$num_samples()
197197
num_samples = function() {
198-
ts_ptr_num_samples(self$pointer)
198+
ts_xptr_num_samples(self$pointer)
199199
},
200200

201201
#' @description Get the number of nodes in a tree sequence.
@@ -204,7 +204,7 @@ TreeSequence <- R6Class(
204204
#' ts <- ts_load(ts_file)
205205
#' ts$num_nodes()
206206
num_nodes = function() {
207-
ts_ptr_num_nodes(self$pointer)
207+
ts_xptr_num_nodes(self$pointer)
208208
},
209209

210210
#' @description Get the number of edges in a tree sequence.
@@ -213,7 +213,7 @@ TreeSequence <- R6Class(
213213
#' ts <- ts_load(ts_file)
214214
#' ts$num_edges()
215215
num_edges = function() {
216-
ts_ptr_num_edges(self$pointer)
216+
ts_xptr_num_edges(self$pointer)
217217
},
218218

219219
#' @description Get the number of trees in a tree sequence.
@@ -222,7 +222,7 @@ TreeSequence <- R6Class(
222222
#' ts <- ts_load(ts_file)
223223
#' ts$num_trees()
224224
num_trees = function() {
225-
ts_ptr_num_trees(self$pointer)
225+
ts_xptr_num_trees(self$pointer)
226226
},
227227

228228
#' @description Get the number of sites in a tree sequence.
@@ -231,7 +231,7 @@ TreeSequence <- R6Class(
231231
#' ts <- ts_load(ts_file)
232232
#' ts$num_sites()
233233
num_sites = function() {
234-
ts_ptr_num_sites(self$pointer)
234+
ts_xptr_num_sites(self$pointer)
235235
},
236236

237237
#' @description Get the number of mutations in a tree sequence.
@@ -240,7 +240,7 @@ TreeSequence <- R6Class(
240240
#' ts <- ts_load(ts_file)
241241
#' ts$num_mutations()
242242
num_mutations = function() {
243-
ts_ptr_num_mutations(self$pointer)
243+
ts_xptr_num_mutations(self$pointer)
244244
},
245245

246246
#' @description Get the sequence length.
@@ -249,7 +249,7 @@ TreeSequence <- R6Class(
249249
#' ts <- ts_load(ts_file)
250250
#' ts$sequence_length()
251251
sequence_length = function() {
252-
ts_ptr_sequence_length(self$pointer)
252+
ts_xptr_sequence_length(self$pointer)
253253
},
254254

255255
#' @description Get the discrete genome status.
@@ -263,7 +263,7 @@ TreeSequence <- R6Class(
263263
#' ts2 <- ts_load(ts_file2)
264264
#' ts2$discrete_genome()
265265
discrete_genome = function() {
266-
ts_ptr_discrete_genome(self$pointer)
266+
ts_xptr_discrete_genome(self$pointer)
267267
},
268268

269269
#' @description Get whether the tree sequence has a reference genome sequence.
@@ -275,7 +275,7 @@ TreeSequence <- R6Class(
275275
#' ts2 <- ts_load(ts_file2)
276276
#' ts2$has_reference_sequence()
277277
has_reference_sequence = function() {
278-
ts_ptr_has_reference_sequence(self$pointer)
278+
ts_xptr_has_reference_sequence(self$pointer)
279279
},
280280

281281
#' @description Get the time units string.
@@ -284,7 +284,7 @@ TreeSequence <- R6Class(
284284
#' ts <- ts_load(ts_file)
285285
#' ts$time_units()
286286
time_units = function() {
287-
ts_ptr_time_units(self$pointer)
287+
ts_xptr_time_units(self$pointer)
288288
},
289289

290290
#' @description Get the discrete time status.
@@ -298,7 +298,7 @@ TreeSequence <- R6Class(
298298
#' ts2 <- ts_load(ts_file2)
299299
#' ts2$discrete_time()
300300
discrete_time = function() {
301-
ts_ptr_discrete_time(self$pointer)
301+
ts_xptr_discrete_time(self$pointer)
302302
},
303303

304304
#' @description Get the min time in node table and mutation table.
@@ -307,7 +307,7 @@ TreeSequence <- R6Class(
307307
#' ts <- ts_load(ts_file)
308308
#' ts$min_time()
309309
min_time = function() {
310-
ts_ptr_min_time(self$pointer)
310+
ts_xptr_min_time(self$pointer)
311311
},
312312

313313
#' @description Get the max time in node table and mutation table.
@@ -316,7 +316,7 @@ TreeSequence <- R6Class(
316316
#' ts <- ts_load(ts_file)
317317
#' ts$max_time()
318318
max_time = function() {
319-
ts_ptr_max_time(self$pointer)
319+
ts_xptr_max_time(self$pointer)
320320
},
321321

322322
#' @description Get the length of metadata in a tree sequence and its tables.
@@ -326,7 +326,7 @@ TreeSequence <- R6Class(
326326
#' ts <- ts_load(ts_file)
327327
#' ts$metadata_length()
328328
metadata_length = function() {
329-
ts_ptr_metadata_length(self$pointer)
329+
ts_xptr_metadata_length(self$pointer)
330330
},
331331

332332
#' @description Get the file UUID string.
@@ -337,7 +337,7 @@ TreeSequence <- R6Class(
337337
#' ts <- ts_load(ts_file)
338338
#' ts$file_uuid()
339339
file_uuid = function() {
340-
ts_ptr_file_uuid(self$pointer)
340+
ts_xptr_file_uuid(self$pointer)
341341
}
342342
)
343343
)

0 commit comments

Comments
 (0)