Skip to content

ext/com_dotnet: Use modern HashTable APIs #16208

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

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

Girgias
Copy link
Member

@Girgias Girgias commented Oct 3, 2024

I cannot test this locally, nor do I know if we have tests. But I have done a couple of these conversions and it looks correct to me.

@Girgias Girgias requested a review from cmb69 October 3, 2024 22:26
@Girgias Girgias marked this pull request as ready for review October 4, 2024 00:05
@cmb69
Copy link
Member

cmb69 commented Oct 8, 2024

Thank you for working on this; long overdue! However, this PR might open up a can of worms. :) I need to check that thoroughly.

@cmb69
Copy link
Member

cmb69 commented Oct 11, 2024

See #16309 and #16331 regarding the conflicts and new tests. I'll still need to fix method calling, and need to check php_com_wrapper_export_as_sink().

@Girgias
Copy link
Member Author

Girgias commented Oct 12, 2024

I'll let you work on the fixes :) Do ping me when you are done so that I can re-request a review after I fixed all the conflicts.

@Girgias Girgias force-pushed the com-hash-foreach branch 2 times, most recently from 362f64a to 215915e Compare February 8, 2025 21:49
@Girgias
Copy link
Member Author

Girgias commented Feb 8, 2025

@cmb69 I rebased on top of master, hopefully I didn't break anything.

Copy link
Member

@cmb69 cmb69 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've left comments regarding the changes to com_variant.c below.

I have not found out why two tests are failing due to the changes to com_wrapper.c (generate_dispids()). Can probably have a closer look this evening.

Regarding the changes to php_com_wrapper_export_as_sink(): I still haven't come around to understanding what this is about. Will try to catch up.

for (;; zend_hash_move_forward_ex(Z_ARRVAL_P(z), &pos)) {

keytype = zend_hash_get_current_key_ex(Z_ARRVAL_P(z), &strindex, &intindex, &pos);
if (!zend_array_is_list(ht)) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is now stricter as before, where arrays with holes could be passed. Since the old behavior doesn't make much sense (would then skip elements at the end), the change might be okay, but the test case would need to be updated.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll copy the similar function from f90323c

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That would solve the BC problem, but I'm not sure that's the best way forward.

"off" => [2 => 1, 1 => 2, 3],

NULL
int(2)
int(1)

I mean, that doesn't make sense. Might be better to require users to pass a proper list (can be checked upfront, or just pass array_values($my_arr)). At least for PHP 9, this should be done.

break;
}
uint32_t nb_values = zend_hash_num_elements(ht);
if (nb_values > UINT_MAX) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This appears to be superfluous, since UINT_MAX == UINT32_MAX for all supported platforms. (Actually, that should have been ULONG_MAX, but that doesn't make a difference on Windows.)

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.

2 participants