Author: jelmer
Date: 2005-08-23 13:19:33 +0000 (Tue, 23 Aug 2005)
New Revision: 9519

WebSVN: http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=rev&root=samba&rev=9519

Log:
Use the value() value of an element when that element is used in 
limited expressions (size_is,length_is,subcontext_size,etc)

Modified:
   branches/SAMBA_4_0/source/librpc/idl/drsuapi.idl
   branches/SAMBA_4_0/source/pidl/lib/Parse/Pidl/Samba/NDR/Parser.pm


Changeset:
Modified: branches/SAMBA_4_0/source/librpc/idl/drsuapi.idl
===================================================================
--- branches/SAMBA_4_0/source/librpc/idl/drsuapi.idl    2005-08-23 13:12:07 UTC 
(rev 9518)
+++ branches/SAMBA_4_0/source/librpc/idl/drsuapi.idl    2005-08-23 13:19:33 UTC 
(rev 9519)
@@ -444,7 +444,7 @@
 
        typedef struct {
                
[range(0,10485760),value(ndr_size_drsuapi_DsReplicaObjectIdentifier3(object, 
ndr->flags))] uint32 __ndr_size;
-               [subcontext(4)] drsuapi_DsReplicaObjectIdentifier3 *object;
+               [subcontext(4),subcontext_size(__ndr_size)] 
drsuapi_DsReplicaObjectIdentifier3 *object;
        } drsuapi_DsAttributeValueDNString;
 
        typedef struct {

Modified: branches/SAMBA_4_0/source/pidl/lib/Parse/Pidl/Samba/NDR/Parser.pm
===================================================================
--- branches/SAMBA_4_0/source/pidl/lib/Parse/Pidl/Samba/NDR/Parser.pm   
2005-08-23 13:12:07 UTC (rev 9518)
+++ branches/SAMBA_4_0/source/pidl/lib/Parse/Pidl/Samba/NDR/Parser.pm   
2005-08-23 13:19:33 UTC (rev 9519)
@@ -235,6 +235,20 @@
        return \%env;
 }
 
+sub EnvSubstituteValue($$)
+{
+       my ($env,$s) = @_;
+
+       # Substitute the value() values in the env
+       foreach my $e (@{$s->{ELEMENTS}}) {
+               next unless (my $v = has_property($e, "value"));
+               
+               $env->{$e->{NAME}} = ParseExpr($v, $env);
+       }
+
+       return $env;
+}
+
 sub GenerateFunctionInEnv($)
 {
        my $fn = shift;
@@ -1095,6 +1109,8 @@
 
        my $env = GenerateStructEnv($struct);
 
+       EnvSubstituteValue($env, $struct);
+
        # save the old relative_base_offset
        pidl "uint32_t _save_relative_base_offset = 
ndr_push_get_relative_base_offset(ndr);" if 
defined($struct->{PROPERTIES}{relative_base});
 
@@ -1326,6 +1342,8 @@
 
        my $env = GenerateStructEnv($struct);
 
+       EnvSubstituteValue($env, $struct);
+
        foreach my $e (@{$struct->{ELEMENTS}}) {
                DeclareArrayVariables($e);
        }
@@ -1870,6 +1888,7 @@
        pidl "ndr->depth++;";
 
        my $env = GenerateFunctionInEnv($fn);
+       EnvSubstituteValue($env, $fn);
 
        foreach my $e (@{$fn->{ELEMENTS}}) {
                if (grep(/in/,@{$e->{DIRECTION}})) {
@@ -1925,6 +1944,8 @@
 
        my $env = GenerateFunctionInEnv($fn);
 
+       EnvSubstituteValue($env, $fn);
+
        foreach my $e (@{$fn->{ELEMENTS}}) {
                if (grep(/in/,@{$e->{DIRECTION}})) {
                        ParseElementPush($e, "ndr", "r->in.", $env, 1, 1);

Reply via email to