diff options
author | Günther Deschner <gd@samba.org> | 2015-07-22 18:57:57 +0200 |
---|---|---|
committer | Günther Deschner <gd@samba.org> | 2015-07-24 16:44:16 +0200 |
commit | adbd6d32531a339046a2bcf73d3f22ee34d7184b (patch) | |
tree | cb42cce9ac01b3638ba316f2d1ef78757003137c /pidl | |
parent | 3d0b23dbd443381be1f265305ddda5434c0580aa (diff) | |
download | samba-adbd6d32531a339046a2bcf73d3f22ee34d7184b.tar.gz |
pidl: merge multiple 'genpad' implementations into one.
Guenther
Signed-off-by: Günther Deschner <gd@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
Autobuild-User(master): Günther Deschner <gd@samba.org>
Autobuild-Date(master): Fri Jul 24 16:44:16 CEST 2015 on sn-devel-104
Diffstat (limited to 'pidl')
-rw-r--r-- | pidl/lib/Parse/Pidl/Samba3/ClientNDR.pm | 11 | ||||
-rw-r--r-- | pidl/lib/Parse/Pidl/Samba3/Template.pm | 11 | ||||
-rw-r--r-- | pidl/lib/Parse/Pidl/Samba4/NDR/Client.pm | 11 | ||||
-rw-r--r-- | pidl/lib/Parse/Pidl/Samba4/Template.pm | 11 | ||||
-rw-r--r-- | pidl/lib/Parse/Pidl/Util.pm | 16 |
5 files changed, 21 insertions, 39 deletions
diff --git a/pidl/lib/Parse/Pidl/Samba3/ClientNDR.pm b/pidl/lib/Parse/Pidl/Samba3/ClientNDR.pm index aa913f192eb..28d5245af8d 100644 --- a/pidl/lib/Parse/Pidl/Samba3/ClientNDR.pm +++ b/pidl/lib/Parse/Pidl/Samba3/ClientNDR.pm @@ -13,7 +13,7 @@ use Exporter; use strict; use Parse::Pidl qw(fatal warning error); -use Parse::Pidl::Util qw(has_property ParseExpr); +use Parse::Pidl::Util qw(has_property ParseExpr genpad); use Parse::Pidl::NDR qw(ContainsPipe); use Parse::Pidl::Typelist qw(mapTypeName); use Parse::Pidl::Samba4 qw(DeclLong); @@ -28,15 +28,6 @@ sub pidl($$) { my ($self,$txt) = @_; $self->{res} .= $txt ? "$self->{tabs}$txt\n sub pidl_hdr($$) { my ($self, $txt) = @_; $self->{res_hdr} .= "$txt\n"; } sub fn_declare($$) { my ($self,$n) = @_; $self->pidl($n); $self->pidl_hdr("$n;"); } -sub genpad($) -{ - my ($s) = @_; - my $nt = int((length($s)+1)/8); - my $lt = ($nt*8)-1; - my $ns = (length($s)-$lt); - return "\t"x($nt)." "x($ns); -} - sub new($) { my ($class) = shift; diff --git a/pidl/lib/Parse/Pidl/Samba3/Template.pm b/pidl/lib/Parse/Pidl/Samba3/Template.pm index 34969271df6..4750cef00f2 100644 --- a/pidl/lib/Parse/Pidl/Samba3/Template.pm +++ b/pidl/lib/Parse/Pidl/Samba3/Template.pm @@ -8,19 +8,12 @@ package Parse::Pidl::Samba3::Template; use vars qw($VERSION); $VERSION = '0.01'; +use Parse::Pidl::Util qw(genpad); + use strict; my($res); -sub genpad($) -{ - my ($s) = @_; - my $nt = int((length($s)+1)/8); - my $lt = ($nt*8)-1; - my $ns = (length($s)-$lt); - return "\t"x($nt)." "x($ns); -} - ##################################################################### # produce boilerplate code for a interface sub Template($) diff --git a/pidl/lib/Parse/Pidl/Samba4/NDR/Client.pm b/pidl/lib/Parse/Pidl/Samba4/NDR/Client.pm index ee68090ac6c..040cd5a4bd3 100644 --- a/pidl/lib/Parse/Pidl/Samba4/NDR/Client.pm +++ b/pidl/lib/Parse/Pidl/Samba4/NDR/Client.pm @@ -11,7 +11,7 @@ use Exporter; @EXPORT_OK = qw(Parse); use Parse::Pidl qw(fatal warning error); -use Parse::Pidl::Util qw(has_property ParseExpr); +use Parse::Pidl::Util qw(has_property ParseExpr genpad); use Parse::Pidl::NDR qw(ContainsPipe); use Parse::Pidl::Typelist qw(mapTypeName); use Parse::Pidl::Samba4 qw(choose_header is_intree DeclLong); @@ -29,15 +29,6 @@ sub pidl_hdr($$) { my ($self, $txt) = @_; $self->{res_hdr} .= "$txt\n"; } sub pidl_both($$) { my ($self, $txt) = @_; $self->{hdr} .= "$txt\n"; $self->{res_hdr} .= "$txt\n"; } sub fn_declare($$) { my ($self,$n) = @_; $self->pidl($n); $self->pidl_hdr("$n;"); } -sub genpad($) -{ - my ($s) = @_; - my $nt = int((length($s)+1)/8); - my $lt = ($nt*8)-1; - my $ns = (length($s)-$lt); - return "\t"x($nt)." "x($ns); -} - sub new($) { my ($class) = shift; diff --git a/pidl/lib/Parse/Pidl/Samba4/Template.pm b/pidl/lib/Parse/Pidl/Samba4/Template.pm index e79af856919..d9fb3041163 100644 --- a/pidl/lib/Parse/Pidl/Samba4/Template.pm +++ b/pidl/lib/Parse/Pidl/Samba4/Template.pm @@ -8,19 +8,12 @@ package Parse::Pidl::Samba4::Template; use vars qw($VERSION); $VERSION = '0.01'; +use Parse::Pidl::Util qw(genpad); + use strict; my($res); -sub genpad($) -{ - my ($s) = @_; - my $nt = int((length($s)+1)/8); - my $lt = ($nt*8)-1; - my $ns = (length($s)-$lt); - return "\t"x($nt)." "x($ns); -} - ##################################################################### # produce boilerplate code for a interface sub Template($) diff --git a/pidl/lib/Parse/Pidl/Util.pm b/pidl/lib/Parse/Pidl/Util.pm index 421cb8f9dc1..83e23937a87 100644 --- a/pidl/lib/Parse/Pidl/Util.pm +++ b/pidl/lib/Parse/Pidl/Util.pm @@ -6,7 +6,7 @@ package Parse::Pidl::Util; require Exporter; @ISA = qw(Exporter); -@EXPORT = qw(has_property property_matches ParseExpr ParseExprExt is_constant make_str unmake_str print_uuid MyDumper); +@EXPORT = qw(has_property property_matches ParseExpr ParseExprExt is_constant make_str unmake_str print_uuid MyDumper genpad); use vars qw($VERSION); $VERSION = '0.01'; @@ -176,6 +176,20 @@ sub ParseExprExt($$$$$) $deref, $use); } +=item B<genpad> +return an empty string consisting of tabs and spaces suitable for proper indent +of C-functions. + +=cut +sub genpad($) +{ + my ($s) = @_; + my $nt = int((length($s)+1)/8); + my $lt = ($nt*8)-1; + my $ns = (length($s)-$lt); + return "\t"x($nt)." "x($ns); +} + =back =cut |