Skip to content
Snippets Groups Projects
Commit e0826e1b authored by florian's avatar florian
Browse files

ENH: Add destructors

parent b5209375
No related branches found
No related tags found
2 merge requests!3TST: Add CI infrastructure for integration testing,!2ENH: Add minimal wrapping of libcaosdb's C interface
Pipeline #10281 passed
...@@ -75,7 +75,23 @@ Struct containing a pointer to the wrapped cpp authenticator class. ...@@ -75,7 +75,23 @@ Struct containing a pointer to the wrapped cpp authenticator class.
mutable struct Authenticator mutable struct Authenticator
wrapped_authenticator::Ptr{Cvoid} wrapped_authenticator::Ptr{Cvoid}
Authenticator() = new() function Authenticator()
auth = new()
# force this to point to C_NULL after initialization
auth.wrapped_authenticator = C_NULL
function f(t)
if t.wrapped_authenticator != C_NULL
# Only if pointer was filled after real initialization
ccall(
(:caosdb_authentication_delete_authenticator, "libccaosdb"),
Cint,
(Ref{Authenticator},),
Ref{Authenticator}(t),
)
end
end
finalizer(f, auth)
end
end end
function create_plain_password_authenticator( function create_plain_password_authenticator(
...@@ -116,7 +132,21 @@ Struct containing the actual connection to a CaosDB server. ...@@ -116,7 +132,21 @@ Struct containing the actual connection to a CaosDB server.
mutable struct CaosDBConnection mutable struct CaosDBConnection
wrapped_connection::Ptr{Cvoid} wrapped_connection::Ptr{Cvoid}
CaosDBConnection() = new() function CaosDBConnection()
conn = new()
conn.wrapped_connection = C_NULL
function f(t)
if t.wrapped_connection != C_NULL
ccall(
(:caosdb_connection_delete_connection, "libccaosdb"),
Cint,
(Ref{CaosDBConnection},),
Ref{CaosDBConnection}(t),
)
end
end
finalizer(f, conn)
end
end end
""" """
...@@ -126,7 +156,21 @@ certificate provider. ...@@ -126,7 +156,21 @@ certificate provider.
mutable struct CertificateProvider mutable struct CertificateProvider
wrapped_certificate_provider::Ptr{Cvoid} wrapped_certificate_provider::Ptr{Cvoid}
CertificateProvider() = new() function CertificateProvider()
prov = new()
prov.wrapped_certificate_provider = C_NULL
function f(t)
if t.wrapped_certificate_provider != C_NULL
ccall(
(:caosdb_connection_delete_certificate_provider, "libccaosdb"),
Cint,
(Ref{CertificateProvider},),
Ref{CertificateProvider}(t),
)
end
end
finalizer(f, prov)
end
end end
""" """
...@@ -136,7 +180,21 @@ connection configuration. ...@@ -136,7 +180,21 @@ connection configuration.
mutable struct Configuration mutable struct Configuration
wrapped_connection_configuration::Ptr{Cvoid} wrapped_connection_configuration::Ptr{Cvoid}
Configuration() = new() function Configuration()
config = new()
config.wrapped_connection_configuration = C_NULL
function f(t)
if t.wrapped_connection_configuration != C_NULL
ccall(
(:caosdb_connection_delete_connection_configuration, "libcaosdb"),
Cint,
(Ref{Configuration},),
Ref{Configuration}(t),
)
end
end
finalizer(f, config)
end
end end
""" """
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment