CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Advanced:
Creating wrapper over a wrapper

 



sunnyagarwal008
New User

May 5, 2010, 2:27 AM

Post #1 of 3 (1785 views)
Creating wrapper over a wrapper Can't Post

I have a perl module which is basically just a wrapper over C code and it works fine. Now I am trying to write another wrapper over this perl wrapper. In this, I am exporting all the functions that the original wrapper exports. I am defining all these methods like:

Code
sub  ABC 
{
return wrapper::ABC(@_);
}


When i compile this, i get errors saying that there is a prototype mismatch between the ABC here and wrapper::ABC. Can someone please help me out on this?


(This post was edited by sunnyagarwal008 on May 5, 2010, 2:28 AM)


shawnhcorey
Enthusiast


May 5, 2010, 5:07 AM

Post #2 of 3 (1775 views)
Re: [sunnyagarwal008] Creating wrapper over a wrapper [In reply to] Can't Post

Please show the code for wrapper::ABC.

Note that prototypes should not be used unless you really have to.

__END__

I love Perl; it's the only language where you can bless your thingy.

Perl documentation is available at perldoc.perl.org. The list of standard modules and pragmatics is available in perlmodlib.

Get Markup Help. Please note the markup tag of "code".


sunnyagarwal008
New User

May 5, 2010, 6:42 AM

Post #3 of 3 (1765 views)
Re: [shawnhcorey] Creating wrapper over a wrapper [In reply to] Can't Post

Hi,

As I said, its just a wrapper over C functions, there's not much of code in it (works with Dynaloader and AutoLoader). It works fine if I use this module alone. Here is the code:
<code>
package ABC;

$ABC::VERSION = '0.02';

use strict;
use vars qw($VERSION @ISA @EXPORT @EXPORT_OK);

require Exporter;
require DynaLoader;
require AutoLoader;

@ISA = qw(Exporter AutoLoader DynaLoader);

# Items to export into callers namespace by default.
@EXPORT = qw(
new_time_var
dl_ascii_to_date
dl_ascii_to_time
dl_close_cache
);
@EXPORT_OK = qw();

bootstrap ABC $VERSION;
</code>

and here is the wrapper module:
<code>
package PQR;
use strict;
use vars qw($VERSION @ISA @EXPORT @EXPORT_OK);

require Exporter;
require AutoLoader;
use ABC;

$PQR::VERSION = $ABC::VERSION;

@ISA = qw(Exporter AutoLoader);
@EXPORT = qw(
new_time_var
dl_ascii_to_date
dl_ascii_to_time
dl_close_cache
);

@EXPORT_OK = qw();

sub new_time_var
{
return ABC::new_time_var(@_);
}

sub dl_ascii_to_date
{
return ABC::dl_ascii_to_date(@_);
}

sub dl_ascii_to_time
{
return ABC::dl_ascii_to_time(@_);
}

sub dl_close_cache
{
return ABC::dl_close_cache(@_);
}
</code>

The actual subroutine signatures are:
<code>
<new_time_var>()
<dl_ascii_to_date>(<string>)
<dl_ascii_to_time>(<string>, <dtp>)
<dl_close_cache>(<dcp>)
</code>

When I test this using a script I get the following errors:
<code>
>/u/agarwsun/test> perl -wc test.pl
</code>
Prototype mismatch: sub PQR::new_time_var () vs none at /u/agarwsun/projects/packages/datelib/lib/perl5/5.8.6/i86pc-solaris/PQR.pm line 71.
<br>
Subroutine new_time_var redefined at /u/agarwsun/projects/packages/datelib/lib/perl5/5.8.6/i86pc-solaris/PQR.pm line 67.
<br>
Prototype mismatch: sub PQR::dl_ascii_to_date ($) vs none at /u/agarwsun/projects/packages/datelib/lib/perl5/5.8.6/i86pc-solaris/PQR.pm line 76.
Subroutine dl_ascii_to_date redefined at /u/agarwsun/projects/packages/datelib/lib/perl5/5.8.6/i86pc-solaris/PQR.pm line 74.
<br>
Prototype mismatch: sub PQR::dl_ascii_to_time ($$) vs none at /u/agarwsun/projects/packages/datelib/lib/perl5/5.8.6/i86pc-solaris/PQR.pm line 81.

<br>
If I do not re-export the functions in PQR, and extend from ABC, I don't get the errors related to redefining subroutines, but I still get prototype mismatch errors:
<br>
Prototype mismatch: sub ABC::new_time_var () vs none at /u/agarwsun/projects/packages/datelib/lib/perl5/5.8.6/i86pc-solaris/PQR.pm line 22.
<br>
Prototype mismatch: sub ABC::dl_ascii_to_date ($) vs none at /u/agarwsun/projects/packages/datelib/lib/perl5/5.8.6/i86pc-solaris/PQR.pm line 27.
<br>
Prototype mismatch: sub Deshaw::DateLib::dl_ascii_to_time ($$) vs none at /u/agarwsun/projects/packages/datelib/lib/perl5/5.8.6/i86pc-solaris/PQR.pm line 32.

 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives