[cairo-commit] cairo-perl ChangeLog, 1.34, 1.35 MakeHelper.pm, 1.7, 1.8 Makefile.PL, 1.18, 1.19

Torsten Schoenfeld commit at pdx.freedesktop.org
Sun Aug 20 11:09:49 PDT 2006


Committed by: tsch

Update of /cvs/cairo/cairo-perl
In directory kemper:/tmp/cvs-serv28392

Modified Files:
	ChangeLog MakeHelper.pm Makefile.PL 
Log Message:
	* MakeHelper.pm: Add the infrastructure necessary to support
	protecting the enum related things with #ifdef, if needed.  Also
	use the real enum types for the enum converters, instead of just
	int.


Index: ChangeLog
===================================================================
RCS file: /cvs/cairo/cairo-perl/ChangeLog,v
retrieving revision 1.34
retrieving revision 1.35
diff -u -d -r1.34 -r1.35
--- ChangeLog	15 Aug 2006 14:06:47 -0000	1.34
+++ ChangeLog	20 Aug 2006 18:09:47 -0000	1.35
@@ -1,3 +1,10 @@
+2006-08-20	tsch
+
+	* MakeHelper.pm: Add the infrastructure necessary to support
+	protecting the enum related things with #ifdef, if needed.  Also
+	use the real enum types for the enum converters, instead of just
+	int.
+
 2006-08-15	tsch
 
 	* Cairo.pm, MANIFEST, NEWS, README: Beta release 0.92.

Index: MakeHelper.pm
===================================================================
RCS file: /cvs/cairo/cairo-perl/MakeHelper.pm,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -d -r1.7 -r1.8
--- MakeHelper.pm	10 Aug 2006 17:34:40 -0000	1.7
+++ MakeHelper.pm	20 Aug 2006 18:09:47 -0000	1.8
@@ -71,7 +71,8 @@
 	my %objects = %{shift ()};
 	my %structs = %{shift ()};
 	my %enums = %{shift ()};
-	my %backend_macros = %{shift ()};
+	my %backend_guards = %{shift ()};
+	my %enum_guards = %{shift ()};
 
 	my $cairo_perl = File::Spec->catfile ($autogen_dir,
 					      'cairo-perl-auto.typemap');
@@ -198,8 +199,8 @@
 		my $mangled = mangle ($type);
 		my $ref = reference ($type);
 
-		if (exists $backend_macros{$type}) {
-			print HEADER "#ifdef $backend_macros{$type}\n";
+		if (exists $backend_guards{$type}) {
+			print HEADER "#ifdef $backend_guards{$type}\n";
 		}
 
 		print HEADER <<"EOS";
@@ -212,8 +213,8 @@
 #define newSV${mangled}_ornull(object)	(((object) == NULL) ? &PL_sv_undef : newSV$mangled(object))
 EOS
 
-		if (exists $backend_macros{$type}) {
-			print HEADER "#endif /* $backend_macros{$type} */\n";
+		if (exists $backend_guards{$type}) {
+			print HEADER "#endif /* $backend_guards{$type} */\n";
 		}
 	}
 
@@ -240,18 +241,25 @@
 
 	print HEADER "\n/* enums */\n\n";
 
-	foreach (keys %enums)
+	foreach my $type (keys %enums)
 	{
-		my $type = $_;
 		my $mangled = mangle ($type);
 		my $name = name ($type);
 
+		if (exists $enum_guards{$type}) {
+			print HEADER "#ifdef $enum_guards{$type}\n";
+		}
+
 		print HEADER <<"EOS";
-int cairo_${name}_from_sv (SV * $name);
-SV * cairo_${name}_to_sv (int val);
+$type cairo_${name}_from_sv (SV * $name);
+SV * cairo_${name}_to_sv ($type val);
 #define Sv$mangled(sv)		(cairo_${name}_from_sv (sv))
 #define newSV$mangled(val)	(cairo_${name}_to_sv (val))
 EOS
+
+		if (exists $enum_guards{$type}) {
+			print HEADER "#endif /* $enum_guards{$type} */\n";
+		}
 	}
 
 	close HEADER;
@@ -264,6 +272,7 @@
 sub do_enums
 {
 	my %enums = %{shift ()};
+        my %guards = %{shift ()};
 
 	my $cairo_enums = 'cairo-perl-enums.c';
 	open ENUMS, '>', $cairo_enums
@@ -341,10 +350,10 @@
 		$str;
 	}
 
-	foreach (keys %enums)
+	foreach my $type (keys %enums)
 	{
-		my $name = name($_);
-		my @enum_values = @{$enums{$_}};
+		my $name = name($type);
+		my @enum_values = @{$enums{$type}};
 
 		# Create stub converters to make xsubpp happy even if the
 		# current cairo doesn't have this type
@@ -368,31 +377,39 @@
 			next;
 		}
 
-		my $value_list = join ", ", map { canonicalize($_, $enum_values[0]) } @enum_values[1..$#enum_values];
+		my $value_list = join ", ", map { canonicalize($type, $enum_values[0]) } @enum_values[1..$#enum_values];
 		my $tree_from = if_tree_from (@enum_values);
 		my $tree_to = if_tree_to (@enum_values);
 
+		if (exists $guards{$type}) {
+			print ENUMS "#ifdef $guards{$type}\n\n";
+		}
+
 		print ENUMS <<"EOS";
-int
+$type
 cairo_${name}_from_sv (SV * $name)
 {
 	char * str = SvPV_nolen ($name);
 
 	$tree_from
-	croak ("`%s' is not a valid $_ value; valid values are: $value_list", str);
+	croak ("`%s' is not a valid $type value; valid values are: $value_list", str);
 
 	return 0;
 }
 
 SV *
-cairo_${name}_to_sv (int val)
+cairo_${name}_to_sv ($type val)
 {
 	$tree_to
-	warn ("unknown $_ value %d encountered", val);
+	warn ("unknown $type value %d encountered", val);
 	return &PL_sv_undef;
 }
 
 EOS
+
+		if (exists $guards{$type}) {
+			print ENUMS "#endif /* $guards{$type} */\n";
+		}
 	}
 
 	close ENUMS;

Index: Makefile.PL
===================================================================
RCS file: /cvs/cairo/cairo-perl/Makefile.PL,v
retrieving revision 1.18
retrieving revision 1.19
diff -u -d -r1.18 -r1.19
--- Makefile.PL	10 Aug 2006 17:34:40 -0000	1.18
+++ Makefile.PL	20 Aug 2006 18:09:47 -0000	1.19
@@ -53,7 +53,7 @@
 
 my %cairo_cfg = ExtUtils::PkgConfig->find ("cairo >= $extreqs{cairo}");
 
-my %backend_macros = (
+my %backend_guards = (
 	'cairo_pdf_surface_t' => 'CAIRO_HAS_PDF_SURFACE',
 	'cairo_ps_surface_t'  => 'CAIRO_HAS_PS_SURFACE',
 	'cairo_svg_surface_t' => 'CAIRO_HAS_SVG_SURFACE',
@@ -268,7 +268,11 @@
 	$enums{cairo_svg_version_t} = [];
 }
 
-MakeHelper::do_enums (\%enums);
+my %enum_guards = (
+	cairo_svg_version_t => $backend_guards{cairo_svg_surface_t},
+);
+
+MakeHelper::do_enums (\%enums, \%enum_guards);
 
 my @xs_files = <*.xs>;
 
@@ -278,7 +282,7 @@
 );
 
 my @typemaps = MakeHelper::do_typemaps (\%objects, \%structs, \%enums,
-                                        \%backend_macros);
+                                        \%backend_guards, \%enum_guards);
 push @typemaps, 'cairo-perl.typemap';
 
 my $dep = ExtUtils::Depends->new ('Cairo');



More information about the cairo-commit mailing list