
sunnyagarwal008
New User
May 5, 2010, 6:42 AM
Views: 3774
|
Re: [shawnhcorey] Creating wrapper over a wrapper
|
|
|
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.
|