mirror of
https://github.com/samba-team/samba.git
synced 2025-01-08 21:18:16 +03:00
pidl: Add a helper function to determine whether a type is a string type
Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
This commit is contained in:
parent
d1e5a6176c
commit
436814572d
@ -608,7 +608,7 @@ sub ParseStruct($$$)
|
||||
$surrounding = $e;
|
||||
}
|
||||
|
||||
if (defined $e->{TYPE} && $e->{TYPE} eq "string"
|
||||
if (defined $e->{TYPE} && Parse::Pidl::Typelist::is_string_type($e->{TYPE})
|
||||
&& property_matches($e, "flag", ".*LIBNDR_FLAG_STR_CONFORMANT.*")) {
|
||||
$surrounding = $struct->{ELEMENTS}[-1];
|
||||
}
|
||||
|
@ -763,8 +763,8 @@ sub ParseFunction($$$)
|
||||
# TODO: make this fatal at NDR level
|
||||
if ($e->{LEVELS}[0]->{TYPE} eq "POINTER") {
|
||||
if ($e->{LEVELS}[1]->{TYPE} eq "DATA" and
|
||||
$e->{LEVELS}[1]->{DATA_TYPE} eq "string") {
|
||||
$reason = "is a pointer to type 'string'";
|
||||
Parse::Pidl::Typelist::is_string_type($e->{LEVELS}[1]->{DATA_TYPE})) {
|
||||
$reason = "is a pointer to a string type";
|
||||
} elsif ($e->{LEVELS}[1]->{TYPE} eq "ARRAY" and
|
||||
$e->{LEVELS}[1]->{IS_ZERO_TERMINATED}) {
|
||||
next;
|
||||
|
@ -1119,7 +1119,7 @@ sub ParseMemCtxPullFlags($$$$)
|
||||
my $nl = GetNextLevel($e, $l);
|
||||
return undef if ($nl->{TYPE} eq "PIPE");
|
||||
return undef if ($nl->{TYPE} eq "ARRAY");
|
||||
return undef if (($nl->{TYPE} eq "DATA") and ($nl->{DATA_TYPE} eq "string"));
|
||||
return undef if (($nl->{TYPE} eq "DATA") and (Parse::Pidl::Typelist::is_string_type($nl->{DATA_TYPE})));
|
||||
|
||||
if ($l->{LEVEL} eq "TOP") {
|
||||
$mem_flags = "LIBNDR_FLAG_REF_ALLOC";
|
||||
@ -1358,7 +1358,7 @@ sub ParsePtrPull($$$$$)
|
||||
my $nl = GetNextLevel($e, $l);
|
||||
my $next_is_array = ($nl->{TYPE} eq "ARRAY");
|
||||
my $next_is_string = (($nl->{TYPE} eq "DATA") and
|
||||
($nl->{DATA_TYPE} eq "string"));
|
||||
(Parse::Pidl::Typelist::is_string_type($nl->{DATA_TYPE})));
|
||||
|
||||
if ($l->{POINTER_TYPE} eq "ref" and $l->{LEVEL} eq "TOP") {
|
||||
|
||||
@ -2644,7 +2644,7 @@ sub ParseFunctionPull($$)
|
||||
next unless ($e->{LEVELS}[0]->{TYPE} eq "POINTER" and
|
||||
$e->{LEVELS}[0]->{POINTER_TYPE} eq "ref");
|
||||
next if (($e->{LEVELS}[1]->{TYPE} eq "DATA") and
|
||||
($e->{LEVELS}[1]->{DATA_TYPE} eq "string"));
|
||||
(Parse::Pidl::Typelist::is_string_type($e->{LEVELS}[1]->{DATA_TYPE})));
|
||||
next if ($e->{LEVELS}[1]->{TYPE} eq "PIPE");
|
||||
next if (($e->{LEVELS}[1]->{TYPE} eq "ARRAY")
|
||||
and $e->{LEVELS}[1]->{IS_ZERO_TERMINATED});
|
||||
@ -2696,7 +2696,7 @@ sub ParseFunctionPull($$)
|
||||
next unless ($e->{LEVELS}[0]->{TYPE} eq "POINTER" and
|
||||
$e->{LEVELS}[0]->{POINTER_TYPE} eq "ref");
|
||||
next if (($e->{LEVELS}[1]->{TYPE} eq "DATA") and
|
||||
($e->{LEVELS}[1]->{DATA_TYPE} eq "string"));
|
||||
(Parse::Pidl::Typelist::is_string_type($e->{LEVELS}[1]->{DATA_TYPE})));
|
||||
next if ($e->{LEVELS}[1]->{TYPE} eq "PIPE");
|
||||
next if ($e->{LEVELS}[1]->{TYPE} eq "ARRAY");
|
||||
|
||||
|
@ -10,6 +10,7 @@ require Exporter;
|
||||
@EXPORT_OK = qw(hasType getType resolveType mapTypeName mapTypeSpecifier scalar_is_reference expandAlias
|
||||
mapScalarType addType typeIs is_signed is_scalar enum_type_fn
|
||||
bitmap_type_fn mapType typeHasBody is_fixed_size_scalar
|
||||
is_string_type
|
||||
);
|
||||
use vars qw($VERSION);
|
||||
$VERSION = '0.01';
|
||||
@ -230,6 +231,13 @@ sub scalar_is_reference($)
|
||||
return 0;
|
||||
}
|
||||
|
||||
sub is_string_type
|
||||
{
|
||||
my ($t) = @_;
|
||||
|
||||
return ($t eq "string");
|
||||
}
|
||||
|
||||
sub RegisterScalars()
|
||||
{
|
||||
foreach (keys %scalars) {
|
||||
|
Loading…
Reference in New Issue
Block a user