Ap |OP * |doref |NN OP *o|I32 type|bool set_op_ref
Apd |SV* |eval_pv |NN const char* p|I32 croak_on_error
Apd |I32 |eval_sv |NN SV* sv|I32 flags
-Apd |SV* |get_sv |NN const char* name|I32 create
+Apd |SV* |get_sv |NN const char *name|I32 flags
Apd |AV* |get_av |NN const char *name|I32 flags
Apd |HV* |get_hv |NN const char *name|I32 flags
Apd |CV* |get_cv |NN const char* name|I32 flags
if (!g_frequ) {
if (CheckOSError(DosTmrQueryFreq(&g_frequ)))
- croak("DosTmrQueryFreq: %s", SvPV_nolen(perl_get_sv("!",TRUE)));
+ croak("DosTmrQueryFreq: %s", SvPV_nolen(perl_get_sv("!",GV_ADD)));
else
g_frequ = g_frequ/DPROF_HZ; /* count per tick */
if (CheckOSError(DosTmrQueryTime(&cnt)))
croak("DosTmrQueryTime: %s",
- SvPV_nolen_const(perl_get_sv("!",TRUE)));
+ SvPV_nolen_const(perl_get_sv("!",GV_ADD)));
g_start_cnt = toLongLong(cnt);
}
if (CheckOSError(DosTmrQueryTime(&cnt)))
- croak("DosTmrQueryTime: %s", SvPV_nolen(perl_get_sv("!",TRUE)));
+ croak("DosTmrQueryTime: %s", SvPV_nolen(perl_get_sv("!",GV_ADD)));
t->tms_stime = 0;
return (t->tms_utime = (toLongLong(cnt) - g_start_cnt)/g_frequ);
#else /* !OS2 */
if (!tv0.tv_sec)
if (gettimeofday(&tv0, NULL) < 0)
- croak("gettimeofday: %s", SvPV_nolen_const(perl_get_sv("!",TRUE)));
+ croak("gettimeofday: %s", SvPV_nolen_const(perl_get_sv("!",GV_ADD)));
if (getrusage(0, &ru) < 0)
- croak("getrusage: %s", SvPV_nolen_const(perl_get_sv("!",TRUE)));
+ croak("getrusage: %s", SvPV_nolen_const(perl_get_sv("!",GV_ADD)));
if (gettimeofday(&tv, NULL) < 0)
- croak("gettimeofday: %s", SvPV_nolen_const(perl_get_sv("!",TRUE)));
+ croak("gettimeofday: %s", SvPV_nolen_const(perl_get_sv("!",GV_ADD)));
t->tms_stime = DPROF_HZ * ru.ru_stime.tv_sec + ru.ru_stime.tv_usec;
t->tms_utime = DPROF_HZ * ru.ru_utime.tv_sec + ru.ru_utime.tv_usec;
I32 lim
PPCODE:
{
- SV *pv_lim_sv = perl_get_sv("Devel::Peek::pv_limit", FALSE);
+ SV *pv_lim_sv = perl_get_sv("Devel::Peek::pv_limit", 0);
const STRLEN pv_lim = pv_lim_sv ? SvIV(pv_lim_sv) : 0;
- SV *dumpop = perl_get_sv("Devel::Peek::dump_ops", FALSE);
+ SV *dumpop = perl_get_sv("Devel::Peek::dump_ops", 0);
const U16 save_dumpindent = PL_dumpindent;
PL_dumpindent = 2;
do_sv_dump(0, Perl_debug_log, sv, 0, lim,
PPCODE:
{
long i;
- SV *pv_lim_sv = perl_get_sv("Devel::Peek::pv_limit", FALSE);
+ SV *pv_lim_sv = perl_get_sv("Devel::Peek::pv_limit", 0);
const STRLEN pv_lim = pv_lim_sv ? SvIV(pv_lim_sv) : 0;
- SV *dumpop = perl_get_sv("Devel::Peek::dump_ops", FALSE);
+ SV *dumpop = perl_get_sv("Devel::Peek::dump_ops", 0);
const U16 save_dumpindent = PL_dumpindent;
PL_dumpindent = 2;
dTHX;
ULONG len;
char *s;
- int number = SvTRUE(get_sv("OS2::nsyserror", TRUE));
+ int number = SvTRUE(get_sv("OS2::nsyserror", GV_ADD));
if (!(_emx_env & 0x200)) return ""; /* Nop if not OS/2. */
if (rc == 0)
=for apidoc p||get_sv
-Returns the SV of the specified Perl scalar. If C<create> is set and the
-Perl variable does not exist then it will be created. If C<create> is not
-set and the variable does not exist then NULL is returned.
+Returns the SV of the specified Perl scalar. C<flags> are passed to
+C<gv_fetchpv>. If C<GV_ADD> is set and the
+Perl variable does not exist then it will be created. If C<flags> is zero
+and the variable does not exist then NULL is returned.
=cut
*/
SV*
-Perl_get_sv(pTHX_ const char *name, I32 create)
+Perl_get_sv(pTHX_ const char *name, I32 flags)
{
GV *gv;
PERL_ARGS_ASSERT_GET_SV;
- gv = gv_fetchpv(name, create, SVt_PV);
+ gv = gv_fetchpv(name, flags, SVt_PV);
if (gv)
return GvSV(gv);
return NULL;
PL_rs = newSVpvn(&ch, 1);
}
}
- sv_setsv(get_sv("/", TRUE), PL_rs);
+ sv_setsv(get_sv("/", GV_ADD), PL_rs);
return s + numlen;
}
case 'C':
PL_globalstash = GvHV(gv_fetchpvs("CORE::GLOBAL::", GV_ADDMULTI,
SVt_PVHV));
/* We must init $/ before switches are processed. */
- sv_setpvs(get_sv("/", TRUE), "\n");
+ sv_setpvs(get_sv("/", GV_ADD), "\n");
}
STATIC int
GV *tmpgv;
IO *io;
- sv_setpvs(get_sv("\"", TRUE), " ");
+ sv_setpvs(get_sv("\"", GV_ADD), " ");
PL_ofsgv = (GV*)SvREFCNT_inc(gv_fetchpvs(",", GV_ADD|GV_NOTQUAL, SVt_PV));
PL_stdingv = gv_fetchpvs("STDIN", GV_ADD|GV_NOTQUAL, SVt_PVIO);
being declared (when building a module that has XS code), you need
to add C<dTHR;> at the beginning of the block that elicited the error.
-The API function C<perl_get_sv("@",FALSE)> should be used instead of
+The API function C<perl_get_sv("@",GV_ADD)> should be used instead of
directly accessing perl globals as C<GvSV(errgv)>. The API call is
backward compatible with existing perls and provides source compatibility
with threading is enabled.
=item get_sv
X<get_sv>
-Returns the SV of the specified Perl scalar. If C<create> is set and the
-Perl variable does not exist then it will be created. If C<create> is not
-set and the variable does not exist then NULL is returned.
+Returns the SV of the specified Perl scalar. C<flags> are passed to
+C<gv_fetchpv>. If C<GV_ADD> is set and the
+Perl variable does not exist then it will be created. If C<flags> is zero
+and the variable does not exist then NULL is returned.
NOTE: the perl_ form of this function is deprecated.
- SV* get_sv(const char* name, I32 create)
+ SV* get_sv(const char *name, I32 flags)
=for hackers
Found in file perl.c
If you want to throw an exception object, assign the object to
C<$@> and then pass C<NULL> to croak():
- errsv = get_sv("@", TRUE);
+ errsv = get_sv("@", GV_ADD);
sv_setsv(errsv, exception_object);
croak(NULL);
/** Treat $a as an integer **/
eval_pv("$a = 3; $a **= 2", TRUE);
- printf("a = %d\n", SvIV(get_sv("a", FALSE)));
+ printf("a = %d\n", SvIV(get_sv("a", 0)));
/** Treat $a as a float **/
eval_pv("$a = 3.14; $a **= 2", TRUE);
- printf("a = %f\n", SvNV(get_sv("a", FALSE)));
+ printf("a = %f\n", SvNV(get_sv("a", 0)));
/** Treat $a as a string **/
eval_pv("$a = 'rekcaH lreP rehtonA tsuJ'; $a = reverse($a);", TRUE);
- printf("a = %s\n", SvPV_nolen(get_sv("a", FALSE)));
+ printf("a = %s\n", SvPV_nolen(get_sv("a", 0)));
perl_destruct(my_perl);
perl_free(my_perl);
retval = my_eval_sv(command, TRUE);
SvREFCNT_dec(command);
- *string = get_sv("string", FALSE);
+ *string = get_sv("string", 0);
return SvIV(retval);
}
If you know the name of a scalar variable, you can get a pointer to its SV
by using the following:
- SV* get_sv("package::varname", FALSE);
+ SV* get_sv("package::varname", 0);
This returns NULL if the variable does not exist.
To create a new Perl variable with an undef value which can be accessed from
your Perl script, use the following routines, depending on the variable type.
- SV* get_sv("package::varname", TRUE);
+ SV* get_sv("package::varname", GV_ADD);
AV* get_av("package::varname", GV_ADD);
HV* get_hv("package::varname", GV_ADD);
extern int dberror;
extern char *dberror_list;
- SV* sv = get_sv("dberror", TRUE);
+ SV* sv = get_sv("dberror", GV_ADD);
sv_setiv(sv, (IV) dberror);
sv_setpv(sv, dberror_list[dberror]);
SvIOK_on(sv);
#define PERL_ARGS_ASSERT_EVAL_SV \
assert(sv)
-PERL_CALLCONV SV* Perl_get_sv(pTHX_ const char* name, I32 create)
+PERL_CALLCONV SV* Perl_get_sv(pTHX_ const char *name, I32 flags)
__attribute__nonnull__(pTHX_1);
#define PERL_ARGS_ASSERT_GET_SV \
assert(name)
} else {
buf8.Format(_L8("Symbian error %d"), error);
}
- SV* sv = Perl_get_sv(aTHX_ "\005", TRUE); /* $^E or ${^OS_ERROR} */
+ SV* sv = Perl_get_sv(aTHX_ "\005", GV_ADD); /* $^E or ${^OS_ERROR} */
if (!sv)
return (char*)NullErr;
sv_setpv(sv, (const char *)buf8.PtrZ());
If you want to throw an exception object, assign the object to
C<$@> and then pass C<NULL> to croak():
- errsv = get_sv("@", TRUE);
+ errsv = get_sv("@", GV_ADD);
sv_setsv(errsv, exception_object);
croak(NULL);