Ancient

 view release on metacpan or  search on metacpan

Changes  view on Meta::CPAN


0.17    2026-02-03
        - object: Add DEMOLISH support for destructor callbacks
          * Define DEMOLISH method in class, auto-wrapped DESTROY installed
          * Zero overhead: wrapper only installed if DEMOLISH exists
        - object: Add Role system for reusable slot/method bundles
          * object::role($name, @slots) - define a role with slots
          * object::requires($role, @methods) - declare required methods
          * object::with($class, @roles) - compose roles into class
          * object::does($obj, $role) - check role consumption
          * Copies slots and methods, validates required methods
        - object: Add Method Modifiers (before/after/around)
          * object::before('Class::method', \&callback)
          * object::after('Class::method', \&callback)
          * object::around('Class::method', sub { my ($orig, $self) = @_; ... })
          * Multiple modifiers stack correctly
          * Zero overhead: wrapper only installed when modifier added
        - object: Add lazy/builder support for deferred slot initialization
          * 'slot:Type:lazy:builder(_build_method)' syntax
          * Value computed on first access, cached thereafter
        - object: Add clearer/predicate support

lib/object.pm  view on Meta::CPAN

Register a type with C-level check and optional coercion functions.
Call from your BOOT section. The type name can then be used in
C<object::define()> slot specifications.

Parameters:

=over 4

=item * C<name> - Type name (e.g., "PositiveInt", "Email")

=item * C<check> - C function to validate values (required)

=item * C<coerce> - C function to coerce values (optional, pass NULL)

=back

=head4 ObjectTypeCheckFunc

    typedef bool (*ObjectTypeCheckFunc)(pTHX_ SV *val);

Type check function signature. Return true if value passes the check.

t/1061-util-valid-hof.t  view on Meta::CPAN


    is(pipeline(5, $add10, $add20), 35, 'partial in pipeline: 5+10+20');
};

subtest 'real-world use case: validation chain' => sub {
    # Build validators using HOFs
    my $not_empty = sub { defined $_[0] && length($_[0]) > 0 };
    my $max_len = sub { my $max = $_[0]; sub { length($_[0]) <= $max } };
    my $min_len = sub { my $min = $_[0]; sub { length($_[0]) >= $min } };

    my $validate_username = sub {
        my $val = $_[0];
        return 0 unless $not_empty->($val);
        return 0 unless $min_len->(3)->($val);
        return 0 unless $max_len->(20)->($val);
        return 1;
    };

    ok($validate_username->("alice"), 'valid username');
    ok(!$validate_username->("ab"), 'too short');
    ok(!$validate_username->("a" x 25), 'too long');
    ok(!$validate_username->(""), 'empty');
};

subtest 'real-world use case: retry logic' => sub {
    my $attempts = 0;
    my $fail_twice = sub {
        $attempts++;
        die "fail" if $attempts <= 2;
        return "success";
    };

t/7028-nvec-numerical-validation.t  view on Meta::CPAN

#!/usr/bin/env perl
# Test nvec numerical validation with known mathematical identities
# These tests validate correctness across precision levels
use strict;
use warnings;
use Test::More;
use lib 'blib/lib', 'blib/arch', 't/lib';

use nvec;
use TestVec qw(is_quadmath approx_eq vec_approx_eq get_tolerance within_tolerance);

my $is_quad = is_quadmath();
if ($is_quad) {

xs/const/ppport.h  view on Meta::CPAN

uvoffuni_to_utf8_flags|5.027009||cV
uvoffuni_to_utf8_flags_msgs|5.027009||cVu
UVSIZE|5.006000|5.003007|poVn
UVTYPE|5.006000|5.003007|poVn
UVuf|5.006000|5.003007|poVn
uvuni_to_utf8|5.019004||cVu
uvuni_to_utf8_flags|5.007003||dcV
UVxf|5.006000|5.003007|poVn
UVXf|5.007001|5.007001|poVn
VAL_EAGAIN|5.003007|5.003007|Vn
validate_proto|5.019002||xcVi
validate_suid|||iu
valid_utf8_to_uvchr|5.015009||cVn
valid_utf8_to_uvuni|5.015009||dcVu
VAL_O_NONBLOCK|5.003007|5.003007|Vn
variant_byte_number|5.031004||cVnu
variant_under_utf8_count|5.027007||Vni
varname|5.009003||Viu
vcmp|5.009000|5.009000|
VCMP|5.019008||Viu
vcroak|5.006000|5.006000|
vdeb|5.007003|5.007003|u

xs/doubly/ppport.h  view on Meta::CPAN

uvoffuni_to_utf8_flags|5.027009||cV
uvoffuni_to_utf8_flags_msgs|5.027009||cVu
UVSIZE|5.006000|5.003007|poVn
UVTYPE|5.006000|5.003007|poVn
UVuf|5.006000|5.003007|poVn
uvuni_to_utf8|5.019004||cVu
uvuni_to_utf8_flags|5.007003||dcV
UVxf|5.006000|5.003007|poVn
UVXf|5.007001|5.007001|poVn
VAL_EAGAIN|5.003007|5.003007|Vn
validate_proto|5.019002||xcVi
validate_suid|||iu
valid_utf8_to_uvchr|5.015009||cVn
valid_utf8_to_uvuni|5.015009||dcVu
VAL_O_NONBLOCK|5.003007|5.003007|Vn
variant_byte_number|5.031004||cVnu
variant_under_utf8_count|5.027007||Vni
varname|5.009003||Viu
vcmp|5.009000|5.009000|
VCMP|5.019008||Viu
vcroak|5.006000|5.006000|
vdeb|5.007003|5.007003|u

xs/file/ppport.h  view on Meta::CPAN

uvoffuni_to_utf8_flags|5.027009||cV
uvoffuni_to_utf8_flags_msgs|5.027009||cVu
UVSIZE|5.006000|5.003007|poVn
UVTYPE|5.006000|5.003007|poVn
UVuf|5.006000|5.003007|poVn
uvuni_to_utf8|5.019004||cVu
uvuni_to_utf8_flags|5.007003||dcV
UVxf|5.006000|5.003007|poVn
UVXf|5.007001|5.007001|poVn
VAL_EAGAIN|5.003007|5.003007|Vn
validate_proto|5.019002||xcVi
validate_suid|||iu
valid_utf8_to_uvchr|5.015009||cVn
valid_utf8_to_uvuni|5.015009||dcVu
VAL_O_NONBLOCK|5.003007|5.003007|Vn
variant_byte_number|5.031004||cVnu
variant_under_utf8_count|5.027007||Vni
varname|5.009003||Viu
vcmp|5.009000|5.009000|
VCMP|5.019008||Viu
vcroak|5.006000|5.006000|
vdeb|5.007003|5.007003|u

xs/heap/ppport.h  view on Meta::CPAN

uvoffuni_to_utf8_flags|5.027009||cV
uvoffuni_to_utf8_flags_msgs|5.027009||cVu
UVSIZE|5.006000|5.003007|poVn
UVTYPE|5.006000|5.003007|poVn
UVuf|5.006000|5.003007|poVn
uvuni_to_utf8|5.019004||cVu
uvuni_to_utf8_flags|5.007003||dcV
UVxf|5.006000|5.003007|poVn
UVXf|5.007001|5.007001|poVn
VAL_EAGAIN|5.003007|5.003007|Vn
validate_proto|5.019002||xcVi
validate_suid|||iu
valid_utf8_to_uvchr|5.015009||cVn
valid_utf8_to_uvuni|5.015009||dcVu
VAL_O_NONBLOCK|5.003007|5.003007|Vn
variant_byte_number|5.031004||cVnu
variant_under_utf8_count|5.027007||Vni
varname|5.009003||Viu
vcmp|5.009000|5.009000|
VCMP|5.019008||Viu
vcroak|5.006000|5.006000|
vdeb|5.007003|5.007003|u

xs/lru/ppport.h  view on Meta::CPAN

uvoffuni_to_utf8_flags|5.027009||cV
uvoffuni_to_utf8_flags_msgs|5.027009||cVu
UVSIZE|5.006000|5.003007|poVn
UVTYPE|5.006000|5.003007|poVn
UVuf|5.006000|5.003007|poVn
uvuni_to_utf8|5.019004||cVu
uvuni_to_utf8_flags|5.007003||dcV
UVxf|5.006000|5.003007|poVn
UVXf|5.007001|5.007001|poVn
VAL_EAGAIN|5.003007|5.003007|Vn
validate_proto|5.019002||xcVi
validate_suid|||iu
valid_utf8_to_uvchr|5.015009||cVn
valid_utf8_to_uvuni|5.015009||dcVu
VAL_O_NONBLOCK|5.003007|5.003007|Vn
variant_byte_number|5.031004||cVnu
variant_under_utf8_count|5.027007||Vni
varname|5.009003||Viu
vcmp|5.009000|5.009000|
VCMP|5.019008||Viu
vcroak|5.006000|5.006000|
vdeb|5.007003|5.007003|u

xs/noop/ppport.h  view on Meta::CPAN

uvoffuni_to_utf8_flags|5.027009||cV
uvoffuni_to_utf8_flags_msgs|5.027009||cVu
UVSIZE|5.006000|5.003007|poVn
UVTYPE|5.006000|5.003007|poVn
UVuf|5.006000|5.003007|poVn
uvuni_to_utf8|5.019004||cVu
uvuni_to_utf8_flags|5.007003||dcV
UVxf|5.006000|5.003007|poVn
UVXf|5.007001|5.007001|poVn
VAL_EAGAIN|5.003007|5.003007|Vn
validate_proto|5.019002||xcVi
validate_suid|||iu
valid_utf8_to_uvchr|5.015009||cVn
valid_utf8_to_uvuni|5.015009||dcVu
VAL_O_NONBLOCK|5.003007|5.003007|Vn
variant_byte_number|5.031004||cVnu
variant_under_utf8_count|5.027007||Vni
varname|5.009003||Viu
vcmp|5.009000|5.009000|
VCMP|5.019008||Viu
vcroak|5.006000|5.006000|
vdeb|5.007003|5.007003|u

xs/nvec/ppport.h  view on Meta::CPAN

uvoffuni_to_utf8_flags|5.027009||cV
uvoffuni_to_utf8_flags_msgs|5.027009||cVu
UVSIZE|5.006000|5.003007|poVn
UVTYPE|5.006000|5.003007|poVn
UVuf|5.006000|5.003007|poVn
uvuni_to_utf8|5.019004||cVu
uvuni_to_utf8_flags|5.007003||dcV
UVxf|5.006000|5.003007|poVn
UVXf|5.007001|5.007001|poVn
VAL_EAGAIN|5.003007|5.003007|Vn
validate_proto|5.019002||xcVi
validate_suid|||iu
valid_utf8_to_uvchr|5.015009||cVn
valid_utf8_to_uvuni|5.015009||dcVu
VAL_O_NONBLOCK|5.003007|5.003007|Vn
variant_byte_number|5.031004||cVnu
variant_under_utf8_count|5.027007||Vni
varname|5.009003||Viu
vcmp|5.009000|5.009000|
VCMP|5.019008||Viu
vcroak|5.006000|5.006000|
vdeb|5.007003|5.007003|u

xs/object/object_types.h  view on Meta::CPAN

 * Return NULL if coercion is not possible.
 */
typedef SV* (*ObjectTypeCoerceFunc)(pTHX_ SV *val);

/*
 * Register a type with C-level check and coerce functions.
 * Call this from your BOOT section.
 *
 * Parameters:
 *   name   - Type name (e.g., "PositiveInt", "Email")
 *   check  - C function to validate values (required)
 *   coerce - C function to coerce values (optional, pass NULL if not needed)
 *
 * The type name can then be used in object::define() slot specifications.
 * Type checks and coercions run as direct C function calls with no Perl overhead.
 */
extern void object_register_type_xs(pTHX_ const char *name,
                                    ObjectTypeCheckFunc check,
                                    ObjectTypeCoerceFunc coerce);

/*

xs/object/ppport.h  view on Meta::CPAN

uvoffuni_to_utf8_flags|5.027009||cV
uvoffuni_to_utf8_flags_msgs|5.027009||cVu
UVSIZE|5.006000|5.003007|poVn
UVTYPE|5.006000|5.003007|poVn
UVuf|5.006000|5.003007|poVn
uvuni_to_utf8|5.019004||cVu
uvuni_to_utf8_flags|5.007003||dcV
UVxf|5.006000|5.003007|poVn
UVXf|5.007001|5.007001|poVn
VAL_EAGAIN|5.003007|5.003007|Vn
validate_proto|5.019002||xcVi
validate_suid|||iu
valid_utf8_to_uvchr|5.015009||cVn
valid_utf8_to_uvuni|5.015009||dcVu
VAL_O_NONBLOCK|5.003007|5.003007|Vn
variant_byte_number|5.031004||cVnu
variant_under_utf8_count|5.027007||Vni
varname|5.009003||Viu
vcmp|5.009000|5.009000|
VCMP|5.019008||Viu
vcroak|5.006000|5.006000|
vdeb|5.007003|5.007003|u

xs/ppport.h  view on Meta::CPAN

uvoffuni_to_utf8_flags|5.027009||cV
uvoffuni_to_utf8_flags_msgs|5.027009||cVu
UVSIZE|5.006000|5.003007|poVn
UVTYPE|5.006000|5.003007|poVn
UVuf|5.006000|5.003007|poVn
uvuni_to_utf8|5.019004||cVu
uvuni_to_utf8_flags|5.007003||dcV
UVxf|5.006000|5.003007|poVn
UVXf|5.007001|5.007001|poVn
VAL_EAGAIN|5.003007|5.003007|Vn
validate_proto|5.019002||xcVi
validate_suid|||iu
valid_utf8_to_uvchr|5.015009||cVn
valid_utf8_to_uvuni|5.015009||dcVu
VAL_O_NONBLOCK|5.003007|5.003007|Vn
variant_byte_number|5.031004||cVnu
variant_under_utf8_count|5.027007||Vni
varname|5.009003||Viu
vcmp|5.009000|5.009000|
VCMP|5.019008||Viu
vcroak|5.006000|5.006000|
vdeb|5.007003|5.007003|u

xs/slot/ppport.h  view on Meta::CPAN

uvoffuni_to_utf8_flags|5.027009||cV
uvoffuni_to_utf8_flags_msgs|5.027009||cVu
UVSIZE|5.006000|5.003007|poVn
UVTYPE|5.006000|5.003007|poVn
UVuf|5.006000|5.003007|poVn
uvuni_to_utf8|5.019004||cVu
uvuni_to_utf8_flags|5.007003||dcV
UVxf|5.006000|5.003007|poVn
UVXf|5.007001|5.007001|poVn
VAL_EAGAIN|5.003007|5.003007|Vn
validate_proto|5.019002||xcVi
validate_suid|||iu
valid_utf8_to_uvchr|5.015009||cVn
valid_utf8_to_uvuni|5.015009||dcVu
VAL_O_NONBLOCK|5.003007|5.003007|Vn
variant_byte_number|5.031004||cVnu
variant_under_utf8_count|5.027007||Vni
varname|5.009003||Viu
vcmp|5.009000|5.009000|
VCMP|5.019008||Viu
vcroak|5.006000|5.006000|
vdeb|5.007003|5.007003|u

xs/util/ppport.h  view on Meta::CPAN

utf8_to_bytes||5.006001|
utf8_to_uvchr||5.007001|
utf8_to_uvuni||5.007001|
utf8n_to_uvchr|||
utf8n_to_uvuni||5.007001|
utilize|||
uvchr_to_utf8_flags||5.007003|
uvchr_to_utf8|||
uvuni_to_utf8_flags||5.007003|
uvuni_to_utf8||5.007001|
validate_suid|||
varname|||
vcmp||5.009000|
vcroak||5.006000|
vdeb||5.007003|
vdie_common|||
vdie_croak_common|||
vdie|||
vform||5.006000|
visit|||
vivify_defelem|||



( run in 1.815 second using v1.01-cache-2.11-cpan-13bb782fe5a )