本文整理汇总了C++中PTR2IV函数的典型用法代码示例。如果您正苦于以下问题:C++ PTR2IV函数的具体用法?C++ PTR2IV怎么用?C++ PTR2IV使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了PTR2IV函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: PLCBA_construct
SV *
PLCBA_construct(const char *pkg, AV *options)
{
PLCBA_t *async;
char *host, *username, *password, *bucket;
libcouchbase_t instance;
SV *blessed_obj;
Newxz(async, 1, PLCBA_t);
extract_async_options(async, options);
plcb_ctor_conversion_opts(&async->base, options);
plcb_ctor_cbc_opts(options, &host, &username, &password, &bucket);
instance = libcouchbase_create(host, username, password, bucket,
plcba_make_io_opts(async));
if(!instance) {
die("Couldn't create instance!");
}
plcb_ctor_init_common(&async->base, instance, options);
plcba_setup_callbacks(async);
async->base_rv = newRV_inc(newSViv(PTR2IV(&(async->base))));
blessed_obj = newSV(0);
sv_setiv(newSVrv(blessed_obj, pkg), PTR2IV(async));
return blessed_obj;
}
示例2: ffi_pl_closure_add_data
void
ffi_pl_closure_add_data(SV *closure, ffi_pl_closure *closure_data)
{
dSP;
ENTER;
SAVETMPS;
PUSHMARK(SP);
XPUSHs(closure);
XPUSHs(sv_2mortal(newSViv(PTR2IV(closure_data))));
XPUSHs(sv_2mortal(newSViv(PTR2IV(closure_data->type))));
PUTBACK;
call_pv("FFI::Platypus::Closure::add_data", G_DISCARD);
FREETMPS;
LEAVE;
}
示例3: ffi_pl_closure_get_data
ffi_pl_closure *
ffi_pl_closure_get_data(SV *closure, ffi_pl_type *type)
{
dSP;
int count;
ffi_pl_closure *ret;
ENTER;
SAVETMPS;
PUSHMARK(SP);
XPUSHs(closure);
XPUSHs(sv_2mortal(newSViv(PTR2IV(type))));
PUTBACK;
count = call_pv("FFI::Platypus::Closure::get_data", G_SCALAR);
SPAGAIN;
if (count != 1)
ret = NULL;
else
ret = INT2PTR(void*, POPi);
PUTBACK;
FREETMPS;
LEAVE;
return ret;
}
示例4: XS
static
XS (XS_Xchat_get_info)
{
SV *temp = NULL;
dXSARGS;
if (items != 1) {
xchat_print (ph, "Usage: Xchat::get_info(id)");
} else {
SV *id = ST (0);
const char *RETVAL;
RETVAL = xchat_get_info (ph, SvPV_nolen (id));
if (RETVAL == NULL) {
XSRETURN_UNDEF;
}
if (!strncmp ("win_ptr", SvPV_nolen (id), 7)) {
XSRETURN_IV (PTR2IV (RETVAL));
} else {
if (
!strncmp ("libdirfs", SvPV_nolen (id), 8) ||
!strncmp ("xchatdirfs", SvPV_nolen (id), 10)
) {
XSRETURN_PV (RETVAL);
} else {
temp = newSVpv (RETVAL, 0);
SvUTF8_on (temp);
PUSHMARK (SP);
XPUSHs (sv_2mortal (temp));
PUTBACK;
}
}
}
}
示例5: Newxz
static void *create_event(plcba_cbcio *cbcio)
{
PLCBA_c_event *cevent;
PLCBA_t *async;
async = (PLCBA_t*)cbcio->v.v0.cookie;
Newxz(cevent, 1, PLCBA_c_event);
cevent->pl_event = newAV();
cevent->evtype = PLCBA_EVTYPE_IO;
av_store(cevent->pl_event,
PLCBA_EVIDX_OPAQUE,
newSViv(PTR2IV(cevent)));
if (async->cevents) {
cevent->prev = NULL;
cevent->next = async->cevents;
async->cevents->prev = cevent;
async->cevents = cevent;
} else {
async->cevents = cevent;
cevent->next = NULL;
cevent->prev = NULL;
}
return cevent;
}
示例6: S_lazy_init_host_obj
static void
S_lazy_init_host_obj(kino_Obj *self)
{
SV *inner_obj = newSV(0);
SvOBJECT_on(inner_obj);
PL_sv_objcount++;
SvUPGRADE(inner_obj, SVt_PVMG);
sv_setiv(inner_obj, PTR2IV(self));
// Connect class association.
kino_CharBuf *class_name = Kino_VTable_Get_Name(self->vtable);
HV *stash = gv_stashpvn((char*)Kino_CB_Get_Ptr8(class_name),
Kino_CB_Get_Size(class_name), TRUE);
SvSTASH_set(inner_obj, (HV*)SvREFCNT_inc(stash));
/* Up till now we've been keeping track of the refcount in
* self->ref.count. We're replacing ref.count with ref.host_obj, which
* will assume responsibility for maintaining the refcount. ref.host_obj
* starts off with a refcount of 1, so we need to transfer any refcounts
* in excess of that. */
size_t old_refcount = self->ref.count;
self->ref.host_obj = inner_obj;
while (old_refcount > 1) {
SvREFCNT_inc_simple_void_NN(inner_obj);
old_refcount--;
}
}
示例7: fd_cb
static int
fd_cb (int fd, int flags, void *userdata)
{
HookData *data = (HookData *) userdata;
int retVal = 0;
int count = 0;
dSP;
ENTER;
SAVETMPS;
PUSHMARK (SP);
XPUSHs (data->userdata);
PUTBACK;
set_current_package (data->package);
count = call_sv (data->callback, G_EVAL);
set_current_package (&PL_sv_undef);
SPAGAIN;
if (SvTRUE (ERRSV)) {
hexchat_printf (ph, "Error in fd callback %s", SvPV_nolen (ERRSV));
if (!SvOK (POPs)) {} /* remove undef from the top of the stack */
retVal = HEXCHAT_EAT_ALL;
} else {
if (count != 1) {
hexchat_print (ph, "Fd handler should only return 1 value.");
retVal = HEXCHAT_EAT_NONE;
} else {
retVal = POPi;
if (retVal == 0) {
/* if 0 is returned, the fd is going to get unhooked */
PUSHMARK (SP);
XPUSHs (sv_2mortal (newSViv (PTR2IV (data->hook))));
PUTBACK;
call_pv ("Xchat::unhook", G_EVAL);
SPAGAIN;
SvREFCNT_dec (data->callback);
if (data->userdata) {
SvREFCNT_dec (data->userdata);
}
free (data);
}
}
}
PUTBACK;
FREETMPS;
LEAVE;
return retVal;
}
示例8: XS
static
XS (XS_Xchat_get_context)
{
dXSARGS;
if (items != 0) {
xchat_print (ph, "Usage: Xchat::get_context()");
} else {
XSRETURN_IV (PTR2IV (xchat_get_context (ph)));
}
}
示例9: timer_cb
static int
timer_cb (void *userdata)
{
HookData *data = (HookData *) userdata;
int retVal = 0;
int count = 0;
dSP;
ENTER;
SAVETMPS;
PUSHMARK (SP);
XPUSHs (data->userdata);
PUTBACK;
if (data->ctx) {
xchat_set_context (ph, data->ctx);
}
set_current_package (data->package);
count = call_sv (data->callback, G_EVAL);
set_current_package (&PL_sv_undef);
SPAGAIN;
if (SvTRUE (ERRSV)) {
xchat_printf (ph, "Error in timer callback %s", SvPV_nolen (ERRSV));
if (!SvOK (POPs)) {} /* remove undef from the top of the stack */
retVal = XCHAT_EAT_ALL;
} else {
if (count != 1) {
xchat_print (ph, "Timer handler should only return 1 value.");
retVal = XCHAT_EAT_NONE;
} else {
retVal = POPi;
if (retVal == 0) {
/* if 0 is return the timer is going to get unhooked */
PUSHMARK (SP);
XPUSHs (sv_2mortal (newSViv (PTR2IV (data->hook))));
XPUSHs (sv_mortalcopy (data->package));
PUTBACK;
call_pv ("Xchat::unhook", G_EVAL);
SPAGAIN;
}
}
}
PUTBACK;
FREETMPS;
LEAVE;
return retVal;
}
示例10: preprocessAndRun
int preprocessAndRun(struct collectionFormat *collection, struct cargsF *cargs, char execute[], char *error, int errorlength) {
//antar at rutiner som ikke returnerer noe mislykkes. Dette kan for eks skje hvis vi kaller die, eller ikke trenger retur koden
char perlfile[PATH_MAX];
snprintf(perlfile,sizeof(perlfile),"%s/main.pm",collection->crawlLibInfo->resourcepath);
bblog(DEBUGINFO, "cargs %p\n",cargs);
#ifdef DEBUG
//printer ut pekere til colection info, og alle rutinene
bblog(DEBUGINFO, "collection %p, documentExist %p, documentAdd %p, documentError %p, documentContinue %p",cargs->collection,cargs->documentExist,cargs->documentAdd,cargs->documentError,cargs->documentContinue);
#endif
HV *obj_attr = newHV();
hv_store(obj_attr, "ptr", strlen("ptr"), sv_2mortal(newSViv(PTR2IV(cargs))), 0);
HV *hv = newHV();
//sendes altid med
hv_store(hv, "last_crawl", strlen("last_crawl"), sv_2mortal(newSVuv(collection->lastCrawl)), 0);
//sendes bare med hvis vi har verdi
if (collection->resource != NULL)
hv_store(hv, "resource", strlen("resource"), sv_2mortal(newSVpv(collection->resource, 0)), 0);
if (collection->connector != NULL)
hv_store(hv, "connector", strlen("connector"), sv_2mortal(newSVpv(collection->connector, 0)), 0);
if (collection->password != NULL)
hv_store(hv, "password", strlen("password"), sv_2mortal(newSVpv(collection->password, 0)), 0);
if (collection->query1 != NULL)
hv_store(hv, "query1", strlen("query1"), sv_2mortal(newSVpv(collection->query1, 0)), 0);
if (collection->query2 != NULL)
hv_store(hv, "query2", strlen("query2"), sv_2mortal(newSVpv(collection->query2, 0)), 0);
if (collection->collection_name != NULL)
hv_store(hv, "collection_name", strlen("collection_name"), sv_2mortal(newSVpv(collection->collection_name, 0)), 0);
if (collection->user != NULL)
hv_store(hv, "user", strlen("user"), sv_2mortal(newSVpv(collection->user, 0)), 0);
if (collection->userprefix != NULL)
hv_store(hv, "userprefix", strlen("userprefix"), sv_2mortal(newSVpv(collection->userprefix, 0)), 0);
if (collection->extra != NULL)
hv_store(hv, "extra", strlen("extra"), sv_2mortal(newSVpv(collection->extra, 0)), 0);
if (collection->test_file_prefix != NULL)
hv_store(hv, "test_file_prefix", strlen("test_file_prefix"), sv_2mortal(newSVpv(collection->test_file_prefix, 0)), 0);
// Add custom params to hash.
ht_to_perl_ht(hv, collection->params);
return perl_embed_run(perlfile, execute, hv, "Perlcrawl", obj_attr, error, errorlength);
}
示例11: XS
/* Xchat::Internal::hook_fd(fd, callback, flags, userdata) */
static
XS (XS_Xchat_hook_fd)
{
int fd;
SV *callback;
int flags;
SV *userdata;
SV *package;
hexchat_hook *hook;
HookData *data;
dXSARGS;
if (items != 5) {
hexchat_print (ph,
"Usage: Xchat::Internal::hook_fd(fd, callback, flags, userdata)");
} else {
fd = (int) SvIV (ST (0));
callback = ST (1);
flags = (int) SvIV (ST (2));
userdata = ST (3);
package = ST (4);
data = NULL;
#ifdef WIN32
if ((flags & HEXCHAT_FD_NOTSOCKET) == 0) {
/* this _get_osfhandle if from win32iop.h in the perl distribution,
* not the one provided by Windows
*/
fd = _get_osfhandle(fd);
if (fd < 0) {
hexchat_print(ph, "Invalid file descriptor");
XSRETURN_UNDEF;
}
}
#endif
data = malloc (sizeof (HookData));
if (data == NULL) {
XSRETURN_UNDEF;
}
data->callback = newSVsv (callback);
data->userdata = newSVsv (userdata);
data->depth = 0;
data->package = newSVsv (package);
hook = hexchat_hook_fd (ph, fd, flags, fd_cb, data);
data->hook = hook;
XSRETURN_IV (PTR2IV (hook));
}
}
示例12: modperl_handler_make_args
void modperl_handler_make_args(pTHX_ AV **avp, ...)
{
va_list args;
if (!*avp) {
*avp = newAV(); /* XXX: cache an intialized AV* per-request */
}
va_start(args, avp);
for (;;) {
char *classname = va_arg(args, char *);
void *ptr;
SV *sv;
if (classname == NULL) {
break;
}
ptr = va_arg(args, void *);
switch (*classname) {
case 'A':
if (strEQ(classname, "APR::Table")) {
sv = modperl_hash_tie(aTHX_ classname, (SV *)NULL, ptr);
break;
}
case 'I':
if (strEQ(classname, "IV")) {
sv = ptr ? newSViv(PTR2IV(ptr)) : &PL_sv_undef;
break;
}
case 'P':
if (strEQ(classname, "PV")) {
sv = ptr ? newSVpv((char *)ptr, 0) : &PL_sv_undef;
break;
}
case 'H':
if (strEQ(classname, "HV")) {
sv = newRV_noinc((SV*)ptr);
break;
}
default:
sv = modperl_ptr2obj(aTHX_ classname, ptr);
break;
}
av_push(*avp, sv);
}
va_end(args);
}
示例13: new_xs_ea_object
/*
* Create a new ::Object by wrapping an ea_object_t in a perl SV. This is used
* to wrap exacct records that have been read from a file, or packed records
* that have been inflated.
*/
SV *
new_xs_ea_object(ea_object_t *ea_obj)
{
xs_ea_object_t *xs_obj;
SV *sv_obj;
/* Allocate space - use perl allocator. */
New(0, xs_obj, 1, xs_ea_object_t);
PERL_ASSERT(xs_obj != NULL);
xs_obj->ea_obj = ea_obj;
xs_obj->perl_obj = NULL;
sv_obj = NEWSV(0, 0);
PERL_ASSERT(sv_obj != NULL);
/*
* Initialise according to the type of the passed exacct object,
* and bless the perl object into the appropriate class.
*/
if (ea_obj->eo_type == EO_ITEM) {
if ((ea_obj->eo_catalog & EXT_TYPE_MASK) == EXT_EXACCT_OBJECT) {
INIT_EMBED_ITEM_FLAGS(xs_obj);
} else {
INIT_PLAIN_ITEM_FLAGS(xs_obj);
}
sv_setiv(newSVrv(sv_obj, NULL), PTR2IV(xs_obj));
sv_bless(sv_obj, Sun_Solaris_Exacct_Object_Item_stash);
} else {
INIT_GROUP_FLAGS(xs_obj);
sv_setiv(newSVrv(sv_obj, NULL), PTR2IV(xs_obj));
sv_bless(sv_obj, Sun_Solaris_Exacct_Object_Group_stash);
}
/*
* We are passing back a pointer masquerading as a perl IV,
* so make sure it can't be modified.
*/
SvREADONLY_on(SvRV(sv_obj));
return (sv_obj);
}
示例14: lucy_Err_trap
lucy_Err*
lucy_Err_trap(Cfish_Err_Attempt_t routine, void *context) {
lucy_Err *error = NULL;
SV *routine_sv = newSViv(PTR2IV(routine));
SV *context_sv = newSViv(PTR2IV(context));
dSP;
ENTER;
SAVETMPS;
PUSHMARK(SP);
EXTEND(SP, 2);
PUSHs(sv_2mortal(routine_sv));
PUSHs(sv_2mortal(context_sv));
PUTBACK;
int count = call_sv(attempt_xsub, G_EVAL | G_DISCARD);
if (count != 0) {
lucy_CharBuf *mess
= lucy_CB_newf("'attempt' returned too many values: %i32",
(int32_t)count);
error = lucy_Err_new(mess);
}
else {
SV *dollar_at = get_sv("@", FALSE);
if (SvTRUE(dollar_at)) {
if (sv_isobject(dollar_at)
&& sv_derived_from(dollar_at,"Clownfish::Err")
) {
IV error_iv = SvIV(SvRV(dollar_at));
error = INT2PTR(lucy_Err*, error_iv);
CFISH_INCREF(error);
}
else {
STRLEN len;
char *ptr = SvPVutf8(dollar_at, len);
lucy_CharBuf *mess = lucy_CB_new_from_trusted_utf8(ptr, len);
error = lucy_Err_new(mess);
}
}
示例15: Encode_XSEncoding
static void
Encode_XSEncoding(pTHX_ encode_t *enc)
{
dSP;
HV *stash = gv_stashpv("Encode::XS", TRUE);
SV *sv = sv_bless(newRV_noinc(newSViv(PTR2IV(enc))),stash);
int i = 0;
PUSHMARK(sp);
XPUSHs(sv);
while (enc->name[i])
{
const char *name = enc->name[i++];
XPUSHs(sv_2mortal(newSVpvn(name,strlen(name))));
}
PUTBACK;
call_pv("Encode::define_encoding",G_DISCARD);
SvREFCNT_dec(sv);
}