1package FFI::Platypus::Record::Meta; 2 3use strict; 4use warnings; 5use 5.008004; 6 7# ABSTRACT: FFI support for structured records data 8our $VERSION = '1.56'; # VERSION 9 10 11{ 12 require FFI::Platypus; 13 my $ffi = FFI::Platypus->new( 14 api => 1, 15 ); 16 $ffi->bundle; 17 $ffi->mangler(sub { 18 my($name) = @_; 19 $name =~ s/^/ffi_platypus_record_meta__/; 20 $name; 21 }); 22 23 $ffi->type('opaque' => 'ffi_type'); 24 25 $ffi->custom_type('meta_t' => { 26 native_type => 'opaque', 27 perl_to_native => sub { 28 ${ $_[0] }; 29 }, 30 }); 31 32 $ffi->attach( _find_symbol => ['string'] => 'ffi_type'); 33 34 $ffi->attach( new => ['ffi_type[]','int'] => 'meta_t', sub { 35 my($xsub, $class, $elements, $closure_safe) = @_; 36 37 if(ref($elements) ne 'ARRAY') 38 { 39 require Carp; 40 Carp::croak("passed something other than a array ref to @{[ __PACKAGE__ ]}"); 41 } 42 43 my @element_type_pointers; 44 foreach my $element_type (@$elements) 45 { 46 my $ptr = _find_symbol($element_type); 47 if($ptr) 48 { 49 push @element_type_pointers, $ptr; 50 } 51 else 52 { 53 require Carp; 54 Carp::croak("unknown type: $element_type"); 55 } 56 } 57 58 push @element_type_pointers, undef; 59 60 my $ptr = $xsub->(\@element_type_pointers, $closure_safe); 61 bless \$ptr, $class; 62 }); 63 64 $ffi->attach( ffi_type => ['meta_t'] => 'ffi_type' ); 65 $ffi->attach( size => ['meta_t'] => 'size_t' ); 66 $ffi->attach( alignment => ['meta_t'] => 'ushort' ); 67 $ffi->attach( element_pointers => ['meta_t'] => 'ffi_type[]' ); 68 69 $ffi->attach( DESTROY => ['meta_t'] => 'void' ); 70} 71 72sub ptr { ${ shift() } } 73 741; 75 76__END__ 77 78=pod 79 80=encoding UTF-8 81 82=head1 NAME 83 84FFI::Platypus::Record::Meta - FFI support for structured records data 85 86=head1 VERSION 87 88version 1.56 89 90=head1 DESCRIPTION 91 92This class is private to FFI::Platypus. See L<FFI::Platypus::Record> for 93the public interface to Platypus records. 94 95=head1 AUTHOR 96 97Author: Graham Ollis E<lt>plicease@cpan.orgE<gt> 98 99Contributors: 100 101Bakkiaraj Murugesan (bakkiaraj) 102 103Dylan Cali (calid) 104 105pipcet 106 107Zaki Mughal (zmughal) 108 109Fitz Elliott (felliott) 110 111Vickenty Fesunov (vyf) 112 113Gregor Herrmann (gregoa) 114 115Shlomi Fish (shlomif) 116 117Damyan Ivanov 118 119Ilya Pavlov (Ilya33) 120 121Petr Písař (ppisar) 122 123Mohammad S Anwar (MANWAR) 124 125Håkon Hægland (hakonhagland, HAKONH) 126 127Meredith (merrilymeredith, MHOWARD) 128 129Diab Jerius (DJERIUS) 130 131Eric Brine (IKEGAMI) 132 133szTheory 134 135José Joaquín Atria (JJATRIA) 136 137Pete Houston (openstrike, HOUSTON) 138 139=head1 COPYRIGHT AND LICENSE 140 141This software is copyright (c) 2015,2016,2017,2018,2019,2020 by Graham Ollis. 142 143This is free software; you can redistribute it and/or modify it under 144the same terms as the Perl 5 programming language system itself. 145 146=cut 147