svn commit: samba r6180 - in branches/SAMBA_4_0/source: build/pidl
librpc/ndr
jelmer at samba.org
jelmer at samba.org
Sat Apr 2 20:57:28 GMT 2005
Author: jelmer
Date: 2005-04-02 20:57:27 +0000 (Sat, 02 Apr 2005)
New Revision: 6180
WebSVN: http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=rev&root=samba&rev=6180
Log:
Use token_lists for storing switch values
Modified:
branches/SAMBA_4_0/source/build/pidl/ndr_parser.pm
branches/SAMBA_4_0/source/librpc/ndr/libndr.h
branches/SAMBA_4_0/source/librpc/ndr/ndr.c
Changeset:
Modified: branches/SAMBA_4_0/source/build/pidl/ndr_parser.pm
===================================================================
--- branches/SAMBA_4_0/source/build/pidl/ndr_parser.pm 2005-04-02 06:51:54 UTC (rev 6179)
+++ branches/SAMBA_4_0/source/build/pidl/ndr_parser.pm 2005-04-02 20:57:27 UTC (rev 6180)
@@ -670,12 +670,14 @@
if (util::array_size($e)) {
ParseArrayPrint($e, $var_prefix)
- } elsif (my $switch = util::has_property($e, "switch_is")) {
- my $switch_var = ParseExpr($e, $switch, $var_prefix);
- check_null_pointer_void($switch_var);
+ } else {
+ if (my $switch = util::has_property($e, "switch_is")) {
+ my $switch_var = ParseExpr($e, $switch, $var_prefix);
+ check_null_pointer_void($switch_var);
- pidl "ndr_print_$e->{TYPE}(ndr, \"$e->{NAME}\", $switch_var, $cprefix$var_prefix$e->{NAME});";
- } else {
+ pidl "ndr_print_set_switch_value(ndr, $cprefix$var_prefix$e->{NAME}, $switch_var);";
+ }
+
pidl "ndr_print_$e->{TYPE}(ndr, \"$e->{NAME}\", $cprefix$var_prefix$e->{NAME});";
}
@@ -1406,6 +1408,8 @@
my $have_default = 0;
my($name) = $e->{PARENT}->{NAME};
+ pidl "int level = ndr_print_get_switch_value(ndr, r);";
+
pidl "ndr_print_union(ndr, name, level, \"$name\");";
start_flags($e);
@@ -1535,7 +1539,7 @@
sub ArgsUnionPrint($)
{
my $e = shift;
- return "struct ndr_print *ndr, const char *name, int level, union $e->{NAME} *r";
+ return "struct ndr_print *ndr, const char *name, union $e->{NAME} *r";
}
sub ArgsUnionPull($)
Modified: branches/SAMBA_4_0/source/librpc/ndr/libndr.h
===================================================================
--- branches/SAMBA_4_0/source/librpc/ndr/libndr.h 2005-04-02 06:51:54 UTC (rev 6179)
+++ branches/SAMBA_4_0/source/librpc/ndr/libndr.h 2005-04-02 20:57:27 UTC (rev 6180)
@@ -86,6 +86,7 @@
struct ndr_print {
uint32_t flags; /* LIBNDR_FLAG_* */
uint32_t depth;
+ struct ndr_token_list *switch_list;
void (*print)(struct ndr_print *, const char *, ...);
void *private;
};
@@ -248,5 +249,4 @@
typedef NTSTATUS (*ndr_pull_flags_fn_t)(struct ndr_pull *, int ndr_flags, void *);
typedef void (*ndr_print_fn_t)(struct ndr_print *, const char *, void *);
typedef void (*ndr_print_function_t)(struct ndr_print *, const char *, int, void *);
-typedef void (*ndr_print_union_fn_t)(struct ndr_print *, const char *, uint32_t, void *);
Modified: branches/SAMBA_4_0/source/librpc/ndr/ndr.c
===================================================================
--- branches/SAMBA_4_0/source/librpc/ndr/ndr.c 2005-04-02 06:51:54 UTC (rev 6179)
+++ branches/SAMBA_4_0/source/librpc/ndr/ndr.c 2005-04-02 20:57:27 UTC (rev 6180)
@@ -324,24 +324,7 @@
talloc_free(ndr);
}
-
/*
- a useful helper function for printing idl unions via DEBUG()
-*/
-void ndr_print_union_debug(ndr_print_union_fn_t fn, const char *name, uint32_t level, void *ptr)
-{
- struct ndr_print *ndr;
-
- ndr = talloc(NULL, struct ndr_print);
- if (!ndr) return;
- ndr->print = ndr_print_debug_helper;
- ndr->depth = 1;
- ndr->flags = 0;
- fn(ndr, name, level, ptr);
- talloc_free(ndr);
-}
-
-/*
a useful helper function for printing idl function calls via DEBUG()
*/
void ndr_print_function_debug(ndr_print_function_t fn, const char *name, int flags, void *ptr)
@@ -690,7 +673,20 @@
return ndr_token_peek(&ndr->switch_list, p);
}
+NTSTATUS ndr_print_set_switch_value(struct ndr_print *ndr, const void *p, uint32_t val)
+{
+ return ndr_token_store(ndr, &ndr->switch_list, p, val);
+}
+
/*
+ retrieve a switch value
+ */
+uint32_t ndr_print_get_switch_value(struct ndr_print *ndr, const void *p)
+{
+ return ndr_token_peek(&ndr->switch_list, p);
+}
+
+/*
pull a relative object - stage1
called during SCALARS processing
*/
More information about the samba-cvs
mailing list