pidl: merge multiple 'genpad' implementations into one.
authorGünther Deschner <gd@samba.org>
Wed, 22 Jul 2015 16:57:57 +0000 (18:57 +0200)
committerGünther Deschner <gd@samba.org>
Fri, 24 Jul 2015 14:44:16 +0000 (16:44 +0200)
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

pidl/lib/Parse/Pidl/Samba3/ClientNDR.pm
pidl/lib/Parse/Pidl/Samba3/Template.pm
pidl/lib/Parse/Pidl/Samba4/NDR/Client.pm
pidl/lib/Parse/Pidl/Samba4/Template.pm
pidl/lib/Parse/Pidl/Util.pm

index aa913f192eb1c802dfaeefd57a929b5cf676d844..28d5245af8d563d58ce7c126786e5706572a05b3 100644 (file)
@@ -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;
index 34969271df6aa5485d163e48f171ad54b6884fad..4750cef00f2f66c58adfa794a90de709b8e07e9a 100644 (file)
@@ -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($)
index ee68090ac6c791cd45caa017013904572ddc6822..040cd5a4bd337586a15edd9d32488876d755d781 100644 (file)
@@ -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;
index e79af856919dce58f7186d69496a9a0b79c8ea31..d9fb3041163378f2d42c39c1d8cc63b05d5c5ab1 100644 (file)
@@ -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($)
index 421cb8f9dc1279a3b5957d6bb800e114bb356f95..83e23937a87723f89b44d4b85141fbb5acaa9dc9 100644 (file)
@@ -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