mirror of
https://github.com/danog/ext-uv.git
synced 2024-11-30 04:29:01 +01:00
update for libuv 1.0.0rc2, updated tests for api changes
This commit is contained in:
parent
84d7e09ce6
commit
1ea6c5aca4
26
php_uv.c
26
php_uv.c
@ -875,14 +875,14 @@ static void php_uv_fs_common(uv_fs_type fs_type, INTERNAL_FUNCTION_PARAMETERS)
|
||||
PHP_UV_FS_SETUP_AND_EXECUTE(open, path, flag, mode);
|
||||
break;
|
||||
}
|
||||
case UV_FS_READDIR:
|
||||
case UV_FS_SCANDIR:
|
||||
{
|
||||
char *path;
|
||||
int path_len = 0;
|
||||
long flags;
|
||||
|
||||
PHP_UV_FS_PARSE_PARAMETERS("zslf!", &zloop, &path, &path_len, &flags, &fci, &fcc);
|
||||
PHP_UV_FS_SETUP_AND_EXECUTE(readdir, path, flags);
|
||||
PHP_UV_FS_SETUP_AND_EXECUTE(scandir, path, flags);
|
||||
break;
|
||||
}
|
||||
case UV_FS_LSTAT:
|
||||
@ -1798,7 +1798,7 @@ static void php_uv_fs_cb(uv_fs_t* req)
|
||||
argc = 1;
|
||||
break;
|
||||
}
|
||||
case UV_FS_READDIR:
|
||||
case UV_FS_SCANDIR:
|
||||
{
|
||||
zval *dirent;
|
||||
int nnames, i = 0;
|
||||
@ -2133,7 +2133,7 @@ static void php_uv_idle_cb(uv_timer_t *handle)
|
||||
|
||||
params[0] = &idle;
|
||||
|
||||
php_uv_do_callback2(&retval_ptr, uv, params, 2, PHP_UV_IDLE_CB TSRMLS_CC);
|
||||
php_uv_do_callback2(&retval_ptr, uv, params, 1, PHP_UV_IDLE_CB TSRMLS_CC);
|
||||
|
||||
|
||||
if (retval_ptr != NULL) {
|
||||
@ -4839,6 +4839,7 @@ PHP_FUNCTION(uv_pipe_pending_count)
|
||||
{
|
||||
php_uv_t *uv;
|
||||
zval *handle;
|
||||
int count;
|
||||
|
||||
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC,
|
||||
"z",&handle) == FAILURE) {
|
||||
@ -4848,7 +4849,8 @@ PHP_FUNCTION(uv_pipe_pending_count)
|
||||
|
||||
PHP_UV_TYPE_CHECK(uv, IS_UV_PIPE);
|
||||
|
||||
uv_pipe_pending_count(&uv->uv.pipe);
|
||||
count = uv_pipe_pending_count(&uv->uv.pipe);
|
||||
RETURN_LONG(count);
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
@ -4858,6 +4860,7 @@ PHP_FUNCTION(uv_pipe_pending_type)
|
||||
{
|
||||
php_uv_t *uv;
|
||||
zval *handle;
|
||||
uv_handle_type ret;
|
||||
|
||||
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC,
|
||||
"z",&handle) == FAILURE) {
|
||||
@ -4867,7 +4870,8 @@ PHP_FUNCTION(uv_pipe_pending_type)
|
||||
|
||||
PHP_UV_TYPE_CHECK(uv, IS_UV_PIPE);
|
||||
|
||||
uv_pipe_pending_type(&uv->uv.pipe);
|
||||
ret = uv_pipe_pending_type(&uv->uv.pipe);
|
||||
RETURN_LONG(ret);
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
@ -5934,7 +5938,15 @@ PHP_FUNCTION(uv_fs_fstat)
|
||||
*/
|
||||
PHP_FUNCTION(uv_fs_readdir)
|
||||
{
|
||||
php_uv_fs_common(UV_FS_READDIR, INTERNAL_FUNCTION_PARAM_PASSTHRU);
|
||||
php_uv_fs_common(UV_FS_SCANDIR, INTERNAL_FUNCTION_PARAM_PASSTHRU);
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
/* {{{ proto uv_fs_scandir(resource $loop, string $path, long $flags, callable $callback)
|
||||
* */
|
||||
PHP_FUNCTION(uv_fs_scandir)
|
||||
{
|
||||
php_uv_fs_common(UV_FS_SCANDIR, INTERNAL_FUNCTION_PARAM_PASSTHRU);
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
|
@ -3,7 +3,7 @@ Check for uv_async
|
||||
--FILE--
|
||||
<?php
|
||||
$loop = uv_default_loop();
|
||||
$async = uv_async_init($loop, function($async, $status){
|
||||
$async = uv_async_init($loop, function($async){
|
||||
echo "Hello";
|
||||
uv_close($async);
|
||||
});
|
||||
|
@ -16,7 +16,7 @@ uv_idle_start($idle, function($stat) use (&$i, $idle, $loop){
|
||||
}
|
||||
});
|
||||
|
||||
uv_check_start($check, function($check, $status){
|
||||
uv_check_start($check, function($check){
|
||||
echo "Hello";
|
||||
uv_check_stop($check);
|
||||
});
|
||||
|
@ -5,7 +5,7 @@ Check for uv_prepare
|
||||
$loop = uv_default_loop();
|
||||
$prepare = uv_prepare_init($loop);
|
||||
|
||||
uv_prepare_start($prepare, function($rsc, $status){
|
||||
uv_prepare_start($prepare, function($rsc){
|
||||
echo "Hello";
|
||||
uv_unref($rsc);
|
||||
});
|
||||
|
@ -6,7 +6,7 @@ $loop = uv_default_loop();
|
||||
$timer = uv_timer_init();
|
||||
|
||||
$i = 0;
|
||||
uv_timer_start($timer, 10, 10, function($timer, $stat)
|
||||
uv_timer_start($timer, 10, 10, function($timer)
|
||||
use (&$i) {
|
||||
|
||||
echo "count: {$i}" . PHP_EOL;
|
||||
|
@ -5,13 +5,39 @@ Check for #14
|
||||
$loop = uv_default_loop();
|
||||
$filename ="does_not_exist.txt";
|
||||
uv_fs_stat($loop, $filename, function ($result, $stat) {
|
||||
echo $result . PHP_EOL;
|
||||
if($result < 0) {
|
||||
echo 'OK' . PHP_EOL;
|
||||
} else {
|
||||
echo 'FAILED: uv_fs_stat should have returned a value less than 0' . PHP_EOL;
|
||||
}
|
||||
|
||||
if (is_null($stat)) {
|
||||
echo "NULL" . PHP_EOL;
|
||||
} else {
|
||||
echo "FAILED: uv_fs_stat \$stat return value should be NULL" . PHP_EOL;
|
||||
}
|
||||
});
|
||||
|
||||
$filename = tempnam(sys_get_temp_dir(), 'test-no14');
|
||||
|
||||
uv_fs_stat($loop, $filename, function ($result, $stat) {
|
||||
if($result === 0) {
|
||||
echo 'OK' . PHP_EOL;
|
||||
} else {
|
||||
echo "FAILED: uv_fs_stat should have returned a result of 0" . PHP_EOL;
|
||||
}
|
||||
|
||||
if(!empty($stat)) {
|
||||
echo 'OK' . PHP_EOL;
|
||||
} else {
|
||||
echo 'FAILED: $stat should be an array with values' . PHP_EOL;
|
||||
}
|
||||
});
|
||||
|
||||
uv_run();
|
||||
|
||||
--EXPECT--
|
||||
-1
|
||||
OK
|
||||
NULL
|
||||
OK
|
||||
OK
|
||||
|
@ -19,7 +19,7 @@ uv_spawn(uv_default_loop(), "php", array('-r','echo "WORLD";'), $stdio, dirname(
|
||||
|
||||
}, $flags);
|
||||
|
||||
uv_read2_start($out, function($out, $nread, $buffer, $stat){
|
||||
uv_read_start($out, function($out, $nread, $buffer) {
|
||||
echo $buffer;
|
||||
|
||||
uv_close($out,function(){});
|
||||
|
@ -4,7 +4,12 @@ Check for uv_chdir
|
||||
<?php
|
||||
uv_chdir(); // don't SEGV
|
||||
|
||||
uv_chdir(dirname(__FILE__));
|
||||
if(uv_chdir(dirname(__FILE__))) {
|
||||
echo "OK\n";
|
||||
} else {
|
||||
echo "FAILED: expected uv_chdir to return true";
|
||||
}
|
||||
|
||||
if (uv_cwd() == dirname(__FILE__)) {
|
||||
echo "OK";
|
||||
} else {
|
||||
@ -15,3 +20,4 @@ if (uv_cwd() == dirname(__FILE__)) {
|
||||
|
||||
Warning: uv_chdir() expects exactly 1 parameter, 0 given in %s on line %d
|
||||
OK
|
||||
OK
|
||||
|
1
tests/fixtures/poll
vendored
Normal file
1
tests/fixtures/poll
vendored
Normal file
@ -0,0 +1 @@
|
||||
hoge
|
2
uv.c
2
uv.c
@ -190,7 +190,7 @@ static int php_uv_class_init(TSRMLS_D)
|
||||
zend_declare_class_constant_long(uv_class_entry, "HTTP_RESPONSE", sizeof("HTTP_RESPONSE")-1, HTTP_RESPONSE TSRMLS_CC);
|
||||
#endif
|
||||
|
||||
#define PHP_UV_ERRNO_GEN(code_notused, name, msg_notused) zend_declare_class_constant_long(uv_class_entry, #name, sizeof(#name)-1, UV_##name TSRMLS_CC);
|
||||
#define PHP_UV_ERRNO_GEN(name, msg_notused) zend_declare_class_constant_long(uv_class_entry, #name, sizeof(#name)-1, UV_##name TSRMLS_CC);
|
||||
UV_ERRNO_MAP(PHP_UV_ERRNO_GEN)
|
||||
#undef PHP_UV_ERRNO_GEN
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user