svn commit: samba r5288 - in branches/SAMBA_4_0/source/build/pidl: .
jelmer at samba.org
jelmer at samba.org
Wed Feb 9 21:53:25 GMT 2005
Author: jelmer
Date: 2005-02-09 21:53:25 +0000 (Wed, 09 Feb 2005)
New Revision: 5288
WebSVN: http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=rev&root=samba&rev=5288
Log:
Make alignment code more generic
Modified:
branches/SAMBA_4_0/source/build/pidl/parser.pm
Changeset:
Modified: branches/SAMBA_4_0/source/build/pidl/parser.pm
===================================================================
--- branches/SAMBA_4_0/source/build/pidl/parser.pm 2005-02-09 21:23:33 UTC (rev 5287)
+++ branches/SAMBA_4_0/source/build/pidl/parser.pm 2005-02-09 21:53:25 UTC (rev 5288)
@@ -1,5 +1,5 @@
###################################################
-# Samba4 parser generator for IDL structures
+# Samba4 NDR parser generator for IDL structures
# Copyright tridge at samba.org 2000-2003
# Copyright tpot at samba.org 2001
# Copyright jelmer at samba.org 2004
@@ -10,8 +10,8 @@
use strict;
use needed;
-# the list of needed functions
-my %structs;
+# list of known types
+my %typedefs;
sub pidl($)
{
@@ -184,20 +184,7 @@
for my $e (@{$s->{ELEMENTS}}) {
my $a = 1;
- if (!util::need_wire_pointer($e)
- && defined $structs{$e->{TYPE}}) {
- if ($structs{$e->{TYPE}}->{DATA}->{TYPE} eq "STRUCT") {
- $a = struct_alignment($structs{$e->{TYPE}}->{DATA});
- } elsif ($structs{$e->{TYPE}}->{DATA}->{TYPE} eq "UNION") {
- if (defined $structs{$e->{TYPE}}->{DATA}) {
- $a = union_alignment($structs{$e->{TYPE}}->{DATA});
- }
- } elsif ($structs{$e->{TYPE}}->{DATA}->{TYPE} eq "ENUM") {
- $a = util::type_align($e);
- }
- } else {
- $a = util::type_align($e);
- }
+ $a = align_type($e);
if ($align < $a) {
$align = $a;
@@ -222,17 +209,7 @@
next;
}
- if (!util::need_wire_pointer($e)
- && defined $structs{$e->{DATA}->{TYPE}}) {
- my $s = $structs{$e->{DATA}->{TYPE}};
- if ($s->{DATA}->{TYPE} eq "STRUCT") {
- $a = struct_alignment($s->{DATA});
- } elsif ($s->{DATA}->{TYPE} eq "UNION") {
- $a = union_alignment($s->{DATA});
- }
- } else {
- $a = util::type_align($e->{DATA});
- }
+ $a = align_type($e->{DATA});
if ($align < $a) {
$align = $a;
@@ -243,6 +220,28 @@
}
#####################################################################
+# align a type
+sub align_type
+{
+ my $e = shift;
+
+ if (!util::need_wire_pointer($e)
+ && defined $typedefs{$e->{TYPE}}) {
+ if ($typedefs{$e->{TYPE}}->{DATA}->{TYPE} eq "STRUCT") {
+ return struct_alignment($typedefs{$e->{TYPE}}->{DATA});
+ } elsif ($typedefs{$e->{TYPE}}->{DATA}->{TYPE} eq "UNION") {
+ if (defined $typedefs{$e->{TYPE}}->{DATA}) {
+ return union_alignment($typedefs{$e->{TYPE}}->{DATA});
+ }
+ } elsif ($typedefs{$e->{TYPE}}->{DATA}->{TYPE} eq "ENUM") {
+ return util::type_align($e);
+ }
+ } else {
+ return util::type_align($e);
+ }
+}
+
+#####################################################################
# parse an array - push side
sub ParseArrayPush($$$)
{
@@ -457,7 +456,7 @@
my $cprefix = util::c_pull_prefix($e);
- my $utype = $structs{$e->{TYPE}};
+ my $utype = $typedefs{$e->{TYPE}};
check_null_pointer($switch_var);
@@ -511,7 +510,7 @@
check_null_pointer($switch_var);
- my $utype = $structs{$e->{TYPE}};
+ my $utype = $typedefs{$e->{TYPE}};
if (!defined $utype ||
!util::has_property($utype, "nodiscriminant")) {
my $e2 = find_sibling($e, $switch);
@@ -1713,10 +1712,10 @@
foreach my $d (@{$data}) {
if ($d->{TYPE} eq "DECLARE") {
- $structs{$d->{NAME}} = $d;
+ $typedefs{$d->{NAME}} = $d;
}
if ($d->{TYPE} eq "TYPEDEF") {
- $structs{$d->{NAME}} = $d;
+ $typedefs{$d->{NAME}} = $d;
}
}
@@ -1812,3 +1811,14 @@
}
1;
+
+#Each type can:
+#
+#- Generate push fn
+#- Generate pull fn
+#- Generate print fn
+#- Generate push array fn
+#- Generate pull array fn
+#- Generate print fn
+#- align size
+#- "push prefix"
More information about the samba-cvs
mailing list