CARVIEW |
Select Language
HTTP/2 302
server: nginx
date: Sun, 31 Aug 2025 09:56:51 GMT
content-type: text/plain; charset=utf-8
content-length: 0
x-archive-redirect-reason: found capture at 20180611034549
location: https://web.archive.org/web/20180611034549/https://github.com/gitpan/XS-Object-Magic
server-timing: captures_list;dur=0.445388, exclusion.robots;dur=0.016712, exclusion.robots.policy;dur=0.007894, esindex;dur=0.008833, cdx.remote;dur=103.843104, LoadShardBlock;dur=436.228171, PetaboxLoader3.datanode;dur=94.312206, PetaboxLoader3.resolve;dur=202.906236
x-app-server: wwwb-app219
x-ts: 302
x-tr: 562
server-timing: TR;dur=0,Tw;dur=0,Tc;dur=0
set-cookie: wb-p-SERVER=wwwb-app219; path=/
x-location: All
x-rl: 0
x-na: 0
x-page-cache: MISS
server-timing: MISS
x-nid: DigitalOcean
referrer-policy: no-referrer-when-downgrade
permissions-policy: interest-cohort=()
HTTP/2 200
server: nginx
date: Sun, 31 Aug 2025 09:56:52 GMT
content-type: text/html; charset=utf-8
x-archive-orig-server: GitHub.com
x-archive-orig-date: Mon, 11 Jun 2018 03:45:50 GMT
x-archive-orig-transfer-encoding: chunked
x-archive-orig-status: 200 OK
x-archive-orig-cache-control: no-cache
x-archive-orig-vary: X-PJAX
x-archive-orig-set-cookie: logged_in=no; domain=.github.com; path=/; expires=Fri, 11 Jun 2038 03:45:50 -0000; secure; HttpOnly
x-archive-orig-set-cookie: _gh_sess=T09Jek5jS0c0b2dWSENwd29SSytJQkxQNWxVTlNsOVB1YitIZUtnSWNlKzEyZnYvZEFKSTVGSjJMdjBaRGlkMzY4Ull1eU9yaTgxT0tPYWF3TURoQ0F1blBMWDVUS2lhMlVma3NyYnp2NGhuOXkrbUpVeWd6NG5nZ2RoeXdYRVk4aVQ1TCtQQnRPVEVQdGkyOVp4RnkzTlFwbVMwZmFiUXJSSlRGSUI0Qk5vQXVISENrcG54UWVOUWFsWVZtK2x0YzI3b083ZjZOeU5sQ1d2NE84VmNYVlpsMk82b3pYdjdLSFV6amQxL2RTOG5IcnI2UjBpa25xcThFbExCaWxHb1lRelNadmhqeGtGbWk4T0FlTkxoWjBjMkp1WDBrV24vbHBrOTZ3OW1sb2xITkFySVdFYVkvcS92b0xQaEZ1QVZ1NVY0UStpMFloUGNpeElwWXZESkZ3b1FqenJDQXU1WSt4U1Y1b1owNlVEanlxN2FPczVkdmd5L05iV3UvUCtFYlNXRTd3SVdMNXNIUmtvb3lJMWlkMnp6MGNQZ3NiQTBsWUt3aG1uOGNGUT0tLTh1cS9JZ1BabzM3cDNxMEpLelJ3YUE9PQ%3D%3D--97d45fa92dfd614e9966c1e091486408a3d2e07d; path=/; secure; HttpOnly
x-archive-orig-x-request-id: 4edea3a6-a25c-4485-b75c-311e085846f9
x-archive-orig-x-runtime: 0.268452
x-archive-orig-strict-transport-security: max-age=31536000; includeSubdomains; preload
x-archive-orig-x-frame-options: deny
x-archive-orig-x-content-type-options: nosniff
x-archive-orig-x-xss-protection: 1; mode=block
x-archive-orig-expect-ct: max-age=2592000, report-uri="https://api.github.com/_private/browser/errors"
x-archive-orig-content-security-policy: default-src 'none'; base-uri 'self'; block-all-mixed-content; connect-src 'self' uploads.github.com status.github.com collector.githubapp.com api.github.com www.google-analytics.com github-cloud.s3.amazonaws.com github-production-repository-file-5c1aeb.s3.amazonaws.com github-production-upload-manifest-file-7fdce7.s3.amazonaws.com github-production-user-asset-6210df.s3.amazonaws.com wss://live.github.com; font-src assets-cdn.github.com; form-action 'self' github.com gist.github.com; frame-ancestors 'none'; frame-src render.githubusercontent.com; img-src 'self' data: assets-cdn.github.com identicons.github.com collector.githubapp.com github-cloud.s3.amazonaws.com *.githubusercontent.com; manifest-src 'self'; media-src 'none'; script-src assets-cdn.github.com; style-src 'unsafe-inline' assets-cdn.github.com
x-archive-orig-x-runtime-rack: 0.276452
x-archive-orig-x-github-request-id: B916:58FA:855470D:EEFAC06:5B1DF06D
x-archive-guessed-content-type: text/html
x-archive-guessed-charset: utf-8
memento-datetime: Mon, 11 Jun 2018 03:45:49 GMT
link: ; rel="original", ; rel="timemap"; type="application/link-format", ; rel="timegate", ; rel="first memento"; datetime="Mon, 11 Jun 2018 03:45:49 GMT", ; rel="memento"; datetime="Mon, 11 Jun 2018 03:45:49 GMT", ; rel="next memento"; datetime="Tue, 08 Sep 2020 21:11:01 GMT", ; rel="last memento"; datetime="Tue, 08 Sep 2020 21:11:11 GMT"
content-security-policy: default-src 'self' 'unsafe-eval' 'unsafe-inline' data: blob: archive.org web.archive.org web-static.archive.org wayback-api.archive.org athena.archive.org analytics.archive.org pragma.archivelab.org wwwb-events.archive.org
x-archive-src: archiveteam_github_20180703020419/archiveteam_github_20180703020419.megawarc.warc.gz
server-timing: captures_list;dur=0.502195, exclusion.robots;dur=0.019606, exclusion.robots.policy;dur=0.010021, esindex;dur=0.011090, cdx.remote;dur=27.689423, LoadShardBlock;dur=240.906492, PetaboxLoader3.datanode;dur=85.989114, PetaboxLoader3.resolve;dur=301.272258, load_resource;dur=182.503887
x-app-server: wwwb-app219
x-ts: 200
x-tr: 613
server-timing: TR;dur=0,Tw;dur=0,Tc;dur=0
x-location: All
x-rl: 0
x-na: 0
x-page-cache: MISS
server-timing: MISS
x-nid: DigitalOcean
referrer-policy: no-referrer-when-downgrade
permissions-policy: interest-cohort=()
content-encoding: gzip
GitHub - gitpan/XS-Object-Magic: Read-only release history for XS-Object-Magic
Fetching latest commit…
Permalink
Join GitHub today
GitHub is home to over 20 million developers working together to host and review code, manage projects, and build software together.
Read-only release history for XS-Object-Magic
https://metacpan.org/release/XS-Object…
C
Perl
Switch branches/tags
Nothing to show
stable
gitpan_version/0.04
gitpan_version/0.03
gitpan_version/0.02
gitpan_version/0.01
cpan_version/0.04
cpan_version/0.03
cpan_version/0.02
cpan_version/0.01
cpan_path/NUFFIN/XS-Object-Magic-0.02.tar.gz
cpan_path/NUFFIN/XS-Object-Magic-0.01.tar.gz
cpan_path/FLORA/XS-Object-Magic-0.04.tar.gz
cpan_path/FLORA/XS-Object-Magic-0.03.tar.gz
NUFFIN
FLORA
Nothing to show
Clone or download
Launching GitHub Desktop...
If nothing happens, download GitHub Desktop and try again.
Launching GitHub Desktop...
If nothing happens, download GitHub Desktop and try again.
Launching Xcode...
If nothing happens, download Xcode and try again.
Launching Visual Studio...
If nothing happens, download the GitHub extension for Visual Studio and try again.

Cannot retrieve the latest commit at this time.
Failed to load latest commit information. | |||
![]() |
build | ||
![]() |
inc/Module | ||
![]() |
lib/XS/Object | ||
![]() |
t | ||
![]() |
Changes | ||
![]() |
MANIFEST | ||
![]() |
META.yml | ||
![]() |
Magic.xs | ||
![]() |
Makefile.PL | ||
![]() |
README | ||
![]() |
ppport.h | ||
![]() |
test_typemap | ||
![]() |
typemap | ||
![]() |
xs_object_magic.h |
README
NAME XS::Object::Magic - Opaque, extensible XS pointer backed objects using "sv_magic" SYNOPSIS package MyObject; use XS::Object::Magic; sub new { my $class = shift; # create any object representation you like my $self = bless {}, $class; $self->build_struct; return $self; } # or using Moose package MyObject; use Moose; sub BUILD { shift->build_struct; } # then in XS MODULE = MyObject PACKAGE = MyObject void build_struct (SV *self) PREINIT: my_struct_t *thingy; CODE: thingy = create_whatever(); /* note that we dereference self first. This * can be done using an XS typemap of course */ xs_object_magic_attach_struct(aTHX_ SvRV(self), thingy); void foo (SV *self) PREINIT: my_struct_t *thingy; INIT: thingy = xs_object_magic_get_struct_rv(aTHX_ self); CODE: my_struct_foo(thingy); /* delegate to C api */ /* using typemap */ void foo (my_struct_t *thingy) CODE: my_struct_foo(thingy); /* or better yet */ PREFIX = my_struct_ void my_struct_foo (thingy) my_struct_t *thingy; /* don't forget a destructor */ void DESTROY (my_struct_t *thingy) CODE: Safefree(thingy); /* note that xs_object_magic_get_struct() will * still return a pointe which is now invalid */ DESCRPTION This way of associating structs with Perl space objects is designed to supercede Perl's builtin "T_PTROBJ" with something that is designed to be: Extensible The association of the pointer using "sv_magicext" can be done on any data type, so you can associate C structs with any representation type. This means that you can add pointers to any object (hand coded, Moose or otherwise), while still having instance data in regular hashes. Opaque The C pointer is neither visible nor modifiable from Perl space. This prevents accidental corruption which could lead to segfaults using "T_PTROBJ" (e.g. "$$ptr_obj = 0"). C API void *xs_object_magic_get_struct_rv(aTHX_ SV *sv) When called on the object reference it will check that the "sv" is a reference, dereference it and return the associated pointer using "xs_object_magic_get_struct". Basically the same as "xs_object_magic_get_struct(aTHX_ SvRV(sv)" but croaks if no magic was found. Note that storing a "NULL" pointer will not cause an error. void *xs_object_magic_get_struct(aTHX_ SV *sv) Fetches the pointer associated with "sv". Returns "NULL" if no pointer is found. There is no way to distinguish this from having a "NULL" pointer. MAGIC *xs_object_magic_get_mg (aTHX_ SV *sv) Fetches the appropriate "MAGIC" entry for the struct pointer storage from "sv". This lets you manipulate "mg-"mg_ptr> if you need to. void xs_object_magic_attach_struct(aTHX_ SV *sv, void *ptr) Associates "ptr" with "sv" by adding a magic entry to "sv". SV *xs_object_magic_create(aTHX_ void *ptr, HV *stash) Convenience function that creates a hash object blessed to "stash" and associates it with "ptr". Can be used to easily create a constructor: SV * new(char *class) CODE: RETVAL = xs_object_magic_create( (void *)test_new(), gv_stashpv(class, 0) ); OUTPUT: RETVAL int xs_object_magic_has_struct(aTHX_ SV *sv) Returns 1 if the SV has XS::Object::Magic magic, 0 otherwise. int xs_object_magic_has_struct_rv(aTHX_ SV *self) Returns 1 if the SV references an SV that has XS::Object::Magic magic, 0 otherwise. This lets you write a quick predicate method, like: void my_struct_has_struct (self) SV *self; PPCODE: EXTEND(SP, 1); if(xs_object_magic_has_struct_rv(aTHX_ self)) PUSHs(&PL_sv_yes); else PUSHs(&PL_sv_no); Then you can check for the existence of your struct from the Perl side: if( $object->has_struct ) { ... } int xs_object_magic_detach_struct(aTHX_ SV *sv) Removes the XS::Object::Magic magic from the given SV. Returns 1 if something is removed, 0 otherwise. int xs_object_magic_detach_struct_rv(aTHX_ SV *self) Likes "xs_object_magic_detach_struct", but takes a reference to the magic-containing SV instead of the SV itself. The reference to the SV is typically $self. Returns 0 if the SV is not a reference, otherwise returns whatever "xs_object_magic_detach_struct" returns. TYPEMAP The included typemap provides a "T_PTROBJ_MG" entry which only supports the "INPUT" conversion. This typemap entry lets you declare methods that are invoked directly on the associated pointer. In your own typemap add an entry: TYPEMAP my_pointer_t * T_PTROBJ_MG and then you can use "my_pointer_t" as the argument type of the invocant: I32 method (self) my_pointer_t *self; CODE: ... Note that there is no "OUTPUT" conversion. In order to return your object you need to use ST(0) or some other means of getting the invocant. VERSION CONTROL <https://github.com/nothingmuch/xs-object-magic> AUTHOR Florian Ragwitz, Yuval Kogman COPYRIGHT & LICENSE Copyright (c) 2009 Florian Ragwitz, Yuval Kogman. All rights reserved This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session.
You signed out in another tab or window. Reload to refresh your session.
Press h to open a hovercard with more details.