Skip to content

Commit fb5967f

Browse files
jmarkJohannes MarkertJoshuaLampert
authored
Add conversion dispatch for ForestWrapper. (#76)
* Adding cleanup logic. * Applying review comments and adding a test. * Applied review suggestions. * Adding format utility. * Renamed formatter. * Removed trixi formatter. * Limited folders to format. * Applie formatter. * Fixed error in code. * Updated formatter. * Formatted examples. * Revised package version. * Downgraded formatter. * Fixed version number of formatter. * Applied formater with version x.x.60. * Fixing compats. * Bumped MPIPreferences. * Update Project.toml Co-authored-by: Joshua Lampert <[email protected]> * Update test/Project.toml Co-authored-by: Joshua Lampert <[email protected]> * Refining test. * Added test evals. * Added further test eval. * Adding convenient dispatch on type conversion. * Version bump. * Refined comment. * Update src/T8code.jl Co-authored-by: Joshua Lampert <[email protected]> --------- Co-authored-by: Johannes Markert <[email protected]> Co-authored-by: Joshua Lampert <[email protected]>
1 parent 235b47f commit fb5967f

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

Project.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name = "T8code"
22
uuid = "d0cc0030-9a40-4274-8435-baadcfd54fa1"
33
authors = ["Johannes Markert <[email protected]>"]
4-
version = "0.7.1"
4+
version = "0.7.2"
55

66
[deps]
77
CEnum = "fa961155-64e5-5f13-b03f-caf6b980ea82"

src/T8code.jl

+7
Original file line numberDiff line numberDiff line change
@@ -212,6 +212,13 @@ mutable struct ForestWrapper
212212
end
213213
end
214214

215+
Base.pointer(fw::ForestWrapper) = fw.pointer
216+
# This dispatched conversion allows to conveniently pass a ForestWrapper object
217+
# to `t8_forest_...` calls. The following link leads to a lengthy discussion
218+
# about if this is a valid way to achieve this:
219+
# https://discourse.julialang.org/t/how-to-use-ccall-cconvert-and-unsafe-convert-in-a-convenient-and-memory-safe-way/41932/18
220+
Base.unsafe_convert(::Type{Ptr{t8_forest}}, fw::ForestWrapper) = fw.pointer
221+
215222
function clean_up()
216223
# Finalize all registered t8code objects before MPI shuts down.
217224
while length(T8CODE_OBJECT_TRACKER) > 0

0 commit comments

Comments
 (0)