FFI-Platypus-2.12/ 000755 000000 000000 00000000000 15251066120 013635 5 ustar 00root root 000000 000000 FFI-Platypus-2.12/CONTRIBUTING 000644 000000 000000 00000012472 15251066120 015475 0 ustar 00root root 000000 000000 CONTRIBUTING
If you have implemented a new feature or fixed a bug then you may make
a pull request on this project's GitHub repository:
https://github.com/PerlFFI/FFI-Platypus/pulls
This project is developed using Dist::Zilla. The project's git
repository also comes with the Makefile.PL file necessary for building,
testing (and even installing if necessary) without Dist::Zilla. Please
keep in mind though that these files are generated so if changes need
to be made to those files they should be done through the project's
dist.ini file. If you do use Dist::Zilla and already have the necessary
plugins installed, then I encourage you to run dzil test before making
any pull requests. This is not a requirement, however, I am happy to
integrate especially smaller patches that need tweaking to fit the
project standards. I may push back and ask you to write a test case or
alter the formatting of a patch depending on the amount of time I have
and the amount of code that your patch touches.
This project's GitHub issue tracker listed above is not Write-Only. If
you want to contribute then feel free to browse through the existing
issues and see if there is something you feel you might be good at and
take a whack at the problem. I frequently open issues myself that I
hope will be accomplished by someone in the future but do not have time
to immediately implement myself.
Another good area to help out in is documentation. I try to make sure
that there is good document coverage, that is there should be
documentation describing all the public features and warnings about
common pitfalls, but an outsider's or alternate view point on such
things would be welcome; if you see something confusing or lacks
sufficient detail I encourage documentation only pull requests to
improve things.
The Platypus distribution comes with a test library named libtest that
is normally automatically built by ./Build test. If you prefer to use
prove or run tests directly, you can use the ./Build libtest command to
build it. Example:
% perl Makefile.PL
% make
% make ffi-test
% prove -bv t
# or an individual test
% perl -Mblib t/ffi_platypus_memory.t
The build process also respects these environment variables:
FFI_PLATYPUS_DEBUG_FAKE32
When building Platypus on 32 bit Perls, it will use the Math::Int64 C
API and make Math::Int64 a prerequisite. Setting this environment
variable will force Platypus to build with both of those options on a
64 bit Perl as well.
% env FFI_PLATYPUS_DEBUG_FAKE32=1 perl Makefile.PL
DEBUG_FAKE32:
+ making Math::Int64 a prereq
+ Using Math::Int64's C API to manipulate 64 bit values
Generating a Unix-style Makefile
Writing Makefile for FFI::Platypus
Writing MYMETA.yml and MYMETA.json
%
FFI_PLATYPUS_NO_ALLOCA
Platypus uses the non-standard and somewhat controversial C function
alloca by default on platforms that support it. I believe that
Platypus uses it responsibly to allocate small amounts of memory for
argument type parameters, and does not use it to allocate large
structures like arrays or buffers. If you prefer not to use alloca
despite these precautions, then you can turn its use off by setting
this environment variable when you run Makefile.PL:
helix% env FFI_PLATYPUS_NO_ALLOCA=1 perl Makefile.PL
NO_ALLOCA:
+ alloca() will not be used, even if your platform supports it.
Generating a Unix-style Makefile
Writing Makefile for FFI::Platypus
Writing MYMETA.yml and MYMETA.json
V
When building platypus may hide some of the excessive output when
probing and building, unless you set V to a true value.
% env V=1 perl Makefile.PL
% make V=1
...
Coding Guidelines
* Do not hesitate to make code contribution. Making useful
contributions is more important than following byzantine bureaucratic
coding regulations. We can always tweak things later.
* Please make an effort to follow existing coding style when making
pull requests.
* The intent of the FFI-Platypus team is to support the same versions
of Perl that are supported by the Perl toolchain. As of this writing
that means 5.16 and better. As such, please do not include any code
that requires a newer version of Perl.
Performance Testing
As Mark Twain was fond of saying there are four types of lies: lies,
damn lies, statistics and benchmarks. That being said, it can sometimes
be helpful to compare the runtime performance of Platypus if you are
making significant changes to the Platypus Core. For that I use
`FFI-Performance`, which can be found in my GitHub repository here:
https://github.com/Perl5-FFI/FFI-Performance
System integrators
This distribution uses Alien::FFI in fallback mode, meaning if the
system doesn't provide pkg-config and libffi it will attempt to
download libffi and build it from source. If you are including Platypus
in a larger system (for example a Linux distribution) you only need to
make sure to declare pkg-config or pkgconf and the development package
for libffi as prereqs for this module.
FFI-Platypus-2.12/Changes 000644 000000 000000 00000111714 15251066120 015135 0 ustar 00root root 000000 000000 Revision history for FFI-Platypus
2.12 2026-09-11 15:02:01 -0600
- Added FFI::Platypus::Buffer::raw_scalar which allocates an
uninitialized scalar of a fixed size for use as a buffer
(gh#411)
- Fixed intermittent segfault in the bundle-bzip2 example caused
by an uninitialized bz_stream struct (gh#411)
- FFI::Platypus::Closure sticky and unstick methods now return
$self so that they can be chained (gh#411, gh#405 JBARRETT++)
- Added a SECURITY policy document (gh#406, gh#411)
- Fixed regression from 0.94 that broke the identity cast used
internally by attach_cast on hppa-linux (gh#394, gh#411)
2.11 2026-01-12 03:30:38 -0700
- Documentation updates only
2.10 2024-12-18 11:11:31 -0700
- Detect V modules according to v.mod files (gh#402)
2.09 2024-08-18 20:33:42 -0600
- Fix bug in complex type detection (gh#396, mauke++)
2.08 2023-05-05 15:48:53 -0600
- Updated non-binding support for Perls to match the policy
of the Perl toolchain (Perls older than 10 years old are
unsupported, with a one-time exception of Perl 5.16). The
intent is not to suddenly drop support for older Perls, but
the FFI-Platypus team may take advantage of features in
supported Perls that will effectively remove compatability
with unsupported Perls.
- Documentation improvements (gh#392)
2.07 2023-03-14 06:59:09 -0600
- Production release identical to 2.06_01
2.06_01 2023-02-27 10:13:25 -0700
- Refactor Alien::FFI fallback mode to delete it as a prereq when it is not
needed instead of adding it when it is. This way the CPAN river rating
for Alien::FFI more closely reflects reality (gh#391)
2.05 2022-11-15 16:59:05 -0700
- Documentation improvements (gh#387, gh#388)
2.04 2022-11-05 07:14:35 -0600
- Documentation improvements (gh#372, gh#378, gh#380, gh#381, gh#382, gh#383,
gh#384, gh#386)
2.03 2022-10-27 21:19:06 -0600
- Add hook for detecting bundled Zig project. You will need to install
FFI::Build::File::Zig to use it. (gh#379)
2.02 2022-10-24 10:43:09 -0600
- The closure method now accepts undef as an argument. It just returns undef
which should be accepted by any function that takes a closure. (gh#376, gh#377)
2.01 2022-08-30 15:37:22 -0600
- Documentation fixes (gh#373)
2.00 2022-08-12 13:58:51 -0600
- Production release identical to 1.91_01
1.91_01 2022-07-05 07:41:07 -0400
- Setting the env environment V variable to a true value now will override the
verbose option on FFI::Build. This allows modules that use it to display verbose
output without having to change the .fbx files. This mirrors the behavior of
how FFI-Platypus itself works. (gh#369)
1.90_02 2022-06-27 08:33:31 -0600
- Documentation updates for API = 2 (gh#340, gh#368)
1.90_01 2022-06-24 11:03:35 -0500
- api = 2 is no longer experimental (gh#365)
1.61_01 2022-06-23 16:16:43 -0500
- Added experimental modules FFI::Build::Plugin and FFI::Build::PluginData (gh#351)
1.60_01 2022-06-23 15:49:42 -0500
- Updated installer
1.59_01 2022-06-19 07:47:49 -0600
- Internal refactor (gh#361)
1.58 2022-06-19 06:19:42 -0600
- TypeParser version 2 accept string(10) as alias for string(10)* (gh#346, gh#359)
1.57 2022-06-15 18:30:29 -0600
- Documentation improvements
1.56 2021-10-27 19:44:37 -0600
- Fixes for very old versions of Mac OS X / Xcode (gh#350)
- Added cxxld method to FFI::Build::Platform (gh#350)
1.55 2021-07-29 10:41:02 -0600
- Production release identical to 1.54_01
1.54_01 2021-07-12 17:05:37 -0600
- FFI::Temp will retry up to 10 times to avoid a race (gh#344, gh#348)
1.53 2021-07-12 12:18:27 -0600
- Documentation improvements (gh#307, gh#347)
1.52 2021-07-01 07:33:44 -0600
- Probe for intmax_t uintmax_t types (gh#341)
1.51 2021-07-01 07:25:38 -0600
- Fix testing bug that was failing on systems with libffi that does
not support variadic functions (ppisar++ gh#323, gh#343, gh#345)
1.50 2021-06-30 08:34:17 -0600
- Production release identical to 1.49_01
1.49_01 2021-06-22 17:07:44 -0600
- float gets promoted to double when used as a varadic argument
(gh#323, gh#338)
1.48_01 2021-06-22 00:32:02 -0600
- Test forks in CI (gh#333, #334, #335)
- Internal refactor of pointer and array input arguments to reduce
duplication (gh#336)
1.47_01 2021-06-21 22:24:40 -0600
- Restore experimental code from 1.45_01
1.46 2021-06-21 22:20:12 -0600
- Hotfix due to testing bug in 1.44 (gh#333)
- This version does not include experimental code from 1.45_01.
1.45_01 2021-06-21 18:23:17 -0600
- Experimental: with api => 2, you can now pass an array reference to
a pointer argument, which is roughly equivalent to an array type with
no size, example: sint[] (gh#227, gh#332)
1.44 2021-06-20 06:50:03 -0600
- Migrate test suite to Test::V0 (gh#327)
- Use parent instead of base in documentation and in code (gh#239 jjatria++)
- Improved consistency of examples and documentation (gh#328, gh#330, jjatria++)
1.43 2021-03-17 09:46:40 -0600
- Fix test hang on cygwin (gh#320, gh#321)
1.42 2021-03-15 05:42:23 -0600
- Production release identical to 1.41_01
1.41_01 2021-03-14 12:49:38 -0600
- Adjusted test introduced in 1.40_01 to not rely on returning
a record-value for platforms that do not support that. (gh#318, gh#319)
1.40_01 2021-03-12 13:08:41 -0700
- Add support for closures returning records pass-by-value
if they do not include string pointers (gh#313, gh#315)
1.39_01 2021-03-09 17:38:37 -0700
- Fix bug where closure ABI wasn't being used for non-default
ABIs (gh#313, gh#314)
- Add support for closures taking records pass-by-value (gh#312)
1.38 2021-03-08 17:13:15 -0700
- Production release identical to 1.37_01
1.37_01 2021-03-06 14:03:35 -0700
- Document the .fbx interface for specifying compiler / linker flags or
using Aliens with bundled C code in FFI::Platypus::Bundle
(gh#221, gh#306)
1.36_01 2021-03-02 17:32:03 -0700
- Improved the reliability of ABI detection on some platforms
(gh#285, gh#301, gh#302)
1.35_01 2021-03-01 16:02:07 -0700
- Favor the Microsoft strdup over the bundled copy if found as _strdup
which is what it is called now (gh#299).
- Added FFI::Platypus::Type::WideString type plugin
(IKEGAMI++ gh#291, gh#292, gh#299)
1.34 2020-10-23 09:04:46 -0600
- Fixed bug in in record meta object which expressed itself on at least
some platforms (gh#287, gh#288)
1.33 2020-09-28 10:47:26 -0600
- FFI::Platypus::Declare is no longer part of this distribution. It is
now available from FFI-Platypus-Declare instead. It has already
been discouraged for quite some time. (gh#285)
- Fix bug where bundled .so name could incorrectly get double colons (::)
in the name in development mode only. This is probably only a problem
on Windows. (gh#284)
1.32 2020-09-21 04:25:13 -0600
- Fix unsupported Perl tests.
Fixes code that refuse to install on 5.10.0t (threads) (gh#275, gh#280)
1.31 2020-07-01 05:28:10 -0600
- Refuse to install on very old versions of Perl 5.8.1, 5.8.2, 5.8.3 and
5.10.0t (threads) (Gh#275)
- Move to new GH org PerlFFI (old org was Perl5-FFI, and will remain to
keep URL redirection). The new URL is
https://github.com/PerlFFI/FFI-Platypus
1.30 2020-06-16 06:51:53 -0600
- Dropping support for Perl 5.8.1, 5.8.2 and 5.8.3, and the threaded version
of 5.10.0. For now Platypus will install on these versions of Perl, but a
warning will be issued, along with a 45s sleep at configure time and a 180s
sleep at test time. Please upgrade to 5.8.4 (or preferrably 5.32).
Starting July 1st, Platypus will refuse to install on these elderly Perls.
(gh#271, gh#272)
1.29 2020-06-06 08:40:10 -0600
- For window (from FFI::Platypus::Buffer), if $size is omitted then
it will assumed to be a C string and computed using strlen (gh#270)
1.28 2020-05-20 01:43:09 -0600
- Production release identical to 1.27_01
1.27_01 2020-05-17 18:01:37 -0600
- Add strcpy to FFI::Platypus::Memory (gh#265)
- Add window to FFI::Platypus::Buffer (gh#266, gh#267)
1.26 2020-05-07 04:59:17 -0600
- The return type for the function method can now be omitted and
defaults to 'void' (gh#262, gh#263)
- The attach_cast method can now take a wrapper function (gh#261, gh#264)
1.25 2020-05-05 19:40:02 -0600
- Fixed bug where return type uint64* was being returned as
sint64* (gh#258, gh#259)
1.24 2020-05-02 16:59:34 -0600
- Add kindof method (gh#243, gh#254)
- Add countof method (gh#243, gh#254)
- Add unitof method (gh#245, gh#254)
- Add def method (gh#244, gh#248, gh#254)
- Add hook load_custom_types to the language plugins that allows
them to define custom types (gh#253)
1.23_01 2020-05-01 11:13:59 -0600
- Custom record arguments are kept around for the lifetime of the
function call, meaning they don't have to be explicitly kept by
the custom code wrapper as long as they aren't used after the
function returns (gh#236, gh#247).
- This completes support for custom record types. This is a
release candidate.
1.22_01 2020-05-01 08:16:25 -0600
- Fix test on MSWin32 + older libffi where returning record values
doesn't work (introduced in 1.20_01, gh#250)
1.21_01 2020-04-29 19:10:59 -0600
- Diagnostic release.
1.20_01 2020-04-29 06:45:11 -0600
- Return record custom record value (gh#214, gh#215, gh#235, gh#238, gh#245)
1.19_01 2020-04-27 12:38:43 -0600
- Diagnostic release.
1.18_01 2020-04-19 10:17:52 -0600
- Return pointer to custom record (gh#214, gh#215, gh#235, gh#238)
1.17_01 2020-04-18 09:04:02 -0600
- Silence (probably harmless) clang warning introduced in 1.12_01
(gh#237, gh#239)
1.16_01 2020-04-18 10:10:37 -0400
- Initial support for custom records. Returning custom records
(either via pointer or by reference) is excluded, but should
be added soon (gh#214, gh#215, gh#235)
1.15_01 2020-04-17 10:34:13 -0600
- Internal refactor (gh#214)
1.14_01 2020-04-17 09:14:25 -0600
- Experimental: with api => 2, a return value of NULL is
translated to undef instead of empty list (gh#234, gh#231)
1.12_01 2020-04-17 10:35:51 -0400
- Added grow and set_used_length functions to
FFI::Platypus::Buffer (djerius++ gh#225)
1.11 2020-04-16 04:07:34 -0600
- Add api method (gh#233)
- On Visual C++ Perl detect libffi using Win32::Vcpkg, if
available (gh#229)
- Simplified internal handling of 64 bit integers for
32 and 64 bit arch (gh#228)
1.10 2020-02-05 16:39:51 -0700
- On OS X, check if homebrew + libffi is installed and use
that instead of falling back on Alien::FFI (libffi isn't
installed by homebrew in a way that it can be found by
without specifically looking for it).
- Die with an appropriate diagnostic if there is a syntax or
runtime error in an .fbx file (FFI::Build).
(djerius++ gh#223)
1.09 2020-01-18 13:41:56 -0700
- Production release identical to 1.08_01
1.08_01 2020-01-17 19:39:21 -0700
- Fix warning on some versions of windows (gh#217, gh#218)
1.07 2019-12-28 08:44:36 -0700
- Fix bug in variadic argument count (gh#210, gh#211)
1.06 2019-12-14 07:49:54 -0700
- Visual C++ Perl build probe for ssize_t (gh#208, gh#209)
1.05 2019-12-13 09:27:50 -0700
- ffi_platypus_bundle.h provides an EXPORT macro which allows
you to decorate functions/data for export under Visual C++ Perl (gh#207)
- ffi_pl_bundle_init, ffi_pl_bundle_constant and ffi_pl_bundle_fini
are now properly marked as EXPORT. No code changes needed as long
as you are using the header file (gh#207)
1.04_01 2019-12-12 19:05:54 -0700
- Some additional testing fixes for Visual C++ Perl build (gh#206)
1.03_01 2019-12-11 20:53:40 -0700
- Restore support for Visual C++ Perl build (gh#202)
- C++ support on Visual C++ Perl is not supported at this time (gh#203)
1.02 2019-12-09 03:07:41 -0700
- FFI::Build is no longer described as "alpha"
- Documentation fixes.
1.01 2019-11-16 07:16:20 -0700
- Documentation fixes only (gh#198, gh#199, gh#200)
1.00 2019-11-15 13:46:15 -0500
- Production release identical to 0.99_06
0.99_06 2019-11-12 21:08:23 -0500
- Detect Rust or Go modules according to Cargo.toml or go.mod files (gh#197)
0.99_05 2019-10-30 19:25:02 -0600
- Add FFI::Build support for build_all method (gh#195)
0.99_03 2019-10-24 10:46:02 -0700
- Documentation
0.99_02 2019-10-14 16:16:16 -0600
- api = 1 is no longer experimental (gh#193)
0.99_01 2019-10-14 14:39:18 -0600
- Convert documentation from api => 0 (implicit) to api => 1 (explicit)
- Improved documentation (gh#181, gh#184)
0.98 2019-10-14 13:18:02 -0600
- Production release identical to 0.97_05
0.97_05 2019-10-12 13:09:12 -0600
- Fixed several memory leaks on some return types and complex type
arguments (gh#190, gh#191)
0.97_04 2019-10-05 12:31:32 -0600
- pointer is no longer an alias for opaque with api => 1 (gh#189)
- Added several reserved words for the type parser when api => 1 (gh#189)
0.97_03 2019-09-25 18:03:13 -0600
- FFI::Platypus::Record has a record_layout_1 function which
uses api => 1 by default. (gh#187)
0.97_02 2019-09-20 04:03:59 -0600
- FFI::Platypus::Record record_layout may now take FFI::Platypus
constructor arguments as a array reference as the first argument
(gh#185)
0.97_01 2019-09-18 20:56:59 -0600
- Pre-compute cast functions when they are created to save time each time
they are called (gh#178, #179)
- sizeof and alignof can now be used as class methods (gh#183)
0.96 2019-08-19 18:33:58 -0400
- Production release identical to 0.95_11
0.95_11 2019-08-19 09:41:56 -0400
- Documentation fixes (hakonhagland++ gh#173)
- Increased Perl::Critic criticism and associated fixes (gh#172)
0.95_10 2019-08-16 16:14:54 -0400
- Detect bad forks.pm (gh#170)
0.95_09 2019-08-15 10:37:41 -0400
- Daignostic release
0.95_08 2019-08-14 09:18:10 -0400
- Document constant interface (see FFI::Platypus::Constant) (gh#169)
0.95_07 2019-08-13 13:38:30 -0400
- Minor tweak to bundle interface: do not create fbx.json file when
running on-demand (gh#167)
- Document bundle interface (see FFI::Platypus::Bundle) (gh#160, gh#168)
0.95_06 2019-08-03 08:51:46 -0400
- Platypus now passes the api version (if > 0) into language plugins
class native_type_map method (gh#165, gh#166)
0.95_05 2019-08-01 16:18:41 -0400
- Under api = 1, a warning will be issued when Platypus tries to load
a file that is not a dnyamic library. Previously, and under api = 0
this warning was only issued if the environment variable
FFI_PLATYPUS_DLERROR is set to a true value (gh#161, gh#163)
0.95_04 2019-07-31 21:18:30 -0400
- New interface for bundling code with dist (see bundle method)
experimental, requires api = 1 (gh#160, gh#162)
- Bundle API provides a way to define Perl constants from C
(gh#138)
0.95_03 2019-07-29 19:21:24 -0400
- Remove build dependent strings from deployment
(gh#104, gh#110, gh#157, gh#159)
0.95_02 2019-07-25 17:15:09 -0400
- Fix memory leak related to array in the case of bad type error (gh#154)
- Fix compiler warnings in record meta module (gh#153, gh155)
- More consistent use of temp directories to work around noexec on /tmp
(gh#156, gh#158)
0.95_01 2019-07-23 22:19:14 -0400
- Add support for "object" types. (gh#49, gh#89, gh#151)
- Fixed bug where 64 bit integer types could be truncated in a
cast on 32 bit platform (gh#151)
- You can now decorate record value types with * to get
a record type using type parse 1 (gh#150)
- Add support for complex arrays on platforms where
complex types are supported (gh#89, gh#152)
0.94 2019-07-23 09:53:46 -0400
- Production release identical to 0.93_03
0.93_03 2019-07-22 15:02:05 -0400
- Reclaim some memory waste introduced in 0.93_01 (gh#149)
0.93_02 2019-07-18 10:03:01 -0400
- Fix complex test on 32bit
0.93_01 2019-07-17 20:21:47 -0400
- Add support for returning records pass-by-value (gh#89, gh#147)
- Add enum and senum (signed enum) types (gh#146)
0.92 2019-07-17 18:16:40 -0400
- Production release identical to 0.91_02
0.91_02 2019-07-16 19:31:40 -0400
- Documentation improvements. (gh#139, gh#145, et. al)
- Fixed minor testing error introduced in 0.91_01 (gh#143, gh#144)
0.91_01 2019-07-14 09:32:13 -0400
- Add support for variadic functions (gh#136, gh#141)
- Include Type Parser version 1. This can be activated using
the api => 1 when creating a FFI::Platypus instance (gh#135)
- Usage of Type Parser version 1 is experimental and will
issue a warning until FFI::Platypus 1.00 is released (gh#135)
- Added support for pass-by-value records (gh#57,gh#92,gh#135)
this requires Type Parser version 1
- Allow decoration of aliases of basic types (gh#135, gh#135)
this requires Type Parser version 1
- Fix bug where Math::LongDouble and Math::Complex detection
wasn't being made for array and pointers of longdouble,
complex_float and complex_double types. (gh#135)
- For functions: allow a single 'void' argument type to indicate
an empty list of arguments (a la old C style). The 'void'
type is otherwise now illegal as an argument type (ie when
there is more than one argument) and will throw an exception
when the function is created. Previously a warning would
be issued when the funtion was called. (gh#140, gh#142)
0.90 2019-07-01 09:47:31 -0400
- Documentation improvements (gh#137, et. al.)
0.89_01 2019-06-24 08:33:05 -0400
- Fixed bug where prototypes to attach were sometimes being
ignored.
- Add sub_ref method to FFI::Platypus::Function (gh#133)
- Better file/line number diagnostics for croak inside a
wrapper (gh#129, gh#132)
0.88 2019-06-19 06:56:57 -0400
- Add mangler attribute for FFI::Platypus (gh#128)
0.87 2019-04-23 08:25:35 -0400
- Add probe for intptr_t and uintptr_t types (gh#123)
- You may now use the ALIEN_INSTALL_TYPE environment
to force using Alien::FFI (gh#121)
- Documentation improvements (gh#122 manwar++ gh#120 ppisar++)
0.86 2019-03-02 16:42:12 -0500
- Production release identical to 0.85_01
0.85_01 2019-03-01 20:38:22 -0500
- Fix configure bug that misconfigured Perls with 32bit IVs
resulting in truncated 64bit values. (gh#117, gh#118).
This was a regression, probably introduced around 0.72
or so. The test t/gh117.t has been added to avoid a
recurrence of this regression.
0.84 2019-02-15 15:26:23 -0500
- FFI::Build sets @rpath on libraries that it builds
on OS X.
0.83 2019-02-12 14:05:04 -0500
- Fix warning in FFI::Build when verbose off
- Allow arry file spec for FFI::Buuild source method
- Added scalar_to_pointer to FFI::Platypus::Buffer
0.82 2019-02-10 10:34:57 -0500
- Production release identical to 0.81_04
0.81_04 2019-02-08 14:49:20 -0500
- Diagnostic release
0.81_02 2019-02-05 12:19:50 -0500
- Diagnostic release
0.81_01 2019-02-04 11:51:52 -0500
- Diagnostic release
0.80 2019-02-01 15:36:50 -0500
- Fix incompatibility with parallel bsd make
0.79 2019-01-31 20:58:07 -0500
- Fix probe runner builder bug (gh#112, gh#113)
0.78 2019-01-30 10:28:22 -0500
- Production release identical to 0.77_03
0.77_03 2019-01-29 21:44:29 -0500
- Remove Java gcj examples. The gcj compiler has been deprecated,
unmaintained, and removed from the gcc collection for quite a while
now.
- Fix problem diagnostic window on Windows during probe
0.77_02 2019-01-29 11:30:56 -0500
- Fix regressions in 0.77_01
0.77_01 2019-01-28 15:47:07 -0500
- Honor compiler and linker flag overrides provided on the command-line
for FFI::Probe::Runner::Builder, make ffi and make ffi-test (gh#104)
0.76_01 2019-01-20 20:14:45 -0500
- function method can now take a wrapper code reference as its last
argument in the same way as attach.
0.75_01 2019-01-19 04:45:19 -0500
- Add strndup to FFI::Platypus::Memory
0.74 2019-01-19 04:42:22 -0500
- Production release identical to 0.73_01
0.73_01 2019-01-13 18:31:33 -0500
- Remove dependency on Win32::ErrorMode on Windows
0.72_01 2019-01-11 22:17:11 -0500
- Remove dependency on Config::AutoConf
0.71_01 2019-01-10 23:29:06 -0500
- Merge FFI-Build into this distribution
- Add FFI::Probe
0.70_01 2019-01-10 15:34:57 -0500
- prereq fix: IPC::Cmd as a configure requires
since it doesn't come with Perl 5.8.x
0.69_01 2019-01-09 15:59:43 -0500
- require Alien::FFI in fallback mode
0.68_01 2019-01-05 21:12:47 -0500
- Improve platform probing of complex type
- Allow override of platform probing using FFI_PLATYPUS_PROBE_OVERRIDE
0.67_01 2019-01-05 09:16:22 -0500
- Better support for complex types: pointers to complex types and complex
type and pointers to complex as return value
0.66_01 2019-01-04 20:16:59 -0500
- EXPERIMENTAL ExtUtils::MakeMaker fixes for dynamic prereqs on windows
- restore FFI_PLATYPUS_DEBUG_FAKE32
- restore FFI_PLATYPUS_NO_ALLOCA
0.65_01 2019-01-04 13:38:58 -0500
- EXPERIMENTAL ExtUtils::MakeMaker fixes for parallel and freebsd build
0.64_01 2019-01-03 03:16:57 -0500
- EXPERIMENTAL ExtUtils::MakeMaker fixes for MSWin32 / cygwin
0.63_01 2019-01-02 11:23:48 -0500
- EXPERIMENTAL ExtUtils::MakeMaker release
0.62_01 2019-01-01 04:23:23 -0500
- New type: array of string "string [x]" and "string []" are supported
- NULL terminated arrays are supported as return types for string and opaque
arrays "opaque []" and "string []"
0.61_01 2018-12-31 19:56:20 -0500
- New type: pointers to string "string *" are supported.
- FFI::Platypus::Type::StringPointer is now deprecated.
0.60_01 2018-12-30 14:55:15 -0500
- sticky/unstick functions can safely be called multiple times
- Removed some extra lookups from closure calls, should be faster now.
0.59 2018-12-16 16:33:37 -0700
- Workaround for possibly buggy pack/unpack on Perl 5.8.8 gh#91
Fixes FFI::Platypus::Type::StringArray
0.58 2018-11-20 14:31:10 -0500
- Add unstick method to FFI::Platypus::Closure
0.57_01 2018-11-04 15:36:33 -0500
- Major refactor of the internals of the type system. The API is
the same but some type meta-data (which was never guaranteed
to stay the same) may have changed.
* The internal representation of types is much smaller (4 bytes
for simple types), which can save a lot of memory if you have
lots of types.
* Fixed width strings example: `string(32)` are now internally
treated the same as a record with no class `record(32)`.
Previously these were separate types but worked identically,
this removes duplicate code.
* Fixed width string arguments to a closure are now read-only,
Usually you should be copying these arguments anyway.
* Removed the internal type "exotic float" which includes
`long double`, `complex float` and `complex double`. These are
now grouped internally with other scalar types.
- Merge FFI::Platypus::Type::StringArray into this distribution
0.56 2018-09-03 09:17:42 -0400
- lib method accepts code reference which will be called immediately
and results added to lib list
0.55 2018-08-29 10:37:36 -0400
- Production release identical to 0.54_03
0.54_03 2018-08-28 10:46:04 -0400
- Additional test diagnostics.
0.54_02 2018-08-28 05:30:04 -0400
- record as closure argument is now read-only. This makes
sense since such records are actually copies. For when
you need a non-copy use an opaque type instead. This allows
records with rw strings (although they will be ro in the
closure).
0.54_01 2018-08-16 03:27:31 -0400
- Experimental: allow record as closure argument
Records with string_rw are not supported, and
will likely crash your script if you try to use
them. Support for such records is probably not in
the cards, but a future version may disallow them
to avoid crashes.
- Closure objects now have a sticky method, similar to what
is already available in the discouraged FFI::Platypus::Declare
interface
0.53 2018-08-15 20:38:29 -0400
- Production release identical to 0.52_04
0.52_04 2018-08-15 05:52:15 -0400
- Work-around for Strawberry Perl 5.14.4 unicode bug (see gh#85)
0.52_03 2018-08-14 15:28:19 -0400
- Major refactoring of test suite
0.52_02 2018-08-14 08:05:07 -0400
- Added standard RTLD_ constants to FFI::Platypus::DL
- Fixed long standing but till now unused bug on Windows where dlopen was
returning a handle for libraries that weren't actually being loaded.
0.52_01 2018-08-13 20:39:32 -0400
- Testing: moved libtest to t/ffi, using the same convention as FFI::Build
- Added FFI::Platypus::DL. Previously this had been (under a different
name) a private interface to libdl used by FFI::Platypus under the covers.
On Windows it is an emulation layer over the native equivalents.
0.51 2018-08-09 03:14:15 -0400
- update the package method to work with FFI-Build
0.50 2018-06-01 07:58:33 -0400
- Additional diagnostics
0.49_05 2018-05-29 12:44:45 -0400
- Require Alien::FFI 0.20 for bugfixes
0.49_04 2018-05-27 07:36:58 -0400
- Additional diagnostics
- Added a FAQ section. Some other minor documentation enhancements.
0.49_03 2018-05-19 10:09:15 -0400
- The previous version contained build files that would break the install
unless you were building on my machine. This is what the previous
version should have been.
0.49_02 2018-05-18 22:08:43 -0400
- Fix version mismatch error with XS
0.49_01 2018-05-18 16:16:13 -0400
- Move the source repository for this project into the GitHub org Perl5-FFI
The new URL is https://github.org/Perl5-FFI/FFI-Platypus
- Remove dependency on JSON::PP, use Data::Dumper for build configuration.
This may improve startup performance.
0.48 2018-02-20 09:37:32 -0500
- setting lib => undef is now the same as setting it to [undef] in the
constructor (previously lib => undef was ignored)
0.47 2017-03-23 18:26:01 -0400
- Fix installer bug where My::ShareConfig was accidentally declared as a
prereq
0.46 2017-03-23 15:47:29 -0400
- Remove some internal use of Module::Build with the intent of one day
migrating to EUMM or some other installer
- Remove Module::Build::FFI. It now has its own distribution.
- Prefix the lang attribute with an equal '=' sign to indicate a fully
qualified class name instead of one under FFI::Platypus::Lang
0.45 2016-10-24 07:59:57 -0400
- Remove check for Threaded Perl / OpenBSD, as the issue there has been
reported fixed
0.44 2016-10-20 14:31:23 -0400
- You can now control which implementation of strdup FFI::Platypus::Memory
uses via the FFI_PLATYPUS_MEMORY_STRDUP_IMPL environment variable.
0.43 2016-07-08 03:28:57 -0400
- Numerous fixes for systems with 64bit big-endian arch
(previously only 32bit big-endian had been tested)
- Officially discourage the use of FFI::Platypus::Declare
0.42 2016-05-06 16:31:01 -0400
- Support for MSYS2
0.41 2016-04-09 16:03:07 -0400
- For the return value undef can be passed in to mean 'void'.
- Fixed installer bug where ABI probe would silently fail if /tmp
was mounted noexec
- Avoid unnecessary downgrade on when Perl is compiled to use longdouble
0.40 2015-08-29 08:45:19 -0400
- Closure declarations ignore white space between () and ->
0.39 2015-08-24 03:23:10 -0400
- Fixed spurious warning: auto loading of record class (via
FFI::Platypus::Record) was ALWAYS warning, when it should have only been
warning on load failure.
0.38 2015-08-13 17:13:07 -0400
- closure method now comes with a more useful diagnostic thinks to
Carp::croak
- Added a check for standard C headers. This seems to help the configure
stage find ptrdiff_t, which was frequently not detected correctly
(at least on Linux).
- Improved thread safety by using MY_CXT for some very infrequently used
global variables.
- Added IRC meta data information for metacpan.org. Please join us at
#native on irc.perl.org!
- Many minor documentation corrections and tweaks. Most significant is
that Convert::Binary::C can now be recommended as it is once again
properly maintained.
- Added tests for threads and forks. If these tests fail in your environment
please let me know!
0.37 2015-05-29 14:28:21 -0400
- Added compatibility back in for older version of constant
(newer one is not available on CPAN yet)
0.36 2015-05-29 13:40:32 -0400
- Explicitly require constant pragma version 1.32
0.35 2015-05-29 12:06:39 -0400
- FFI::Platypus::Record uses constant to create size of alignment constants
instead of creating them with a sub reference (this usage was deprecated
in Perl 5.22)
0.34 2015-05-07 09:27:04 -0400
- Require Alien::FFI which is more reliable at configure time on some
platforms
0.33 2015-03-23 21:55:02 -0400
- Additional fix for Microsoft Visual C++ that didn't get folded into
the previous release.
- Fixed segfault during global destruction (gh#53)
0.32 2015-03-18 13:02:53 -0400
- Make sure -L flags from Alien::FFI come before those in perl Config
For more reliable builds
- Support for Microsoft Visual C++ (you will probably also need
Alien::FFI 0.09 or beter)
0.31 2015-02-26 13:41:23 -0500
- Fix bug involving wide custom arguments
"wide" meaning where a single Perl argument is translated
into multiple machine code arguments. (pipcet++ gh#43)
0.30 2015-02-25 17:50:54 -0500
- You can now pass an opaque in place of a closure type (pipcet++ gh#40,gh#41)
- FFI closures are now cached and can be reused if the same closure is passed
repeatedly (pipcet++ gh#40,gh#42)
- Passing non-reference to scalar as a pointer argument will now issue a
warning (gh#5)
0.29 2015-02-24 08:50:34 -0500
- Delayed loading of Win32::ErrorMode to avoid build prereq failure on Windows
0.28 2015-02-23 14:01:54 -0500
- Fix Win32 probe prereq on non-Strawberry 5.20.x+
- Fix for Solaris cc
0.27 2015-02-22 11:17:05 -0500
- Interface to alternate ABIs / calling conventions
- Added abi method
- Added abis class method
- Simplify Win32 probe
- Added FFI::Platypus::Lang::Win32 which provides data types used by
the Windows API. Takes care of subtle differences between
Win32 and Win64.
- Fixed bugs specific to 5.8.x
- Language plugins can now specify an ABI with abi class method
- Default ABI for FFI::Platypus::Lang::Win32 is stdcall on 32bit windows
0.26 2015-02-18 17:47:43 -0500
- Added support for pointers to longdouble (in C "long double *") type
- Added support for array of longdouble (in C "long double []") type
- Added tied array interface for record array members (see
FFI::Platypus::Record::TieArray) Marked as EXPERIMENTAL
- Array members of records can now be accessed (set/get) by element
- Array members of records types are now documented (see
FFI::Platypus::Record)
- Bugfix: array wasn't being updated on return for variable length
array types
- Should now build with an Alien::FFI that was built with ALIEN_FORCE=1
0.25 2015-02-16 20:18:41 -0500
- Probe for proper long double support instead of trusting ffi.h
- This disables long double support on cygwin, which does not seem to
work, at least in so far as it seems to work on other platforms
patches to prove otherwise are welcome.
0.24 2015-02-16 15:38:58 -0500
- Fixed Windows / Strawberry configuration issues
0.23 2015-02-16 05:44:39 -0500
- Support for longdouble (in C "long double") type.
- Support for complex_float (in C "float complex") type
- Support for complex_double (in C "double complex") type
- Fixes for Big Endian architectures (tested on Linux PowerPC)
0.22 2015-02-12 07:47:32 -0500
- Variable length arrays
- More recent version of Config::AutoConf required in the configure step
(gh#33 zmughal)
- Documentation improvements and additional examples, including a
crazy Java one
0.21 2015-02-09 06:23:03 -0500
- Added FFI::Platypus#alignof method
- Added FFI::Platypus::Record module
- Added fixed length strings example: string(10)
- Added ro and rw trait for strings
0.20 2015-02-05 14:06:11 -0500
- Added optional wrapper argument to FFI::Platypus#attach
and FFI::Platypus::Declare#attach
- Added FFI::Platypus#find_lib method
- FFI::CheckLib is now a runtime requirement for Platypus
- Bumped Alien::FFI requirement to 0.06
0.19 2015-02-03 13:34:53 -0500
- Accept additional extensions, in addition to dlext
Example: on OS X both .bundle and .dylib can be used
Example: although arguably wrong, on cygwin sometimes .so is used
- Added Module::Build::FFI->ffi_dlext class method
0.18 2015-01-30 15:22:07 -0500
- Improved support for C++ in Module::Build::FFI
- Module::Build::FFI can now be subclassed to support foreign
languages other than C and C++. See Module::Build::FFI::Rust as an
example.
- Added a hook to allow different names for native types. See
FFI::Platypus::Lang::Rust for an example.
- Added a hook to allow mangling of symbol (function) names. See
FFI::Platypus::Lang::CPP for an example with C++
- Module::Build::FFI#ffi_include_dir can now be an array reference
- Module::Build::FFI#ffi_source_dir can now be an array reference
- Module::Build::FFI#ffi_libtest_dir can now be an array reference
- Module::Build::FFI will build assembly source files (with .s
extensions) in the libtest and ffi directories
0.17 2015-01-28 11:11:02 -0500
- Allow integer and floating point type default to 0 when not provided
without warning
- You can now take the sizeof a custom type (it will be the size of
the native type that is actually passed on the C argument stack).
- Sizeof should be faster now as it doesn't look up the other meta
information or create a hash to contain it
- Added record type see FFI::Platypus::Type#Records
- Added bool as a primitive type.
0.16 2015-01-23 17:31:00 -0500
- Bumping Alien::FFI version requirement up to 0.04
Thus indirectly Alien::Base to 0.07
Believe this may fix a cpan testers failure that I am seeing
0.15 2015-01-23 16:46:27 -0500
- add FFI::Platypus#ignore_not_found attribute
- add FFI::Platypus#package method
- Module::Build::FFI was moved into this distribution
(formerly distributed as part of FFI-Util)
- added aliases: uchar, ushort, uint and ulong
0.14 2015-01-22 08:19:42 -0500
- Fixed some broken links in the documentation
0.12 2015-01-21 23:22:16 -0500
- First CPAN release
- Improved documentation
- Functionally identically to 0.11
0.11 2015-01-21 16:33:58 -0500
- Release candidate 2
- arguments are available during custom return type even when
platform does not support alloca
- More documentation and examples
- FFI::Platypus::API now use prototypes so you can skip the ()
0.10 2015-01-20 04:06:17 -0500
- Release candidate 1
- Added custom Types API (see FFI::Platypus::API)
- Added String Pointer custom type (FFI::Platypus::Type::StringPointer)
- Added Pointer / Size Buffer custom type
(FFI::Platypus::Type::PointerSizeBuffer)
0.09 2015-01-19 03:01:48 -0500
- Third beta
- moved cast and sizeof from FFI::Platypus::Memory
into FFI::Platypus methods.
- cast and size of functions for FFI::Platypus::Declare
- attach_cast for faster casting
- renamed FFI::Platypus::Declare#function to
FFI::Platypus::Declare#attach to more closely match
the OO interface
- adjusted custom type interface
- renamed ffi_to_perl native_to_perl
- renamed perl_to_ffi perl_to_native
- type argument is now part of the hash and is called
native_type
0.08 2015-01-16 10:55:14 -0500
- Second beta
- add FFI::Platypus::Buffer
stole the buffer functions from FFI::Util
can do this with cast, but cast is slow
- Fixed bug where cast didn't work with closures.
- closure data now free'd when it the closure
goes out of scope (GH#4)
0.07 2015-01-15 18:53:45 -0500
- First (mostly complete) beta
- workaround some issues with closures
- much more comprehensive documentation
0.06 2015-01-14 17:13:57 -0500
- fix typo in last version that broke 32 bit Perls. oops.
0.05 2015-01-14 17:04:25 -0500
- Forth (and mostly complete) alpha
- custom types written in Perl are supported.
- bug fixes for 32 bit Perls (with compilers that support int64_t)
0.04 2015-01-13 11:14:54 -0500
- Third (and incomplete) alpha
- all basic types supported everywhere
- closures do not support non basic types or returning strings from a closure
0.03 2015-01-09 15:40:14 -0500
- Second (and incomplete) alpha
- closure support added (only integer arguments implmented).
- memory leak related to closures will be fixed in the next alpha.
0.02 2015-01-07 17:40:35 -0500
- Early (and incomplete) alpha
0.01 2015-01-07 17:21:27 -0500
- Original (and incompatible) prototype
FFI-Platypus-2.12/Changes.FFI-Build 000644 000000 000000 00000002244 15251066120 016572 0 ustar 00root root 000000 000000 Revision history for {{$dist->name}}
After 0.12 FFI-Build was merged with FFI-Platypus
0.12 2019-01-06 10:23:17 -0500
- Make FFI::Platypus an optional testing dependency
(previously it was a required dependency for testing
only).
0.11 2018-12-20 21:55:50 -0700
- Require EUMM 7.24 for fixes in testing
0.10 2018-12-20 17:51:17 -0700
- Fix bug where build aliens were used
for test only build
0.09 2018-08-28 10:50:27 -0400
- Additional test diagnostics
0.08 2018-08-28 09:58:19 -0400
- Same workaroudn for linkers with space
0.07 2018-08-20 10:52:27 -0400
- Workaround for compilers with space
0.06 2018-08-20 08:57:30 -0400
- Fix test
0.05 2018-08-20 05:17:36 -0400
- Removed FFI::Build::File::Fortran, which is now part of the
FFI-Platypus-Lang-Fortran dist
0.04 2018-08-19 12:56:54 -0400
- When `cc -MM` or `c++ -MM` fails for computing dependencies, fall back
on just the .c file being the dependency.
0.03 2018-08-16 04:03:09 -0400
- Fix for test failure on cygwin + MSWin32
- Additional diagnostics for Fortran build test
0.02 2018-08-09 04:54:30 -0400
- initial version
FFI-Platypus-2.12/Changes.FFI-Platypus-Type-StringArray 000644 000000 000000 00000000372 15251066120 022536 0 ustar 00root root 000000 000000 Revision history for FFI-Platypus-Type-StringArray
After 0.02 FFI-Platypus-Type-StringArray was merged with FFI-Platypus
0.02 2018-07-28 21:34:16 -0400
- Add support as a return type.
0.01 2015-01-23 16:50:47 -0500
- initial version
FFI-Platypus-2.12/INSTALL 000644 000000 000000 00000004553 15251066120 014675 0 ustar 00root root 000000 000000 This is the Perl distribution FFI-Platypus.
Installing FFI-Platypus is straightforward.
## Installation with cpanm
If you have cpanm, you only need one line:
% cpanm FFI::Platypus
If it does not have permission to install modules to the current perl, cpanm
will automatically set up and install to a local::lib in your home directory.
See the local::lib documentation (https://metacpan.org/pod/local::lib) for
details on enabling it in your environment.
## Installing with the CPAN shell
Alternatively, if your CPAN shell is set up, you should just be able to do:
% cpan FFI::Platypus
## Manual installation
As a last resort, you can manually install it. If you have not already
downloaded the release tarball, you can find the download link on the module's
MetaCPAN page: https://metacpan.org/pod/FFI::Platypus
Untar the tarball, install configure prerequisites (see below), then build it:
% perl Makefile.PL
% make && make test
Then install it:
% make install
On Windows platforms, you should use `dmake` or `nmake`, instead of `make`.
If your perl is system-managed, you can create a local::lib in your home
directory to install modules to. For details, see the local::lib documentation:
https://metacpan.org/pod/local::lib
The prerequisites of this distribution will also have to be installed manually. The
prerequisites are listed in one of the files: `MYMETA.yml` or `MYMETA.json` generated
by running the manual build process described above.
## Configure Prerequisites
This distribution requires other modules to be installed before this
distribution's installer can be run. They can be found under the
"configure_requires" key of META.yml or the
"{prereqs}{configure}{requires}" key of META.json.
## Other Prerequisites
This distribution may require additional modules to be installed after running
Makefile.PL.
Look for prerequisites in the following phases:
* to run make, PHASE = build
* to use the module code itself, PHASE = runtime
* to run tests, PHASE = test
They can all be found in the "PHASE_requires" key of MYMETA.yml or the
"{prereqs}{PHASE}{requires}" key of MYMETA.json.
## Documentation
FFI-Platypus documentation is available as POD.
You can run `perldoc` from a shell to read the documentation:
% perldoc FFI::Platypus
For more information on installing Perl modules via CPAN, please see:
https://www.cpan.org/modules/INSTALL.html
FFI-Platypus-2.12/LICENSE 000644 000000 000000 00000046320 15251066120 014647 0 ustar 00root root 000000 000000 This software is copyright (c) 2015-2022 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.
Terms of the Perl programming language system itself
a) the GNU General Public License as published by the Free
Software Foundation; either version 1, or (at your option) any
later version, or
b) the "Artistic License"
--- The GNU General Public License, Version 1, February 1989 ---
This software is Copyright (c) 2015-2022 by Graham Ollis.
This is free software, licensed under:
The GNU General Public License, Version 1, February 1989
GNU GENERAL PUBLIC LICENSE
Version 1, February 1989
Copyright (C) 1989 Free Software Foundation, Inc.
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
Preamble
The license agreements of most software companies try to keep users
at the mercy of those companies. By contrast, our General Public
License is intended to guarantee your freedom to share and change free
software--to make sure the software is free for all its users. The
General Public License applies to the Free Software Foundation's
software and to any other program whose authors commit to using it.
You can use it for your programs, too.
When we speak of free software, we are referring to freedom, not
price. Specifically, the General Public License is designed to make
sure that you have the freedom to give away or sell copies of free
software, that you receive source code or can get it if you want it,
that you can change the software or use pieces of it in new free
programs; and that you know you can do these things.
To protect your rights, we need to make restrictions that forbid
anyone to deny you these rights or to ask you to surrender the rights.
These restrictions translate to certain responsibilities for you if you
distribute copies of the software, or if you modify it.
For example, if you distribute copies of a such a program, whether
gratis or for a fee, you must give the recipients all the rights that
you have. You must make sure that they, too, receive or can get the
source code. And you must tell them their rights.
We protect your rights with two steps: (1) copyright the software, and
(2) offer you this license which gives you legal permission to copy,
distribute and/or modify the software.
Also, for each author's protection and ours, we want to make certain
that everyone understands that there is no warranty for this free
software. If the software is modified by someone else and passed on, we
want its recipients to know that what they have is not the original, so
that any problems introduced by others will not reflect on the original
authors' reputations.
The precise terms and conditions for copying, distribution and
modification follow.
GNU GENERAL PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
0. This License Agreement applies to any program or other work which
contains a notice placed by the copyright holder saying it may be
distributed under the terms of this General Public License. The
"Program", below, refers to any such program or work, and a "work based
on the Program" means either the Program or any work containing the
Program or a portion of it, either verbatim or with modifications. Each
licensee is addressed as "you".
1. You may copy and distribute verbatim copies of the Program's source
code as you receive it, in any medium, provided that you conspicuously and
appropriately publish on each copy an appropriate copyright notice and
disclaimer of warranty; keep intact all the notices that refer to this
General Public License and to the absence of any warranty; and give any
other recipients of the Program a copy of this General Public License
along with the Program. You may charge a fee for the physical act of
transferring a copy.
2. You may modify your copy or copies of the Program or any portion of
it, and copy and distribute such modifications under the terms of Paragraph
1 above, provided that you also do the following:
a) cause the modified files to carry prominent notices stating that
you changed the files and the date of any change; and
b) cause the whole of any work that you distribute or publish, that
in whole or in part contains the Program or any part thereof, either
with or without modifications, to be licensed at no charge to all
third parties under the terms of this General Public License (except
that you may choose to grant warranty protection to some or all
third parties, at your option).
c) If the modified program normally reads commands interactively when
run, you must cause it, when started running for such interactive use
in the simplest and most usual way, to print or display an
announcement including an appropriate copyright notice and a notice
that there is no warranty (or else, saying that you provide a
warranty) and that users may redistribute the program under these
conditions, and telling the user how to view a copy of this General
Public License.
d) You may charge a fee for the physical act of transferring a
copy, and you may at your option offer warranty protection in
exchange for a fee.
Mere aggregation of another independent work with the Program (or its
derivative) on a volume of a storage or distribution medium does not bring
the other work under the scope of these terms.
3. You may copy and distribute the Program (or a portion or derivative of
it, under Paragraph 2) in object code or executable form under the terms of
Paragraphs 1 and 2 above provided that you also do one of the following:
a) accompany it with the complete corresponding machine-readable
source code, which must be distributed under the terms of
Paragraphs 1 and 2 above; or,
b) accompany it with a written offer, valid for at least three
years, to give any third party free (except for a nominal charge
for the cost of distribution) a complete machine-readable copy of the
corresponding source code, to be distributed under the terms of
Paragraphs 1 and 2 above; or,
c) accompany it with the information you received as to where the
corresponding source code may be obtained. (This alternative is
allowed only for noncommercial distribution and only if you
received the program in object code or executable form alone.)
Source code for a work means the preferred form of the work for making
modifications to it. For an executable file, complete source code means
all the source code for all modules it contains; but, as a special
exception, it need not include source code for modules which are standard
libraries that accompany the operating system on which the executable
file runs, or for standard header files or definitions files that
accompany that operating system.
4. You may not copy, modify, sublicense, distribute or transfer the
Program except as expressly provided under this General Public License.
Any attempt otherwise to copy, modify, sublicense, distribute or transfer
the Program is void, and will automatically terminate your rights to use
the Program under this License. However, parties who have received
copies, or rights to use copies, from you under this General Public
License will not have their licenses terminated so long as such parties
remain in full compliance.
5. By copying, distributing or modifying the Program (or any work based
on the Program) you indicate your acceptance of this license to do so,
and all its terms and conditions.
6. Each time you redistribute the Program (or any work based on the
Program), the recipient automatically receives a license from the original
licensor to copy, distribute or modify the Program subject to these
terms and conditions. You may not impose any further restrictions on the
recipients' exercise of the rights granted herein.
7. The Free Software Foundation may publish revised and/or new versions
of the General Public License from time to time. Such new versions will
be similar in spirit to the present version, but may differ in detail to
address new problems or concerns.
Each version is given a distinguishing version number. If the Program
specifies a version number of the license which applies to it and "any
later version", you have the option of following the terms and conditions
either of that version or of any later version published by the Free
Software Foundation. If the Program does not specify a version number of
the license, you may choose any version ever published by the Free Software
Foundation.
8. If you wish to incorporate parts of the Program into other free
programs whose distribution conditions are different, write to the author
to ask for permission. For software which is copyrighted by the Free
Software Foundation, write to the Free Software Foundation; we sometimes
make exceptions for this. Our decision will be guided by the two goals
of preserving the free status of all derivatives of our free software and
of promoting the sharing and reuse of software generally.
NO WARRANTY
9. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
REPAIR OR CORRECTION.
10. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
POSSIBILITY OF SUCH DAMAGES.
END OF TERMS AND CONDITIONS
Appendix: How to Apply These Terms to Your New Programs
If you develop a new program, and you want it to be of the greatest
possible use to humanity, the best way to achieve this is to make it
free software which everyone can redistribute and change under these
terms.
To do so, attach the following notices to the program. It is safest to
attach them to the start of each source file to most effectively convey
the exclusion of warranty; and each file should have at least the
"copyright" line and a pointer to where the full notice is found.
Copyright (C) 19yy
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
the Free Software Foundation; either version 1, or (at your option)
any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, see .
Also add information on how to contact you by electronic and paper mail.
If the program is interactive, make it output a short notice like this
when it starts in an interactive mode:
Gnomovision version 69, Copyright (C) 19xx name of author
Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
This is free software, and you are welcome to redistribute it
under certain conditions; type `show c' for details.
The hypothetical commands `show w' and `show c' should show the
appropriate parts of the General Public License. Of course, the
commands you use may be called something other than `show w' and `show
c'; they could even be mouse-clicks or menu items--whatever suits your
program.
You should also get your employer (if you work as a programmer) or your
school, if any, to sign a "copyright disclaimer" for the program, if
necessary. Here a sample; alter the names:
Yoyodyne, Inc., hereby disclaims all copyright interest in the
program `Gnomovision' (a program to direct compilers to make passes
at assemblers) written by James Hacker.
, 1 April 1989
Moe Ghoul, President of Vice
That's all there is to it!
--- The Perl Artistic License 1.0 ---
This software is Copyright (c) 2015-2022 by Graham Ollis.
This is free software, licensed under:
The Perl Artistic License 1.0
The "Artistic License"
Preamble
The intent of this document is to state the conditions under which a
Package may be copied, such that the Copyright Holder maintains some
semblance of artistic control over the development of the package,
while giving the users of the package the right to use and distribute
the Package in a more-or-less customary fashion, plus the right to make
reasonable modifications.
Definitions:
"Package" refers to the collection of files distributed by the
Copyright Holder, and derivatives of that collection of files
created through textual modification.
"Standard Version" refers to such a Package if it has not been
modified, or has been modified in accordance with the wishes
of the Copyright Holder as specified below.
"Copyright Holder" is whoever is named in the copyright or
copyrights for the package.
"You" is you, if you're thinking about copying or distributing
this Package.
"Reasonable copying fee" is whatever you can justify on the
basis of media cost, duplication charges, time of people involved,
and so on. (You will not be required to justify it to the
Copyright Holder, but only to the computing community at large
as a market that must bear the fee.)
"Freely Available" means that no fee is charged for the item
itself, though there may be fees involved in handling the item.
It also means that recipients of the item may redistribute it
under the same conditions they received it.
1. You may make and give away verbatim copies of the source form of the
Standard Version of this Package without restriction, provided that you
duplicate all of the original copyright notices and associated disclaimers.
2. You may apply bug fixes, portability fixes and other modifications
derived from the Public Domain or from the Copyright Holder. A Package
modified in such a way shall still be considered the Standard Version.
3. You may otherwise modify your copy of this Package in any way, provided
that you insert a prominent notice in each changed file stating how and
when you changed that file, and provided that you do at least ONE of the
following:
a) place your modifications in the Public Domain or otherwise make them
Freely Available, such as by posting said modifications to Usenet or
an equivalent medium, or placing the modifications on a major archive
site such as uunet.uu.net, or by allowing the Copyright Holder to include
your modifications in the Standard Version of the Package.
b) use the modified Package only within your corporation or organization.
c) rename any non-standard executables so the names do not conflict
with standard executables, which must also be provided, and provide
a separate manual page for each non-standard executable that clearly
documents how it differs from the Standard Version.
d) make other distribution arrangements with the Copyright Holder.
4. You may distribute the programs of this Package in object code or
executable form, provided that you do at least ONE of the following:
a) distribute a Standard Version of the executables and library files,
together with instructions (in the manual page or equivalent) on where
to get the Standard Version.
b) accompany the distribution with the machine-readable source of
the Package with your modifications.
c) give non-standard executables non-standard names, and clearly
document the differences in manual pages (or equivalent), together
with instructions on where to get the Standard Version.
d) make other distribution arrangements with the Copyright Holder.
5. You may charge a reasonable copying fee for any distribution of this
Package. You may charge any fee you choose for support of this
Package. You may not charge a fee for this Package itself. However,
you may distribute this Package in aggregate with other (possibly
commercial) programs as part of a larger (possibly commercial) software
distribution provided that you do not advertise this Package as a
product of your own. You may embed this Package's interpreter within
an executable of yours (by linking); this shall be construed as a mere
form of aggregation, provided that the complete Standard Version of the
interpreter is so embedded.
6. The scripts and library files supplied as input to or produced as
output from the programs of this Package do not automatically fall
under the copyright of this Package, but belong to whoever generated
them, and may be sold commercially, and may be aggregated with this
Package. If such scripts or library files are aggregated with this
Package via the so-called "undump" or "unexec" methods of producing a
binary executable image, then distribution of such an image shall
neither be construed as a distribution of this Package nor shall it
fall under the restrictions of Paragraphs 3 and 4, provided that you do
not represent such an executable image as a Standard Version of this
Package.
7. C subroutines (or comparably compiled subroutines in other
languages) supplied by you and linked into this Package in order to
emulate subroutines and variables of the language defined by this
Package shall not be considered part of this Package, but are the
equivalent of input as in Paragraph 6, provided these subroutines do
not change the language in any way that would cause it to fail the
regression tests for the language.
8. Aggregation of this Package with a commercial distribution is always
permitted provided that the use of this Package is embedded; that is,
when no overt attempt is made to make this Package's interfaces visible
to the end user of the commercial distribution. Such use shall not be
construed as a distribution of this Package.
9. The name of the Copyright Holder may not be used to endorse or promote
products derived from this software without specific prior written permission.
10. THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR
IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
The End
FFI-Platypus-2.12/MANIFEST 000644 000000 000000 00000020622 15251066120 014770 0 ustar 00root root 000000 000000 # This file was automatically generated by Dist::Zilla::Plugin::Manifest v6.037
CONTRIBUTING
Changes
Changes.FFI-Build
Changes.FFI-Platypus-Type-StringArray
INSTALL
LICENSE
MANIFEST
META.json
META.yml
Makefile.PL
README
SECURITY
SUPPORT
author.yml
corpus/ffi_build/project-cxx/foo1.cxx
corpus/ffi_build/project-cxx/foo2.cpp
corpus/ffi_build/project1/foo1.c
corpus/ffi_build/project1/foo2.c
corpus/ffi_build/project2/bar.c
corpus/ffi_build/source/foo.c
corpus/ffi_build_file_base/basic.foo
corpus/ffi_build_file_c/basic.c
corpus/ffi_build_file_c/foo1.c
corpus/ffi_build_file_c/foo2.c
corpus/ffi_build_file_c/include/myfoo.h
corpus/ffi_build_file_cxx/basic.cxx
corpus/ffi_build_file_cxx/foo1.cxx
corpus/ffi_build_file_cxx/foo2.cpp
corpus/ffi_build_file_cxx/include/myfoo.h
corpus/ffi_build_mm/lb1/hello.fbx
corpus/ffi_build_mm/lb1/hello1.c
corpus/ffi_build_mm/lb1/hello2.c
corpus/ffi_build_mm/lb1bad/hello.fbx
corpus/ffi_build_mm/lb1bad/hello1.c
corpus/ffi_build_mm/lb1bad/hello2.c
corpus/ffi_build_mm/lb2/hello1.c
corpus/ffi_build_mm/lb2/hello2.c
corpus/ffi_build_mm/project1/ffi/x.c
corpus/ffi_build_mm/project1/ffi/y.c
corpus/ffi_build_mm/project1/ffi/z.c
corpus/ffi_build_mm/project1/t/ffi/a.c
corpus/ffi_build_mm/project1/t/ffi/b.c
corpus/ffi_build_mm/project1/t/ffi/c.c
corpus/ffi_build_plugin/lib1/FFI/Build/Plugin/blank.txt
corpus/ffi_build_plugin/lib2/FFI/Build/Plugin/Foo1.pm
corpus/ffi_build_plugin/lib2/FFI/Build/Plugin/Foo2.pm
corpus/ffi_probe_runner/bar.c
corpus/ffi_probe_runner/foo.c
corpus/memory/arg_array.pl
corpus/memory/arg_custom.pl
corpus/memory/arg_object.pl
corpus/memory/arg_pointer.pl
corpus/memory/arg_scalar.pl
corpus/memory/attach.pl
corpus/memory/empty.pl
corpus/memory/function.pl
corpus/memory/return_array.pl
corpus/memory/return_custom.pl
corpus/memory/return_object.pl
corpus/memory/return_pointer.pl
corpus/memory/return_scalar.pl
corpus/memory/supp/basic_type_cache.supp
dist.ini
examples/add.c
examples/add.pl
examples/archive.pl
examples/archive.tar
examples/archive_object.pl
examples/array_reverse.c
examples/array_reverse.pl
examples/array_sum.c
examples/array_sum.pl
examples/bundle-answer/ffi/answer.c
examples/bundle-answer/ffi/answer.fbx
examples/bundle-answer/include/answer.h
examples/bundle-answer/lib/Answer.pm
examples/bundle-answer/t/answer.t
examples/bundle-bzip2/ffi/bz2.fbx
examples/bundle-bzip2/ffi/compress.c
examples/bundle-bzip2/lib/Bzip2.pm
examples/bundle-bzip2/t/bzip2.t
examples/bundle-const/ffi/const.c
examples/bundle-const/ffi/myheader.h
examples/bundle-const/lib/Const.pm
examples/bundle-const/t/const.t
examples/bundle-foo/Makefile.PL
examples/bundle-foo/ffi/foo.c
examples/bundle-foo/lib/Foo.pm
examples/bundle-foo/t/foo.t
examples/bundle-init/ffi/init.c
examples/bundle-init/lib/Init.pm
examples/bundle-init/t/init.t
examples/char.pl
examples/closure-opaque.pl
examples/closure.c
examples/closure.pl
examples/color.c
examples/color.pl
examples/curl.pl
examples/curl_callback.pl
examples/file_handle.pl
examples/file_handle.txt
examples/list_integer_types.pl
examples/malloc.pl
examples/math.pl
examples/notify.pl
examples/notify.png
examples/person.c
examples/person.pl
examples/pipe.pl
examples/puts.pl
examples/string_reverse.c
examples/string_reverse.pl
examples/swap.c
examples/swap.pl
examples/tcod.pl
examples/time.pl
examples/time_record.pl
examples/time_struct.pl
examples/var_array.c
examples/var_array.pl
examples/win32_beep.pl
examples/win32_getSystemTime.pl
examples/win32_messagebox.pl
examples/win32_messagebox.png
examples/xor_cipher.c
examples/xor_cipher.pl
examples/zmq3.pl
ffi/constant.c
ffi/memory.c
ffi/record_meta.c
inc/Alien/Base/Wrapper.pm
inc/Alien/FFI/PkgConfigPP.pm
inc/Alien/FFI/Vcpkg.pm
inc/Alien/FFI/pkgconfig.pm
inc/Alien/psapi.pm
inc/My/BuildConfig.pm
inc/My/Config.pm
inc/My/ConfigH.pm
inc/My/ConfigPl.pm
inc/My/ShareConfig.pm
inc/abi/abis-all.json
inc/abi/compute-all.pl
inc/bad-5100t.pl
inc/bad-forks.pl
inc/bad-oldperl.pl
inc/mm-build.pl
inc/mm-clean.pl
inc/mm-config-pb.pl
inc/mm-config-set.pl
inc/mm-config.pl
inc/mm-test.pl
inc/mymm.pl
inc/pdb
inc/probe/abi.c
inc/probe/alloca.c
inc/probe/bigendian.c
inc/probe/bigendian64.c
inc/probe/complex.c
inc/probe/longdouble.c
inc/probe/recordvalue.c
inc/probe/strnlen.c
inc/probe/variadic.c
include/ffi_platypus.h
include/ffi_platypus_bundle.h
include/ffi_platypus_call.h
include/ffi_platypus_guts.h
include/libtest.h
include/perl_math_int64.h
include/ppport.h
lib/FFI/Build.pm
lib/FFI/Build/File/Base.pm
lib/FFI/Build/File/C.pm
lib/FFI/Build/File/CXX.pm
lib/FFI/Build/File/Library.pm
lib/FFI/Build/File/Object.pm
lib/FFI/Build/MM.pm
lib/FFI/Build/Platform.pm
lib/FFI/Build/Plugin.pm
lib/FFI/Build/PluginData.pm
lib/FFI/Platypus.pm
lib/FFI/Platypus.xs
lib/FFI/Platypus/API.pm
lib/FFI/Platypus/Buffer.pm
lib/FFI/Platypus/Bundle.pm
lib/FFI/Platypus/Closure.pm
lib/FFI/Platypus/Constant.pm
lib/FFI/Platypus/DL.pm
lib/FFI/Platypus/Function.pm
lib/FFI/Platypus/Internal.pm
lib/FFI/Platypus/Lang.pm
lib/FFI/Platypus/Lang/ASM.pm
lib/FFI/Platypus/Lang/C.pm
lib/FFI/Platypus/Lang/Win32.pm
lib/FFI/Platypus/Legacy.pm
lib/FFI/Platypus/Memory.pm
lib/FFI/Platypus/Record.pm
lib/FFI/Platypus/Record/Meta.pm
lib/FFI/Platypus/Record/TieArray.pm
lib/FFI/Platypus/ShareConfig.pm
lib/FFI/Platypus/Type.pm
lib/FFI/Platypus/Type/PointerSizeBuffer.pm
lib/FFI/Platypus/Type/StringArray.pm
lib/FFI/Platypus/Type/StringPointer.pm
lib/FFI/Platypus/Type/WideString.pm
lib/FFI/Platypus/TypeParser.pm
lib/FFI/Platypus/TypeParser/Version0.pm
lib/FFI/Platypus/TypeParser/Version1.pm
lib/FFI/Platypus/TypeParser/Version2.pm
lib/FFI/Probe.pm
lib/FFI/Probe/Runner.pm
lib/FFI/Probe/Runner/Builder.pm
lib/FFI/Probe/Runner/Result.pm
lib/FFI/Temp.pm
lib/FFI/typemap
maint/cip-before-install
maint/cip-test-examples
maint/generate-abw
maint/generate-readme
maint/generate-record-accessor
maint/run-after_build.pl
maint/run-before_build.pl
maint/tt/accessor.tt
maint/tt/accessor_wrapper.tt
perlcriticrc
t/00_diag.t
t/ffi/align.c
t/ffi/align_array.c
t/ffi/align_fixed.c
t/ffi/align_string.c
t/ffi/basic.c
t/ffi/closure.c
t/ffi/color.c
t/ffi/complex_double.c
t/ffi/complex_float.c
t/ffi/double.c
t/ffi/float.c
t/ffi/gh117.c
t/ffi/gh174.c
t/ffi/longdouble.c
t/ffi/memcmp4.c
t/ffi/meta.c
t/ffi/pointer.c
t/ffi/record.c
t/ffi/sint16.c
t/ffi/sint32.c
t/ffi/sint64.c
t/ffi/sint8.c
t/ffi/string.c
t/ffi/string_array.c
t/ffi/uint16.c
t/ffi/uint32.c
t/ffi/uint64.c
t/ffi/uint8.c
t/ffi/variadic.c
t/ffi_build.t
t/ffi_build_file_base.t
t/ffi_build_file_c.t
t/ffi_build_file_cxx.t
t/ffi_build_file_library.t
t/ffi_build_file_object.t
t/ffi_build_mm.t
t/ffi_build_platform.t
t/ffi_build_plugin.t
t/ffi_build_plugindata.t
t/ffi_platypus.t
t/ffi_platypus_api.t
t/ffi_platypus_buffer.t
t/ffi_platypus_bundle.t
t/ffi_platypus_closure.t
t/ffi_platypus_constant.t
t/ffi_platypus_dl.t
t/ffi_platypus_function.t
t/ffi_platypus_function_wrapper.t
t/ffi_platypus_internal.t
t/ffi_platypus_lang.t
t/ffi_platypus_lang_asm.t
t/ffi_platypus_lang_c.t
t/ffi_platypus_lang_win32.t
t/ffi_platypus_legacy.t
t/ffi_platypus_memory.t
t/ffi_platypus_record.t
t/ffi_platypus_record_meta.t
t/ffi_platypus_record_tiearray.t
t/ffi_platypus_shareconfig.t
t/ffi_platypus_type.t
t/ffi_platypus_type_pointersizebuffer.t
t/ffi_platypus_type_stringarray.t
t/ffi_platypus_type_stringpointer.t
t/ffi_platypus_type_widestring.t
t/ffi_platypus_typeparser.t
t/ffi_platypus_typeparser_version0.t
t/ffi_platypus_typeparser_version1.t
t/ffi_platypus_typeparser_version2.t
t/ffi_probe.t
t/ffi_probe_runner.t
t/ffi_probe_runner_builder.t
t/ffi_probe_runner_result.t
t/ffi_temp.t
t/forks.t
t/gh117.t
t/gh129.t
t/gh260.t
t/gh323.t
t/lib/Test/Cleanup.pm
t/lib/Test/FauxAttach.pm
t/lib/Test/Platypus.pm
t/memory.t
t/threads.t
t/type_complex_double.t
t/type_complex_float.t
t/type_custom.t
t/type_double.t
t/type_float.t
t/type_longdouble.t
t/type_longdouble__array.t
t/type_longdouble__hide.t
t/type_longdouble__ptr.t
t/type_opaque.t
t/type_record.t
t/type_record_value.t
t/type_sint16.t
t/type_sint32.t
t/type_sint64.t
t/type_sint8.t
t/type_string.t
t/type_uint16.t
t/type_uint32.t
t/type_uint64.t
t/type_uint8.t
xs/ABI.xs
xs/API.xs
xs/Buffer.xs
xs/Closure.xs
xs/ClosureData.xs
xs/DL.xs
xs/Function.xs
xs/Internal.xs
xs/Record.xs
xs/Type.xs
xs/TypeParser.xs
xs/cast.c
xs/closure.c
xs/complex.c
xs/custom.c
xs/meta.c
xs/names.c
xs/perl_math_int64.c
xs/record_opaque.c
xs/record_simple.c
xs/record_string.c
xs/windl.c
xt/author/critic.t
xt/author/eol.t
xt/author/example.t
xt/author/no_tabs.t
xt/author/pod.t
xt/author/pod_coverage.t
xt/author/pod_link.t
xt/author/pod_spelling_system.t
xt/author/version.t
xt/release/changes.t
xt/release/fixme.t
FFI-Platypus-2.12/META.json 000644 000000 000000 00000021213 15251066120 015255 0 ustar 00root root 000000 000000 {
"abstract" : "Write Perl bindings to non-Perl libraries with FFI. No XS required.",
"author" : [
"Graham Ollis "
],
"dynamic_config" : 1,
"generated_by" : "Dist::Zilla version 6.037, CPAN::Meta::Converter version 2.150010",
"license" : [
"perl_5"
],
"meta-spec" : {
"url" : "http://search.cpan.org/perldoc?CPAN::Meta::Spec",
"version" : 2
},
"name" : "FFI-Platypus",
"no_index" : {
"directory" : [
"examples"
]
},
"prereqs" : {
"build" : {
"requires" : {
"Alien::FFI" : "0.20",
"ExtUtils::CBuilder" : "0"
}
},
"configure" : {
"requires" : {
"Capture::Tiny" : "0",
"ExtUtils::MakeMaker" : "7.12",
"ExtUtils::ParseXS" : "3.30",
"IPC::Cmd" : "0",
"JSON::PP" : "0",
"parent" : "0",
"perl" : "5.006"
}
},
"develop" : {
"recommends" : {
"Dist::Zilla::Plugin::AlienBase::Wrapper::Bundle" : "0.26",
"Dist::Zilla::Plugin::Author::Plicease::Thanks" : "0",
"Dist::Zilla::Plugin::Author::Plicease::Upload" : "0",
"Dist::Zilla::Plugin::CopyFilesFromBuild" : "0",
"Dist::Zilla::Plugin::InsertExample" : "0.10",
"Dist::Zilla::Plugin::Meta::Dynamic::Config" : "0",
"Dist::Zilla::Plugin::MetaNoIndex" : "0",
"Dist::Zilla::Plugin::PPPort" : "0",
"Dist::Zilla::Plugin::Prereqs" : "0",
"Dist::Zilla::Plugin::PruneFiles" : "0",
"Dist::Zilla::Plugin::RemovePrereqs" : "0",
"Dist::Zilla::PluginBundle::Author::Plicease" : "2.69",
"ExtUtils::MakeMaker" : "0",
"Perl::Critic::Policy::BuiltinFunctions::ProhibitBooleanGrep" : "0",
"Perl::Critic::Policy::BuiltinFunctions::ProhibitStringySplit" : "0",
"Perl::Critic::Policy::BuiltinFunctions::ProhibitVoidGrep" : "0",
"Perl::Critic::Policy::BuiltinFunctions::ProhibitVoidMap" : "0",
"Perl::Critic::Policy::ClassHierarchies::ProhibitExplicitISA" : "0",
"Perl::Critic::Policy::ClassHierarchies::ProhibitOneArgBless" : "0",
"Perl::Critic::Policy::CodeLayout::ProhibitHardTabs" : "0",
"Perl::Critic::Policy::CodeLayout::ProhibitTrailingWhitespace" : "0",
"Perl::Critic::Policy::CodeLayout::RequireConsistentNewlines" : "0",
"Perl::Critic::Policy::Community::ArrayAssignAref" : "0",
"Perl::Critic::Policy::Community::BarewordFilehandles" : "0",
"Perl::Critic::Policy::Community::ConditionalDeclarations" : "0",
"Perl::Critic::Policy::Community::ConditionalImplicitReturn" : "0",
"Perl::Critic::Policy::Community::DeprecatedFeatures" : "0",
"Perl::Critic::Policy::Community::DiscouragedModules" : "0",
"Perl::Critic::Policy::Community::DollarAB" : "0",
"Perl::Critic::Policy::Community::Each" : "0",
"Perl::Critic::Policy::Community::IndirectObjectNotation" : "0",
"Perl::Critic::Policy::Community::LexicalForeachIterator" : "0",
"Perl::Critic::Policy::Community::LoopOnHash" : "0",
"Perl::Critic::Policy::Community::ModPerl" : "0",
"Perl::Critic::Policy::Community::OpenArgs" : "0",
"Perl::Critic::Policy::Community::OverloadOptions" : "0",
"Perl::Critic::Policy::Community::POSIXImports" : "0",
"Perl::Critic::Policy::Community::PackageMatchesFilename" : "0",
"Perl::Critic::Policy::Community::PreferredAlternatives" : "0",
"Perl::Critic::Policy::Community::StrictWarnings" : "0",
"Perl::Critic::Policy::Community::Threads" : "0",
"Perl::Critic::Policy::Community::Wantarray" : "0",
"Perl::Critic::Policy::Community::WarningsSwitch" : "0",
"Perl::Critic::Policy::Community::WhileDiamondDefaultAssignment" : "0",
"Perl::Critic::Policy::ControlStructures::ProhibitLabelsWithSpecialBlockNames" : "0",
"Perl::Critic::Policy::ControlStructures::ProhibitMutatingListFunctions" : "0",
"Perl::Critic::Policy::ControlStructures::ProhibitUnreachableCode" : "0",
"Perl::Critic::Policy::InputOutput::ProhibitBarewordFileHandles" : "0",
"Perl::Critic::Policy::InputOutput::ProhibitJoinedReadline" : "0",
"Perl::Critic::Policy::InputOutput::ProhibitTwoArgOpen" : "0",
"Perl::Critic::Policy::Miscellanea::ProhibitFormats" : "0",
"Perl::Critic::Policy::Miscellanea::ProhibitUselessNoCritic" : "0",
"Perl::Critic::Policy::Modules::ProhibitConditionalUseStatements" : "0",
"Perl::Critic::Policy::Modules::RequireNoMatchVarsWithUseEnglish" : "0",
"Perl::Critic::Policy::Objects::ProhibitIndirectSyntax" : "0",
"Perl::Critic::Policy::RegularExpressions::ProhibitUselessTopic" : "0",
"Perl::Critic::Policy::Subroutines::ProhibitNestedSubs" : "0",
"Perl::Critic::Policy::ValuesAndExpressions::ProhibitLeadingZeros" : "0",
"Perl::Critic::Policy::ValuesAndExpressions::ProhibitMixedBooleanOperators" : "0",
"Perl::Critic::Policy::ValuesAndExpressions::ProhibitSpecialLiteralHeredocTerminator" : "0",
"Perl::Critic::Policy::ValuesAndExpressions::RequireUpperCaseHeredocTerminator" : "0",
"Perl::Critic::Policy::Variables::ProhibitPerl4PackageNames" : "0",
"Perl::Critic::Policy::Variables::ProhibitUnusedVariables" : "0",
"Software::License::Perl_5" : "0"
},
"requires" : {
"Alien::Libbz2" : "0",
"CHI" : "0",
"Convert::Binary::C" : "0",
"Devel::Hide" : "0",
"Devel::PPPort" : "3.28",
"FFI::C" : "0",
"File::chdir" : "0",
"FindBin" : "0",
"HTTP::Tiny::Mech" : "0",
"Path::Tiny" : "0.130",
"Perl::Critic" : "0",
"Test2::Require::EnvVar" : "0.000121",
"Test2::Require::Module" : "0.000121",
"Test2::Tools::PerlCritic" : "0",
"Test2::V0" : "0.000121",
"Test::CPAN::Changes" : "0",
"Test::EOL" : "0",
"Test::Fixme" : "0.07",
"Test::More" : "0.98",
"Test::NoTabs" : "0",
"Test::Pod" : "0",
"Test::Pod::Coverage" : "0",
"Test::Pod::LinkCheck::Lite" : "0",
"Test::Script" : "0",
"Test::Spelling" : "0",
"WWW::Mechanize::Cached" : "0",
"YAML" : "0"
}
},
"runtime" : {
"requires" : {
"Capture::Tiny" : "0",
"ExtUtils::MakeMaker" : "7.12",
"FFI::CheckLib" : "0.05",
"File::Spec::Functions" : "0",
"IPC::Cmd" : "0",
"JSON::PP" : "0",
"List::Util" : "1.45",
"autodie" : "0",
"constant" : "1.32",
"parent" : "0",
"perl" : "5.008004"
}
},
"test" : {
"requires" : {
"Capture::Tiny" : "0",
"Test2::API" : "1.302015",
"Test2::V0" : "0.000121",
"perl" : "5.008004"
}
}
},
"release_status" : "stable",
"resources" : {
"bugtracker" : {
"web" : "https://github.com/PerlFFI/FFI-Platypus/issues"
},
"homepage" : "https://pl.atypus.org",
"repository" : {
"type" : "git",
"url" : "git://github.com/PerlFFI/FFI-Platypus.git",
"web" : "https://github.com/PerlFFI/FFI-Platypus"
},
"x_IRC" : "irc://irc.perl.org/#native",
"x_twitter" : "https://fosstodon.org/@PerlFFI"
},
"version" : "2.12",
"x_contributors" : [
"Graham Ollis ",
"Bakkiaraj Murugesan (bakkiaraj)",
"Dylan Cali (calid)",
"pipcet",
"Zaki Mughal (zmughal)",
"Fitz Elliott (felliott)",
"Vickenty Fesunov (vyf)",
"Gregor Herrmann (gregoa)",
"Shlomi Fish (shlomif)",
"Damyan Ivanov",
"Ilya Pavlov (Ilya33)",
"Petr P\u00edsa\u0159 (ppisar)",
"Mohammad S Anwar (MANWAR)",
"H\u00e5kon H\u00e6gland (hakonhagland, HAKONH)",
"Meredith (merrilymeredith, MHOWARD)",
"Diab Jerius (DJERIUS)",
"Eric Brine (IKEGAMI)",
"szTheory",
"Jos\u00e9 Joaqu\u00edn Atria (JJATRIA)",
"Pete Houston (openstrike, HOUSTON)",
"Lukas Mai (MAUKE)"
],
"x_generated_by_perl" : "v5.42.3",
"x_serialization_backend" : "Cpanel::JSON::XS version 4.43",
"x_spdx_expression" : "Artistic-1.0-Perl OR GPL-1.0-or-later",
"x_use_unsafe_inc" : 0
}
FFI-Platypus-2.12/META.yml 000644 000000 000000 00000003710 15251066120 015107 0 ustar 00root root 000000 000000 ---
abstract: 'Write Perl bindings to non-Perl libraries with FFI. No XS required.'
author:
- 'Graham Ollis '
build_requires:
Alien::FFI: '0.20'
Capture::Tiny: '0'
ExtUtils::CBuilder: '0'
Test2::API: '1.302015'
Test2::V0: '0.000121'
perl: '5.008004'
configure_requires:
Capture::Tiny: '0'
ExtUtils::MakeMaker: '7.12'
ExtUtils::ParseXS: '3.30'
IPC::Cmd: '0'
JSON::PP: '0'
parent: '0'
perl: '5.006'
dynamic_config: 1
generated_by: 'Dist::Zilla version 6.037, CPAN::Meta::Converter version 2.150010'
license: perl
meta-spec:
url: http://module-build.sourceforge.net/META-spec-v1.4.html
version: '1.4'
name: FFI-Platypus
no_index:
directory:
- examples
requires:
Capture::Tiny: '0'
ExtUtils::MakeMaker: '7.12'
FFI::CheckLib: '0.05'
File::Spec::Functions: '0'
IPC::Cmd: '0'
JSON::PP: '0'
List::Util: '1.45'
autodie: '0'
constant: '1.32'
parent: '0'
perl: '5.008004'
resources:
IRC: irc://irc.perl.org/#native
Twitter: https://fosstodon.org/@PerlFFI
bugtracker: https://github.com/PerlFFI/FFI-Platypus/issues
homepage: https://pl.atypus.org
repository: git://github.com/PerlFFI/FFI-Platypus.git
version: '2.12'
x_contributors:
- 'Graham Ollis '
- 'Bakkiaraj Murugesan (bakkiaraj)'
- 'Dylan Cali (calid)'
- pipcet
- 'Zaki Mughal (zmughal)'
- 'Fitz Elliott (felliott)'
- 'Vickenty Fesunov (vyf)'
- 'Gregor Herrmann (gregoa)'
- 'Shlomi Fish (shlomif)'
- 'Damyan Ivanov'
- 'Ilya Pavlov (Ilya33)'
- 'Petr PÃsaÅ™ (ppisar)'
- 'Mohammad S Anwar (MANWAR)'
- 'Håkon Hægland (hakonhagland, HAKONH)'
- 'Meredith (merrilymeredith, MHOWARD)'
- 'Diab Jerius (DJERIUS)'
- 'Eric Brine (IKEGAMI)'
- szTheory
- 'José JoaquÃn Atria (JJATRIA)'
- 'Pete Houston (openstrike, HOUSTON)'
- 'Lukas Mai (MAUKE)'
x_generated_by_perl: v5.42.3
x_serialization_backend: 'YAML::Tiny version 1.76'
x_spdx_expression: 'Artistic-1.0-Perl OR GPL-1.0-or-later'
x_use_unsafe_inc: 0
FFI-Platypus-2.12/Makefile.PL 000644 000000 000000 00000012763 15251066120 015620 0 ustar 00root root 000000 000000 BEGIN {
use strict; use warnings;
unless(eval q{ use 5.008004; 1}) {
print "Perl 5.008004 or better required\n";
exit;
}
}
# This file was automatically generated by Dist::Zilla::Plugin::Author::Plicease::MakeMaker v2.80
use strict;
use warnings;
use 5.008004;
use ExtUtils::MakeMaker 6.64;
require "./inc/mymm.pl";
my %WriteMakefileArgs = (
"ABSTRACT" => "Write Perl bindings to non-Perl libraries with FFI. No XS required.",
"AUTHOR" => "Graham Ollis ",
"BUILD_REQUIRES" => {
"Alien::FFI" => "0.20",
"ExtUtils::CBuilder" => 0
},
"CONFIGURE_REQUIRES" => {
"Capture::Tiny" => 0,
"ExtUtils::MakeMaker" => "7.12",
"ExtUtils::ParseXS" => "3.30",
"IPC::Cmd" => 0,
"JSON::PP" => 0,
"parent" => 0
},
"DISTNAME" => "FFI-Platypus",
"LICENSE" => "perl",
"MIN_PERL_VERSION" => "5.008004",
"NAME" => "FFI::Platypus",
"PM" => {
"lib/FFI/Build.pm" => "\$(INST_LIB)/FFI/Build.pm",
"lib/FFI/Build/File/Base.pm" => "\$(INST_LIB)/FFI/Build/File/Base.pm",
"lib/FFI/Build/File/C.pm" => "\$(INST_LIB)/FFI/Build/File/C.pm",
"lib/FFI/Build/File/CXX.pm" => "\$(INST_LIB)/FFI/Build/File/CXX.pm",
"lib/FFI/Build/File/Library.pm" => "\$(INST_LIB)/FFI/Build/File/Library.pm",
"lib/FFI/Build/File/Object.pm" => "\$(INST_LIB)/FFI/Build/File/Object.pm",
"lib/FFI/Build/MM.pm" => "\$(INST_LIB)/FFI/Build/MM.pm",
"lib/FFI/Build/Platform.pm" => "\$(INST_LIB)/FFI/Build/Platform.pm",
"lib/FFI/Build/Plugin.pm" => "\$(INST_LIB)/FFI/Build/Plugin.pm",
"lib/FFI/Build/PluginData.pm" => "\$(INST_LIB)/FFI/Build/PluginData.pm",
"lib/FFI/Platypus.pm" => "\$(INST_LIB)/FFI/Platypus.pm",
"lib/FFI/Platypus/API.pm" => "\$(INST_LIB)/FFI/Platypus/API.pm",
"lib/FFI/Platypus/Buffer.pm" => "\$(INST_LIB)/FFI/Platypus/Buffer.pm",
"lib/FFI/Platypus/Bundle.pm" => "\$(INST_LIB)/FFI/Platypus/Bundle.pm",
"lib/FFI/Platypus/Closure.pm" => "\$(INST_LIB)/FFI/Platypus/Closure.pm",
"lib/FFI/Platypus/Constant.pm" => "\$(INST_LIB)/FFI/Platypus/Constant.pm",
"lib/FFI/Platypus/DL.pm" => "\$(INST_LIB)/FFI/Platypus/DL.pm",
"lib/FFI/Platypus/Function.pm" => "\$(INST_LIB)/FFI/Platypus/Function.pm",
"lib/FFI/Platypus/Internal.pm" => "\$(INST_LIB)/FFI/Platypus/Internal.pm",
"lib/FFI/Platypus/Lang.pm" => "\$(INST_LIB)/FFI/Platypus/Lang.pm",
"lib/FFI/Platypus/Lang/ASM.pm" => "\$(INST_LIB)/FFI/Platypus/Lang/ASM.pm",
"lib/FFI/Platypus/Lang/C.pm" => "\$(INST_LIB)/FFI/Platypus/Lang/C.pm",
"lib/FFI/Platypus/Lang/Win32.pm" => "\$(INST_LIB)/FFI/Platypus/Lang/Win32.pm",
"lib/FFI/Platypus/Legacy.pm" => "\$(INST_LIB)/FFI/Platypus/Legacy.pm",
"lib/FFI/Platypus/Memory.pm" => "\$(INST_LIB)/FFI/Platypus/Memory.pm",
"lib/FFI/Platypus/Record.pm" => "\$(INST_LIB)/FFI/Platypus/Record.pm",
"lib/FFI/Platypus/Record/Meta.pm" => "\$(INST_LIB)/FFI/Platypus/Record/Meta.pm",
"lib/FFI/Platypus/Record/TieArray.pm" => "\$(INST_LIB)/FFI/Platypus/Record/TieArray.pm",
"lib/FFI/Platypus/ShareConfig.pm" => "\$(INST_LIB)/FFI/Platypus/ShareConfig.pm",
"lib/FFI/Platypus/Type.pm" => "\$(INST_LIB)/FFI/Platypus/Type.pm",
"lib/FFI/Platypus/Type/PointerSizeBuffer.pm" => "\$(INST_LIB)/FFI/Platypus/Type/PointerSizeBuffer.pm",
"lib/FFI/Platypus/Type/StringArray.pm" => "\$(INST_LIB)/FFI/Platypus/Type/StringArray.pm",
"lib/FFI/Platypus/Type/StringPointer.pm" => "\$(INST_LIB)/FFI/Platypus/Type/StringPointer.pm",
"lib/FFI/Platypus/Type/WideString.pm" => "\$(INST_LIB)/FFI/Platypus/Type/WideString.pm",
"lib/FFI/Platypus/TypeParser.pm" => "\$(INST_LIB)/FFI/Platypus/TypeParser.pm",
"lib/FFI/Platypus/TypeParser/Version0.pm" => "\$(INST_LIB)/FFI/Platypus/TypeParser/Version0.pm",
"lib/FFI/Platypus/TypeParser/Version1.pm" => "\$(INST_LIB)/FFI/Platypus/TypeParser/Version1.pm",
"lib/FFI/Platypus/TypeParser/Version2.pm" => "\$(INST_LIB)/FFI/Platypus/TypeParser/Version2.pm",
"lib/FFI/Probe.pm" => "\$(INST_LIB)/FFI/Probe.pm",
"lib/FFI/Probe/Runner.pm" => "\$(INST_LIB)/FFI/Probe/Runner.pm",
"lib/FFI/Probe/Runner/Builder.pm" => "\$(INST_LIB)/FFI/Probe/Runner/Builder.pm",
"lib/FFI/Probe/Runner/Result.pm" => "\$(INST_LIB)/FFI/Probe/Runner/Result.pm",
"lib/FFI/Temp.pm" => "\$(INST_LIB)/FFI/Temp.pm"
},
"PREREQ_PM" => {
"Capture::Tiny" => 0,
"ExtUtils::MakeMaker" => "7.12",
"FFI::CheckLib" => "0.05",
"File::Spec::Functions" => 0,
"IPC::Cmd" => 0,
"JSON::PP" => 0,
"List::Util" => "1.45",
"autodie" => 0,
"constant" => "1.32",
"parent" => 0
},
"TEST_REQUIRES" => {
"Capture::Tiny" => 0,
"Test2::API" => "1.302015",
"Test2::V0" => "0.000121"
},
"VERSION" => "2.12",
"test" => {
"TESTS" => "t/*.t"
}
);
mymm::myWriteMakefile(%WriteMakefileArgs); FFI-Platypus-2.12/README 000644 000000 000000 00000250252 15251066120 014523 0 ustar 00root root 000000 000000 NAME
FFI::Platypus - Write Perl bindings to non-Perl libraries with FFI. No
XS required.
VERSION
version 2.12
SYNOPSIS
use FFI::Platypus 2.00;
# for all new code you should use api => 2
my $ffi = FFI::Platypus->new(
api => 2,
lib => undef, # search libc
);
# call dynamically
$ffi->function( puts => ['string'] => 'int' )->call("hello world");
# attach as a xsub and call (much faster)
$ffi->attach( puts => ['string'] => 'int' );
puts("hello world");
DESCRIPTION
Platypus is a library for creating interfaces to machine code libraries
written in languages like C, C++, Go, Fortran, Rust, Pascal.
Essentially anything that gets compiled into machine code. This
implementation uses libffi to
accomplish this task. libffi is battle tested by a number of other
scripting and virtual machine languages, such as Python and Ruby to
serve a similar role. There are a number of reasons why you might want
to write an extension with Platypus instead of XS:
FFI / Platypus does not require messing with the guts of Perl
XS is less of an API and more of the guts of perl splayed out to do
whatever you want. That may at times be very powerful, but it can
also be a frustrating exercise in hair pulling.
FFI / Platypus is portable
Lots of languages have FFI interfaces, and it is subjectively easier
to port an extension written in FFI in Perl or another language to
FFI in another language or Perl. One goal of the Platypus Project is
to reduce common interface specifications to a common format like
JSON that could be shared between different languages.
FFI / Platypus could be a bridge to Raku
One of those "other" languages could be Raku and Raku already has an
FFI interface I am told.
FFI / Platypus can be reimplemented
In a bright future with multiple implementations of Perl 5, each
interpreter will have its own implementation of Platypus, allowing
extensions to be written once and used on multiple platforms, in much
the same way that Ruby-FFI extensions can be use in Ruby, JRuby and
Rubinius.
FFI / Platypus is pure perl (sorta)
One Platypus script or module works on any platform where the
libraries it uses are available. That means you can deploy your
Platypus script in a shared filesystem where they may be run on
different platforms. It also means that Platypus modules do not need
to be installed in the platform specific Perl library path.
FFI / Platypus is not C or C++ centric
XS is implemented primarily as a bunch of C macros, which requires at
least some understanding of C, the C pre-processor, and some C++
caveats (since on some platforms Perl is compiled and linked with a
C++ compiler). Platypus on the other hand could be used to call other
compiled languages, like Fortran, Go, Rust, Pascal, C++, or even
assembly, allowing you to focus on your strengths.
FFI / Platypus does not require a parser
Inline isolates the extension developer from XS to some extent, but
it also requires a parser. The various Inline language bindings are a
great technical achievement, but I think writing a parser for every
language that you want to interface with is a bit of an anti-pattern.
This document consists of an API reference, a set of examples, some
support and development (for contributors) information. If you are new
to Platypus or FFI, you may want to skip down to the EXAMPLES to get a
taste of what you can do with Platypus.
Platypus has extensive documentation of types at FFI::Platypus::Type
and its custom types API at FFI::Platypus::API.
You are strongly encouraged to use API level 2 for all new code. There
are a number of improvements and design fixes that you get for free.
You should even consider updating existing modules to use API level 2
where feasible. How do I do that you might ask? Simply pass in the API
level to the platypus constructor.
my $ffi = FFI::Platypus->new( api => 2 );
The Platypus documentation has already been updated to assume API level
1.
CONSTRUCTORS
new
my $ffi = FFI::Platypus->new( api => 2, %options);
Create a new instance of FFI::Platypus.
Any types defined with this instance will be valid for this instance
only, so you do not need to worry about stepping on the toes of other
CPAN FFI / Platypus Authors.
Any functions found will be out of the list of libraries specified with
the lib attribute.
options
api
[version 0.91]
Sets the API level. The recommended value for all new code is 2. The
Platypus documentation assumes API level 2 except for a few places
that specifically document older versions. You should only use a
lower value for a legacy code base that cannot be migrated to a newer
API level. Legal values are:
0
Original API level. See FFI::Platypus::TypeParser::Version0 for
details on the differences.
1
Enable version 1 API type parser which allows pass-by-value records
and type decoration on basic types.
2
Enable version 2 API. The Platypus documentation assumes this api
level is set.
API version 2 is identical to version 1, except:
Pointer functions that return NULL will return undef instead of
empty list
This fixes a long standing design bug in Platypus.
Array references may be passed to pointer argument types
This replicates the behavior of array argument types with no
size. So the types sint8* and sint8[] behave identically when an
array reference is passed in. They differ in that, as before, you
can pass a scalar reference into type sint8*.
The fixed string type can be specified without pointer modifier
That is you can use string(10) instead of string(10)* as you were
previously able to in API 0.
lib
Either a pathname (string) or a list of pathnames (array ref of
strings) to pre-populate the lib attribute. Use [undef] to search the
current process for symbols.
0.48
undef (without the array reference) can be used to search the current
process for symbols.
ignore_not_found
[version 0.15]
Set the ignore_not_found attribute.
lang
[version 0.18]
Set the lang attribute.
ATTRIBUTES
lib
$ffi->lib($path1, $path2, ...);
my @paths = $ffi->lib;
The list of libraries to search for symbols in.
The most portable and reliable way to find dynamic libraries is by
using FFI::CheckLib, like this:
use FFI::CheckLib 0.06;
$ffi->lib(find_lib_or_die lib => 'archive');
# finds libarchive.so on Linux
# libarchive.bundle on OS X
# libarchive.dll (or archive.dll) on Windows
# cygarchive-13.dll on Cygwin
# ...
# and will die if it isn't found
FFI::CheckLib has a number of options, such as checking for specific
symbols, etc. You should consult the documentation for that module.
As a special case, if you add undef as a "library" to be searched,
Platypus will also search the current process for symbols. This is
mostly useful for finding functions in the standard C library, without
having to know the name of the standard c library for your platform (as
it turns out it is different just about everywhere!).
You may also use the "find_lib" method as a shortcut:
$ffi->find_lib( lib => 'archive' );
ignore_not_found
[version 0.15]
$ffi->ignore_not_found(1);
my $ignore_not_found = $ffi->ignore_not_found;
Normally the attach and function methods will throw an exception if it
cannot find the name of the function you provide it. This will change
the behavior such that function will return undef when the function is
not found and attach will ignore functions that are not found. This is
useful when you are writing bindings to a library and have many
optional functions and you do not wish to wrap every call to function
or attach in an eval.
lang
[version 0.18]
$ffi->lang($language);
Specifies the foreign language that you will be interfacing with. The
default is C. The foreign language specified with this attribute
changes the default native types (for example, if you specify Rust, you
will get i32 as an alias for sint32 instead of int as you do with C).
If the foreign language plugin supports it, this will also enable
Platypus to find symbols using the demangled names (for example, if you
specify CPP for C++ you can use method names like Foo::get_bar() with
"attach" or "function".
api
[version 1.11]
my $level = $ffi->api;
Returns the API level of the Platypus instance.
METHODS
type
$ffi->type($typename);
$ffi->type($typename => $alias);
Define a type. The first argument is the native or C name of the type.
The second argument (optional) is an alias name that you can use to
refer to this new type. See FFI::Platypus::Type for legal type
definitions.
Examples:
$ffi->type('sint32'); # only checks to see that sint32 is a valid type
$ffi->type('sint32' => 'myint'); # creates an alias myint for sint32
$ffi->type('bogus'); # dies with appropriate diagnostic
custom_type
$ffi->custom_type($alias => {
native_type => $native_type,
native_to_perl => $coderef,
perl_to_native => $coderef,
perl_to_native_post => $coderef,
});
Define a custom type. See FFI::Platypus::Type#Custom-Types for details.
load_custom_type
$ffi->load_custom_type($name => $alias, @type_args);
Load the custom type defined in the module $name, and make an alias
$alias. If the custom type requires any arguments, they may be passed
in as @type_args. See FFI::Platypus::Type#Custom-Types for details.
If $name contains :: then it will be assumed to be a fully qualified
package name. If not, then FFI::Platypus::Type:: will be prepended to
it.
types
my @types = $ffi->types;
my @types = FFI::Platypus->types;
Returns the list of types that FFI knows about. This will include the
native libffi types (example: sint32, opaque and double) and the normal
C types (example: unsigned int, uint32_t), any types that you have
defined using the type method, and custom types.
The list of types that Platypus knows about varies somewhat from
platform to platform, FFI::Platypus::Type includes a list of the core
types that you can always count on having access to.
It can also be called as a class method, in which case, no user defined
or custom types will be included in the list.
type_meta
my $meta = $ffi->type_meta($type_name);
my $meta = FFI::Platypus->type_meta($type_name);
Returns a hash reference with the meta information for the given type.
It can also be called as a class method, in which case, you won't be
able to get meta data on user defined types.
The format of the meta data is implementation dependent and subject to
change. It may be useful for display or debugging.
Examples:
my $meta = $ffi->type_meta('int'); # standard int type
my $meta = $ffi->type_meta('int[64]'); # array of 64 ints
$ffi->type('int[128]' => 'myintarray');
my $meta = $ffi->type_meta('myintarray'); # array of 128 ints
mangler
$ffi->mangler(\&mangler);
Specify a customer mangler to be used for symbol lookup. This is
usually useful when you are writing bindings for a library where all of
the functions have the same prefix. Example:
$ffi->mangler(sub {
my($symbol) = @_;
return "foo_$symbol";
});
$ffi->function( get_bar => [] => 'int' ); # attaches foo_get_bar
my $f = $ffi->function( set_baz => ['int'] => 'void' );
$f->call(22); # calls foo_set_baz
function
my $function = $ffi->function($name => \@argument_types => $return_type);
my $function = $ffi->function($address => \@argument_types => $return_type);
my $function = $ffi->function($name => \@argument_types => $return_type, \&wrapper);
my $function = $ffi->function($address => \@argument_types => $return_type, \&wrapper);
Returns an object that is similar to a code reference in that it can be
called like one.
Caveat: many situations require a real code reference, so at the price
of a performance penalty you can get one like this:
my $function = $ffi->function(...);
my $coderef = sub { $function->(@_) };
It may be better, and faster to create a real Perl function using the
attach method.
In addition to looking up a function by name you can provide the
address of the symbol yourself:
my $address = $ffi->find_symbol('my_function');
my $function = $ffi->function($address => ...);
Under the covers, function uses find_symbol when you provide it with a
name, but it is useful to keep this in mind as there are alternative
ways of obtaining a functions address. Example: a C function could
return the address of another C function that you might want to call.
[version 0.76]
If the last argument is a code reference, then it will be used as a
wrapper around the function when called. The first argument to the
wrapper will be the inner function, or if it is later attached an xsub.
This can be used if you need to verify/modify input/output data.
Examples:
my $function = $ffi->function('my_function_name', ['int', 'string'] => 'string');
my $return_string = $function->(1, "hi there");
[version 0.91]
my $function = $ffi->function( $name => \@fixed_argument_types => \@var_argument_types => $return_type);
my $function = $ffi->function( $name => \@fixed_argument_types => \@var_argument_types => $return_type, \&wrapper);
my $function = $ffi->function( $name => \@fixed_argument_types => \@var_argument_types);
my $function = $ffi->function( $name => \@fixed_argument_types => \@var_argument_types => \&wrapper);
Version 0.91 and later allows you to creat functions for c variadic
functions (such as printf, scanf, etc) which can take a variable number
of arguments. The first set of arguments are the fixed set, the second
set are the variable arguments to bind with. The variable argument
types must be specified in order to create a function object, so if you
need to call variadic function with different set of arguments then you
will need to create a new function object each time:
# int printf(const char *fmt, ...);
$ffi->function( printf => ['string'] => ['int'] => 'int' )
->call("print integer %d\n", 42);
$ffi->function( printf => ['string'] => ['string'] => 'int' )
->call("print string %s\n", 'platypus');
Some older versions of libffi and possibly some platforms may not
support variadic functions. If you try to create a one, then an
exception will be thrown.
[version 1.26]
If the return type is omitted then void will be the assumed return
type.
attach
$ffi->attach($name => \@argument_types => $return_type);
$ffi->attach([$c_name => $perl_name] => \@argument_types => $return_type);
$ffi->attach([$address => $perl_name] => \@argument_types => $return_type);
$ffi->attach($name => \@argument_types => $return_type, \&wrapper);
$ffi->attach([$c_name => $perl_name] => \@argument_types => $return_type, \&wrapper);
$ffi->attach([$address => $perl_name] => \@argument_types => $return_type, \&wrapper);
Find and attach a C function as a real live Perl xsub. The advantage of
attaching a function over using the function method is that it is much
much much faster since no object resolution needs to be done. The
disadvantage is that it locks the function and the FFI::Platypus
instance into memory permanently, since there is no way to deallocate
an xsub.
If just one $name is given, then the function will be attached in Perl
with the same name as it has in C. The second form allows you to give
the Perl function a different name. You can also provide an address
(the third form), just like with the function method.
Examples:
$ffi->attach('my_function_name', ['int', 'string'] => 'string');
$ffi->attach(['my_c_function_name' => 'my_perl_function_name'], ['int', 'string'] => 'string');
my $string1 = my_function_name($int);
my $string2 = my_perl_function_name($int);
[version 0.20]
If the last argument is a code reference, then it will be used as a
wrapper around the attached xsub. The first argument to the wrapper
will be the inner xsub. This can be used if you need to verify/modify
input/output data.
Examples:
$ffi->attach('my_function', ['int', 'string'] => 'string', sub {
my($my_function_xsub, $integer, $string) = @_;
$integer++;
$string .= " and another thing";
my $return_string = $my_function_xsub->($integer, $string);
$return_string =~ s/Belgium//; # HHGG remove profanity
$return_string;
});
[version 0.91]
$ffi->attach($name => \@fixed_argument_types => \@var_argument_types, $return_type);
$ffi->attach($name => \@fixed_argument_types => \@var_argument_types, $return_type, \&wrapper);
As of version 0.91 you can attach a variadic functions, if it is
supported by the platform / libffi that you are using. For details see
the function documentation. If not supported by the implementation then
an exception will be thrown.
closure
my $closure = $ffi->closure($coderef);
my $closure = FFI::Platypus->closure($coderef);
Prepares a code reference so that it can be used as a FFI closure (a
Perl subroutine that can be called from C code). For details on
closures, see FFI::Platypus::Type#Closures and FFI::Platypus::Closure.
cast
my $converted_value = $ffi->cast($original_type, $converted_type, $original_value);
The cast function converts an existing $original_value of type
$original_type into one of type $converted_type. Not all types are
supported, so care must be taken. For example, to get the address of a
string, you can do this:
my $address = $ffi->cast('string' => 'opaque', $string_value);
Something that won't work is trying to cast an array to anything:
my $address = $ffi->cast('int[10]' => 'opaque', \@list); # WRONG
attach_cast
$ffi->attach_cast("cast_name", $original_type, $converted_type);
$ffi->attach_cast("cast_name", $original_type, $converted_type, \&wrapper);
my $converted_value = cast_name($original_value);
This function attaches a cast as a permanent xsub. This will make it
faster and may be useful if you are calling a particular cast a lot.
[version 1.26]
A wrapper may be added as the last argument to attach_cast and works
just like the wrapper for attach and function methods.
sizeof
my $size = $ffi->sizeof($type);
my $size = FFI::Platypus->sizeof($type);
Returns the total size of the given type in bytes. For example to get
the size of an integer:
my $intsize = $ffi->sizeof('int'); # usually 4
my $longsize = $ffi->sizeof('long'); # usually 4 or 8 depending on platform
You can also get the size of arrays
my $intarraysize = $ffi->sizeof('int[64]'); # usually 4*64
my $intarraysize = $ffi->sizeof('long[64]'); # usually 4*64 or 8*64
# depending on platform
Keep in mind that "pointer" types will always be the pointer / word
size for the platform that you are using. This includes strings, opaque
and pointers to other types.
This function is not very fast, so you might want to save this value as
a constant, particularly if you need the size in a loop with many
iterations.
alignof
[version 0.21]
my $align = $ffi->alignof($type);
Returns the alignment of the given type in bytes.
kindof
[version 1.24]
my $kind = $ffi->kindof($type);
Returns the kind of a type. This is a string with a value of one of
void
scalar
string
closure
record
record-value
pointer
array
object
countof
[version 1.24]
my $count = $ffi->countof($type);
For array types returns the number of elements in the array (returns 0
for variable length array). For the void type returns 0. Returns 1 for
all other types.
def
[version 1.24]
$ffi->def($package, $type, $value);
my $value = $ff->def($package, $type);
This method allows you to store data for types. If the $package is not
provided, then the caller's package will be used. $type must be a legal
Platypus type for the FFI::Platypus instance.
unitof
[version 1.24]
my $unittype = $ffi->unitof($type);
For array and pointer types, returns the basic type without the array
or pointer part. In other words, for sin16[] or sint16* it will return
sint16.
find_lib
[version 0.20]
$ffi->find_lib( lib => $libname );
This is just a shortcut for calling FFI::CheckLib#find_lib and updating
the "lib" attribute appropriately. Care should be taken though, as this
method simply passes its arguments to FFI::CheckLib#find_lib, so if
your module or script is depending on a specific feature in
FFI::CheckLib then make sure that you update your prerequisites
appropriately.
find_symbol
my $address = $ffi->find_symbol($name);
Return the address of the given symbol (usually function).
bundle
[version 0.96 api = 1+]
$ffi->bundle($package, \@args);
$ffi->bundle(\@args);
$ffi->bundle($package);
$ffi->bundle;
This is an interface for bundling compiled code with your distribution
intended to eventually replace the package method documented above. See
FFI::Platypus::Bundle for details on how this works.
package
[version 0.15 api = 0]
$ffi->package($package, $file); # usually __PACKAGE__ and __FILE__ can be used
$ffi->package; # autodetect
Note: This method is officially discouraged in favor of bundle
described above.
If you use FFI::Build (or the older deprecated Module::Build::FFI to
bundle C code with your distribution, you can use this method to tell
the FFI::Platypus instance to look for symbols that came with the
dynamic library that was built when your distribution was installed.
abis
my $href = $ffi->abis;
my $href = FFI::Platypus->abis;
Get the legal ABIs supported by your platform and underlying
implementation. What is supported can vary a lot by CPU and by
platform, or even between 32 and 64 bit on the same CPU and platform.
They keys are the "ABI" names, also known as "calling conventions". The
values are integers used internally by the implementation to represent
those ABIs.
abi
$ffi->abi($name);
Set the ABI or calling convention for use in subsequent calls to
"function" or "attach". May be either a string name or integer value
from the "abis" method above.
EXAMPLES
Here are some examples. These examples are provided in full with the
Platypus distribution in the "examples" directory. There are also some
more examples in FFI::Platypus::Type that are related to types.
Passing and Returning Integers
C Source
int add(int a, int b) {
return a+b;
}
Perl Source
use FFI::Platypus 2.00;
use FFI::CheckLib qw( find_lib_or_die );
use File::Basename qw( dirname );
my $ffi = FFI::Platypus->new( api => 2, lib => './add.so' );
$ffi->attach( add => ['int', 'int'] => 'int' );
print add(1,2), "\n"; # prints 3
Execute
$ cc -shared -o add.so add.c
$ perl add.pl
3
Discussion
Basic types like integers and floating points are the easiest to pass
across the FFI boundary. Because they are values that are passed on the
stack (or through registers) you don't need to worry about memory
allocations or ownership.
Here we are building our own C dynamic library using the native C
compiler on a Unix like platform. The exact incantation that you will
use to do this would unfortunately depend on your platform and C
compiler.
By default, Platypus uses the Platypus C language plugin, which gives
you easy access to many of the basic types used by C APIs. (for example
int, unsigned long, double, size_t and others).
If you are working with another language like Fortran, Go, Rust or Zig,
you will find similar examples where you can use the Platypus language
plugin for that language and use the native types.
String Arguments (with puts)
C API
cppreference - puts
Perl Source
use FFI::Platypus 2.00;
my $ffi = FFI::Platypus->new( api => 2, lib => undef );
$ffi->attach( puts => ['string'] => 'int' );
puts("hello world");
Execute
$ perl puts.pl
hello world
Discussion
Passing strings into a C function as an argument is also pretty easy
using Platypus. Just use the string type, which is equivalent to the C
or const char * types.
In this example we are using the C Standard Library's puts function, so
we don't need to build our own C code. We do still need to tell
Platypus where to look for the puts symbol though, which is why we set
lib to undef. This is a special value which tells Platypus to search
the Perl runtime executable itself (including any dynamic libraries)
for symbols. That helpfully includes the C Standard Library.
Returning Strings
C Source
#include
#include
const char *
string_reverse(const char *input)
{
static char *output = NULL;
int i, len;
if(output != NULL)
free(output);
if(input == NULL)
return NULL;
len = strlen(input);
output = malloc(len+1);
for(i=0; input[i]; i++)
output[len-i-1] = input[i];
output[len] = '\0';
return output;
}
Perl Source
use FFI::Platypus 2.00;
my $ffi = FFI::Platypus->new(
api => 2,
lib => './string_reverse.so',
);
$ffi->attach( string_reverse => ['string'] => 'string' );
print string_reverse("\nHello world");
string_reverse(undef);
Execute
$ cc -shared -o string_reverse.so string_reverse.c
$ perl string_reverse.pl
dlrow olleH
Discussion
The C code here takes an input ASCII string and reverses it, returning
the result. Note that it retains ownership of the string, the caller is
expected to use it before the next call to reverse_string, or copy it.
The Perl code simply declares the return value as string and is very
simple. This does bring up an inconsistency though, strings passed in
to a function as arguments are passed by reference, whereas the return
value is copied! This is usually what you want because C APIs usually
follow this pattern where you are expected to make your own copy of the
string.
At the end of the program we call reverse_string with undef, which gets
translated to C as NULL. This allows it to free the output buffer so
that the memory will not leak.
Returning and Freeing Strings with Embedded NULLs
C Source
#include
#include
char *
string_crypt(const char *input, int len, const char *key)
{
char *output;
int i, n;
if(input == NULL)
return NULL;
output = malloc(len+1);
output[len] = '\0';
for(i=0, n=0; inew(
api => 2,
lib => './xor_cipher.so',
);
$ffi->attach( string_crypt_free => ['opaque'] );
$ffi->attach( string_crypt => ['string','int','string'] => 'opaque' => sub{
my($xsub, $input, $key) = @_;
my $ptr = $xsub->($input, length($input), $key);
my $output = buffer_to_scalar $ptr, length($input);
string_crypt_free($ptr);
return $output;
});
my $orig = "hello world";
my $key = "foobar";
print YAML::Dump($orig);
my $encrypted = string_crypt($orig, $key);
print YAML::Dump($encrypted);
my $decrypted = string_crypt($encrypted, $key);
print YAML::Dump($decrypted);
Execute
$ cc -shared -o xor_cipher.so xor_cipher.c
$ perl xor_cipher.pl
--- hello world
--- "\x0e\n\x03\x0e\x0eR\x11\0\x1d\x0e\x05"
--- hello world
Discussion
The C code here also returns a string, but it has some different
expectations, so we can't just use the string type like we did in the
previous example and copy the string.
This C code implements a simple XOR cipher. Given an input string and a
key it returns an encrypted or decrypted output string where the
characters are XORd with the key. There are some challenges here
though. First the input and output strings can have embedded NULLs in
them. For the string passed in, we can provide the length of the input
string. For the output, the string type expects a NULL terminated
string, so we can't use that. So instead we get a pointer to the output
using the opaque type. Because we know that the output string is the
same length as the input string we can convert the pointer to a regular
Perl string using the buffer_to_scalar function. (For more details
about working with buffers and strings see FFI::Platypus::Buffer).
Next, the C code here does not keep the pointer to the output string,
as in the previous example. We are expected to call string_encrypt_free
when we are done. Since we are getting the pointer back from the C code
instead of copying the string that is easy to do.
Finally, we are using a wrapper to hide a lot of this complexity from
our caller. The last argument to the attach call is a code reference
which will wrap around the C function, which is passed in as the first
argument of the wrapper. This is a good practice when writing modules,
to hide the complexity of C.
Pointers
C Source
void
swap(int *a, int *b)
{
int tmp = *b;
*b = *a;
*a = tmp;
}
Perl Source
use FFI::Platypus 2.00;
my $ffi = FFI::Platypus->new(
api => 2,
lib => './swap.so',
);
$ffi->attach( swap => ['int*','int*'] );
my $a = 1;
my $b = 2;
print "[a,b] = [$a,$b]\n";
swap( \$a, \$b );
print "[a,b] = [$a,$b]\n";
Execute
$ cc -shared -o swap.so swap.c
$ perl swap.pl
[a,b] = [1,2]
[a,b] = [2,1]
Discussion
Pointers are often use in C APIs to return simple values like this.
Platypus provides access to pointers to primitive types by appending *
to the primitive type. Here for example we are using int* to create a
function that takes two pointers to integers and swaps their values.
When calling the function from Perl we pass in a reference to a scalar.
Strictly speaking Perl allows modifying the argument values to
subroutines, so we could have allowed just passing in a scalar, but in
the design of Platypus we decided that forcing the use of a reference
here emphasizes that you are passing a reference to the variable, not
just the value.
Not pictured in this example, but you can also pass in undef for a
pointer value and that will be translated into NULL on the C side. You
can also return a pointer to a primitive type from a function, again
this will be returned to Perl as a reference to a scalar. Platypus also
supports string pointers (string*). (Though the C equivalent to a
string* is a double pointer to char char**).
Opaque Pointers (objects)
C Source
#include
#include
typedef struct person_t {
char *name;
unsigned int age;
} person_t;
person_t *
person_new(const char *name, unsigned int age) {
person_t *self = malloc(sizeof(person_t));
self->name = strdup(name);
self->age = age;
}
const char *
person_name(person_t *self) {
return self->name;
}
unsigned int
person_age(person_t *self) {
return self->age;
}
void
person_free(person_t *self) {
free(self->name);
free(self);
}
Perl Source
use FFI::Platypus 2.00;
my $ffi = FFI::Platypus->new(
api => 2,
lib => './person.so',
);
$ffi->type( 'opaque' => 'person_t' );
$ffi->attach( person_new => ['string','unsigned int'] => 'person_t' );
$ffi->attach( person_name => ['person_t'] => 'string' );
$ffi->attach( person_age => ['person_t'] => 'unsigned int' );
$ffi->attach( person_free => ['person_t'] );
my $person = person_new( 'Roger Frooble Bits', 35 );
print "name = ", person_name($person), "\n";
print "age = ", person_age($person), "\n";
person_free($person);
Execute
$ cc -shared -o person.so person.c
$ perl person.pl
name = Roger Frooble Bits
age = 35
Discussion
An opaque pointer is a pointer (memory address) that is pointing to
something but you do not know the structure of that something. In C
this is usually a void*, but it could also be a pointer to a struct
without a defined body.
This is often used to as an abstraction around objects in C. Here in
the C code we have a person_t struct with functions to create (a
constructor), free (a destructor) and query it (methods).
The Perl code can then use the constructor, methods and destructors
without having to understand the internals. The person_t internals can
also be changed without having to modify the calling code.
We use the Platypus type method to create an alias of opaque called
person_t. While this is not necessary, it does make the Perl code
easier to understand.
In later examples we will see how to hide the use of opaque types
further using the object type, but for some code direct use of opaque
is appropriate.
Opaque Pointers (buffers and strings)
C API
cppreference - free
cppreference - malloc
cppreference - memcpy
cppreference - strdup
Perl Source
use FFI::Platypus 2.00;
use FFI::Platypus::Memory qw( malloc free memcpy strdup );
my $ffi = FFI::Platypus->new( api => 2 );
my $buffer = malloc 14;
my $ptr_string = strdup("hello there!!\n");
memcpy $buffer, $ptr_string, 15;
print $ffi->cast('opaque' => 'string', $buffer);
free $ptr_string;
free $buffer;
Execute
$ perl malloc.pl
hello there!!
Discussion
Another useful application of the opaque type is for dealing with
buffers, and C strings that you do not immediately need to convert into
Perl strings. This example is completely contrived, but we are using
malloc to create a buffer of 14 bytes. We create a C string using
strdup, and then copy it into the buffer using memcpy. When we are done
with the opaque pointers we can free them using free since they. (This
is generally only okay when freeing memory that was allocated by
malloc, which is the case for strdup).
These memory tools, along with others are provided by the
FFI::Platypus::Memory module, which is worth reviewing when you need to
manipulate memory from Perl when writing your FFI code.
Just to verify that the memcpy did the right thing we convert the
buffer into a Perl string and print it out using the Platypus cast
method.
Arrays
C Source
void
array_reverse(int a[], int len) {
int tmp, i;
for(i=0; i < len/2; i++) {
tmp = a[i];
a[i] = a[len-i-1];
a[len-i-1] = tmp;
}
}
void
array_reverse10(int a[10]) {
array_reverse(a, 10);
}
Perl Source
use FFI::Platypus 2.00;
my $ffi = FFI::Platypus->new(
api => 2,
lib => './array_reverse.so',
);
$ffi->attach( array_reverse => ['int[]','int'] );
$ffi->attach( array_reverse10 => ['int[10]'] );
my @a = (1..10);
array_reverse10( \@a );
print "$_ " for @a;
print "\n";
@a = (1..20);
array_reverse( \@a, 20 );
print "$_ " for @a;
print "\n";
Execute
$ cc -shared -o array_reverse.so array_reverse.c
$ perl array_reverse.pl
10 9 8 7 6 5 4 3 2 1
20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1
Discussion
Arrays in C are passed as pointers, so the C code here reverses the
array in place, rather than returning it. Arrays can also be fixed or
variable length. If the array is variable length the length of the
array must be provided in some way. In this case we explicitly pass in
a length. Another way might be to end the array with 0, if you don't
otherwise expect any 0 to appear in your data. For this reason,
Platypus adds a zero (or NULL in the case of pointers) element at the
end of the array when passing it into a variable length array type,
although we do not use it here.
With Platypus you can declare an array type as being either fixed or
variable length. Because Perl stores arrays in completely differently
than C, a temporary array is created by Platypus, passed into the C
function as a pointer. When the function returns the array is re-read
by Platypus and the Perl array is updated with the new values. The
temporary array is then freed.
You can use any primitive type for arrays, even string. You can also
return an array from a function. As in our discussion about strings,
when you return an array the value is copied, which is usually what you
want.
Pointers as Arrays
C Source
#include
int
array_sum(const int *a) {
int i, sum;
if(a == NULL)
return -1;
for(i=0, sum=0; a[i] != 0; i++)
sum += a[i];
return sum;
}
Perl Source
use FFI::Platypus 2.00;
my $ffi = FFI::Platypus->new(
api => 2,
lib => './array_sum.so',
);
$ffi->attach( array_sum => ['int*'] => 'int' );
print array_sum(undef), "\n"; # -1
print array_sum([0]), "\n"; # 0
print array_sum([1,2,3,0]), "\n"; # 6
Execute
$ cc -shared -o array_sum.so array_sum.c
$ perl array_sum.pl
-1
0
6
Discussion
Starting with the Platypus version 2 API, you can also pass an array
reference in to a pointer argument.
In C pointer and array arguments are often used somewhat
interchangeably. In this example we have an array_sum function that
takes a zero terminated array of integers and computes the sum. If the
pointer to the array is zero (0) then we return -1 to indicate an
error.
This is the main advantage from Perl for using pointer argument rather
than an array one: the array argument will not let you pass in undef /
NULL.
Sending Strings to GUI on Unix with libnotify
C API
Libnotify Reference Manual
Perl Source
use FFI::CheckLib;
use FFI::Platypus 2.00;
my $ffi = FFI::Platypus->new(
api => 2,
lib => find_lib_or_die(lib => 'notify'),
);
$ffi->attach( notify_init => ['string'] );
$ffi->attach( notify_uninit => [] );
$ffi->attach( notify_notification_new => ['string', 'string', 'string'] => 'opaque' );
$ffi->attach( notify_notification_show => ['opaque', 'opaque'] );
my $message = join "\n",
"Hello from Platypus!",
"Welcome to the fun",
"world of FFI";
notify_init('Platypus Hello');
my $n = notify_notification_new('Platypus Hello World', $message, 'dialog-information');
notify_notification_show($n, undef);
notify_uninit();
Execute
$ perl notify.pl
Discussion
The GNOME project provides an API to send notifications to its desktop
environment. Nothing here is particularly new: all of the types and
techniques are ones that we have seen before, except we are using a
third party library, instead of using our own C code or the standard C
library functions.
When using a third party library you have to know the name or location
of it, which is not typically portable, so here we use FFI::CheckLib's
find_lib_or_die function. If the library is not found the script will
die with a useful diagnostic. FFI::CheckLib has a number of useful
features and will integrate nicely with Alien::Build based Aliens.
The Win32 API with MessageBoxW
Win32 API
MessageBoxW function (winuser.h)
Perl Source
use utf8;
use FFI::Platypus 2.00;
my $ffi = FFI::Platypus->new(
api => 2,
lib => [undef],
);
# see FFI::Platypus::Lang::Win32
$ffi->lang('Win32');
# Send a Unicode string to the Windows API MessageBoxW function.
use constant MB_OK => 0x00000000;
use constant MB_DEFAULT_DESKTOP_ONLY => 0x00020000;
$ffi->attach( [MessageBoxW => 'MessageBox'] => [ 'HWND', 'LPCWSTR', 'LPCWSTR', 'UINT'] => 'int' );
MessageBox(undef, "I �� Platypus", "Confession", MB_OK|MB_DEFAULT_DESKTOP_ONLY);
Execute
$ perl win32_messagebox.pl
Discussion
The API used by Microsoft Windows presents some unique challenges. On
32 bit systems a different ABI is used than what is used by the
standard C library. It also provides a rats nest of type aliases.
Finally if you want to talk Unicode to any of the Windows API you will
need to use UTF-16LE instead of UTF-8 which is native to Perl. (The
Win32 API refers to these as LPWSTR and LPCWSTR types). As much as
possible the Win32 "language" plugin attempts to handle these
challenges transparently. For more details see
FFI::Platypus::Lang::Win32.
Discussion
The libnotify library is a desktop GUI notification system for the
GNOME Desktop environment. This script sends a notification event that
should show up as a balloon, for me it did so in the upper right hand
corner of my screen.
Structured Data Records (by pointer or by reference)
C API
cppreference - localtime
Perl Source
use FFI::Platypus 2.00;
use FFI::C;
my $ffi = FFI::Platypus->new(
api => 2,
lib => [undef],
);
FFI::C->ffi($ffi);
package Unix::TimeStruct {
FFI::C->struct(tm => [
tm_sec => 'int',
tm_min => 'int',
tm_hour => 'int',
tm_mday => 'int',
tm_mon => 'int',
tm_year => 'int',
tm_wday => 'int',
tm_yday => 'int',
tm_isdst => 'int',
tm_gmtoff => 'long',
_tm_zone => 'opaque',
]);
# For now 'string' is unsupported by FFI::C, but we
# can cast the time zone from an opaque pointer to
# string.
sub tm_zone {
my $self = shift;
$ffi->cast('opaque', 'string', $self->_tm_zone);
}
# attach the C localtime function
$ffi->attach( localtime => ['time_t*'] => 'tm', sub {
my($inner, $class, $time) = @_;
$time = time unless defined $time;
$inner->(\$time);
});
}
# now we can actually use our Unix::TimeStruct class
my $time = Unix::TimeStruct->localtime;
printf "time is %d:%d:%d %s\n",
$time->tm_hour,
$time->tm_min,
$time->tm_sec,
$time->tm_zone;
Execute
$ perl time_struct.pl
time is 3:48:19 MDT
Discussion
C and other machine code languages frequently provide interfaces that
include structured data records (defined using the struct keyword in
C). Some libraries will provide an API which you are expected to read
or write before and/or after passing them along to the library.
For C pointers to strict, union, nested struct and nested union
structures, the easiest interface to use is via FFI::C. If you are
working with a struct that must be passed by value (not pointers), then
you will want to use FFI::Platypus::Record class instead. We will
discuss an example of that next.
The C localtime function takes a pointer to a C struct. We simply
define the members of the struct using the FFI::C struct method.
Because we used the ffi method to tell FFI::C to use our local instance
of FFI::Platypus it registers the tm type for us, and we can just start
using it as a return type!
Structured Data Records (on stack or by value)
C Source
#include
#include
typedef struct color_t {
char name[8];
uint8_t red;
uint8_t green;
uint8_t blue;
} color_t;
color_t
color_increase_red(color_t color, uint8_t amount)
{
strcpy(color.name, "reddish");
color.red += amount;
return color;
}
Perl Source
use FFI::Platypus 2.00;
my $ffi = FFI::Platypus->new(
api => 2,
lib => './color.so'
);
package Color {
use FFI::Platypus::Record;
use overload
'""' => sub { shift->as_string },
bool => sub { 1 }, fallback => 1;
record_layout_1($ffi,
'string(8)' => 'name', qw(
uint8 red
uint8 green
uint8 blue
));
sub as_string {
my($self) = @_;
sprintf "%s: [red:%02x green:%02x blue:%02x]",
$self->name, $self->red, $self->green, $self->blue;
}
}
$ffi->type('record(Color)' => 'color_t');
$ffi->attach( color_increase_red => ['color_t','uint8'] => 'color_t' );
my $gray = Color->new(
name => 'gray',
red => 0xDC,
green => 0xDC,
blue => 0xDC,
);
my $slightly_red = color_increase_red($gray, 20);
print "$gray\n";
print "$slightly_red\n";
Execute
$ cc -shared -o color.so color.c
$ perl color.pl
gray: [red:dc green:dc blue:dc]
reddish: [red:f0 green:dc blue:dc]
Discussion
In the C source of this example, we pass a C struct by value by copying
it onto the stack. On the Perl side we create a Color class using
FFI::Platypus::Record, which allows us to pass the structure the way
the C source wants us to.
Generally you should only reach for FFI::Platypus::Record if you need
to pass small records on the stack like this. For more complicated
(including nested) data you want to use FFI::C using pointers.
Avoiding Copy Using Memory Windows (with libzmq3)
C API
ØMQ/3.2.6 API Reference
Perl Source
use constant ZMQ_IO_THREADS => 1;
use constant ZMQ_MAX_SOCKETS => 2;
use constant ZMQ_REQ => 3;
use constant ZMQ_REP => 4;
use FFI::CheckLib qw( find_lib_or_die );
use FFI::Platypus 2.00;
use FFI::Platypus::Memory qw( malloc );
use FFI::Platypus::Buffer qw( scalar_to_buffer window );
my $endpoint = "ipc://zmq-ffi-$$";
my $ffi = FFI::Platypus->new(
api => 2,
lib => find_lib_or_die lib => 'zmq',
);
$ffi->attach(zmq_version => ['int*', 'int*', 'int*'] => 'void');
my($major,$minor,$patch);
zmq_version(\$major, \$minor, \$patch);
print "libzmq version $major.$minor.$patch\n";
die "this script only works with libzmq 3 or better" unless $major >= 3;
$ffi->type('opaque' => 'zmq_context');
$ffi->type('opaque' => 'zmq_socket');
$ffi->type('opaque' => 'zmq_msg_t');
$ffi->attach(zmq_ctx_new => [] => 'zmq_context');
$ffi->attach(zmq_ctx_set => ['zmq_context', 'int', 'int'] => 'int');
$ffi->attach(zmq_socket => ['zmq_context', 'int'] => 'zmq_socket');
$ffi->attach(zmq_connect => ['opaque', 'string'] => 'int');
$ffi->attach(zmq_bind => ['zmq_socket', 'string'] => 'int');
$ffi->attach(zmq_send => ['zmq_socket', 'opaque', 'size_t', 'int'] => 'int');
$ffi->attach(zmq_msg_init => ['zmq_msg_t'] => 'int');
$ffi->attach(zmq_msg_recv => ['zmq_msg_t', 'zmq_socket', 'int'] => 'int');
$ffi->attach(zmq_msg_data => ['zmq_msg_t'] => 'opaque');
$ffi->attach(zmq_errno => [] => 'int');
$ffi->attach(zmq_strerror => ['int'] => 'string');
my $context = zmq_ctx_new();
zmq_ctx_set($context, ZMQ_IO_THREADS, 1);
my $socket1 = zmq_socket($context, ZMQ_REQ);
zmq_connect($socket1, $endpoint);
my $socket2 = zmq_socket($context, ZMQ_REP);
zmq_bind($socket2, $endpoint);
{ # send
our $sent_message = "hello there";
my($pointer, $size) = scalar_to_buffer $sent_message;
my $r = zmq_send($socket1, $pointer, $size, 0);
die zmq_strerror(zmq_errno()) if $r == -1;
}
{ # recv
my $msg_ptr = malloc 100;
zmq_msg_init($msg_ptr);
my $size = zmq_msg_recv($msg_ptr, $socket2, 0);
die zmq_strerror(zmq_errno()) if $size == -1;
my $data_ptr = zmq_msg_data($msg_ptr);
window(my $recv_message, $data_ptr, $size);
print "recv_message = $recv_message\n";
}
Execute
$ perl zmq3.pl
libzmq version 4.3.4
recv_message = hello there
Discussion
ØMQ is a high-performance asynchronous messaging library. There are a
few things to note here.
Firstly, sometimes there may be multiple versions of a library in the
wild and you may need to verify that the library on a system meets your
needs (alternatively you could support multiple versions and configure
your bindings dynamically). Here we use zmq_version to ask libzmq which
version it is.
zmq_version returns the version number via three integer pointer
arguments, so we use the pointer to integer type: int *. In order to
pass pointer types, we pass a reference. In this case it is a reference
to an undefined value, because zmq_version will write into the pointers
the output values, but you can also pass in references to integers,
floating point values and opaque pointer types. When the function
returns the $major variable (and the others) has been updated and we
can use it to verify that it supports the API that we require.
Finally we attach the necessary functions, send and receive a message.
When we receive we use the FFI::Platypus::Buffer function window
instead of buffer_to_scalar. They have a similar effect in that the
provide a scalar from a region of memory, but window doesn't have to
copy any data, so it is cheaper to call. The only downside is that a
windowed scalar like this is read-only.
libarchive
C Documentation
https://www.libarchive.org/
Perl Source
use FFI::Platypus 2.00;
use FFI::CheckLib qw( find_lib_or_die );
# This example uses FreeBSD's libarchive to list the contents of any
# archive format that it suppors. We've also filled out a part of
# the ArchiveWrite class that could be used for writing archive formats
# supported by libarchive
my $ffi = FFI::Platypus->new(
api => 2,
lib => find_lib_or_die(lib => 'archive'),
);
$ffi->type('object(Archive)' => 'archive_t');
$ffi->type('object(ArchiveRead)' => 'archive_read_t');
$ffi->type('object(ArchiveWrite)' => 'archive_write_t');
$ffi->type('object(ArchiveEntry)' => 'archive_entry_t');
package Archive {
# base class is "abstract" having no constructor or destructor
$ffi->mangler(sub {
my($name) = @_;
"archive_$name";
});
$ffi->attach( error_string => ['archive_t'] => 'string' );
}
package ArchiveRead {
our @ISA = qw( Archive );
$ffi->mangler(sub {
my($name) = @_;
"archive_read_$name";
});
$ffi->attach( new => ['string'] => 'archive_read_t' );
$ffi->attach( [ free => 'DESTROY' ] => ['archive_t'] );
$ffi->attach( support_filter_all => ['archive_t'] => 'int' );
$ffi->attach( support_format_all => ['archive_t'] => 'int' );
$ffi->attach( open_filename => ['archive_t','string','size_t'] => 'int' );
$ffi->attach( next_header2 => ['archive_t', 'archive_entry_t' ] => 'int' );
$ffi->attach( data_skip => ['archive_t'] => 'int' );
# ... define additional read methods
}
package ArchiveWrite {
our @ISA = qw( Archive );
$ffi->mangler(sub {
my($name) = @_;
"archive_write_$name";
});
$ffi->attach( new => ['string'] => 'archive_write_t' );
$ffi->attach( [ free => 'DESTROY' ] => ['archive_write_t'] );
# ... define additional write methods
}
package ArchiveEntry {
$ffi->mangler(sub {
my($name) = @_;
"archive_entry_$name";
});
$ffi->attach( new => ['string'] => 'archive_entry_t' );
$ffi->attach( [ free => 'DESTROY' ] => ['archive_entry_t'] );
$ffi->attach( pathname => ['archive_entry_t'] => 'string' );
# ... define additional entry methods
}
use constant ARCHIVE_OK => 0;
# this is a Perl version of the C code here:
# https://github.com/libarchive/libarchive/wiki/Examples#List_contents_of_Archive_stored_in_File
my $archive_filename = shift @ARGV;
unless(defined $archive_filename)
{
print "usage: $0 archive.tar\n";
exit;
}
my $archive = ArchiveRead->new;
$archive->support_filter_all;
$archive->support_format_all;
my $r = $archive->open_filename($archive_filename, 1024);
die "error opening $archive_filename: ", $archive->error_string
unless $r == ARCHIVE_OK;
my $entry = ArchiveEntry->new;
while($archive->next_header2($entry) == ARCHIVE_OK)
{
print $entry->pathname, "\n";
$archive->data_skip;
}
Execute
$ perl archive_object.pl archive.tar
archive.pl
archive_object.pl
Discussion
libarchive is the implementation of tar for FreeBSD provided as a
library and available on a number of platforms.
One interesting thing about libarchive is that it provides a kind of
object oriented interface via opaque pointers. This example creates an
abstract class Archive, and concrete classes ArchiveWrite, ArchiveRead
and ArchiveEntry. The concrete classes can even be inherited from and
extended just like any Perl classes because of the way the custom types
are implemented. We use Platypus's object type for this implementation,
which is a wrapper around an opaque (can also be an integer) type that
is blessed into a particular class.
Another advanced feature of this example is that we define a mangler to
modify the symbol resolution for each class. This means we can do this
when we define a method for Archive:
$ffi->attach( support_filter_all => ['archive_t'] => 'int' );
Rather than this:
$ffi->attach(
[ archive_read_support_filter_all => 'support_read_filter_all' ] =>
['archive_t'] => 'int' );
);
As nice as libarchive is, note that we have to shoehorn then
archive_free function name into the Perl convention of using DESTROY as
the destructor. We can easily do that for just this one function with:
$ffi->attach( [ free => 'DESTROY' ] => ['archive_t'] );
The libarchive is a large library with hundreds of methods. For
comprehensive FFI bindings for libarchive see Archive::Libarchive.
unix open
C API
Input-output system calls in C
Perl Source
use FFI::Platypus 2.00;
{
package FD;
use constant O_RDONLY => 0;
use constant O_WRONLY => 1;
use constant O_RDWR => 2;
use constant IN => bless \do { my $in=0 }, __PACKAGE__;
use constant OUT => bless \do { my $out=1 }, __PACKAGE__;
use constant ERR => bless \do { my $err=2 }, __PACKAGE__;
my $ffi = FFI::Platypus->new( api => 2, lib => [undef]);
$ffi->type('object(FD,int)' => 'fd');
$ffi->attach( [ 'open' => 'new' ] => [ 'string', 'int', 'mode_t' ] => 'fd' => sub {
my($xsub, $class, $fn, @rest) = @_;
my $fd = $xsub->($fn, @rest);
die "error opening $fn $!" if $$fd == -1;
$fd;
});
$ffi->attach( write => ['fd', 'string', 'size_t' ] => 'ssize_t' );
$ffi->attach( read => ['fd', 'string', 'size_t' ] => 'ssize_t' );
$ffi->attach( close => ['fd'] => 'int' );
}
my $fd = FD->new("file_handle.txt", FD::O_RDONLY);
my $buffer = "\0" x 10;
while(my $br = $fd->read($buffer, 10))
{
FD::OUT->write($buffer, $br);
}
$fd->close;
Execute
$ perl file_handle.pl
Hello World
Discussion
The Unix file system calls use an integer handle for each open file. We
can use the same object type that we used for libarchive above, except
we let platypus know that the underlying type is int instead of opaque
(the latter being the default for the object type). Mainly just for
demonstration since Perl has much better IO libraries, but now we have
an OO interface to the Unix IO functions.
Varadic Functions (with libcurl)
C API
curl_easy_init
curl_easy_setopt
curl_easy_perform
curl_easy_cleanup
CURLOPT_URL
Perl Source
use FFI::Platypus 2.00;
use FFI::CheckLib qw( find_lib_or_die );
use constant CURLOPT_URL => 10002;
my $ffi = FFI::Platypus->new(
api => 2,
lib => find_lib_or_die(lib => 'curl'),
);
my $curl_handle = $ffi->function( 'curl_easy_init' => [] => 'opaque' )
->call;
$ffi->function( 'curl_easy_setopt' => ['opaque', 'enum' ] => ['string'] )
->call($curl_handle, CURLOPT_URL, "https://pl.atypus.org" );
$ffi->function( 'curl_easy_perform' => ['opaque' ] => 'enum' )
->call($curl_handle);
$ffi->function( 'curl_easy_cleanup' => ['opaque' ] )
->call($curl_handle);
Execute
$ perl curl.pl
pl.atypus.org - Home for the Perl Platypus Project
...
Discussion
The libcurl library makes extensive use of "varadic"
functions.
The C programming language and ABI have the concept of "varadic"
functions that can take a variable number and variable type of
arguments. Assuming you have a libffi that supports it (and most modern
systems should), then you can create bindings to a varadic function by
providing two sets of array references, one for the fixed arguments
(for reasons, C varadic functions must have at least one) and one for
variable arguments. In this example we call curl_easy_setopt as a
varadic function.
For functions that have a large or infinite number of possible
signatures it may be impracticable or impossible to attach them all.
You can instead do as we did in this example, create a function object
using the function method and call it immediately. This is not as
performant either when you create or call as using the attach method,
but in some cases the performance penalty may be worth it or
unavoidable.
Callbacks (with libcurl)
C API
curl_easy_init
curl_easy_setopt
curl_easy_perform
curl_easy_cleanup
CURLOPT_URL
CURLOPT_WRITEFUNCTION
Perl Source
use FFI::Platypus 2.00;
use FFI::CheckLib qw( find_lib_or_die );
use FFI::Platypus::Buffer qw( window );
use constant CURLOPT_URL => 10002;
use constant CURLOPT_WRITEFUNCTION => 20011;
my $ffi = FFI::Platypus->new(
api => 2,
lib => find_lib_or_die(lib => 'curl'),
);
my $curl_handle = $ffi->function( 'curl_easy_init' => [] => 'opaque' )
->call;
$ffi->function( 'curl_easy_setopt' => [ 'opaque', 'enum' ] => ['string'] )
->call($curl_handle, CURLOPT_URL, "https://pl.atypus.org" );
my $html;
my $closure = $ffi->closure(sub {
my($ptr, $len, $num, $user) = @_;
window(my $buf, $ptr, $len*$num);
$html .= $buf;
return $len*$num;
});
$ffi->function( 'curl_easy_setopt' => [ 'opaque', 'enum' ] => ['(opaque,size_t,size_t,opaque)->size_t'] => 'enum' )
->call($curl_handle, CURLOPT_WRITEFUNCTION, $closure);
$ffi->function( 'curl_easy_perform' => [ 'opaque' ] => 'enum' )
->call($curl_handle);
$ffi->function( 'curl_easy_cleanup' => [ 'opaque' ] )
->call($curl_handle);
if($html =~ /(.*?)<\/title>/) {
print "$1\n";
}
Execute
$ perl curl_callback.pl
pl.atypus.org - Home for the Perl Platypus Project
Discussion
This example is similar to the previous one, except instead of letting
libcurl write the content body to STDOUT, we give it
a callback to send the data to instead. The closure method can be used
to create a callback function pointer that can be called from C. The
type for the callback is in the form
(arg_type,arg_type,etc)->return_type where the argument types are in
parentheticals with an arrow between the argument types and the return
type.
Inside the closure or callback we use the window function from
FFI::Platypus::Buffer again to avoid an extra copy. We still have to
copy the buffer to append it to $hmtl but it is at least one less copy.
bundle your own code
C Source
ffi/foo.c:
#include
#include
typedef struct {
char *name;
int value;
} foo_t;
foo_t*
foo__new(const char *class_name, const char *name, int value) {
(void)class_name;
foo_t *self = malloc( sizeof( foo_t ) );
self->name = strdup(name);
self->value = value;
return self;
}
const char *
foo__name(foo_t *self) {
return self->name;
}
int
foo__value(foo_t *self) {
return self->value;
}
void
foo__DESTROY(foo_t *self) {
free(self->name);
free(self);
}
Perl Source
lib/Foo.pm:
package Foo;
use strict;
use warnings;
use FFI::Platypus 2.00;
my $ffi = FFI::Platypus->new( api => 2 );
$ffi->type('object(Foo)' => 'foo_t');
$ffi->mangler(sub {
my $name = shift;
$name =~ s/^/foo__/;
$name;
});
$ffi->bundle;
$ffi->attach( new => [ 'string', 'string', 'int' ] => 'foo_t' );
$ffi->attach( name => [ 'foo_t' ] => 'string' );
$ffi->attach( value => [ 'foo_t' ] => 'int' );
$ffi->attach( DESTROY => [ 'foo_t' ] => 'void' );
1;
t/foo.t:
use Test2::V0;
use Foo;
my $foo = Foo->new("platypus", 10);
isa_ok $foo, 'Foo';
is $foo->name, "platypus";
is $foo->value, 10;
done_testing;
Makefile.PL:
use ExtUtils::MakeMaker;
use FFI::Build::MM;
my $fbmm = FFI::Build::MM->new;
WriteMakefile(
$fbmm->mm_args(
NAME => 'Foo',
DISTNAME => 'Foo',
VERSION => '1.00',
# ...
)
);
sub MY::postamble
{
$fbmm->mm_postamble;
}
Execute
With prove:
$ prove -lvm
t/foo.t ..
# Seeded srand with seed '20221105' from local date.
ok 1 - Foo=SCALAR->isa('Foo')
ok 2
ok 3
1..3
ok
All tests successful.
Files=1, Tests=3, 0 wallclock secs ( 0.00 usr 0.00 sys + 0.10 cusr 0.00 csys = 0.10 CPU)
Result: PASS
With ExtUtils::MakeMaker:
$ perl Makefile.PL
Generating a Unix-style Makefile
Writing Makefile for Foo
Writing MYMETA.yml and MYMETA.json
$ make
cp lib/Foo.pm blib/lib/Foo.pm
"/home/ollisg/opt/perl/5.37.5/bin/perl5.37.5" -MFFI::Build::MM=cmd -e fbx_build
CC ffi/foo.c
LD blib/lib/auto/share/dist/Foo/lib/libFoo.so
$ make test
"/home/ollisg/opt/perl/5.37.5/bin/perl5.37.5" -MFFI::Build::MM=cmd -e fbx_build
"/home/ollisg/opt/perl/5.37.5/bin/perl5.37.5" -MFFI::Build::MM=cmd -e fbx_test
PERL_DL_NONLAZY=1 "/home/ollisg/opt/perl/5.37.5/bin/perl5.37.5" "-MExtUtils::Command::MM" "-MTest::Harness" "-e" "undef *Test::Harness::Switches; test_harness(0, 'blib/lib', 'blib/arch')" t/*.t
t/foo.t .. ok
All tests successful.
Files=1, Tests=3, 1 wallclock secs ( 0.00 usr 0.00 sys + 0.03 cusr 0.00 csys = 0.03 CPU)
Result: PASS
Discussion
You can bundle your own C code with your Perl extension. There are a
number of reasons you might want to do this Sometimes you need to
optimize a tight loop for speed. Or you might need a little bit of glue
code for your bindings to a library that isn't inherently FFI friendly.
Either way what you want is the FFI::Build system on the install step
and the FFI::Platypus::Bundle interface on the runtime step. If you are
using Dist::Zilla for your distribution, you will also want to check
out the Dist::Zilla::Plugin::FFI::Build plugin to make this as painless
as possible.
One of the nice things about the bundle interface is that it is smart
enough to work with either App::Prove or ExtUtils::MakeMaker. This
means, unlike XS, you do not need to explicitly compile your C code in
development mode, that will be done for you when you call $ffi->bundle
FAQ
How do I get constants defined as macros in C header files
This turns out to be a challenge for any language calling into C, which
frequently uses #define macros to define constants like so:
#define FOO_STATIC 1
#define FOO_DYNAMIC 2
#define FOO_OTHER 3
As macros are expanded and their definitions are thrown away by the C
pre-processor there isn't any way to get the name/value mappings from
the compiled dynamic library.
You can manually create equivalent constants in your Perl source:
use constant FOO_STATIC => 1;
use constant FOO_DYNAMIC => 2;
use constant FOO_OTHER => 3;
If there are a lot of these types of constants you might want to
consider using a tool (Convert::Binary::C can do this) that can extract
the constants for you.
See also the "Integer constants" example in FFI::Platypus::Type.
You can also use the new Platypus bundle interface to define Perl
constants from C space. This is more reliable, but does require a
compiler at install time. It is recommended mainly for writing bindings
against libraries that have constants that can vary widely from
platform to platform. See FFI::Platypus::Constant for details.
What about enums?
The C enum types are integers. The underlying type is up to the
platform, so Platypus provides enum and senum types for unsigned and
singed enums respectively. At least some compilers treat signed and
unsigned enums as different types. The enum values are essentially the
same as macro constants described above from an FFI perspective. Thus
the process of defining enum values is identical to the process of
defining macro constants in Perl.
For more details on enumerated types see "Enum types" in
FFI::Platypus::Type.
There is also a type plugin (FFI::Platypus::Type::Enum) that can be
helpful in writing interfaces that use enums.
Memory leaks
There are a couple places where memory is allocated, but never
deallocated that may look like memory leaks by tools designed to find
memory leaks like valgrind. This memory is intended to be used for the
lifetime of the perl process so there normally this isn't a problem
unless you are embedding a Perl interpreter which doesn't closely match
the lifetime of your overall application.
Specifically:
type cache
some types are cached and not freed. These are needed as long as
there are FFI functions that could be called.
attached functions
Attaching a function as an xsub will definitely allocate memory that
won't be freed because the xsub could be called at any time,
including in END blocks.
The Platypus team plans on adding a hook to free some of this "leaked"
memory for use cases where Perl and Platypus are embedded in a larger
application where the lifetime of the Perl process is significantly
smaller than the overall lifetime of the whole process.
I get seg faults on some platforms but not others with a library using
pthreads.
On some platforms, Perl isn't linked with libpthreads if Perl threads
are not enabled. On some platforms this doesn't seem to matter,
libpthreads can be loaded at runtime without much ill-effect. (Linux
from my experience doesn't seem to mind one way or the other). Some
platforms are not happy about this, and about the only thing that you
can do about it is to build Perl such that it links with libpthreads
even if it isn't a threaded Perl.
This is not really an FFI issue, but a Perl issue, as you will have the
same problem writing XS code for the such libraries.
Doesn't work on Perl 5.10.0.
The first point release of Perl 5.10 was buggy, and is not supported by
Platypus. Please upgrade to a newer Perl.
CAVEATS
Platypus and Native Interfaces like libffi rely on the availability of
dynamic libraries. Things not supported include:
Systems that lack dynamic library support
Like MS-DOS
Systems that are not supported by libffi
Like OpenVMS
Languages that do not support using dynamic libraries from other
languages
This used to be the case with Google's Go, but is no longer the case.
This is a problem for C / XS code as well.
Languages that do not compile to machine code
Like .NET based languages and Java.
The documentation has a bias toward using FFI / Platypus with C. This
is my fault, as my background mainly in C/C++ programmer (when I am not
writing Perl). In many places I use "C" as a short form for "any
language that can generate machine code and is callable from C". I
welcome pull requests to the Platypus core to address this issue. In an
attempt to ease usage of Platypus by non C programmers, I have written
a number of foreign language plugins for various popular languages (see
the SEE ALSO below). These plugins come with examples specific to those
languages, and documentation on common issues related to using those
languages with FFI. In most cases these are available for easy adoption
for those with the know-how or the willingness to learn. If your
language doesn't have a plugin YET, that is just because you haven't
written it yet.
SUPPORT
The intent of the FFI-Platypus team is to support the same versions of
Perl that are supported by the Perl toolchain. As of this writing that
means 5.16 and better.
IRC: #native on irc.perl.org
(click for instant chat room login)
If something does not work the way you think it should, or if you have
a feature request, please open an issue on this project's GitHub Issue
tracker:
https://github.com/perlFFI/FFI-Platypus/issues
SECURITY
If you have identified a security vulnerability in the code, or the
possibility of one, please report it right away using GitHub's private
vulnerability reporting feature at
https://github.com/PerlFFI/FFI-Platypus/security/advisories/new, rather
than this project's public GitHub issue tracker, so that a fix can be
prepared before any public disclosure.
The maintainer will try to respond promptly, and will release a fix as
soon as reasonably possible. Please keep in mind, though, that
FFI-Platypus is maintained by volunteers in their spare time, and a
rapid response cannot be guaranteed.
Security fixes will normally only be made for the most recent
production release.
You may also report the issue to CPANSec
, particularly if the issue is urgent
or you do not get a response from the maintainer in a reasonable amount
of time.
CONTRIBUTING
If you have implemented a new feature or fixed a bug then you may make
a pull request on this project's GitHub repository:
https://github.com/PerlFFI/FFI-Platypus/pulls
This project is developed using Dist::Zilla. The project's git
repository also comes with the Makefile.PL file necessary for building,
testing (and even installing if necessary) without Dist::Zilla. Please
keep in mind though that these files are generated so if changes need
to be made to those files they should be done through the project's
dist.ini file. If you do use Dist::Zilla and already have the necessary
plugins installed, then I encourage you to run dzil test before making
any pull requests. This is not a requirement, however, I am happy to
integrate especially smaller patches that need tweaking to fit the
project standards. I may push back and ask you to write a test case or
alter the formatting of a patch depending on the amount of time I have
and the amount of code that your patch touches.
This project's GitHub issue tracker listed above is not Write-Only. If
you want to contribute then feel free to browse through the existing
issues and see if there is something you feel you might be good at and
take a whack at the problem. I frequently open issues myself that I
hope will be accomplished by someone in the future but do not have time
to immediately implement myself.
Another good area to help out in is documentation. I try to make sure
that there is good document coverage, that is there should be
documentation describing all the public features and warnings about
common pitfalls, but an outsider's or alternate view point on such
things would be welcome; if you see something confusing or lacks
sufficient detail I encourage documentation only pull requests to
improve things.
The Platypus distribution comes with a test library named libtest that
is normally automatically built by ./Build test. If you prefer to use
prove or run tests directly, you can use the ./Build libtest command to
build it. Example:
% perl Makefile.PL
% make
% make ffi-test
% prove -bv t
# or an individual test
% perl -Mblib t/ffi_platypus_memory.t
The build process also respects these environment variables:
FFI_PLATYPUS_DEBUG_FAKE32
When building Platypus on 32 bit Perls, it will use the Math::Int64 C
API and make Math::Int64 a prerequisite. Setting this environment
variable will force Platypus to build with both of those options on a
64 bit Perl as well.
% env FFI_PLATYPUS_DEBUG_FAKE32=1 perl Makefile.PL
DEBUG_FAKE32:
+ making Math::Int64 a prereq
+ Using Math::Int64's C API to manipulate 64 bit values
Generating a Unix-style Makefile
Writing Makefile for FFI::Platypus
Writing MYMETA.yml and MYMETA.json
%
FFI_PLATYPUS_NO_ALLOCA
Platypus uses the non-standard and somewhat controversial C function
alloca by default on platforms that support it. I believe that
Platypus uses it responsibly to allocate small amounts of memory for
argument type parameters, and does not use it to allocate large
structures like arrays or buffers. If you prefer not to use alloca
despite these precautions, then you can turn its use off by setting
this environment variable when you run Makefile.PL:
helix% env FFI_PLATYPUS_NO_ALLOCA=1 perl Makefile.PL
NO_ALLOCA:
+ alloca() will not be used, even if your platform supports it.
Generating a Unix-style Makefile
Writing Makefile for FFI::Platypus
Writing MYMETA.yml and MYMETA.json
V
When building platypus may hide some of the excessive output when
probing and building, unless you set V to a true value.
% env V=1 perl Makefile.PL
% make V=1
...
Coding Guidelines
* Do not hesitate to make code contribution. Making useful
contributions is more important than following byzantine bureaucratic
coding regulations. We can always tweak things later.
* Please make an effort to follow existing coding style when making
pull requests.
* The intent of the FFI-Platypus team is to support the same versions
of Perl that are supported by the Perl toolchain. As of this writing
that means 5.16 and better. As such, please do not include any code
that requires a newer version of Perl.
Performance Testing
As Mark Twain was fond of saying there are four types of lies: lies,
damn lies, statistics and benchmarks. That being said, it can sometimes
be helpful to compare the runtime performance of Platypus if you are
making significant changes to the Platypus Core. For that I use
`FFI-Performance`, which can be found in my GitHub repository here:
https://github.com/Perl5-FFI/FFI-Performance
System integrators
This distribution uses Alien::FFI in fallback mode, meaning if the
system doesn't provide pkg-config and libffi it will attempt to
download libffi and build it from source. If you are including Platypus
in a larger system (for example a Linux distribution) you only need to
make sure to declare pkg-config or pkgconf and the development package
for libffi as prereqs for this module.
SEE ALSO
Extending Platypus
FFI::Platypus::Type
Type definitions for Platypus.
FFI::C
Interface for defining structured data records for use with Platypus.
It supports C struct, union, nested structures and arrays of all of
those. It only supports passing these types by reference or pointer,
so if you need to pass structured data by value see
FFI::Platypus::Record below.
FFI::Platypus::Record
Interface for defining structured data records for use with Platypus.
Included in the Platypus core. Supports pass by value which is
uncommon in C, but frequently used in languages like Rust and Go.
Consider using FFI::C instead if you don't need to pass by value.
FFI::Platypus::API
The custom types API for Platypus.
FFI::Platypus::Memory
Memory functions for FFI.
Languages
FFI::Platypus::Lang::C
Documentation and tools for using Platypus with the C programming
language
FFI::Platypus::Lang::CPP
Documentation and tools for using Platypus with the C++ programming
language
FFI::Platypus::Lang::Fortran
Documentation and tools for using Platypus with Fortran
FFI::Platypus::Lang::Go
Documentation and tools for using Platypus with Go
FFI::Platypus::Lang::Pascal
Documentation and tools for using Platypus with Free Pascal
FFI::Platypus::Lang::Rust
Documentation and tools for using Platypus with the Rust programming
language
FFI::Platypus::Lang::ASM
Documentation and tools for using Platypus with the Assembly
FFI::Platypus::Lang::Win32
Documentation and tools for using Platypus with the Win32 API.
FFI::Platypus::Lang::Zig
Documentation and tools for using Platypus with the Zig programming
language
Wasm and Wasm::Wasmtime
Modules for writing WebAssembly bindings in Perl. This allows you to
call functions written in any language supported by WebAssembly.
These modules are also implemented using Platypus.
Other Tools Related Tools Useful for FFI
FFI::CheckLib
Find dynamic libraries in a portable way.
Convert::Binary::C
A great interface for decoding C data structures, including structs,
enums, #defines and more.
pack and unpack
Native to Perl functions that can be used to decode C struct types.
C::Scan
This module can extract constants and other useful objects from C
header files that may be relevant to an FFI application. One downside
is that its use may require development packages to be installed.
Other Foreign Function Interfaces
Affix
A wrapper around infix , an
FFI-focused just-in-time (JIT) compiler.
NativeCall
Promising interface to Platypus inspired by Raku.
Win32::API
Microsoft Windows specific FFI style interface.
FFI
Older, simpler, less featureful FFI. It used to be implemented using
FSF's ffcall. Because ffcall has been unsupported for some time, I
reimplemented this module using FFI::Platypus.
C::DynaLib
Another FFI for Perl that doesn't appear to have worked for a long
time.
C::Blocks
Embed a tiny C compiler into your Perl scripts.
P5NCI
Yet another FFI like interface that does not appear to be supported
or under development anymore.
Other
Alien::FFI
Provides libffi for Platypus during its configuration and build
stages.
ACKNOWLEDGMENTS
In addition to the contributors mentioned below, I would like to
acknowledge Brock Wilcox (AWWAIID) and Meredith Howard (MHOWARD) whose
work on FFI::Sweet not only helped me get started with FFI but
significantly influenced the design of Platypus.
Dan Book, who goes by Grinnz on IRC for answering user questions about
FFI and Platypus.
In addition I'd like to thank Alessandro Ghedini (ALEXBIO) whose work
on another Perl FFI library helped drive some of the development ideas
for FFI::Platypus.
AUTHOR
Author: Graham Ollis
Contributors:
Bakkiaraj Murugesan (bakkiaraj)
Dylan Cali (calid)
pipcet
Zaki Mughal (zmughal)
Fitz Elliott (felliott)
Vickenty Fesunov (vyf)
Gregor Herrmann (gregoa)
Shlomi Fish (shlomif)
Damyan Ivanov
Ilya Pavlov (Ilya33)
Petr PÃsaÅ™ (ppisar)
Mohammad S Anwar (MANWAR)
Håkon Hægland (hakonhagland, HAKONH)
Meredith (merrilymeredith, MHOWARD)
Diab Jerius (DJERIUS)
Eric Brine (IKEGAMI)
szTheory
José JoaquÃn Atria (JJATRIA)
Pete Houston (openstrike, HOUSTON)
Lukas Mai (MAUKE)
COPYRIGHT AND LICENSE
This software is copyright (c) 2015-2022 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.
FFI-Platypus-2.12/SECURITY 000644 000000 000000 00000001662 15251066120 015034 0 ustar 00root root 000000 000000 SECURITY
If you have identified a security vulnerability in the code, or the
possibility of one, please report it right away using GitHub's private
vulnerability reporting feature at
https://github.com/PerlFFI/FFI-Platypus/security/advisories/new, rather
than this project's public GitHub issue tracker, so that a fix can be
prepared before any public disclosure.
The maintainer will try to respond promptly, and will release a fix as
soon as reasonably possible. Please keep in mind, though, that
FFI-Platypus is maintained by volunteers in their spare time, and a
rapid response cannot be guaranteed.
Security fixes will normally only be made for the most recent
production release.
You may also report the issue to CPANSec
, particularly if the issue is urgent
or you do not get a response from the maintainer in a reasonable amount
of time.
FFI-Platypus-2.12/SUPPORT 000644 000000 000000 00000001020 15251066120 014725 0 ustar 00root root 000000 000000 SUPPORT
The intent of the FFI-Platypus team is to support the same versions of
Perl that are supported by the Perl toolchain. As of this writing that
means 5.16 and better.
IRC: #native on irc.perl.org
(click for instant chat room login)
If something does not work the way you think it should, or if you have
a feature request, please open an issue on this project's GitHub Issue
tracker:
https://github.com/perlFFI/FFI-Platypus/issues
FFI-Platypus-2.12/author.yml 000644 000000 000000 00000006775 15251066120 015701 0 ustar 00root root 000000 000000 ---
pod_spelling_system:
skip: 0
# list of words that are spelled correctly
# (regardless of what spell check thinks)
stopwords:
- valgrind
- merrilymeredith
- longdouble
- sint
- uint
- parentheticals
- ffi
- xsub
- JIT
- xsubs
- libffi
- strdup
- libc
- libarchive
- free'd
- free'ing
- SIGSEGV
- Ctypes
- libm
- libnotify
- libuuid
- libzmq
- deparsed
- tcc
- fsprogs
- DLLs
- libtest
- bzip
- Fortran
- smushes
- Bakkiaraj
- Murugesan
- bakkiaraj
- demangling
- lang
- demangled
- alignof
- ALEXBIO
- AWWAIID
- Alessandro
- Ghedini
- MHOWARD
- JRuby
- Rubinius
- reimplemented
- Mughal
- Zaki
- zmughal
- Scala
- JVM
- integrators
- ABIs
- abis
- abi
- ABI
- pipcet
- FSF
- bzip2
- e2fsprogs
- g3
- sint8
- sint16
- sint32
- sint64
- uint8
- uint16
- uint32
- uint64
- x86
- calid
- Fitz
- felliott
- Fesunov
- Vickenty
- vyf
- Gregor
- Herrmann
- gregoa
- Damyan
- Ivanov
- Shlomi
- shlomif
- seg
- pthreads
- UNIXen
- dlclose
- dlerror
- dlopen
- dlsym
- libdl
- or'd
- customizations
- unmark
- unstick
- dlrun
- exe
- rv
- decl
- stmt
- dirname
- osname
- diag
- cflags
- fPIC
- ld
- ldflags
- buildname
- libs
- cxx
- shellwords
- fbx
- strndup
- Petr
- PÃsaÅ™
- ppisar
- Anwar
- MANWAR
- api
- deallocating
- deinitialization
- HAKONH
- hakonhagland
- kon
- merrilymeredith
- Grinnz
- DJERIUS
- Diab
- Jerius
- featureful
- countof
- kindof
- thet
- unitof
- const
- IKEGAMI
- BMP
- WebAssembly
- sensical
- eXtensions
- szTheory
- JJATRIA
- Joaqu
- Jos
- openstrike
- Raku
- cxxld
- dyncall
# for tl;dr
- tl
- winuser
- MessageBoxW
- Zig
- cppreference
- NULLs
- XORd
- decrypted
- varadic
- libcurl
- performant
- Lukas
- MAUKE
- HÃ¥kon
- Hægland
- José
- JoaquÃn
- CPANSec
pod_coverage:
skip: 0
# format is "Class#method" or "Class", regex allowed
# for either Class or method.
private:
- FFI::Platypus::Type::.*
- FFI::Platypus::Record::Meta
- FFI::Platypus::ShareConfig
- FFI::Platypus::Internal
- FFI::Platypus::Type
- FFI::Platypus::TypeParser
- FFI::Platypus::TypeParser::Version0
- FFI::Platypus::TypeParser::Version1
- FFI::Platypus::Closure#get_data
- FFI::Platypus::Closure#add_data
- FFI::Probe
- FFI::Platypus::Bundle
- FFI::Platypus::Constant
- App::fbx#main
- FFI::Build::File::Object#default_suffix
- FFI::Build::File::Library#default_suffix
- FFI::Build::File::C#cc
- FFI::Build::File::C#ld
- FFI::Build::File::C#accept_suffix
- FFI::Build::File::C#build_item_cpp
- FFI::Build::File::CXX#cc
- FFI::Build::File::CXX#ld
- FFI::Build::File::CXX#accept_suffix
- FFI::Build::File::Fortran#cc
- FFI::Build::File::Fortran#ld
- FFI::Build::File::Fortran#accept_suffix
- FFI::Build::File::C#build_item
- FFI::Build::File::Object#build_item
- FFI::Build::MM
- FFI::Build::Plugin
- FFI::Build::PluginData
- FFI::Platypus::Function#new
- FFI::Temp
FFI-Platypus-2.12/corpus/ 000755 000000 000000 00000000000 15251066120 015150 5 ustar 00root root 000000 000000 FFI-Platypus-2.12/corpus/ffi_build/ 000755 000000 000000 00000000000 15251066120 017073 5 ustar 00root root 000000 000000 FFI-Platypus-2.12/corpus/ffi_build/project-cxx/ 000755 000000 000000 00000000000 15251066120 021341 5 ustar 00root root 000000 000000 FFI-Platypus-2.12/corpus/ffi_build/project-cxx/foo1.cxx 000644 000000 000000 00000000167 15251066120 022735 0 ustar 00root root 000000 000000 class Foo {
public:
int answer() { return 42; };
};
extern "C" int
foo1()
{
Foo foo;
return foo.answer();
}
FFI-Platypus-2.12/corpus/ffi_build/project-cxx/foo2.cpp 000644 000000 000000 00000000523 15251066120 022712 0 ustar 00root root 000000 000000 // This requires C++11 (I believe)
// TODO: support older c++ compilers.
#include
class Foo2 {
public:
const char *answer() { return "42"; };
};
extern "C" const char *
foo2()
{
Foo2 foo;
return foo.answer();
}
extern "C" void
not_to_call_just_to_pull_in_the_stdcpp()
{
std::cout << "Hello There" << std::endl;
}
FFI-Platypus-2.12/corpus/ffi_build/project1/ 000755 000000 000000 00000000000 15251066120 020622 5 ustar 00root root 000000 000000 FFI-Platypus-2.12/corpus/ffi_build/project1/foo1.c 000644 000000 000000 00000000165 15251066120 021634 0 ustar 00root root 000000 000000 #ifdef _MSC_VER
#define EXPORT __declspec(dllexport)
#else
#define EXPORT
#endif
EXPORT
int
foo1()
{
return 42;
}
FFI-Platypus-2.12/corpus/ffi_build/project1/foo2.c 000644 000000 000000 00000000200 15251066120 021623 0 ustar 00root root 000000 000000 #ifdef _MSC_VER
#define EXPORT __declspec(dllexport)
#else
#define EXPORT
#endif
EXPORT
const char *
foo2()
{
return "42";
}
FFI-Platypus-2.12/corpus/ffi_build/project2/ 000755 000000 000000 00000000000 15251066120 020623 5 ustar 00root root 000000 000000 FFI-Platypus-2.12/corpus/ffi_build/project2/bar.c 000644 000000 000000 00000000101 15251066120 021523 0 ustar 00root root 000000 000000 #include
int myanswer()
{
return answer();
}
FFI-Platypus-2.12/corpus/ffi_build/source/ 000755 000000 000000 00000000000 15251066120 020373 5 ustar 00root root 000000 000000 FFI-Platypus-2.12/corpus/ffi_build/source/foo.c 000644 000000 000000 00000000000 15251066120 021310 0 ustar 00root root 000000 000000 FFI-Platypus-2.12/corpus/ffi_build_file_base/ 000755 000000 000000 00000000000 15251066120 021064 5 ustar 00root root 000000 000000 FFI-Platypus-2.12/corpus/ffi_build_file_base/basic.foo 000644 000000 000000 00000000025 15251066120 022647 0 ustar 00root root 000000 000000 This is a basic foo.
FFI-Platypus-2.12/corpus/ffi_build_file_c/ 000755 000000 000000 00000000000 15251066120 020374 5 ustar 00root root 000000 000000 FFI-Platypus-2.12/corpus/ffi_build_file_c/basic.c 000644 000000 000000 00000000105 15251066120 021615 0 ustar 00root root 000000 000000 #include
int
main(int argc, char *argv[])
{
return 0;
}
FFI-Platypus-2.12/corpus/ffi_build_file_c/foo1.c 000644 000000 000000 00000000034 15251066120 021401 0 ustar 00root root 000000 000000 int
foo1()
{
return 42;
}
FFI-Platypus-2.12/corpus/ffi_build_file_c/foo2.c 000644 000000 000000 00000000057 15251066120 021407 0 ustar 00root root 000000 000000 #include
int
foo1()
{
return 42;
}
FFI-Platypus-2.12/corpus/ffi_build_file_c/include/ 000755 000000 000000 00000000000 15251066120 022017 5 ustar 00root root 000000 000000 FFI-Platypus-2.12/corpus/ffi_build_file_c/include/myfoo.h 000644 000000 000000 00000000123 15251066120 023315 0 ustar 00root root 000000 000000 #ifndef MYFOO_H
#define MYFOO_H
/* this doesn't do anything apparently */
#endif
FFI-Platypus-2.12/corpus/ffi_build_file_cxx/ 000755 000000 000000 00000000000 15251066120 020754 5 ustar 00root root 000000 000000 FFI-Platypus-2.12/corpus/ffi_build_file_cxx/basic.cxx 000644 000000 000000 00000000151 15251066120 022556 0 ustar 00root root 000000 000000 #include
int
main(int argc, char *argv[])
{
cout << "hello world" << endl;
return 0;
}
FFI-Platypus-2.12/corpus/ffi_build_file_cxx/foo1.cxx 000644 000000 000000 00000000171 15251066120 022343 0 ustar 00root root 000000 000000 class Foo {
public:
int answer() { return 42; };
};
int
foo1()
{
// comment
Foo foo;
return foo.answer();
}
FFI-Platypus-2.12/corpus/ffi_build_file_cxx/foo2.cpp 000644 000000 000000 00000000170 15251066120 022323 0 ustar 00root root 000000 000000 #include
class Foo {
public:
int answer() { return 42; };
};
int
foo1()
{
// comment
return 42;
}
FFI-Platypus-2.12/corpus/ffi_build_file_cxx/include/ 000755 000000 000000 00000000000 15251066120 022377 5 ustar 00root root 000000 000000 FFI-Platypus-2.12/corpus/ffi_build_file_cxx/include/myfoo.h 000644 000000 000000 00000000123 15251066120 023675 0 ustar 00root root 000000 000000 #ifndef MYFOO_H
#define MYFOO_H
/* this doesn't do anything apparently */
#endif
FFI-Platypus-2.12/corpus/ffi_build_mm/ 000755 000000 000000 00000000000 15251066120 017564 5 ustar 00root root 000000 000000 FFI-Platypus-2.12/corpus/ffi_build_mm/lb1/ 000755 000000 000000 00000000000 15251066120 020242 5 ustar 00root root 000000 000000 FFI-Platypus-2.12/corpus/ffi_build_mm/lb1/hello.fbx 000644 000000 000000 00000000206 15251066120 022044 0 ustar 00root root 000000 000000 use strict;
use warnings;
our $DIR;
our $PLATFORM;
die unless $PLATFORM->isa('FFI::Build::Platform');
{ source => [ "$DIR/*.c" ] };
FFI-Platypus-2.12/corpus/ffi_build_mm/lb1/hello1.c 000644 000000 000000 00000000000 15251066120 021560 0 ustar 00root root 000000 000000 FFI-Platypus-2.12/corpus/ffi_build_mm/lb1/hello2.c 000644 000000 000000 00000000000 15251066120 021561 0 ustar 00root root 000000 000000 FFI-Platypus-2.12/corpus/ffi_build_mm/lb1bad/ 000755 000000 000000 00000000000 15251066120 020711 5 ustar 00root root 000000 000000 FFI-Platypus-2.12/corpus/ffi_build_mm/lb1bad/hello.fbx 000644 000000 000000 00000000226 15251066120 022515 0 ustar 00root root 000000 000000 use strict;
use warnings;
skootch skootch;
our $DIR;
our $PLATFORM;
die unless $PLATFORM->isa('FFI::Build::Platform');
{ source => [ "$DIR/*.c" ] };
FFI-Platypus-2.12/corpus/ffi_build_mm/lb1bad/hello1.c 000644 000000 000000 00000000000 15251066120 022227 0 ustar 00root root 000000 000000 FFI-Platypus-2.12/corpus/ffi_build_mm/lb1bad/hello2.c 000644 000000 000000 00000000000 15251066120 022230 0 ustar 00root root 000000 000000 FFI-Platypus-2.12/corpus/ffi_build_mm/lb2/ 000755 000000 000000 00000000000 15251066120 020243 5 ustar 00root root 000000 000000 FFI-Platypus-2.12/corpus/ffi_build_mm/lb2/hello1.c 000644 000000 000000 00000000000 15251066120 021561 0 ustar 00root root 000000 000000 FFI-Platypus-2.12/corpus/ffi_build_mm/lb2/hello2.c 000644 000000 000000 00000000000 15251066120 021562 0 ustar 00root root 000000 000000 FFI-Platypus-2.12/corpus/ffi_build_mm/project1/ 000755 000000 000000 00000000000 15251066120 021313 5 ustar 00root root 000000 000000 FFI-Platypus-2.12/corpus/ffi_build_mm/project1/ffi/ 000755 000000 000000 00000000000 15251066120 022057 5 ustar 00root root 000000 000000 FFI-Platypus-2.12/corpus/ffi_build_mm/project1/ffi/x.c 000644 000000 000000 00000000200 15251066120 022462 0 ustar 00root root 000000 000000 #ifdef _MSC_VER
#define EXPORT __declspec(dllexport)
#else
#define EXPORT
#endif
EXPORT
int
frooble_runtime()
{
return 47;
}
FFI-Platypus-2.12/corpus/ffi_build_mm/project1/ffi/y.c 000644 000000 000000 00000000000 15251066120 022461 0 ustar 00root root 000000 000000 FFI-Platypus-2.12/corpus/ffi_build_mm/project1/ffi/z.c 000644 000000 000000 00000000000 15251066120 022462 0 ustar 00root root 000000 000000 FFI-Platypus-2.12/corpus/ffi_build_mm/project1/t/ 000755 000000 000000 00000000000 15251066120 021556 5 ustar 00root root 000000 000000 FFI-Platypus-2.12/corpus/ffi_build_mm/project1/t/ffi/ 000755 000000 000000 00000000000 15251066120 022322 5 ustar 00root root 000000 000000 FFI-Platypus-2.12/corpus/ffi_build_mm/project1/t/ffi/a.c 000644 000000 000000 00000000175 15251066120 022711 0 ustar 00root root 000000 000000 #ifdef _MSC_VER
#define EXPORT __declspec(dllexport)
#else
#define EXPORT
#endif
EXPORT
int
frooble_test()
{
return 50;
}
FFI-Platypus-2.12/corpus/ffi_build_mm/project1/t/ffi/b.c 000644 000000 000000 00000000000 15251066120 022675 0 ustar 00root root 000000 000000 FFI-Platypus-2.12/corpus/ffi_build_mm/project1/t/ffi/c.c 000644 000000 000000 00000000000 15251066120 022676 0 ustar 00root root 000000 000000 FFI-Platypus-2.12/corpus/ffi_build_plugin/ 000755 000000 000000 00000000000 15251066120 020451 5 ustar 00root root 000000 000000 FFI-Platypus-2.12/corpus/ffi_build_plugin/lib1/ 000755 000000 000000 00000000000 15251066120 021300 5 ustar 00root root 000000 000000 FFI-Platypus-2.12/corpus/ffi_build_plugin/lib1/FFI/ 000755 000000 000000 00000000000 15251066120 021704 5 ustar 00root root 000000 000000 FFI-Platypus-2.12/corpus/ffi_build_plugin/lib1/FFI/Build/ 000755 000000 000000 00000000000 15251066120 022743 5 ustar 00root root 000000 000000 FFI-Platypus-2.12/corpus/ffi_build_plugin/lib1/FFI/Build/Plugin/ 000755 000000 000000 00000000000 15251066120 024201 5 ustar 00root root 000000 000000 FFI-Platypus-2.12/corpus/ffi_build_plugin/lib1/FFI/Build/Plugin/blank.txt 000644 000000 000000 00000000001 15251066120 026020 0 ustar 00root root 000000 000000
FFI-Platypus-2.12/corpus/ffi_build_plugin/lib2/ 000755 000000 000000 00000000000 15251066120 021301 5 ustar 00root root 000000 000000 FFI-Platypus-2.12/corpus/ffi_build_plugin/lib2/FFI/ 000755 000000 000000 00000000000 15251066120 021705 5 ustar 00root root 000000 000000 FFI-Platypus-2.12/corpus/ffi_build_plugin/lib2/FFI/Build/ 000755 000000 000000 00000000000 15251066120 022744 5 ustar 00root root 000000 000000 FFI-Platypus-2.12/corpus/ffi_build_plugin/lib2/FFI/Build/Plugin/ 000755 000000 000000 00000000000 15251066120 024202 5 ustar 00root root 000000 000000 FFI-Platypus-2.12/corpus/ffi_build_plugin/lib2/FFI/Build/Plugin/Foo1.pm 000644 000000 000000 00000000323 15251066120 025342 0 ustar 00root root 000000 000000 package FFI::Build::Plugin::Foo1;
use strict;
use warnings;
use constant api_version => 0;
sub new
{
my($class) = @_;
bless {}, $class;
}
sub bar
{
my($self, @args) = @_;
$self->{bar} = \@args;
}
1;
FFI-Platypus-2.12/corpus/ffi_build_plugin/lib2/FFI/Build/Plugin/Foo2.pm 000644 000000 000000 00000000224 15251066120 025343 0 ustar 00root root 000000 000000 package FFI::Build::Plugin::Foo2;
use strict;
use warnings;
use constant api_version => 0;
sub new
{
my($class) = @_;
bless {}, $class;
}
1;
FFI-Platypus-2.12/corpus/ffi_probe_runner/ 000755 000000 000000 00000000000 15251066120 020474 5 ustar 00root root 000000 000000 FFI-Platypus-2.12/corpus/ffi_probe_runner/bar.c 000644 000000 000000 00000000333 15251066120 021403 0 ustar 00root root 000000 000000 #include
int
dlmain(int argc, char *argv[])
{
int i;
printf("argc=%d\n", argc);
for(i=0;i