aboutsummaryrefslogtreecommitdiff
path: root/julia
diff options
context:
space:
mode:
authorThomas White <taw@physics.org>2023-04-14 14:51:39 +0200
committerThomas White <taw@physics.org>2024-02-06 16:59:34 +0100
commitd216eda3fa9e5eb926c996c887e409d099f1ba02 (patch)
tree04890be58b9a212df882a18986aa5e76799ed174 /julia
parent5ac899bee2d033525410c8a69011f87933052eff (diff)
Julia: initial experimentation
Diffstat (limited to 'julia')
-rw-r--r--julia/CrystFEL/Project.toml4
-rw-r--r--julia/CrystFEL/src/CrystFEL.jl7
-rw-r--r--julia/CrystFEL/src/datatemplates.jl29
3 files changed, 40 insertions, 0 deletions
diff --git a/julia/CrystFEL/Project.toml b/julia/CrystFEL/Project.toml
new file mode 100644
index 00000000..2c6596b0
--- /dev/null
+++ b/julia/CrystFEL/Project.toml
@@ -0,0 +1,4 @@
+name = "CrystFEL"
+uuid = "02864af1-98e3-4af5-94a7-a156d2a4edba"
+authors = ["Thomas White <taw@physics.org>"]
+version = "0.1.0"
diff --git a/julia/CrystFEL/src/CrystFEL.jl b/julia/CrystFEL/src/CrystFEL.jl
new file mode 100644
index 00000000..0ef197c0
--- /dev/null
+++ b/julia/CrystFEL/src/CrystFEL.jl
@@ -0,0 +1,7 @@
+module CrystFEL
+
+include("datatemplates.jl")
+using .DataTemplates
+export DataTemplate, loaddatatemplate
+
+end # module CrystFEL
diff --git a/julia/CrystFEL/src/datatemplates.jl b/julia/CrystFEL/src/datatemplates.jl
new file mode 100644
index 00000000..1357acb6
--- /dev/null
+++ b/julia/CrystFEL/src/datatemplates.jl
@@ -0,0 +1,29 @@
+module DataTemplates
+
+export DataTemplate, loaddatatemplate
+
+mutable struct InternalDataTemplate end
+
+mutable struct DataTemplate
+ internalptr::Ptr{InternalDataTemplate}
+end
+
+function loaddatatemplate(filename::AbstractString)
+
+ out = ccall((:data_template_new_from_file, :libcrystfel),
+ Ptr{InternalDataTemplate}, (Cstring,), filename)
+ if out == C_NULL
+ throw(OutOfMemoryError())
+ end
+
+ dt = DataTemplate(out)
+
+ finalizer(dt) do x
+ ccall((:data_template_free, :libcrystfel),
+ Cvoid, (Ptr{InternalDataTemplate},), x.internalptr)
+ end
+
+ return dt
+end
+
+end