diff options
author | Andrew Tridgell <tridge@samba.org> | 2003-11-22 22:53:08 +0000 |
---|---|---|
committer | Andrew Tridgell <tridge@samba.org> | 2003-11-22 22:53:08 +0000 |
commit | 868555bca5fdc87d4e46df6e853c19e5d5f5f796 (patch) | |
tree | a2a0627062c1e77af1c5dee11ac305f0d2dbf41f | |
parent | e79e6bc4726dc96d553e245e34e94e39de7c2da3 (diff) | |
download | samba-868555bca5fdc87d4e46df6e853c19e5d5f5f796.tar.gz samba-868555bca5fdc87d4e46df6e853c19e5d5f5f796.tar.bz2 samba-868555bca5fdc87d4e46df6e853c19e5d5f5f796.zip |
added support for enumerated types in IDL files. This makes unions
easier to work with.
(This used to be commit 60be15d306e7b65efdd27df02250c0264996ccf3)
-rw-r--r-- | source4/build/pidl/header.pm | 29 | ||||
-rw-r--r-- | source4/build/pidl/idl.gram | 31 | ||||
-rw-r--r-- | source4/librpc/idl/samr.idl | 15 |
3 files changed, 54 insertions, 21 deletions
diff --git a/source4/build/pidl/header.pm b/source4/build/pidl/header.pm index 751383a2b3..d6584a05ad 100644 --- a/source4/build/pidl/header.pm +++ b/source4/build/pidl/header.pm @@ -86,6 +86,31 @@ sub HeaderStruct($$) $res .= "}"; } +##################################################################### +# parse a struct +sub HeaderEnum($$) +{ + my($enum) = shift; + my($name) = shift; + $res .= "\nenum $name {\n"; + $tab_depth++; + my $els = \@{$enum->{ELEMENTS}}; + foreach my $i (0 .. $#{$els}-1) { + my $e = ${$els}[$i]; + tabs(); + chomp $e; + $res .= "$e,\n"; + } + + my $e = ${$els}[$#{$els}]; + tabs(); + chomp $e; + $e =~ /^(.*?)\s*$/; + $res .= "$1\n"; + $tab_depth--; + $res .= "}"; +} + ##################################################################### # parse a union element @@ -105,7 +130,7 @@ sub HeaderUnion($$) my($union) = shift; my($name) = shift; (defined $union->{PROPERTIES}) && HeaderProperties($union->{PROPERTIES}); - $res .= "union $name {\n"; + $res .= "\nunion $name {\n"; foreach my $e (@{$union->{DATA}}) { HeaderUnionElement($e); } @@ -120,6 +145,8 @@ sub HeaderType($$$) my($data) = shift; my($name) = shift; if (ref($data) eq "HASH") { + ($data->{TYPE} eq "ENUM") && + HeaderEnum($data, $name); ($data->{TYPE} eq "STRUCT") && HeaderStruct($data, $name); ($data->{TYPE} eq "UNION") && diff --git a/source4/build/pidl/idl.gram b/source4/build/pidl/idl.gram index 70d1c36b5e..1e19ae6cf1 100644 --- a/source4/build/pidl/idl.gram +++ b/source4/build/pidl/idl.gram @@ -48,6 +48,15 @@ typedef : 'typedef' <commit> type identifier array_len(?) ';' }} | <error?> +enum: 'enum' <commit> '{' enum_element(s? /,/) '}' + {{ + "TYPE" => "ENUM", + "ELEMENTS" => $item[4] + }} + | <error?> + +enum_element: /[\w\s=]+/ + struct: property_list(s?) 'struct' <commit> '{' element_list1(?) '}' {{ "TYPE" => "STRUCT", @@ -65,16 +74,16 @@ union: property_list(s?) 'union' <commit> '{' union_element(s?) '}' | <error?> union_element: - '[' 'case' '(' constant ')' ']' base_element ';' + '[' 'case' '(' identifier ')' ']' base_element ';' {{ "TYPE" => "UNION_ELEMENT", - "CASE" => $item{constant}, + "CASE" => $item{identifier}, "DATA" => $item{base_element} }} - | '[' 'case' '(' constant ')' ']' ';' + | '[' 'case' '(' identifier ')' ']' ';' {{ "TYPE" => "EMPTY", - "CASE" => $item{constant}, + "CASE" => $item{identifier}, }} | '[' 'default' ']' base_element ';' {{ @@ -124,20 +133,16 @@ property: 'unique' | 'in' | 'out' | 'ref' - | 'context_handle' - | 'string' | 'public' | 'noprint' | 'relative' | 'nodiscriminant' | 'subcontext' '(' constant ')' {{ "$item[1]" => "$item{constant}" }} | 'flag' '(' anytext ')' {{ "$item[1]" => "$item{anytext}" }} - | 'byte_count_pointer' '(' expression ')' {{ "$item[1]" => "$item{expression}" }} | 'size_is' '(' expression ')' {{ "$item[1]" => "$item{expression}" }} | 'length_is' '(' expression ')' {{ "$item[1]" => "$item{expression}" }} | 'switch_is' '(' expression ')' {{ "$item[1]" => "$item{expression}" }} | 'value' '(' anytext ')' {{ "$item[1]" => "$item{anytext}" }} - | 'switch_type' '(' type ')' {{ "$item[1]" => $item{type} }} identifier: /[\w?]+/ @@ -153,12 +158,9 @@ function : type identifier '(' <commit> element_list2 ');' | <error?> type : - 'unsigned' type { "$item[1] $item[2]" } - | 'long' { $item[1] } - | 'string' { $item[1] } - | 'wchar_t' { $item[1] } - | struct { $item[1] } + struct { $item[1] } | union { $item[1] } + | enum { $item[1] } | identifier { $item[1] } | <error> @@ -172,9 +174,6 @@ anytext: text2 '(' <commit> anytext ')' anytext {{ "$item[1]+$item[3]" }} | text2 -call: expression '(' <commit> expression ')' - {{ "$item[1]($item[4])" }} - constant: /-?[\dx]+/ | '*' diff --git a/source4/librpc/idl/samr.idl b/source4/librpc/idl/samr.idl index 8b349123fb..eb1d126227 100644 --- a/source4/librpc/idl/samr.idl +++ b/source4/librpc/idl/samr.idl @@ -341,11 +341,18 @@ samr_Name description; } samr_GroupInfoDesciption; + typedef enum { + GroupInfoAll = 1, + GroupInfoName, + GroupInfoX, + GroupInfoDescription + } GroupInfo; + typedef union { - [case(1)] samr_GroupInfoAll all; - [case(2)] samr_GroupInfoName name; - [case(3)] samr_GroupInfoX unknown; - [case(4)] samr_GroupInfoDesciption description; + [case(GroupInfoAll)] samr_GroupInfoAll all; + [case(GroupInfoName)] samr_GroupInfoName name; + [case(GroupInfoX)] samr_GroupInfoX unknown; + [case(GroupInfoDescription)] samr_GroupInfoDesciption description; } samr_GroupInfo; NTSTATUS samr_QueryGroupInfo( |