ExtUtils::Typemaps::OutputMap(3p)

NAME
ExtUtils::Typemaps::OutputMap - 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
Refer to ExtUtils::Typemaps for details.

METHODS

  new
Requires "xstype" and "code" parameters.

  code
Returns or sets the OUTPUT mapping code for this entry.

  xstype
Returns the name of the XS type of the OUTPUT map.

  cleaned_code
Returns a cleaned-up copy of the code to which certain transformations have been applied to make it more ANSI compliant.

  targetable_legacy
Do not use for new code.

This is the original version of the targetable() method, whose behaviour has been frozen for backwards compatibility. It is used to determine 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 continue to declare it under the same conditions as before. The newer "targetable" method may be true under additional circumstances.

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 an 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 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).

SEE ALSO
ExtUtils::Typemaps

AUTHOR
Steffen Mueller "<smueller@cpan.org">

COPYRIGHT & LICENSE
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.