#  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.
#-------------------------------------------------------------------------------
#
#  Print all object types of an application together with their properties
#  and inheritance relations.
#

if (@ARGV != 1) {
   warn "usage: polymake --script list_all_properties APPLICATION_NAME\n";
   exit(1);
}

application($ARGV[0]);
print "application ", $application->name, " {\n";

foreach my $type (sort { $a->name cmp $b->name } @{$application->object_types}) {
   print "  type ", $type->full_name;
   if (@{$type->super}) {
      print " : ", join(", ", map { $_->full_name } @{$type->super});
   }
   print " {\n";
   foreach my $prop (sort { $a->name cmp $b->name } values %{$type->properties}) {
      if ($prop->belongs_to == $type) {
	 if ($prop->flags & $Core::Property::is_augmented) {
	    print "    ", $prop->name, ":", $prop->type->super->[1]->full_name, " {\n";
	    foreach my $local_prop (sort { $a->name cmp $b->name } values %{$prop->type->super->[0]->properties}) {
	       print "      ", $local_prop->name, ":", $local_prop->type->full_name, "\n";
	    }
	    print "    }\n";
	 } else {
	    print "    ", $prop->name, ":", $prop->type->full_name, "\n";
	 }
      }
   }
   print "  }\n";
}
print "}\n";


# Local Variables:
# mode: perl
# cperl-indent-level:3
# End:
