📄 magic.c
字号:
/*
* This file was generated automatically by xsubpp version 1.9402 from the
* contents of Book.xs. Do not edit this file, edit Book.xs instead.
*
* ANY CHANGES MADE HERE WILL BE LOST!
*
*/
#line 1 "Book.xs"
#include <EXTERN.h>
#include <perl.h>
#include <XSUB.h>
int my_foo;
int foo_get (SV *sv, MAGIC *mg)
{
sv_setiv(sv, my_foo); /* return my_foo's value */
printf ("GET foo => %d\n", my_foo);
return 1;
}
int foo_set (SV *sv, MAGIC *mg)
{
my_foo = SvIV(sv); /* set my_foo's value */
printf ("SET foo => %d\n", my_foo);
return 1;
}
MGVTBL foo_accessors = { /* Custom virtual table */
foo_get,
foo_set,
NULL,
NULL,
NULL
};
void t ()
{
MAGIC *m;
/* Create a variable*/
char *var = "main::foo";
SV *sv = perl_get_sv(var,TRUE);
/* Upgrade the sv to a magical variable*/
sv_magic(sv, NULL, '~', var, strlen(var));
/* sv_magic adds a MAGIC structure (of type '~') to the SV.
Get it and set the virtual table pointer */
m = mg_find(sv, '~');
m->mg_virtual = &foo_accessors;
SvMAGICAL_on(sv);
sv_dump(sv);
}
void t1 ()
{
sv_dump(perl_get_sv("main::foo",FALSE));
}
XS(XS_Book_t)
{
dXSARGS;
if (items != 0)
croak("Usage: Book::t()");
{
#line 51 "Book.xs"
#line 51 "Book.xs"
t();
#line 51 "Book.xs"
#line 51 "Book.xs"
#line 51 "Book.xs"
}
XSRETURN_EMPTY;
}
XS(XS_Book_t1)
{
dXSARGS;
if (items != 0)
croak("Usage: Book::t1()");
{
#line 55 "Book.xs"
#line 55 "Book.xs"
t1();
#line 55 "Book.xs"
#line 55 "Book.xs"
#line 55 "Book.xs"
}
XSRETURN_EMPTY;
}
#ifdef __cplusplus
extern "C"
#endif
XS(boot_Book)
{
dXSARGS;
char* file = __FILE__;
XS_VERSION_BOOTCHECK ;
newXSproto("Book::t", XS_Book_t, file, "");
newXSproto("Book::t1", XS_Book_t1, file, "");
ST(0) = &sv_yes;
XSRETURN(1);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -