Skip to content

Conversation

devnexen
Copy link
Member

@devnexen devnexen commented Aug 8, 2025

No description provided.

@devnexen devnexen force-pushed the intl_tocxx_3 branch 2 times, most recently from 1ce1fe9 to c615dc5 Compare August 8, 2025 07:40
@devnexen devnexen marked this pull request as ready for review August 8, 2025 08:20
@bukka
Copy link
Member

bukka commented Aug 9, 2025

What's the actual reason for all of this?

@devnexen
Copy link
Member Author

devnexen commented Aug 9, 2025

couple of reasons :
1/ icu C++ api is the main api, C wrappers versions of new features come later (when they do).
2/ mixing C++ with cumbersome procedural C makes the code more complicated (esp. memory management,e.g. zend mm and C++ objects, lesser chances of leaks).
3/ no more need to export C++ symbols as C.
4/ C++ has stronger typing, can be annoying again to mix with C "looseness".

@bukka
Copy link
Member

bukka commented Aug 9, 2025

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.

@bukka
Copy link
Member

bukka commented Aug 9, 2025

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.

@bukka
Copy link
Member

bukka commented Aug 9, 2025

That comment was more about type of changes in #19429 rather than this though.

@devnexen devnexen force-pushed the intl_tocxx_3 branch 2 times, most recently from 8693166 to bd83367 Compare October 4, 2025 06:25
@devnexen devnexen requested a review from nielsdos October 4, 2025 06:51
Copy link
Member

@nielsdos nielsdos left a 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)));
Copy link
Member

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 :)

Copy link
Member Author

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;
Copy link
Member

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;
Copy link
Member

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;
Copy link
Member

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;
Copy link
Member

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;
Copy link
Member

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)));
Copy link
Member

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

@devnexen devnexen merged commit 7f65512 into php:master Oct 11, 2025
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants