1
0
mirror of https://github.com/samba-team/samba.git synced 2025-01-25 06:04:04 +03:00

r8612: Parse::Pidl::NDR:

Values that are deferred but don't contain deferred data don't
	need NDR_BUFFERS

Parse::Pidl::Samba::NDR::Parser:
	Only use manually written array access functions when the array
	functions are faster then the autogenerated ones. Makes ndr_basic.c
	a bit shorter.
This commit is contained in:
Jelmer Vernooij 2005-07-19 19:00:22 +00:00 committed by Gerald (Jerry) Carter
parent 1183f54c8d
commit cad40815dc
3 changed files with 11 additions and 201 deletions

View File

@ -9,7 +9,7 @@ package Parse::Pidl::NDR;
require Exporter;
@ISA = qw(Exporter);
@EXPORT = qw(GetPrevLevel GetNextLevel);
@EXPORT = qw(GetPrevLevel GetNextLevel ContainsDeferred);
use strict;
use Parse::Pidl::Typelist qw(hasType getType);
@ -195,7 +195,6 @@ sub GetElementLevelTable($)
nonfatal($e, "string() attribute on non-array element");
}
push (@$order, {
TYPE => "DATA",
DATA_TYPE => $e->{TYPE},
@ -216,13 +215,13 @@ sub can_contain_deferred
{
my $e = shift;
return 1 if ($e->{POINTERS});
return 0 if (Parse::Pidl::Typelist::is_scalar($e->{TYPE}));
return 1 unless (hasType($e->{TYPE})); # assume the worst
my $type = getType($e->{TYPE});
foreach my $x (@{$type->{DATA}->{ELEMENTS}}) {
return 1 if ($x->{POINTERS});
return 1 if (can_contain_deferred ($x));
}

View File

@ -10,7 +10,7 @@ package Parse::Pidl::Samba::NDR::Parser;
use strict;
use Parse::Pidl::Typelist qw(hasType getType);
use Parse::Pidl::Util qw(has_property ParseExpr);
use Parse::Pidl::NDR qw(GetPrevLevel GetNextLevel);
use Parse::Pidl::NDR qw(GetPrevLevel GetNextLevel ContainsDeferred);
# list of known types
my %typefamily;
@ -55,7 +55,10 @@ sub has_fast_array($$)
return 0 unless ($nl->{TYPE} eq "DATA");
return 0 unless (hasType($nl->{DATA_TYPE}));
return Parse::Pidl::Typelist::is_scalar($nl->{DATA_TYPE});
my $t = getType($nl->{DATA_TYPE});
# Only uint8 and string have fast array functions at the moment
return ($t->{NAME} eq "uint8") or ($t->{NAME} eq "string");
}
sub get_pointer_to($)
@ -567,7 +570,7 @@ sub ParseElementPushLevel
pidl "}";
}
if ($deferred and Parse::Pidl::NDR::ContainsDeferred($e, $l)) {
if ($deferred and ContainsDeferred($e, $l)) {
pidl "for ($counter = 0; $counter < $length; $counter++) {";
indent;
ParseElementPushLevel($e, GetNextLevel($e, $l), $ndr, $var_name, $env, 0, 1);
@ -590,7 +593,7 @@ sub ParseElementPush($$$$$$)
$var_name = append_prefix($e, $var_name);
return unless $primitives or ($deferred and Parse::Pidl::NDR::ContainsDeferred($e, $e->{LEVELS}[0]));
return unless $primitives or ($deferred and ContainsDeferred($e, $e->{LEVELS}[0]));
start_flags($e);
@ -881,7 +884,7 @@ sub ParseElementPullLevel
}
}
if ($deferred and Parse::Pidl::NDR::ContainsDeferred($e, $l)) {
if ($deferred and ContainsDeferred($e, $l)) {
pidl "for ($counter = 0; $counter < $length; $counter++) {";
indent;
ParseElementPullLevel($e,GetNextLevel($e,$l), $ndr, $var_name, $env, 0, 1);
@ -903,7 +906,7 @@ sub ParseElementPull($$$$$$)
$var_name = append_prefix($e, $var_name);
return unless $primitives or ($deferred and Parse::Pidl::NDR::ContainsDeferred($e, $e->{LEVELS}[0]));
return unless $primitives or ($deferred and ContainsDeferred($e, $e->{LEVELS}[0]));
start_flags($e);

View File

@ -262,66 +262,6 @@ NTSTATUS ndr_pull_array_uint8(struct ndr_pull *ndr, int ndr_flags, uint8_t *data
return ndr_pull_bytes(ndr, data, n);
}
/*
pull an array of uint16
*/
NTSTATUS ndr_pull_array_uint16(struct ndr_pull *ndr, int ndr_flags, uint16_t *data, uint32_t n)
{
uint32_t i;
if (!(ndr_flags & NDR_SCALARS)) {
return NT_STATUS_OK;
}
for (i=0;i<n;i++) {
NDR_CHECK(ndr_pull_uint16(ndr, NDR_SCALARS, &data[i]));
}
return NT_STATUS_OK;
}
/*
pull a const array of uint32_t
*/
NTSTATUS ndr_pull_array_uint32(struct ndr_pull *ndr, int ndr_flags, uint32_t *data, uint32_t n)
{
uint32_t i;
if (!(ndr_flags & NDR_SCALARS)) {
return NT_STATUS_OK;
}
for (i=0;i<n;i++) {
NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &data[i]));
}
return NT_STATUS_OK;
}
/*
pull a const array of hyper
*/
NTSTATUS ndr_pull_array_hyper(struct ndr_pull *ndr, int ndr_flags, uint64_t *data, uint32_t n)
{
uint32_t i;
if (!(ndr_flags & NDR_SCALARS)) {
return NT_STATUS_OK;
}
for (i=0;i<n;i++) {
NDR_CHECK(ndr_pull_hyper(ndr, NDR_SCALARS, &data[i]));
}
return NT_STATUS_OK;
}
/*
pull a const array of WERROR
*/
NTSTATUS ndr_pull_array_WERROR(struct ndr_pull *ndr, int ndr_flags, WERROR *data, uint32_t n)
{
uint32_t i;
if (!(ndr_flags & NDR_SCALARS)) {
return NT_STATUS_OK;
}
for (i=0;i<n;i++) {
NDR_CHECK(ndr_pull_WERROR(ndr, NDR_SCALARS, &data[i]));
}
return NT_STATUS_OK;
}
/*
push a int8_t
*/
@ -480,66 +420,6 @@ NTSTATUS ndr_push_array_uint8(struct ndr_push *ndr, int ndr_flags, const uint8_t
return ndr_push_bytes(ndr, data, n);
}
/*
push an array of uint16
*/
NTSTATUS ndr_push_array_uint16(struct ndr_push *ndr, int ndr_flags, const uint16_t *data, uint32_t n)
{
int i;
if (!(ndr_flags & NDR_SCALARS)) {
return NT_STATUS_OK;
}
for (i=0;i<n;i++) {
NDR_CHECK(ndr_push_uint16(ndr, NDR_SCALARS, data[i]));
}
return NT_STATUS_OK;
}
/*
push an array of uint32_t
*/
NTSTATUS ndr_push_array_uint32(struct ndr_push *ndr, int ndr_flags, const uint32_t *data, uint32_t n)
{
int i;
if (!(ndr_flags & NDR_SCALARS)) {
return NT_STATUS_OK;
}
for (i=0;i<n;i++) {
NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, data[i]));
}
return NT_STATUS_OK;
}
/*
push an array of hyper
*/
NTSTATUS ndr_push_array_hyper(struct ndr_push *ndr, int ndr_flags, const uint64_t *data, uint32_t n)
{
int i;
if (!(ndr_flags & NDR_SCALARS)) {
return NT_STATUS_OK;
}
for (i=0;i<n;i++) {
NDR_CHECK(ndr_push_hyper(ndr, NDR_SCALARS, data[i]));
}
return NT_STATUS_OK;
}
/*
push an array of hyper
*/
NTSTATUS ndr_push_array_WERROR(struct ndr_push *ndr, int ndr_flags, const WERROR *data, uint32_t n)
{
int i;
if (!(ndr_flags & NDR_SCALARS)) {
return NT_STATUS_OK;
}
for (i=0;i<n;i++) {
NDR_CHECK(ndr_push_WERROR(ndr, NDR_SCALARS, data[i]));
}
return NT_STATUS_OK;
}
/*
save the current position
*/
@ -837,78 +717,6 @@ void ndr_print_bad_level(struct ndr_print *ndr, const char *name, uint16_t level
ndr->print(ndr, "UNKNOWN LEVEL %u", level);
}
void ndr_print_array_WERROR(struct ndr_print *ndr, const char *name,
const WERROR *data, uint32_t count)
{
int i;
ndr->print(ndr, "%s: ARRAY(%d)", name, count);
ndr->depth++;
for (i=0;i<count;i++) {
char *idx=NULL;
asprintf(&idx, "[%d]", i);
if (idx) {
ndr_print_WERROR(ndr, idx, data[i]);
free(idx);
}
}
ndr->depth--;
}
void ndr_print_array_hyper(struct ndr_print *ndr, const char *name,
const uint64_t *data, uint32_t count)
{
int i;
ndr->print(ndr, "%s: ARRAY(%d)", name, count);
ndr->depth++;
for (i=0;i<count;i++) {
char *idx=NULL;
asprintf(&idx, "[%d]", i);
if (idx) {
ndr_print_hyper(ndr, idx, data[i]);
free(idx);
}
}
ndr->depth--;
}
void ndr_print_array_uint32(struct ndr_print *ndr, const char *name,
const uint32_t *data, uint32_t count)
{
int i;
ndr->print(ndr, "%s: ARRAY(%d)", name, count);
ndr->depth++;
for (i=0;i<count;i++) {
char *idx=NULL;
asprintf(&idx, "[%d]", i);
if (idx) {
ndr_print_uint32(ndr, idx, data[i]);
free(idx);
}
}
ndr->depth--;
}
void ndr_print_array_uint16(struct ndr_print *ndr, const char *name,
const uint16_t *data, uint32_t count)
{
int i;
ndr->print(ndr, "%s: ARRAY(%d)", name, count);
ndr->depth++;
for (i=0;i<count;i++) {
char *idx=NULL;
asprintf(&idx, "[%d]", i);
if (idx) {
ndr_print_uint16(ndr, idx, data[i]);
free(idx);
}
}
ndr->depth--;
}
void ndr_print_array_uint8(struct ndr_print *ndr, const char *name,
const uint8_t *data, uint32_t count)
{