EXTUTILS::TYPEMAPS::OUTPUTMAP(3perl)

πŸ’– ExtUtils::Typemaps::OutputMap πŸ’–

okay bestie so this is part of the Perl Programmers Reference Guide β€” it's ExtUtils::Typemaps::OutputMap, and it's literally one single entry in the OUTPUT section of a typemap. one (1) entry. that's the whole job. tiny but iconic ✨


✨ NAME ✨

ExtUtils::Typemaps::OutputMap β€” the entry in the OUTPUT section of a typemap 🫢


🌸 SYNOPSIS 🌸

use ExtUtils::Typemaps;
...
my $output = $typemap->get_output_map('T_NV');
my $code = $output->code();
$output->code("...");

πŸ¦‹ DESCRIPTION πŸ¦‹

ngl there's not a ton here β€” you gotta go look at ExtUtils::Typemaps for the details, that's where the lore lives πŸ’…


πŸ‘‘ METHODS πŸ‘‘

πŸŽ€ new

Takes xstype and code parameters, and it requires them. both of them. no skipping, bestie, it's not optional 😀

πŸŽ€ code

Returns or sets the OUTPUT mapping code for this entry. you're getting it or you're setting it, those are the vibes 🫢

πŸŽ€ xstype

Returns the name of the XS type of the OUTPUT map. just the name. that's it ✨

πŸŽ€ cleaned_code

Returns a cleaned-up copy of the code, where certain transformations have been applied to make it more ANSI compliant. glow-up but for code πŸ’…

πŸŽ€ targetable_legacy

🚨 bestie do NOT use this for new code. periodt. it's legacy for a reason πŸ™ˆ

So this is the original version of the targetable() method, and its behaviour has been frozen for backwards compatibility β€” like, preserved in amber, not getting touched, we're just leaving it there. It's used to decide whether to emit an early dXSTARG, which will be in scope for most of the XSUB. More recent XSUB code generation emits a dXSTARG in a tighter scope if one has not already been emitted. Some XS code assumes that TARG has been declared, so we continue to declare it under the same conditions as before. The newer targetable method may be true under additional circumstances. so like, similar but not the same, iykyk.

If the optimization can not be applied, this returns undef. If it can be applied, this method returns a hash reference containing the following information:

type:      Any of the characters i, u, n, p
with_size: Bool indicating whether this is the sv_setpvn variant
what:      The code that actually evaluates to the output scalar
what_size: If "with_size", this has the string length (as code,
           not constant, including leading comma)

πŸŽ€ targetable

Class method. 🫢

Return a boolean indicating whether the supplied code snippet is suitable for using TARG as the destination SV rather than a new mortal.

In principle most things are, except expressions which would set the SV to a ref value. That can cause the referred value to never be freed, as targs aren't freed (at least for the lifetime of their CV). so yeah, memory leak coded behaviour, we're avoiding that πŸ’€

So in practice, we restrict it to an approved list of sv_setfoo() forms, and only where there is no extra code following the sv_setfoo() (so we have to match the closing bracket, allowing for nested brackets etc within). very much a vibe check on the brackets, honestly πŸŽ€


🌈 SEE ALSO 🌈

  • ExtUtils::Typemaps

πŸ’œ AUTHOR πŸ’œ

Steffen Mueller "<smueller@cpan.org>" πŸ‘‘


Copyright 2009, 2010, 2011, 2012 Steffen Mueller

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


okay that's the whole page bestie, you ate that 🫢 this was perl v5.44.0, dated 2026-10-17, from the Perl Programmers Reference Guide β€” mwah, go read ExtUtils::Typemaps next, love u bye πŸ’–βœ¨πŸ¦‹

πŸ“¦ where this page comes from
  • arch rolling: perl 5.44.0-1 Β· Artistic-1.0-Perl AND GPL-1.0-or-later
  • πŸ’– girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms