summaryrefslogtreecommitdiff
path: root/mg.c
diff options
context:
space:
mode:
authorNicholas Clark <nick@ccl4.org>2010-04-25 15:41:48 +0100
committerNicholas Clark <nick@ccl4.org>2010-04-26 21:09:54 +0100
commit67549bd2d9da9e6710cdab4542e708ef4d4346b6 (patch)
treedd10c6ceb21eec955d442f1f38693673a62fe647 /mg.c
parentbbda9cad3990b2899f9b14eed43d91fea90bd738 (diff)
downloadperl-67549bd2d9da9e6710cdab4542e708ef4d4346b6.tar.gz
For Perl_magic_methcall() add G_UNDEF_FILL to fill the stack with &PL_sv_undef.
This replaces the previous special case of using a negative argument count to signify this, allowing the argument count to become unsigned. Rename it from n to argc.
Diffstat (limited to 'mg.c')
-rw-r--r--mg.c30
1 files changed, 13 insertions, 17 deletions
diff --git a/mg.c b/mg.c
index e29b1c6804..66d777f1c9 100644
--- a/mg.c
+++ b/mg.c
@@ -1649,10 +1649,12 @@ Invoke a magic method (like FETCH).
* sv and mg are the tied thinggy and the tie magic;
* meth is the name of the method to call;
-* n, arg1, arg2 are the number of args (in addition to $self) to pass to
- the method, and the args themselves (negative n is special-cased);
+* argc, arg1, arg2 are the number of args (in addition to $self) to pass to
+ the method, and the args themselves
* flags:
G_DISCARD: invoke method with G_DISCARD flag and don't return a value
+ G_UNDEF_FILL: fill the stack with argc pointers to PL_sv_undef;
+ ignore arg1 and arg2.
Returns the SV (if any) returned by the method, or NULL on failure.
@@ -1662,7 +1664,7 @@ Returns the SV (if any) returned by the method, or NULL on failure.
SV*
Perl_magic_methcall(pTHX_ SV *sv, const MAGIC *mg, const char *meth, U32 flags,
- int n, SV *arg1, SV *arg2)
+ U32 argc, SV *arg1, SV *arg2)
{
dVAR;
dSP;
@@ -1674,22 +1676,16 @@ Perl_magic_methcall(pTHX_ SV *sv, const MAGIC *mg, const char *meth, U32 flags,
PUSHSTACKi(PERLSI_MAGIC);
PUSHMARK(SP);
- if (n < 0) {
- /* special case for UNSHIFT */
- EXTEND(SP,-n+1);
- PUSHs(SvTIED_obj(sv, mg));
- while (n++ < 0) {
+ EXTEND(SP, argc+1);
+ PUSHs(SvTIED_obj(sv, mg));
+ if (flags & G_UNDEF_FILL) {
+ while (argc--) {
PUSHs(&PL_sv_undef);
}
- }
- else {
- EXTEND(SP,n+1);
- PUSHs(SvTIED_obj(sv, mg));
- if (n > 0) {
- PUSHs(arg1);
- if (n > 1) PUSHs(arg2);
- assert(n <= 2);
- }
+ } else if (argc > 0) {
+ PUSHs(arg1);
+ if (argc > 1) PUSHs(arg2);
+ assert(argc <= 2);
}
PUTBACK;
if (flags & G_DISCARD) {