summaryrefslogtreecommitdiff
path: root/source4
diff options
context:
space:
mode:
Diffstat (limited to 'source4')
-rw-r--r--source4/build/pidl/header.pm49
-rw-r--r--source4/build/pidl/idl.pm24
-rw-r--r--source4/build/pidl/idl.yp24
-rw-r--r--source4/build/pidl/ndr.pm50
-rw-r--r--source4/build/pidl/util.pm38
-rw-r--r--source4/librpc/ndr/ndr_basic.c3
6 files changed, 63 insertions, 125 deletions
diff --git a/source4/build/pidl/header.pm b/source4/build/pidl/header.pm
index 33e7d56208..c49f60ce8b 100644
--- a/source4/build/pidl/header.pm
+++ b/source4/build/pidl/header.pm
@@ -103,8 +103,6 @@ sub HeaderEnum($$)
my($enum) = shift;
my($name) = shift;
- util::register_enum($enum, $name);
-
pidl "\nenum $name {\n";
$tab_depth++;
my $els = \@{$enum->{ELEMENTS}};
@@ -133,8 +131,6 @@ sub HeaderBitmap($$)
my($bitmap) = shift;
my($name) = shift;
- util::register_bitmap($bitmap, $name);
-
pidl "\n/* bitmap $name */\n";
my $els = \@{$bitmap->{ELEMENTS}};
@@ -188,32 +184,27 @@ sub HeaderType($$$)
HeaderUnion($data, $name);
return;
}
+
+ my $dt = $NdrParser::typedefs{$e->{TYPE}}->{DATA};
+
if ($data =~ "string") {
pidl "const char *";
- } elsif (util::is_enum($e->{TYPE})) {
- pidl "enum $data";
- } elsif (util::is_bitmap($e->{TYPE})) {
- my $bitmap = util::get_bitmap($e->{TYPE});
- pidl util::bitmap_type_decl($bitmap);
- } elsif (NdrParser::is_scalar_type($data)) {
- pidl util::map_type($data);
- } elsif (util::has_property($e, "switch_is")) {
- pidl "union $data";
- } else {
+ } elsif (not defined($dt->{TYPE})) {
pidl "struct $data";
- }
-}
-
-#####################################################################
-# parse a declare
-sub HeaderDeclare($)
-{
- my($declare) = shift;
-
- if ($declare->{DATA}->{TYPE} eq "ENUM") {
- util::register_enum($declare, $declare->{NAME});
- } elsif ($declare->{DATA}->{TYPE} eq "BITMAP") {
- util::register_bitmap($declare, $declare->{NAME});
+ } else {
+ if ($dt->{TYPE} eq "ENUM") {
+ pidl "enum $data";
+ } elsif ($dt->{TYPE} eq "BITMAP") {
+ pidl util::bitmap_type_decl($dt);
+ } elsif ($dt->{TYPE} eq "SCALAR") {
+ pidl util::map_type($data);
+ } elsif ($dt->{TYPE} eq "UNION") {
+ pidl "union $data";
+ } elsif ($dt->{TYPE} eq "STRUCT") {
+ pidl "struct $data";
+ } else {
+ print "Unknown data type type $dt->{TYPE}\n";
+ }
}
}
@@ -471,8 +462,6 @@ sub HeaderInterface($)
foreach my $d (@{$data}) {
($d->{TYPE} eq "CONST") &&
HeaderConst($d);
- ($d->{TYPE} eq "DECLARE") &&
- HeaderDeclare($d);
($d->{TYPE} eq "TYPEDEF") &&
HeaderTypedef($d);
($d->{TYPE} eq "TYPEDEF") &&
@@ -496,6 +485,8 @@ sub Parse($)
my($idl) = shift;
$tab_depth = 0;
+ NdrParser::Load($idl);
+
$res = "";
pidl "/* header auto-generated by pidl */\n\n";
foreach my $x (@{$idl}) {
diff --git a/source4/build/pidl/idl.pm b/source4/build/pidl/idl.pm
index b18215ed34..6ae7cb463f 100644
--- a/source4/build/pidl/idl.pm
+++ b/source4/build/pidl/idl.pm
@@ -2383,28 +2383,8 @@ sub parse_idl($$)
my $idl = $self->YYParse( yylex => \&_Lexer, yyerror => \&_Error );
foreach my $x (@{$idl}) {
- # Add [in] ORPCTHIS *this, [out] ORPCTHAT *that
- # for 'object' interfaces
- if (util::has_property($x, "object")) {
- foreach my $e (@{$x->{DATA}}) {
- if($e->{TYPE} eq "FUNCTION") {
- $e->{PROPERTIES}->{object} = 1;
- unshift(@{$e->{ELEMENTS}},
- { 'NAME' => 'ORPCthis',
- 'POINTERS' => 0,
- 'PROPERTIES' => { 'in' => '1' },
- 'TYPE' => 'ORPCTHIS'
- });
- unshift(@{$e->{ELEMENTS}},
- { 'NAME' => 'ORPCthat',
- 'POINTERS' => 0,
- 'PROPERTIES' => { 'out' => '1' },
- 'TYPE' => 'ORPCTHAT'
- });
- }
- }
- }
-
+ NdrParser::InterfaceORPC($x);
+
# Do the inheritance
if (defined($x->{BASE}) and $x->{BASE} ne "") {
my $parent = util::get_interface($idl, $x->{BASE});
diff --git a/source4/build/pidl/idl.yp b/source4/build/pidl/idl.yp
index 4ee1703602..aff7f82f69 100644
--- a/source4/build/pidl/idl.yp
+++ b/source4/build/pidl/idl.yp
@@ -374,28 +374,8 @@ sub parse_idl($$)
my $idl = $self->YYParse( yylex => \&_Lexer, yyerror => \&_Error );
foreach my $x (@{$idl}) {
- # Add [in] ORPCTHIS *this, [out] ORPCTHAT *that
- # for 'object' interfaces
- if (util::has_property($x, "object")) {
- foreach my $e (@{$x->{DATA}}) {
- if($e->{TYPE} eq "FUNCTION") {
- $e->{PROPERTIES}->{object} = 1;
- unshift(@{$e->{ELEMENTS}},
- { 'NAME' => 'ORPCthis',
- 'POINTERS' => 0,
- 'PROPERTIES' => { 'in' => '1' },
- 'TYPE' => 'ORPCTHIS'
- });
- unshift(@{$e->{ELEMENTS}},
- { 'NAME' => 'ORPCthat',
- 'POINTERS' => 0,
- 'PROPERTIES' => { 'out' => '1' },
- 'TYPE' => 'ORPCTHAT'
- });
- }
- }
- }
-
+ NdrParser::InterfaceORPC($x);
+
# Do the inheritance
if (defined($x->{BASE}) and $x->{BASE} ne "") {
my $parent = util::get_interface($idl, $x->{BASE});
diff --git a/source4/build/pidl/ndr.pm b/source4/build/pidl/ndr.pm
index 6257fb360e..f3f40fb784 100644
--- a/source4/build/pidl/ndr.pm
+++ b/source4/build/pidl/ndr.pm
@@ -11,7 +11,7 @@ use strict;
use needed;
# list of known types
-my %typedefs;
+our %typedefs;
my %type_alignments =
(
@@ -55,9 +55,11 @@ sub is_scalar_type($)
{
my $type = shift;
- return 1 if (defined($typedefs{$type}) and $typedefs{$type}->{DATA}->{TYPE} eq "SCALAR");
- return 1 if (util::is_enum($type));
- return 1 if (util::is_bitmap($type));
+ if (my $dt = $typedefs{$type}->{DATA}->{TYPE}) {
+ return 1 if ($dt eq "SCALAR");
+ return 1 if ($dt eq "ENUM");
+ return 1 if ($dt eq "BITMAP");
+ }
return 0;
}
@@ -355,7 +357,7 @@ sub align_type
{
my $e = shift;
- unless (defined($typedefs{$e})) {
+ unless (defined($typedefs{$e}) && defined($typedefs{$e}->{DATA}->{TYPE})) {
# 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;
@@ -370,9 +372,9 @@ sub align_type
} elsif($dt->{TYPE} eq "UNION") {
$dt->{ALIGN} = struct_alignment($dt);
} elsif ($dt->{TYPE} eq "ENUM") {
- $dt->{ALIGN} = align_type(util::enum_type_fn(util::get_enum($e)));
+ $dt->{ALIGN} = align_type(util::enum_type_fn($typedefs{$e}->{DATA}));
} elsif ($dt->{TYPE} eq "BITMAP") {
- $dt->{ALIGN} = align_type(util::bitmap_type_fn(util::get_bitmap($e)));
+ $dt->{ALIGN} = align_type(util::bitmap_type_fn($typedefs{$e}->{DATA}));
}
if (not defined($dt->{ALIGN})) {
@@ -517,7 +519,6 @@ sub ParseArrayPull($$$)
}
}
-
#####################################################################
# parse scalars in a structure element
sub ParseElementPushScalar($$$)
@@ -606,9 +607,9 @@ sub ParseElementPullSwitch($$$$)
my $e2 = find_sibling($e, $switch);
my $type_decl = util::map_type($e2->{TYPE});
pidl "\tif (($ndr_flags) & NDR_SCALARS) {\n";
- if (util::is_enum($e2->{TYPE})) {
+ if ($typedefs{$e2->{TYPE}}->{DATA}->{TYPE} eq "ENUM") {
$type_decl = util::enum_type_decl($e2);
- } elsif (util::is_bitmap($e2->{TYPE})) {
+ } elsif ($typedefs{$e2->{TYPE}}->{DATA}->{TYPE} eq "BITMAP") {
$type_decl = util::bitmap_type_decl($e2);
}
pidl "\t\t$type_decl _level;\n";
@@ -1942,7 +1943,7 @@ sub LoadInterface($)
}
foreach my $d (@{$x->{DATA}}) {
- if ($d->{TYPE} eq "DECLARE" or $d->{TYPE} eq "TYPEDEF") {
+ if (($d->{TYPE} eq "DECLARE") or ($d->{TYPE} eq "TYPEDEF")) {
$typedefs{$d->{NAME}} = $d;
if ($d->{DATA}->{TYPE} eq "STRUCT" or $d->{DATA}->{TYPE} eq "UNION") {
CheckPointerTypes($d->{DATA}, $x->{PROPERTIES}->{pointer_default});
@@ -1956,6 +1957,33 @@ sub LoadInterface($)
}
}
+# Add ORPC specific bits to an interface.
+sub InterfaceORPC($)
+{
+ my $x = shift;
+ # Add [in] ORPCTHIS *this, [out] ORPCTHAT *that
+ # for 'object' interfaces
+ if (util::has_property($x, "object")) {
+ foreach my $e (@{$x->{DATA}}) {
+ if($e->{TYPE} eq "FUNCTION") {
+ $e->{PROPERTIES}->{object} = 1;
+ unshift(@{$e->{ELEMENTS}},
+ { 'NAME' => 'ORPCthis',
+ 'POINTERS' => 0,
+ 'PROPERTIES' => { 'in' => '1' },
+ 'TYPE' => 'ORPCTHIS'
+ });
+ unshift(@{$e->{ELEMENTS}},
+ { 'NAME' => 'ORPCthat',
+ 'POINTERS' => 0,
+ 'PROPERTIES' => { 'out' => '1' },
+ 'TYPE' => 'ORPCTHAT'
+ });
+ }
+ }
+ }
+}
+
sub Load($)
{
my $idl = shift;
diff --git a/source4/build/pidl/util.pm b/source4/build/pidl/util.pm
index 58d95eff39..02a7518ccf 100644
--- a/source4/build/pidl/util.pm
+++ b/source4/build/pidl/util.pm
@@ -202,25 +202,6 @@ sub property_matches($$$)
my %enum_list;
-sub register_enum($$)
-{
- my $enum = shift;
- my $name = shift;
- $enum_list{$name} = $enum;
-}
-
-sub is_enum($)
-{
- my $name = shift;
- return defined $enum_list{$name}
-}
-
-sub get_enum($)
-{
- my $name = shift;
- return $enum_list{$name};
-}
-
sub enum_type_decl($)
{
my $enum = shift;
@@ -240,25 +221,6 @@ sub enum_type_fn($)
my %bitmap_list;
-sub register_bitmap($$)
-{
- my $bitmap = shift;
- my $name = shift;
- $bitmap_list{$name} = $bitmap;
-}
-
-sub is_bitmap($)
-{
- my $name = shift;
- return defined $bitmap_list{$name};
-}
-
-sub get_bitmap($)
-{
- my $name = shift;
- return $bitmap_list{$name};
-}
-
sub bitmap_type_fn($)
{
my $bitmap = shift;
diff --git a/source4/librpc/ndr/ndr_basic.c b/source4/librpc/ndr/ndr_basic.c
index 8f43d6c18a..5eecb1d60b 100644
--- a/source4/librpc/ndr/ndr_basic.c
+++ b/source4/librpc/ndr/ndr_basic.c
@@ -486,9 +486,6 @@ NTSTATUS ndr_push_unique_ptr(struct ndr_push *ndr, const void *p)
{
uint32_t ptr = 0;
if (p) {
- /* we do this to ensure that we generate unique ref ids,
- which means we can handle the case where a MS programmer
- forgot to mark a pointer as unique */
ndr->ptr_count++;
ptr = ndr->ptr_count;
}