B::Hoo...bForCV(3pm)

πŸ’– NAME πŸ’–

B::Hooks::OP::Check::EntersubForCV β€” bestie, this one lets you invoke callbacks on construction of entersub OPs for certain CVs. no cap. πŸ¦‹


✨ SYNOPSIS ✨

πŸ’… From Perl

sub foo {}

use B::Hooks::OP::Check::EntersubForCV
    \&foo => sub { warn "entersub for foo() being compiled" };

foo(); # callback is invoked when this like is compiled

no B::Hooks::OP::Check::EntersubForCV \&foo;

foo(); # callback isn't invoked

πŸ’… From C/XS

#include "hook_op_check_entersubforcv.h"

STATIC OP *
my_callback (pTHX_ OP *op, CV *cv, void *user_data) {
    /* ... */
    return op;
}

hook_op_check_id id;

/* register callback */
id = hook_op_check_entersubforcv (cv, my_callback, NULL);

/* unregister */
hook_op_check_entersubforcv_remove (id);

🌸 DESCRIPTION 🌸

Perl API

πŸŽ€ import / register

use B::Hooks::OP::Check::EntersubForCV
    \&code => \&handler;

# or
my $id = B::Hooks::OP::Check::EntersubForCV::register(\&code => \&handler);

Okay so what this does: you register a "handler", and that handler gets executed when an entersub opcode for the CV that "code" points to gets compiled. it's giving "notice me when this gets built" energy.

And when you go through register instead? it hands you back an id, and you can use that id later to remove the handler with unregister. keep it in your pocket, bestie. 🫢

πŸŽ€ unimport / unregister

no B::Hooks::OP::Check::EntersubForCV \&code;

# or
B::Hooks::OP::Check::EntersubForCV::unregister($id);

This one stops calling the registered handler for "code" for all entersubs after this point. like, goodbye, we're done, no more texts. πŸ’…

C API

πŸ¦‹ TYPES

OP *(*hook_op_check_entersubforcv_cb) (pTHX_ OP *, CV *, void *)

This is the type that the handlers need to implement. you gotta match the signature, periodt.

πŸ¦‹ FUNCTIONS

hook_op_check_id hook_op_check_entersubforcv (CV *cv,
hook_op_check_entersubforcv_cb cb, void *user_data)

Register the callback "cb" to be called when an entersub opcode for "cv" is compiled. and "user_data"? that gets passed to the callback as the last argument, so it can carry whatever you want with it. iconic behavior honestly.

Returns an id that you can use to remove the handler using hook_op_check_entersubforcv_remove.

void *hook_op_check_entersubforcv_remove (hook_op_check_id id)

Remove a previously registered handler referred to by "id".

And it returns the user data that was associated with the handler. giving it back to you like a good friend returning your hoodie. 🧚


πŸ‘‘ SEE ALSO πŸ‘‘

  • B::Hooks::OP::Check

πŸ’œ AUTHOR πŸ’œ

Florian Ragwitz <rafl@debian.org>


Copyright (c) 2008, 2009 Florian Ragwitz

Copyright (c) 2011, 2012, 2017 Andrew Main (Zefram)

This module is free software.

You may distribute this code under the same terms as Perl itself.


okay that's the whole page bestie, you ate it πŸ’– and just so you know the receipts: this is perl v5.42.3, dated 2026-08-20, and it lives in the manual as B::Hoo...bForCV(3pm) (yes that's the truncated title, she's mysterious like that ✨). go compile something iconic πŸ’…πŸŒΈ

πŸ“¦ where this page comes from