Skip to content

Commit

Permalink
Merge pull request #473 from oscar-system/bl/bigobjtype
Browse files Browse the repository at this point in the history
BigObject: helper for qualified type name
  • Loading branch information
benlorenz authored Feb 16, 2024
2 parents 9c3d018 + 88fc9cb commit 063c4c5
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 12 deletions.
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "Polymake"
uuid = "d720cf60-89b5-51f5-aff5-213f193123e7"
repo = "https://github.com/oscar-system/Polymake.jl.git"
version = "0.11.13"
version = "0.11.14"

[deps]
BinaryWrappers = "f01c122e-0ea1-4f85-ad8f-907073ad7a9f"
Expand Down
8 changes: 7 additions & 1 deletion src/perlobj.jl
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,17 @@ function bigobject(fname::String, name::String; kwargsdata...)
end

function bigobject_eltype(obj::BigObject)
res = call_function(:User, :get_bigobject_elemtype, obj)
res = call_function(:common, :get_bigobject_elemtype, obj)
res isa CxxWrap.StdString && !isempty(res) || error("could not determine element type of BigObject")
return String(res)
end

function bigobject_qualifiedname(obj::BigObject)
res = call_function(:common, :get_bigobject_qualified_name, obj)
res isa CxxWrap.StdString && !isempty(res) || error("could not determine full type of BigObject")
return String(res)
end

# polymake can either just give a reference or do a full copy.
# but even that full copy will contain references to the same data
# objects in memory, but this is fine since most of them are immutable anyway.
Expand Down
24 changes: 14 additions & 10 deletions src/polymake/julia.rules
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,20 @@ function safe_to_string($) {
return "$var";
}

function get_bigobject_elemtype($) {
my $params = $_[0]->type->params;
return "" unless defined($params) && @$params > 0;
if ($params->[0]->name =~ /^Min|Max$/) {
return $params->[1]->name;
} else {
return $params->[0]->name;
}
}

function get_bigobject_qualified_name($) {
return $_[0]->type->qualified_name;
}

package Polymake::User;

function get_shell_scalar($) {
Expand All @@ -104,13 +118,3 @@ function set_shell_scalar($,$) {
no strict 'refs';
${"Polymake::User::$varname"} = $obj;
}

sub get_bigobject_elemtype($) {
my $params = $_[0]->type->params;
return "" unless defined($params) && @$params > 0;
if ($params->[0]->name =~ /^Min|Max$/) {
return $params->[1]->name;
} else {
return $params->[0]->name;
}
}
1 change: 1 addition & 0 deletions test/perlobj.jl
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@
P = @pm polytope.Polytope{Rational}(POINTS=[1 0.5 0; 1 0 1])
@test P.VERTICES isa Polymake.Matrix{Polymake.Rational}
@test Polymake.bigobject_eltype(P) == "Rational"
@test Polymake.bigobject_qualifiedname(P) == "polytope::Polytope<Rational>"
end

@testset verbose=true "PolymakeException" begin
Expand Down

2 comments on commit 063c4c5

@benlorenz
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JuliaRegistrator register()

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Registration pull request created: JuliaRegistries/General/101020

Tip: Release Notes

Did you know you can add release notes too? Just add markdown formatted text underneath the comment after the text
"Release notes:" and it will be added to the registry PR, and if TagBot is installed it will also be added to the
release that TagBot creates. i.e.

@JuliaRegistrator register

Release notes:

## Breaking changes

- blah

To add them here just re-invoke and the PR will be updated.

Tagging

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a v0.11.14 -m "<description of version>" 063c4c5ef9ab0e260d2a6e84821b713c2c58c5f7
git push origin v0.11.14

Please sign in to comment.