diff options
author | Florian Ragwitz <rafl@debian.org> | 2010-11-25 02:40:00 +0100 |
---|---|---|
committer | Florian Ragwitz <rafl@debian.org> | 2010-11-30 12:37:29 +0100 |
commit | 39de7f53b474076d5a8e28b5b41fddefd29e45d7 (patch) | |
tree | b27c20c09b496e75b9eee2c3a778196aead62ba0 | |
parent | b83794c7d64c56b8d918c51e93d1136d33fa202b (diff) | |
download | perl-39de7f53b474076d5a8e28b5b41fddefd29e45d7.tar.gz |
Add mg_findext
-rw-r--r-- | embed.fnc | 1 | ||||
-rw-r--r-- | embed.h | 1 | ||||
-rw-r--r-- | global.sym | 1 | ||||
-rw-r--r-- | mg.c | 45 | ||||
-rw-r--r-- | proto.h | 3 |
5 files changed, 42 insertions, 9 deletions
@@ -727,6 +727,7 @@ Apd |int |mg_copy |NN SV *sv|NN SV *nsv|NULLOK const char *key \ : Defined in mg.c, used only in scope.c pd |void |mg_localize |NN SV* sv|NN SV* nsv|bool setmagic ApdR |MAGIC* |mg_find |NULLOK const SV* sv|int type +ApdR |MAGIC* |mg_findext |NULLOK const SV* sv|int type|NULLOK const MGVTBL *vtbl Apd |int |mg_free |NN SV* sv Apd |void |mg_free_type |NN SV* sv|int how Apd |int |mg_get |NN SV* sv @@ -278,6 +278,7 @@ #define mg_clear(a) Perl_mg_clear(aTHX_ a) #define mg_copy(a,b,c,d) Perl_mg_copy(aTHX_ a,b,c,d) #define mg_find(a,b) Perl_mg_find(aTHX_ a,b) +#define mg_findext(a,b,c) Perl_mg_findext(aTHX_ a,b,c) #define mg_free(a) Perl_mg_free(aTHX_ a) #define mg_free_type(a,b) Perl_mg_free_type(aTHX_ a,b) #define mg_get(a) Perl_mg_get(aTHX_ a) diff --git a/global.sym b/global.sym index 4aaa59ea40..3831f004f9 100644 --- a/global.sym +++ b/global.sym @@ -311,6 +311,7 @@ Perl_mfree Perl_mg_clear Perl_mg_copy Perl_mg_find +Perl_mg_findext Perl_mg_free Perl_mg_free_type Perl_mg_get @@ -416,6 +416,26 @@ Perl_mg_clear(pTHX_ SV *sv) return 0; } +MAGIC* +S_mg_findext_flags(pTHX_ const SV *sv, int type, const MGVTBL *vtbl, U32 flags) +{ + PERL_UNUSED_CONTEXT; + + assert(flags <= 1); + + if (sv) { + MAGIC *mg; + + for (mg = SvMAGIC(sv); mg; mg = mg->mg_moremagic) { + if (mg->mg_type == type && (!flags || mg->mg_virtual == vtbl)) { + return mg; + } + } + } + + return NULL; +} + /* =for apidoc mg_find @@ -427,15 +447,22 @@ Finds the magic pointer for type matching the SV. See C<sv_magic>. MAGIC* Perl_mg_find(pTHX_ const SV *sv, int type) { - PERL_UNUSED_CONTEXT; - if (sv) { - MAGIC *mg; - for (mg = SvMAGIC(sv); mg; mg = mg->mg_moremagic) { - if (mg->mg_type == type) - return mg; - } - } - return NULL; + return S_mg_findext_flags(aTHX_ sv, type, NULL, 0); +} + +/* +=for apidoc mg_findext + +Finds the magic pointer of C<type> with the given C<vtbl> for the C<SV>. See +C<sv_magicext>. + +=cut +*/ + +MAGIC* +Perl_mg_findext(pTHX_ const SV *sv, int type, const MGVTBL *vtbl) +{ + return S_mg_findext_flags(aTHX_ sv, type, vtbl, 1); } /* @@ -2208,6 +2208,9 @@ PERL_CALLCONV int Perl_mg_copy(pTHX_ SV *sv, SV *nsv, const char *key, I32 klen) PERL_CALLCONV MAGIC* Perl_mg_find(pTHX_ const SV* sv, int type) __attribute__warn_unused_result__; +PERL_CALLCONV MAGIC* Perl_mg_findext(pTHX_ const SV* sv, int type, const MGVTBL *vtbl) + __attribute__warn_unused_result__; + PERL_CALLCONV int Perl_mg_free(pTHX_ SV* sv) __attribute__nonnull__(pTHX_1); #define PERL_ARGS_ASSERT_MG_FREE \ |