summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJelmer Vernooij <jelmer@samba.org>2005-02-20 12:17:33 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 13:10:48 -0500
commitc33c4569e51f2a351d16932cd491ec30545c8f70 (patch)
tree667ea1a67c9c621b11216c1d08b904928e980e1d
parent64112074e9772aead31092c8713e077d1aff050b (diff)
downloadsamba-c33c4569e51f2a351d16932cd491ec30545c8f70.tar.gz
samba-c33c4569e51f2a351d16932cd491ec30545c8f70.tar.bz2
samba-c33c4569e51f2a351d16932cd491ec30545c8f70.zip
r5466: Put the type information list in a seperate module
(require for some of the COM stuff) (This used to be commit fbce7464b2a61a46f5135ba2a341bea4e53f28e7)
-rw-r--r--source4/build/pidl/header.pm3
-rw-r--r--source4/build/pidl/ndr.pm59
-rw-r--r--source4/build/pidl/typelist.pm56
-rw-r--r--source4/build/pidl/util.pm1
4 files changed, 80 insertions, 39 deletions
diff --git a/source4/build/pidl/header.pm b/source4/build/pidl/header.pm
index d450886604..efcd2dbb45 100644
--- a/source4/build/pidl/header.pm
+++ b/source4/build/pidl/header.pm
@@ -7,6 +7,7 @@ package IdlHeader;
use strict;
use needed;
+use typelist;
my($res);
my($tab_depth);
@@ -195,7 +196,7 @@ sub HeaderType($$$)
}
my $dt;
- if (my $t = NdrParser::get_typedef($e->{TYPE})) {
+ if (my $t = typelist::getType($e->{TYPE})) {
$dt = $t->{DATA};
}
diff --git a/source4/build/pidl/ndr.pm b/source4/build/pidl/ndr.pm
index 4f78ca6888..df756e2f30 100644
--- a/source4/build/pidl/ndr.pm
+++ b/source4/build/pidl/ndr.pm
@@ -9,27 +9,19 @@ package NdrParser;
use strict;
use needed;
+use typelist;
# list of known types
-my %typedefs;
my %typefamily;
-sub get_typedef($)
-{
- my $n = shift;
- return $typedefs{$n};
-}
-
sub get_typefamily($)
{
my $n = shift;
return $typefamily{$n};
}
-sub RegisterPrimitives()
-{
- my %type_alignments =
- (
+my %scalar_alignments =
+(
"char" => 1,
"int8" => 1,
"uint8" => 1,
@@ -55,25 +47,22 @@ sub RegisterPrimitives()
"ipv4address" => 4,
"hyper" => 8,
"NTTIME_hyper" => 8
- );
-
- foreach my $k (keys %type_alignments) {
- $typedefs{$k} = {
- NAME => $k,
- TYPE => "TYPEDEF",
- DATA => {
- TYPE => "SCALAR",
- ALIGN => $type_alignments{$k}
- }
- };
+);
+
+$typefamily{SCALAR} = {
+ ALIGN => sub {
+ my $t = shift;
+ return $scalar_alignments{$t->{NAME}};
}
-}
+};
sub is_scalar_type($)
{
my $type = shift;
- if (my $dt = $typedefs{$type}->{DATA}->{TYPE}) {
+ return 0 unless typelist::hasType($type);
+
+ if (my $dt = typelist::getType($type)->{DATA}->{TYPE}) {
return 1 if ($dt eq "SCALAR" or $dt eq "ENUM" or $dt eq "BITMAP");
}
@@ -430,16 +419,16 @@ sub align_type
{
my $e = shift;
- unless (defined($typedefs{$e}) && defined($typedefs{$e}->{DATA}->{TYPE})) {
+ unless (typelist::hasType($e)) {
# it must be an external type - all we can do is guess
# print "Warning: assuming alignment of unknown type '$e' is 4\n";
return 4;
}
- my $dt = $typedefs{$e}->{DATA};
+ my $dt = typelist::getType($e)->{DATA};
- return $dt->{ALIGN} if ($dt->{ALIGN});
- return $typefamily{$dt->{TYPE}}->{ALIGN}->($dt);
+ my $tmp = $typefamily{$dt->{TYPE}}->{ALIGN}->($dt);
+ return $tmp;
}
#####################################################################
@@ -657,7 +646,6 @@ sub ParseElementPushPtr($$$)
pidl "NDR_CHECK(ndr_push_unique_ptr(ndr, $var_prefix$e->{NAME}));";
}
-
#####################################################################
# print scalars in a structure element
sub ParseElementPrint($$)
@@ -721,7 +709,7 @@ sub ParseElementPullSwitch($$$$)
my $cprefix = c_pull_prefix($e);
- my $utype = $typedefs{$e->{TYPE}};
+ my $utype = typelist::getType($e->{TYPE});
check_null_pointer($switch_var);
@@ -731,9 +719,9 @@ sub ParseElementPullSwitch($$$$)
my $type_decl = util::map_type($e2->{TYPE});
pidl "if (($ndr_flags) & NDR_SCALARS) {";
indent;
- if ($typedefs{$e2->{TYPE}}->{DATA}->{TYPE} eq "ENUM") {
+ if (typelist::getType($e2->{TYPE})->{DATA}->{TYPE} eq "ENUM") {
$type_decl = util::enum_type_decl($e2);
- } elsif ($typedefs{$e2->{TYPE}}->{DATA}->{TYPE} eq "BITMAP") {
+ } elsif (typelist::getType($e2->{TYPE})->{DATA}->{TYPE} eq "BITMAP") {
$type_decl = util::bitmap_type_decl($e2);
}
pidl "$type_decl _level;";
@@ -783,7 +771,7 @@ sub ParseElementPushSwitch($$$$)
check_null_pointer($switch_var);
- my $utype = $typedefs{$e->{TYPE}};
+ my $utype = typelist::getType($e->{TYPE});
if (!defined $utype ||
!util::has_property($utype, "nodiscriminant")) {
my $e2 = find_sibling($e, $switch);
@@ -2104,7 +2092,7 @@ sub LoadInterface($)
foreach my $d (@{$x->{DATA}}) {
if (($d->{TYPE} eq "DECLARE") or ($d->{TYPE} eq "TYPEDEF")) {
- $typedefs{$d->{NAME}} = $d;
+ typelist::addType($d);
if ($d->{DATA}->{TYPE} eq "STRUCT" or $d->{DATA}->{TYPE} eq "UNION") {
CheckPointerTypes($d->{DATA}, $x->{PROPERTIES}->{pointer_default});
}
@@ -2190,7 +2178,4 @@ sub Parse($$)
return $res;
}
-RegisterPrimitives();
-
1;
-
diff --git a/source4/build/pidl/typelist.pm b/source4/build/pidl/typelist.pm
new file mode 100644
index 0000000000..e5d6a81355
--- /dev/null
+++ b/source4/build/pidl/typelist.pm
@@ -0,0 +1,56 @@
+###################################################
+# Samba4 parser generator for IDL structures
+# Copyright jelmer@samba.org 2005
+# released under the GNU GPL
+
+package typelist;
+
+use strict;
+
+my %typedefs;
+
+sub addType($)
+{
+ my $t = shift;
+ $typedefs{$t->{NAME}} = $t;
+}
+
+sub getType($)
+{
+ my $t = shift;
+ return undef unless(defined($typedefs{$t}));
+ return $typedefs{$t};
+}
+
+sub hasType($)
+{
+ my $t = shift;
+ return 1 if defined($typedefs{$t});
+ return 0;
+}
+
+sub RegisterPrimitives()
+{
+ my @primitives = (
+ "char", "int8", "uint8", "short", "wchar_t",
+ "int16", "uint16", "long", "int32", "uint32",
+ "dlong", "udlong", "udlongr", "NTTIME", "NTTIME_1sec",
+ "time_t", "DATA_BLOB", "error_status_t", "WERROR",
+ "NTSTATUS", "boolean32", "unsigned32", "ipv4address",
+ "hyper", "NTTIME_hyper");
+
+ foreach my $k (@primitives) {
+ $typedefs{$k} = {
+ NAME => $k,
+ TYPE => "TYPEDEF",
+ DATA => {
+ TYPE => "SCALAR",
+ NAME => $k
+ }
+ };
+ }
+}
+
+RegisterPrimitives();
+
+1;
diff --git a/source4/build/pidl/util.pm b/source4/build/pidl/util.pm
index f5971c1624..1a908e92e3 100644
--- a/source4/build/pidl/util.pm
+++ b/source4/build/pidl/util.pm
@@ -322,4 +322,3 @@ sub map_type($)
}
1;
-