From ebfbb2a7abe33e47af48d69164c37f4c24b7f8ed Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Sat, 24 Dec 2005 22:11:44 +0000 Subject: r12463: Rename 'Samba' namespace to 'Samba4' (This used to be commit f25358270d44a5642adbb85ecaa50b2e5730d7f0) --- source4/pidl/lib/Parse/Pidl/Samba4/Header.pm | 361 +++++++++++++++++++++++++++ 1 file changed, 361 insertions(+) create mode 100644 source4/pidl/lib/Parse/Pidl/Samba4/Header.pm (limited to 'source4/pidl/lib/Parse/Pidl/Samba4/Header.pm') diff --git a/source4/pidl/lib/Parse/Pidl/Samba4/Header.pm b/source4/pidl/lib/Parse/Pidl/Samba4/Header.pm new file mode 100644 index 0000000000..a1c568cdc7 --- /dev/null +++ b/source4/pidl/lib/Parse/Pidl/Samba4/Header.pm @@ -0,0 +1,361 @@ +################################################### +# create C header files for an IDL structure +# Copyright tridge@samba.org 2000 +# Copyright jelmer@samba.org 2005 +# released under the GNU GPL + +package Parse::Pidl::Samba4::Header; + +use strict; +use Parse::Pidl::Typelist qw(mapType); +use Parse::Pidl::Util qw(has_property is_constant); +use Parse::Pidl::NDR qw(GetNextLevel GetPrevLevel); + +use vars qw($VERSION); +$VERSION = '0.01'; + +my($res); +my($tab_depth); + +sub pidl ($) +{ + $res .= shift; +} + +sub tabs() +{ + my $res = ""; + $res .="\t" foreach (1..$tab_depth); + return $res; +} + +##################################################################### +# parse a properties list +sub HeaderProperties($$) +{ + my($props,$ignores) = @_; + my $ret = ""; + + foreach my $d (keys %{$props}) { + next if (grep(/^$d$/, @$ignores)); + if($props->{$d} ne "1") { + $ret.= "$d($props->{$d}),"; + } else { + $ret.="$d,"; + } + } + + if ($ret) { + pidl "/* [" . substr($ret, 0, -1) . "] */"; + } +} + +##################################################################### +# parse a structure element +sub HeaderElement($) +{ + my($element) = shift; + + pidl tabs(); + HeaderType($element, $element->{TYPE}, ""); + pidl " "; + my $numstar = $element->{POINTERS}; + if ($numstar >= 1) { + $numstar-- if Parse::Pidl::Typelist::scalar_is_reference($element->{TYPE}); + } + foreach (@{$element->{ARRAY_LEN}}) + { + next if is_constant($_) and + not has_property($element, "charset"); + $numstar++; + } + pidl "*" foreach (1..$numstar); + pidl $element->{NAME}; + foreach (@{$element->{ARRAY_LEN}}) { + next unless (is_constant($_) and + not has_property($element, "charset")); + pidl "[$_]"; + } + + pidl ";"; + if (defined $element->{PROPERTIES}) { + HeaderProperties($element->{PROPERTIES}, ["in", "out"]); + } + pidl "\n"; +} + +##################################################################### +# parse a struct +sub HeaderStruct($$) +{ + my($struct,$name) = @_; + pidl "struct $name {\n"; + $tab_depth++; + my $el_count=0; + if (defined $struct->{ELEMENTS}) { + foreach my $e (@{$struct->{ELEMENTS}}) { + HeaderElement($e); + $el_count++; + } + } + if ($el_count == 0) { + # some compilers can't handle empty structures + pidl tabs()."char _empty_;\n"; + } + $tab_depth--; + pidl tabs()."}"; + if (defined $struct->{PROPERTIES}) { + HeaderProperties($struct->{PROPERTIES}, []); + } +} + +##################################################################### +# parse a enum +sub HeaderEnum($$) +{ + my($enum,$name) = @_; + my $first = 1; + + if (not Parse::Pidl::Util::useUintEnums()) { + pidl "enum $name {\n"; + $tab_depth++; + foreach my $e (@{$enum->{ELEMENTS}}) { + unless ($first) { pidl ",\n"; } + $first = 0; + pidl tabs(); + pidl $e; + } + pidl "\n"; + $tab_depth--; + pidl "}"; + } else { + my $count = 0; + pidl "enum $name { __donnot_use_enum_$name=0x7FFFFFFF};\n"; + my $with_val = 0; + my $without_val = 0; + foreach my $e (@{$enum->{ELEMENTS}}) { + my $t = "$e"; + my $name; + my $value; + if ($t =~ /(.*)=(.*)/) { + $name = $1; + $value = $2; + $with_val = 1; + die ("you can't mix enum member with values and without values when using --uint-enums!") + unless ($without_val == 0); + } else { + $name = $t; + $value = $count++; + $without_val = 1; + die ("you can't mix enum member with values and without values when using --uint-enums!") + unless ($with_val == 0); + } + pidl "#define $name ( $value )\n"; + } + pidl "\n"; + } +} + +##################################################################### +# parse a bitmap +sub HeaderBitmap($$) +{ + my($bitmap,$name) = @_; + + pidl "/* bitmap $name */\n"; + pidl "#define $_\n" foreach (@{$bitmap->{ELEMENTS}}); + pidl "\n"; +} + +##################################################################### +# parse a union +sub HeaderUnion($$) +{ + my($union,$name) = @_; + my %done = (); + + pidl "union $name {\n"; + $tab_depth++; + foreach my $e (@{$union->{ELEMENTS}}) { + if ($e->{TYPE} ne "EMPTY") { + if (! defined $done{$e->{NAME}}) { + HeaderElement($e); + } + $done{$e->{NAME}} = 1; + } + } + $tab_depth--; + pidl "}"; + + if (defined $union->{PROPERTIES}) { + HeaderProperties($union->{PROPERTIES}, []); + } +} + +##################################################################### +# parse a type +sub HeaderType($$$) +{ + my($e,$data,$name) = @_; + if (ref($data) eq "HASH") { + ($data->{TYPE} eq "ENUM") && HeaderEnum($data, $name); + ($data->{TYPE} eq "BITMAP") && HeaderBitmap($data, $name); + ($data->{TYPE} eq "STRUCT") && HeaderStruct($data, $name); + ($data->{TYPE} eq "UNION") && HeaderUnion($data, $name); + return; + } + + if (has_property($e, "charset")) { + pidl "const char"; + } else { + pidl mapType($e->{TYPE}); + } +} + +##################################################################### +# parse a typedef +sub HeaderTypedef($) +{ + my($typedef) = shift; + HeaderType($typedef, $typedef->{DATA}, $typedef->{NAME}); + pidl ";\n\n" unless ($typedef->{DATA}->{TYPE} eq "BITMAP"); +} + +##################################################################### +# parse a const +sub HeaderConst($) +{ + my($const) = shift; + if (!defined($const->{ARRAY_LEN}[0])) { + pidl "#define $const->{NAME}\t( $const->{VALUE} )\n"; + } else { + pidl "#define $const->{NAME}\t $const->{VALUE}\n"; + } +} + +##################################################################### +# parse a function +sub HeaderFunctionInOut($$) +{ + my($fn,$prop) = @_; + + foreach my $e (@{$fn->{ELEMENTS}}) { + if (has_property($e, $prop)) { + HeaderElement($e); + } + } +} + +##################################################################### +# determine if we need an "in" or "out" section +sub HeaderFunctionInOut_needed($$) +{ + my($fn,$prop) = @_; + + return 1 if ($prop eq "out" && $fn->{RETURN_TYPE} ne "void"); + + foreach (@{$fn->{ELEMENTS}}) { + return 1 if (has_property($_, $prop)); + } + + return undef; +} + +my %headerstructs = (); + +##################################################################### +# parse a function +sub HeaderFunction($) +{ + my($fn) = shift; + + return if ($headerstructs{$fn->{NAME}}); + + $headerstructs{$fn->{NAME}} = 1; + + pidl "\nstruct $fn->{NAME} {\n"; + $tab_depth++; + my $needed = 0; + + if (HeaderFunctionInOut_needed($fn, "in")) { + pidl tabs()."struct {\n"; + $tab_depth++; + HeaderFunctionInOut($fn, "in"); + $tab_depth--; + pidl tabs()."} in;\n\n"; + $needed++; + } + + if (HeaderFunctionInOut_needed($fn, "out")) { + pidl tabs()."struct {\n"; + $tab_depth++; + HeaderFunctionInOut($fn, "out"); + if ($fn->{RETURN_TYPE} ne "void") { + pidl tabs().mapType($fn->{RETURN_TYPE}) . " result;\n"; + } + $tab_depth--; + pidl tabs()."} out;\n\n"; + $needed++; + } + + if (! $needed) { + # sigh - some compilers don't like empty structures + pidl tabs()."int _dummy_element;\n"; + } + + $tab_depth--; + pidl "};\n\n"; +} + +##################################################################### +# parse the interface definitions +sub HeaderInterface($) +{ + my($interface) = shift; + + my $count = 0; + + pidl "#ifndef _HEADER_$interface->{NAME}\n"; + pidl "#define _HEADER_$interface->{NAME}\n\n"; + + if (defined $interface->{PROPERTIES}->{depends}) { + my @d = split / /, $interface->{PROPERTIES}->{depends}; + foreach my $i (@d) { + pidl "#include \"librpc/gen_ndr/$i\.h\"\n"; + } + } + + foreach my $d (@{$interface->{DATA}}) { + next if ($d->{TYPE} ne "CONST"); + HeaderConst($d); + } + + foreach my $d (@{$interface->{DATA}}) { + next if ($d->{TYPE} ne "TYPEDEF"); + HeaderTypedef($d); + } + + foreach my $d (@{$interface->{DATA}}) { + next if ($d->{TYPE} ne "FUNCTION"); + HeaderFunction($d); + } + + pidl "#endif /* _HEADER_$interface->{NAME} */\n"; +} + +##################################################################### +# parse a parsed IDL into a C header +sub Parse($) +{ + my($idl) = shift; + $tab_depth = 0; + + $res = ""; + pidl "/* header auto-generated by pidl */\n\n"; + foreach my $x (@{$idl}) { + ($x->{TYPE} eq "INTERFACE") && HeaderInterface($x); + } + return $res; +} + +1; -- cgit From 7717f180ca2f908e1b3258355520719991215050 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Sun, 25 Dec 2005 03:04:13 +0000 Subject: r12470: Add helper module for pidl tests Convert other pidl tests to use Test::More and run them from 'make test' (This used to be commit 3a57d29a62112ab654e290ccc985fba7f67664c5) --- source4/pidl/lib/Parse/Pidl/Samba4/Header.pm | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) (limited to 'source4/pidl/lib/Parse/Pidl/Samba4/Header.pm') diff --git a/source4/pidl/lib/Parse/Pidl/Samba4/Header.pm b/source4/pidl/lib/Parse/Pidl/Samba4/Header.pm index a1c568cdc7..46caba731a 100644 --- a/source4/pidl/lib/Parse/Pidl/Samba4/Header.pm +++ b/source4/pidl/lib/Parse/Pidl/Samba4/Header.pm @@ -17,10 +17,7 @@ $VERSION = '0.01'; my($res); my($tab_depth); -sub pidl ($) -{ - $res .= shift; -} +sub pidl($) { $res .= shift; } sub tabs() { @@ -261,7 +258,7 @@ sub HeaderFunctionInOut_needed($$) return undef; } -my %headerstructs = (); +my %headerstructs; ##################################################################### # parse a function @@ -313,8 +310,6 @@ sub HeaderInterface($) { my($interface) = shift; - my $count = 0; - pidl "#ifndef _HEADER_$interface->{NAME}\n"; pidl "#define _HEADER_$interface->{NAME}\n\n"; @@ -337,6 +332,7 @@ sub HeaderInterface($) foreach my $d (@{$interface->{DATA}}) { next if ($d->{TYPE} ne "FUNCTION"); + HeaderFunction($d); } @@ -351,9 +347,10 @@ sub Parse($) $tab_depth = 0; $res = ""; + %headerstructs = (); pidl "/* header auto-generated by pidl */\n\n"; - foreach my $x (@{$idl}) { - ($x->{TYPE} eq "INTERFACE") && HeaderInterface($x); + foreach (@{$idl}) { + ($_->{TYPE} eq "INTERFACE") && HeaderInterface($_); } return $res; } -- cgit From ecf0dd6bafaa95692c3ece94b6f71446cd54ebdc Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Thu, 16 Mar 2006 20:02:31 +0000 Subject: r14488: Install more headers. Generate different #include lines in pidl depending on whether we're building inside or outside of the Samba tree (useful for 3rd-party projects). (This used to be commit 0c188833154c1fe565cb1735909e408a4a1a6049) --- source4/pidl/lib/Parse/Pidl/Samba4/Header.pm | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'source4/pidl/lib/Parse/Pidl/Samba4/Header.pm') diff --git a/source4/pidl/lib/Parse/Pidl/Samba4/Header.pm b/source4/pidl/lib/Parse/Pidl/Samba4/Header.pm index 46caba731a..54e410f716 100644 --- a/source4/pidl/lib/Parse/Pidl/Samba4/Header.pm +++ b/source4/pidl/lib/Parse/Pidl/Samba4/Header.pm @@ -10,6 +10,7 @@ use strict; use Parse::Pidl::Typelist qw(mapType); use Parse::Pidl::Util qw(has_property is_constant); use Parse::Pidl::NDR qw(GetNextLevel GetPrevLevel); +use Parse::Pidl::Samba4 qw(is_intree); use vars qw($VERSION); $VERSION = '0.01'; @@ -349,6 +350,10 @@ sub Parse($) $res = ""; %headerstructs = (); pidl "/* header auto-generated by pidl */\n\n"; + if (!is_intree()) { + pidl "#include "; + } + foreach (@{$idl}) { ($_->{TYPE} eq "INTERFACE") && HeaderInterface($_); } -- cgit From 4469fa31e3e3b2d62da7686fd6426bb44be09830 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Thu, 16 Mar 2006 21:35:31 +0000 Subject: r14491: Allow building more output outside of the Samba source tree (This used to be commit 272ca8e636cc5043279ff247fc8d5693a9181992) --- source4/pidl/lib/Parse/Pidl/Samba4/Header.pm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/pidl/lib/Parse/Pidl/Samba4/Header.pm') diff --git a/source4/pidl/lib/Parse/Pidl/Samba4/Header.pm b/source4/pidl/lib/Parse/Pidl/Samba4/Header.pm index 54e410f716..e082a74fc4 100644 --- a/source4/pidl/lib/Parse/Pidl/Samba4/Header.pm +++ b/source4/pidl/lib/Parse/Pidl/Samba4/Header.pm @@ -351,7 +351,7 @@ sub Parse($) %headerstructs = (); pidl "/* header auto-generated by pidl */\n\n"; if (!is_intree()) { - pidl "#include "; + pidl "#include \n\n"; } foreach (@{$idl}) { -- cgit From 5d9ea9170d2e0fd816285bd460de05f800ce26e8 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Fri, 24 Mar 2006 12:40:07 +0000 Subject: r14690: Support represent_as in headers, enable represent_as() test (which works now) (This used to be commit 31e847a0844a6871befc6091e813ae017cd6e4b4) --- source4/pidl/lib/Parse/Pidl/Samba4/Header.pm | 38 +++++++++++++++------------- 1 file changed, 20 insertions(+), 18 deletions(-) (limited to 'source4/pidl/lib/Parse/Pidl/Samba4/Header.pm') diff --git a/source4/pidl/lib/Parse/Pidl/Samba4/Header.pm b/source4/pidl/lib/Parse/Pidl/Samba4/Header.pm index e082a74fc4..6fb3ee2eec 100644 --- a/source4/pidl/lib/Parse/Pidl/Samba4/Header.pm +++ b/source4/pidl/lib/Parse/Pidl/Samba4/Header.pm @@ -55,19 +55,23 @@ sub HeaderElement($) my($element) = shift; pidl tabs(); - HeaderType($element, $element->{TYPE}, ""); - pidl " "; - my $numstar = $element->{POINTERS}; - if ($numstar >= 1) { - $numstar-- if Parse::Pidl::Typelist::scalar_is_reference($element->{TYPE}); - } - foreach (@{$element->{ARRAY_LEN}}) - { - next if is_constant($_) and - not has_property($element, "charset"); - $numstar++; + if (has_property($element, "represent_as")) { + pidl mapType($element->{PROPERTIES}->{represent_as})." "; + } else { + HeaderType($element, $element->{TYPE}, ""); + pidl " "; + my $numstar = $element->{POINTERS}; + if ($numstar >= 1) { + $numstar-- if Parse::Pidl::Typelist::scalar_is_reference($element->{TYPE}); + } + foreach (@{$element->{ARRAY_LEN}}) + { + next if is_constant($_) and + not has_property($element, "charset"); + $numstar++; + } + pidl "*" foreach (1..$numstar); } - pidl "*" foreach (1..$numstar); pidl $element->{NAME}; foreach (@{$element->{ARRAY_LEN}}) { next unless (is_constant($_) and @@ -91,8 +95,8 @@ sub HeaderStruct($$) $tab_depth++; my $el_count=0; if (defined $struct->{ELEMENTS}) { - foreach my $e (@{$struct->{ELEMENTS}}) { - HeaderElement($e); + foreach (@{$struct->{ELEMENTS}}) { + HeaderElement($_); $el_count++; } } @@ -237,10 +241,8 @@ sub HeaderFunctionInOut($$) { my($fn,$prop) = @_; - foreach my $e (@{$fn->{ELEMENTS}}) { - if (has_property($e, $prop)) { - HeaderElement($e); - } + foreach (@{$fn->{ELEMENTS}}) { + HeaderElement($_) if (has_property($_, $prop)); } } -- cgit From 9727b061f330ba8f500a29bf4b94992e2bceffbc Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Sun, 21 May 2006 12:58:39 +0000 Subject: r15776: Don't generate ref pointers in Samba4-generated code. There is no point in having pointers for outgoing data when you can already modify the top-level element. This can be overridden (temporarily) by specifying the new "keepref" attribute. Once we've removed keepref from all IDL files, I'll remove this attribute as well. (This used to be commit bdc6dd37503ced8322a671d225122ccffbb8bfec) --- source4/pidl/lib/Parse/Pidl/Samba4/Header.pm | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'source4/pidl/lib/Parse/Pidl/Samba4/Header.pm') diff --git a/source4/pidl/lib/Parse/Pidl/Samba4/Header.pm b/source4/pidl/lib/Parse/Pidl/Samba4/Header.pm index 6fb3ee2eec..c9487115f5 100644 --- a/source4/pidl/lib/Parse/Pidl/Samba4/Header.pm +++ b/source4/pidl/lib/Parse/Pidl/Samba4/Header.pm @@ -60,7 +60,11 @@ sub HeaderElement($) } else { HeaderType($element, $element->{TYPE}, ""); pidl " "; - my $numstar = $element->{POINTERS}; + my $numstar = 0; + if (!has_property($element, "ref") or + has_property($element, "keepref")) { + $numstar += $element->{POINTERS}; + } if ($numstar >= 1) { $numstar-- if Parse::Pidl::Typelist::scalar_is_reference($element->{TYPE}); } -- cgit From cd9057a0bb90bef6d31051f176849b6a3543a376 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Mon, 18 Sep 2006 21:52:00 +0000 Subject: r18639: Get rid of the keepref support (This used to be commit d1364ef0cd8f1a64f44476476323ab390ac4de48) --- source4/pidl/lib/Parse/Pidl/Samba4/Header.pm | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) (limited to 'source4/pidl/lib/Parse/Pidl/Samba4/Header.pm') diff --git a/source4/pidl/lib/Parse/Pidl/Samba4/Header.pm b/source4/pidl/lib/Parse/Pidl/Samba4/Header.pm index c9487115f5..6fb3ee2eec 100644 --- a/source4/pidl/lib/Parse/Pidl/Samba4/Header.pm +++ b/source4/pidl/lib/Parse/Pidl/Samba4/Header.pm @@ -60,11 +60,7 @@ sub HeaderElement($) } else { HeaderType($element, $element->{TYPE}, ""); pidl " "; - my $numstar = 0; - if (!has_property($element, "ref") or - has_property($element, "keepref")) { - $numstar += $element->{POINTERS}; - } + my $numstar = $element->{POINTERS}; if ($numstar >= 1) { $numstar-- if Parse::Pidl::Typelist::scalar_is_reference($element->{TYPE}); } -- cgit From d8ecabe452f36302105c6412ae5ab93cabfe5cf2 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Mon, 6 Nov 2006 21:54:19 +0000 Subject: r19585: Add support for some more standard IDL instructions: - `include' (replaces helper()) - `import' (replaces depends()) Add support for parsing importlib() - importlib() is now ignored (with a warning), but no longer causes syntax errors. helper() and depends() are now marked deprecated and will cause warnings. (This used to be commit 1ccab71cb8a9e3db9448b6679d01ad00e1c1e9a3) --- source4/pidl/lib/Parse/Pidl/Samba4/Header.pm | 25 +++++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) (limited to 'source4/pidl/lib/Parse/Pidl/Samba4/Header.pm') diff --git a/source4/pidl/lib/Parse/Pidl/Samba4/Header.pm b/source4/pidl/lib/Parse/Pidl/Samba4/Header.pm index 6fb3ee2eec..94346efe4b 100644 --- a/source4/pidl/lib/Parse/Pidl/Samba4/Header.pm +++ b/source4/pidl/lib/Parse/Pidl/Samba4/Header.pm @@ -307,6 +307,24 @@ sub HeaderFunction($) pidl "};\n\n"; } +sub HeaderImport +{ + my @imports = @_; + foreach (@imports) { + s/\.idl\"$//; + s/^\"//; + pidl "#include \"librpc/gen_ndr/$_\.h\"\n"; + } +} + +sub HeaderInclude +{ + my @includes = @_; + foreach (@includes) { + pidl "#include \"$_\"\n"; + } +} + ##################################################################### # parse the interface definitions sub HeaderInterface($) @@ -317,10 +335,7 @@ sub HeaderInterface($) pidl "#define _HEADER_$interface->{NAME}\n\n"; if (defined $interface->{PROPERTIES}->{depends}) { - my @d = split / /, $interface->{PROPERTIES}->{depends}; - foreach my $i (@d) { - pidl "#include \"librpc/gen_ndr/$i\.h\"\n"; - } + HeaderImport(split / /, $interface->{PROPERTIES}->{depends}); } foreach my $d (@{$interface->{DATA}}) { @@ -358,6 +373,8 @@ sub Parse($) foreach (@{$idl}) { ($_->{TYPE} eq "INTERFACE") && HeaderInterface($_); + ($_->{TYPE} eq "IMPORT") && HeaderImport(@{$_->{PATHS}}); + ($_->{TYPE} eq "INCLUDE") && HeaderInclude(@{$_->{PATHS}}); } return $res; } -- cgit From 863dcbfa06cfcd4eecba7559c03080321b9a8a91 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Mon, 6 Nov 2006 22:54:49 +0000 Subject: r19588: Use include and import statements rather than depends() and helper(). (This used to be commit 347ae9628202ca4de4318ef8156999239aad9192) --- source4/pidl/lib/Parse/Pidl/Samba4/Header.pm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/pidl/lib/Parse/Pidl/Samba4/Header.pm') diff --git a/source4/pidl/lib/Parse/Pidl/Samba4/Header.pm b/source4/pidl/lib/Parse/Pidl/Samba4/Header.pm index 94346efe4b..6a999d4147 100644 --- a/source4/pidl/lib/Parse/Pidl/Samba4/Header.pm +++ b/source4/pidl/lib/Parse/Pidl/Samba4/Header.pm @@ -321,7 +321,7 @@ sub HeaderInclude { my @includes = @_; foreach (@includes) { - pidl "#include \"$_\"\n"; + pidl "#include $_\n"; } } -- cgit From 5b05f5f5f1bad489091c715867eddda7eff4c8c6 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Thu, 16 Nov 2006 22:13:44 +0000 Subject: r19752: Remove support for the `depends' attribute (use "import") instead. (This used to be commit 324395afc725e90f44f286fd776b38a64bdc8e3b) --- source4/pidl/lib/Parse/Pidl/Samba4/Header.pm | 4 ---- 1 file changed, 4 deletions(-) (limited to 'source4/pidl/lib/Parse/Pidl/Samba4/Header.pm') diff --git a/source4/pidl/lib/Parse/Pidl/Samba4/Header.pm b/source4/pidl/lib/Parse/Pidl/Samba4/Header.pm index 6a999d4147..da7d39a238 100644 --- a/source4/pidl/lib/Parse/Pidl/Samba4/Header.pm +++ b/source4/pidl/lib/Parse/Pidl/Samba4/Header.pm @@ -334,10 +334,6 @@ sub HeaderInterface($) pidl "#ifndef _HEADER_$interface->{NAME}\n"; pidl "#define _HEADER_$interface->{NAME}\n\n"; - if (defined $interface->{PROPERTIES}->{depends}) { - HeaderImport(split / /, $interface->{PROPERTIES}->{depends}); - } - foreach my $d (@{$interface->{DATA}}) { next if ($d->{TYPE} ne "CONST"); HeaderConst($d); -- cgit From 30bfba96d3b7007aa47e037328ea0f2b8e7d1d6e Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Mon, 22 Jan 2007 00:04:59 +0000 Subject: r20942: Simplify handling of systems that don't support negative enum values by using an ifdef rather than a pidl argument. (This used to be commit 6bada0dcf0c7915d366c7917189375dbabecdd4f) --- source4/pidl/lib/Parse/Pidl/Samba4/Header.pm | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) (limited to 'source4/pidl/lib/Parse/Pidl/Samba4/Header.pm') diff --git a/source4/pidl/lib/Parse/Pidl/Samba4/Header.pm b/source4/pidl/lib/Parse/Pidl/Samba4/Header.pm index da7d39a238..96f695d1cd 100644 --- a/source4/pidl/lib/Parse/Pidl/Samba4/Header.pm +++ b/source4/pidl/lib/Parse/Pidl/Samba4/Header.pm @@ -118,8 +118,8 @@ sub HeaderEnum($$) my($enum,$name) = @_; my $first = 1; - if (not Parse::Pidl::Util::useUintEnums()) { - pidl "enum $name {\n"; + pidl "#ifndef USE_UINT_ENUMS\n"; + pidl "enum $name {\n"; $tab_depth++; foreach my $e (@{$enum->{ELEMENTS}}) { unless ($first) { pidl ",\n"; } @@ -129,9 +129,9 @@ sub HeaderEnum($$) } pidl "\n"; $tab_depth--; - pidl "}"; - } else { - my $count = 0; + pidl "};\n"; + pidl "#else\n"; + my $count = 0; pidl "enum $name { __donnot_use_enum_$name=0x7FFFFFFF};\n"; my $with_val = 0; my $without_val = 0; @@ -154,8 +154,8 @@ sub HeaderEnum($$) } pidl "#define $name ( $value )\n"; } + pidl "#endif\n"; pidl "\n"; - } } ##################################################################### @@ -220,7 +220,8 @@ sub HeaderTypedef($) { my($typedef) = shift; HeaderType($typedef, $typedef->{DATA}, $typedef->{NAME}); - pidl ";\n\n" unless ($typedef->{DATA}->{TYPE} eq "BITMAP"); + pidl ";\n\n" unless ($typedef->{DATA}->{TYPE} eq "BITMAP" or + $typedef->{DATA}->{TYPE} eq "ENUM"); } ##################################################################### -- cgit From 45db1030651e69896fdb9e78aa2e2495a7ce7ff5 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Thu, 8 Feb 2007 23:54:31 +0000 Subject: r21253: Merge some pidl fixes: * Add tests for wireshark dissector generator * Add tests for the header code * Some cleanups * Fix handling of elements without [in] or [out] (This used to be commit 1aecba7100685ed291ea13b0ae47fb0cf9e6a6c8) --- source4/pidl/lib/Parse/Pidl/Samba4/Header.pm | 31 ++++++++++++++++++++-------- 1 file changed, 22 insertions(+), 9 deletions(-) (limited to 'source4/pidl/lib/Parse/Pidl/Samba4/Header.pm') diff --git a/source4/pidl/lib/Parse/Pidl/Samba4/Header.pm b/source4/pidl/lib/Parse/Pidl/Samba4/Header.pm index 96f695d1cd..2b5b9c9e01 100644 --- a/source4/pidl/lib/Parse/Pidl/Samba4/Header.pm +++ b/source4/pidl/lib/Parse/Pidl/Samba4/Header.pm @@ -9,7 +9,6 @@ package Parse::Pidl::Samba4::Header; use strict; use Parse::Pidl::Typelist qw(mapType); use Parse::Pidl::Util qw(has_property is_constant); -use Parse::Pidl::NDR qw(GetNextLevel GetPrevLevel); use Parse::Pidl::Samba4 qw(is_intree); use vars qw($VERSION); @@ -236,15 +235,25 @@ sub HeaderConst($) } } +sub ElementDirection($) +{ + my ($e) = @_; + + return "inout" if (has_property($e, "in") and has_property($e, "out")); + return "in" if (has_property($e, "in")); + return "out" if (has_property($e, "out")); + return "inout"; +} + ##################################################################### # parse a function sub HeaderFunctionInOut($$) { my($fn,$prop) = @_; - foreach (@{$fn->{ELEMENTS}}) { - HeaderElement($_) if (has_property($_, $prop)); - } + foreach (@{$fn->{ELEMENTS}}) { + HeaderElement($_) if (ElementDirection($_) eq $prop); + } } ##################################################################### @@ -255,8 +264,8 @@ sub HeaderFunctionInOut_needed($$) return 1 if ($prop eq "out" && $fn->{RETURN_TYPE} ne "void"); - foreach (@{$fn->{ELEMENTS}}) { - return 1 if (has_property($_, $prop)); + foreach (@{$fn->{ELEMENTS}}) { + return 1 if (ElementDirection($_) eq $prop); } return undef; @@ -278,19 +287,23 @@ sub HeaderFunction($) $tab_depth++; my $needed = 0; - if (HeaderFunctionInOut_needed($fn, "in")) { + if (HeaderFunctionInOut_needed($fn, "in") or + HeaderFunctionInOut_needed($fn, "inout")) { pidl tabs()."struct {\n"; $tab_depth++; HeaderFunctionInOut($fn, "in"); + HeaderFunctionInOut($fn, "inout"); $tab_depth--; pidl tabs()."} in;\n\n"; $needed++; } - if (HeaderFunctionInOut_needed($fn, "out")) { + if (HeaderFunctionInOut_needed($fn, "out") or + HeaderFunctionInOut_needed($fn, "inout")) { pidl tabs()."struct {\n"; $tab_depth++; HeaderFunctionInOut($fn, "out"); + HeaderFunctionInOut($fn, "inout"); if ($fn->{RETURN_TYPE} ne "void") { pidl tabs().mapType($fn->{RETURN_TYPE}) . " result;\n"; } @@ -299,7 +312,7 @@ sub HeaderFunction($) $needed++; } - if (! $needed) { + if (!$needed) { # sigh - some compilers don't like empty structures pidl tabs()."int _dummy_element;\n"; } -- cgit From 97416e6b011a3c733d07f83073bf12796c7ecc6b Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Mon, 12 Feb 2007 12:12:12 +0000 Subject: r21297: Remove the GTK+ tools and library from the main repository. They are now maintained separately in bzr at http://people.samba.org/bzr/jelmer/samba-gtk This also adds some more headers to the list that is installed and a couple of extra #include lines so these headers can be used externally without problems. (This used to be commit 07652f65ce7a5b19130f1a27cbf0e1e5fae13454) --- source4/pidl/lib/Parse/Pidl/Samba4/Header.pm | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'source4/pidl/lib/Parse/Pidl/Samba4/Header.pm') diff --git a/source4/pidl/lib/Parse/Pidl/Samba4/Header.pm b/source4/pidl/lib/Parse/Pidl/Samba4/Header.pm index 2b5b9c9e01..110a483fc4 100644 --- a/source4/pidl/lib/Parse/Pidl/Samba4/Header.pm +++ b/source4/pidl/lib/Parse/Pidl/Samba4/Header.pm @@ -378,8 +378,10 @@ sub Parse($) %headerstructs = (); pidl "/* header auto-generated by pidl */\n\n"; if (!is_intree()) { - pidl "#include \n\n"; + pidl "#include \n"; } + pidl "#include \n"; + pidl "\n"; foreach (@{$idl}) { ($_->{TYPE} eq "INTERFACE") && HeaderInterface($_); -- cgit From 8cf122c2d2a0913fd9a7c55032c549598844111c Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Sun, 18 Feb 2007 16:21:28 +0000 Subject: r21430: Support tagged types without typedef. This means: struct foo { ... }; in IDL will now work. This is the first step towards nested types and using typedefs for partial types (such as "typedef int *bar;"), a requirement for complex uses of represent_as(). (This used to be commit a716aa70f0c90898e6fcf57d63a2cf4c40e7d4df) --- source4/pidl/lib/Parse/Pidl/Samba4/Header.pm | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'source4/pidl/lib/Parse/Pidl/Samba4/Header.pm') diff --git a/source4/pidl/lib/Parse/Pidl/Samba4/Header.pm b/source4/pidl/lib/Parse/Pidl/Samba4/Header.pm index 110a483fc4..fbc00d7c13 100644 --- a/source4/pidl/lib/Parse/Pidl/Samba4/Header.pm +++ b/source4/pidl/lib/Parse/Pidl/Samba4/Header.pm @@ -219,8 +219,6 @@ sub HeaderTypedef($) { my($typedef) = shift; HeaderType($typedef, $typedef->{DATA}, $typedef->{NAME}); - pidl ";\n\n" unless ($typedef->{DATA}->{TYPE} eq "BITMAP" or - $typedef->{DATA}->{TYPE} eq "ENUM"); } ##################################################################### @@ -354,8 +352,12 @@ sub HeaderInterface($) } foreach my $d (@{$interface->{DATA}}) { - next if ($d->{TYPE} ne "TYPEDEF"); - HeaderTypedef($d); + HeaderTypedef($d) if ($d->{TYPE} eq "TYPEDEF"); + HeaderStruct($d, $d->{NAME}) if ($d->{TYPE} eq "STRUCT"); + HeaderUnion($d, $d->{NAME}) if ($d->{TYPE} eq "UNION"); + HeaderEnum($d, $d->{NAME}) if ($d->{TYPE} eq "ENUM"); + HeaderBitmap($d, $d->{NAME}) if ($d->{TYPE} eq "BITMAP"); + pidl ";\n\n"; } foreach my $d (@{$interface->{DATA}}) { -- cgit From 0515f728e64dde0c197aee6180dce79ad281d5f8 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Sun, 18 Feb 2007 18:44:56 +0000 Subject: r21433: Get rid of the COM support code - it's not used and unmaintained. We can always bring it back if we need to. This code was getting in the way while refactoring. Add some tests for TDR. Get rid of typedef in lib/registry/tdr_regf.idl and fix the TDR code to be able to deal with it. (This used to be commit 1ad0f99a439f0d52a735b391bf9900d50171aca5) --- source4/pidl/lib/Parse/Pidl/Samba4/Header.pm | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'source4/pidl/lib/Parse/Pidl/Samba4/Header.pm') diff --git a/source4/pidl/lib/Parse/Pidl/Samba4/Header.pm b/source4/pidl/lib/Parse/Pidl/Samba4/Header.pm index fbc00d7c13..7e52dbc2ee 100644 --- a/source4/pidl/lib/Parse/Pidl/Samba4/Header.pm +++ b/source4/pidl/lib/Parse/Pidl/Samba4/Header.pm @@ -7,7 +7,7 @@ package Parse::Pidl::Samba4::Header; use strict; -use Parse::Pidl::Typelist qw(mapType); +use Parse::Pidl::Typelist qw(mapTypeName); use Parse::Pidl::Util qw(has_property is_constant); use Parse::Pidl::Samba4 qw(is_intree); @@ -55,7 +55,7 @@ sub HeaderElement($) pidl tabs(); if (has_property($element, "represent_as")) { - pidl mapType($element->{PROPERTIES}->{represent_as})." "; + pidl mapTypeName($element->{PROPERTIES}->{represent_as})." "; } else { HeaderType($element, $element->{TYPE}, ""); pidl " "; @@ -209,7 +209,7 @@ sub HeaderType($$$) if (has_property($e, "charset")) { pidl "const char"; } else { - pidl mapType($e->{TYPE}); + pidl mapTypeName($e->{TYPE}); } } @@ -303,7 +303,7 @@ sub HeaderFunction($) HeaderFunctionInOut($fn, "out"); HeaderFunctionInOut($fn, "inout"); if ($fn->{RETURN_TYPE} ne "void") { - pidl tabs().mapType($fn->{RETURN_TYPE}) . " result;\n"; + pidl tabs().mapTypeName($fn->{RETURN_TYPE}) . " result;\n"; } $tab_depth--; pidl tabs()."} out;\n\n"; -- cgit From 613d1c1fb9d86120c062ab640b69842bd246187c Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Wed, 21 Feb 2007 10:55:03 +0000 Subject: r21486: Remove spurious semicolons. (This used to be commit d2307f3f7e364a2d17f48301a921a532ae313986) --- source4/pidl/lib/Parse/Pidl/Samba4/Header.pm | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'source4/pidl/lib/Parse/Pidl/Samba4/Header.pm') diff --git a/source4/pidl/lib/Parse/Pidl/Samba4/Header.pm b/source4/pidl/lib/Parse/Pidl/Samba4/Header.pm index 7e52dbc2ee..39e6c4233c 100644 --- a/source4/pidl/lib/Parse/Pidl/Samba4/Header.pm +++ b/source4/pidl/lib/Parse/Pidl/Samba4/Header.pm @@ -128,10 +128,10 @@ sub HeaderEnum($$) } pidl "\n"; $tab_depth--; - pidl "};\n"; + pidl "}\n"; pidl "#else\n"; my $count = 0; - pidl "enum $name { __donnot_use_enum_$name=0x7FFFFFFF};\n"; + pidl "enum $name { __donnot_use_enum_$name=0x7FFFFFFF}\n"; my $with_val = 0; my $without_val = 0; foreach my $e (@{$enum->{ELEMENTS}}) { @@ -154,7 +154,6 @@ sub HeaderEnum($$) pidl "#define $name ( $value )\n"; } pidl "#endif\n"; - pidl "\n"; } ##################################################################### @@ -357,7 +356,11 @@ sub HeaderInterface($) HeaderUnion($d, $d->{NAME}) if ($d->{TYPE} eq "UNION"); HeaderEnum($d, $d->{NAME}) if ($d->{TYPE} eq "ENUM"); HeaderBitmap($d, $d->{NAME}) if ($d->{TYPE} eq "BITMAP"); - pidl ";\n\n"; + pidl ";\n\n" if ($d->{TYPE} eq "BITMAP" or + $d->{TYPE} eq "STRUCT" or + $d->{TYPE} eq "TYPEDEF" or + $d->{TYPE} eq "UNION" or + $d->{TYPE} eq "ENUM"); } foreach my $d (@{$interface->{DATA}}) { -- cgit From 79a1b1a928f0f8cdd6c60d74291bf048c8484f0b Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Wed, 21 Feb 2007 14:35:25 +0000 Subject: r21492: Finish work on nested type support in EJS. (This used to be commit e88055b76a3d81fcc40773d880f76a1c3f53fbf0) --- source4/pidl/lib/Parse/Pidl/Samba4/Header.pm | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source4/pidl/lib/Parse/Pidl/Samba4/Header.pm') diff --git a/source4/pidl/lib/Parse/Pidl/Samba4/Header.pm b/source4/pidl/lib/Parse/Pidl/Samba4/Header.pm index 39e6c4233c..11ecc17001 100644 --- a/source4/pidl/lib/Parse/Pidl/Samba4/Header.pm +++ b/source4/pidl/lib/Parse/Pidl/Samba4/Header.pm @@ -7,7 +7,7 @@ package Parse::Pidl::Samba4::Header; use strict; -use Parse::Pidl::Typelist qw(mapTypeName); +use Parse::Pidl::Typelist qw(mapTypeName scalar_is_reference); use Parse::Pidl::Util qw(has_property is_constant); use Parse::Pidl::Samba4 qw(is_intree); @@ -61,7 +61,7 @@ sub HeaderElement($) pidl " "; my $numstar = $element->{POINTERS}; if ($numstar >= 1) { - $numstar-- if Parse::Pidl::Typelist::scalar_is_reference($element->{TYPE}); + $numstar-- if (scalar_is_reference($element->{TYPE})); } foreach (@{$element->{ARRAY_LEN}}) { -- cgit From 5ba8169109253c96f71e0e039b1c0b7a1056eab0 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Wed, 28 Feb 2007 13:25:53 +0000 Subject: r21584: Support for tagged types has landed! It's now possible to use "struct foo" without a typedef in IDL files. echo_info4 is the first type that's been converted. (This used to be commit 3ac68e858df9b53cf5e0a84741916214a53b3121) --- source4/pidl/lib/Parse/Pidl/Samba4/Header.pm | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) (limited to 'source4/pidl/lib/Parse/Pidl/Samba4/Header.pm') diff --git a/source4/pidl/lib/Parse/Pidl/Samba4/Header.pm b/source4/pidl/lib/Parse/Pidl/Samba4/Header.pm index 11ecc17001..2eddf22b05 100644 --- a/source4/pidl/lib/Parse/Pidl/Samba4/Header.pm +++ b/source4/pidl/lib/Parse/Pidl/Samba4/Header.pm @@ -57,7 +57,11 @@ sub HeaderElement($) if (has_property($element, "represent_as")) { pidl mapTypeName($element->{PROPERTIES}->{represent_as})." "; } else { - HeaderType($element, $element->{TYPE}, ""); + if (ref($element->{TYPE}) eq "HASH") { + HeaderType($element, $element->{TYPE}, $element->{TYPE}->{NAME}); + } else { + HeaderType($element, $element->{TYPE}, ""); + } pidl " "; my $numstar = $element->{POINTERS}; if ($numstar >= 1) { @@ -90,14 +94,14 @@ sub HeaderElement($) sub HeaderStruct($$) { my($struct,$name) = @_; - pidl "struct $name {\n"; + pidl "struct $name"; + return if (not defined($struct->{ELEMENTS})); + pidl " {\n"; $tab_depth++; my $el_count=0; - if (defined $struct->{ELEMENTS}) { - foreach (@{$struct->{ELEMENTS}}) { - HeaderElement($_); - $el_count++; - } + foreach (@{$struct->{ELEMENTS}}) { + HeaderElement($_); + $el_count++; } if ($el_count == 0) { # some compilers can't handle empty structures @@ -174,7 +178,9 @@ sub HeaderUnion($$) my($union,$name) = @_; my %done = (); - pidl "union $name {\n"; + pidl "union $name"; + return if (not defined($union->{ELEMENTS})); + pidl " {\n"; $tab_depth++; foreach my $e (@{$union->{ELEMENTS}}) { if ($e->{TYPE} ne "EMPTY") { -- cgit From 0bc6c5a7b159bdd4678a378819b9346523729033 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Wed, 2 May 2007 18:00:02 +0000 Subject: r22640: - generate nicer output - fix compiler warning about unused ';' metze (This used to be commit 715060187f482486f00e2d6b2cd62d2a0e215a2f) --- source4/pidl/lib/Parse/Pidl/Samba4/Header.pm | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) (limited to 'source4/pidl/lib/Parse/Pidl/Samba4/Header.pm') diff --git a/source4/pidl/lib/Parse/Pidl/Samba4/Header.pm b/source4/pidl/lib/Parse/Pidl/Samba4/Header.pm index 2eddf22b05..f43c042da9 100644 --- a/source4/pidl/lib/Parse/Pidl/Samba4/Header.pm +++ b/source4/pidl/lib/Parse/Pidl/Samba4/Header.pm @@ -43,7 +43,7 @@ sub HeaderProperties($$) } if ($ret) { - pidl "/* [" . substr($ret, 0, -1) . "] */"; + pidl " /* [" . substr($ret, 0, -1) . "] */"; } } @@ -108,10 +108,12 @@ sub HeaderStruct($$) pidl tabs()."char _empty_;\n"; } $tab_depth--; - pidl tabs()."}"; + + pidl "};"; if (defined $struct->{PROPERTIES}) { HeaderProperties($struct->{PROPERTIES}, []); } + pidl "\n\n"; } ##################################################################### @@ -132,10 +134,10 @@ sub HeaderEnum($$) } pidl "\n"; $tab_depth--; - pidl "}\n"; + pidl "};\n"; pidl "#else\n"; my $count = 0; - pidl "enum $name { __donnot_use_enum_$name=0x7FFFFFFF}\n"; + pidl "enum $name { __donnot_use_enum_$name=0x7FFFFFFF};\n"; my $with_val = 0; my $without_val = 0; foreach my $e (@{$enum->{ELEMENTS}}) { @@ -191,11 +193,12 @@ sub HeaderUnion($$) } } $tab_depth--; - pidl "}"; + pidl "};"; if (defined $union->{PROPERTIES}) { HeaderProperties($union->{PROPERTIES}, []); } + pidl "\n\n"; } ##################################################################### @@ -297,7 +300,7 @@ sub HeaderFunction($) HeaderFunctionInOut($fn, "in"); HeaderFunctionInOut($fn, "inout"); $tab_depth--; - pidl tabs()."} in;\n\n"; + pidl tabs()."} in;\n"; $needed++; } @@ -311,7 +314,7 @@ sub HeaderFunction($) pidl tabs().mapTypeName($fn->{RETURN_TYPE}) . " result;\n"; } $tab_depth--; - pidl tabs()."} out;\n\n"; + pidl tabs()."} out;\n"; $needed++; } @@ -362,11 +365,6 @@ sub HeaderInterface($) HeaderUnion($d, $d->{NAME}) if ($d->{TYPE} eq "UNION"); HeaderEnum($d, $d->{NAME}) if ($d->{TYPE} eq "ENUM"); HeaderBitmap($d, $d->{NAME}) if ($d->{TYPE} eq "BITMAP"); - pidl ";\n\n" if ($d->{TYPE} eq "BITMAP" or - $d->{TYPE} eq "STRUCT" or - $d->{TYPE} eq "TYPEDEF" or - $d->{TYPE} eq "UNION" or - $d->{TYPE} eq "ENUM"); } foreach my $d (@{$interface->{DATA}}) { -- cgit From c83c6740ab8a82354b4f6d5be610389e58f8a926 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Fri, 4 May 2007 10:44:41 +0000 Subject: r22667: revert revision 22640 as it breaks nested structs in idl metze (This used to be commit b5c84460fc8599fbd894bcf8c4f7b440e2424af1) --- source4/pidl/lib/Parse/Pidl/Samba4/Header.pm | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) (limited to 'source4/pidl/lib/Parse/Pidl/Samba4/Header.pm') diff --git a/source4/pidl/lib/Parse/Pidl/Samba4/Header.pm b/source4/pidl/lib/Parse/Pidl/Samba4/Header.pm index f43c042da9..2eddf22b05 100644 --- a/source4/pidl/lib/Parse/Pidl/Samba4/Header.pm +++ b/source4/pidl/lib/Parse/Pidl/Samba4/Header.pm @@ -43,7 +43,7 @@ sub HeaderProperties($$) } if ($ret) { - pidl " /* [" . substr($ret, 0, -1) . "] */"; + pidl "/* [" . substr($ret, 0, -1) . "] */"; } } @@ -108,12 +108,10 @@ sub HeaderStruct($$) pidl tabs()."char _empty_;\n"; } $tab_depth--; - - pidl "};"; + pidl tabs()."}"; if (defined $struct->{PROPERTIES}) { HeaderProperties($struct->{PROPERTIES}, []); } - pidl "\n\n"; } ##################################################################### @@ -134,10 +132,10 @@ sub HeaderEnum($$) } pidl "\n"; $tab_depth--; - pidl "};\n"; + pidl "}\n"; pidl "#else\n"; my $count = 0; - pidl "enum $name { __donnot_use_enum_$name=0x7FFFFFFF};\n"; + pidl "enum $name { __donnot_use_enum_$name=0x7FFFFFFF}\n"; my $with_val = 0; my $without_val = 0; foreach my $e (@{$enum->{ELEMENTS}}) { @@ -193,12 +191,11 @@ sub HeaderUnion($$) } } $tab_depth--; + pidl "}"; - pidl "};"; if (defined $union->{PROPERTIES}) { HeaderProperties($union->{PROPERTIES}, []); } - pidl "\n\n"; } ##################################################################### @@ -300,7 +297,7 @@ sub HeaderFunction($) HeaderFunctionInOut($fn, "in"); HeaderFunctionInOut($fn, "inout"); $tab_depth--; - pidl tabs()."} in;\n"; + pidl tabs()."} in;\n\n"; $needed++; } @@ -314,7 +311,7 @@ sub HeaderFunction($) pidl tabs().mapTypeName($fn->{RETURN_TYPE}) . " result;\n"; } $tab_depth--; - pidl tabs()."} out;\n"; + pidl tabs()."} out;\n\n"; $needed++; } @@ -365,6 +362,11 @@ sub HeaderInterface($) HeaderUnion($d, $d->{NAME}) if ($d->{TYPE} eq "UNION"); HeaderEnum($d, $d->{NAME}) if ($d->{TYPE} eq "ENUM"); HeaderBitmap($d, $d->{NAME}) if ($d->{TYPE} eq "BITMAP"); + pidl ";\n\n" if ($d->{TYPE} eq "BITMAP" or + $d->{TYPE} eq "STRUCT" or + $d->{TYPE} eq "TYPEDEF" or + $d->{TYPE} eq "UNION" or + $d->{TYPE} eq "ENUM"); } foreach my $d (@{$interface->{DATA}}) { -- cgit From 42ded6d10bd3e2efa472f99d607284996d581f27 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Thu, 16 Aug 2007 10:07:19 +0000 Subject: r24482: white space cleanup only... metze (This used to be commit 8a23db61e425d10a6f9710a277497d60b114a753) --- source4/pidl/lib/Parse/Pidl/Samba4/Header.pm | 207 ++++++++++++++------------- 1 file changed, 104 insertions(+), 103 deletions(-) (limited to 'source4/pidl/lib/Parse/Pidl/Samba4/Header.pm') diff --git a/source4/pidl/lib/Parse/Pidl/Samba4/Header.pm b/source4/pidl/lib/Parse/Pidl/Samba4/Header.pm index 2eddf22b05..3cf86f769e 100644 --- a/source4/pidl/lib/Parse/Pidl/Samba4/Header.pm +++ b/source4/pidl/lib/Parse/Pidl/Samba4/Header.pm @@ -30,10 +30,10 @@ sub tabs() # parse a properties list sub HeaderProperties($$) { - my($props,$ignores) = @_; + my($props,$ignores) = @_; my $ret = ""; - foreach my $d (keys %{$props}) { + foreach my $d (keys %{$props}) { next if (grep(/^$d$/, @$ignores)); if($props->{$d} ne "1") { $ret.= "$d($props->{$d}),"; @@ -93,22 +93,22 @@ sub HeaderElement($) # parse a struct sub HeaderStruct($$) { - my($struct,$name) = @_; + my($struct,$name) = @_; pidl "struct $name"; - return if (not defined($struct->{ELEMENTS})); + return if (not defined($struct->{ELEMENTS})); pidl " {\n"; - $tab_depth++; - my $el_count=0; + $tab_depth++; + my $el_count=0; foreach (@{$struct->{ELEMENTS}}) { HeaderElement($_); $el_count++; - } - if ($el_count == 0) { - # some compilers can't handle empty structures - pidl tabs()."char _empty_;\n"; - } - $tab_depth--; - pidl tabs()."}"; + } + if ($el_count == 0) { + # some compilers can't handle empty structures + pidl tabs()."char _empty_;\n"; + } + $tab_depth--; + pidl tabs()."}"; if (defined $struct->{PROPERTIES}) { HeaderProperties($struct->{PROPERTIES}, []); } @@ -118,17 +118,17 @@ sub HeaderStruct($$) # parse a enum sub HeaderEnum($$) { - my($enum,$name) = @_; - my $first = 1; + my($enum,$name) = @_; + my $first = 1; pidl "#ifndef USE_UINT_ENUMS\n"; pidl "enum $name {\n"; $tab_depth++; foreach my $e (@{$enum->{ELEMENTS}}) { - unless ($first) { pidl ",\n"; } - $first = 0; - pidl tabs(); - pidl $e; + unless ($first) { pidl ",\n"; } + $first = 0; + pidl tabs(); + pidl $e; } pidl "\n"; $tab_depth--; @@ -139,23 +139,23 @@ sub HeaderEnum($$) my $with_val = 0; my $without_val = 0; foreach my $e (@{$enum->{ELEMENTS}}) { - my $t = "$e"; - my $name; - my $value; - if ($t =~ /(.*)=(.*)/) { - $name = $1; - $value = $2; - $with_val = 1; - die ("you can't mix enum member with values and without values when using --uint-enums!") - unless ($without_val == 0); - } else { - $name = $t; - $value = $count++; - $without_val = 1; - die ("you can't mix enum member with values and without values when using --uint-enums!") - unless ($with_val == 0); - } - pidl "#define $name ( $value )\n"; + my $t = "$e"; + my $name; + my $value; + if ($t =~ /(.*)=(.*)/) { + $name = $1; + $value = $2; + $with_val = 1; + die ("you can't mix enum member with values and without values when using --uint-enums!") + unless ($without_val == 0); + } else { + $name = $t; + $value = $count++; + $without_val = 1; + die ("you can't mix enum member with values and without values when using --uint-enums!") + unless ($with_val == 0); + } + pidl "#define $name ( $value )\n"; } pidl "#endif\n"; } @@ -164,11 +164,11 @@ sub HeaderEnum($$) # parse a bitmap sub HeaderBitmap($$) { - my($bitmap,$name) = @_; + my($bitmap,$name) = @_; - pidl "/* bitmap $name */\n"; - pidl "#define $_\n" foreach (@{$bitmap->{ELEMENTS}}); - pidl "\n"; + pidl "/* bitmap $name */\n"; + pidl "#define $_\n" foreach (@{$bitmap->{ELEMENTS}}); + pidl "\n"; } ##################################################################### @@ -222,20 +222,20 @@ sub HeaderType($$$) # parse a typedef sub HeaderTypedef($) { - my($typedef) = shift; - HeaderType($typedef, $typedef->{DATA}, $typedef->{NAME}); + my($typedef) = shift; + HeaderType($typedef, $typedef->{DATA}, $typedef->{NAME}); } ##################################################################### # parse a const sub HeaderConst($) { - my($const) = shift; - if (!defined($const->{ARRAY_LEN}[0])) { - pidl "#define $const->{NAME}\t( $const->{VALUE} )\n"; - } else { - pidl "#define $const->{NAME}\t $const->{VALUE}\n"; - } + my($const) = shift; + if (!defined($const->{ARRAY_LEN}[0])) { + pidl "#define $const->{NAME}\t( $const->{VALUE} )\n"; + } else { + pidl "#define $const->{NAME}\t $const->{VALUE}\n"; + } } sub ElementDirection($) @@ -252,7 +252,7 @@ sub ElementDirection($) # parse a function sub HeaderFunctionInOut($$) { - my($fn,$prop) = @_; + my($fn,$prop) = @_; foreach (@{$fn->{ELEMENTS}}) { HeaderElement($_) if (ElementDirection($_) eq $prop); @@ -263,15 +263,15 @@ sub HeaderFunctionInOut($$) # determine if we need an "in" or "out" section sub HeaderFunctionInOut_needed($$) { - my($fn,$prop) = @_; + my($fn,$prop) = @_; - return 1 if ($prop eq "out" && $fn->{RETURN_TYPE} ne "void"); + return 1 if ($prop eq "out" && $fn->{RETURN_TYPE} ne "void"); foreach (@{$fn->{ELEMENTS}}) { return 1 if (ElementDirection($_) eq $prop); - } + } - return undef; + return undef; } my %headerstructs; @@ -280,48 +280,48 @@ my %headerstructs; # parse a function sub HeaderFunction($) { - my($fn) = shift; + my($fn) = shift; - return if ($headerstructs{$fn->{NAME}}); + return if ($headerstructs{$fn->{NAME}}); - $headerstructs{$fn->{NAME}} = 1; + $headerstructs{$fn->{NAME}} = 1; - pidl "\nstruct $fn->{NAME} {\n"; - $tab_depth++; - my $needed = 0; + pidl "\nstruct $fn->{NAME} {\n"; + $tab_depth++; + my $needed = 0; - if (HeaderFunctionInOut_needed($fn, "in") or + if (HeaderFunctionInOut_needed($fn, "in") or HeaderFunctionInOut_needed($fn, "inout")) { - pidl tabs()."struct {\n"; - $tab_depth++; - HeaderFunctionInOut($fn, "in"); - HeaderFunctionInOut($fn, "inout"); - $tab_depth--; - pidl tabs()."} in;\n\n"; - $needed++; - } - - if (HeaderFunctionInOut_needed($fn, "out") or + pidl tabs()."struct {\n"; + $tab_depth++; + HeaderFunctionInOut($fn, "in"); + HeaderFunctionInOut($fn, "inout"); + $tab_depth--; + pidl tabs()."} in;\n\n"; + $needed++; + } + + if (HeaderFunctionInOut_needed($fn, "out") or HeaderFunctionInOut_needed($fn, "inout")) { - pidl tabs()."struct {\n"; - $tab_depth++; - HeaderFunctionInOut($fn, "out"); - HeaderFunctionInOut($fn, "inout"); - if ($fn->{RETURN_TYPE} ne "void") { - pidl tabs().mapTypeName($fn->{RETURN_TYPE}) . " result;\n"; - } - $tab_depth--; - pidl tabs()."} out;\n\n"; - $needed++; - } - - if (!$needed) { - # sigh - some compilers don't like empty structures - pidl tabs()."int _dummy_element;\n"; - } - - $tab_depth--; - pidl "};\n\n"; + pidl tabs()."struct {\n"; + $tab_depth++; + HeaderFunctionInOut($fn, "out"); + HeaderFunctionInOut($fn, "inout"); + if ($fn->{RETURN_TYPE} ne "void") { + pidl tabs().mapTypeName($fn->{RETURN_TYPE}) . " result;\n"; + } + $tab_depth--; + pidl tabs()."} out;\n\n"; + $needed++; + } + + if (!$needed) { + # sigh - some compilers don't like empty structures + pidl tabs()."int _dummy_element;\n"; + } + + $tab_depth--; + pidl "};\n\n"; } sub HeaderImport @@ -363,10 +363,10 @@ sub HeaderInterface($) HeaderEnum($d, $d->{NAME}) if ($d->{TYPE} eq "ENUM"); HeaderBitmap($d, $d->{NAME}) if ($d->{TYPE} eq "BITMAP"); pidl ";\n\n" if ($d->{TYPE} eq "BITMAP" or - $d->{TYPE} eq "STRUCT" or - $d->{TYPE} eq "TYPEDEF" or - $d->{TYPE} eq "UNION" or - $d->{TYPE} eq "ENUM"); + $d->{TYPE} eq "STRUCT" or + $d->{TYPE} eq "TYPEDEF" or + $d->{TYPE} eq "UNION" or + $d->{TYPE} eq "ENUM"); } foreach my $d (@{$interface->{DATA}}) { @@ -382,24 +382,25 @@ sub HeaderInterface($) # parse a parsed IDL into a C header sub Parse($) { - my($idl) = shift; - $tab_depth = 0; + my($idl) = shift; + $tab_depth = 0; $res = ""; %headerstructs = (); - pidl "/* header auto-generated by pidl */\n\n"; + pidl "/* header auto-generated by pidl */\n\n"; if (!is_intree()) { pidl "#include \n"; } pidl "#include \n"; pidl "\n"; - - foreach (@{$idl}) { - ($_->{TYPE} eq "INTERFACE") && HeaderInterface($_); - ($_->{TYPE} eq "IMPORT") && HeaderImport(@{$_->{PATHS}}); - ($_->{TYPE} eq "INCLUDE") && HeaderInclude(@{$_->{PATHS}}); - } - return $res; + + foreach (@{$idl}) { + ($_->{TYPE} eq "INTERFACE") && HeaderInterface($_); + ($_->{TYPE} eq "IMPORT") && HeaderImport(@{$_->{PATHS}}); + ($_->{TYPE} eq "INCLUDE") && HeaderInclude(@{$_->{PATHS}}); + } + + return $res; } 1; -- cgit From e87adacc43eb1f68d0d32b03ced62ae0caabebc9 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Thu, 16 Aug 2007 10:54:11 +0000 Subject: r24484: pass down $ndr tree instead of the $pidl tree to Samba4/Header.pm metze (This used to be commit 212e8ec8d51b75fdfed5ae1ea228133811186a72) --- source4/pidl/lib/Parse/Pidl/Samba4/Header.pm | 25 +++++++++++-------------- 1 file changed, 11 insertions(+), 14 deletions(-) (limited to 'source4/pidl/lib/Parse/Pidl/Samba4/Header.pm') diff --git a/source4/pidl/lib/Parse/Pidl/Samba4/Header.pm b/source4/pidl/lib/Parse/Pidl/Samba4/Header.pm index 3cf86f769e..650b6f51ab 100644 --- a/source4/pidl/lib/Parse/Pidl/Samba4/Header.pm +++ b/source4/pidl/lib/Parse/Pidl/Samba4/Header.pm @@ -351,17 +351,16 @@ sub HeaderInterface($) pidl "#ifndef _HEADER_$interface->{NAME}\n"; pidl "#define _HEADER_$interface->{NAME}\n\n"; - foreach my $d (@{$interface->{DATA}}) { - next if ($d->{TYPE} ne "CONST"); + foreach my $d (@{$interface->{CONSTS}}) { HeaderConst($d); } - foreach my $d (@{$interface->{DATA}}) { - HeaderTypedef($d) if ($d->{TYPE} eq "TYPEDEF"); - HeaderStruct($d, $d->{NAME}) if ($d->{TYPE} eq "STRUCT"); - HeaderUnion($d, $d->{NAME}) if ($d->{TYPE} eq "UNION"); - HeaderEnum($d, $d->{NAME}) if ($d->{TYPE} eq "ENUM"); - HeaderBitmap($d, $d->{NAME}) if ($d->{TYPE} eq "BITMAP"); + foreach my $d (@{$interface->{TYPES}}) { + HeaderTypedef($d->{ORIGINAL}) if ($d->{TYPE} eq "TYPEDEF"); + HeaderStruct($d->{ORIGINAL}, $d->{NAME}) if ($d->{TYPE} eq "STRUCT"); + HeaderUnion($d->{ORIGINAL}, $d->{NAME}) if ($d->{TYPE} eq "UNION"); + HeaderEnum($d->{ORIGINAL}, $d->{NAME}) if ($d->{TYPE} eq "ENUM"); + HeaderBitmap($d->{ORIGINAL}, $d->{NAME}) if ($d->{TYPE} eq "BITMAP"); pidl ";\n\n" if ($d->{TYPE} eq "BITMAP" or $d->{TYPE} eq "STRUCT" or $d->{TYPE} eq "TYPEDEF" or @@ -369,10 +368,8 @@ sub HeaderInterface($) $d->{TYPE} eq "ENUM"); } - foreach my $d (@{$interface->{DATA}}) { - next if ($d->{TYPE} ne "FUNCTION"); - - HeaderFunction($d); + foreach my $d (@{$interface->{FUNCTIONS}}) { + HeaderFunction($d->{ORIGINAL}); } pidl "#endif /* _HEADER_$interface->{NAME} */\n"; @@ -382,7 +379,7 @@ sub HeaderInterface($) # parse a parsed IDL into a C header sub Parse($) { - my($idl) = shift; + my($ndr) = shift; $tab_depth = 0; $res = ""; @@ -394,7 +391,7 @@ sub Parse($) pidl "#include \n"; pidl "\n"; - foreach (@{$idl}) { + foreach (@{$ndr}) { ($_->{TYPE} eq "INTERFACE") && HeaderInterface($_); ($_->{TYPE} eq "IMPORT") && HeaderImport(@{$_->{PATHS}}); ($_->{TYPE} eq "INCLUDE") && HeaderInclude(@{$_->{PATHS}}); -- cgit From f9bca9e9acc3188f9c8449b2505c0c723dd516af Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Fri, 17 Aug 2007 07:06:02 +0000 Subject: r24505: pass down $fn one level metze (This used to be commit 0bad3f06199341aeacef228e482ab755e2e48306) --- source4/pidl/lib/Parse/Pidl/Samba4/Header.pm | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) (limited to 'source4/pidl/lib/Parse/Pidl/Samba4/Header.pm') diff --git a/source4/pidl/lib/Parse/Pidl/Samba4/Header.pm b/source4/pidl/lib/Parse/Pidl/Samba4/Header.pm index 650b6f51ab..3c0a7bc24e 100644 --- a/source4/pidl/lib/Parse/Pidl/Samba4/Header.pm +++ b/source4/pidl/lib/Parse/Pidl/Samba4/Header.pm @@ -290,24 +290,24 @@ sub HeaderFunction($) $tab_depth++; my $needed = 0; - if (HeaderFunctionInOut_needed($fn, "in") or - HeaderFunctionInOut_needed($fn, "inout")) { + if (HeaderFunctionInOut_needed($fn->{ORIGINAL}, "in") or + HeaderFunctionInOut_needed($fn->{ORIGINAL}, "inout")) { pidl tabs()."struct {\n"; $tab_depth++; - HeaderFunctionInOut($fn, "in"); - HeaderFunctionInOut($fn, "inout"); + HeaderFunctionInOut($fn->{ORIGINAL}, "in"); + HeaderFunctionInOut($fn->{ORIGINAL}, "inout"); $tab_depth--; pidl tabs()."} in;\n\n"; $needed++; } - if (HeaderFunctionInOut_needed($fn, "out") or - HeaderFunctionInOut_needed($fn, "inout")) { + if (HeaderFunctionInOut_needed($fn->{ORIGINAL}, "out") or + HeaderFunctionInOut_needed($fn->{ORIGINAL}, "inout")) { pidl tabs()."struct {\n"; $tab_depth++; - HeaderFunctionInOut($fn, "out"); - HeaderFunctionInOut($fn, "inout"); - if ($fn->{RETURN_TYPE} ne "void") { + HeaderFunctionInOut($fn->{ORIGINAL}, "out"); + HeaderFunctionInOut($fn->{ORIGINAL}, "inout"); + if (defined($fn->{RETURN_TYPE})) { pidl tabs().mapTypeName($fn->{RETURN_TYPE}) . " result;\n"; } $tab_depth--; @@ -368,8 +368,8 @@ sub HeaderInterface($) $d->{TYPE} eq "ENUM"); } - foreach my $d (@{$interface->{FUNCTIONS}}) { - HeaderFunction($d->{ORIGINAL}); + foreach my $fn (@{$interface->{FUNCTIONS}}) { + HeaderFunction($fn); } pidl "#endif /* _HEADER_$interface->{NAME} */\n"; -- cgit From 9785c25519c412670ee6fc7e39828e6744e66e14 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Fri, 17 Aug 2007 07:46:34 +0000 Subject: r24506: pass $fn down one more layer metze (This used to be commit 8cc3fd09ffce6f389d979ec0a49d2ecefda70dd1) --- source4/pidl/lib/Parse/Pidl/Samba4/Header.pm | 30 ++++++++++++++++------------ 1 file changed, 17 insertions(+), 13 deletions(-) (limited to 'source4/pidl/lib/Parse/Pidl/Samba4/Header.pm') diff --git a/source4/pidl/lib/Parse/Pidl/Samba4/Header.pm b/source4/pidl/lib/Parse/Pidl/Samba4/Header.pm index 3c0a7bc24e..e10f647635 100644 --- a/source4/pidl/lib/Parse/Pidl/Samba4/Header.pm +++ b/source4/pidl/lib/Parse/Pidl/Samba4/Header.pm @@ -254,8 +254,10 @@ sub HeaderFunctionInOut($$) { my($fn,$prop) = @_; - foreach (@{$fn->{ELEMENTS}}) { - HeaderElement($_) if (ElementDirection($_) eq $prop); + return unless defined($fn->{ELEMENTS}); + + foreach my $e (@{$fn->{ELEMENTS}}) { + HeaderElement($e->{ORIGINAL}) if (ElementDirection($e) eq $prop); } } @@ -265,10 +267,12 @@ sub HeaderFunctionInOut_needed($$) { my($fn,$prop) = @_; - return 1 if ($prop eq "out" && $fn->{RETURN_TYPE} ne "void"); + return 1 if ($prop eq "out" && defined($fn->{RETURN_TYPE})); + + return undef unless defined($fn->{ELEMENTS}); - foreach (@{$fn->{ELEMENTS}}) { - return 1 if (ElementDirection($_) eq $prop); + foreach my $e (@{$fn->{ELEMENTS}}) { + return 1 if (ElementDirection($e) eq $prop); } return undef; @@ -290,23 +294,23 @@ sub HeaderFunction($) $tab_depth++; my $needed = 0; - if (HeaderFunctionInOut_needed($fn->{ORIGINAL}, "in") or - HeaderFunctionInOut_needed($fn->{ORIGINAL}, "inout")) { + if (HeaderFunctionInOut_needed($fn, "in") or + HeaderFunctionInOut_needed($fn, "inout")) { pidl tabs()."struct {\n"; $tab_depth++; - HeaderFunctionInOut($fn->{ORIGINAL}, "in"); - HeaderFunctionInOut($fn->{ORIGINAL}, "inout"); + HeaderFunctionInOut($fn, "in"); + HeaderFunctionInOut($fn, "inout"); $tab_depth--; pidl tabs()."} in;\n\n"; $needed++; } - if (HeaderFunctionInOut_needed($fn->{ORIGINAL}, "out") or - HeaderFunctionInOut_needed($fn->{ORIGINAL}, "inout")) { + if (HeaderFunctionInOut_needed($fn, "out") or + HeaderFunctionInOut_needed($fn, "inout")) { pidl tabs()."struct {\n"; $tab_depth++; - HeaderFunctionInOut($fn->{ORIGINAL}, "out"); - HeaderFunctionInOut($fn->{ORIGINAL}, "inout"); + HeaderFunctionInOut($fn, "out"); + HeaderFunctionInOut($fn, "inout"); if (defined($fn->{RETURN_TYPE})) { pidl tabs().mapTypeName($fn->{RETURN_TYPE}) . " result;\n"; } -- cgit From 3d753b59a95fdb04c26e349c93fddab485beab0f Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Fri, 17 Aug 2007 08:05:57 +0000 Subject: r24507: pass $d down to HeaderTypedef metze (This used to be commit 0edec25af84744074aeeb5f8f7b61a6c78ef35b7) --- source4/pidl/lib/Parse/Pidl/Samba4/Header.pm | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source4/pidl/lib/Parse/Pidl/Samba4/Header.pm') diff --git a/source4/pidl/lib/Parse/Pidl/Samba4/Header.pm b/source4/pidl/lib/Parse/Pidl/Samba4/Header.pm index e10f647635..76034109b7 100644 --- a/source4/pidl/lib/Parse/Pidl/Samba4/Header.pm +++ b/source4/pidl/lib/Parse/Pidl/Samba4/Header.pm @@ -223,7 +223,7 @@ sub HeaderType($$$) sub HeaderTypedef($) { my($typedef) = shift; - HeaderType($typedef, $typedef->{DATA}, $typedef->{NAME}); + HeaderType($typedef, $typedef->{DATA}->{ORIGINAL}, $typedef->{NAME}); } ##################################################################### @@ -360,7 +360,7 @@ sub HeaderInterface($) } foreach my $d (@{$interface->{TYPES}}) { - HeaderTypedef($d->{ORIGINAL}) if ($d->{TYPE} eq "TYPEDEF"); + HeaderTypedef($d) if ($d->{TYPE} eq "TYPEDEF"); HeaderStruct($d->{ORIGINAL}, $d->{NAME}) if ($d->{TYPE} eq "STRUCT"); HeaderUnion($d->{ORIGINAL}, $d->{NAME}) if ($d->{TYPE} eq "UNION"); HeaderEnum($d->{ORIGINAL}, $d->{NAME}) if ($d->{TYPE} eq "ENUM"); -- cgit From de512e88a905a7075e876127c252c010319d47d3 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Fri, 17 Aug 2007 08:47:38 +0000 Subject: r24508: add HeaderTypeNew() which will go if everything is converted metze (This used to be commit 0eba05b6a67eb5b119e9054af3fe9db855cb9fbe) --- source4/pidl/lib/Parse/Pidl/Samba4/Header.pm | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) (limited to 'source4/pidl/lib/Parse/Pidl/Samba4/Header.pm') diff --git a/source4/pidl/lib/Parse/Pidl/Samba4/Header.pm b/source4/pidl/lib/Parse/Pidl/Samba4/Header.pm index 76034109b7..d7cfdd8e9f 100644 --- a/source4/pidl/lib/Parse/Pidl/Samba4/Header.pm +++ b/source4/pidl/lib/Parse/Pidl/Samba4/Header.pm @@ -217,13 +217,30 @@ sub HeaderType($$$) pidl mapTypeName($e->{TYPE}); } } +sub HeaderTypeNew($$$) +{ + my($e,$data,$name) = @_; + if (ref($data) eq "HASH") { + ($data->{TYPE} eq "ENUM") && HeaderEnum($data->{ORIGINAL}, $name); + ($data->{TYPE} eq "BITMAP") && HeaderBitmap($data->{ORIGINAL}, $name); + ($data->{TYPE} eq "STRUCT") && HeaderStruct($data->{ORIGINAL}, $name); + ($data->{TYPE} eq "UNION") && HeaderUnion($data->{ORIGINAL}, $name); + return; + } + + if (has_property($e, "charset")) { + pidl "const char"; + } else { + pidl mapTypeName($e->{TYPE}); + } +} ##################################################################### # parse a typedef sub HeaderTypedef($) { my($typedef) = shift; - HeaderType($typedef, $typedef->{DATA}->{ORIGINAL}, $typedef->{NAME}); + HeaderTypeNew($typedef, $typedef->{DATA}, $typedef->{NAME}); } ##################################################################### -- cgit From 1aa024dfbb1912054571de04e31cf0be7b1d2a27 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Fri, 17 Aug 2007 09:01:19 +0000 Subject: r24509: pass down the full ndr elements instead of the old pidl elements from ->{ORIGINAL} metze (This used to be commit e8ebee2698d7d91d8cf25b3017f3414578607ff5) --- source4/pidl/lib/Parse/Pidl/Samba4/Header.pm | 103 ++++++++++++--------------- 1 file changed, 46 insertions(+), 57 deletions(-) (limited to 'source4/pidl/lib/Parse/Pidl/Samba4/Header.pm') diff --git a/source4/pidl/lib/Parse/Pidl/Samba4/Header.pm b/source4/pidl/lib/Parse/Pidl/Samba4/Header.pm index d7cfdd8e9f..bcf3693573 100644 --- a/source4/pidl/lib/Parse/Pidl/Samba4/Header.pm +++ b/source4/pidl/lib/Parse/Pidl/Samba4/Header.pm @@ -63,11 +63,11 @@ sub HeaderElement($) HeaderType($element, $element->{TYPE}, ""); } pidl " "; - my $numstar = $element->{POINTERS}; + my $numstar = $element->{ORIGINAL}->{POINTERS}; if ($numstar >= 1) { $numstar-- if (scalar_is_reference($element->{TYPE})); } - foreach (@{$element->{ARRAY_LEN}}) + foreach (@{$element->{ORIGINAL}->{ARRAY_LEN}}) { next if is_constant($_) and not has_property($element, "charset"); @@ -76,7 +76,7 @@ sub HeaderElement($) pidl "*" foreach (1..$numstar); } pidl $element->{NAME}; - foreach (@{$element->{ARRAY_LEN}}) { + foreach (@{$element->{ORIGINAL}->{ARRAY_LEN}}) { next unless (is_constant($_) and not has_property($element, "charset")); pidl "[$_]"; @@ -124,11 +124,13 @@ sub HeaderEnum($$) pidl "#ifndef USE_UINT_ENUMS\n"; pidl "enum $name {\n"; $tab_depth++; - foreach my $e (@{$enum->{ELEMENTS}}) { - unless ($first) { pidl ",\n"; } - $first = 0; - pidl tabs(); - pidl $e; + if (defined($enum->{ELEMENTS})) { + foreach my $e (@{$enum->{ELEMENTS}}) { + unless ($first) { pidl ",\n"; } + $first = 0; + pidl tabs(); + pidl $e; + } } pidl "\n"; $tab_depth--; @@ -138,24 +140,26 @@ sub HeaderEnum($$) pidl "enum $name { __donnot_use_enum_$name=0x7FFFFFFF}\n"; my $with_val = 0; my $without_val = 0; - foreach my $e (@{$enum->{ELEMENTS}}) { - my $t = "$e"; - my $name; - my $value; - if ($t =~ /(.*)=(.*)/) { - $name = $1; - $value = $2; - $with_val = 1; - die ("you can't mix enum member with values and without values when using --uint-enums!") - unless ($without_val == 0); - } else { - $name = $t; - $value = $count++; - $without_val = 1; - die ("you can't mix enum member with values and without values when using --uint-enums!") - unless ($with_val == 0); + if (defined($enum->{ELEMENTS})) { + foreach my $e (@{$enum->{ELEMENTS}}) { + my $t = "$e"; + my $name; + my $value; + if ($t =~ /(.*)=(.*)/) { + $name = $1; + $value = $2; + $with_val = 1; + die ("you can't mix enum member with values and without values!") + unless ($without_val == 0); + } else { + $name = $t; + $value = $count++; + $without_val = 1; + die ("you can't mix enum member with values and without values!") + unless ($with_val == 0); + } + pidl "#define $name ( $value )\n"; } - pidl "#define $name ( $value )\n"; } pidl "#endif\n"; } @@ -166,6 +170,8 @@ sub HeaderBitmap($$) { my($bitmap,$name) = @_; + return unless defined($bitmap->{ELEMENTS}); + pidl "/* bitmap $name */\n"; pidl "#define $_\n" foreach (@{$bitmap->{ELEMENTS}}); pidl "\n"; @@ -217,30 +223,13 @@ sub HeaderType($$$) pidl mapTypeName($e->{TYPE}); } } -sub HeaderTypeNew($$$) -{ - my($e,$data,$name) = @_; - if (ref($data) eq "HASH") { - ($data->{TYPE} eq "ENUM") && HeaderEnum($data->{ORIGINAL}, $name); - ($data->{TYPE} eq "BITMAP") && HeaderBitmap($data->{ORIGINAL}, $name); - ($data->{TYPE} eq "STRUCT") && HeaderStruct($data->{ORIGINAL}, $name); - ($data->{TYPE} eq "UNION") && HeaderUnion($data->{ORIGINAL}, $name); - return; - } - - if (has_property($e, "charset")) { - pidl "const char"; - } else { - pidl mapTypeName($e->{TYPE}); - } -} ##################################################################### # parse a typedef sub HeaderTypedef($) { my($typedef) = shift; - HeaderTypeNew($typedef, $typedef->{DATA}, $typedef->{NAME}); + HeaderType($typedef, $typedef->{DATA}, $typedef->{NAME}); } ##################################################################### @@ -274,7 +263,7 @@ sub HeaderFunctionInOut($$) return unless defined($fn->{ELEMENTS}); foreach my $e (@{$fn->{ELEMENTS}}) { - HeaderElement($e->{ORIGINAL}) if (ElementDirection($e) eq $prop); + HeaderElement($e) if (ElementDirection($e) eq $prop); } } @@ -372,21 +361,21 @@ sub HeaderInterface($) pidl "#ifndef _HEADER_$interface->{NAME}\n"; pidl "#define _HEADER_$interface->{NAME}\n\n"; - foreach my $d (@{$interface->{CONSTS}}) { - HeaderConst($d); + foreach my $c (@{$interface->{CONSTS}}) { + HeaderConst($c); } - foreach my $d (@{$interface->{TYPES}}) { - HeaderTypedef($d) if ($d->{TYPE} eq "TYPEDEF"); - HeaderStruct($d->{ORIGINAL}, $d->{NAME}) if ($d->{TYPE} eq "STRUCT"); - HeaderUnion($d->{ORIGINAL}, $d->{NAME}) if ($d->{TYPE} eq "UNION"); - HeaderEnum($d->{ORIGINAL}, $d->{NAME}) if ($d->{TYPE} eq "ENUM"); - HeaderBitmap($d->{ORIGINAL}, $d->{NAME}) if ($d->{TYPE} eq "BITMAP"); - pidl ";\n\n" if ($d->{TYPE} eq "BITMAP" or - $d->{TYPE} eq "STRUCT" or - $d->{TYPE} eq "TYPEDEF" or - $d->{TYPE} eq "UNION" or - $d->{TYPE} eq "ENUM"); + foreach my $t (@{$interface->{TYPES}}) { + HeaderTypedef($t) if ($t->{TYPE} eq "TYPEDEF"); + HeaderStruct($t, $t->{NAME}) if ($t->{TYPE} eq "STRUCT"); + HeaderUnion($t, $t->{NAME}) if ($t->{TYPE} eq "UNION"); + HeaderEnum($t, $t->{NAME}) if ($t->{TYPE} eq "ENUM"); + HeaderBitmap($t, $t->{NAME}) if ($t->{TYPE} eq "BITMAP"); + pidl ";\n\n" if ($t->{TYPE} eq "BITMAP" or + $t->{TYPE} eq "STRUCT" or + $t->{TYPE} eq "TYPEDEF" or + $t->{TYPE} eq "UNION" or + $t->{TYPE} eq "ENUM"); } foreach my $fn (@{$interface->{FUNCTIONS}}) { -- cgit From 60501f20a72c3c9739184f768899a0132eb765d9 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Fri, 17 Aug 2007 11:24:25 +0000 Subject: r24515: use fatal() wrapper instead of die() directly metze (This used to be commit d90a0d3ba1ac18caee08ab3f621b742229a41e45) --- source4/pidl/lib/Parse/Pidl/Samba4/Header.pm | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'source4/pidl/lib/Parse/Pidl/Samba4/Header.pm') diff --git a/source4/pidl/lib/Parse/Pidl/Samba4/Header.pm b/source4/pidl/lib/Parse/Pidl/Samba4/Header.pm index bcf3693573..52263e848a 100644 --- a/source4/pidl/lib/Parse/Pidl/Samba4/Header.pm +++ b/source4/pidl/lib/Parse/Pidl/Samba4/Header.pm @@ -7,6 +7,7 @@ package Parse::Pidl::Samba4::Header; use strict; +use Parse::Pidl qw(fatal); use Parse::Pidl::Typelist qw(mapTypeName scalar_is_reference); use Parse::Pidl::Util qw(has_property is_constant); use Parse::Pidl::Samba4 qw(is_intree); @@ -149,13 +150,13 @@ sub HeaderEnum($$) $name = $1; $value = $2; $with_val = 1; - die ("you can't mix enum member with values and without values!") + fatal($e->{ORIGINAL}, "you can't mix enum member with values and without values!") unless ($without_val == 0); } else { $name = $t; $value = $count++; $without_val = 1; - die ("you can't mix enum member with values and without values!") + fatal($e->{ORIGINAL}, "you can't mix enum member with values and without values!") unless ($with_val == 0); } pidl "#define $name ( $value )\n"; -- cgit From 70b525a546da5deb8dbc2eff8c5334f9ec57497a Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Fri, 17 Aug 2007 12:04:41 +0000 Subject: r24516: don't use ->{ORIGINAL} metze (This used to be commit 98d8753d37e5ac6273316c83bf6f0e6851afd30a) --- source4/pidl/lib/Parse/Pidl/Samba4/Header.pm | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) (limited to 'source4/pidl/lib/Parse/Pidl/Samba4/Header.pm') diff --git a/source4/pidl/lib/Parse/Pidl/Samba4/Header.pm b/source4/pidl/lib/Parse/Pidl/Samba4/Header.pm index 52263e848a..f03f7c0c43 100644 --- a/source4/pidl/lib/Parse/Pidl/Samba4/Header.pm +++ b/source4/pidl/lib/Parse/Pidl/Samba4/Header.pm @@ -10,6 +10,7 @@ use strict; use Parse::Pidl qw(fatal); use Parse::Pidl::Typelist qw(mapTypeName scalar_is_reference); use Parse::Pidl::Util qw(has_property is_constant); +use Parse::Pidl::NDR qw(GetPrevLevel); use Parse::Pidl::Samba4 qw(is_intree); use vars qw($VERSION); @@ -64,23 +65,30 @@ sub HeaderElement($) HeaderType($element, $element->{TYPE}, ""); } pidl " "; - my $numstar = $element->{ORIGINAL}->{POINTERS}; + my $numstar = 0; + foreach my $l (@{$element->{LEVELS}}) { + next unless ($l->{TYPE} eq "POINTER"); + $numstar++; + } if ($numstar >= 1) { $numstar-- if (scalar_is_reference($element->{TYPE})); } - foreach (@{$element->{ORIGINAL}->{ARRAY_LEN}}) - { - next if is_constant($_) and + foreach my $l (@{$element->{LEVELS}}) { + next unless ($l->{TYPE} eq "ARRAY"); + next if ($l->{IS_FIXED}) and not has_property($element, "charset"); + my $pl = GetPrevLevel($element, $l); + next if (defined($pl) and $pl->{TYPE} eq "POINTER"); $numstar++; } pidl "*" foreach (1..$numstar); } pidl $element->{NAME}; - foreach (@{$element->{ORIGINAL}->{ARRAY_LEN}}) { - next unless (is_constant($_) and + foreach my $l (@{$element->{LEVELS}}) { + next unless ($l->{TYPE} eq "ARRAY"); + next unless ($l->{IS_FIXED} and not has_property($element, "charset")); - pidl "[$_]"; + pidl "[$l->{SIZE_IS}]"; } pidl ";"; -- cgit From a9531c0e23b622cb96c6c4a61a0df43d12a3cee8 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Fri, 17 Aug 2007 12:55:47 +0000 Subject: r24517: move skipping pointer before an array logic into the pointer loop as we do in other places metze (This used to be commit ee92d47b538e2f92e4c342893f04c598311e1021) --- source4/pidl/lib/Parse/Pidl/Samba4/Header.pm | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'source4/pidl/lib/Parse/Pidl/Samba4/Header.pm') diff --git a/source4/pidl/lib/Parse/Pidl/Samba4/Header.pm b/source4/pidl/lib/Parse/Pidl/Samba4/Header.pm index f03f7c0c43..9d8b521a49 100644 --- a/source4/pidl/lib/Parse/Pidl/Samba4/Header.pm +++ b/source4/pidl/lib/Parse/Pidl/Samba4/Header.pm @@ -10,7 +10,7 @@ use strict; use Parse::Pidl qw(fatal); use Parse::Pidl::Typelist qw(mapTypeName scalar_is_reference); use Parse::Pidl::Util qw(has_property is_constant); -use Parse::Pidl::NDR qw(GetPrevLevel); +use Parse::Pidl::NDR qw(GetNextLevel); use Parse::Pidl::Samba4 qw(is_intree); use vars qw($VERSION); @@ -68,6 +68,10 @@ sub HeaderElement($) my $numstar = 0; foreach my $l (@{$element->{LEVELS}}) { next unless ($l->{TYPE} eq "POINTER"); + + my $nl = GetNextLevel($element, $l); + next if (defined($nl) and $nl->{TYPE} eq "ARRAY"); + $numstar++; } if ($numstar >= 1) { @@ -77,8 +81,6 @@ sub HeaderElement($) next unless ($l->{TYPE} eq "ARRAY"); next if ($l->{IS_FIXED}) and not has_property($element, "charset"); - my $pl = GetPrevLevel($element, $l); - next if (defined($pl) and $pl->{TYPE} eq "POINTER"); $numstar++; } pidl "*" foreach (1..$numstar); -- cgit From 95d4e550bd66cefe19396387ad52fb3cec5d0b64 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Fri, 17 Aug 2007 13:08:00 +0000 Subject: r24520: make use of the new ElementStars() and ArrayBrackets() functions metze (This used to be commit fad5af2f2069993b7284e74a177b78a4b4798383) --- source4/pidl/lib/Parse/Pidl/Samba4/Header.pm | 31 +++------------------------- 1 file changed, 3 insertions(+), 28 deletions(-) (limited to 'source4/pidl/lib/Parse/Pidl/Samba4/Header.pm') diff --git a/source4/pidl/lib/Parse/Pidl/Samba4/Header.pm b/source4/pidl/lib/Parse/Pidl/Samba4/Header.pm index 9d8b521a49..7deb3ca331 100644 --- a/source4/pidl/lib/Parse/Pidl/Samba4/Header.pm +++ b/source4/pidl/lib/Parse/Pidl/Samba4/Header.pm @@ -10,8 +10,7 @@ use strict; use Parse::Pidl qw(fatal); use Parse::Pidl::Typelist qw(mapTypeName scalar_is_reference); use Parse::Pidl::Util qw(has_property is_constant); -use Parse::Pidl::NDR qw(GetNextLevel); -use Parse::Pidl::Samba4 qw(is_intree); +use Parse::Pidl::Samba4 qw(is_intree ElementStars ArrayBrackets); use vars qw($VERSION); $VERSION = '0.01'; @@ -64,34 +63,10 @@ sub HeaderElement($) } else { HeaderType($element, $element->{TYPE}, ""); } - pidl " "; - my $numstar = 0; - foreach my $l (@{$element->{LEVELS}}) { - next unless ($l->{TYPE} eq "POINTER"); - - my $nl = GetNextLevel($element, $l); - next if (defined($nl) and $nl->{TYPE} eq "ARRAY"); - - $numstar++; - } - if ($numstar >= 1) { - $numstar-- if (scalar_is_reference($element->{TYPE})); - } - foreach my $l (@{$element->{LEVELS}}) { - next unless ($l->{TYPE} eq "ARRAY"); - next if ($l->{IS_FIXED}) and - not has_property($element, "charset"); - $numstar++; - } - pidl "*" foreach (1..$numstar); + pidl " ".ElementStars($element); } pidl $element->{NAME}; - foreach my $l (@{$element->{LEVELS}}) { - next unless ($l->{TYPE} eq "ARRAY"); - next unless ($l->{IS_FIXED} and - not has_property($element, "charset")); - pidl "[$l->{SIZE_IS}]"; - } + pidl ArrayBrackets($element); pidl ";"; if (defined $element->{PROPERTIES}) { -- cgit From 09c188e7353a74d05a674935c85e548bd09073ae Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Thu, 30 Aug 2007 22:25:59 +0000 Subject: r24812: Fix headers for external users. (This used to be commit ff6684adfd96b59381dd941e54070ab9f8984912) --- source4/pidl/lib/Parse/Pidl/Samba4/Header.pm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/pidl/lib/Parse/Pidl/Samba4/Header.pm') diff --git a/source4/pidl/lib/Parse/Pidl/Samba4/Header.pm b/source4/pidl/lib/Parse/Pidl/Samba4/Header.pm index 7deb3ca331..31145e9fb3 100644 --- a/source4/pidl/lib/Parse/Pidl/Samba4/Header.pm +++ b/source4/pidl/lib/Parse/Pidl/Samba4/Header.pm @@ -382,7 +382,7 @@ sub Parse($) %headerstructs = (); pidl "/* header auto-generated by pidl */\n\n"; if (!is_intree()) { - pidl "#include \n"; + pidl "#include \n"; } pidl "#include \n"; pidl "\n"; -- cgit From 7acc0e77a6f6d74d1ccfcf04424a63b224b292a5 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Fri, 31 Aug 2007 00:03:54 +0000 Subject: r24815: Support cpp_quote(). (This used to be commit 30c1de30bb4ded16e79316c0ab43809e0e19f75d) --- source4/pidl/lib/Parse/Pidl/Samba4/Header.pm | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'source4/pidl/lib/Parse/Pidl/Samba4/Header.pm') diff --git a/source4/pidl/lib/Parse/Pidl/Samba4/Header.pm b/source4/pidl/lib/Parse/Pidl/Samba4/Header.pm index 31145e9fb3..40fb1d3579 100644 --- a/source4/pidl/lib/Parse/Pidl/Samba4/Header.pm +++ b/source4/pidl/lib/Parse/Pidl/Samba4/Header.pm @@ -371,6 +371,13 @@ sub HeaderInterface($) pidl "#endif /* _HEADER_$interface->{NAME} */\n"; } +sub HeaderQuote($) +{ + my($quote) = shift; + + pidl $quote->{DATA}; +} + ##################################################################### # parse a parsed IDL into a C header sub Parse($) @@ -388,6 +395,7 @@ sub Parse($) pidl "\n"; foreach (@{$ndr}) { + ($_->{TYPE} eq "CPP_QUOTE") && HeaderQuote($_); ($_->{TYPE} eq "INTERFACE") && HeaderInterface($_); ($_->{TYPE} eq "IMPORT") && HeaderImport(@{$_->{PATHS}}); ($_->{TYPE} eq "INCLUDE") && HeaderInclude(@{$_->{PATHS}}); -- cgit From 8d182d881d189e9855165b3a423f2d545a97fae8 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Fri, 31 Aug 2007 00:31:32 +0000 Subject: r24816: Move the rest of the contents of core.h to more appropriate places. include/ now only contains build system related headers, all other headers are now near the source code they're related to. (This used to be commit 6890a01dbfc6d8041a88ef5c6be52dfcd046fe80) --- source4/pidl/lib/Parse/Pidl/Samba4/Header.pm | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source4/pidl/lib/Parse/Pidl/Samba4/Header.pm') diff --git a/source4/pidl/lib/Parse/Pidl/Samba4/Header.pm b/source4/pidl/lib/Parse/Pidl/Samba4/Header.pm index 40fb1d3579..75d4c235cb 100644 --- a/source4/pidl/lib/Parse/Pidl/Samba4/Header.pm +++ b/source4/pidl/lib/Parse/Pidl/Samba4/Header.pm @@ -9,7 +9,7 @@ package Parse::Pidl::Samba4::Header; use strict; use Parse::Pidl qw(fatal); use Parse::Pidl::Typelist qw(mapTypeName scalar_is_reference); -use Parse::Pidl::Util qw(has_property is_constant); +use Parse::Pidl::Util qw(has_property is_constant unmake_str); use Parse::Pidl::Samba4 qw(is_intree ElementStars ArrayBrackets); use vars qw($VERSION); @@ -375,7 +375,7 @@ sub HeaderQuote($) { my($quote) = shift; - pidl $quote->{DATA}; + pidl unmake_str($quote->{DATA}) . "\n"; } ##################################################################### -- cgit From cc17260f5d1fe5f0f3b46514f6e53f2aebd352ab Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Fri, 14 Sep 2007 18:26:23 +0000 Subject: r25168: Fix include for gen_ndr/misc.h. Patch by Julien Kerihuel. (This used to be commit 160c0013dc02165ed1787291937b641b6cef5a2b) --- source4/pidl/lib/Parse/Pidl/Samba4/Header.pm | 1 + 1 file changed, 1 insertion(+) (limited to 'source4/pidl/lib/Parse/Pidl/Samba4/Header.pm') diff --git a/source4/pidl/lib/Parse/Pidl/Samba4/Header.pm b/source4/pidl/lib/Parse/Pidl/Samba4/Header.pm index 75d4c235cb..071bec297c 100644 --- a/source4/pidl/lib/Parse/Pidl/Samba4/Header.pm +++ b/source4/pidl/lib/Parse/Pidl/Samba4/Header.pm @@ -390,6 +390,7 @@ sub Parse($) pidl "/* header auto-generated by pidl */\n\n"; if (!is_intree()) { pidl "#include \n"; + pidl "#include \n"; } pidl "#include \n"; pidl "\n"; -- cgit From 9b009c900987517359485799be8be4167494b376 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Sun, 23 Sep 2007 21:35:03 +0000 Subject: r25301: Merge my includes.h cleanups. (This used to be commit 37425495f392a2d0122a93aa2c42758eab7dab5a) --- source4/pidl/lib/Parse/Pidl/Samba4/Header.pm | 1 - 1 file changed, 1 deletion(-) (limited to 'source4/pidl/lib/Parse/Pidl/Samba4/Header.pm') diff --git a/source4/pidl/lib/Parse/Pidl/Samba4/Header.pm b/source4/pidl/lib/Parse/Pidl/Samba4/Header.pm index 071bec297c..75d4c235cb 100644 --- a/source4/pidl/lib/Parse/Pidl/Samba4/Header.pm +++ b/source4/pidl/lib/Parse/Pidl/Samba4/Header.pm @@ -390,7 +390,6 @@ sub Parse($) pidl "/* header auto-generated by pidl */\n\n"; if (!is_intree()) { pidl "#include \n"; - pidl "#include \n"; } pidl "#include \n"; pidl "\n"; -- cgit From fd6288c584085663d16c8dad8eade4b33608ae93 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Tue, 2 Oct 2007 04:45:25 +0000 Subject: r25457: use different location for out-of-tree builds (This used to be commit aa089378a04f84c507a7c31f96499a88de963d06) --- source4/pidl/lib/Parse/Pidl/Samba4/Header.pm | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source4/pidl/lib/Parse/Pidl/Samba4/Header.pm') diff --git a/source4/pidl/lib/Parse/Pidl/Samba4/Header.pm b/source4/pidl/lib/Parse/Pidl/Samba4/Header.pm index 75d4c235cb..7a6ffa46d6 100644 --- a/source4/pidl/lib/Parse/Pidl/Samba4/Header.pm +++ b/source4/pidl/lib/Parse/Pidl/Samba4/Header.pm @@ -10,7 +10,7 @@ use strict; use Parse::Pidl qw(fatal); use Parse::Pidl::Typelist qw(mapTypeName scalar_is_reference); use Parse::Pidl::Util qw(has_property is_constant unmake_str); -use Parse::Pidl::Samba4 qw(is_intree ElementStars ArrayBrackets); +use Parse::Pidl::Samba4 qw(is_intree ElementStars ArrayBrackets choose_header); use vars qw($VERSION); $VERSION = '0.01'; @@ -326,7 +326,7 @@ sub HeaderImport foreach (@imports) { s/\.idl\"$//; s/^\"//; - pidl "#include \"librpc/gen_ndr/$_\.h\"\n"; + pidl choose_header("librpc/gen_ndr/$_\.h", "gen_ndr/$_.h") . "\n"; } } -- cgit From 90198fa7ca83b41516ac5bea014ae0396a1d128f Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Sat, 12 Jan 2008 22:35:28 +0100 Subject: pidl: Prevent empty declarations for enums without body. (This used to be commit c1e0570506d7c77112065a03a876cda4e4db7769) --- source4/pidl/lib/Parse/Pidl/Samba4/Header.pm | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) (limited to 'source4/pidl/lib/Parse/Pidl/Samba4/Header.pm') diff --git a/source4/pidl/lib/Parse/Pidl/Samba4/Header.pm b/source4/pidl/lib/Parse/Pidl/Samba4/Header.pm index 7a6ffa46d6..9e27719d51 100644 --- a/source4/pidl/lib/Parse/Pidl/Samba4/Header.pm +++ b/source4/pidl/lib/Parse/Pidl/Samba4/Header.pm @@ -108,25 +108,28 @@ sub HeaderEnum($$) my $first = 1; pidl "#ifndef USE_UINT_ENUMS\n"; - pidl "enum $name {\n"; - $tab_depth++; + pidl "enum $name"; if (defined($enum->{ELEMENTS})) { + pidl " {\n"; + $tab_depth++; foreach my $e (@{$enum->{ELEMENTS}}) { unless ($first) { pidl ",\n"; } $first = 0; pidl tabs(); pidl $e; } + pidl "\n"; + $tab_depth--; + pidl "}"; } pidl "\n"; - $tab_depth--; - pidl "}\n"; pidl "#else\n"; my $count = 0; - pidl "enum $name { __donnot_use_enum_$name=0x7FFFFFFF}\n"; + pidl "enum $name"; my $with_val = 0; my $without_val = 0; if (defined($enum->{ELEMENTS})) { + pidl " { __donnot_use_enum_$name=0x7FFFFFFF}"; foreach my $e (@{$enum->{ELEMENTS}}) { my $t = "$e"; my $name; @@ -144,9 +147,10 @@ sub HeaderEnum($$) fatal($e->{ORIGINAL}, "you can't mix enum member with values and without values!") unless ($with_val == 0); } - pidl "#define $name ( $value )\n"; + pidl "\n#define $name ( $value )"; } } + pidl "\n"; pidl "#endif\n"; } @@ -215,7 +219,7 @@ sub HeaderType($$$) sub HeaderTypedef($) { my($typedef) = shift; - HeaderType($typedef, $typedef->{DATA}, $typedef->{NAME}); + HeaderType($typedef, $typedef->{DATA}, $typedef->{NAME}) if defined ($typedef->{DATA}); } ##################################################################### -- cgit From 532154af9bebbdf76b2f62ee2b0810e66bc431c7 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Sat, 12 Jan 2008 23:06:00 +0100 Subject: pidl: Move more stuff outside ifdef when defining enums and generate pretty code for enums without body. (This used to be commit d91af936ae51e33c8598d88c77575abbeb0e556b) --- source4/pidl/lib/Parse/Pidl/Samba4/Header.pm | 56 ++++++++++++++-------------- 1 file changed, 27 insertions(+), 29 deletions(-) (limited to 'source4/pidl/lib/Parse/Pidl/Samba4/Header.pm') diff --git a/source4/pidl/lib/Parse/Pidl/Samba4/Header.pm b/source4/pidl/lib/Parse/Pidl/Samba4/Header.pm index 9e27719d51..b96a58783c 100644 --- a/source4/pidl/lib/Parse/Pidl/Samba4/Header.pm +++ b/source4/pidl/lib/Parse/Pidl/Samba4/Header.pm @@ -107,9 +107,9 @@ sub HeaderEnum($$) my($enum,$name) = @_; my $first = 1; - pidl "#ifndef USE_UINT_ENUMS\n"; pidl "enum $name"; if (defined($enum->{ELEMENTS})) { + pidl "\n#ifndef USE_UINT_ENUMS\n"; pidl " {\n"; $tab_depth++; foreach my $e (@{$enum->{ELEMENTS}}) { @@ -121,37 +121,35 @@ sub HeaderEnum($$) pidl "\n"; $tab_depth--; pidl "}"; - } - pidl "\n"; - pidl "#else\n"; - my $count = 0; - pidl "enum $name"; - my $with_val = 0; - my $without_val = 0; - if (defined($enum->{ELEMENTS})) { - pidl " { __donnot_use_enum_$name=0x7FFFFFFF}"; - foreach my $e (@{$enum->{ELEMENTS}}) { - my $t = "$e"; - my $name; - my $value; - if ($t =~ /(.*)=(.*)/) { - $name = $1; - $value = $2; - $with_val = 1; - fatal($e->{ORIGINAL}, "you can't mix enum member with values and without values!") - unless ($without_val == 0); - } else { - $name = $t; - $value = $count++; - $without_val = 1; - fatal($e->{ORIGINAL}, "you can't mix enum member with values and without values!") - unless ($with_val == 0); + pidl "\n"; + pidl "#else\n"; + my $count = 0; + my $with_val = 0; + my $without_val = 0; + if (defined($enum->{ELEMENTS})) { + pidl " { __donnot_use_enum_$name=0x7FFFFFFF}\n"; + foreach my $e (@{$enum->{ELEMENTS}}) { + my $t = "$e"; + my $name; + my $value; + if ($t =~ /(.*)=(.*)/) { + $name = $1; + $value = $2; + $with_val = 1; + fatal($e->{ORIGINAL}, "you can't mix enum member with values and without values!") + unless ($without_val == 0); + } else { + $name = $t; + $value = $count++; + $without_val = 1; + fatal($e->{ORIGINAL}, "you can't mix enum member with values and without values!") + unless ($with_val == 0); + } + pidl "#define $name ( $value )\n"; } - pidl "\n#define $name ( $value )"; } + pidl "#endif\n"; } - pidl "\n"; - pidl "#endif\n"; } ##################################################################### -- cgit From a99dff8660ca2d168523b7264d9208a8a12ca5cc Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Sun, 13 Jan 2008 18:15:12 +0100 Subject: pidl: Move Generate*Env functions to Parse::Pidl::Samba4::Header because they only work with the structures generated by that file. (This used to be commit 9aeb7f31b0fc3b9679e5af07e65e79bc8073c4e1) --- source4/pidl/lib/Parse/Pidl/Samba4/Header.pm | 71 +++++++++++++++++++++++++++- 1 file changed, 70 insertions(+), 1 deletion(-) (limited to 'source4/pidl/lib/Parse/Pidl/Samba4/Header.pm') diff --git a/source4/pidl/lib/Parse/Pidl/Samba4/Header.pm b/source4/pidl/lib/Parse/Pidl/Samba4/Header.pm index b96a58783c..06e9ec4b9f 100644 --- a/source4/pidl/lib/Parse/Pidl/Samba4/Header.pm +++ b/source4/pidl/lib/Parse/Pidl/Samba4/Header.pm @@ -6,10 +6,15 @@ package Parse::Pidl::Samba4::Header; +require Exporter; + +@ISA = qw(Exporter); +@EXPORT_OK = qw(GenerateFunctionInEnv GenerateFunctionOutEnv EnvSubstituteValue GenerateStructEnv); + use strict; use Parse::Pidl qw(fatal); use Parse::Pidl::Typelist qw(mapTypeName scalar_is_reference); -use Parse::Pidl::Util qw(has_property is_constant unmake_str); +use Parse::Pidl::Util qw(has_property is_constant unmake_str ParseExpr); use Parse::Pidl::Samba4 qw(is_intree ElementStars ArrayBrackets choose_header); use vars qw($VERSION); @@ -406,4 +411,68 @@ sub Parse($) return $res; } +sub GenerateStructEnv($$) +{ + my ($x, $v) = @_; + my %env; + + foreach my $e (@{$x->{ELEMENTS}}) { + $env{$e->{NAME}} = "$v->$e->{NAME}"; + } + + $env{"this"} = $v; + + return \%env; +} + +sub EnvSubstituteValue($$) +{ + my ($env,$s) = @_; + + # Substitute the value() values in the env + foreach my $e (@{$s->{ELEMENTS}}) { + next unless (defined(my $v = has_property($e, "value"))); + + $env->{$e->{NAME}} = ParseExpr($v, $env, $e); + } + + return $env; +} + +sub GenerateFunctionInEnv($;$) +{ + my ($fn, $base) = @_; + my %env; + + $base = "r->" unless defined($base); + + foreach my $e (@{$fn->{ELEMENTS}}) { + if (grep (/in/, @{$e->{DIRECTION}})) { + $env{$e->{NAME}} = $base."in.$e->{NAME}"; + } + } + + return \%env; +} + +sub GenerateFunctionOutEnv($;$) +{ + my ($fn, $base) = @_; + my %env; + + $base = "r->" unless defined($base); + + foreach my $e (@{$fn->{ELEMENTS}}) { + if (grep (/out/, @{$e->{DIRECTION}})) { + $env{$e->{NAME}} = $base."out.$e->{NAME}"; + } elsif (grep (/in/, @{$e->{DIRECTION}})) { + $env{$e->{NAME}} = $base."in.$e->{NAME}"; + } + } + + return \%env; +} + + + 1; -- cgit From 5d60cb6ef1c63ce771ab44b6831147568061aa50 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Mon, 14 Jan 2008 01:30:44 +0100 Subject: pidl/python: Fix parsing arguments, fix more pointer issues. (This used to be commit b00c1a072457e5083ffc24a8b74b3793d0b44eee) --- source4/pidl/lib/Parse/Pidl/Samba4/Header.pm | 2 -- 1 file changed, 2 deletions(-) (limited to 'source4/pidl/lib/Parse/Pidl/Samba4/Header.pm') diff --git a/source4/pidl/lib/Parse/Pidl/Samba4/Header.pm b/source4/pidl/lib/Parse/Pidl/Samba4/Header.pm index 06e9ec4b9f..2b3a9df80f 100644 --- a/source4/pidl/lib/Parse/Pidl/Samba4/Header.pm +++ b/source4/pidl/lib/Parse/Pidl/Samba4/Header.pm @@ -473,6 +473,4 @@ sub GenerateFunctionOutEnv($;$) return \%env; } - - 1; -- cgit From 4d656cb5a52bb48fb29b8c546bd33f7a446b0fbf Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Thu, 24 Jan 2008 14:57:30 +0100 Subject: pidl/Samba4::Header: we don't need to check if (defined($enum->{ELEMENTS})) twice metze (This used to be commit c1ac13ee12d6d7e41b3700f207c9a8811bb05cd4) --- source4/pidl/lib/Parse/Pidl/Samba4/Header.pm | 38 +++++++++++++--------------- 1 file changed, 18 insertions(+), 20 deletions(-) (limited to 'source4/pidl/lib/Parse/Pidl/Samba4/Header.pm') diff --git a/source4/pidl/lib/Parse/Pidl/Samba4/Header.pm b/source4/pidl/lib/Parse/Pidl/Samba4/Header.pm index 2b3a9df80f..b2d5126d1d 100644 --- a/source4/pidl/lib/Parse/Pidl/Samba4/Header.pm +++ b/source4/pidl/lib/Parse/Pidl/Samba4/Header.pm @@ -131,27 +131,25 @@ sub HeaderEnum($$) my $count = 0; my $with_val = 0; my $without_val = 0; - if (defined($enum->{ELEMENTS})) { - pidl " { __donnot_use_enum_$name=0x7FFFFFFF}\n"; - foreach my $e (@{$enum->{ELEMENTS}}) { - my $t = "$e"; - my $name; - my $value; - if ($t =~ /(.*)=(.*)/) { - $name = $1; - $value = $2; - $with_val = 1; - fatal($e->{ORIGINAL}, "you can't mix enum member with values and without values!") - unless ($without_val == 0); - } else { - $name = $t; - $value = $count++; - $without_val = 1; - fatal($e->{ORIGINAL}, "you can't mix enum member with values and without values!") - unless ($with_val == 0); - } - pidl "#define $name ( $value )\n"; + pidl " { __donnot_use_enum_$name=0x7FFFFFFF}\n"; + foreach my $e (@{$enum->{ELEMENTS}}) { + my $t = "$e"; + my $name; + my $value; + if ($t =~ /(.*)=(.*)/) { + $name = $1; + $value = $2; + $with_val = 1; + fatal($e->{ORIGINAL}, "you can't mix enum member with values and without values!") + unless ($without_val == 0); + } else { + $name = $t; + $value = $count++; + $without_val = 1; + fatal($e->{ORIGINAL}, "you can't mix enum member with values and without values!") + unless ($with_val == 0); } + pidl "#define $name ( $value )\n"; } pidl "#endif\n"; } -- cgit From 43040be5b9c959c2f9c305eec9d66c103edc14af Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Thu, 24 Jan 2008 15:04:58 +0100 Subject: pidl: get rid of stupid ';' char to terminate bitmap defines metze (This used to be commit dd77fc45eee2dde7bdd31a2e39387e94cec158aa) --- source4/pidl/lib/Parse/Pidl/Samba4/Header.pm | 45 ++++++++++++++-------------- 1 file changed, 22 insertions(+), 23 deletions(-) (limited to 'source4/pidl/lib/Parse/Pidl/Samba4/Header.pm') diff --git a/source4/pidl/lib/Parse/Pidl/Samba4/Header.pm b/source4/pidl/lib/Parse/Pidl/Samba4/Header.pm index b2d5126d1d..14f472340c 100644 --- a/source4/pidl/lib/Parse/Pidl/Samba4/Header.pm +++ b/source4/pidl/lib/Parse/Pidl/Samba4/Header.pm @@ -82,9 +82,9 @@ sub HeaderElement($) ##################################################################### # parse a struct -sub HeaderStruct($$) +sub HeaderStruct($$;$) { - my($struct,$name) = @_; + my($struct,$name,$tail) = @_; pidl "struct $name"; return if (not defined($struct->{ELEMENTS})); pidl " {\n"; @@ -103,13 +103,14 @@ sub HeaderStruct($$) if (defined $struct->{PROPERTIES}) { HeaderProperties($struct->{PROPERTIES}, []); } + pidl $tail if defined($tail); } ##################################################################### # parse a enum -sub HeaderEnum($$) +sub HeaderEnum($$;$) { - my($enum,$name) = @_; + my($enum,$name,$tail) = @_; my $first = 1; pidl "enum $name"; @@ -153,6 +154,7 @@ sub HeaderEnum($$) } pidl "#endif\n"; } + pidl $tail if defined($tail); } ##################################################################### @@ -170,9 +172,9 @@ sub HeaderBitmap($$) ##################################################################### # parse a union -sub HeaderUnion($$) +sub HeaderUnion($$;$) { - my($union,$name) = @_; + my($union,$name,$tail) = @_; my %done = (); pidl "union $name"; @@ -193,18 +195,19 @@ sub HeaderUnion($$) if (defined $union->{PROPERTIES}) { HeaderProperties($union->{PROPERTIES}, []); } + pidl $tail if defined($tail); } ##################################################################### # parse a type -sub HeaderType($$$) +sub HeaderType($$$;$) { - my($e,$data,$name) = @_; + my($e,$data,$name,$tail) = @_; if (ref($data) eq "HASH") { - ($data->{TYPE} eq "ENUM") && HeaderEnum($data, $name); + ($data->{TYPE} eq "ENUM") && HeaderEnum($data, $name, $tail); ($data->{TYPE} eq "BITMAP") && HeaderBitmap($data, $name); - ($data->{TYPE} eq "STRUCT") && HeaderStruct($data, $name); - ($data->{TYPE} eq "UNION") && HeaderUnion($data, $name); + ($data->{TYPE} eq "STRUCT") && HeaderStruct($data, $name, $tail); + ($data->{TYPE} eq "UNION") && HeaderUnion($data, $name, $tail); return; } @@ -213,14 +216,15 @@ sub HeaderType($$$) } else { pidl mapTypeName($e->{TYPE}); } + pidl $tail if defined($tail); } ##################################################################### # parse a typedef -sub HeaderTypedef($) +sub HeaderTypedef($;$) { - my($typedef) = shift; - HeaderType($typedef, $typedef->{DATA}, $typedef->{NAME}) if defined ($typedef->{DATA}); + my($typedef,$tail) = @_; + HeaderType($typedef, $typedef->{DATA}, $typedef->{NAME}, $tail) if defined ($typedef->{DATA}); } ##################################################################### @@ -357,16 +361,11 @@ sub HeaderInterface($) } foreach my $t (@{$interface->{TYPES}}) { - HeaderTypedef($t) if ($t->{TYPE} eq "TYPEDEF"); - HeaderStruct($t, $t->{NAME}) if ($t->{TYPE} eq "STRUCT"); - HeaderUnion($t, $t->{NAME}) if ($t->{TYPE} eq "UNION"); - HeaderEnum($t, $t->{NAME}) if ($t->{TYPE} eq "ENUM"); + HeaderTypedef($t, ";\n\n") if ($t->{TYPE} eq "TYPEDEF"); + HeaderStruct($t, $t->{NAME}, ";\n\n") if ($t->{TYPE} eq "STRUCT"); + HeaderUnion($t, $t->{NAME}, ";\n\n") if ($t->{TYPE} eq "UNION"); + HeaderEnum($t, $t->{NAME}, ";\n\n") if ($t->{TYPE} eq "ENUM"); HeaderBitmap($t, $t->{NAME}) if ($t->{TYPE} eq "BITMAP"); - pidl ";\n\n" if ($t->{TYPE} eq "BITMAP" or - $t->{TYPE} eq "STRUCT" or - $t->{TYPE} eq "TYPEDEF" or - $t->{TYPE} eq "UNION" or - $t->{TYPE} eq "ENUM"); } foreach my $fn (@{$interface->{FUNCTIONS}}) { -- cgit From 5d55aa99e6488244208d7d84b188f92306c083f6 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Fri, 25 Jan 2008 10:07:43 +0100 Subject: pidl/Samba4::Header: fix typedefs of unions and structs without elements metze (This used to be commit 3131847cb67dadd8ee6fcbca5055927b8ba8a219) --- source4/pidl/lib/Parse/Pidl/Samba4/Header.pm | 2 ++ 1 file changed, 2 insertions(+) (limited to 'source4/pidl/lib/Parse/Pidl/Samba4/Header.pm') diff --git a/source4/pidl/lib/Parse/Pidl/Samba4/Header.pm b/source4/pidl/lib/Parse/Pidl/Samba4/Header.pm index 14f472340c..2e77ff01b8 100644 --- a/source4/pidl/lib/Parse/Pidl/Samba4/Header.pm +++ b/source4/pidl/lib/Parse/Pidl/Samba4/Header.pm @@ -86,6 +86,7 @@ sub HeaderStruct($$;$) { my($struct,$name,$tail) = @_; pidl "struct $name"; + pidl $tail if defined($tail) and not defined($struct->{ELEMENTS}); return if (not defined($struct->{ELEMENTS})); pidl " {\n"; $tab_depth++; @@ -178,6 +179,7 @@ sub HeaderUnion($$;$) my %done = (); pidl "union $name"; + pidl $tail if defined($tail) and not defined($union->{ELEMENTS}); return if (not defined($union->{ELEMENTS})); pidl " {\n"; $tab_depth++; -- cgit