Closed p5pRT closed 9 years ago
call_sv's docs currently say
--------------------------------------------------------------- =for apidoc p||call_sv
Performs a callback to the Perl sub whose name is in the SV. See
L\
=cut ---------------------------------------------------------------
That says it is exactly equivalent to "call_pv(SvPV_nolen(sv)\,0);"
perlcall says "This allows you to specify the Perl subroutine to be called either as a C string (which has first been converted to an SV) or a reference to a subroutine."
So my question is\, what is the all inclusive list of what call_sv can be used on? And more specifically\, will call_sv take a CV *? Not a SV * ref to a CV *\, but a CV *?
I put a warn on SvTYPE into XS-APITest\,
------------------------------------------------------ Creating library ..\..\lib\auto\XS\APItest\APItest.lib and object ..\..\lib\a uto\XS\APItest\APItest.exp Generating code Finished generating code if exist ..\..\lib\auto\XS\APItest\APItest.dll.manifest mt -nologo -mani fest ..\..\lib\auto\XS\APItest\APItest.dll.manifest -outputresource:..\..\lib\au to\XS\APItest\APItest.dll;2 if exist ..\..\lib\auto\XS\APItest\APItest.dll.manifest del ..\..\lib\au to\XS\APItest\APItest.dll.manifest C:\p519\src\miniperl.exe "-I..\..\lib" "-I..\..\lib" -MExtUtils::Command -e chmod -- 755 ..\..\lib\auto\XS\APItest\APItest.dll ..\..\perl.exe "-I..\..\lib" "-I..\..\lib" "-MExtUtils::Command::MM" "-M Test::Harness" "-e" "undef *Test::Harness::Switches; test_harness(0\, '..\..\lib' \, '..\..\lib')" t/*.t t/addissub.t ................. ok t/arrayexpr.t ................ ok t/autoload.t ................. ok t/blockasexpr.t .............. ok t/blockhooks-csc.t ........... ok t/blockhooks.t ............... ok t/call.t ..................... type of SV is 1 type of SV is 9 type of SV is 3 # Failed test 10 - 0 args\, G_VOID G_EVAL call_sv('d') - warning at t/call.t line 97 # got "type of SV is 3\n" # expected "" # Failed test 22 - 0 args\, G_VOID G_KEEPERR G_EVAL call_sv('d') - warning at t/c all.t line 97 # got "type of SV is 3\n\t(in cleanup) its_dead_jim\n" # expected "\t(in cleanup) its_dead_jim\n" type of SV is 3 type of SV is 3 type of SV is 1 type of SV is 9 type of SV is 3 # Failed test 47 - 3 args\, G_VOID G_EVAL call_sv('d') - warning at t/call.t line 97 # got "type of SV is 3\n" # expected "" # Failed test 59 - 3 args\, G_VOID G_KEEPERR G_EVAL call_sv('d') - warning at t/c all.t line 97 # got "type of SV is 3\n\t(in cleanup) its_dead_jim\n" # expected "\t(in cleanup) its_dead_jim\n" type of SV is 3 type of SV is 3 type of SV is 1 type of SV is 9 type of SV is 3 # Failed test 84 - 0 args\, G_SCALAR G_EVAL call_sv('d') - warning at t/call.t li ne 97 # got "type of SV is 3\n" # expected "" # Failed test 96 - 0 args\, G_SCALAR G_KEEPERR G_EVAL call_sv('d') - warning at t /call.t line 97 # got "type of SV is 3\n\t(in cleanup) its_dead_jim\n" # expected "\t(in cleanup) its_dead_jim\n" type of SV is 3 type of SV is 3 type of SV is 1 type of SV is 9 type of SV is 3 # Failed test 121 - 3 args\, G_SCALAR G_EVAL call_sv('d') - warning at t/call.t l ine 97 # got "type of SV is 3\n" # expected "" # Failed test 133 - 3 args\, G_SCALAR G_KEEPERR G_EVAL call_sv('d') - warning at t/call.t line 97 # got "type of SV is 3\n\t(in cleanup) its_dead_jim\n" # expected "\t(in cleanup) its_dead_jim\n" type of SV is 3 type of SV is 3 type of SV is 1 type of SV is 9 type of SV is 3 # Failed test 158 - 0 args\, G_ARRAY G_EVAL call_sv('d') - warning at t/call.t li ne 97 # got "type of SV is 3\n" # expected "" # Failed test 170 - 0 args\, G_ARRAY G_KEEPERR G_EVAL call_sv('d') - warning at t /call.t line 97 t/call.t ..................... 1/436 # got "type of SV is 3\n\t(in cleanup) its_dead_jim\n" # expected "\t(in cleanup) its_dead_jim\n" type of SV is 3 type of SV is 3 type of SV is 1 type of SV is 9 type of SV is 3 # Failed test 195 - 3 args\, G_ARRAY G_EVAL call_sv('d') - warning at t/call.t li ne 97 # got "type of SV is 3\n" # expected "" # Failed test 207 - 3 args\, G_ARRAY G_KEEPERR G_EVAL call_sv('d') - warning at t /call.t line 97 # got "type of SV is 3\n\t(in cleanup) its_dead_jim\n" # expected "\t(in cleanup) its_dead_jim\n" type of SV is 3 type of SV is 3 type of SV is 1 type of SV is 9 type of SV is 3 # Failed test 232 - 0 args\, G_DISCARD G_EVAL call_sv('d') - warning at t/call.t line 97 # got "type of SV is 3\n" # expected "" # Failed test 244 - 0 args\, G_DISCARD G_KEEPERR G_EVAL call_sv('d') - warning at t/call.t line 97 # got "type of SV is 3\n\t(in cleanup) its_dead_jim\n" # expected "\t(in cleanup) its_dead_jim\n" type of SV is 3 type of SV is 3 type of SV is 1 type of SV is 9 type of SV is 3 # Failed test 269 - 3 args\, G_DISCARD G_EVAL call_sv('d') - warning at t/call.t line 97 # got "type of SV is 3\n" # expected "" # Failed test 281 - 3 args\, G_DISCARD G_KEEPERR G_EVAL call_sv('d') - warning at t/call.t line 97 # got "type of SV is 3\n\t(in cleanup) its_dead_jim\n" # expected "\t(in cleanup) its_dead_jim\n" type of SV is 3 type of SV is 3 # Failed test 300 - at t/call.t line 170 # got "type of SV is 1\n" # expected "" # Failed test 302 - at t/call.t line 176 # got "type of SV is 1\n" # expected "" # Failed test 304 - at t/call.t line 170 # got "type of SV is 1\n" # expected "" # Failed test 306 - at t/call.t line 176 # got "type of SV is 1\n" # expected "" # Failed test 308 - at t/call.t line 170 # got "type of SV is 1\n" # expected "" # Failed test 310 - at t/call.t line 176 # got "type of SV is 1\n" # expected "" # Failed test 312 - at t/call.t line 170 # got "type of SV is 1\n" # expected "" # Failed test 314 - at t/call.t line 176 # got "type of SV is 1\n\t(in cleanup) aabbcc\n" # expected "\t(in cleanup) aabbcc\n" # Failed test 316 - at t/call.t line 170 # got "type of SV is 1\n" # expected "" # Failed test 318 - at t/call.t line 176 # got "type of SV is 1\n\t(in cleanup) aabbcc\n" # expected "\t(in cleanup) aabbcc\n" # Failed test 320 - at t/call.t line 170 # got "type of SV is 1\n" # expected "" # Failed test 322 - at t/call.t line 176 # got "type of SV is 1\n\t(in cleanup) aabbcc\n" # expected "\t(in cleanup) aabbcc\n" # Failed test 324 - at t/call.t line 170 # got "type of SV is 1\n" # expected "" # Failed test 326 - at t/call.t line 176 # got "type of SV is 1\n\t(in cleanup) ARRAY(0x1badb2c)" # expected "\t(in cleanup) ARRAY(0x1badb2c)" # Failed test 328 - at t/call.t line 170 # got "type of SV is 1\n" # expected "" # Failed test 330 - at t/call.t line 176 # got "type of SV is 1\n\t(in cleanup) ARRAY(0x1badb2c)" # expected "\t(in cleanup) ARRAY(0x1badb2c)" # Failed test 332 - at t/call.t line 170 # got "type of SV is 1\n" # expected "" # Failed test 334 - at t/call.t line 176 # got "type of SV is 1\n\t(in cleanup) ARRAY(0x1badb2c)" # expected "\t(in cleanup) ARRAY(0x1badb2c)" # Failed test 335 - at t/call.t line 185 # got "type of SV is 1\n" # expected "" # Failed test 336 - at t/call.t line 193 # got "type of SV is 1\n\t(in cleanup) aa\n" # expected "\t(in cleanup) aa\n" # Failed test 420 - call_sv('f99'\, G_EVAL|G_ARRAY|0) - __WARN__ not called at t/ call.t line 274 # got "type of SV is 3\n" # expected undef # Failed test 426 - call_sv('f99'\, G_EVAL|G_ARRAY|G_KEEPERR) - the correct error message at t/call.t line 277 # got 'type of SV is 3 # ' # expected /(?^:^$)/ # Failed test 429 - call_sv('d'\, G_EVAL|G_ARRAY|0) - __WARN__ not called at t/ca ll.t line 274 # got "type of SV is 3\n" # expected undef t/call.t ..................... Failed 39/436 subtests t/call_checker.t ............. ok t/caller.t ................... ok t/callregexec.t .............. ok t/check_warnings.t ........... ok t/cleanup.t .................. ok t/clone-with-stack.t ......... ok t/cophh.t .................... ok t/coplabel.t ................. ok t/copstash.t ................. ok t/copyhints.t ................ ok t/customop.t ................. ok t/eval-filter.t .............. ok t/exception.t ................ ok t/fetch_pad_names.t .......... ok t/gotosub.t .................. ok t/grok.t ..................... ok t/gv_autoload4.t ............. ok t/gv_fetchmeth.t ............. ok t/gv_fetchmeth_autoload.t .... ok t/gv_fetchmethod_flags.t ..... ok t/gv_init.t .................. ok t/handy.t .................... ok t/hash.t ..................... ok t/keyword_multiline.t ........ ok t/keyword_plugin.t ........... ok t/labelconst.t ............... ok t/lexsub.t ................... ok t/loopblock.t ................ ok t/looprest.t ................. ok t/lvalue.t ................... ok t/magic.t .................... ok t/magic_chain.t .............. ok t/mro.t ...................... ok t/multicall.t ................ ok t/my_cxt.t ................... ok t/my_exit.t .................. Can't locate test.pl in @INC (@INC contains: C:\p 519\src\lib ..\..\lib C:/p519/src/lib .) at t/my_exit.t line 6. t/my_exit.t .................. Dubious\, test returned 2 (wstat 512\, 0x200) No subtests run t/newCONSTSUB.t .............. ok t/op.t ....................... ok t/op_contextualize.t ......... ok t/op_list.t .................. ok t/overload.t ................. ok t/pad_scalar.t ............... ok t/peep.t ..................... ok t/pmflag.t ................... ok t/postinc.t .................. ok t/printf.t ................... ok t/ptr_table.t ................ ok t/push.t ..................... ok t/refs.t ..................... ok t/rmagical.t ................. ok t/rv2cv_op_cv.t .............. ok t/savehints.t ................ ok t/scopelessblock.t ........... ok t/sort.t ..................... ok t/stmtasexpr.t ............... ok t/stmtsasexpr.t .............. ok t/stuff_modify_bug.t ......... ok t/stuff_svcur_bug.t .......... ok t/subcall.t .................. ok t/sviscow.t .................. ok t/svpeek.t ................... ok t/svpv.t ..................... ok t/svpv_magic.t ............... ok t/svsetsv.t .................. ok t/swaplabel.t ................ ok t/swaptwostmts.t ............. ok t/sym-hook.t ................. ok t/temp_lv_sub.t .............. ok t/underscore_length.t ........ ok t/utf16_to_utf8.t ............ ok t/utf8.t ..................... ok t/whichsig.t ................. ok t/xs_special_subs.t .......... ok t/xs_special_subs_require.t .. ok t/xsub_h.t ................... ok
Test Summary Report ------------------- t/call.t (Wstat: 0 Tests: 436 Failed: 39) Failed tests: 10\, 22\, 47\, 59\, 84\, 96\, 121\, 133\, 158\, 170 195\, 207\, 232\, 244\, 269\, 281\, 300\, 302 304\, 306\, 308\, 310\, 312\, 314\, 316\, 318 320\, 322\, 324\, 326\, 328\, 330\, 332\, 334-336 420\, 426\, 429 t/my_exit.t (Wstat: 512 Tests: 0 Failed: 0) Non-zero exit status: 2 Parse errors: No plan found in TAP output Files=82\, Tests=58285\, 51 wallclock secs ( 7.30 usr + 3.64 sys = 10.94 CPU) Result: FAIL Failed 2/82 test programs. 39/58285 subtests failed. NMAKE : fatal error U1077: '..\..\perl.exe' : return code '0xff' Stop.
C:\p519\src\ext\XS-APItest> ------------------------------------------------------
I got types as far as I can see. 1 (SVt_IV\, probably these are refs to things)\, 3 (SVt_PV)\, and 9 (SVt_PVGV\, not sure what this is in Pure Perl). NO 13 (SVt_PVCV). The tests are all from a very thin wrapper XSUB around the C call_sv. The sub SV * always comes from @_ in the tests\, so whether a CV * is allowed is never tested. AFAIK\, it is not possible to put a CV * on @_ stack from pure perl\, is this correct?
The pod needs fixes. I'm still researching whether to add something to APITest to test if CV *s can be passed to call_sv.
On Thu\, Dec 19\, 2013 at 4:47 AM\, bulk88 \perlbug\-followup@​perl\.org wrote:
# New Ticket Created by bulk88 # Please include the string: [perl #120826] # in the subject line of all future correspondence about this issue. # \<URL: https://rt-archive.perl.org/perl5/Ticket/Display.html?id=120826 >
This is a bug report for perl from bulk88@hotmail.com\, generated with the help of perlbug 1.39 running under perl 5.19.7.
----------------------------------------------------------------- [Please describe your issue here]
call_sv's docs currently say
--------------------------------------------------------------- =for apidoc p||call_sv
Performs a callback to the Perl sub whose name is in the SV. See L\
. =cut ---------------------------------------------------------------
That says it is exactly equivalent to "call_pv(SvPV_nolen(sv)\,0);"
perlcall says "This allows you to specify the Perl subroutine to be called either as a C string (which has first been converted to an SV) or a reference to a subroutine."
So my question is\, what is the all inclusive list of what call_sv can be used on? And more specifically\, will call_sv take a CV *? Not a SV * ref to a CV *\, but a CV *?
[Assumes neither G_METHOD nor G_METHOD_NAMED was provided as a flag.]
A comment in the source says "May be called with any of a CV\, a GV\, or an SV containing the name."
But it also accepts a code reference. Specifically\, when neither G_METHOD nor G_METHOD_NAMED was provided as a flag\, it takes whatever pp_entersub takes.
- AV*\, HV* and undef are errors. - sv == &PL_sv_yes is a no-op. It is documented as "unfound import\, ignore". - GV*\, CV*\, code reference are accepted as the source of a CV*. - Anything else is presumed to be a string.
Note: "GV*" is defined as: SvTYPE(sv) == SVt_PVGV or SvTYPE(sv) == SVt_PVLV && isGV_with_GP(sv)
The RT System itself - Status changed from 'new' to 'open'
Eric Brine wrote:
- sv == &PL_sv_yes is a no-op. It is documented as "unfound import\, ignore".
Freaky:
$ perl -lwe '1->(); print "OK"'
Undefined subroutine &main::1 called at -e line 1.
$ perl -lwe '${\!0}->(); print "OK"'
OK
-zefram
On Thu Dec 19 06:26:12 2013\, ikegami@adaelis.com wrote:
A comment in the source says "May be called with any of a CV\, a GV\, or an SV containing the name." .......
But it also accepts a code reference. Specifically\, when neither G_METHOD nor G_METHOD_NAMED was provided as a flag\, it takes whatever pp_entersub takes.
Not testing this.
- AV*\, HV* and undef are errors.
HV and undef are tested. AV should be pointless to test.
- sv == &PL_sv_yes is a no-op. It is documented as "unfound import\, ignore".
Tested.
- GV*\, CV*\, code reference are accepted as the source of a CV*.
Tested.
- Anything else is presumed to be a string.
Tested.
Note: "GV*" is defined as: SvTYPE(sv) == SVt_PVGV or SvTYPE(sv) == SVt_PVLV && isGV_with_GP(sv)
IDK how to get a LV/isGV_with_GP.
APITest patch attached. Note\, some of things being tested are not (and I don't think they should) be public API or documented. If some of the tests are broken in the future\, the tests should be fixed or removed\, not the future code.
-- bulk88 ~ bulk88 at hotmail.com
On Sat Dec 21 21:53:42 2013\, bulk88 wrote:
APITest patch attached. Note\, some of things being tested are not (and I don't think they should) be public API or documented. If some of the tests are broken in the future\, the tests should be fixed or removed\, not the future code.
Stray leftover comment was in the last patch\, new patch attached.
-- bulk88 ~ bulk88 at hotmail.com
bulk88 wrote:
IDK how to get a LV/isGV_with_GP.
Return a glob from a tied array element. Or assign one to a nonexistent element via a sub:
sub { $_[0] = *foo; # $_[0] is now a pavlov glob }->($h{doesnotexist})
On Sat Dec 21 21:56:28 2013\, bulk88 wrote:
Stray leftover comment was in the last patch\, new patch attached.
this got a commit by FC but no confirmation post in this ticket\, this bug is to stay open since the commit didnt fix the docs for call_sv
-- bulk88 ~ bulk88 at hotmail.com
Daniel Dragan wrote:
this got a commit by FC but no confirmation post in this ticket\, this bug is to stay open since the commit didnt fix the docs for call_sv
Sorry\, I ran out of time when I was about to say so.
The commit id was a85ce6f00e.
On Mon Dec 23 13:40:49 2013\, bulk88 wrote:
On Sat Dec 21 21:56:28 2013\, bulk88 wrote:
Stray leftover comment was in the last patch\, new patch attached.
this got a commit by FC but no confirmation post in this ticket\, this bug is to stay open since the commit didnt fix the docs for call_sv
Patch for the docs attached.
Tony
On Wed Jul 08 18:55:41 2015\, tonyc wrote:
On Mon Dec 23 13:40:49 2013\, bulk88 wrote:
On Sat Dec 21 21:56:28 2013\, bulk88 wrote:
Stray leftover comment was in the last patch\, new patch attached.
this got a commit by FC but no confirmation post in this ticket\, this bug is to stay open since the commit didnt fix the docs for call_sv
Patch for the docs attached.
Tony
No objections.
-- bulk88 ~ bulk88 at hotmail.com
On Wed Jul 08 20:39:54 2015\, bulk88 wrote:
On Wed Jul 08 18:55:41 2015\, tonyc wrote:
On Mon Dec 23 13:40:49 2013\, bulk88 wrote:
On Sat Dec 21 21:56:28 2013\, bulk88 wrote:
Stray leftover comment was in the last patch\, new patch attached.
this got a commit by FC but no confirmation post in this ticket\, this bug is to stay open since the commit didnt fix the docs for call_sv
Patch for the docs attached.
Tony
No objections.
Okay\, maybe I have some objections.
+Performs a callback to the Perl sub specified by the SV. + +If neither the G_METHOD or G_METHOD_NAMED flag is supplied\, the SV may +be any of a CV\, a GV\, a reference to a CV\, a reference to a GV or the +name of the sub to call.
"the SVPV name of the sub to call"\, name is not a technical term\, it isn't obvious what a name is in Perl API. Instead of SVPV\, "PV" is okay too.
+If the G_METHOD flag is supplied\, the SV may be a refernce to a CV of +the name of the method to call.
"name" is ambiguous\, see above.
+If the G_METHOD_NAMED flag is supplied\, the SV must be the name of the +method.
"name" is ambiguous\, see above.
-- bulk88 ~ bulk88 at hotmail.com
On Sun Aug 02 21:54:28 2015\, bulk88 wrote:
On Wed Jul 08 20:39:54 2015\, bulk88 wrote:
No objections.
Okay\, maybe I have some objections.
+Performs a callback to the Perl sub specified by the SV. + +If neither the G_METHOD or G_METHOD_NAMED flag is supplied\, the SV may +be any of a CV\, a GV\, a reference to a CV\, a reference to a GV or the +name of the sub to call.
"the SVPV name of the sub to call"\, name is not a technical term\, it isn't obvious what a name is in Perl API. Instead of SVPV\, "PV" is okay too.
+If the G_METHOD flag is supplied\, the SV may be a refernce to a CV of +the name of the method to call.
"name" is ambiguous\, see above.
+If the G_METHOD_NAMED flag is supplied\, the SV must be the name of the +method.
"name" is ambiguous\, see above.
Updated patch attached.
Tony
On Sun Aug 02 23:49:25 2015\, tonyc wrote:
Updated patch attached.
Tony
New version is okay. Once this patch is applied\, this 1 yr 7 mo old ticket can finally be closed.
-- bulk88 ~ bulk88 at hotmail.com
On Mon Aug 03 04:04:09 2015\, bulk88 wrote:
On Sun Aug 02 23:49:25 2015\, tonyc wrote:
Updated patch attached.
Tony
New version is okay. Once this patch is applied\, this 1 yr 7 mo old ticket can finally be closed.
Applied as 078e2213d1e79935a637aef6d5b7bc38aa6954fe.
Tony
@tonycoz - Status changed from 'open' to 'resolved'
That text contains "neither..or" instead of "neither..nor".
If neither the C\<G_METHOD> or C\<G_METHOD_NAMED> flag is supplied
should be
If neither the C\<G_METHOD> flag nor the C\<G_METHOD_NAMED> flag is supplied
or
If neither of the C\<G_METHOD> and C\<G_METHOD_NAMED> flags are supplied
On Wed\, Aug 5\, 2015 at 12:57 AM\, Tony Cook via RT \<perlbug-followup@perl.org
wrote:
On Mon Aug 03 04:04:09 2015\, bulk88 wrote:
On Sun Aug 02 23:49:25 2015\, tonyc wrote:
Updated patch attached.
Tony
New version is okay. Once this patch is applied\, this 1 yr 7 mo old ticket can finally be closed.
Applied as 078e2213d1e79935a637aef6d5b7bc38aa6954fe.
Tony
--- via perlbug: queue: perl5 status: open https://rt-archive.perl.org/perl5/Ticket/Display.html?id=120826
On Wed\, Aug 5\, 2015 at 3:22 PM\, Eric Brine \ikegami@​adaelis\.com wrote:
That text contains "neither..or" instead of "neither..nor".
If neither the C\<G_METHOD> or C\<G_METHOD_NAMED> flag is supplied
should be
If neither the C\<G_METHOD> flag nor the C\<G_METHOD_NAMED> flag is supplied
Fixed in 7c0c544ccc3283021df458dc39fb3638b44c2d6e.
Thanks.
-- Matthew Horsfall (alh)
Migrated from rt.perl.org#120826 (status was 'resolved')
Searchable as RT120826$