Skip to content

Commit

Permalink
allow passing nothing for undef values
Browse files Browse the repository at this point in the history
  • Loading branch information
benlorenz committed Feb 9, 2024
1 parent a537177 commit 8c9ee04
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/convert.jl
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ struct PolymakeType end

convert(::Type{PolymakeType}, x::T) where T = convert(convert_to_pm_type(T), x)
convert(::Type{PolymakeType}, v::Visual) = v.obj
convert(::Type{PolymakeType}, ::Nothing) = call_function(PropertyValue, :common, :get_undef)
convert(::Type{OptionSet}, dict) = OptionSet(dict)

############### Adjusting type parameter to CxxWrap ##################
Expand Down Expand Up @@ -69,7 +70,7 @@ convert_to_pm_type(T::Type) = throw(ArgumentError("Unrecognized argument type: $
convert_to_pm_type(::Type{T}) where T <: Union{Int64, Float64} = T
convert_to_pm_type(::Type{T}) where T <: Union{BigObject, PropertyValue, OptionSet, TropicalNumber} = T


convert_to_pm_type(::Nothing) = Nothing
convert_to_pm_type(::Type{Int32}) = Int64
convert_to_pm_type(::Type{<:AbstractFloat}) = Float64
convert_to_pm_type(::Type{<:AbstractString}) = String
Expand Down
5 changes: 5 additions & 0 deletions src/polymake/julia.rules
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,11 @@ function is_boolean_wrapper($) {
return is_boolean($c);
}

# helper function for converting `nothing`
function get_undef() {
return undef;
}

function jupyter_visual_threejs(Visual::Object+) {
my $string = "";
local $ThreeJS::is_used_in_jupyter=1;
Expand Down

0 comments on commit 8c9ee04

Please sign in to comment.