description about hook_process in WeeChat plugin API reference

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

description about hook_process in WeeChat plugin API reference

AYANOKOUZI, Ryuunosuke
Dear all,

Recently, 'hook_process' API function was updated[1]
and become possible to hook internal function also.

I have a question about C and Script (Python) API for 'hook_process'.

1. For C API case, If 'const char *command' is set "func:get_status",
   function 'get_status' is NEVER called by both parent and child process.
2. For Python API case, If 'command' is set "func:get_status",
   function 'get_status' IS called by child process.
Is my understanding correct?

[1] https://github.com/weechat/weechat/commit/51c3e0b9ec7ff5720d860168b7a5d60fb69226b8

I am awaiting your reply.

Sincerely yours,
Ryuunosuke Ayanokouzi
--
AYANOKOUZI, Ryuunosuke <[hidden email]>

_______________________________________________
Weechat-dev mailing list
[hidden email]
https://lists.nongnu.org/mailman/listinfo/weechat-dev

attachment0 (484 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: description about hook_process in WeeChat plugin API reference

Sébastien Helleu
On Sun, Apr 24, 2016 at 02:29:20AM +0900, AYANOKOUZI, Ryuunosuke wrote:

> Dear all,
>
> Recently, 'hook_process' API function was updated[1]
> and become possible to hook internal function also.
>
> I have a question about C and Script (Python) API for 'hook_process'.
>
> 1. For C API case, If 'const char *command' is set "func:get_status",
>    function 'get_status' is NEVER called by both parent and child process.
> 2. For Python API case, If 'command' is set "func:get_status",
>    function 'get_status' IS called by child process.
> Is my understanding correct?
>
> [1] https://github.com/weechat/weechat/commit/51c3e0b9ec7ff5720d860168b7a5d60fb69226b8
>
> I am awaiting your reply.
>
> Sincerely yours,
> Ryuunosuke Ayanokouzi
> --
> AYANOKOUZI, Ryuunosuke <[hidden email]>
Hi,

Yes, in C API, the callback (of hook_process) is called in the child process,
and then this callback can do anything with the command received (which is
"func:name"). So the function name is not really used (the callback can use it
if needed).

The behavior is different in scripting API, the callback is called too, and this
callback runs the function after "func:", so the callback is called only one
time in script, after the call to function in child.

--
Sébastien Helleu

web: weechat.org / flashtux.org
irc: FlashCode @ irc.freenode.net

_______________________________________________
Weechat-dev mailing list
[hidden email]
https://lists.nongnu.org/mailman/listinfo/weechat-dev

signature.asc (188 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: description about hook_process in WeeChat plugin API reference

AYANOKOUZI, Ryuunosuke
Dear Sébastien,

Thanks for your prompt response.

At Sat, 23 Apr 2016 20:56:55 +0200,
Sébastien Helleu wrote:

>
> On Sun, Apr 24, 2016 at 02:29:20AM +0900, AYANOKOUZI, Ryuunosuke wrote:
> >
> > I have a question about C and Script (Python) API for 'hook_process'.
> >
> > 1. For C API case, If 'const char *command' is set "func:get_status",
> >    function 'get_status' is NEVER called by both parent and child process.
> > 2. For Python API case, If 'command' is set "func:get_status",
> >    function 'get_status' IS called by child process.
> > Is my understanding correct?
> >
>
> Yes, in C API, the callback (of hook_process) is called in the child process,
> and then this callback can do anything with the command received (which is
> "func:name"). So the function name is not really used (the callback can use it
> if needed).
>
> The behavior is different in scripting API, the callback is called too, and this
> callback runs the function after "func:", so the callback is called only one
> time in script, after the call to function in child.
OK, I understand.

In that behavior,
explicitly specifying function name like "func:get_status" in C example
may drive people to expect that the function 'get_status' is called.
Just "func:" is better I think.

And the following sentence[1] may also drive people to expect that
the function "name" is executed independently from the code of callback
even for C API case.
I think the expression of a paragraph with the sentence should be reconsidered.

[1] The command can also be a function name with format:
    "func:name", to execute the function "name" (WeeChat ≥ 1.5).

Making difference between C API and scripting API clear,
It would be nice if explanation of the behavior of
forking process, executing function, and calling callback is mentioned.

I attached a patch for quick fix,
I would appreciate if you review and, if possible, commit it to your repository.

I am awaiting for your reply.

Sincerely yours,
Ryuunosuke Ayanokouzi
--
AYANOKOUZI, Ryuunosuke <[hidden email]>

_______________________________________________
Weechat-dev mailing list
[hidden email]
https://lists.nongnu.org/mailman/listinfo/weechat-dev

0002-doc-update-description-of-functions-in-hook_process.patch (5K) Download Attachment
attachment1 (484 bytes) Download Attachment