Skip to content

Commit 1918464

Browse files
committed
Add low-level Julia test
1 parent 3b1b37c commit 1918464

File tree

2 files changed

+43
-0
lines changed

2 files changed

+43
-0
lines changed

CMakeLists.txt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -652,6 +652,14 @@ if(openPMD_HAVE_JULIA)
652652
POSITION_INDEPENDENT_CODE ON
653653
WINDOWS_EXPORT_ALL_SYMBOLS ON
654654
)
655+
656+
add_test(NAME CLI.julia_lowlevel
657+
COMMAND julia
658+
${openPMD_SOURCE_DIR}/test/julia/lowlevel_test.jl
659+
${openPMD_LIBRARY_OUTPUT_DIRECTORY}/libopenPMD.jl.so
660+
WORKING_DIRECTORY
661+
${openPMD_RUNTIME_OUTPUT_DIRECTORY}
662+
)
655663
endif()
656664

657665
# python bindings

test/julia/lowlevel_test.jl

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
import Base
2+
3+
# pass as first argument the path to libopenPMD.jl.so
4+
5+
module openPMD
6+
using CxxWrap
7+
@wrapmodule(ARGS[1])
8+
9+
function __init__()
10+
@initcxx
11+
end
12+
end
13+
14+
s = openPMD.CXX_Series(
15+
"../samples/lowlevel_julia_test.json", openPMD.ACCESS_CREATE)
16+
17+
function Base.getindex(
18+
cont::Cont,
19+
index,
20+
) where
21+
{
22+
A,
23+
B,
24+
Cont<:openPMD.CXX_Container{A,B}
25+
}
26+
return openPMD.cxx_getindex(cont, index)
27+
end
28+
29+
iteration = openPMD.cxx_iterations(s)[100]
30+
mesh = openPMD.cxx_meshes(iteration)
31+
# empty brackets to dereference CxxRef
32+
# automatic dereferencing works only for Int types since CxxRwap.jl defines
33+
# Base.getindex(x::CxxBaseRef, i::Int) = Base.getindex(x[], i)
34+
mesh[]["E"][]["x"]
35+
openPMD.cxx_flush(s, "{}")

0 commit comments

Comments
 (0)