diff options
Diffstat (limited to 'source4/pidl/lib/Parse')
-rw-r--r-- | source4/pidl/lib/Parse/Pidl/NDR.pm | 26 | ||||
-rw-r--r-- | source4/pidl/lib/Parse/Pidl/Samba4/Header.pm | 6 | ||||
-rw-r--r-- | source4/pidl/lib/Parse/Pidl/Samba4/NDR/Parser.pm | 30 | ||||
-rw-r--r-- | source4/pidl/lib/Parse/Pidl/Typelist.pm | 21 |
4 files changed, 47 insertions, 36 deletions
diff --git a/source4/pidl/lib/Parse/Pidl/NDR.pm b/source4/pidl/lib/Parse/Pidl/NDR.pm index 5839b042d3..21875a1297 100644 --- a/source4/pidl/lib/Parse/Pidl/NDR.pm +++ b/source4/pidl/lib/Parse/Pidl/NDR.pm @@ -571,8 +571,7 @@ sub ParseFunction($$$) sub CheckPointerTypes($$) { - my $s = shift; - my $default = shift; + my ($s,$default) = @_; foreach my $e (@{$s->{ELEMENTS}}) { if ($e->{POINTERS} and not defined(pointer_type($e))) { @@ -581,6 +580,23 @@ sub CheckPointerTypes($$) } } +#FIXME: Remove when ref handling in Samba4 is fixed +sub AddKeepRef($) +{ + my $d = shift; + + if ($d->{TYPE} eq "FUNCTION") { + foreach (@{$d->{ELEMENTS}}) { + $_->{PROPERTIES}->{keepref} = 1; + } + } elsif ($d->{TYPE} eq "TYPEDEF" and ($d->{DATA}->{TYPE} eq "STRUCT" + or $d->{DATA}->{TYPE} eq "UNION")) { + foreach (@{$d->{DATA}->{ELEMENTS}}) { + $_->{PROPERTIES}->{keepref} = 1; + } + } +} + sub ParseInterface($) { my $idl = shift; @@ -606,10 +622,12 @@ sub ParseInterface($) if ($d->{TYPE} eq "DECLARE") { push (@declares, $d); } elsif ($d->{TYPE} eq "FUNCTION") { + AddKeepRef($d) if (has_property($idl, "keepref")); push (@functions, ParseFunction($idl, $d, \$opnum)); } elsif ($d->{TYPE} eq "CONST") { push (@consts, ParseConst($idl, $d)); } else { + AddKeepRef($d) if (has_property($idl, "keepref")); push (@types, ParseType($idl, $d)); } } @@ -831,6 +849,10 @@ my %property_list = ( "noheader" => ["ELEMENT"], "charset" => ["ELEMENT"], "length_is" => ["ELEMENT"], + + # temporary (should be removed once we've migrated away from + # relying on ref pointers being there in Samba4's code) + "keepref" => ["ELEMENT","INTERFACE"], ); ##################################################################### diff --git a/source4/pidl/lib/Parse/Pidl/Samba4/Header.pm b/source4/pidl/lib/Parse/Pidl/Samba4/Header.pm index 6fb3ee2eec..c9487115f5 100644 --- a/source4/pidl/lib/Parse/Pidl/Samba4/Header.pm +++ b/source4/pidl/lib/Parse/Pidl/Samba4/Header.pm @@ -60,7 +60,11 @@ sub HeaderElement($) } else { HeaderType($element, $element->{TYPE}, ""); pidl " "; - my $numstar = $element->{POINTERS}; + my $numstar = 0; + if (!has_property($element, "ref") or + has_property($element, "keepref")) { + $numstar += $element->{POINTERS}; + } if ($numstar >= 1) { $numstar-- if Parse::Pidl::Typelist::scalar_is_reference($element->{TYPE}); } diff --git a/source4/pidl/lib/Parse/Pidl/Samba4/NDR/Parser.pm b/source4/pidl/lib/Parse/Pidl/Samba4/NDR/Parser.pm index b7ae526e68..5a8ef53e14 100644 --- a/source4/pidl/lib/Parse/Pidl/Samba4/NDR/Parser.pm +++ b/source4/pidl/lib/Parse/Pidl/Samba4/NDR/Parser.pm @@ -582,7 +582,9 @@ sub ParseElementPushLevel pidl "NDR_CHECK(ndr_push_relative_ptr2(ndr, $var_name));"; } } - $var_name = get_value_of($var_name); + if ($l->{POINTER_TYPE} ne "ref" or has_property($e, "keepref")) { + $var_name = get_value_of($var_name); + } ParseElementPushLevel($e, GetNextLevel($e, $l), $ndr, $var_name, $env, 1, 1); if ($l->{POINTER_TYPE} ne "ref") { @@ -662,11 +664,12 @@ sub ParsePtrPush($$$) my ($e,$l,$var_name) = @_; if ($l->{POINTER_TYPE} eq "ref") { - if ($l->{LEVEL} eq "EMBEDDED") { - pidl "NDR_CHECK(ndr_push_ref_ptr(ndr, $var_name));"; - } else { + if (has_property($e, "keepref")) { check_null_pointer(get_value_of($var_name)); } + if ($l->{LEVEL} eq "EMBEDDED") { + pidl "NDR_CHECK(ndr_push_ref_ptr(ndr));"; + } } elsif ($l->{POINTER_TYPE} eq "relative") { pidl "NDR_CHECK(ndr_push_relative_ptr1(ndr, $var_name));"; } elsif ($l->{POINTER_TYPE} eq "unique") { @@ -872,7 +875,7 @@ sub ParseMemCtxPullStart($$$) my $next_is_array = ($nl->{TYPE} eq "ARRAY"); my $next_is_string = (($nl->{TYPE} eq "DATA") and ($nl->{DATA_TYPE} eq "string")); - if ($next_is_array or $next_is_string) { + if ($next_is_array or $next_is_string or not has_property($e, "keepref")) { return; } else { $mem_c_flags = "LIBNDR_FLAG_REF_ALLOC"; @@ -898,7 +901,7 @@ sub ParseMemCtxPullEnd($$) my $next_is_array = ($nl->{TYPE} eq "ARRAY"); my $next_is_string = (($nl->{TYPE} eq "DATA") and ($nl->{DATA_TYPE} eq "string")); - if ($next_is_array or $next_is_string) { + if ($next_is_array or $next_is_string or not has_property($e, "keepref")) { return; } else { $mem_r_flags = "LIBNDR_FLAG_REF_ALLOC"; @@ -975,7 +978,9 @@ sub ParseElementPullLevel ParseMemCtxPullStart($e,$l, $var_name); - $var_name = get_value_of($var_name); + if ($l->{POINTER_TYPE} ne "ref" or has_property($e, "keepref")) { + $var_name = get_value_of($var_name); + } ParseElementPullLevel($e,GetNextLevel($e,$l), $ndr, $var_name, $env, 1, 1); ParseMemCtxPullEnd($e,$l); @@ -1075,11 +1080,12 @@ sub ParsePtrPull($$$$) ($nl->{DATA_TYPE} eq "string")); if ($l->{POINTER_TYPE} eq "ref") { - unless ($l->{LEVEL} eq "TOP") { + if ($l->{LEVEL} eq "EMBEDDED") { pidl "NDR_CHECK(ndr_pull_ref_ptr($ndr, &_ptr_$e->{NAME}));"; } - unless ($next_is_array or $next_is_string) { + if (!$next_is_array and !$next_is_string and + has_property($e, "keepref")) { pidl "if (ndr->flags & LIBNDR_FLAG_REF_ALLOC) {"; pidl "\tNDR_PULL_ALLOC($ndr, $var_name);"; pidl "}"; @@ -1413,8 +1419,7 @@ sub DeclareArrayVariables($) sub need_decl_mem_ctx($$) { - my $e = shift; - my $l = shift; + my ($e,$l) = @_; return 0 if has_fast_array($e,$l); return 0 if is_charset_array($e,$l); @@ -1425,7 +1430,7 @@ sub need_decl_mem_ctx($$) my $next_is_array = ($nl->{TYPE} eq "ARRAY"); my $next_is_string = (($nl->{TYPE} eq "DATA") and ($nl->{DATA_TYPE} eq "string")); - return 0 if ($next_is_array or $next_is_string); + return 0 if ($next_is_array or $next_is_string or not has_property($e, "keepref")); } return 1 if ($l->{TYPE} eq "POINTER"); @@ -2091,6 +2096,7 @@ sub ParseFunctionPull($) next unless (grep(/out/, @{$e->{DIRECTION}})); next unless ($e->{LEVELS}[0]->{TYPE} eq "POINTER" and $e->{LEVELS}[0]->{POINTER_TYPE} eq "ref"); + next unless has_property($e, "keepref"); next if (($e->{LEVELS}[1]->{TYPE} eq "DATA") and ($e->{LEVELS}[1]->{DATA_TYPE} eq "string")); next if (($e->{LEVELS}[1]->{TYPE} eq "ARRAY") diff --git a/source4/pidl/lib/Parse/Pidl/Typelist.pm b/source4/pidl/lib/Parse/Pidl/Typelist.pm index 10a1e8136f..66d5e59e7c 100644 --- a/source4/pidl/lib/Parse/Pidl/Typelist.pm +++ b/source4/pidl/lib/Parse/Pidl/Typelist.pm @@ -23,50 +23,29 @@ my @reference_scalars = ( # a list of known scalar types my %scalars = ( - # 0 byte types "void" => "void", - - # 1 byte types "char" => "char", "int8" => "int8_t", "uint8" => "uint8_t", - - # 2 byte types "int16" => "int16_t", "uint16" => "uint16_t", - - # 4 byte types "int32" => "int32_t", "uint32" => "uint32_t", - - # 8 byte types "hyper" => "uint64_t", "dlong" => "int64_t", "udlong" => "uint64_t", "udlongr" => "uint64_t", - - # assume its a 8 byte type, but cope with either "pointer" => "void*", - - # DATA_BLOB types "DATA_BLOB" => "DATA_BLOB", - - # string types "string" => "const char *", "string_array" => "const char **", - - # time types "time_t" => "time_t", "NTTIME" => "NTTIME", "NTTIME_1sec" => "NTTIME", "NTTIME_hyper" => "NTTIME", - - # error code types "WERROR" => "WERROR", "NTSTATUS" => "NTSTATUS", "COMRESULT" => "COMRESULT", - - # special types "nbt_string" => "const char *", "wrepl_nbt_name"=> "struct nbt_name *", "ipv4address" => "const char *", |