From e66585f4671aad396803fed6dd86485b3841d9f2 Mon Sep 17 00:00:00 2001 From: Stoiko Ivanov Date: Sat, 5 Jun 2021 16:02:35 +0000 Subject: [PATCH] update bindings by running `h2xs -P -v 1.0 -F -DHAVE_MMAP -M '^XDG_' -Ofan Xdgmime xdgmime.h` and selectively adding changes. upstream xdgmime.h contains all functions also as defines (preprocessor mangling to add XDG_PREFIX to the function name) - thus all functions would also be added as constants, which leads to errors in the automatically generated tests. The functions need to be in EXPORT_OK, but not added to @names in Makefile.PL. Signed-off-by: Stoiko Ivanov --- Xdgmime/Changes | 4 ++ Xdgmime/Makefile.PL | 30 ++++------- Xdgmime/README | 8 +-- Xdgmime/Xdgmime.xs | 1 + Xdgmime/lib/Xdgmime.pm | 112 ++--------------------------------------- Xdgmime/t/Xdgmime.t | 25 +++++++-- 6 files changed, 43 insertions(+), 137 deletions(-) diff --git a/Xdgmime/Changes b/Xdgmime/Changes index 462f934..2f43e76 100644 --- a/Xdgmime/Changes +++ b/Xdgmime/Changes @@ -1,5 +1,9 @@ Revision history for Perl extension Xdgmime. +1.0 Fri Jun 11 11:16:07 2021 + - updated by running h2xs 1.23 with options + -P -v 1.0 -F -DHAVE_MMAP -M '^XDG_' -t PV -Ofan Xdgmime xdgmime.h + 0.01 Fri Jun 1 10:46:21 2012 - original version; created by h2xs 1.23 with options xdgmime.h diff --git a/Xdgmime/Makefile.PL b/Xdgmime/Makefile.PL index de596c2..c41c99d 100644 --- a/Xdgmime/Makefile.PL +++ b/Xdgmime/Makefile.PL @@ -1,18 +1,19 @@ -use 5.010001; +use 5.032001; use ExtUtils::MakeMaker; # See lib/ExtUtils/MakeMaker.pm for details of how to influence # the contents of the Makefile that is written. WriteMakefile( NAME => 'Xdgmime', - VERSION_FROM => 'lib/Xdgmime.pm', # finds $VERSION + VERSION_FROM => 'lib/Xdgmime.pm', # finds $VERSION, requires EU::MM from perl >= 5.5 PREREQ_PM => {}, # e.g., Module::Name => 1.1 - ($] >= 5.005 ? ## Add these new keywords supported since 5.005 - (ABSTRACT_FROM => 'lib/Xdgmime.pm', # retrieve abstract from module - AUTHOR => 'root ') : ()), + ABSTRACT_FROM => 'lib/Xdgmime.pm', # retrieve abstract from module + AUTHOR => 'stoiko ivanov ', + #LICENSE => 'perl', + #Value must be from legacy list of licenses here + #https://metacpan.org/pod/Module::Build::API LIBS => [''], # e.g., '-lm' DEFINE => '-DHAVE_MMAP', # 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 ); if (eval {require ExtUtils::Constant; 1}) { @@ -21,24 +22,11 @@ if (eval {require ExtUtils::Constant; 1}) { # files to replace their "fallback" counterparts before distributing your # changes. my @names = (qw(XDG_MIME_TYPE_EMPTY XDG_MIME_TYPE_TEXTPLAIN - XDG_MIME_TYPE_UNKNOWN _xdg_mime_mime_type_equal - _xdg_mime_mime_type_subclass _xdg_mime_unalias_mime_type - xdg_mime_dump xdg_mime_get_generic_icon xdg_mime_get_icon - xdg_mime_get_max_buffer_extents xdg_mime_get_mime_parents - xdg_mime_get_mime_type_for_data - xdg_mime_get_mime_type_for_file - xdg_mime_get_mime_type_from_file_name - xdg_mime_get_mime_types_from_file_name - xdg_mime_is_valid_mime_type xdg_mime_list_mime_parents - xdg_mime_media_type_equal xdg_mime_mime_type_equal - xdg_mime_mime_type_subclass xdg_mime_register_reload_callback - xdg_mime_remove_callback xdg_mime_shutdown xdg_mime_type_empty - xdg_mime_type_textplain xdg_mime_type_unknown - xdg_mime_unalias_mime_type)); + XDG_MIME_TYPE_UNKNOWN)); ExtUtils::Constant::WriteConstants( NAME => 'Xdgmime', NAMES => \@names, - DEFAULT_TYPE => 'IV', + DEFAULT_TYPE => 'PV', C_FILE => 'const-c.inc', XS_FILE => 'const-xs.inc', ); diff --git a/Xdgmime/README b/Xdgmime/README index 018c206..7e4d0b1 100644 --- a/Xdgmime/README +++ b/Xdgmime/README @@ -1,5 +1,5 @@ -Xdgmime version 0.01 -==================== +Xdgmime version 1.0 +=================== The README is used to introduce the module and provide instructions on how to install the module, any machine dependencies it may have (for @@ -31,10 +31,10 @@ COPYRIGHT AND LICENCE Put the correct copyright and licence information here. -Copyright (C) 2012 by root +Copyright (C) 2021 by stoiko ivanov This library is free software; you can redistribute it and/or modify -it under the same terms as Perl itself, either Perl version 5.10.1 or, +it under the same terms as Perl itself, either Perl version 5.32.1 or, at your option, any later version of Perl 5 you may have available. diff --git a/Xdgmime/Xdgmime.xs b/Xdgmime/Xdgmime.xs index edd09bf..c474442 100644 --- a/Xdgmime/Xdgmime.xs +++ b/Xdgmime/Xdgmime.xs @@ -1,3 +1,4 @@ +#define PERL_NO_GET_CONTEXT #include "EXTERN.h" #include "perl.h" #include "XSUB.h" diff --git a/Xdgmime/lib/Xdgmime.pm b/Xdgmime/lib/Xdgmime.pm index eba6889..b37e883 100644 --- a/Xdgmime/lib/Xdgmime.pm +++ b/Xdgmime/lib/Xdgmime.pm @@ -1,6 +1,6 @@ package Xdgmime; -use 5.010001; +use 5.032001; use strict; use warnings; use Carp; @@ -21,30 +21,17 @@ our %EXPORT_TAGS = ( 'all' => [ qw( XDG_MIME_TYPE_EMPTY XDG_MIME_TYPE_TEXTPLAIN XDG_MIME_TYPE_UNKNOWN - _xdg_mime_mime_type_equal - _xdg_mime_mime_type_subclass - _xdg_mime_unalias_mime_type xdg_mime_dump - xdg_mime_get_generic_icon - xdg_mime_get_icon xdg_mime_get_max_buffer_extents - xdg_mime_get_mime_parents xdg_mime_get_mime_type_for_data xdg_mime_get_mime_type_for_file xdg_mime_get_mime_type_from_file_name - xdg_mime_get_mime_types_from_file_name xdg_mime_is_valid_mime_type xdg_mime_list_mime_parents xdg_mime_media_type_equal xdg_mime_mime_type_equal xdg_mime_mime_type_subclass - xdg_mime_register_reload_callback - xdg_mime_remove_callback xdg_mime_shutdown - xdg_mime_type_empty - xdg_mime_type_textplain - xdg_mime_type_unknown - xdg_mime_unalias_mime_type ) ] ); our @EXPORT_OK = ( @{ $EXPORT_TAGS{'all'} } ); @@ -53,33 +40,20 @@ our @EXPORT = qw( XDG_MIME_TYPE_EMPTY XDG_MIME_TYPE_TEXTPLAIN XDG_MIME_TYPE_UNKNOWN - _xdg_mime_mime_type_equal - _xdg_mime_mime_type_subclass - _xdg_mime_unalias_mime_type xdg_mime_dump - xdg_mime_get_generic_icon - xdg_mime_get_icon xdg_mime_get_max_buffer_extents - xdg_mime_get_mime_parents xdg_mime_get_mime_type_for_data xdg_mime_get_mime_type_for_file xdg_mime_get_mime_type_from_file_name - xdg_mime_get_mime_types_from_file_name xdg_mime_is_valid_mime_type xdg_mime_list_mime_parents xdg_mime_media_type_equal xdg_mime_mime_type_equal xdg_mime_mime_type_subclass - xdg_mime_register_reload_callback - xdg_mime_remove_callback xdg_mime_shutdown - xdg_mime_type_empty - xdg_mime_type_textplain - xdg_mime_type_unknown - xdg_mime_unalias_mime_type ); -our $VERSION = '0.01'; +our $VERSION = '1.0'; sub AUTOLOAD { # This AUTOLOAD is used to 'autoload' constants from the constant() @@ -109,87 +83,7 @@ XSLoader::load('Xdgmime', $VERSION); # Preloaded methods go here. -# Autoload methods go after =cut, and are processed by the autosplit program. +# Autoload methods go after __END__, and are processed by the autosplit program. 1; __END__ -# Below is stub documentation for your module. You'd better edit it! - -=head1 NAME - -Xdgmime - Perl extension for blah blah blah - -=head1 SYNOPSIS - - use Xdgmime; - blah blah blah - -=head1 DESCRIPTION - -Stub documentation for Xdgmime, created by h2xs. It looks like the -author of the extension was negligent enough to leave the stub -unedited. - -Blah blah blah. - -=head2 EXPORT - -None by default. - -=head2 Exportable constants - - XDG_MIME_TYPE_EMPTY - XDG_MIME_TYPE_TEXTPLAIN - XDG_MIME_TYPE_UNKNOWN - _xdg_mime_mime_type_equal - _xdg_mime_mime_type_subclass - _xdg_mime_unalias_mime_type - xdg_mime_dump - xdg_mime_get_generic_icon - xdg_mime_get_icon - xdg_mime_get_max_buffer_extents - xdg_mime_get_mime_parents - xdg_mime_get_mime_type_for_data - xdg_mime_get_mime_type_for_file - xdg_mime_get_mime_type_from_file_name - xdg_mime_get_mime_types_from_file_name - xdg_mime_is_valid_mime_type - xdg_mime_list_mime_parents - xdg_mime_media_type_equal - xdg_mime_mime_type_equal - xdg_mime_mime_type_subclass - xdg_mime_register_reload_callback - xdg_mime_remove_callback - xdg_mime_shutdown - xdg_mime_type_empty - xdg_mime_type_textplain - xdg_mime_type_unknown - xdg_mime_unalias_mime_type - - - -=head1 SEE ALSO - -Mention other useful documentation such as the documentation of -related modules or operating system documentation (such as man pages -in UNIX), or any relevant external documentation such as RFCs or -standards. - -If you have a mailing list set up for your module, mention it here. - -If you have a web site set up for your module, mention it here. - -=head1 AUTHOR - -root, Eroot@E - -=head1 COPYRIGHT AND LICENSE - -Copyright (C) 2012 by root - -This library is free software; you can redistribute it and/or modify -it under the same terms as Perl itself, either Perl version 5.10.1 or, -at your option, any later version of Perl 5 you may have available. - - -=cut diff --git a/Xdgmime/t/Xdgmime.t b/Xdgmime/t/Xdgmime.t index 7af5bac..b8a7997 100644 --- a/Xdgmime/t/Xdgmime.t +++ b/Xdgmime/t/Xdgmime.t @@ -1,14 +1,33 @@ -# Before `make install' is performed this script should be runnable with -# `make test'. After `make install' it should work as `perl Xdgmime.t' +# Before 'make install' is performed this script should be runnable with +# 'make test'. After 'make install' it should work as 'perl Xdgmime.t' ######################### # change 'tests => 2' to 'tests => last_test_to_print'; -use Test::More tests => 1; +use strict; +use warnings; +use Test::More tests => 2; BEGIN { use_ok('Xdgmime') }; + +my $fail = 0; +foreach my $constname (qw( + XDG_MIME_TYPE_EMPTY XDG_MIME_TYPE_TEXTPLAIN XDG_MIME_TYPE_UNKNOWN)) { + next if (eval "my \$a = $constname; 1"); + if ($@ =~ /^Your vendor has not defined Xdgmime macro $constname/) { + print "# pass: $@"; + } else { + print "# fail: $@"; + $fail = 1; + } + +} + +ok( $fail == 0 , 'Constants' ); +######################### + # 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.