[Gtk-sharp-list] patch: gapi.pl allows renaming of enum and enum members

Mike Kestner mkestner@speakeasy.net
Tue, 26 Aug 2003 23:21:32 -0500


Hi Aleksey,

Thanks for the patch.

I've made some comments below.  Can you rework the patch to incorporate
the comments and verify that it still works for your libzvt binding? 
Also, please check out the guidelines on go-mono.org for obtaining a cvs
account.  You'll still need to submit patches to the list for approval,
but I'd like you to get you set up to be able to check in your own
patches after review.

On Tue, 2003-08-26 at 15:15, Aleksey Sanin wrote:
> While I worked on wrapping libzvt I found that current gapi scripts 
> could not
> process enums. The attached patch fixes this problem and allows to rename
> enums and enum memebers from metadata file using syntax like one on the
> following example:
> 
> <rule>
>   <enum name="zvtfont_t" />

While it's a terrible nomenclature, "class" is the proper element to
identify the type to be altered by a rule. There's really no need to add
the distinction of <enum> element handling in the rules.
 
>   <data>
>     <attribute target="enum">

Thus, this becomes target="class".


Please include a ChangeLog entry with your patches.

> Index: parser/GAPI/Metadata.pm
> ===================================================================
> RCS file: /mono/gtk-sharp/parser/GAPI/Metadata.pm,v
> retrieving revision 1.12
> diff -u -r1.12 Metadata.pm
> --- parser/GAPI/Metadata.pm	11 Jul 2003 02:00:12 -0000	1.12
> +++ parser/GAPI/Metadata.pm	26 Aug 2003 19:58:49 -0000
> @@ -35,7 +35,7 @@
>  			$methods{$method_node->firstChild->nodeValue} = 1;
>  		} elsif ($method_node->nodeName eq "signal") {
>  			$signals{$method_node->firstChild->nodeValue} = 1;
> -		} elsif ($method_node->nodeName eq "property") {
> +		} elsif ($method_node->nodeName eq "property" or $method_node->nodeName eq "member") {
>  			$properties{$method_node->firstChild->nodeValue} = 1;

We probably should rename the $properties hash throughout the file to
something more generic.  Maybe $members or $simple or
$parameterless_members.  :)

>  		}	
>  	}
> @@ -80,7 +80,7 @@
>  		my %classes = ();
>  		my @data;
>  		for ($node = $rule_node->firstChild; $node != undef; $node = $node->nextSibling ()) {
> -			if ($node->nodeName eq "class") {
> +			if ($node->nodeName eq "class" or $node->nodeName eq "enum") {

This goes away per the above rule comments.

>  				parseClass ($node, \%classes);
>  			} elsif ($node->nodeName eq "data") {
>  				@data = parseData ($node);	
> @@ -158,7 +158,7 @@
>      my ($doc, $node, $class, $data_list_ref) = @_;
>  
>      foreach $data (@$data_list_ref) {
> -	if ($$data[1] eq "class") {
> +	if ($$data[1] eq "class" or $$data[1] eq "enum") {

As does this.

-- 
Mike Kestner <mkestner@speakeasy.net>