/usr/share/polymake/perllib/Polymake/MainFunctions.pm is in polymake-common 3.2r2-3.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 | # Copyright (c) 1997-2018
# Ewgenij Gawrilow, Michael Joswig (Technische Universitaet Berlin, Germany)
# http://www.polymake.org
#
# This program is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by the
# Free Software Foundation; either version 2, or (at your option) any
# later version: http://www.gnu.org/licenses/gpl.txt.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#-------------------------------------------------------------------------------
package Polymake::Ext;
sub import {
my $module=caller;
&{"$module\::bootstrap"}();
}
BEGIN {
bootstrap();
$INC{"Polymake/Ext.pm"}=$INC{"Polymake/Main.pm"};
}
package Polymake;
use strict;
use vars qw($InstallTop $InstallArch $Arch $DeveloperMode @BundledExts $ConfigTime $DebugLevel);
use Polymake;
use namespaces;
use warnings qw(FATAL void syntax misc);
use feature 'state';
package Polymake::Main;
# private: only called from import()
sub _init {
&Main::init;
$Scope=new Scope();
add AtEnd "FinalCleanup", sub { undef $Scope }, after => "Object";
}
sub createNewScope {
my $prevScope=$Scope;
$Scope=new Scope();
$prevScope
}
sub application_from_object {
User::application((shift)->type->application);
}
sub set_custom {
my $name=shift;
if (@_==1 && substr($name,0,1) eq '@' && is_ARRAY($_[0])) {
$User::application->_set_custom($Prefs->custom, $name, @{$_[0]});
} elsif (@_==1 && substr($name,0,1) eq '%' && is_hash($_[0])) {
$User::application->_set_custom($Prefs->custom, $name, %{$_[0]});
} elsif (@_) {
$User::application->_set_custom($Prefs->custom, $name, @_);
} else {
die "set_custom: value missing\n";
}
}
sub reset_custom {
my $name=shift;
$User::application->_reset_custom($Prefs->custom, $name, @_);
}
sub local_custom {
my $var=$User::application->find_custom_var(shift, $Prefs->custom);
$Scope->begin_locals;
no strict 'refs';
$var->prefix eq '$'
? local_scalar(*{$var->name}, $_[0]) :
$var->prefix eq '@'
? local_array(*{$var->name}, $_[0]) :
@_==2
? local_hash(*{$var->name}, $_[0])
: (local ${$var->name}{$_[0]}=$_[1]);
$Scope->end_locals;
}
sub shell_enable {
state $init_shell=do {
require Polymake::Core::ShellMock;
$Shell=new Core::Shell::Mock;
1
};
}
sub shell_execute {
if (!defined $User::application) {
$@="current application not set";
return;
}
open my $saved_STDOUT, ">&=STDOUT";
close STDOUT;
my $gather_stdout="";
open STDOUT, ">:utf8", \$gather_stdout;
open my $saved_STDERR, ">&=STDERR";
close STDERR;
my $gather_stderr="";
open STDERR, ">:utf8", \$gather_stderr;
my $executed=$Shell->process_input(@_);
my $exc=$@;
$@="";
close STDOUT;
open STDOUT, ">&=", $saved_STDOUT;
close STDERR;
open STDERR, ">&=", $saved_STDERR;
($executed, $gather_stdout, $gather_stderr, $exc);
}
sub shell_complete {
if (!defined $User::application) {
$@="current application not set";
return;
}
$_[0] =~ /\S/ or return (0, "");
$Shell->complete($_[0]);
($Shell->completion_offset, $Shell->term->Attribs->{completion_append_character} // "", @{$Shell->completion_proposals});
}
sub shell_context_help {
if (!defined $User::application) {
$@="current application not set";
return;
}
my ($input, $pos, $full, $html)=@_;
require Polymake::Core::HelpAsHTML if $html;
$input =~ /\S/ or return;
$Shell->context_help($input, $pos);
map {
my $writer= $html ? new Core::HelpAsHTML() : new Core::HelpAsPlainText(0);
$_->write_text($writer, $full);
$writer->text
} @{$Shell->help_topics};
}
1;
# Local Variables:
# cperl-indent-level:3
# indent-tabs-mode:nil
# End:
|