2002-07-17 Radek Doulik <rodo@ximian.com>

* gtk/ScrolledWindow.custom: new file with ScrolledWindow custom
	default constructor

	* parser/Metadata.pm: addClassData subroutine to add
	<disabledefaultconstructor/>

	* parser/Gtk.metadata: disable default constructor for
	ScrolledWindow

	* generator/ObjectGen.cs: added hasDefaultConstructor flag, dont
	generate default protected empty constructor if
	hasDefaultConstructor is false, it will be provided by .custom
	file

	* generator/makefile (RUNTIME): use RUNTIME variable

svn path=/trunk/gtk-sharp/; revision=5854
This commit is contained in:
Radek Doulik 2002-07-17 15:05:22 +00:00
parent 9e29ccbf0a
commit 33b715ef83
8 changed files with 109 additions and 8 deletions

View file

@ -1,3 +1,21 @@
2002-07-17 Radek Doulik <rodo@ximian.com>
* gtk/ScrolledWindow.custom: new file with ScrolledWindow custom
default constructor
* parser/Metadata.pm: addClassData subroutine to add
<disabledefaultconstructor/>
* parser/Gtk.metadata: disable default constructor for
ScrolledWindow
* generator/ObjectGen.cs: added hasDefaultConstructor flag, dont
generate default protected empty constructor if
hasDefaultConstructor is false, it will be provided by .custom
file
* generator/makefile (RUNTIME): use RUNTIME variable
2002-07-17 Rachel Hestilow <hestilow@ximian.com>
* parser/Gtk.metadata: Tag MenuItem.SetSubmenu as null-ok.

View file

@ -15,6 +15,7 @@ namespace GtkSharp.Generation {
private ArrayList ctors = new ArrayList();
private ArrayList strings = new ArrayList();
private bool hasDefaultConstructor = true;
private bool ctors_initted = false;
private Hashtable clash_map;
@ -34,6 +35,10 @@ namespace GtkSharp.Generation {
case "constructor":
ctors.Add (new Ctor (LibraryName, member, this));
break;
case "disabledefaultconstructor":
hasDefaultConstructor = false;
break;
case "static-string":
strings.Add (node);
@ -218,7 +223,7 @@ namespace GtkSharp.Generation {
}
}
if (!clash_map.ContainsKey("")) {
if (!clash_map.ContainsKey("") && hasDefaultConstructor) {
sw.WriteLine("\t\tprotected " + Name + "() : base(){}");
sw.WriteLine();
}

View file

@ -1,4 +1,5 @@
MCS=mcs
RUNTIME=mono
all: linux
@ -9,7 +10,7 @@ windows: *.cs
linux: generated-stamp
generated-stamp: codegen.exe gtkapi.xml
mono ./codegen.exe gtkapi.xml && touch generated-stamp
$(RUNTIME) ./codegen.exe gtkapi.xml && touch generated-stamp
clean:
rm -f *.exe

13
gtk/ScrolledWindow.custom Normal file
View file

@ -0,0 +1,13 @@
//
// Gtk.ScrolledWindow.custom - Gtk ScrolledWindow class customizations
//
// Author: Radek Doulik (rodo@ximian.com)
//
// Copyright (C) 2002 Ximian, Inc.
//
// This code is inserted after the automatically generated code.
//
public ScrolledWindow () : this (new Adjustment (IntPtr.Zero), new Adjustment (IntPtr.Zero)) {
SetPolicy (PolicyType.Automatic, PolicyType.Automatic);
}

View file

@ -80,7 +80,7 @@ sub load {
@data = parseData ($node);
}
}
push @{$self->{rules}}, [\%classes, \@data];
}
}
@ -127,8 +127,25 @@ sub fixupParams {
}
}
sub addClassData {
my ($doc, $node, $class, $data_list_ref) = @_;
foreach $data (@$data_list_ref) {
if ($$data[1] eq "class") {
my @nodes = $node->getChildrenByTagName ($$data[5]);
if (0 == scalar @nodes) {
print STDERR "DEBUG> $class $$data[0] $$data[1] $$data[2] $$data[3] $$data[4] $$data[5] $$data[6]\n";
my $new_node = $doc->createElement ($$data[5]);
$node->appendChild ($new_node);
}
next;
}
}
}
sub fixupNamespace {
my ($self, $ns_node) = @_;
my ($self, $doc, $ns_node) = @_;
my $node;
foreach $rule (@{$self->{rules}}) {
my ($classes_ref, $data_list_ref) = @$rule;
@ -145,6 +162,11 @@ sub fixupNamespace {
my %classes = %$classes_ref;
$methods_ref = $classes{$class}[0];
$signals_ref = $classes{$class}[1];
if ({%$classes_ref}->{$class}) {
addClassData ($doc, $node, $class, $data_list_ref);
}
next if not ($methods_ref or $signals_ref);
for ($method_node = $node->firstChild; $method_node; $method_node = $method_node->nextSibling ()) {
@ -196,7 +218,7 @@ sub fixup {
if (not ($metadata and $metadata->{namespace} eq $namespace)) {
$metadata = new Metadata ($namespace);
}
$metadata->fixupNamespace ($ns_node);
$metadata->fixupNamespace ($doc, $ns_node);
}
}
}

View file

@ -1188,6 +1188,16 @@
</data>
</rule>
<!-- disable default constructor -->
<rule>
<class name="GtkScrolledWindow"/>
<data>
<attribute target="class">
<name>disabledefaultconstructor</name>
</attribute>
</data>
</rule>
<!-- null args -->
<rule>
<class name="GtkCList">

View file

@ -80,7 +80,7 @@ sub load {
@data = parseData ($node);
}
}
push @{$self->{rules}}, [\%classes, \@data];
}
}
@ -127,8 +127,25 @@ sub fixupParams {
}
}
sub addClassData {
my ($doc, $node, $class, $data_list_ref) = @_;
foreach $data (@$data_list_ref) {
if ($$data[1] eq "class") {
my @nodes = $node->getChildrenByTagName ($$data[5]);
if (0 == scalar @nodes) {
print STDERR "DEBUG> $class $$data[0] $$data[1] $$data[2] $$data[3] $$data[4] $$data[5] $$data[6]\n";
my $new_node = $doc->createElement ($$data[5]);
$node->appendChild ($new_node);
}
next;
}
}
}
sub fixupNamespace {
my ($self, $ns_node) = @_;
my ($self, $doc, $ns_node) = @_;
my $node;
foreach $rule (@{$self->{rules}}) {
my ($classes_ref, $data_list_ref) = @$rule;
@ -145,6 +162,11 @@ sub fixupNamespace {
my %classes = %$classes_ref;
$methods_ref = $classes{$class}[0];
$signals_ref = $classes{$class}[1];
if ({%$classes_ref}->{$class}) {
addClassData ($doc, $node, $class, $data_list_ref);
}
next if not ($methods_ref or $signals_ref);
for ($method_node = $node->firstChild; $method_node; $method_node = $method_node->nextSibling ()) {
@ -196,7 +218,7 @@ sub fixup {
if (not ($metadata and $metadata->{namespace} eq $namespace)) {
$metadata = new Metadata ($namespace);
}
$metadata->fixupNamespace ($ns_node);
$metadata->fixupNamespace ($doc, $ns_node);
}
}
}

View file

@ -1188,6 +1188,16 @@
</data>
</rule>
<!-- disable default constructor -->
<rule>
<class name="GtkScrolledWindow"/>
<data>
<attribute target="class">
<name>disabledefaultconstructor</name>
</attribute>
</data>
</rule>
<!-- null args -->
<rule>
<class name="GtkCList">