diff options
author | Andrew Tridgell <tridge@samba.org> | 2005-01-06 07:22:47 +0000 |
---|---|---|
committer | Gerald (Jerry) Carter <jerry@samba.org> | 2007-10-10 13:08:27 -0500 |
commit | 939d37a0f2f1c5193bdbdd20d4fad387a79c5d99 (patch) | |
tree | da5014933814587b49b012bef7e62cdeaf06b043 /source4/build/pidl/util.pm | |
parent | 88217c3b26efee054557bbdac84b6ad5a2253b08 (diff) | |
download | samba-939d37a0f2f1c5193bdbdd20d4fad387a79c5d99.tar.gz samba-939d37a0f2f1c5193bdbdd20d4fad387a79c5d99.tar.bz2 samba-939d37a0f2f1c5193bdbdd20d4fad387a79c5d99.zip |
r4556: neater (and faster) way of doing alignments and scalars
(This used to be commit ec70d9a740ab0b6f83b6b10c1b5313e585164383)
Diffstat (limited to 'source4/build/pidl/util.pm')
-rw-r--r-- | source4/build/pidl/util.pm | 63 |
1 files changed, 30 insertions, 33 deletions
diff --git a/source4/build/pidl/util.pm b/source4/build/pidl/util.pm index e3ec3d6138..189f88de0f 100644 --- a/source4/build/pidl/util.pm +++ b/source4/build/pidl/util.pm @@ -279,23 +279,41 @@ sub bitmap_type_fn($) return bitmap_type_decl($bitmap); } +my %type_alignments = + ( + "char" => 1, + "int8" => 1, + "uint8" => 1, + "short" => 2, + "wchar_t" => 2, + "int16" => 2, + "uint16" => 2, + "long" => 4, + "int32" => 4, + "uint32" => 4, + "int64" => 4, + "uint64" => 4, + "NTTIME" => 4, + "NTTIME_1sec" => 4, + "time_t" => 4, + "DATA_BLOB" => 4, + "error_status_t" => 4, + "WERROR" => 4, + "boolean32" => 4, + "unsigned32" => 4, + "HYPER_T" => 8 + ); + sub is_scalar_type($) { - my($type) = shift; + my $type = shift; - if ($type =~ /^u?int\d+/) { - return 1; - } - if ($type =~ /char|short|long|NTTIME|NTTIME_1sec| - time_t|error_status_t|boolean32|unsigned32| - HYPER_T|wchar_t|DATA_BLOB|WERROR/x) { + if (defined $type_alignments{$type}) { return 1; } - if (is_enum($type)) { return 1; } - if (is_bitmap($type)) { return 1; } @@ -312,30 +330,9 @@ sub type_align($) if (need_wire_pointer($e)) { return 4; } - - return 1, if ($type eq "char"); - return 1, if ($type eq "int8"); - return 1, if ($type eq "uint8"); - - return 2, if ($type eq "short"); - return 2, if ($type eq "wchar_t"); - return 2, if ($type eq "int16"); - return 2, if ($type eq "uint16"); - - return 4, if ($type eq "long"); - return 4, if ($type eq "int32"); - return 4, if ($type eq "uint32"); - - return 4, if ($type eq "int64"); - return 4, if ($type eq "uint64"); - - return 4, if ($type eq "NTTIME"); - return 4, if ($type eq "NTTIME_1sec"); - return 4, if ($type eq "time_t"); - - return 4, if ($type eq "DATA_BLOB"); - - return 8, if ($type eq "HYPER_T"); + if (my $ret = $type_alignments{$type}) { + return $ret; + } # it must be an external type - all we can do is guess return 4; |