Mark Dootson wrote:
Mattia Barbon wrote:
Hi
The patch is OK, one tiny nit: could you move the handling of
$load_fun/$unload_fun to the standard loader? This way a custom
loader will have precedence over the callbacks set via
set_load_function/set_end_function.
OK - I'll rework and test with Wx::Perl::Packager - which uses
set_load_function/set_end_function. Changed as you want, a custom loader
should 'break' it - if it overrides - which I guess is the right thing.
I think so; on the long run I'd like to remove the
set_load_function/end_load_function hooks, after all one does not need
two different ways of overriding the loading process.
Unfortunately, this won't work, since on Linux (and I suspect other
unices) you can't know the name of the dynamic object, which is the
reason dynamic loading was disabled for Linux. You are correct that
loading the dynamic object as plugins is required for Wx::Html to work
correctly (and probably Wx::XRC, Wx::RichText and Wx::DocView).
One way around it might be to locally replace
DynaLoader::dl_load_file with a version that loads DLLs as if they
were plugins. I will experiment with that.
It works fine on Linux - I use DynaLoader::dl_load_file in the Linux
PPMS and do a ' for (qw( base core adv) ) - dl_load_file '
So it is just a matter of 'munging' the .so extension on the values in
$Wx::dlls
I load the dlls in the call to Wx::_start() - so that they are loaded
before Wx.so and so that Wx::Perl::SplashFast works too.
I was surprised this worked - but it does.
Of course, because it is a PPM, I do know the extensions of the dlls
because I use a specific .so extension rather than the proper symlinks.
For a PPM this seemed OK.
Sorry, I wasn't clear: I was talking about the standard wxPerl
loader, that doesn't necessarily know the correct extension for its
shared objects.
I just applied the attached patch (only tested on Mac and Linux for
now), and it seems to do the trick without breaking anything.
Regards,
Mattia
Index: Wx.xs
===================================================================
--- Wx.xs (revisione 2769)
+++ Wx.xs (revisione 2770)
@@ -340,8 +340,8 @@
#include <wx/dynload.h>
-bool
-_load_plugin( string )
+IV
+_load_plugin( string, int flags = 0 /* to be compatible with dl_load_file */ )
wxString string
CODE:
#ifdef HACK
@@ -350,7 +350,8 @@
delete new wxMediaCtrl();
#endif
#endif
- RETVAL = wxPluginManager::LoadLibrary( string, wxDL_VERBATIM );
+ wxDynamicLibrary *lib = wxPluginManager::LoadLibrary( string,
wxDL_VERBATIM );
+ RETVAL = PTR2IV( lib->GetLibHandle() );
OUTPUT:
RETVAL
Index: lib/Wx/Mini.pm
===================================================================
--- lib/Wx/Mini.pm (revisione 2769)
+++ lib/Wx/Mini.pm (revisione 2770)
@@ -21,17 +21,21 @@
#
our( $wx_path );
+# see the comment in Wx.xs:_load_plugin for why this is necessary
sub wxPL_STATIC();
sub wx_boot($$) {
local $ENV{PATH} = $wx_path . ';' . $ENV{PATH} if $wx_path;
if( $_[0] eq 'Wx' || !wxPL_STATIC ) {
+ no warnings 'redefine';
if( $] < 5.006 ) {
require DynaLoader;
+ local *DynaLoader::dl_load_file = \&Wx::_load_plugin if $_[0] ne 'Wx';
no strict 'refs';
push @{"$_[0]::ISA"}, 'DynaLoader';
$_[0]->bootstrap( $_[1] );
} else {
require XSLoader;
+ local *DynaLoader::dl_load_file = \&Wx::_load_plugin if $_[0] ne 'Wx';
XSLoader::load( $_[0], $_[1] );
}
} else {