Skip to content

Commit

Permalink
Merge pull request #225 from LCSB-BioCore/mk-safer-create
Browse files Browse the repository at this point in the history
use the safer Object_createChild SBML methods.
  • Loading branch information
exaexa authored Jul 25, 2022
2 parents 66c2612 + d0284be commit 384dd91
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 209 deletions.
27 changes: 0 additions & 27 deletions src/unitful.jl
Original file line number Diff line number Diff line change
Expand Up @@ -101,30 +101,3 @@ string ID.
"""
unitful(m::Model, val::Tuple{Float64,String}, default_unit::String) =
unitful(m, val, unitful(m.units[default_unit]))

function unit_definition(id::String, units::UnitDefinition)::VPtr
unit_definition = ccall(
sbml(:UnitDefinition_create),
VPtr,
(Cint, Cint),
WRITESBML_DEFAULT_LEVEL,
WRITESBML_DEFAULT_VERSION,
)
ccall(sbml(:UnitDefinition_setId), Cint, (VPtr, Cstring), unit_definition, id)
isnothing(units.name) || ccall(
sbml(:UnitDefinition_setName),
Cint,
(VPtr, Cstring),
unit_definition,
units.name,
)
for unit in units.unit_parts
unit_ptr = ccall(sbml(:UnitDefinition_createUnit), VPtr, (VPtr,), unit_definition)
unit_kind = ccall(sbml(:UnitKind_forName), Cint, (Cstring,), unit.kind)
ccall(sbml(:Unit_setKind), Cint, (VPtr, Cint), unit_ptr, unit_kind)
ccall(sbml(:Unit_setScale), Cint, (VPtr, Cint), unit_ptr, unit.scale)
ccall(sbml(:Unit_setExponent), Cint, (VPtr, Cint), unit_ptr, unit.exponent)
ccall(sbml(:Unit_setMultiplier), Cint, (VPtr, Cdouble), unit_ptr, unit.multiplier)
end
return unit_definition
end
Loading

0 comments on commit 384dd91

Please sign in to comment.