The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

XS::Framework::Manual::SVAPI::Scope - XS::Framework scope utils

Scope::Hints - compiler scope hints

Overview

This class contains static methods for setting scope hints at compile time and getting it in runtime.

Example:

    use MyModule::strict_mode; # MyModule::strict_mode::import() XS function calls Scope::Hints::set
    ...
    MyModule::somefunc($arg); # XS function may use Scope::Hints::get to alter its behaviour
    ...
    no MyModule::strict_mode; # MyModule::strict_mode::unimport() XS function calls Scope::Hints::remove

void set (string_view name, const Sv& value)

Set hint name with value value. Must be called at compile time to take effect, i.e. from XS import() function or from XS function that is called from BEGIN block.

    Scope::Hints::set("myhint", Simple("myvalue"));

Have the same effect as calling from perl

    BEGIN { $^H{myhint} = "myvalue" }

void remove (string_view name)

Removes hint name and its associated value. Must be called at compile time to take effect (usually from unimport()).

bool exists (string_view name)

Returns true if hint name exists in current scope. Must be called at runtime.

Scalar get (string_view name)

Returns value associated with hint name or empty scalar if no such hint in scope. Must be called at runtime.

Hash get ()

Returns all hints and their values in scope as hashref. Must be called at runtime.

Scalar get_ct (string_view name)

Compile-time version of get(name). Returns value associated with hint name or empty scalar if no such hint enabled. Must be called at compile time.

Have the same effect as calling from perl

    BEGIN { my $val = $^H{myhint}; }

SEE ALSO

XS::Framework

XS::Framework::Manual::SVAPI