view release on metacpan or search on metacpan
void glGetClipPlane(...)
PREINIT:
GLdouble equation[4];
int i;
PPCODE:
if (1==items) {
/* Dump everything on the stack */
glGetClipPlane(SvIV(ST(0)),equation);
EXTEND(sp,4);
/* Dunno if this should really be allocated on the stack. */
GLdouble doublearr[16];
GLint intarr[4];
GLboolean boolarr[4];
int nvals; /* No of values returned by glGet() */
PPCODE:
if ( (1!=items) && (2!=items) ) {
croak("glGet() requires 1 or 2 arguments");
}
if ( (2==items) && (!SvROK(ST(1))) ) {
PREINIT:
GLuint *texture=NULL;
int n;
AV *array;
SV **svpp;
PPCODE:
if ( (1!=items) && (2!=items) ) {
croak("Bad number of arguments");
}
n = SvUV(ST(0));
view all matches for this distribution
view release on metacpan or search on metacpan
XScreenSaver.xs view on Meta::CPAN
OUTPUT:
RETVAL
void
xss_viewport_dimensions()
PPCODE:
XWindowAttributes xwa;
XGetWindowAttributes(dpy, win, &xwa);
XPUSHs(sv_2mortal(newSVnv(xwa.width)));
XPUSHs(sv_2mortal(newSVnv(xwa.height)));
view all matches for this distribution
view release on metacpan or search on metacpan
newhash(const char *password)
INIT:
int rv;
char buf [_PASSWORD_LEN];
PPCODE:
rv = crypt_newhash(password, "bcrypt,a", buf, sizeof(buf));
if (rv == 0)
XPUSHs(sv_2mortal(newSVpv(buf, 0)));
else
XPUSHs(sv_newmortal());
view all matches for this distribution
view release on metacpan or search on metacpan
=cut
int
constant(name)
char * name
PPCODE:
{
SV *Return;
int result;
if ( (result = constant_int(name)) != 0 )
{
view all matches for this distribution
view release on metacpan or search on metacpan
PREINIT:
dMY_CXT;
MYSQL_RES *res = NULL;
MYSQL_FIELD *fields;
int num_fields, i;
PPCODE:
switch( my_mysql_stmt_or_res( &MY_CXT, resid ) ) {
case MY_TYPE_RES:
res = ( (MY_RES *) resid )->res;
break;
case MY_TYPE_STMT:
PREINIT:
dMY_CXT;
MYSQL_RES *res;
MYSQL_FIELD *field;
unsigned int flags;
PPCODE:
switch( my_mysql_stmt_or_res( &MY_CXT, resid ) ) {
case MY_TYPE_RES:
res = ( (MY_RES *) resid )->res;
break;
case MY_TYPE_STMT:
MYSQL_ROW row;
DWORD *lengths;
MY_STMT *stmt;
MYSQL_BIND *result;
DWORD num_fields, i;
PPCODE:
switch( my_mysql_stmt_or_res( &MY_CXT, resid ) ) {
case MY_TYPE_RES:
res = (MY_RES *) resid;
row = mysql_fetch_row( res->res );
if( ! row ) goto error;
MY_RES *res;
MYSQL_ROW row;
DWORD *lengths;
MY_STMT *stmt;
MYSQL_BIND *result;
PPCODE:
switch( my_mysql_stmt_or_res( &MY_CXT, resid ) ) {
case MY_TYPE_RES:
res = (MY_RES *) resid;
EXTEND( SP, res->numrows );
while( ( row = mysql_fetch_row( res->res ) ) ) {
MYSQL_FIELD *fields;
MY_STMT *stmt;
MYSQL_BIND *result;
DWORD *lengths;
DWORD num_fields, i;
PPCODE:
switch( my_mysql_stmt_or_res( &MY_CXT, resid ) ) {
case MY_TYPE_RES:
res = (MY_RES *) resid;
row = mysql_fetch_row( res->res );
if( ! row ) goto error;
PREINIT:
dMY_CXT;
DWORD *lengths;
DWORD num_fields, i;
MY_STMT *stmt;
PPCODE:
switch( my_mysql_stmt_or_res( &MY_CXT, resid ) ) {
case MY_TYPE_RES:
lengths = mysql_fetch_lengths( ( (MY_RES *) resid )->res );
if( lengths ) {
num_fields = mysql_num_fields( ( (MY_RES *) resid )->res );
PREINIT:
dMY_CXT;
MY_CON *con;
MYSQL_RES *res;
MYSQL_ROW row;
PPCODE:
if( ! ( linkid = my_verify_linkid( &MY_CXT, linkid ) ) ) goto error;
con = (MY_CON *) linkid;
res = mysql_list_dbs( con->conid, wild );
if( res ) {
while( ( row = mysql_fetch_row( res ) ) ) {
MY_CON *con;
MYSQL_RES *res;
MYSQL_ROW row;
char sql[512], *p1;
AV *av;
PPCODE:
if( ! ( linkid = my_verify_linkid( &MY_CXT, linkid ) ) ) goto error;
con = (MY_CON *) linkid;
if( db && db[0] != '\0' ) {
p1 = my_strcpy( sql, "SHOW TABLES FROM `" );
p1 = my_strcpy( p1, db );
MYSQL_RES *res;
MYSQL_ROW row;
int numfields, numrows, r;
char sql[512], *p1;
AV *av;
PPCODE:
if( items < ( SvIOK( ST(0) ) ? 2 : 1 ) || items > 5 )
Perl_croak( aTHX_ "Usage: " __PACKAGE__ "::show_fields(linkid = 0, table, schema = NULL, db = NULL, wild = NULL)" );
if( SvIOK( ST( itemp ) ) ) {
linkid = INT2PTR( void *, SvIV( ST( itemp ) ) );
itemp ++;
MYSQL_ROW row;
char sql[512], *p1;
int step, num_fields, num_rows, itemp = 0;
long r;
AV *av;
PPCODE:
if( items < ( SvIOK( ST(0) ) ? 2 : 1 ) || items > 4 )
Perl_croak( aTHX_ "Usage: " __PACKAGE__ "::show_index(linkid = 0, table, schema = NULL, db = NULL)" );
if( SvIOK( ST( itemp ) ) ) {
linkid = INT2PTR( void *, SvIV( ST( itemp ) ) );
itemp ++;
view all matches for this distribution
view release on metacpan or search on metacpan
Postgres.xs view on Meta::CPAN
PREINIT:
dMY_CXT;
MY_RES *res;
const char *name;
int num_fields, i;
PPCODE:
switch( my_stmt_or_result( &MY_CXT, resid ) ) {
case MY_TYPE_RES:
res = (MY_RES *) resid;
break;
case MY_TYPE_STMT:
Postgres.xs view on Meta::CPAN
PREINIT:
dMY_CXT;
MY_RES *res = NULL;
const char *tmps;
UV tmpu;
PPCODE:
switch( my_stmt_or_result( &MY_CXT, resid ) ) {
case MY_TYPE_RES:
res = (MY_RES *) resid;
break;
case MY_TYPE_STMT:
Postgres.xs view on Meta::CPAN
PREINIT:
dMY_CXT;
DWORD i, l;
MY_RES *res;
const char *val;
PPCODE:
switch( my_stmt_or_result( &MY_CXT, resid ) ) {
case MY_TYPE_RES:
res = (MY_RES *) resid;
break;
case MY_TYPE_STMT:
Postgres.xs view on Meta::CPAN
PREINIT:
dMY_CXT;
MY_RES *res;
DWORD i, l;
const char *val;
PPCODE:
switch( my_stmt_or_result( &MY_CXT, resid ) ) {
case MY_TYPE_RES:
res = (MY_RES *) resid;
break;
case MY_TYPE_STMT:
Postgres.xs view on Meta::CPAN
PREINIT:
dMY_CXT;
MY_RES *res;
DWORD i, l;
const char *val, *name;
PPCODE:
switch( my_stmt_or_result( &MY_CXT, resid ) ) {
case MY_TYPE_RES:
res = (MY_RES *) resid;
break;
case MY_TYPE_STMT:
Postgres.xs view on Meta::CPAN
void * resid;
PREINIT:
dMY_CXT;
MY_RES *res;
DWORD i, s;
PPCODE:
switch( my_stmt_or_result( &MY_CXT, resid ) ) {
case MY_TYPE_RES:
res = (MY_RES *) resid;
break;
case MY_TYPE_STMT:
Postgres.xs view on Meta::CPAN
dMY_CXT;
MY_CON *con;
PGresult *pres;
DWORD numrows, i, l;
const char *val;
PPCODE:
con = my_con_verify( &MY_CXT, linkid );
if( con == NULL ) goto error;
pres = PQexec( con->con, "select datname from pg_database" );
if( PQresultStatus( pres ) == PGRES_TUPLES_OK ) {
numrows = PQntuples( pres );
Postgres.xs view on Meta::CPAN
DWORD numrows, i, l, dbl;
int itemp = 0;
const char *val;
AV *av;
PGresult *res;
PPCODE:
if( items < 0 || items > 4 )
Perl_croak( aTHX_ "Usage: " __PACKAGE__ "::show_tables(linkid = 0, schema = NULL, db = NULL, wild = NULL)" );
if( SvIOK( ST( itemp ) ) ) {
linkid = INT2PTR( void *, SvIV( ST( itemp ) ) );
itemp ++;
view all matches for this distribution
view release on metacpan or search on metacpan
void * resid;
PREINIT:
dMY_CXT;
MY_RES *res;
DWORD i;
PPCODE:
switch( my_stmt_or_res( &MY_CXT, resid ) ) {
case MY_TYPE_RES:
res = (MY_RES *) resid;
break;
case MY_TYPE_STMT:
MY_RES *res;
MY_STMT *stmt;
DWORD i;
const char *table, *catalog, *dt, *cs;
int nn, pk, ai, r;
PPCODE:
switch( my_stmt_or_res( &MY_CXT, resid ) ) {
case MY_TYPE_RES:
res = (MY_RES *) resid;
stmt = res->stmt;
break;
PREINIT:
dMY_CXT;
MY_RES *res;
MY_ROWS *row;
unsigned long i;
PPCODE:
switch( my_stmt_or_res( &MY_CXT, resid ) ) {
case MY_TYPE_RES:
res = (MY_RES *) resid;
break;
case MY_TYPE_STMT:
PREINIT:
dMY_CXT;
MY_RES *res;
MY_ROWS *row;
unsigned long i;
PPCODE:
switch( my_stmt_or_res( &MY_CXT, resid ) ) {
case MY_TYPE_RES:
res = (MY_RES *) resid;
break;
case MY_TYPE_STMT:
PREINIT:
dMY_CXT;
MY_RES *res;
MY_ROWS *row;
DWORD i;
PPCODE:
switch( my_stmt_or_res( &MY_CXT, resid ) ) {
case MY_TYPE_RES:
res = (MY_RES *) resid;
break;
case MY_TYPE_STMT:
PREINIT:
dMY_CXT;
MY_RES *res;
MY_ROWS *row;
DWORD i;
PPCODE:
switch( my_stmt_or_res( &MY_CXT, resid ) ) {
case MY_TYPE_RES:
res = (MY_RES *) resid;
break;
case MY_TYPE_STMT:
const char *wild;
PREINIT:
dMY_CXT;
int r;
MY_CON *con;
PPCODE:
int _intcb( void *arg, int columns, char **data, char **names ) {
if( columns > 1 )
XPUSHs( sv_2mortal( newSVpvn( data[1], strlen( data[1] ) ) ) );
return 0;
}
PREINIT:
dMY_CXT;
MY_CON *con;
AV *av;
char sql[256], *p1;
PPCODE:
// TABLE, SCHEMA, DB, TYPE
int _intcb( void *arg, int columns, char **data, char **names ) {
/*
int i;
const char *wild = NULL;
int itemp = 0;
MY_CON *con;
AV *av;
char *sql, *p1;
PPCODE:
// COLUMN, NULLABLE, DEFAULT, IS_PRIMARY, IS_UNIQUE, TYPENAME, AUTOINC
int _intcb( void *arg, int columns, char **data, char **names ) {
// cid|name|type|notnull|dflt_value|pk
int pk;
const char *db = NULL;
int itemp = 0;
MY_CON *con;
AV *av;
char *sql, **il_data, *p1;
PPCODE:
// NAME, COLUMN, TYPE
int _intcb_ii( void *arg, int columns, char **data, char **names ) {
// seqno|cid|name
view all matches for this distribution
view release on metacpan or search on metacpan
xs/PAB3/PAB3.xs view on Meta::CPAN
SV *sv;
HV *hv;
int itemp;
STRLEN lkey, lval;
char *key, *val;
PPCODE:
sv = sv_2mortal( (SV*) newHV() );
tv = my_thread_var_add( &MY_CXT, sv );
for( itemp = 1; itemp < items - 1; itemp += 2 ) {
if( ! SvPOK( ST(itemp) ) ) continue;
key = SvPVx( ST(itemp), lkey );
xs/PAB3/PAB3.xs view on Meta::CPAN
reset( this )
SV *this;
PREINIT:
dMY_CXT;
my_thread_var_t *tv;
PPCODE:
if( ( tv = my_thread_var_find( &MY_CXT, this ) ) != NULL ) {
my_parser_session_cleanup( tv );
my_loop_def_cleanup( tv );
my_hashmap_cleanup( tv );
}
xs/PAB3/PAB3.xs view on Meta::CPAN
my_thread_var_t *tv;
STRLEN ltmp, ltpl;
char *tmp, *p1;
char tpl[256], cac[256];
/*PerlIO *pfile;*/
PPCODE:
if( (tv = my_thread_var_find( &MY_CXT, this )) == NULL )
goto ferror;
tv->last_error[0] = '\0';
tmp = SvPVx( template, ltpl );
if( ltpl + tv->path_template_length < 256 ) {
xs/PAB3/PAB3.xs view on Meta::CPAN
error( this )
SV *this;
PREINIT:
dMY_CXT;
my_thread_var_t *tv;
PPCODE:
if( ( tv = my_thread_var_find( &MY_CXT, this ) ) == NULL ) goto error;
if( tv->last_error[0] != '\0' ) {
XPUSHs( sv_2mortal( newSVpvn( tv->last_error, strlen( tv->last_error ) ) ) );
}
goto exit;
xs/PAB3/PAB3.xs view on Meta::CPAN
SV *this;
char *msg;
PREINIT:
dMY_CXT;
my_thread_var_t *tv;
PPCODE:
if( ( tv = my_thread_var_find( &MY_CXT, this ) ) == NULL ) return;
my_strncpy( tv->last_error, msg, sizeof( tv->last_error ) );
#/*****************************************************************************
xs/PAB3/PAB3.xs view on Meta::CPAN
DESTROY( this )
SV *this;
PREINIT:
dMY_CXT;
my_thread_var_t *tv;
PPCODE:
if( ( tv = my_thread_var_find( &MY_CXT, this ) ) == NULL ) return;
_debug( __PACKAGE__ " destroying tv: 0x%08X\n", tv );
my_thread_var_rem( &MY_CXT, tv );
view all matches for this distribution
view release on metacpan or search on metacpan
getenvlist(pam_handle)
pam_handle_t *pam_handle
PREINIT:
char **env;
char **env_orig;
PPCODE:
env = pam_getenvlist(pam_handle);
env_orig = env;
while (env != NULL) {
XPUSHs(sv_2mortal(newSVpv(*env, 0)));
env++;
view all matches for this distribution
view release on metacpan or search on metacpan
sql_ufetch = 3
sql_fetchall = 4
sql_ufetchall = 5
sql_exists = 6
sql_uexists = 7
PPCODE:
{
if (items == 0)
croak ("Usage: sql_exec [database-handle,] [bind-var-refs,... ] \"sql-statement\", [arguments, ...]");
else
{
view all matches for this distribution
view release on metacpan or search on metacpan
void
surl(...)
PROTOTYPE: @
ALIAS:
salternative = 1
PPCODE:
{
int i;
UV xalternative;
SV *surl;
AV *args = newAV ();
void
find_path (path)
SV * path
PROTOTYPE: $
PPCODE:
HV *hash;
char *elem = find_path (path, &hash);
EXTEND (SP, 2);
PUSHs (sv_2mortal (newRV_inc ((SV *)hash)));
XSRETURN_NO;
void
obj_of (SV *ref)
PROTOTYPE: $
PPCODE:
if (SvROK (ref) && SvMAGICAL (SvRV (ref)))
{
MAGIC *mg = mg_find (SvRV (ref), PERL_MAGIC_tiedelem);
/* turn magic off before destruction, to ease perls job */
SvRMAGICAL_off (SvRV (rv));
void
FETCH(SV *self, SV *key)
PPCODE:
agni_try_patch (Perl_pp_helem, agni_fetch_op);
{
SV *ret;
PUTBACK;
ret = agni_fetch (self, key);
XPUSHs (ret);
}
void
STORE(SV *self, SV *key, SV *value)
PPCODE:
/*agni_try_patch (Perl_pp_helem, agni_store_op);*/
PUTBACK;
agni_store (self, key, value);
SPAGAIN;
void
EXISTS(SV *self, SV *key)
PPCODE:
HV *hv = (HV*) SvRV (self);
HV *hvt;
char *key_ = SvPV_nolen (key);
SvRMAGICAL_off (hv);
SvRMAGICAL_on (hv);
void
DELETE(SV *self, SV *key)
PPCODE:
HV *hv = (HV*) SvRV (self);
char *key_ = SvPV_nolen (key);
SV *value;
SvRMAGICAL_off (hv);
void
NEXTKEY(self, ...)
SV * self
ALIAS:
FIRSTKEY = 1
PPCODE:
HV *hv = (HV*) SvRV (self);
HV *hvt;
HE *he;
SvRMAGICAL_off (hv);
view all matches for this distribution
view release on metacpan or search on metacpan
Attr/Attr.xs view on Meta::CPAN
void
set_name(self, name)
struct attrl *self
char *name
PPCODE:
self->name = strdup(name);
char *
get_resource(self)
struct attrl *self
Attr/Attr.xs view on Meta::CPAN
void
set_resource(self, resource)
struct attrl *self
char *resource
PPCODE:
self->resource = strdup(resource);
char *
get_value(self)
struct attrl *self
Attr/Attr.xs view on Meta::CPAN
void
set_value(self, value)
struct attrl *self
char *value
PPCODE:
self->value = strdup(value);
void
push(self, next)
struct attrl *self
struct attrl *next
PPCODE:
self->next = next;
void
set_current(self, values)
struct attrl *self
HV *values
PREINIT:
SV **ssv;
PPCODE:
ssv = hv_fetch(values, "name", strlen("name"), 0);
if (ssv != NULL) {
self->name = SvPV_nolen(*ssv);
}
Attr/Attr.xs view on Meta::CPAN
DESTROY(self)
struct attrl *self
PREINIT:
struct attrl *p;
struct attrl *q;
PPCODE:
if (self != NULL) {
p = self;
while (p != NULL) {
q = p;
p = p->next;
view all matches for this distribution
view release on metacpan or search on metacpan
SaveAsString(pdf)
PDF::Haru pdf
PREINIT:
unsigned char * buf;
unsigned int siz;
PPCODE:
HPDF_SaveToStream (pdf);
HPDF_ResetStream (pdf);
siz = HPDF_GetStreamSize (pdf);
buf = (unsigned char*)malloc(siz);
HPDF_ReadFromStream (pdf, buf, &siz);
void
GetCurrentPos (page)
PDF::Haru::Page page
PREINIT:
HPDF_Point point;
PPCODE:
point = HPDF_Page_GetCurrentPos (page);
XPUSHs(sv_2mortal(newSVnv(point.x)));
XPUSHs(sv_2mortal(newSVnv(point.y)));
void
GetCurrentTextPos (page)
PDF::Haru::Page page
PREINIT:
HPDF_Point point;
PPCODE:
point = HPDF_Page_GetCurrentTextPos (page);
XPUSHs(sv_2mortal(newSVnv(point.x)));
XPUSHs(sv_2mortal(newSVnv(point.y)));
PDF::Haru::Font
void
GetTransMatrix (page)
PDF::Haru::Page page
PREINIT:
HPDF_TransMatrix matrix;
PPCODE:
matrix = HPDF_Page_GetTransMatrix (page);
XPUSHs(sv_2mortal(newSVnv(matrix.a)));
XPUSHs(sv_2mortal(newSVnv(matrix.b)));
XPUSHs(sv_2mortal(newSVnv(matrix.c)));
XPUSHs(sv_2mortal(newSVnv(matrix.d)));
PDF::Haru::Page page
PREINIT:
AV * ptn;
int n;
HPDF_DashMode mode;
PPCODE:
mode = HPDF_Page_GetDash (page);
ptn = (AV *)sv_2mortal((SV *)newAV());
for (n = 0; n < mode.num_ptn; n++) {
av_push(ptn, newSViv(mode.ptn[n]));
}
void
GetRGBFill (page)
PDF::Haru::Page page
PREINIT:
HPDF_RGBColor color;
PPCODE:
color = HPDF_Page_GetRGBFill (page);
XPUSHs(sv_2mortal(newSVnv(color.r)));
XPUSHs(sv_2mortal(newSVnv(color.g)));
XPUSHs(sv_2mortal(newSVnv(color.b)));
void
GetRGBStroke (page)
PDF::Haru::Page page
PREINIT:
HPDF_RGBColor color;
PPCODE:
color = HPDF_Page_GetRGBStroke (page);
XPUSHs(sv_2mortal(newSVnv(color.r)));
XPUSHs(sv_2mortal(newSVnv(color.g)));
XPUSHs(sv_2mortal(newSVnv(color.b)));
void
GetCMYKFill (page)
PDF::Haru::Page page
PREINIT:
HPDF_CMYKColor color;
PPCODE:
color = HPDF_Page_GetCMYKFill (page);
XPUSHs(sv_2mortal(newSVnv(color.c)));
XPUSHs(sv_2mortal(newSVnv(color.m)));
XPUSHs(sv_2mortal(newSVnv(color.y)));
XPUSHs(sv_2mortal(newSVnv(color.k)));
void
GetCMYKStroke (page)
PDF::Haru::Page page
PREINIT:
HPDF_CMYKColor color;
PPCODE:
color = HPDF_Page_GetCMYKStroke (page);
XPUSHs(sv_2mortal(newSVnv(color.c)));
XPUSHs(sv_2mortal(newSVnv(color.m)));
XPUSHs(sv_2mortal(newSVnv(color.y)));
XPUSHs(sv_2mortal(newSVnv(color.k)));
void
GetTextMatrix (page)
PDF::Haru::Page page
PREINIT:
HPDF_TransMatrix matrix;
PPCODE:
matrix = HPDF_Page_GetTextMatrix (page);
XPUSHs(sv_2mortal(newSVnv(matrix.a)));
XPUSHs(sv_2mortal(newSVnv(matrix.b)));
XPUSHs(sv_2mortal(newSVnv(matrix.c)));
XPUSHs(sv_2mortal(newSVnv(matrix.d)));
void
GetBBox (font);
PDF::Haru::Font font
PREINIT:
HPDF_Box box;
PPCODE:
box = HPDF_Font_GetBBox (font);
XPUSHs(sv_2mortal(newSVnv(box.left)));
XPUSHs(sv_2mortal(newSVnv(box.bottom)));
XPUSHs(sv_2mortal(newSVnv(box.right)));
XPUSHs(sv_2mortal(newSVnv(box.top)));
PDF::Haru::Font font
const char *text
HPDF_UINT len
PREINIT:
HPDF_TextWidth textwidth;
PPCODE:
textwidth = HPDF_Font_TextWidth (font,(const unsigned char*)text,len);
XPUSHs(sv_2mortal(newSViv(textwidth.numchars)));
XPUSHs(sv_2mortal(newSViv(textwidth.numwords)));
XPUSHs(sv_2mortal(newSViv(textwidth.width)));
XPUSHs(sv_2mortal(newSViv(textwidth.numspace)));
void
HPDF_Image_GetSize (image)
PDF::Haru::Image image
PREINIT:
HPDF_Point point;
PPCODE:
point = HPDF_Image_GetSize (image);
XPUSHs(sv_2mortal(newSVnv(point.x)));
XPUSHs(sv_2mortal(newSVnv(point.y)));
HPDF_UINT
view all matches for this distribution
view release on metacpan or search on metacpan
xs/bridge.xs view on Meta::CPAN
void
_page_size(self, page)
SV *self
int page
PPCODE:
pdfmake_bridge_t *bridge = BRIDGE_FROM_SV(self);
CHECK_BRIDGE(bridge);
double width, height;
pdfmake_err_t err = pdfmake_bridge_page_size(bridge, page, &width, &height);
if (err != PDFMAKE_OK) {
view all matches for this distribution
view release on metacpan or search on metacpan
lib/PDL/GSL/RNG.pd view on Meta::CPAN
void
set_seed(rng, seed)
gsl_rng * rng
int seed
PPCODE:
gsl_rng_set(rng,seed);
XPUSHs(ST(0)); /* return self */
unsigned int
min(rng)
view all matches for this distribution
view release on metacpan or search on metacpan
MODULE = PDL::Graphics::IIS PACKAGE = PDL::Graphics::IIS
void
_iiscur_int()
PPCODE:
float x,y;
char ch;
int frame = (int)SvIV( perl_get_sv("iisframe", FALSE) );
iis_open(SvPV_nolen(perl_get_sv("fifi",FALSE)),SvPV_nolen(perl_get_sv("fifo",FALSE)),
view all matches for this distribution
view release on metacpan or search on metacpan
void
$func(x, y, grid)
double x
double y
$type grid
PPCODE:
PLFLT tx, ty;
$func(x, y, &tx, &ty, (PLPointer) grid);
EXTEND (SP, 2);
PUSHs(sv_2mortal(newSVnv((double) tx)));
PUSHs(sv_2mortal(newSVnv((double) ty)));
pp_addxs (<<"EOC");
void
plFreeGrid (pg)
PLcGridPtr pg
PPCODE:
PLPTR_RECEIVE_IN(PLcGrid, grid, pg)
Safefree(grid->xg);
Safefree(grid->yg);
Safefree(grid);
EOC
pp_addxs (<<"EOC");
void
plFree2dGrid(pg)
PLcGrid2Ptr pg
PPCODE:
PLPTR_RECEIVE_IN(PLcGrid2, grid, pg)
plFree2dGrid(grid->xg, grid->nx, grid->ny);
plFree2dGrid(grid->yg, grid->nx, grid->ny);
free(grid);
EOC
EOPM
pp_addxs (<<"EOC");
void
plGetCursor ()
PPCODE:
PLGraphicsIn gin;
if (plGetCursor (&gin)) {
EXTEND (SP, 24);
PUSHs (sv_2mortal (newSVpv ("type", 0)));
PUSHs (sv_2mortal (newSViv ((IV) gin.type)));
SV* line_widths_rv
SV* symbol_colors_rv
SV* symbol_scales_rv
SV* symbol_numbers_rv
SV* symbols_rv
PPCODE:
int i;
double p_legend_width;
double p_legend_height;
int opt_array[nlegend];
int text_colors[nlegend];
pp_addxs (<<"EOC");
int
plspal0 (filename)
char* filename
PPCODE:
plspal0((const char *)filename);
EOC
pp_add_exported ('plspal0');
#----------------------------------------------------------------------------
pp_addxs (<<"EOC");
int
plspal1 (filename, interpolate)
char* filename
int interpolate
PPCODE:
plspal1((const char *)filename, (PLBOOL)interpolate);
EOC
pp_add_exported ('plspal1');
pp_addpm (<<'EOPM');
pp_addxs (<<"EOC");
void
plbtime (ctime)
double ctime
PPCODE:
PLINT year;
PLINT month;
PLINT day;
PLINT hour;
PLINT min;
int month
int day
int hour
int min
double sec
PPCODE:
c_plconfigtime((PLFLT) scale, (PLFLT) offset1, (PLFLT) offset2,
(PLINT) ccontrol, (PLBOOL) ifbtime_offset, (PLINT) year,
(PLINT) month, (PLINT) day, (PLINT) hour, (PLINT) min, (PLFLT) sec);
EOC
pp_add_exported ('plconfigtime');
int month
int day
int hour
int min
double sec
PPCODE:
PLFLT ctime;
c_plctime(year, month, day, hour, min, sec, &ctime);
EXTEND (SP, 1);
PUSHs (sv_2mortal (newSVnv (ctime)));
EOC
pp_addxs (<<"EOC");
void
pltimefmt(fmt)
char *fmt
PPCODE:
c_pltimefmt((const char *)fmt);
EOC
pp_add_exported ('pltimefmt');
pp_addpm (<<'EOPM');
pp_addxs (<<"EOC");
void
plsesc (esc)
SV* esc
PPCODE:
char *esc_c;
esc_c = (char *)SvPV_nolen(esc);
c_plsesc((char)*esc_c);
EOC
view all matches for this distribution
view release on metacpan or search on metacpan
PREINIT:
int dsetCount = 0;
char ** datasetNames; /* Array of dataset names */
char ** datasetPtr; /* temp pointer to datasetNames */
int i; /* Index variable */
PPCODE:
/* Get the number of datasets */
H5Giterate(groupID, groupName, NULL, incIfDset, &dsetCount);
if( dsetCount > 0){ /* Datasets found */
PREINIT:
int groupCount = 0;
char ** groupNames; /* Array of group names */
char ** groupPtr; /* temp pointer to groupnames */
int i; /* Index variable */
PPCODE:
/* Get the number of datasets */
H5Giterate(groupID, groupName, NULL, incIfGroup, &groupCount);
if( groupCount > 0){ /* Groups found */
view all matches for this distribution
view release on metacpan or search on metacpan
OUTPUT:
RETVAL
void
dump_bitmap(PDL::IO::Image self, int target_bpp=0)
PPCODE:
{
SV *bmp_sv, *pal_sv;
unsigned char *bmp = NULL, *pal = NULL;
unsigned w, h, bpp, cu, it, sz, szp, szl, y, i;
FIBITMAP *newdib = NULL, *b = NULL;
OUTPUT:
RETVAL
void
format_list(SV *class)
PPCODE:
{
int i;
for(i = 0; i < FreeImage_GetFIFCount(); i++) {
if(FreeImage_IsPluginEnabled((FREE_IMAGE_FORMAT)i)) {
const char *f = FreeImage_GetFormatFromFIF((FREE_IMAGE_FORMAT)i);
OUTPUT:
RETVAL
void
set_dots_per_meter_x(PDL::IO::Image self, unsigned res)
PPCODE:
FreeImage_SetDotsPerMeterX(self->dib, res);
XPUSHs(ST(0)); /* return self */
unsigned
get_dots_per_meter_y(PDL::IO::Image self)
OUTPUT:
RETVAL
void
set_dots_per_meter_y(PDL::IO::Image self, unsigned res)
PPCODE:
FreeImage_SetDotsPerMeterY(self->dib, res);
XPUSHs(ST(0)); /* return self */
const char*
get_color_type(PDL::IO::Image self)
OUTPUT:
RETVAL
void
set_transparent_index(PDL::IO::Image self, int index)
PPCODE:
FreeImage_SetTransparentIndex(self->dib, index);
XPUSHs(ST(0)); /* return self */
void
flip_horizontal(PDL::IO::Image self)
PPCODE:
if(!FreeImage_FlipHorizontal(self->dib)) {
warn("FreeImage_FlipHorizontal failed");
}
XPUSHs(ST(0)); /* return self */
void
flip_vertical(PDL::IO::Image self)
PPCODE:
if(!FreeImage_FlipVertical(self->dib)) {
warn("FreeImage_FlipVertical failed");
}
XPUSHs(ST(0)); /* return self */
void
convert_image_type(PDL::IO::Image self, SV * dst_image_type, int scale_linear=1)
PPCODE:
{
FREE_IMAGE_TYPE fit = _sv2fit(dst_image_type);
if (fit == FIT_UNKNOWN) {
warn("invalid dst_image_type");
}
XPUSHs(ST(0)); /* return self */
}
void
adjust_colors(PDL::IO::Image self, double brightness=0, double contrast=0, double gamma=0, int invert=0)
PPCODE:
if(!FreeImage_AdjustColors(self->dib, brightness, contrast, gamma, invert)) {
warn("FreeImage_AdjustColors failed");
}
XPUSHs(ST(0)); /* return self */
void
tone_mapping(PDL::IO::Image self, int tmo, double p1=0, double p2=0)
PPCODE:
if (tmo == FITMO_DRAGO03 || tmo == FITMO_REINHARD05 || tmo == FITMO_FATTAL02) {
FIBITMAP *newdib = FreeImage_ToneMapping(self->dib, tmo, p1, p2);
if (newdib) {
if (self->dib) FreeImage_Unload(self->dib);
self->dib = newdib;
}
XPUSHs(ST(0)); /* return self */
void
rotate(PDL::IO::Image self, double angle, ...)
PPCODE:
{
FIBITMAP *newdib = NULL;
unsigned bpp = FreeImage_GetBPP(self->dib);
FREE_IMAGE_TYPE fit = FreeImage_GetImageType(self->dib);
XPUSHs(ST(0)); /* return self */
}
void
color_dither(PDL::IO::Image self, int algorithm=FID_FS)
PPCODE:
{
FIBITMAP *newdib = FreeImage_Dither(self->dib, algorithm);
if (newdib) {
if (self->dib) FreeImage_Unload(self->dib);
self->dib = newdib;
XPUSHs(ST(0)); /* return self */
}
void
color_threshhold(PDL::IO::Image self, unsigned threshold=127)
PPCODE:
{
FIBITMAP *newdib = FreeImage_Threshold(self->dib, (BYTE)threshold);
if (newdib) {
if (self->dib) FreeImage_Unload(self->dib);
self->dib = newdib;
XPUSHs(ST(0)); /* return self */
}
void
color_quantize(PDL::IO::Image self, int quantize=FIQ_WUQUANT)
PPCODE:
{
FIBITMAP *newdib = FreeImage_ColorQuantize(self->dib, quantize);
if (newdib) {
if (self->dib) FreeImage_Unload(self->dib);
self->dib = newdib;
XPUSHs(ST(0)); /* return self */
}
void
color_to_4bpp(PDL::IO::Image self)
PPCODE:
{
FIBITMAP *newdib = FreeImage_ConvertTo4Bits(self->dib);
if (newdib) {
if (self->dib) FreeImage_Unload(self->dib);
self->dib = newdib;
XPUSHs(ST(0)); /* return self */
}
void
color_to_8bpp(PDL::IO::Image self)
PPCODE:
{
FIBITMAP *newdib = FreeImage_ConvertTo8Bits(self->dib);
if (newdib) {
if (self->dib) FreeImage_Unload(self->dib);
self->dib = newdib;
XPUSHs(ST(0)); /* return self */
}
void
color_to_8bpp_grey(PDL::IO::Image self)
PPCODE:
{
FIBITMAP *newdib = FreeImage_ConvertToGreyscale(self->dib);
if (newdib) {
if (self->dib) FreeImage_Unload(self->dib);
self->dib = newdib;
XPUSHs(ST(0)); /* return self */
}
void
color_to_16bpp_555(PDL::IO::Image self)
PPCODE:
{
FIBITMAP *newdib = FreeImage_ConvertTo16Bits555(self->dib);
if (newdib) {
if (self->dib) FreeImage_Unload(self->dib);
self->dib = newdib;
XPUSHs(ST(0)); /* return self */
}
void
color_to_16bpp_565(PDL::IO::Image self)
PPCODE:
{
FIBITMAP *newdib = FreeImage_ConvertTo16Bits565(self->dib);
if (newdib) {
if (self->dib) FreeImage_Unload(self->dib);
self->dib = newdib;
XPUSHs(ST(0)); /* return self */
}
void
color_to_24bpp(PDL::IO::Image self)
PPCODE:
{
FIBITMAP *newdib = FreeImage_ConvertTo24Bits(self->dib);
if (newdib) {
if (self->dib) FreeImage_Unload(self->dib);
self->dib = newdib;
XPUSHs(ST(0)); /* return self */
}
void
color_to_32bpp(PDL::IO::Image self)
PPCODE:
{
FIBITMAP *newdib = FreeImage_ConvertTo32Bits(self->dib);
if (newdib) {
if (self->dib) FreeImage_Unload(self->dib);
self->dib = newdib;
XPUSHs(ST(0)); /* return self */
}
void
rescale(PDL::IO::Image self, int dst_width=0, int dst_height=0, int filter=FILTER_CATMULLROM)
PPCODE:
{
if (dst_height<=0 && dst_width>0) {
double ratio = (double)dst_width / (double)FreeImage_GetWidth(self->dib);
dst_height = (int)floor(0.5 + ratio * (double)FreeImage_GetHeight(self->dib));
}
XPUSHs(ST(0)); /* return self */
}
void
rescale_pct(PDL::IO::Image self, double dst_width_pct=0, double dst_height_pct=0, int filter=FILTER_CATMULLROM)
PPCODE:
{
int dst_height = (int)floor(0.5 + (double)FreeImage_GetHeight(self->dib) * dst_height_pct / 100.0);
int dst_width = (int)floor(0.5 + (double)FreeImage_GetWidth(self->dib) * dst_width_pct / 100.0);
if (dst_height<=0 && dst_width>0) {
XPUSHs(ST(0)); /* return self */
}
void
save(PDL::IO::Image self, SV * destination, SV * f=NULL, int flags=0);
PPCODE:
{
if (self->dib) {
FIMEMORY *hmem = NULL;
BYTE *mem_buffer = NULL;
DWORD size_in_bytes = 0;
view all matches for this distribution
view release on metacpan or search on metacpan
void
get_library_version()
INIT:
int major,minor,release;
PPCODE:
Mat_GetLibraryVersion(&major, &minor, &release);
XPUSHs(sv_2mortal(newSVnv(major)));
XPUSHs(sv_2mortal(newSVnv(minor)));
XPUSHs(sv_2mortal(newSVnv(release)));
void
_convert_next_matvar_to_pdl(matfp,onedr)
mat_t * matfp
int onedr
PPCODE:
pdl * retpdl;
matvar_t * matvar;
retpdl = convert_next_matvar_to_pdl(matfp, &matvar, onedr);
SV * s = sv_newmortal();
SV * p = sv_newmortal();
# LocalWords: iopts undef wvarname wvarnum elsif ver cpan
# LocalWords: matvar varname foreach printdata Lapeyre qq
# LocalWords: jlapeyre Hulbert addhdr stdlib addxs RETVAL
# LocalWords: ACC RDONLY RDWR matname hdr str CreateVer
# LocalWords: matfp retval GetVersion fprintf stderr vers
# LocalWords: VarReadDataAll INIT PPCODE XPUSHs sv feof
# LocalWords: GetLibraryVersion newSVnv filehandle fp EOF
# LocalWords: newmortal SetSV namekey varbasew exobj todo
# LocalWords: hardcoded retpdl setpv VarFree disa
view all matches for this distribution
view release on metacpan or search on metacpan
SV* varids
SV* datatypes
SV* strlen
int idx
SV* values
PPCODE:
int i;
int dt;
int varid;
char c_elem;
int ncid
SV* varids
SV* datatypes
SV* strlen
int idx
PPCODE:
int i;
int dt;
int varid;
char c_elem;
view all matches for this distribution
view release on metacpan or search on metacpan
source,tag,comm,&global_status);
MPIpm_errhandler("&PDL::Parallel::MPI::receive",retval);
void
get_status_list()
PPCODE:
/* return the status as a 4 element array:
* (count,MPI_SOURCE,MPI_TAG,MPI_ERROR) */
XPUSHs(sv_2mortal(newSViv(global_status.count)));
XPUSHs(sv_2mortal(newSViv(global_status.MPI_SOURCE)));
XPUSHs(sv_2mortal(newSViv(global_status.MPI_TAG)));
int ret;
MPI_Status status;
#ifdef SEND_DEBUG
int i;
#endif
PPCODE:
if (! SvROK(ref))
croak("MPI_Recv: First argument is not a reference!");
if (SvTYPE(SvRV(ref)) == SVt_PVHV) {
croak("MPI_Recv: Hashes are not supported yet.");
MPI_Comm comm
PREINIT:
void* sendbuf, *recvbuf;
int ret;
MPI_Status status;
PPCODE:
if (! SvROK(sendref) || ! SvROK(recvref))
croak("MPI_Sendrecv: First and Fourth arguments must be references!");
if (SvTYPE(SvRV(sendref)) == SVt_PVAV &&
SvTYPE(SvRV(recvref)) == SVt_PVAV)
view all matches for this distribution
view release on metacpan or search on metacpan
lib/PDL/Transform/Proj4.pd view on Meta::CPAN
# Utility functions for getting projection description information (in a general case).
pp_addxs('', <<'ENDXS' );
void
proj_version(...)
PPCODE:
EXTEND(sp, 3);
mPUSHu(PROJ_VERSION_MAJOR);
mPUSHu(PROJ_VERSION_MINOR);
mPUSHu(PROJ_VERSION_PATCH);
# returns input_units, output_units
void
units(proj_str)
char *proj_str
PPCODE:
PJ *proj = proj_create( NULL, proj_str ); /* Init the projection */
if (!proj)
croak("Failed to create PJ from '%s': %s", proj_str, proj_errno_string(proj_errno(proj)));
EXTEND(sp, 2);
char *input_u = proj_angular_input(proj, PJ_FWD) ||
view all matches for this distribution
view release on metacpan or search on metacpan
lib/PDL/PP.pm view on Meta::CPAN
my $preamble = @preinit ? qq[\n PREINIT:@{[join "\n ", "", @preinit]}\n INPUT:\n] : '';
join '', qq[
\nvoid
pdl_run_$name(@{[join ', ', @xsargs]})$svdecls
$preamble@{[join "\n ", "", @inputdecls]}
PPCODE:
], map "$_\n", $argcode;
}),
# globalnew implies internal usage, not XS
PDL::PP::Rule::Returns->new("VarArgsXSReturn","GlobalNew",undef),
view all matches for this distribution
view release on metacpan or search on metacpan
Basic/Gen/PP.pm view on Meta::CPAN
SV *parent = 0;
int nreturn;
$svdecls
$pars
PPCODE:
{
PDLA_COMMENT("Check if you can get a package name for this input value. ")
PDLA_COMMENT("It can be either a PDLA (SVt_PVMG) or a hash which is a ")
PDLA_COMMENT("derived PDLA subclass (SVt_PVHV) ")
view all matches for this distribution
view release on metacpan or search on metacpan
Graphics/IIS/iis.pd view on Meta::CPAN
MODULE = PDLA::Graphics::IIS PACKAGE = PDLA::Graphics::IIS
void
_iiscur_int()
PPCODE:
STRLEN n_a;
STRLEN n_b;
float x,y;
char ch;
int frame = (int)SvIV( perl_get_sv("iisframe", FALSE) );
view all matches for this distribution
view release on metacpan or search on metacpan
Basic/Gen/PP.pm view on Meta::CPAN
SV *parent = 0;
int nreturn;
$svdecls
$pars
PPCODE:
{
PDLA_COMMENT("Check if you can get a package name for this input value. ")
PDLA_COMMENT("It can be either a PDLA (SVt_PVMG) or a hash which is a ")
PDLA_COMMENT("derived PDLA subclass (SVt_PVHV) ")
view all matches for this distribution
view release on metacpan or search on metacpan
const-xs.inc view on Meta::CPAN
/* NV nv; Uncomment this if you need to return NVs */
/* const char *pv; Uncomment this if you need to return PVs */
INPUT:
SV * sv;
const char * s = SvPV(sv, len);
PPCODE:
type = constant(aTHX_ s, len);
/* Return 1 or 2 items. First is error message, or undef if no error.
Second, if present, is found value */
switch (type) {
case PERL_constant_NOTFOUND:
view all matches for this distribution
view release on metacpan or search on metacpan
FR/perlxs.pod view on Meta::CPAN
simples, la valeur de RETVAL sera mise dans ST(0) sur la pile
d'arguments, où Perl le recevra comme valeur de retour de la XSUB.
Si la XSUB a un type de retour égal à C<void>, le compilateur ne
fournira pas de variable RETVAL pour cette fonction. Lorsqu'on utilise
la directive PPCODE:, la variable RETVAL n'est plus nécessaire, sauf
si on l'utilise explicitement.
Si la directive PPCODE: n'est pas utilisée, la valeur de retour
C<void> devrait être utilisée uniquement pour des sous-routines qui ne
renvoient pas de valeur, I<même si> la directive CODE: est utilisée
pour positionner ST(0) explicitement.
Dans des versions plus anciennes de ce document, on conseillait
FR/perlxs.pod view on Meta::CPAN
=head2 Le mot-clé C_ARGS
Le mot-clé C_ARGS permet de réaliser des XSUB que l'on n'appelle pas
de la même manière depuis Perl que depuis C, sans qu'il soit
nécessaire d'écrire une section CODE: ou PPCODE:. Le contenu du
paragraphe C_ARGS est passé comme argument à la fonction C, sans aucun
changement.
Supposons par exemple que la fonction C soit déclarée ainsi :
FR/perlxs.pod view on Meta::CPAN
symbolic function
int n
C_ARGS:
n, function, default_flags
=head2 Le mot-clé PPCODE
Le mot-clé PPCODE: est une variante du mot-clé CODE: qui est utilisée
pour indiquer au compilateur B<xsubpp> que le programmeur fournit le
code contrôlant la pile des arguments pour les valeurs de retour des
XSUB. On souhaite parfois que la XSUB renvoie une liste de valeurs et
non une valeur unique. Dans ce cas-là, il faut utiliser PPCODE: et
rajouter de manière explicite la liste des valeurs sur la pile. Les
mots-clés PPCODE: et CODE: ne sont pas utilisés simultanément dans la
même XSUB.
La XSUB suivante appelle la fonction C rpcb_gettime() et renvoie à Perl
ses deux valeurs de sortie, timep et status, comme une seule liste.
FR/perlxs.pod view on Meta::CPAN
rpcb_gettime(host)
char *host
PREINIT:
time_t timep;
bool_t status;
PPCODE:
status = rpcb_gettime( host, &timep );
EXTEND(SP, 2);
PUSHs(sv_2mortal(newSViv(status)));
PUSHs(sv_2mortal(newSViv(timep)));
FR/perlxs.pod view on Meta::CPAN
Le type de retour C<void> pour cette fonction indique au compilateur
B<xsubpp> que la variable RETVAL n'est pas nécessaire, qu'elle n'est
pas utlisée, et qu'elle ne devrait pas être créée. Dans la plupart des
cas, il faut utiliser le type de retour void avec l'instruction
PPCODE:.
On utilise la macro EXTEND() afin de dégager de la place sur la pile
des arguments pour les 2 valeurs de retour. L'instruction PPCODE: fait
en sorte que le compilateur B<xsubpp> crée un pointeur vers la pile
dans la variable C<SP> ; c'est ce pointeur qui est utilisé dans la
macro EXTEND(). Les valeurs sont ensuite rajoutées sur la pile avec
les macros PUSHs().
FR/perlxs.pod view on Meta::CPAN
avec l'instruction suivante.
($status, $timep) = rpcb_gettime("localhost");
Lorsque vous travaillez sur les paramètres en sortie avec une section
PPCODE:, assurez-vous de traiter l'effet 'set'
convenablement. Consultez L<perlguts> pour plus de détails sur cet
effet 'set'.
=head2 Renvoyer undef et des listes vides
FR/perlxs.pod view on Meta::CPAN
}
else{
ST(0) = &PL_sv_undef;
}
Pour renvoyer une liste vide, il faut utiliser un bloc PPCODE: et ne
pas rajouter de valeur de retour sur la pile.
void
rpcb_gettime(host)
char *host
PREINIT:
time_t timep;
PPCODE:
if( rpcb_gettime( host, &timep ) )
PUSHs(sv_2mortal(newSViv(timep)));
else{
/* Rien n'est remis sur la pile, donc une */
/* liste vide est renvoyee implicitement */
FR/perlxs.pod view on Meta::CPAN
=head2 Le mot-clé CLEANUP
Ce mot-clé peut être utilisé quand une XSUB doit exécuter des
procédures de nettoyage spéciales avant de se terminer. Quand le
mot-clé CLEANUP: est utilisé, il doit suivre tout bloc CODE:, PPCODE:
ou OUTPUT: présent dans la XSUB. Les instructions spécifiées dans le bloc de
nettoyage seront les dernières instructions de la XSUB.
=head2 Le mot-clé BOOT
FR/perlxs.pod view on Meta::CPAN
timep
=head2 Insérer des commentaires et des directives de pré-processeur C
Des directives de pré-processeur C peuvent prendre place à l'intérieur
des blocs BOOT:, PREINIT:, INIT:, CODE:, PPCODE: et CLEANUP:, de même
qu'en dehors des fonctions. Les commentaires sont autorisés partout
après le mot-clé MODULE. Le compilateur transmet les directives de
pré-processeur sans modification et supprime les lignes commentées.
On peut rajouter des commentaires dans les XSUB en mettant un C<#> sur
view all matches for this distribution
view release on metacpan or search on metacpan
IT/perlxstut.pod view on Meta::CPAN
In ogni caso, queste due XSUB forniscono un codice C generato praticamente
uguale: il compilatore B<xsubpp> E<egrave> abbastanza intelligente da intuire
la sezione C<CODE:> dalle prime due righe della descrizione XSUB. Che
dire della sezione C<OUTPUT:>? E<Egrave> assolutamente la stessa! Anche la
sezione C<OUTPUT:> puE<ograve> essere rimossa, I<sempre che le sezioni C<CODE:>
o C<PPCODE:> > non siano specificate: B<xsubpp> puE<ograve> quindi vedere che ha
bisogno di generare una sezione di chiamata a funzione, e genererE<agrave> anche
la sezione C<OUTPUT>. Per quanto detto, un'abbreviazione della XSUB
diventa:
double
IT/perlxstut.pod view on Meta::CPAN
char * path
INIT:
int i;
struct statfs buf;
PPCODE:
i = statfs(path, &buf);
if (i == 0) {
XPUSHs(sv_2mortal(newSVnv(buf.f_bavail)));
XPUSHs(sv_2mortal(newSVnv(buf.f_bfree)));
XPUSHs(sv_2mortal(newSVnv(buf.f_blocks)));
IT/perlxstut.pod view on Meta::CPAN
La direttiva C<INIT:> contiene codice che verrE<agrave> inserito immediatamente
dopo che lo stack degli argomenti viene decodificato. Il linguaggio C
non consente dichiarazioni di variaible in posizioni arbitrarie
all'interno di una funzione, per cui questa E<egrave> di norma la soluzione migliore
per dichiarare le variabili locali di cui la XSUB ha bisogno. (In
alternativa, E<egrave> possibile mettere l'intera sezione C<PPCODE:> in
parentesi graffe, ed aggiungere queste dichiarazioni all'inizio).
=item *
Questa routine restituisce anche un numero di argomenti differenti
IT/perlxstut.pod view on Meta::CPAN
come unico elemento di un array. Se la chiamata ha successo, viene
restituito un array di 9 elementi. PoichE<eacute> questa funzione riceve un solo
argomento, abbiamo bisogno di fare spazio sullo stack per tenere i
9 valori che potrebbero essere restituiti.
Otteniamo tutto ciE<ograve> utilizzando la direttiva C<PPCODE:>, piuttosto che
la direttiva C<CODE:>. Questo indica a B<xsubpp> che utilizzeremo i
valori di ritorno che saranno messi sullo stack degli argomenti da noi
stessi.
=item *
IT/perlxstut.pod view on Meta::CPAN
Questa funzione non utilizza una C<typemap>. Al contrario, dichiariamo che
accetta un parametro C<SV*> (scalare), e che restituisce un valore C<SV*>;
ci prendiamo direttamente cura di questi scalari all'interno del codice.
PoichE<eacute> stiamo restituendo un solo valore, non abbiamo bisogno di una
direttiva C<PPCODE:> - al contrario, utilizziamo le direttive C<CODE:> e
C<OUTPUT:>.
=item *
Quando si ha a che fare con i riferimenti, E<egrave> importante trattarli con
view all matches for this distribution