svn commit: samba r7424 - in branches/SAMBA_4_0/source/build/pidl: .

metze at samba.org metze at samba.org
Thu Jun 9 07:48:26 GMT 2005


Author: metze
Date: 2005-06-09 07:48:26 +0000 (Thu, 09 Jun 2005)
New Revision: 7424

WebSVN: http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=rev&root=samba&rev=7424

Log:
add --uint-enums option to pidl to generate
defines for the enum members
(this hopefully will fix the build on AIX)

metze
Modified:
   branches/SAMBA_4_0/source/build/pidl/ndr_header.pm
   branches/SAMBA_4_0/source/build/pidl/pidl.pl
   branches/SAMBA_4_0/source/build/pidl/util.pm


Changeset:
Modified: branches/SAMBA_4_0/source/build/pidl/ndr_header.pm
===================================================================
--- branches/SAMBA_4_0/source/build/pidl/ndr_header.pm	2005-06-09 07:45:29 UTC (rev 7423)
+++ branches/SAMBA_4_0/source/build/pidl/ndr_header.pm	2005-06-09 07:48:26 UTC (rev 7424)
@@ -120,17 +120,44 @@
     my($name) = shift;
     my $first = 1;
 
-    pidl "\nenum $name {\n";
-    $tab_depth++;
-    foreach my $e (@{$enum->{ELEMENTS}}) {
+    if (not util::useUintEnums()) {
+    	pidl "\nenum $name {\n";
+	$tab_depth++;
+	foreach my $e (@{$enum->{ELEMENTS}}) {
  	    unless ($first) { pidl ",\n"; }
 	    $first = 0;
 	    tabs();
 	    pidl $e;
+	}
+	pidl "\n";
+	$tab_depth--;
+	pidl "}";
+    } else {
+        my $count = 0;
+	pidl "\nenum $name { __donnot_use_enum_$name=0x7FFFFFFF};\n";
+	my $with_val = 0;
+	my $without_val = 0;
+	foreach my $e (@{$enum->{ELEMENTS}}) {
+	    my $t = "$e";
+	    my $name;
+	    my $value;
+	    if ($t =~ /(.*)=(.*)/) {
+	    	$name = $1;
+	    	$value = $2;
+		$with_val = 1;
+		die ("you can't mix enum member with values and without values when using --uint-enums!")
+			unless ($without_val == 0);
+	    } else {
+	    	$name = $t;
+	    	$value = $count++;
+		$without_val = 1;
+		die ("you can't mix enum member with values and without values when using --uint-enums!")
+			unless ($with_val == 0);
+	    }
+	    pidl "#define $name ( $value )\n";
+	}
+	pidl "\n";
     }
-    pidl "\n";
-    $tab_depth--;
-    pidl "}";
 }
 
 #####################################################################

Modified: branches/SAMBA_4_0/source/build/pidl/pidl.pl
===================================================================
--- branches/SAMBA_4_0/source/build/pidl/pidl.pl	2005-06-09 07:45:29 UTC (rev 7423)
+++ branches/SAMBA_4_0/source/build/pidl/pidl.pl	2005-06-09 07:48:26 UTC (rev 7424)
@@ -36,6 +36,7 @@
 my($opt_help) = 0;
 my($opt_parse) = 0;
 my($opt_dump) = 0;
+my($opt_uint_enums) = 0;
 my($opt_diff) = 0;
 my($opt_header);
 my($opt_template) = 0;
@@ -70,6 +71,7 @@
  --output=OUTNAME      put output in OUTNAME.*
  --parse               parse a idl file to a .pidl file
  --dump                dump a pidl file back to idl
+ --uint-enums          don't use C enums, instead use uint* types
  --header[=OUTFILE]    create a C NDR header file
  --parser[=OUTFILE]    create a C NDR parser
  --esp[=OUTFILE]       create esp wrapper file
@@ -96,22 +98,23 @@
 	    'output=s' => \$opt_output,
 	    'parse' => \$opt_parse,
 	    'dump' => \$opt_dump,
+	    'uint-enums' => \$opt_uint_enums,
 	    'header:s' => \$opt_header,
 	    'server' => \$opt_server,
 	    'template' => \$opt_template,
 	    'parser:s' => \$opt_parser,
-        'client' => \$opt_client,
+	    'client' => \$opt_client,
 	    'eth-parser:s' => \$opt_eth_parser,
-		'eth-header:s' => \$opt_eth_header,
-		'esp:s' => \$opt_esp,
+	    'eth-header:s' => \$opt_eth_header,
+	    'esp:s' => \$opt_esp,
 	    'diff' => \$opt_diff,
-		'odl' => \$opt_odl,
+	    'odl' => \$opt_odl,
 	    'keep' => \$opt_keep,
 	    'swig' => \$opt_swig,
-		'dcom-proxy' => \$opt_dcom_proxy,
-		'com-header' => \$opt_com_header,
-		'quiet' => \$opt_quiet,
-		'warn-compat' => \$opt_warn_compat
+	    'dcom-proxy' => \$opt_dcom_proxy,
+	    'com-header' => \$opt_com_header,
+	    'quiet' => \$opt_quiet,
+	    'warn-compat' => \$opt_warn_compat
 	    );
 
 if ($opt_help) {
@@ -151,6 +154,10 @@
 		defined $pidl || die "Failed to load $pidl_file - maybe you need --parse\n";
 	}
 
+	if ($opt_uint_enums) {
+		util::setUseUintEnums(1);
+	}
+
 	if ($opt_dump) {
 		print IdlDump::Dump($pidl);
 	}

Modified: branches/SAMBA_4_0/source/build/pidl/util.pm
===================================================================
--- branches/SAMBA_4_0/source/build/pidl/util.pm	2005-06-09 07:45:29 UTC (rev 7423)
+++ branches/SAMBA_4_0/source/build/pidl/util.pm	2005-06-09 07:48:26 UTC (rev 7424)
@@ -204,4 +204,15 @@
 	return "\"" . $str . "\"";
 }
 
+# a hack to build on platforms that don't like negative enum values
+my $useUintEnums = 0;
+sub setUseUintEnums($)
+{
+	$useUintEnums = shift;
+}
+sub useUintEnums()
+{
+	return $useUintEnums;
+}
+
 1;



More information about the samba-cvs mailing list