-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
368 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
--- | ||
|
||
install: | ||
- choco install strawberryperl | ||
- SET PATH=C:\Perl5\bin;C:\strawberry\c\bin;C:\strawberry\perl\site\bin;C:\strawberry\perl\bin;%PATH% | ||
- perl -v | ||
- if not exist C:\Perl5 mkdir C:\Perl5 | ||
- SET PERL5LIB=C:/Perl5/lib/perl5 | ||
- SET PERL_LOCAL_LIB_ROOT=C:/Perl5 | ||
- SET PERL_MB_OPT=--install_base C:/Perl5 | ||
- SET PERL_MM_OPT=INSTALL_BASE=C:/Perl5 | ||
- cpanm -n Dist::Zilla | ||
- dzil authordeps --missing | cpanm -n | ||
- dzil listdeps --missing | cpanm -n | ||
|
||
build: off | ||
|
||
test_script: | ||
- dzil test -v | ||
|
||
cache: | ||
- C:\Perl5 | ||
|
||
shallow_clone: true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
*.pm linguist-language=Perl | ||
*.t linguist-language=Perl | ||
*.h linguist-language=C |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
/FFI-Platypus-Record-StringArray-* | ||
/.build |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
language: minimal | ||
dist: xenial | ||
services: | ||
- docker | ||
before_install: | ||
- curl https://raw.githubusercontent.com/plicease/cip/master/bin/travis-bootstrap | bash | ||
- cip before-install | ||
install: | ||
- cip diag | ||
- cip install | ||
script: | ||
- cip script | ||
jobs: | ||
include: | ||
- env: CIP_TAG=5.31 | ||
- env: CIP_TAG=5.30 | ||
- env: CIP_TAG=5.28 | ||
- env: CIP_TAG=5.26 | ||
- env: CIP_TAG=5.24 | ||
- env: CIP_TAG=5.22 | ||
- env: CIP_TAG=5.20 | ||
- env: CIP_TAG=5.18 | ||
- env: CIP_TAG=5.16 | ||
- env: CIP_TAG=5.14 | ||
- env: CIP_TAG=5.12 | ||
- env: CIP_TAG=5.10 | ||
- env: CIP_TAG=5.8 | ||
cache: | ||
directories: | ||
- "$HOME/.cip" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
Revision history for {{$dist->name}} | ||
|
||
{{$NEXT}} | ||
- initial version |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
# FFI::Platypus::Record::StringArray [![Build Status](https://secure.travis-ci.org/Perl5-FFI/FFI-Platypus-Record-StringArray.png)](http://travis-ci.org/Perl5-FFI/FFI-Platypus-Record-StringArray) | ||
|
||
Array of strings for your FFI record | ||
|
||
# SYNOPSIS | ||
|
||
my $a = FFI::Platypus::Record::StringArray->new(qw( foo bar baz )); | ||
my $opaque = $a->opaque; | ||
|
||
# DESCRIPTION | ||
|
||
Experimental interface for an array of C strings. | ||
|
||
# CONSTRUCTOR | ||
|
||
## new | ||
|
||
my $a = FFI::Platypus::Record::StringArray->new(@a); | ||
|
||
Creates a new array of C strings. | ||
|
||
# METHODS | ||
|
||
## opaque | ||
|
||
my $opaque = $a->opaque; | ||
|
||
Returns the opaque pointer to the array of C strings. | ||
|
||
## size | ||
|
||
my $size = $a->size; | ||
|
||
Returns the number of elements in the array of C strings. | ||
|
||
## element | ||
|
||
my $element = $a->element($index); | ||
|
||
Returns the string in the array of C strings at the given index. | ||
|
||
# AUTHOR | ||
|
||
Graham Ollis <[email protected]> | ||
|
||
# COPYRIGHT AND LICENSE | ||
|
||
This software is copyright (c) 2019 by Graham Ollis. | ||
|
||
This is free software; you can redistribute it and/or modify it under | ||
the same terms as the Perl 5 programming language system itself. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
--- | ||
pod_spelling_system: | ||
skip: 0 | ||
# list of words that are spelled correctly | ||
# (regardless of what spell check thinks) | ||
# or stuff that I like to spell incorrectly | ||
# intentionally | ||
stopwords: [] | ||
|
||
pod_coverage: | ||
skip: 0 | ||
# format is "Class#method" or "Class",regex allowed | ||
# for either Class or method. | ||
private: [] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
name = FFI-Platypus-Record-StringArray | ||
author = Graham Ollis <[email protected]> | ||
license = Perl_5 | ||
copyright_holder = Graham Ollis | ||
copyright_year = 2019 | ||
version = 0.01 | ||
|
||
[@Author::Plicease] | ||
:version = 2.37 | ||
travis_status = 1 | ||
release_tests = 1 | ||
installer = Author::Plicease::MakeMaker | ||
test2_v0 = 1 | ||
github_user = Perl5-FFI | ||
|
||
[Author::Plicease::Core] | ||
;[Prereqs] | ||
;Foo::Bar = 0 | ||
|
||
[Author::Plicease::Upload] | ||
cpan = 0 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
package FFI::Platypus::Record::StringArray; | ||
|
||
use strict; | ||
use warnings; | ||
use 5.008001; | ||
use FFI::Platypus; | ||
use constant _ptr_size => FFI::Platypus->new->sizeof('opaque'); | ||
|
||
# ABSTRACT: Array of strings for your FFI record | ||
# VERSION | ||
|
||
=head1 SYNOPSIS | ||
my $a = FFI::Platypus::Record::StringArray->new(qw( foo bar baz )); | ||
my $opaque = $a->opaque; | ||
=head1 DESCRIPTION | ||
Experimental interface for an array of C strings. | ||
=head1 CONSTRUCTOR | ||
=head2 new | ||
my $a = FFI::Platypus::Record::StringArray->new(@a); | ||
Creates a new array of C strings. | ||
=cut | ||
|
||
my $ffi; | ||
|
||
sub new | ||
{ | ||
my $class = shift; | ||
|
||
$ffi ||= FFI::Platypus->new; | ||
|
||
my $perl_array = [map { defined $_ ? "$_" : undef } @_]; | ||
my $array_size = _ptr_size * @_; | ||
|
||
my $self = bless { | ||
perl_array => $perl_array, | ||
c_array => $ffi->cast( 'string[]' => "record($array_size)", $perl_array), | ||
array_size => $array_size, | ||
}, $class; | ||
} | ||
|
||
=head1 METHODS | ||
=head2 opaque | ||
my $opaque = $a->opaque; | ||
Returns the opaque pointer to the array of C strings. | ||
=cut | ||
|
||
sub opaque | ||
{ | ||
my($self) = @_; | ||
my $array_size = $self->{array_size}; | ||
$self->{opaque} ||= $ffi->cast( "record($array_size)" => 'opaque', $self->{c_array}); | ||
} | ||
|
||
=head2 size | ||
my $size = $a->size; | ||
Returns the number of elements in the array of C strings. | ||
=cut | ||
|
||
sub size | ||
{ | ||
my($self) = @_; | ||
scalar @{ $self->{perl_array} }; | ||
} | ||
|
||
=head2 element | ||
my $element = $a->element($index); | ||
Returns the string in the array of C strings at the given index. | ||
=cut | ||
|
||
sub element | ||
{ | ||
my($self, $index) = @_; | ||
$self->{perl_array}->[$index]; | ||
} | ||
|
||
1; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
use Test2::V0 -no_srand => 1; | ||
use Config; | ||
|
||
eval { require 'Test/More.pm' }; | ||
|
||
# This .t file is generated. | ||
# make changes instead to dist.ini | ||
|
||
my %modules; | ||
my $post_diag; | ||
|
||
$modules{$_} = $_ for qw( | ||
ExtUtils::MakeMaker | ||
FFI::Platypus | ||
Test2::V0 | ||
); | ||
|
||
|
||
|
||
my @modules = sort keys %modules; | ||
|
||
sub spacer () | ||
{ | ||
diag ''; | ||
diag ''; | ||
diag ''; | ||
} | ||
|
||
pass 'okay'; | ||
|
||
my $max = 1; | ||
$max = $_ > $max ? $_ : $max for map { length $_ } @modules; | ||
our $format = "%-${max}s %s"; | ||
|
||
spacer; | ||
|
||
my @keys = sort grep /(MOJO|PERL|\A(LC|HARNESS)_|\A(SHELL|LANG)\Z)/i, keys %ENV; | ||
|
||
if(@keys > 0) | ||
{ | ||
diag "$_=$ENV{$_}" for @keys; | ||
|
||
if($ENV{PERL5LIB}) | ||
{ | ||
spacer; | ||
diag "PERL5LIB path"; | ||
diag $_ for split $Config{path_sep}, $ENV{PERL5LIB}; | ||
|
||
} | ||
elsif($ENV{PERLLIB}) | ||
{ | ||
spacer; | ||
diag "PERLLIB path"; | ||
diag $_ for split $Config{path_sep}, $ENV{PERLLIB}; | ||
} | ||
|
||
spacer; | ||
} | ||
|
||
diag sprintf $format, 'perl ', $]; | ||
|
||
foreach my $module (sort @modules) | ||
{ | ||
my $pm = "$module.pm"; | ||
$pm =~ s{::}{/}g; | ||
if(eval { require $pm; 1 }) | ||
{ | ||
my $ver = eval { $module->VERSION }; | ||
$ver = 'undef' unless defined $ver; | ||
diag sprintf $format, $module, $ver; | ||
} | ||
else | ||
{ | ||
diag sprintf $format, $module, '-'; | ||
} | ||
} | ||
|
||
if($post_diag) | ||
{ | ||
spacer; | ||
$post_diag->(); | ||
} | ||
|
||
spacer; | ||
|
||
done_testing; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
use Test2::V0 -no_srand => 1; | ||
sub require_ok ($); | ||
|
||
require_ok 'FFI::Platypus::Record::StringArray'; | ||
|
||
done_testing; | ||
|
||
sub require_ok ($) | ||
{ | ||
# special case of when I really do want require_ok. | ||
# I just want a test that checks that the modules | ||
# will compile okay. I won't be trying to use them. | ||
my($mod) = @_; | ||
my $ctx = context(); | ||
eval qq{ require $mod }; | ||
my $error = $@; | ||
my $ok = !$error; | ||
$ctx->ok($ok, "require $mod"); | ||
$ctx->diag("error: $error") if $error ne ''; | ||
$ctx->release; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
use Test2::V0 -no_srand => 1; | ||
use FFI::Platypus::Record::StringArray; | ||
|
||
subtest 'basic' => sub { | ||
|
||
my $a = FFI::Platypus::Record::StringArray->new(qw( foo bar baz ), undef ); | ||
isa_ok $a, 'FFI::Platypus::Record::StringArray'; | ||
is $a->size, 4; | ||
is $a->element(0), 'foo'; | ||
is $a->element(1), 'bar'; | ||
is $a->element(2), 'baz'; | ||
is $a->element(3), undef; | ||
like $a->opaque, qr/^-?[0-9]+$/; | ||
|
||
}; | ||
|
||
done_testing |