rocks/Generator.pm

384 строки
6.8 KiB
Perl
Исходник Обычный вид История

#!/usr/bin/perl
package Generator;
use strict;
my $num_system_funcs = 4;
sub new {
my ($class, $handle) = @_;
my $self = {
output => $handle,
indented => 0,
indent => 0
};
bless $self, $class;
return $self;
}
sub MaxSystemFuncs {
return $num_system_funcs;
}
sub Action {
my ($self, $n) = @_;
return $self->Write (GetAction ($n));
}
sub GetAction {
my ($n) = @_;
if ($n <= $num_system_funcs) {
return "Action";
} else {
return "RocksAction";
}
}
sub Func {
my ($self, $n) = @_;
return $self->Write (GetFunc ($n));
}
sub GetFunc {
my ($n) = @_;
if ($n <= $num_system_funcs) {
return "Func";
} else {
return "RocksFunc";
}
}
sub Write {
my ($self, @args) = @_;
my $s = join "", @args;
my @lines = split /\n/, $s, -1;
my $endnl = $s =~ m/\n$/;
my $h = $self->{output};
if (length ($lines [0]) > 0) {
$self->WriteIndent ();
}
print $h $lines [0];
for (my $i = 1; $i < @lines; ++$i) {
print $h "\n";
if (length ($lines [$i]) > 0) {
$self->{indented} = 0;
$self->WriteIndent ();
}
print $h $lines [$i];
}
if ($endnl) {
$self->{indented} = 0;
}
return $self;
}
sub WriteIndent {
my ($self) = @_;
if (!$self->{indented}) {
my $h = $self->{output};
print $h "\t" x $self->{indent};
$self->{indented} = 1;
}
return $self;
}
sub WriteLicense {
my ($self) = @_;
my $license = <<EOF;
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
EOF
return $self->Write ($license);
}
sub _write {
my ($self, $v) = @_;
if (!ref ($v)) {
$self->Write ($v);
} else {
$v->($self);
}
}
sub Block {
my ($self, $body) = @_;
$self->Write (" ") if ($self->{indented});
$self->Write ("{\n");
++$self->{indent};
_write ($self, $body);
--$self->{indent};
return $self->Write ("}\n");
}
sub Namespace {
my ($self, $namespace, @types) = @_;
$self->Write ("namespace ", $namespace);
return $self->Block (
sub { foreach (@types) { $_->($self); } }
);
}
sub Type {
my ($self, $type, $body) = @_;
_write ($self, $type);
return $self->Block ($body);
}
sub Method {
my ($self, $ret, $name, $args, $body) = @_;
_write ($self, $ret);
_write ($self, $name);
$self->Write (" (");
_write ($self, $args);
$self->Write (")\n");
return $self->Block ($body);
}
sub TypeParameter {
my ($self, $max, $i) = @_;
return $self->Write (GetTypeParameter ($max, $i));
}
sub GetTypeParameter {
my ($max, $i) = @_;
if ($max == 1) {
return "T";
}
return "T$i";
}
sub TypeParameterList {
my ($self, $max, $start, $end) = @_;
$start ||= 1;
$end ||= $max;
$self->TypeParameter ($max, $start);
for (my $i = $start + 1; $i <= $end; ++$i) {
$self->Write (", ");
$self->TypeParameter ($max, $i);
}
return $self;
}
* gendarme.ignore: Update ignored members. * Generator.pm: Add GetTypeParameterList(), GetValue(), GetDocActionType(), GetDocFuncType(), XmlValue(), Nth(); alter GetDocFunc() and GetDocAction() to generate nicer-looking cref-able strings (e.g. Action{T1,T2} instead of Action{``0, ``1}). * Makefile: Don't warn on CS1591, and add additional dependency checks so that when Generator.pm changes we rebuild all generated source. * mkcurry: Generate XML documentation; remove Tuple null checks. * mktuples.cs: Major changes: make Tuples structs instead of classes. This means that, in order to continue supporting the collection interfaces, each Tuple type needs to fully implement them instead of sharing implementation in a base Tuple type (as was done before). Generate XML documentation for all of these members. The reason for this change is performance and semantics; value types were deemed as more logical and faster (due to less GC pressure). * doc/Makefile.include: Rename `update*' targets to `doc-update*'; run a short sed script on doc/mono-rocks.xml before importing. * doc/en/**: Flush (lots of imported docs from mkcurry and mktuples, plus "manual" docs for TupleRocks.xml and KeyValuePairRocks.xml). * doc/fixup.sed: Due to a gmcs bug bnc421815, the XML documentation //member/@name for explicitly implemented interface members is wrong (or at minimum completely different from CSC's output), so this sed script corrects the doc/mono-rocks.xml file so that monodocer can properly import the inline XML documentation for explicitly implemented members. This file, in short, is a hack. * Mono.Rocks/Curry.cs: Add XML documentation; remove Tuple null checks. * Mono.Rocks/IEnumerable.cs: .ToTuple() now returns object, not Tuple. * Mono.Rocks/Lambdas.cs: Flush doc changes. * Mono.Rocks/Sequence.cs (GenerateReverse): Use Func<S,Tuple<R,S>?> instead of Func<S,Tuple<R,S>> as Tuple is a struct now. * Mono.Rocks/Tuple.cs: Major changes: Tuples are now structs, not classes; remove interface member implementations. * Mono.Rocks/Tuples.cs: Flush (major alterations; see mktuples description). * Tests/Mono.Rocks.Tests/CurryTests.cs: Instead of using `int' for all type parameters, use a variety of types to ensure that currying curries the correct values (in left-to-right order), and remove Tuple null checks (as Tuple is a struct). * Tests/Mono.Rocks.Tests/IEnumerableTest.cs: Cope with .ToTuple() return type change. * Tests/Mono.Rocks.Tests/SequenceTest.cs: Cope with Sequence.GenerateReverse() changes. * Tests/Mono.Rocks.Tests/TuplesTest.cs: Remove ToKeyValuePair_TupleNull(), as Tuples are now structs and thus can't be null. svn path=/branches/rocks-playground/; revision=112002
2008-09-01 04:26:41 +04:00
sub GetTypeParameterList {
my ($max, $start, $end) = @_;
$start ||= 1;
$end ||= $max;
my $list = GetTypeParameter ($max, $start);
for (my $i = $start + 1; $i <= $end; ++$i) {
$list .= ", ";
$list .= GetTypeParameter ($max, $i);
}
* gendarme.ignore: Update ignored members. * Generator.pm: Add GetTypeParameterList(), GetValue(), GetDocActionType(), GetDocFuncType(), XmlValue(), Nth(); alter GetDocFunc() and GetDocAction() to generate nicer-looking cref-able strings (e.g. Action{T1,T2} instead of Action{``0, ``1}). * Makefile: Don't warn on CS1591, and add additional dependency checks so that when Generator.pm changes we rebuild all generated source. * mkcurry: Generate XML documentation; remove Tuple null checks. * mktuples.cs: Major changes: make Tuples structs instead of classes. This means that, in order to continue supporting the collection interfaces, each Tuple type needs to fully implement them instead of sharing implementation in a base Tuple type (as was done before). Generate XML documentation for all of these members. The reason for this change is performance and semantics; value types were deemed as more logical and faster (due to less GC pressure). * doc/Makefile.include: Rename `update*' targets to `doc-update*'; run a short sed script on doc/mono-rocks.xml before importing. * doc/en/**: Flush (lots of imported docs from mkcurry and mktuples, plus "manual" docs for TupleRocks.xml and KeyValuePairRocks.xml). * doc/fixup.sed: Due to a gmcs bug bnc421815, the XML documentation //member/@name for explicitly implemented interface members is wrong (or at minimum completely different from CSC's output), so this sed script corrects the doc/mono-rocks.xml file so that monodocer can properly import the inline XML documentation for explicitly implemented members. This file, in short, is a hack. * Mono.Rocks/Curry.cs: Add XML documentation; remove Tuple null checks. * Mono.Rocks/IEnumerable.cs: .ToTuple() now returns object, not Tuple. * Mono.Rocks/Lambdas.cs: Flush doc changes. * Mono.Rocks/Sequence.cs (GenerateReverse): Use Func<S,Tuple<R,S>?> instead of Func<S,Tuple<R,S>> as Tuple is a struct now. * Mono.Rocks/Tuple.cs: Major changes: Tuples are now structs, not classes; remove interface member implementations. * Mono.Rocks/Tuples.cs: Flush (major alterations; see mktuples description). * Tests/Mono.Rocks.Tests/CurryTests.cs: Instead of using `int' for all type parameters, use a variety of types to ensure that currying curries the correct values (in left-to-right order), and remove Tuple null checks (as Tuple is a struct). * Tests/Mono.Rocks.Tests/IEnumerableTest.cs: Cope with .ToTuple() return type change. * Tests/Mono.Rocks.Tests/SequenceTest.cs: Cope with Sequence.GenerateReverse() changes. * Tests/Mono.Rocks.Tests/TuplesTest.cs: Remove ToKeyValuePair_TupleNull(), as Tuples are now structs and thus can't be null. svn path=/branches/rocks-playground/; revision=112002
2008-09-01 04:26:41 +04:00
return $list;
}
sub GetValue {
my ($max, $i) = @_;
if ($max == 1) {
return "value";
}
* gendarme.ignore: Update ignored members. * Generator.pm: Add GetTypeParameterList(), GetValue(), GetDocActionType(), GetDocFuncType(), XmlValue(), Nth(); alter GetDocFunc() and GetDocAction() to generate nicer-looking cref-able strings (e.g. Action{T1,T2} instead of Action{``0, ``1}). * Makefile: Don't warn on CS1591, and add additional dependency checks so that when Generator.pm changes we rebuild all generated source. * mkcurry: Generate XML documentation; remove Tuple null checks. * mktuples.cs: Major changes: make Tuples structs instead of classes. This means that, in order to continue supporting the collection interfaces, each Tuple type needs to fully implement them instead of sharing implementation in a base Tuple type (as was done before). Generate XML documentation for all of these members. The reason for this change is performance and semantics; value types were deemed as more logical and faster (due to less GC pressure). * doc/Makefile.include: Rename `update*' targets to `doc-update*'; run a short sed script on doc/mono-rocks.xml before importing. * doc/en/**: Flush (lots of imported docs from mkcurry and mktuples, plus "manual" docs for TupleRocks.xml and KeyValuePairRocks.xml). * doc/fixup.sed: Due to a gmcs bug bnc421815, the XML documentation //member/@name for explicitly implemented interface members is wrong (or at minimum completely different from CSC's output), so this sed script corrects the doc/mono-rocks.xml file so that monodocer can properly import the inline XML documentation for explicitly implemented members. This file, in short, is a hack. * Mono.Rocks/Curry.cs: Add XML documentation; remove Tuple null checks. * Mono.Rocks/IEnumerable.cs: .ToTuple() now returns object, not Tuple. * Mono.Rocks/Lambdas.cs: Flush doc changes. * Mono.Rocks/Sequence.cs (GenerateReverse): Use Func<S,Tuple<R,S>?> instead of Func<S,Tuple<R,S>> as Tuple is a struct now. * Mono.Rocks/Tuple.cs: Major changes: Tuples are now structs, not classes; remove interface member implementations. * Mono.Rocks/Tuples.cs: Flush (major alterations; see mktuples description). * Tests/Mono.Rocks.Tests/CurryTests.cs: Instead of using `int' for all type parameters, use a variety of types to ensure that currying curries the correct values (in left-to-right order), and remove Tuple null checks (as Tuple is a struct). * Tests/Mono.Rocks.Tests/IEnumerableTest.cs: Cope with .ToTuple() return type change. * Tests/Mono.Rocks.Tests/SequenceTest.cs: Cope with Sequence.GenerateReverse() changes. * Tests/Mono.Rocks.Tests/TuplesTest.cs: Remove ToKeyValuePair_TupleNull(), as Tuples are now structs and thus can't be null. svn path=/branches/rocks-playground/; revision=112002
2008-09-01 04:26:41 +04:00
return "value$i";
}
sub Value {
my ($self, $max, $i) = @_;
$self->Write (GetValue ($max, $i));
return $self;
}
sub ValueList {
my ($self, $max, $start, $end) = @_;
$start ||= 1;
$end ||= $max;
return if $max == 0;
$self->Value ($max, $start);
for (my $i = $start + 1; $i <= $end; ++$i) {
$self->Write (", ");
$self->Value ($max, $i);
}
return $self;
}
sub MethodParameter {
my ($self, $max, $i) = @_;
if ($max == 1) {
$self->Write ("T value");
}
else {
$self->Write ("T$i value$i");
}
return $self;
}
sub MethodParameterList {
my ($self, $max, $start, $end) = @_;
$start ||= 1;
$end ||= $max;
return if $max == 0;
$self->MethodParameter ($max, $start);
for (my $i = $start + 1; $i <= $end; ++$i) {
$self->Write (", ");
$self->MethodParameter ($max, $i);
}
return $self;
}
* gendarme.ignore: Update ignored members. * Generator.pm: Add GetTypeParameterList(), GetValue(), GetDocActionType(), GetDocFuncType(), XmlValue(), Nth(); alter GetDocFunc() and GetDocAction() to generate nicer-looking cref-able strings (e.g. Action{T1,T2} instead of Action{``0, ``1}). * Makefile: Don't warn on CS1591, and add additional dependency checks so that when Generator.pm changes we rebuild all generated source. * mkcurry: Generate XML documentation; remove Tuple null checks. * mktuples.cs: Major changes: make Tuples structs instead of classes. This means that, in order to continue supporting the collection interfaces, each Tuple type needs to fully implement them instead of sharing implementation in a base Tuple type (as was done before). Generate XML documentation for all of these members. The reason for this change is performance and semantics; value types were deemed as more logical and faster (due to less GC pressure). * doc/Makefile.include: Rename `update*' targets to `doc-update*'; run a short sed script on doc/mono-rocks.xml before importing. * doc/en/**: Flush (lots of imported docs from mkcurry and mktuples, plus "manual" docs for TupleRocks.xml and KeyValuePairRocks.xml). * doc/fixup.sed: Due to a gmcs bug bnc421815, the XML documentation //member/@name for explicitly implemented interface members is wrong (or at minimum completely different from CSC's output), so this sed script corrects the doc/mono-rocks.xml file so that monodocer can properly import the inline XML documentation for explicitly implemented members. This file, in short, is a hack. * Mono.Rocks/Curry.cs: Add XML documentation; remove Tuple null checks. * Mono.Rocks/IEnumerable.cs: .ToTuple() now returns object, not Tuple. * Mono.Rocks/Lambdas.cs: Flush doc changes. * Mono.Rocks/Sequence.cs (GenerateReverse): Use Func<S,Tuple<R,S>?> instead of Func<S,Tuple<R,S>> as Tuple is a struct now. * Mono.Rocks/Tuple.cs: Major changes: Tuples are now structs, not classes; remove interface member implementations. * Mono.Rocks/Tuples.cs: Flush (major alterations; see mktuples description). * Tests/Mono.Rocks.Tests/CurryTests.cs: Instead of using `int' for all type parameters, use a variety of types to ensure that currying curries the correct values (in left-to-right order), and remove Tuple null checks (as Tuple is a struct). * Tests/Mono.Rocks.Tests/IEnumerableTest.cs: Cope with .ToTuple() return type change. * Tests/Mono.Rocks.Tests/SequenceTest.cs: Cope with Sequence.GenerateReverse() changes. * Tests/Mono.Rocks.Tests/TuplesTest.cs: Remove ToKeyValuePair_TupleNull(), as Tuples are now structs and thus can't be null. svn path=/branches/rocks-playground/; revision=112002
2008-09-01 04:26:41 +04:00
sub GetDocActionType {
my ($n) = @_;
return (($n <= $num_system_funcs) ? "System." : "Mono.Rocks.")
. GetAction ($n);
}
sub GetDocAction {
* gendarme.ignore: Update ignored members. * Generator.pm: Add GetTypeParameterList(), GetValue(), GetDocActionType(), GetDocFuncType(), XmlValue(), Nth(); alter GetDocFunc() and GetDocAction() to generate nicer-looking cref-able strings (e.g. Action{T1,T2} instead of Action{``0, ``1}). * Makefile: Don't warn on CS1591, and add additional dependency checks so that when Generator.pm changes we rebuild all generated source. * mkcurry: Generate XML documentation; remove Tuple null checks. * mktuples.cs: Major changes: make Tuples structs instead of classes. This means that, in order to continue supporting the collection interfaces, each Tuple type needs to fully implement them instead of sharing implementation in a base Tuple type (as was done before). Generate XML documentation for all of these members. The reason for this change is performance and semantics; value types were deemed as more logical and faster (due to less GC pressure). * doc/Makefile.include: Rename `update*' targets to `doc-update*'; run a short sed script on doc/mono-rocks.xml before importing. * doc/en/**: Flush (lots of imported docs from mkcurry and mktuples, plus "manual" docs for TupleRocks.xml and KeyValuePairRocks.xml). * doc/fixup.sed: Due to a gmcs bug bnc421815, the XML documentation //member/@name for explicitly implemented interface members is wrong (or at minimum completely different from CSC's output), so this sed script corrects the doc/mono-rocks.xml file so that monodocer can properly import the inline XML documentation for explicitly implemented members. This file, in short, is a hack. * Mono.Rocks/Curry.cs: Add XML documentation; remove Tuple null checks. * Mono.Rocks/IEnumerable.cs: .ToTuple() now returns object, not Tuple. * Mono.Rocks/Lambdas.cs: Flush doc changes. * Mono.Rocks/Sequence.cs (GenerateReverse): Use Func<S,Tuple<R,S>?> instead of Func<S,Tuple<R,S>> as Tuple is a struct now. * Mono.Rocks/Tuple.cs: Major changes: Tuples are now structs, not classes; remove interface member implementations. * Mono.Rocks/Tuples.cs: Flush (major alterations; see mktuples description). * Tests/Mono.Rocks.Tests/CurryTests.cs: Instead of using `int' for all type parameters, use a variety of types to ensure that currying curries the correct values (in left-to-right order), and remove Tuple null checks (as Tuple is a struct). * Tests/Mono.Rocks.Tests/IEnumerableTest.cs: Cope with .ToTuple() return type change. * Tests/Mono.Rocks.Tests/SequenceTest.cs: Cope with Sequence.GenerateReverse() changes. * Tests/Mono.Rocks.Tests/TuplesTest.cs: Remove ToKeyValuePair_TupleNull(), as Tuples are now structs and thus can't be null. svn path=/branches/rocks-playground/; revision=112002
2008-09-01 04:26:41 +04:00
my ($max, $start, $end) = @_;
$start ||= 1;
$end ||= $max;
my $t = GetDocActionType ($end - $start);
* gendarme.ignore: Update ignored members. * Generator.pm: Add GetTypeParameterList(), GetValue(), GetDocActionType(), GetDocFuncType(), XmlValue(), Nth(); alter GetDocFunc() and GetDocAction() to generate nicer-looking cref-able strings (e.g. Action{T1,T2} instead of Action{``0, ``1}). * Makefile: Don't warn on CS1591, and add additional dependency checks so that when Generator.pm changes we rebuild all generated source. * mkcurry: Generate XML documentation; remove Tuple null checks. * mktuples.cs: Major changes: make Tuples structs instead of classes. This means that, in order to continue supporting the collection interfaces, each Tuple type needs to fully implement them instead of sharing implementation in a base Tuple type (as was done before). Generate XML documentation for all of these members. The reason for this change is performance and semantics; value types were deemed as more logical and faster (due to less GC pressure). * doc/Makefile.include: Rename `update*' targets to `doc-update*'; run a short sed script on doc/mono-rocks.xml before importing. * doc/en/**: Flush (lots of imported docs from mkcurry and mktuples, plus "manual" docs for TupleRocks.xml and KeyValuePairRocks.xml). * doc/fixup.sed: Due to a gmcs bug bnc421815, the XML documentation //member/@name for explicitly implemented interface members is wrong (or at minimum completely different from CSC's output), so this sed script corrects the doc/mono-rocks.xml file so that monodocer can properly import the inline XML documentation for explicitly implemented members. This file, in short, is a hack. * Mono.Rocks/Curry.cs: Add XML documentation; remove Tuple null checks. * Mono.Rocks/IEnumerable.cs: .ToTuple() now returns object, not Tuple. * Mono.Rocks/Lambdas.cs: Flush doc changes. * Mono.Rocks/Sequence.cs (GenerateReverse): Use Func<S,Tuple<R,S>?> instead of Func<S,Tuple<R,S>> as Tuple is a struct now. * Mono.Rocks/Tuple.cs: Major changes: Tuples are now structs, not classes; remove interface member implementations. * Mono.Rocks/Tuples.cs: Flush (major alterations; see mktuples description). * Tests/Mono.Rocks.Tests/CurryTests.cs: Instead of using `int' for all type parameters, use a variety of types to ensure that currying curries the correct values (in left-to-right order), and remove Tuple null checks (as Tuple is a struct). * Tests/Mono.Rocks.Tests/IEnumerableTest.cs: Cope with .ToTuple() return type change. * Tests/Mono.Rocks.Tests/SequenceTest.cs: Cope with Sequence.GenerateReverse() changes. * Tests/Mono.Rocks.Tests/TuplesTest.cs: Remove ToKeyValuePair_TupleNull(), as Tuples are now structs and thus can't be null. svn path=/branches/rocks-playground/; revision=112002
2008-09-01 04:26:41 +04:00
if ($max == 0) {
return $t;
}
* gendarme.ignore: Update ignored members. * Generator.pm: Add GetTypeParameterList(), GetValue(), GetDocActionType(), GetDocFuncType(), XmlValue(), Nth(); alter GetDocFunc() and GetDocAction() to generate nicer-looking cref-able strings (e.g. Action{T1,T2} instead of Action{``0, ``1}). * Makefile: Don't warn on CS1591, and add additional dependency checks so that when Generator.pm changes we rebuild all generated source. * mkcurry: Generate XML documentation; remove Tuple null checks. * mktuples.cs: Major changes: make Tuples structs instead of classes. This means that, in order to continue supporting the collection interfaces, each Tuple type needs to fully implement them instead of sharing implementation in a base Tuple type (as was done before). Generate XML documentation for all of these members. The reason for this change is performance and semantics; value types were deemed as more logical and faster (due to less GC pressure). * doc/Makefile.include: Rename `update*' targets to `doc-update*'; run a short sed script on doc/mono-rocks.xml before importing. * doc/en/**: Flush (lots of imported docs from mkcurry and mktuples, plus "manual" docs for TupleRocks.xml and KeyValuePairRocks.xml). * doc/fixup.sed: Due to a gmcs bug bnc421815, the XML documentation //member/@name for explicitly implemented interface members is wrong (or at minimum completely different from CSC's output), so this sed script corrects the doc/mono-rocks.xml file so that monodocer can properly import the inline XML documentation for explicitly implemented members. This file, in short, is a hack. * Mono.Rocks/Curry.cs: Add XML documentation; remove Tuple null checks. * Mono.Rocks/IEnumerable.cs: .ToTuple() now returns object, not Tuple. * Mono.Rocks/Lambdas.cs: Flush doc changes. * Mono.Rocks/Sequence.cs (GenerateReverse): Use Func<S,Tuple<R,S>?> instead of Func<S,Tuple<R,S>> as Tuple is a struct now. * Mono.Rocks/Tuple.cs: Major changes: Tuples are now structs, not classes; remove interface member implementations. * Mono.Rocks/Tuples.cs: Flush (major alterations; see mktuples description). * Tests/Mono.Rocks.Tests/CurryTests.cs: Instead of using `int' for all type parameters, use a variety of types to ensure that currying curries the correct values (in left-to-right order), and remove Tuple null checks (as Tuple is a struct). * Tests/Mono.Rocks.Tests/IEnumerableTest.cs: Cope with .ToTuple() return type change. * Tests/Mono.Rocks.Tests/SequenceTest.cs: Cope with Sequence.GenerateReverse() changes. * Tests/Mono.Rocks.Tests/TuplesTest.cs: Remove ToKeyValuePair_TupleNull(), as Tuples are now structs and thus can't be null. svn path=/branches/rocks-playground/; revision=112002
2008-09-01 04:26:41 +04:00
$t .= "{" . GetTypeParameter ($max, $start);
for (my $i = $start+1; $i <= $end; ++$i) {
$t .= "," . GetTypeParameter ($max, $i);
}
$t .= "}";
return $t;
}
* gendarme.ignore: Update ignored members. * Generator.pm: Add GetTypeParameterList(), GetValue(), GetDocActionType(), GetDocFuncType(), XmlValue(), Nth(); alter GetDocFunc() and GetDocAction() to generate nicer-looking cref-able strings (e.g. Action{T1,T2} instead of Action{``0, ``1}). * Makefile: Don't warn on CS1591, and add additional dependency checks so that when Generator.pm changes we rebuild all generated source. * mkcurry: Generate XML documentation; remove Tuple null checks. * mktuples.cs: Major changes: make Tuples structs instead of classes. This means that, in order to continue supporting the collection interfaces, each Tuple type needs to fully implement them instead of sharing implementation in a base Tuple type (as was done before). Generate XML documentation for all of these members. The reason for this change is performance and semantics; value types were deemed as more logical and faster (due to less GC pressure). * doc/Makefile.include: Rename `update*' targets to `doc-update*'; run a short sed script on doc/mono-rocks.xml before importing. * doc/en/**: Flush (lots of imported docs from mkcurry and mktuples, plus "manual" docs for TupleRocks.xml and KeyValuePairRocks.xml). * doc/fixup.sed: Due to a gmcs bug bnc421815, the XML documentation //member/@name for explicitly implemented interface members is wrong (or at minimum completely different from CSC's output), so this sed script corrects the doc/mono-rocks.xml file so that monodocer can properly import the inline XML documentation for explicitly implemented members. This file, in short, is a hack. * Mono.Rocks/Curry.cs: Add XML documentation; remove Tuple null checks. * Mono.Rocks/IEnumerable.cs: .ToTuple() now returns object, not Tuple. * Mono.Rocks/Lambdas.cs: Flush doc changes. * Mono.Rocks/Sequence.cs (GenerateReverse): Use Func<S,Tuple<R,S>?> instead of Func<S,Tuple<R,S>> as Tuple is a struct now. * Mono.Rocks/Tuple.cs: Major changes: Tuples are now structs, not classes; remove interface member implementations. * Mono.Rocks/Tuples.cs: Flush (major alterations; see mktuples description). * Tests/Mono.Rocks.Tests/CurryTests.cs: Instead of using `int' for all type parameters, use a variety of types to ensure that currying curries the correct values (in left-to-right order), and remove Tuple null checks (as Tuple is a struct). * Tests/Mono.Rocks.Tests/IEnumerableTest.cs: Cope with .ToTuple() return type change. * Tests/Mono.Rocks.Tests/SequenceTest.cs: Cope with Sequence.GenerateReverse() changes. * Tests/Mono.Rocks.Tests/TuplesTest.cs: Remove ToKeyValuePair_TupleNull(), as Tuples are now structs and thus can't be null. svn path=/branches/rocks-playground/; revision=112002
2008-09-01 04:26:41 +04:00
sub GetDocFuncType {
my ($n) = @_;
return (($n <= $num_system_funcs) ? "System." : "Mono.Rocks.")
. GetFunc ($n);
}
sub GetDocFunc {
my ($max, $start, $end, $rtype) = @_;
* gendarme.ignore: Update ignored members. * Generator.pm: Add GetTypeParameterList(), GetValue(), GetDocActionType(), GetDocFuncType(), XmlValue(), Nth(); alter GetDocFunc() and GetDocAction() to generate nicer-looking cref-able strings (e.g. Action{T1,T2} instead of Action{``0, ``1}). * Makefile: Don't warn on CS1591, and add additional dependency checks so that when Generator.pm changes we rebuild all generated source. * mkcurry: Generate XML documentation; remove Tuple null checks. * mktuples.cs: Major changes: make Tuples structs instead of classes. This means that, in order to continue supporting the collection interfaces, each Tuple type needs to fully implement them instead of sharing implementation in a base Tuple type (as was done before). Generate XML documentation for all of these members. The reason for this change is performance and semantics; value types were deemed as more logical and faster (due to less GC pressure). * doc/Makefile.include: Rename `update*' targets to `doc-update*'; run a short sed script on doc/mono-rocks.xml before importing. * doc/en/**: Flush (lots of imported docs from mkcurry and mktuples, plus "manual" docs for TupleRocks.xml and KeyValuePairRocks.xml). * doc/fixup.sed: Due to a gmcs bug bnc421815, the XML documentation //member/@name for explicitly implemented interface members is wrong (or at minimum completely different from CSC's output), so this sed script corrects the doc/mono-rocks.xml file so that monodocer can properly import the inline XML documentation for explicitly implemented members. This file, in short, is a hack. * Mono.Rocks/Curry.cs: Add XML documentation; remove Tuple null checks. * Mono.Rocks/IEnumerable.cs: .ToTuple() now returns object, not Tuple. * Mono.Rocks/Lambdas.cs: Flush doc changes. * Mono.Rocks/Sequence.cs (GenerateReverse): Use Func<S,Tuple<R,S>?> instead of Func<S,Tuple<R,S>> as Tuple is a struct now. * Mono.Rocks/Tuple.cs: Major changes: Tuples are now structs, not classes; remove interface member implementations. * Mono.Rocks/Tuples.cs: Flush (major alterations; see mktuples description). * Tests/Mono.Rocks.Tests/CurryTests.cs: Instead of using `int' for all type parameters, use a variety of types to ensure that currying curries the correct values (in left-to-right order), and remove Tuple null checks (as Tuple is a struct). * Tests/Mono.Rocks.Tests/IEnumerableTest.cs: Cope with .ToTuple() return type change. * Tests/Mono.Rocks.Tests/SequenceTest.cs: Cope with Sequence.GenerateReverse() changes. * Tests/Mono.Rocks.Tests/TuplesTest.cs: Remove ToKeyValuePair_TupleNull(), as Tuples are now structs and thus can't be null. svn path=/branches/rocks-playground/; revision=112002
2008-09-01 04:26:41 +04:00
$start ||= 1;
$end ||= $max;
$rtype ||= "TResult";
my $t = GetDocFuncType ($end - $start);
$t .= "{";
* gendarme.ignore: Update ignored members. * Generator.pm: Add GetTypeParameterList(), GetValue(), GetDocActionType(), GetDocFuncType(), XmlValue(), Nth(); alter GetDocFunc() and GetDocAction() to generate nicer-looking cref-able strings (e.g. Action{T1,T2} instead of Action{``0, ``1}). * Makefile: Don't warn on CS1591, and add additional dependency checks so that when Generator.pm changes we rebuild all generated source. * mkcurry: Generate XML documentation; remove Tuple null checks. * mktuples.cs: Major changes: make Tuples structs instead of classes. This means that, in order to continue supporting the collection interfaces, each Tuple type needs to fully implement them instead of sharing implementation in a base Tuple type (as was done before). Generate XML documentation for all of these members. The reason for this change is performance and semantics; value types were deemed as more logical and faster (due to less GC pressure). * doc/Makefile.include: Rename `update*' targets to `doc-update*'; run a short sed script on doc/mono-rocks.xml before importing. * doc/en/**: Flush (lots of imported docs from mkcurry and mktuples, plus "manual" docs for TupleRocks.xml and KeyValuePairRocks.xml). * doc/fixup.sed: Due to a gmcs bug bnc421815, the XML documentation //member/@name for explicitly implemented interface members is wrong (or at minimum completely different from CSC's output), so this sed script corrects the doc/mono-rocks.xml file so that monodocer can properly import the inline XML documentation for explicitly implemented members. This file, in short, is a hack. * Mono.Rocks/Curry.cs: Add XML documentation; remove Tuple null checks. * Mono.Rocks/IEnumerable.cs: .ToTuple() now returns object, not Tuple. * Mono.Rocks/Lambdas.cs: Flush doc changes. * Mono.Rocks/Sequence.cs (GenerateReverse): Use Func<S,Tuple<R,S>?> instead of Func<S,Tuple<R,S>> as Tuple is a struct now. * Mono.Rocks/Tuple.cs: Major changes: Tuples are now structs, not classes; remove interface member implementations. * Mono.Rocks/Tuples.cs: Flush (major alterations; see mktuples description). * Tests/Mono.Rocks.Tests/CurryTests.cs: Instead of using `int' for all type parameters, use a variety of types to ensure that currying curries the correct values (in left-to-right order), and remove Tuple null checks (as Tuple is a struct). * Tests/Mono.Rocks.Tests/IEnumerableTest.cs: Cope with .ToTuple() return type change. * Tests/Mono.Rocks.Tests/SequenceTest.cs: Cope with Sequence.GenerateReverse() changes. * Tests/Mono.Rocks.Tests/TuplesTest.cs: Remove ToKeyValuePair_TupleNull(), as Tuples are now structs and thus can't be null. svn path=/branches/rocks-playground/; revision=112002
2008-09-01 04:26:41 +04:00
for (my $i = $start; $i <= $end; ++$i) {
$t .= GetTypeParameter ($max, $i) . ",";
}
$t .= "$rtype}";
return $t;
}
sub XmlDoc {
my ($self, $start_element, $end_element, $content) = @_;
$self->Write ("/// <$start_element>\n");
my @lines = split /\n/, $content;
foreach my $line (@lines) {
$self->Write ("/// $line\n");
}
return $self->Write ("/// </$end_element>\n");
}
sub XmlException {
my ($self, $type, $content) = @_;
return $self->XmlDoc ("exception cref=\"T:$type\"", "exception", $content);
}
sub XmlParam {
my ($self, $param, $content) = @_;
return $self->XmlDoc ("param name=\"$param\"", "param", $content);
}
sub XmlRemarks {
my ($self, $content) = @_;
return $self->XmlDoc ("remarks", "remarks", $content);
}
sub XmlReturns {
my ($self, $content) = @_;
return $self->XmlDoc ("returns", "returns", $content);
}
sub XmlSummary {
my ($self, $content) = @_;
return $self->XmlDoc ("summary", "summary", $content);
}
sub XmlTypeparam {
my ($self, $param, $content) = @_;
return $self->XmlDoc ("typeparam name=\"$param\"", "typeparam", $content);
}
* gendarme.ignore: Update ignored members. * Generator.pm: Add GetTypeParameterList(), GetValue(), GetDocActionType(), GetDocFuncType(), XmlValue(), Nth(); alter GetDocFunc() and GetDocAction() to generate nicer-looking cref-able strings (e.g. Action{T1,T2} instead of Action{``0, ``1}). * Makefile: Don't warn on CS1591, and add additional dependency checks so that when Generator.pm changes we rebuild all generated source. * mkcurry: Generate XML documentation; remove Tuple null checks. * mktuples.cs: Major changes: make Tuples structs instead of classes. This means that, in order to continue supporting the collection interfaces, each Tuple type needs to fully implement them instead of sharing implementation in a base Tuple type (as was done before). Generate XML documentation for all of these members. The reason for this change is performance and semantics; value types were deemed as more logical and faster (due to less GC pressure). * doc/Makefile.include: Rename `update*' targets to `doc-update*'; run a short sed script on doc/mono-rocks.xml before importing. * doc/en/**: Flush (lots of imported docs from mkcurry and mktuples, plus "manual" docs for TupleRocks.xml and KeyValuePairRocks.xml). * doc/fixup.sed: Due to a gmcs bug bnc421815, the XML documentation //member/@name for explicitly implemented interface members is wrong (or at minimum completely different from CSC's output), so this sed script corrects the doc/mono-rocks.xml file so that monodocer can properly import the inline XML documentation for explicitly implemented members. This file, in short, is a hack. * Mono.Rocks/Curry.cs: Add XML documentation; remove Tuple null checks. * Mono.Rocks/IEnumerable.cs: .ToTuple() now returns object, not Tuple. * Mono.Rocks/Lambdas.cs: Flush doc changes. * Mono.Rocks/Sequence.cs (GenerateReverse): Use Func<S,Tuple<R,S>?> instead of Func<S,Tuple<R,S>> as Tuple is a struct now. * Mono.Rocks/Tuple.cs: Major changes: Tuples are now structs, not classes; remove interface member implementations. * Mono.Rocks/Tuples.cs: Flush (major alterations; see mktuples description). * Tests/Mono.Rocks.Tests/CurryTests.cs: Instead of using `int' for all type parameters, use a variety of types to ensure that currying curries the correct values (in left-to-right order), and remove Tuple null checks (as Tuple is a struct). * Tests/Mono.Rocks.Tests/IEnumerableTest.cs: Cope with .ToTuple() return type change. * Tests/Mono.Rocks.Tests/SequenceTest.cs: Cope with Sequence.GenerateReverse() changes. * Tests/Mono.Rocks.Tests/TuplesTest.cs: Remove ToKeyValuePair_TupleNull(), as Tuples are now structs and thus can't be null. svn path=/branches/rocks-playground/; revision=112002
2008-09-01 04:26:41 +04:00
sub XmlValue {
my ($self, $content) = @_;
return $self->XmlDoc ("value", "value", $content);
}
sub Nth {
my ($n) = @_;
return "first" if $n == 1;
return "second" if $n == 2;
return "third" if $n == 3;
return "fourth" if $n == 4;
return "unknown";
}
1;