texinfo-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[7583] use XSLoader.pm in TestXS.pm


From: gavinsmith0123
Subject: [7583] use XSLoader.pm in TestXS.pm
Date: Tue, 27 Dec 2016 13:03:47 +0000 (UTC)

Revision: 7583
          http://svn.sv.gnu.org/viewvc/?view=rev&root=texinfo&revision=7583
Author:   gavin
Date:     2016-12-27 13:03:46 +0000 (Tue, 27 Dec 2016)
Log Message:
-----------
use XSLoader.pm in TestXS.pm

Modified Paths:
--------------
    trunk/configure.ac
    trunk/tp/Texinfo/Convert/XSParagraph/TestXS.pm

Modified: trunk/configure.ac
===================================================================
--- trunk/configure.ac  2016-12-26 17:48:06 UTC (rev 7582)
+++ trunk/configure.ac  2016-12-27 13:03:46 UTC (rev 7583)
@@ -362,11 +362,11 @@
 # Set xs_srcdir to the path from XSParagraph builddir to srcdir
 case $srcdir in
   .)  # We are building in place.
-    xs_srcdir=. ;;
+    xs_srcdir=../../.. ;;
   [[\\/]]* | ?:[[\\/]]* )  # Absolute name.
-    xs_srcdir=$srcdir/tp/Texinfo/Convert/XSParagraph ;;
+    xs_srcdir=$srcdir/tp ;;
   *) # Relative name.
-    xs_srcdir=../../../../$srcdir/tp/Texinfo/Convert/XSParagraph ;;
+    xs_srcdir=../../../../$srcdir/tp ;;
 esac
 
 # Pass on all the options we were given to the subsidiary configure 
@@ -394,7 +394,7 @@
    && make TestXS.la \
    && ${PERL} -I . \
               -I ${xs_srcdir} \
-              -w ${xs_srcdir}/fail.pl \
+              -w ${xs_srcdir}/Texinfo/Convert/XSParagraph/fail.pl \
       | grep 'message from XS module') \
   && enable_xs=yes
   AC_MSG_CHECKING([whether we can build Perl extension (XS) modules])

Modified: trunk/tp/Texinfo/Convert/XSParagraph/TestXS.pm
===================================================================
--- trunk/tp/Texinfo/Convert/XSParagraph/TestXS.pm      2016-12-26 17:48:06 UTC 
(rev 7582)
+++ trunk/tp/Texinfo/Convert/XSParagraph/TestXS.pm      2016-12-27 13:03:46 UTC 
(rev 7583)
@@ -1,4 +1,4 @@
-# Copyright 2014, 2015 Free Software Foundation, Inc.
+# Copyright 2014, 2015, 2016 Free Software Foundation, Inc.
 #
 # This program is free software; you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
@@ -15,177 +15,20 @@
 
 package Texinfo::Convert::XSParagraph::TestXS;
 
-use DynaLoader;
-
 use 5.00405;
 use strict;
 use warnings;
 
-require Exporter;
-
-our @ISA = qw(Exporter DynaLoader);
-
-# Items to export into callers namespace by default. Note: do not export
-# names by default without a very good reason. Use EXPORT_OK instead.
-# Do not simply export all your public functions/methods/constants.
-
-our %EXPORT_TAGS = ( 'all' => [ qw(
-
-) ] );
-
-our @EXPORT_OK = ( @{ $EXPORT_TAGS{'all'} } );
-
-our @EXPORT = qw(
-       
-);
-
 BEGIN {
-# Possible values for TEXINFO_XS environmental variable:
-#
-# TEXINFO_XS=omit     # don't try loading xs at all
-# TEXINFO_XS=default  # try xs, silent fallback
-# TEXINFO_XS=warn     # try xs, warn on failure
-# TEXINFO_XS=required # abort if not loadable, no fallback
-# TEXINFO_XS=debug    # voluminuous debugging
-#
-# Other values are treated at the moment as 'default'.
+  require Texinfo::XSLoader;
 
-my $TEXINFO_XS = 'debug';
-#my $TEXINFO_XS = $ENV{'TEXINFO_XS'};
-if (!defined($TEXINFO_XS)) {
-  $TEXINFO_XS = '';
+  Texinfo::XSLoader::init (
+    "TestXS",
+    "TestXS",
+    undef,
+    "TestXS",
+    0);
 }
 
-if ($TEXINFO_XS eq 'omit') {
-  # Don't try to use the XS module
-  goto FALLBACK;
-}
-
-# For verbose information about what's being done
-sub _debug($) {
-  if ($TEXINFO_XS eq 'debug') {
-    my $msg = shift;
-    warn $msg . "\n";
-  }
-}
-
-# For messages to say that XS module couldn't be loaded
-sub _fatal($) {
-  if ($TEXINFO_XS eq 'debug'
-      or $TEXINFO_XS eq 'required'
-      or $TEXINFO_XS eq 'warn') {
-    my $msg = shift;
-    warn $msg . "\n";
-  }
-}
-
-# We look for the .la and .so files in @INC because this allows us to override
-# which modules are used using -I flags to "perl".
-sub _find_file($) {
-  my $file = shift;
-  for my $dir (@INC) {
-    _debug "checking $dir/$file";
-    if (-f "$dir/$file") {
-      _debug "found $dir/$file";
-      return ($dir, "$dir/$file");
-    }
-  }
-  return undef;
-}
-
-our $disable_XS;
-if ($disable_XS) {
-  _fatal "use of XS modules was disabled when Texinfo was built";
-  goto FALLBACK;
-}
-
-my ($libtool_dir, $libtool_archive) = _find_file("TestXS.la");
-if (!$libtool_archive) {
-  _fatal "couldn't find Libtool archive file";
-  goto FALLBACK;
-}
-
-my $fh;
-open $fh, $libtool_archive;
-if (!$fh) {
-  _fatal "couldn't open Libtool archive file";
-  goto FALLBACK;
-}
-
-# Look for the line in TestXS.la giving the name of the loadable object.
-my $dlname = undef;
-while (my $line = <$fh>) {
-  if ($line =~ /^\s*dlname\s*=\s*'([^']+)'\s$/) {
-    $dlname = $1;
-    last;
-  }
-}
-if (!$dlname) {
-  _fatal "couldn't find name of shared object";
-  goto FALLBACK;
-}
-
-# The *.so file is under .libs in the source directory.
-push @DynaLoader::dl_library_path, $libtool_dir;
-push @DynaLoader::dl_library_path, "$libtool_dir/.libs";
-
-my $dlpath = DynaLoader::dl_findfile($dlname);
-if (!$dlpath) {
-  _fatal "couldn't find $dlname";
-  goto FALLBACK;
-}
-
-#print STDERR "loadable object is at $dlpath\n";
-
-my $module = "TestXS";
-our $module_version = '0';
-
-my $flags = 0;
-my $libref = DynaLoader::dl_load_file($dlpath, $flags);
-if (!$libref) {
-  _fatal "couldn't load file $dlpath";
-  goto FALLBACK;
-}
-my @undefined_symbols = DynaLoader::dl_undef_symbols();
-if ($#undefined_symbols+1 != 0) {
-  _fatal "still have undefined symbols after dl_load_file";
-}
-my $bootname = "boot_$module";
-$bootname =~ s/:/_/g;
-my $symref = DynaLoader::dl_find_symbol($libref, $bootname);
-if (!$symref) {
-  _fatal "couldn't find boot_$module symbol";
-  goto FALLBACK;
-}
-my $boot_fn = DynaLoader::dl_install_xsub("${module}::bootstrap",
-                                                $symref, $dlname);
-
-if (!$boot_fn) {
-  _fatal "couldn't bootstrap";
-  goto FALLBACK;
-}
-
-push @DynaLoader::dl_shared_objects, $dlpath; # record files loaded
-
-# This is the module bootstrap function, which causes all the other
-# functions (XSUB's) provided by the module to become available to
-# be called from Perl code.
-&$boot_fn($module, $module_version);
-
-if (!TestXS::init ()) {
-  _fatal "error initializing";
-  goto FALLBACK;
-}
-goto DONTFALLBACK;
-
-FALLBACK: ;
-DONTFALLBACK: ;
-} # end BEGIN
-
-
-# Preloaded methods go here.
-
-#########################################################################
-
 1;
 __END__




reply via email to

[Prev in Thread] Current Thread [Next in Thread]