On Mon, Aug 17, 2015 at 12:57:00PM +0100, Gavin Smith wrote: > On 17 August 2015 at 12:48, Patrice Dumas <[email protected]> wrote: > > Ok. Here is an updated patch with a new simple test for XSParagraph. > > It doesn't work, it cannot find XSParagraph::new. I tried to show the > > methods, but none showed up... > > The module name is, at the moment, not "XSParagraph", but > "Texinfo::Convert::XSParagraph::XSParagraph". I've been planning on > switching things around so it is accessed as > "Texinfo::Convert::Paragraph"; I haven't done it yet though.
Here is a patch that seems to work. It mimicks Dynaloader bootstrap for the searching directories too and I fixed the test to be a working simple test. This allows to build a standalone XSParagraph module, I also attach a shell script testing that. Even if you do not maintain it afterwards, I think that it is better to have something that works for now. -- Pat
Index: Makefile.PL
===================================================================
--- Makefile.PL (révision 6530)
+++ Makefile.PL (copie de travail)
@@ -3,18 +3,17 @@
# See lib/ExtUtils/MakeMaker.pm for details of how to influence
# the contents of the Makefile that is written.
WriteMakefile(
- NAME => 'XSParagraph',
- VERSION_FROM => 'lib/XSParagraph.pm', # finds $VERSION
+ NAME => 'Texinfo::Convert::XSParagraph::XSParagraph',
+ VERSION_FROM => 'XSParagraph.pm', # finds $VERSION
PREREQ_PM => {}, # e.g., Module::Name => 1.1
($] >= 5.005 ? ## Add these new keywords supported since 5.005
- (ABSTRACT_FROM => 'lib/XSParagraph.pm', # retrieve abstract from module
- AUTHOR => 'A. U. Thor <[email protected]>') : ()),
+ (AUTHOR => 'Gavin Smith <[email protected]>') : ()),
LIBS => [''], # e.g., '-lm'
DEFINE => '', # e.g., '-DHAVE_SOMETHING'
INC => '-I.', # e.g., '-I. -I/usr/include/other'
# Un-comment this if you add C files to link with later:
- # OBJECT => '$(O_FILES)', # link all the C files too
- 'MYEXTLIB' => 'mylib/libxspara.a',
+ OBJECT => '$(O_FILES)', # link all the C files too
+ #'MYEXTLIB' => 'mylib/libxspara.a',
);
sub MY::postable {
Index: XSParagraph.pm
===================================================================
--- XSParagraph.pm (révision 6530)
+++ XSParagraph.pm (copie de travail)
@@ -47,6 +47,10 @@
);
BEGIN {
+
+my $module = "Texinfo::Convert::XSParagraph::XSParagraph";
+our $VERSION = '6.0';
+
# Possible values for TEXINFO_XS environmental variable:
#
# TEXINFO_XS=omit # don't try loading xs at all
@@ -105,6 +109,25 @@
goto FALLBACK;
}
+my $dlname = undef;
+my $dlpath = undef;
+if ($TEXINFO_XS eq 'module') {
+ #bootstrap('Texinfo::Convert::XSParagraph::XSParagraph');
+ my @modparts = split(/::/,$module);
+ my $modfname = $modparts[-1];
+ my $modpname = join('/',@modparts);
+ # the directories with -L prepended setup direcctory to
+ # be in the search path. Then $modfname is prepended as it is
+ # the name really searched for.
+ $dlpath = DynaLoader::dl_findfile(map("-L$_/auto/$modpname", @INC),
$modfname);
+ #$TEXINFO_XS = 'debug';
+ if (!$dlpath) {
+ _fatal "XSParagraph: couldn't find $module";
+ goto FALLBACK;
+ }
+ goto LOAD;
+}
+
my ($libtool_dir, $libtool_archive) = _find_file("XSParagraph.la");
if (!$libtool_archive) {
_fatal "XSParagraph: couldn't find Libtool archive file";
@@ -119,7 +142,6 @@
}
# Look for the line in XSParagraph.la giving the name of the loadable object.
-my $dlname = undef;
while (my $line = <$fh>) {
if ($line =~ /^\s*dlname\s*=\s*'([^']+)'\s$/) {
$dlname = $1;
@@ -135,17 +157,16 @@
push @DynaLoader::dl_library_path, $libtool_dir;
push @DynaLoader::dl_library_path, "$libtool_dir/.libs";
-my $dlpath = DynaLoader::dl_findfile($dlname);
+$dlpath = DynaLoader::dl_findfile($dlname);
if (!$dlpath) {
_fatal "XSParagraph: couldn't find $dlname";
goto FALLBACK;
}
+LOAD:
+
#print STDERR "loadable object is at $dlpath\n";
-my $module = "Texinfo::Convert::XSParagraph::XSParagraph";
-our $VERSION = '6.0';
-
# Following steps under "bootstrap" in "man DynaLoader".
#bootstrap XSParagraph $VERSION;
Index: t/XSParagraph.t
===================================================================
--- t/XSParagraph.t (révision 6530)
+++ t/XSParagraph.t (copie de travail)
@@ -8,8 +8,8 @@
use strict;
use warnings;
-use Test::More tests => 1;
-BEGIN { use_ok('XSParagraph') };
+use Test::More tests => 2;
+BEGIN { use_ok('Texinfo::Convert::XSParagraph::XSParagraph') };
#########################
@@ -16,13 +16,10 @@
# Insert your test code below, the Test::More module is use()ed here so read
# its man page ( perldoc Test::More ) for help writing this test script.
-my $paragraph;
-$paragraph = {'word' => 'hello world', 'end_sentence' => 0};
+my $paragraph = Texinfo::Convert::XSParagraph::XSParagraph::new({});
-print STDERR "Perl: here 1\n";
-XSParagraph::set_state ($paragraph);
-print STDERR "Perl: here 2\n";
-XSParagraph::get_state ($paragraph);
-print STDERR "In Perl: word set is ", $paragraph->{'word'}, "\n";
-print STDERR "In Perl: end_sentence is ", $paragraph->{'end_sentence'}, "\n";
+my $input = "Some text.";
+my $text = $paragraph->add_text($input);
+$text .= $paragraph->end();
+is($text, $input."\n");
Index: MANIFEST
===================================================================
--- MANIFEST (révision 6530)
+++ MANIFEST (copie de travail)
@@ -1,7 +1,11 @@
Makefile.PL
MANIFEST
ppport.h
+xspara.c
+xspara.h
+text.c
+text.h
README
XSParagraph.xs
t/XSParagraph.t
-lib/XSParagraph.pm
+XSParagraph.pm
prepare_standalone_perl_module.sh
Description: Bourne shell script
