Skip to content

Commit

Permalink
Merge pull request #321 from krakjoe/florian/namespace-php-methods
Browse files Browse the repository at this point in the history
Namespace PHP_METHODs to avoid collisions with ext-event
  • Loading branch information
realFlowControl authored Aug 23, 2024
2 parents 87e71d3 + 2eeaed5 commit 7882d53
Show file tree
Hide file tree
Showing 8 changed files with 71 additions and 70 deletions.
28 changes: 14 additions & 14 deletions src/channel.c
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ ZEND_BEGIN_ARG_INFO_EX(php_parallel_channel_construct_arginfo, 0, 0, 0)
ZEND_ARG_TYPE_INFO(0, capacity, IS_LONG, 0)
ZEND_END_ARG_INFO()

PHP_METHOD(Channel, __construct)
PHP_METHOD(Parallel_Channel, __construct)
{
php_parallel_channel_t *channel = php_parallel_channel_from(getThis());
zend_long capacity = -1;
Expand Down Expand Up @@ -131,7 +131,7 @@ ZEND_BEGIN_ARG_WITH_RETURN_OBJ_INFO_EX(php_parallel_channel_make_arginfo, 0, 1,
ZEND_ARG_TYPE_INFO(0, capacity, IS_LONG, 0)
ZEND_END_ARG_INFO()

PHP_METHOD(Channel, make)
PHP_METHOD(Parallel_Channel, make)
{
zend_string *name = NULL;
zend_bool buffered = 0;
Expand Down Expand Up @@ -174,7 +174,7 @@ ZEND_BEGIN_ARG_WITH_RETURN_OBJ_INFO_EX(php_parallel_channel_open_arginfo, 0, 1,
ZEND_ARG_TYPE_INFO(0, name, IS_STRING, 0)
ZEND_END_ARG_INFO()

PHP_METHOD(Channel, open)
PHP_METHOD(Parallel_Channel, open)
{
zend_string *name = NULL;
php_parallel_link_t *link;
Expand All @@ -201,7 +201,7 @@ ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(php_parallel_channel_send_arginfo, 0, 1,
ZEND_ARG_INFO(0, value)
ZEND_END_ARG_INFO()

PHP_METHOD(Channel, send)
PHP_METHOD(Parallel_Channel, send)
{
php_parallel_channel_t *channel = php_parallel_channel_from(getThis());
zval *value, *error;
Expand Down Expand Up @@ -233,7 +233,7 @@ PHP_METHOD(Channel, send)
ZEND_BEGIN_ARG_INFO_EX(php_parallel_channel_recv_arginfo, 0, 0, 0)
ZEND_END_ARG_INFO()

PHP_METHOD(Channel, recv)
PHP_METHOD(Parallel_Channel, recv)
{
php_parallel_channel_t *channel = php_parallel_channel_from(getThis());

Expand All @@ -251,7 +251,7 @@ PHP_METHOD(Channel, recv)
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(php_parallel_channel_close_arginfo, 0, 0, IS_VOID, 0)
ZEND_END_ARG_INFO()

PHP_METHOD(Channel, close)
PHP_METHOD(Parallel_Channel, close)
{
php_parallel_channel_t *channel = php_parallel_channel_from(getThis());

Expand All @@ -278,7 +278,7 @@ ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(php_parallel_channel___toString_arginfo,
#endif
ZEND_END_ARG_INFO()

PHP_METHOD(Channel, __toString)
PHP_METHOD(Parallel_Channel, __toString)
{
php_parallel_channel_t *channel =
php_parallel_channel_from(getThis());
Expand All @@ -287,13 +287,13 @@ PHP_METHOD(Channel, __toString)
}

zend_function_entry php_parallel_channel_methods[] = {
PHP_ME(Channel, __construct, php_parallel_channel_construct_arginfo, ZEND_ACC_PUBLIC)
PHP_ME(Channel, make, php_parallel_channel_make_arginfo, ZEND_ACC_PUBLIC|ZEND_ACC_STATIC)
PHP_ME(Channel, open, php_parallel_channel_open_arginfo, ZEND_ACC_PUBLIC|ZEND_ACC_STATIC)
PHP_ME(Channel, send, php_parallel_channel_send_arginfo, ZEND_ACC_PUBLIC)
PHP_ME(Channel, recv, php_parallel_channel_recv_arginfo, ZEND_ACC_PUBLIC)
PHP_ME(Channel, close, php_parallel_channel_close_arginfo, ZEND_ACC_PUBLIC)
PHP_ME(Channel, __toString, php_parallel_channel___toString_arginfo, ZEND_ACC_PUBLIC)
PHP_ME(Parallel_Channel, __construct, php_parallel_channel_construct_arginfo, ZEND_ACC_PUBLIC)
PHP_ME(Parallel_Channel, make, php_parallel_channel_make_arginfo, ZEND_ACC_PUBLIC|ZEND_ACC_STATIC)
PHP_ME(Parallel_Channel, open, php_parallel_channel_open_arginfo, ZEND_ACC_PUBLIC|ZEND_ACC_STATIC)
PHP_ME(Parallel_Channel, send, php_parallel_channel_send_arginfo, ZEND_ACC_PUBLIC)
PHP_ME(Parallel_Channel, recv, php_parallel_channel_recv_arginfo, ZEND_ACC_PUBLIC)
PHP_ME(Parallel_Channel, close, php_parallel_channel_close_arginfo, ZEND_ACC_PUBLIC)
PHP_ME(Parallel_Channel, __toString, php_parallel_channel___toString_arginfo, ZEND_ACC_PUBLIC)
PHP_FE_END
};

Expand Down
4 changes: 2 additions & 2 deletions src/event.c
Original file line number Diff line number Diff line change
Expand Up @@ -63,15 +63,15 @@ void php_parallel_events_event_construct(
zend_hash_del(&events->targets, source);
}

PHP_METHOD(Event, __construct)
PHP_METHOD(Parallel_Event, __construct)
{
php_parallel_exception_ex(
php_parallel_events_event_error_ce,
"construction of Events\\Event objects is not allowed");
}

zend_function_entry php_parallel_events_event_methods[] = {
PHP_ME(Event, __construct, php_parallel_no_args_arginfo, ZEND_ACC_PUBLIC)
PHP_ME(Parallel_Event, __construct, php_parallel_no_args_arginfo, ZEND_ACC_PUBLIC)
PHP_FE_END
};

Expand Down
36 changes: 18 additions & 18 deletions src/events.c
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(php_parallel_events_set_input_arginfo, 0
ZEND_ARG_OBJ_INFO(0, input, \\parallel\\Events\\Input, 0)
ZEND_END_ARG_INFO()

PHP_METHOD(Events, setInput)
PHP_METHOD(Parallel_Events, setInput)
{
php_parallel_events_t *events = php_parallel_events_from(getThis());
zval *input;
Expand All @@ -113,7 +113,7 @@ ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(php_parallel_events_add_channel_arginfo,
ZEND_ARG_OBJ_INFO(0, channel, \\parallel\\Channel, 0)
ZEND_END_ARG_INFO()

PHP_METHOD(Events, addChannel)
PHP_METHOD(Parallel_Events, addChannel)
{
php_parallel_events_t *events = php_parallel_events_from(getThis());
zval *target = NULL;
Expand All @@ -136,7 +136,7 @@ ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(php_parallel_events_add_future_arginfo,
ZEND_ARG_OBJ_INFO(0, future, \\parallel\\Future, 0)
ZEND_END_ARG_INFO()

PHP_METHOD(Events, addFuture)
PHP_METHOD(Parallel_Events, addFuture)
{
php_parallel_events_t *events = php_parallel_events_from(getThis());
zval *target = NULL;
Expand All @@ -160,7 +160,7 @@ ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(php_parallel_events_remove_arginfo, 0, 1
ZEND_ARG_TYPE_INFO(0, target, IS_STRING, 0)
ZEND_END_ARG_INFO()

PHP_METHOD(Events, remove)
PHP_METHOD(Parallel_Events, remove)
{
php_parallel_events_t *events = php_parallel_events_from(getThis());
zend_string *target = NULL;
Expand All @@ -181,7 +181,7 @@ ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(php_parallel_events_set_timeout_arginfo,
ZEND_ARG_TYPE_INFO(0, timeout, IS_LONG, 0)
ZEND_END_ARG_INFO()

PHP_METHOD(Events, setTimeout)
PHP_METHOD(Parallel_Events, setTimeout)
{
php_parallel_events_t *events = php_parallel_events_from(getThis());
zend_long timeout = -1;
Expand All @@ -204,7 +204,7 @@ ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(php_parallel_events_set_blocking_arginfo
ZEND_ARG_TYPE_INFO(0, blocking, _IS_BOOL, 0)
ZEND_END_ARG_INFO()

PHP_METHOD(Events, setBlocking)
PHP_METHOD(Parallel_Events, setBlocking)
{
php_parallel_events_t *events = php_parallel_events_from(getThis());
zend_bool blocking;
Expand All @@ -227,7 +227,7 @@ ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(php_parallel_events_set_blocker_arginfo,
ZEND_ARG_CALLABLE_INFO(0, blocker, 0)
ZEND_END_ARG_INFO()

PHP_METHOD(Events, setBlocker)
PHP_METHOD(Parallel_Events, setBlocker)
{
php_parallel_events_t *events = php_parallel_events_from(getThis());
zval *blocker = NULL;
Expand All @@ -253,7 +253,7 @@ PHP_METHOD(Events, setBlocker)
ZEND_BEGIN_ARG_WITH_RETURN_OBJ_INFO_EX(php_parallel_events_poll_arginfo, 0, 0, \\parallel\\Events\\Event, 1)
ZEND_END_ARG_INFO()

PHP_METHOD(Events, poll)
PHP_METHOD(Parallel_Events, poll)
{
php_parallel_events_t *events = php_parallel_events_from(getThis());

Expand All @@ -269,7 +269,7 @@ ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO(php_parallel_events_count_arginfo, IS_LONG,
#endif
ZEND_END_ARG_INFO()

PHP_METHOD(Events, count)
PHP_METHOD(Parallel_Events, count)
{
php_parallel_events_t *events = php_parallel_events_from(getThis());

Expand All @@ -279,15 +279,15 @@ PHP_METHOD(Events, count)
}

zend_function_entry php_parallel_events_methods[] = {
PHP_ME(Events, setInput, php_parallel_events_set_input_arginfo, ZEND_ACC_PUBLIC)
PHP_ME(Events, addChannel, php_parallel_events_add_channel_arginfo, ZEND_ACC_PUBLIC)
PHP_ME(Events, addFuture, php_parallel_events_add_future_arginfo, ZEND_ACC_PUBLIC)
PHP_ME(Events, remove, php_parallel_events_remove_arginfo, ZEND_ACC_PUBLIC)
PHP_ME(Events, setBlocking, php_parallel_events_set_blocking_arginfo, ZEND_ACC_PUBLIC)
PHP_ME(Events, setBlocker, php_parallel_events_set_blocker_arginfo, ZEND_ACC_PUBLIC)
PHP_ME(Events, setTimeout, php_parallel_events_set_timeout_arginfo, ZEND_ACC_PUBLIC)
PHP_ME(Events, poll, php_parallel_events_poll_arginfo, ZEND_ACC_PUBLIC)
PHP_ME(Events, count, php_parallel_events_count_arginfo, ZEND_ACC_PUBLIC)
PHP_ME(Parallel_Events, setInput, php_parallel_events_set_input_arginfo, ZEND_ACC_PUBLIC)
PHP_ME(Parallel_Events, addChannel, php_parallel_events_add_channel_arginfo, ZEND_ACC_PUBLIC)
PHP_ME(Parallel_Events, addFuture, php_parallel_events_add_future_arginfo, ZEND_ACC_PUBLIC)
PHP_ME(Parallel_Events, remove, php_parallel_events_remove_arginfo, ZEND_ACC_PUBLIC)
PHP_ME(Parallel_Events, setBlocking, php_parallel_events_set_blocking_arginfo, ZEND_ACC_PUBLIC)
PHP_ME(Parallel_Events, setBlocker, php_parallel_events_set_blocker_arginfo, ZEND_ACC_PUBLIC)
PHP_ME(Parallel_Events, setTimeout, php_parallel_events_set_timeout_arginfo, ZEND_ACC_PUBLIC)
PHP_ME(Parallel_Events, poll, php_parallel_events_poll_arginfo, ZEND_ACC_PUBLIC)
PHP_ME(Parallel_Events, count, php_parallel_events_count_arginfo, ZEND_ACC_PUBLIC)
PHP_FE_END
};

Expand Down
20 changes: 10 additions & 10 deletions src/future.c
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ zend_bool php_parallel_future_unlock(php_parallel_future_t *future) {
ZEND_BEGIN_ARG_INFO_EX(php_parallel_future_value_arginfo, 0, 0, 0)
ZEND_END_ARG_INFO()

PHP_METHOD(Future, value)
PHP_METHOD(Parallel_Future, value)
{
php_parallel_future_t *future = php_parallel_future_from(getThis());
int32_t state;
Expand Down Expand Up @@ -145,7 +145,7 @@ PHP_METHOD(Future, value)
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(php_parallel_future_cancel_arginfo, 0, 0, _IS_BOOL, 0)
ZEND_END_ARG_INFO()

PHP_METHOD(Future, cancel)
PHP_METHOD(Parallel_Future, cancel)
{
php_parallel_future_t *future =
php_parallel_future_from(getThis());
Expand All @@ -172,7 +172,7 @@ PHP_METHOD(Future, cancel)
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(php_parallel_future_cancelled_arginfo, 0, 0, _IS_BOOL, 0)
ZEND_END_ARG_INFO()

PHP_METHOD(Future, cancelled)
PHP_METHOD(Parallel_Future, cancelled)
{
php_parallel_future_t *future =
php_parallel_future_from(getThis());
Expand All @@ -185,7 +185,7 @@ PHP_METHOD(Future, cancelled)
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(php_parallel_future_done_arginfo, 0, 0, _IS_BOOL, 0)
ZEND_END_ARG_INFO()

PHP_METHOD(Future, done)
PHP_METHOD(Parallel_Future, done)
{
php_parallel_future_t *future =
php_parallel_future_from(getThis());
Expand All @@ -196,7 +196,7 @@ PHP_METHOD(Future, done)
ZEND_BEGIN_ARG_INFO_EX(php_parallel_future_construct_arginfo, 0, 0, 0)
ZEND_END_ARG_INFO()

PHP_METHOD(Future, __construct)
PHP_METHOD(Parallel_Future, __construct)
{
php_parallel_future_t *future = php_parallel_future_from(getThis());

Expand All @@ -208,11 +208,11 @@ PHP_METHOD(Future, __construct)
}

zend_function_entry php_parallel_future_methods[] = {
PHP_ME(Future, __construct, php_parallel_future_construct_arginfo, ZEND_ACC_PUBLIC)
PHP_ME(Future, value, php_parallel_future_value_arginfo, ZEND_ACC_PUBLIC)
PHP_ME(Future, done, php_parallel_future_done_arginfo, ZEND_ACC_PUBLIC)
PHP_ME(Future, cancel, php_parallel_future_cancel_arginfo, ZEND_ACC_PUBLIC)
PHP_ME(Future, cancelled, php_parallel_future_cancelled_arginfo, ZEND_ACC_PUBLIC)
PHP_ME(Parallel_Future, __construct, php_parallel_future_construct_arginfo, ZEND_ACC_PUBLIC)
PHP_ME(Parallel_Future, value, php_parallel_future_value_arginfo, ZEND_ACC_PUBLIC)
PHP_ME(Parallel_Future, done, php_parallel_future_done_arginfo, ZEND_ACC_PUBLIC)
PHP_ME(Parallel_Future, cancel, php_parallel_future_cancel_arginfo, ZEND_ACC_PUBLIC)
PHP_ME(Parallel_Future, cancelled, php_parallel_future_cancelled_arginfo, ZEND_ACC_PUBLIC)
PHP_FE_END
};

Expand Down
12 changes: 6 additions & 6 deletions src/input.c
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(php_parallel_events_input_add_arginfo, 0
ZEND_ARG_INFO(0, value)
ZEND_END_ARG_INFO()

PHP_METHOD(Input, add)
PHP_METHOD(Parallel_Input, add)
{
php_parallel_events_input_t *input =
php_parallel_events_input_from(getThis());
Expand Down Expand Up @@ -103,7 +103,7 @@ ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(php_parallel_events_input_remove_arginfo
ZEND_ARG_TYPE_INFO(0, target, IS_STRING, 0)
ZEND_END_ARG_INFO()

PHP_METHOD(Input, remove)
PHP_METHOD(Parallel_Input, remove)
{
php_parallel_events_input_t *input =
php_parallel_events_input_from(getThis());
Expand All @@ -124,7 +124,7 @@ PHP_METHOD(Input, remove)
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(php_parallel_events_input_clear_arginfo, 0, 0, IS_VOID, 0)
ZEND_END_ARG_INFO()

PHP_METHOD(Input, clear)
PHP_METHOD(Parallel_Input, clear)
{
php_parallel_events_input_t *input =
php_parallel_events_input_from(getThis());
Expand All @@ -135,9 +135,9 @@ PHP_METHOD(Input, clear)
}

zend_function_entry php_parallel_events_input_methods[] = {
PHP_ME(Input, add, php_parallel_events_input_add_arginfo, ZEND_ACC_PUBLIC)
PHP_ME(Input, remove, php_parallel_events_input_remove_arginfo, ZEND_ACC_PUBLIC)
PHP_ME(Input, clear, php_parallel_events_input_clear_arginfo, ZEND_ACC_PUBLIC)
PHP_ME(Parallel_Input, add, php_parallel_events_input_add_arginfo, ZEND_ACC_PUBLIC)
PHP_ME(Parallel_Input, remove, php_parallel_events_input_remove_arginfo, ZEND_ACC_PUBLIC)
PHP_ME(Parallel_Input, clear, php_parallel_events_input_clear_arginfo, ZEND_ACC_PUBLIC)
PHP_FE_END
};

Expand Down
16 changes: 8 additions & 8 deletions src/runtime.c
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ ZEND_BEGIN_ARG_INFO_EX(php_parallel_runtime_construct_arginfo, 0, 0, 0)
ZEND_ARG_TYPE_INFO(0, bootstrap, IS_STRING, 0)
ZEND_END_ARG_INFO()

PHP_METHOD(Runtime, __construct)
PHP_METHOD(Parallel_Runtime, __construct)
{
php_parallel_runtime_t *runtime = php_parallel_runtime_from(getThis());
zend_string *bootstrap = NULL;
Expand All @@ -64,7 +64,7 @@ ZEND_BEGIN_ARG_WITH_RETURN_OBJ_INFO_EX(php_parallel_runtime_run_arginfo, 0, 1, \
ZEND_ARG_TYPE_INFO(0, argv, IS_ARRAY, 0)
ZEND_END_ARG_INFO()

PHP_METHOD(Runtime, run)
PHP_METHOD(Parallel_Runtime, run)
{
php_parallel_runtime_t *runtime = php_parallel_runtime_from(getThis());
zval *closure = NULL;
Expand All @@ -89,7 +89,7 @@ PHP_METHOD(Runtime, run)
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(php_parallel_runtime_close_or_kill_arginfo, 0, 0, IS_VOID, 0)
ZEND_END_ARG_INFO()

PHP_METHOD(Runtime, close)
PHP_METHOD(Parallel_Runtime, close)
{
php_parallel_runtime_t *runtime =
php_parallel_runtime_from(getThis());
Expand All @@ -99,7 +99,7 @@ PHP_METHOD(Runtime, close)
php_parallel_scheduler_join(runtime, 0);
}

PHP_METHOD(Runtime, kill)
PHP_METHOD(Parallel_Runtime, kill)
{
php_parallel_runtime_t *runtime =
php_parallel_runtime_from(getThis());
Expand All @@ -110,10 +110,10 @@ PHP_METHOD(Runtime, kill)
}

zend_function_entry php_parallel_runtime_methods[] = {
PHP_ME(Runtime, __construct, php_parallel_runtime_construct_arginfo, ZEND_ACC_PUBLIC)
PHP_ME(Runtime, run, php_parallel_runtime_run_arginfo, ZEND_ACC_PUBLIC)
PHP_ME(Runtime, close, php_parallel_runtime_close_or_kill_arginfo, ZEND_ACC_PUBLIC)
PHP_ME(Runtime, kill, php_parallel_runtime_close_or_kill_arginfo, ZEND_ACC_PUBLIC)
PHP_ME(Parallel_Runtime, __construct, php_parallel_runtime_construct_arginfo, ZEND_ACC_PUBLIC)
PHP_ME(Parallel_Runtime, run, php_parallel_runtime_run_arginfo, ZEND_ACC_PUBLIC)
PHP_ME(Parallel_Runtime, close, php_parallel_runtime_close_or_kill_arginfo, ZEND_ACC_PUBLIC)
PHP_ME(Parallel_Runtime, kill, php_parallel_runtime_close_or_kill_arginfo, ZEND_ACC_PUBLIC)
PHP_FE_END
};

Expand Down
1 change: 1 addition & 0 deletions src/scheduler.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
#define HAVE_PARALLEL_SCHEDULER

#include "parallel.h"
#include "zend_types.h"

TSRM_TLS php_parallel_runtime_t* php_parallel_scheduler_context = NULL;
TSRM_TLS php_parallel_future_t* php_parallel_scheduler_future = NULL;
Expand Down
Loading

0 comments on commit 7882d53

Please sign in to comment.