-
Notifications
You must be signed in to change notification settings - Fork 8k
ext/intl: migrate C code to C++ step 3. #19411
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
1ce1fe9
to
c615dc5
Compare
What's the actual reason for all of this? |
couple of reasons : |
It seems like it cought up from the https://unicode-org.github.io/icu-docs/apidoc/released/icu4c/ . It's just few things missing from that list. But if you really think it's worth the time and can bring some significant features / reduce number of bugs then I will leave it up to you. |
One thing to note is that it would be good to still keep it understandable for C developers and not try to introduce some C++ features just for the sake of it. I don't have personally have problem to understand C++ which I guess was the reason why the extension was written in really C way. |
That comment was more about type of changes in #19429 rather than this though. |
8693166
to
bd83367
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm getting a bunch of cc1plus: warning: command-line option ‘-Wstrict-prototypes’ is valid for C/ObjC but not for C++
warnings that need to be resolved. Building with GCC 15.1.1
DATE_FORMAT_METHOD_FETCH_OBJECT; | ||
|
||
loc = (char *)udat_getLocaleByType(DATE_FORMAT_OBJECT(dfo), loc_type,&INTL_DATA_ERROR_CODE(dfo)); | ||
loc = const_cast<char *>(udat_getLocaleByType(DATE_FORMAT_OBJECT(dfo), static_cast<ULocDataLocaleType>(loc_type),&INTL_DATA_ERROR_CODE(dfo))); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Icky! If you declare loc
as const char *
then you don't need this evil cast :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ah I misread the code I thought loc was part of the ZPP thing...right !
U_CFUNC PHP_FUNCTION( numfmt_get_attribute ) | ||
{ | ||
zend_long attribute, value; | ||
zend_long zattribute, value; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We typically use the z prefix for zvals, so maybe use the l prefix?
U_CFUNC PHP_FUNCTION( numfmt_get_text_attribute ) | ||
{ | ||
zend_long attribute; | ||
zend_long zattribute; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We typically use the z prefix for zvals, so maybe use the l prefix?
U_CFUNC PHP_FUNCTION( numfmt_set_attribute ) | ||
{ | ||
zend_long attribute; | ||
zend_long zattribute; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We typically use the z prefix for zvals, so maybe use the l prefix?
U_CFUNC PHP_FUNCTION( numfmt_get_symbol ) | ||
{ | ||
zend_long symbol; | ||
zend_long zsymbol; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We typically use the z prefix for zvals, so maybe use the l prefix?
U_CFUNC PHP_FUNCTION( numfmt_set_symbol ) | ||
{ | ||
zend_long symbol; | ||
zend_long zsymbol; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We typically use the z prefix for zvals, so maybe use the l prefix?
FORMATTER_METHOD_FETCH_OBJECT; | ||
|
||
loc = (char *)unum_getLocaleByType(FORMATTER_OBJECT(nfo), type, &INTL_DATA_ERROR_CODE(nfo)); | ||
loc = const_cast<char *>(unum_getLocaleByType(FORMATTER_OBJECT(nfo), static_cast<ULocDataLocaleType>(type), &INTL_DATA_ERROR_CODE(nfo))); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same const cast remark here: if you change the variable type then you don't need this const cast
bd83367
to
02373e3
Compare
No description provided.