The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.

NAME

ExtUtils::Typemaps::Slurp - Typemap for storing objects as a string reference

VERSION

version 0.001

SYNOPSIS

In typemap

 my_init_t    T_SLURP_VAR
 My::Object   T_OPAQUEOBJ

In your XS:

 static void my_init_t_gather(my_init_t* init, size_t count, SV** args) {
     ...;
 }

 typedef object_t* My__Object;

 static object_t* object_new(my_init_t* init_arg) {
     ...;
 }
 
 MODULE = My::Object    PACKAGE = My::Object    PREFIX = object_
 
 My::Object object_new(SV* class, my_init_t arguments, ...)
        C_ARGS: &arguments

DESCRIPTION

ExtUtils::Typemaps::Slurp is a typemap bundle that provides three typemaps that will all slurp all remaining arguments to an xsub: T_SLURP_VAL, T_SLURP_VAR and T_SLURP_AV. This should always be used as final argument, and should be followed by a ... argument.

T_SLURP_VAL expects you to define a function $type ${ntype}_gather(SV** arguments, size_t count). It will call that function with the argument, and it will return the appropriate value.

T_SLURP_VAR expects you to define a function void ${ntype}_gather($type* var, SV** arguments, Size_t count). It works much the same as TL_SLURP_VAL except it takes a pointer as its first argument that it will store the value in instead of returning it.

T_SLURP_AV is a specialization of T_SLURP_VAL that returns the values as an AV*.

INCLUSION

To use this typemap template you need to include it into your local typemap. The easiest way to do that is to use the typemap script in App::typemap. E.g.

 typemap --merge ExtUtils::Typemaps::IntObj

If you author using Dist::Zilla you can use Dist::Zilla::Plugin::Typemap instead.

Alternatively, you can include it at runtime by adding the following to your XS file:

 INCLUDE_COMMAND: $^X -MExtUtils::Typemaps::Cmd -e "print embeddable_typemap('IntObj')"

That does require adding a build time dependency on this module.

AUTHOR

Leon Timmermans <fawaka@gmail.com>

COPYRIGHT AND LICENSE

This software is copyright (c) 2024 by Leon Timmermans.

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.