logo
Free, unlimited AI code reviews that run on commit
git-lrc git-lrc GitHub Install Now We'd appreciate a star git-lrc - Free, unlimited AI code reviews that run on commit | Product Hunt git-lrc - Free, unlimited AI code reviews that run on commit | Product Hunt

FFI::Platypus::Type::StringPointer - Convert a pointer to a string and back

Author

       Author: Graham Ollis <plicease@cpan.org>

       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)

Description

NOTE: As of version 0.61, this custom type is now deprecated since pointers to strings are supported in
       the FFI::Platypus directly without custom types.

       This module provides a FFI::Platypus custom type for pointers to strings.

Name

       FFI::Platypus::Type::StringPointer - Convert a pointer to a string and back

See Also

       FFI::Platypus
           Main Platypus documentation.

       FFI::Platypus::Type
           Platypus types documentation.

Synopsis

       In your C code:

        void
        string_pointer_argument(const char **string)
        {
          ...
        }
        const char **
        string_pointer_return(void)
        {
          ...
        }

       In your Platypus::FFI code:

        use FFI::Platypus 2.00;

        my $ffi = FFI::Platypus->new( api => 2 );
        $ffi->load_custom_type('::StringPointer' => 'string_pointer');

        $ffi->attach(string_pointer_argument => ['string_pointer'] => 'void');
        $ffi->attach(string_pointer_return   => [] => 'string_pointer');

        my $string = "foo";

        string_pointer_argument(\$string); # $string may be modified

        $ref = string_pointer_return();

        print $$ref;  # print the string pointed to by $ref

Version

       version 2.10

See Also