Skip to content

Commit 178011c

Browse files
committed
Add some documentation for sv_numcmp_common()
1 parent 9db4e16 commit 178011c

File tree

2 files changed

+43
-1
lines changed

2 files changed

+43
-1
lines changed

embed.fnc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6084,7 +6084,7 @@ S |const char *|sv_display|NN SV * const sv \
60846084
|NN char *tmpbuf \
60856085
|STRLEN tmpbuf_size
60866086
S |bool |sv_2iuv_common |NN SV * const sv
6087-
S |bool |sv_numcmp_common \
6087+
Sd |bool |sv_numcmp_common \
60886088
|NULLOK SV **sv1 \
60896089
|NULLOK SV **sv2 \
60906090
|const U32 flags \

sv.c

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8732,6 +8732,48 @@ Perl_sv_streq_flags(pTHX_ SV *sv1, SV *sv2, const U32 flags)
87328732
return sv_eq_flags(sv1, sv2, 0);
87338733
}
87348734

8735+
/*
8736+
=for apidoc sv_numcmp_common
8737+
8738+
Handles the common parts of the L<perlapi/sv_numeq>, sv_numne,
8739+
sv_numlt, sv_numle, sv_numge, sv_numgt, sv_numcmp APIs.
8740+
8741+
C<method> should be the C<*_amg> constant for the operator being
8742+
handled, such as C<eq_amg> for numeric equality.
8743+
8744+
C<flags> takes the same flags as the numeric comparison APIs.
8745+
8746+
This includes:
8747+
8748+
=over
8749+
8750+
=item *
8751+
8752+
treating possible NULL C<*sv1> and C<*sv2> arguments as undef.
8753+
8754+
=item *
8755+
8756+
calling get magic
8757+
8758+
=item *
8759+
8760+
handling the pain of overloading, including numericizing the SVs if
8761+
there is no numeric overload, but there is a numeric "0+" overload.
8762+
8763+
=back
8764+
8765+
If there is operator overloading this function will populate
8766+
C<*result> with the SV returned by the overloading and return true.
8767+
The caller will need to convert this to an integer for sv_numcmp() or
8768+
to bool for the rest of the APIs.
8769+
8770+
If there is no operator overloading, this function will return true.
8771+
Before returning it will convert C<*sv1> and C<*sv2> to numbers if
8772+
they are references so do_cmp() can be used safely.
8773+
8774+
=cut
8775+
*/
8776+
87358777
PERL_STATIC_INLINE bool
87368778
S_sv_numcmp_common(pTHX_ SV **sv1, SV **sv2, const U32 flags,
87378779
int method, SV **result) {

0 commit comments

Comments
 (0)