本文整理汇总了C++中SvRV函数的典型用法代码示例。如果您正苦于以下问题:C++ SvRV函数的具体用法?C++ SvRV怎么用?C++ SvRV使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了SvRV函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: p5_unwrap_p6_object
IV p5_unwrap_p6_object(PerlInterpreter *my_perl, SV *obj) {
PERL_SET_CONTEXT(my_perl);
{
SV * const obj_deref = SvRV(obj);
MAGIC * const mg = mg_find(obj_deref, '~');
return ((_perl6_magic*)(mg->mg_ptr))->index;
}
}
示例2: p5_rebless_object
void p5_rebless_object(PerlInterpreter *my_perl, SV *obj) {
SV * const inst = SvRV(obj);
SV * const inst_ptr = newRV_noinc(inst);
HV *stash = gv_stashpv("Perl6::Object", 0);
if (stash == NULL)
croak("Perl6::Object not found!? Forgot to call init_callbacks?");
(void)sv_bless(inst_ptr, stash);
}
示例3: CONFESS
void
Surface::from_SV_check(SV* surface_sv)
{
if (!sv_isa(surface_sv, perl_class_name(this)) && !sv_isa(surface_sv, perl_class_name_ref(this)))
CONFESS("Not a valid %s object", perl_class_name(this));
// a XS Surface was supplied
*this = *(Surface *)SvIV((SV*)SvRV( surface_sv ));
}
示例4: derefPV
/* Convenience function for checking whether pv is a reference, and dereference it if necessary */
static inline SV *
derefPV (SV *pv)
{
if (SvTYPE (pv) == SVt_RV) {
return SvRV (pv);
} else
return pv;
}
示例5: parseApp
void parseApp(const char *func, const char *var, SV *arg, Autoref<App> &res)
{
if ( sv_isobject(arg) && (SvTYPE(SvRV(arg)) == SVt_PVMG) ) {
WrapApp *wa = (WrapApp *)SvIV((SV*)SvRV( arg ));
if (wa == 0 || wa->badMagic()) {
throw Exception::f("%s: %s has an incorrect magic for App", func, var);
}
res = wa->get();
} else if (SvPOK(arg)) {
STRLEN len;
char *s = SvPV(arg, len);
string appname(s, len);
res = App::find(appname); // will throw if can't find
} else {
throw Exception::f("%s: %s is not an App reference nor a string", func, var);
}
}
示例6: HRXSATTR_ithread_predup
void HRXSATTR_ithread_predup(SV *self, SV *table, HV *ptr_map)
{
hrattr_simple *attr = attr_from_sv(SvRV(self));
/*Make sure our attribute hash is visible to perl space*/
SV *attrhash_ref;
RV_Newtmp(attrhash_ref, (SV*)attr->attrhash);
hr_dup_store_rv(ptr_map, attrhash_ref);
RV_Freetmp(attrhash_ref);
char *ktmp;
I32 tmplen;
SV *vtmp;
SV *rlookup;
get_hashes(REF2TABLE(table),
HR_HKEY_LOOKUP_REVERSE, &rlookup,
HR_HKEY_LOOKUP_NULL);
hv_iterinit(attr->attrhash);
while( (vtmp = hv_iternextsv(attr->attrhash, &ktmp, &tmplen))) {
HR_Dup_Vinfo *vi = hr_dup_get_vinfo(ptr_map, SvRV(vtmp), 1);
if(!vi->vhash) {
SV *vaddr = newSVuv((UV)SvRV(vtmp));
SV *vhash = get_vhash_from_rlookup(rlookup, vaddr, 0);
vi->vhash = vhash;
SvREFCNT_dec(vaddr);
}
}
if(attr->encap) {
hrattr_encap *aencap = attr_encap_cast(attr);
hr_dup_store_rv(ptr_map, aencap->obj_rv);
char *ai = (char*)hr_dup_store_kinfo(
ptr_map, HR_DUPKEY_AENCAP, aencap->obj_paddr, 1);
if(SvWEAKREF(aencap->obj_rv)) {
*ai = HRK_DUP_WEAK_ENCAP;
} else {
*ai = 0;
}
}
}
示例7: THX_MopMmV_assign_to_stash
void THX_MopMmV_assign_to_stash(pTHX_ SV* metamethod, GV* gv, HV* stash) {
CV* cv = (CV*) SvRV(metamethod);
GvCVGEN(gv) = 0;
GvCV_set(gv, cv);
CvGV_set(cv, gv);
CvSTASH_set(cv, stash);
}
示例8: hv_to_job_step_info
/*
* convert perl HV to job_step_info_t
*/
int
hv_to_job_step_info(HV *hv, job_step_info_t *step_info)
{
SV **svp;
AV *av;
int i, n;
FETCH_FIELD(hv, step_info, array_job_id, uint32_t, TRUE);
FETCH_FIELD(hv, step_info, array_task_id, uint32_t, TRUE);
FETCH_FIELD(hv, step_info, ckpt_dir, charp, FALSE);
FETCH_FIELD(hv, step_info, ckpt_interval, uint16_t, TRUE);
FETCH_FIELD(hv, step_info, gres, charp, FALSE);
FETCH_FIELD(hv, step_info, job_id, uint16_t, TRUE);
FETCH_FIELD(hv, step_info, name, charp, FALSE);
FETCH_FIELD(hv, step_info, network, charp, FALSE);
FETCH_FIELD(hv, step_info, nodes, charp, FALSE);
svp = hv_fetch(hv, "node_inx", 8, FALSE);
if (svp && SvROK(*svp) && SvTYPE(SvRV(*svp)) == SVt_PVAV) {
av = (AV*)SvRV(*svp);
n = av_len(av) + 2; /* for trailing -1 */
step_info->node_inx = xmalloc(n * sizeof(int));
for (i = 0 ; i < n-1; i += 2) {
step_info->node_inx[i] = (int)SvIV(*(av_fetch(av, i ,FALSE)));
step_info->node_inx[i+1] = (int)SvIV(*(av_fetch(av, i+1 ,FALSE)));
}
step_info->node_inx[n-1] = -1;
} else {
/* nothing to do */
}
FETCH_FIELD(hv, step_info, num_cpus, uint32_t, TRUE);
FETCH_FIELD(hv, step_info, num_tasks, uint32_t, TRUE);
FETCH_FIELD(hv, step_info, partition, charp, FALSE);
FETCH_FIELD(hv, step_info, profile, uint32_t, TRUE);
FETCH_FIELD(hv, step_info, resv_ports, charp, FALSE);
FETCH_FIELD(hv, step_info, run_time, time_t, TRUE);
FETCH_FIELD(hv, step_info, start_time, time_t, TRUE);
FETCH_FIELD(hv, step_info, step_id, uint32_t, TRUE);
FETCH_FIELD(hv, step_info, time_limit, uint32_t, TRUE);
FETCH_FIELD(hv, step_info, user_id, uint32_t, TRUE);
FETCH_FIELD(hv, step_info, state, uint16_t, TRUE);
return 0;
}
示例9: PJS_GetPassport
SV* PJS_GetPassport(
pTHX_
JSContext *cx,
JSObject *thing
) {
jsval temp;
SV *box;
SV *tref;
JSObject *inboxed;
if(!JS_LookupPropertyWithFlags(cx, thing, PJS_PASSPORT_PROP, 0, &temp)
|| JSVAL_IS_VOID(temp) || JSVAL_IS_NULL(temp))
croak("Can't get passport");
box = (SV *)JS_GetPrivate(cx, JSVAL_TO_OBJECT(temp));
tref = *av_fetch((AV *)SvRV(box), 0, 0);
inboxed = INT2PTR(JSObject *, SvIV((SV *)SvRV(tref)));
assert(inboxed == thing);
return box;
}
示例10: tm_input_ptrref
/* T_PTRREF */
void *
tm_input_ptrref(pTHX_ SV * const arg)
{
if (SvROK(arg)) {
IV tmp = SvIV((SV*)SvRV(arg));
return INT2PTR(void *, tmp);
}
else
return NULL;
示例11: THX_MopMcV_construct_instance
SV* THX_MopMcV_construct_instance(pTHX_ SV* metaclass, SV* repr) {
// TODO:
// This should handle all the attributes
// and constructing things properly, which
// should also include running all BUILD
// methods.
// - SL
return sv_bless(repr, (HV*) SvRV(metaclass));
}
示例12: lrint
void
Point::from_SV(SV* point_sv)
{
AV* point_av = (AV*)SvRV(point_sv);
// get a double from Perl and round it, otherwise
// it would get truncated
this->x = lrint(SvNV(*av_fetch(point_av, 0, 0)));
this->y = lrint(SvNV(*av_fetch(point_av, 1, 0)));
}
示例13: attr_from_sv
SV *HRXSATTR_get_hash(SV *self)
{
hrattr_simple *attr = attr_from_sv(SvRV(self));
if(attr->attrhash) {
return newRV_inc((SV*)attr->attrhash);
} else {
return &PL_sv_undef;
}
}
示例14: PJS_finalize
void PJS_finalize(JSContext *cx, JSObject *obj) {
void *ptr = JS_GetPrivate(cx, obj);
if(ptr != NULL) {
if (SvTYPE((SV *) ptr) == SVt_RV) {
SvREFCNT_dec(SvRV((SV *) ptr));
}
}
}
示例15: p5_is_wrapped_p6_object
int p5_is_wrapped_p6_object(PerlInterpreter *my_perl, SV *obj) {
PERL_SET_CONTEXT(my_perl);
{
SV * const obj_deref = SvRV(obj);
/* check for magic! */
MAGIC * const mg = mg_find(obj_deref, '~');
return (mg && mg->mg_ptr && ((_perl6_magic*)(mg->mg_ptr))->key == PERL6_MAGIC_KEY);
}
}