Skip to content

Commit

Permalink
Convert uv_to_utf8-type macros to inline functions
Browse files Browse the repository at this point in the history
This solves the problem of using mTHX pointed out in GH #22902
  • Loading branch information
khwilliamson committed Jan 19, 2025
1 parent bdc8044 commit 04e5548
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 22 deletions.
6 changes: 3 additions & 3 deletions embed.fnc
Original file line number Diff line number Diff line change
Expand Up @@ -3818,13 +3818,13 @@ Cp |U8 * |uvoffuni_to_utf8_flags_msgs \
|const UV flags \
|NULLOK HV **msgs

Admp |U8 * |uv_to_utf8 |NN U8 *d \
Adip |U8 * |uv_to_utf8 |NN U8 *d \
|UV uv
Admp |U8 * |uv_to_utf8_flags \
Adip |U8 * |uv_to_utf8_flags \
|NN U8 *d \
|UV uv \
|UV flags
Admp |U8 * |uv_to_utf8_msgs|NN U8 *d \
Adip |U8 * |uv_to_utf8_msgs|NN U8 *d \
|UV uv \
|UV flags \
|NULLOK HV **msgs
Expand Down
6 changes: 3 additions & 3 deletions embed.h
Original file line number Diff line number Diff line change
Expand Up @@ -875,9 +875,9 @@
# define utf8n_to_uvchr Perl_utf8n_to_uvchr
# define utf8n_to_uvchr_error Perl_utf8n_to_uvchr_error
# define utf8n_to_uvchr_msgs Perl_utf8n_to_uvchr_msgs
# define uv_to_utf8(a,b) Perl_uv_to_utf8(aTHX,a,b)
# define uv_to_utf8_flags(a,b,c) Perl_uv_to_utf8_flags(aTHX,a,b,c)
# define uv_to_utf8_msgs(a,b,c,d) Perl_uv_to_utf8_msgs(aTHX,a,b,c,d)
# define uv_to_utf8(a,b) Perl_uv_to_utf8(aTHX_ a,b)
# define uv_to_utf8_flags(a,b,c) Perl_uv_to_utf8_flags(aTHX_ a,b,c)
# define uv_to_utf8_msgs(a,b,c,d) Perl_uv_to_utf8_msgs(aTHX_ a,b,c,d)
# define uvchr_to_utf8(a,b) Perl_uvchr_to_utf8(aTHX,a,b)
# define uvchr_to_utf8_flags(a,b,c) Perl_uvchr_to_utf8_flags(aTHX,a,b,c)
# define uvchr_to_utf8_flags_msgs(a,b,c,d) Perl_uvchr_to_utf8_flags_msgs(aTHX,a,b,c,d)
Expand Down
18 changes: 18 additions & 0 deletions inline.h
Original file line number Diff line number Diff line change
Expand Up @@ -1231,6 +1231,24 @@ Perl_append_utf8_from_native_byte(const U8 byte, U8** dest)
}
}

PERL_STATIC_INLINE U8 *
Perl_uv_to_utf8(pTHX_ U8 *d, UV input_uv)
{
return uv_to_utf8_flags(d, input_uv, 0);
}

PERL_STATIC_INLINE U8 *
Perl_uv_to_utf8_flags(pTHX_ U8 *d, UV input_uv, UV flags)
{
return uv_to_utf8_msgs(d, input_uv, flags, NULL);
}

PERL_STATIC_INLINE U8 *
Perl_uv_to_utf8_msgs(pTHX_ U8 *d, UV input_uv, UV flags, HV** msgs)
{
return uvoffuni_to_utf8_flags_msgs(d, NATIVE_TO_UNI(input_uv), flags, msgs);
}

/*
=for apidoc valid_utf8_to_uvchr
Like C<L<perlapi/utf8_to_uvchr_buf>>, but should only be called when it is
Expand Down
24 changes: 15 additions & 9 deletions proto.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 0 additions & 7 deletions utf8.h
Original file line number Diff line number Diff line change
Expand Up @@ -142,13 +142,6 @@ typedef enum {
#define uvoffuni_to_utf8_flags(d,uv,flags) \
uvoffuni_to_utf8_flags_msgs(d, uv, flags, 0)

#define Perl_uv_to_utf8(mTHX, d, u) \
Perl_uv_to_utf8_flags(aTHX, d, u, 0)
#define Perl_uv_to_utf8_flags(mTHX, d, u, f) \
Perl_uv_to_utf8_msgs(aTHX, d, u, f, 0)
#define Perl_uv_to_utf8_msgs(mTHX, d, u, f , m) \
Perl_uvoffuni_to_utf8_flags_msgs(aTHX_ d, NATIVE_TO_UNI(u), f, m)

/* This is needed to cast the parameters for all those calls that had them
* improperly as chars */
#define utf8_to_uvchr_buf(s, e, lenp) \
Expand Down

0 comments on commit 04e5548

Please sign in to comment.