Skip to content
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

IDE documentation/stubs, updated and added examples mainly for Windows usage. #77

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

Conversation

TheTechsTech
Copy link

@TheTechsTech TheTechsTech commented Jan 9, 2020

  • added documentation for object return types with interfaces, functions, constants
  • added additional examples for using signals under windows
  • corrected example for windows usage, to get expected results while using uv_spawn
  • added example poll_sendfile.php, which reveal some functionality under windows not working,
    • the functions uv_fs_sendfile, uv_fs_write, and uv_write sending/writing to any uv stream/socket/fd client resource fails in pipe_bind_connect.php, pipe.php, poll.php, and tcp_bind.php

@bwoebi
Copy link
Member

bwoebi commented Jan 9, 2020

Hey,

cool that you're working on it - see it's WIP, but just a quick note at a first glance:

https://github.com/bwoebi/php-uv/blob/master/php_uv.c#L2626-L2676 is defining a lot of UV* named classes. There are no resourced returned by uv_* functions, only properly typed objects.

And the functions are operating on these objects then. (You can compare that with the code, where it's using UV_PARAM_OBJ() with the appropriate class reference.
These objects btw. have no methods.

The README is a little outdated in that regard...
But these stubs are cool and we can keep them up to date; much better than that unwieldy README.

Thanks for working on it!

@ghost
Copy link

ghost commented Jan 9, 2020

FYI: There are already uv stubs in PhpStorm. However these are wrong, since they say the functions return resources.

cc @WyriHaximus

@TheTechsTech
Copy link
Author

@bwoebi, As things currently stand, the readme show resources begin returned for all functions, which should be typed objects. The real reason for WIP, it need more interface like stubs for them, and i'm still testing out, seeing all this library functionality under windows. This extension much better than Event and Ev. It can even handle what Parallel offer.

@CharlotteDunois, My searching did not reveal PhpStorm stubs, otherwise might have not even started this, anyway it does not really document or as informative as what's listed on libuv.org website.

@WyriHaximus
Copy link
Contributor

@CharlotteDunois FYI I took the readme of this extension as the source for those stubs

@ghost
Copy link

ghost commented Jan 9, 2020

@WyriHaximus That's what I figured. But that doesn't make it correct. :D

@techno-express You should not think that libuv is a replacement for parallel. While libuv offers queueing work for a separate thread, there is no special handling being taken care of. I would not be surprised if specific things would simply segfault. Parallel is explicitely made for parallelism in PHP and takes special care of everything. If you need parallelism in PHP, use parallel and not the threading work API of libuv.

@TheTechsTech
Copy link
Author

@CharlotteDunois, maybe you can add some long overdue examples to Parallel repo.

From my programming background/schooling, I look at everything from an computer science perspective. It's just the concepts to me, and whether does it produce the results.

What is Parallel trying to achieve, how is it accomplish, how much effort is needed to get there, when is it needed?

Anyway, I did leave some comments there, krakjoe/parallel#59, krakjoe/parallel#25.

I read Parallel documentation, it's more wrapped up in the terminology from what I see, and that can be simply matched to what's presented in libuv. There are workarounds to everything, it's just the developers responsibility to find it.

Take the uv_spawn() example rewrite it using Parallel, much more work.

Parallel or parallelism have very limited uses, and can currently be accomplished using no external or third party extension.

@WyriHaximus
Copy link
Contributor

@CharlotteDunois agreed, I trusted the readme here to be correct. Maybe we can generate the stubs and readme from the ext source code to make them correct

…, psr-2 fixes

The `poll.php` example errors with PHP Warning:  fclose() expects parameter 1 to be resource, boolean given

The `tcp_bind.php` example does not work as expected, waits for a separate connect then does first parts and exit

The `spawn.php` example has the passed in environment array off by 1 on display
…ils on windows

the `pipe.php` example errors with PHP Warning:  uv_pipe_open(): invalid argument in

It seems all examples network relate stuff fails on windows. uv_fs_write, uv_write, both return false and negative status number
@TheTechsTech TheTechsTech changed the title PHP IDE documentation/stubs - WIP [WIP] IDE documentation/stubs, updated and added examples for mainly for Windows usage. Jan 16, 2020
@TheTechsTech TheTechsTech changed the title [WIP] IDE documentation/stubs, updated and added examples for mainly for Windows usage. [WIP] IDE documentation/stubs, updated and added examples mainly for Windows usage. Jan 16, 2020
@bwoebi
Copy link
Member

bwoebi commented Feb 15, 2020

I've updated the inline proto stubs within php_uv.c: e76ac0d (i.e. grep for {{{ proto)

These should reflect the current state accurately. And also directly mirror the callable signatures. Now the stubs could be updated to be really correct.

@TheTechsTech
Copy link
Author

I see, I believed I already had those types added. Look over whenever, I think i have most things covered.

Unless you have some corrections I need to be make, I'm mostly finish, some stuff mostly Windows I wanted to actually tests to report on.

@bwoebi
Copy link
Member

bwoebi commented Feb 15, 2020

At a quick glance it's not too bad, but there are still more than 10 signatures which still need improvement. I can check them out though in the next week.

TheTechsTech added a commit to symplely/spawn that referenced this pull request Apr 11, 2020
- update `uv_spawn` callback to just close all handles
- renamed function, allow to return results
- update readme about integration
- updated/added channnel class method to send kill to subprocess
- keep `libuv` doc/stubs in sync with [WIP] PR amphp/ext-uv#77
TheTechsTech added a commit to symplely/spawn that referenced this pull request Apr 18, 2020
TheTechsTech added a commit to symplely/spawn that referenced this pull request Apr 29, 2020
… only when result

- `triggerSuccess` should handle actual returned values, no last output
- keep `libuv` doc/stubs in sync with [WIP] PR amphp/ext-uv#77
@glickel
Copy link

glickel commented Jan 6, 2021

Hi, is there any news ? If you need help to finish this pull request, it would be a pleasure

@TheTechsTech
Copy link
Author

I figure it's mostly done, when started it was focused on the previous ext-uv version, might need double checking on some callback signature changes.

@glickel
Copy link

glickel commented Jan 29, 2021

@techno-express so you need some times to finish this pull request ? Or do you wait for @bwoebi to review ?

@TheTechsTech TheTechsTech changed the title [WIP] IDE documentation/stubs, updated and added examples mainly for Windows usage. IDE documentation/stubs, updated and added examples mainly for Windows usage. Jan 29, 2021
@TheTechsTech
Copy link
Author

No, the PR is finish, needs review and not up to me to merge.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

4 participants