Skip to content

Proposal: Rename FFI getFuncArg* to getFuncParameter*, $arg_index->$index #7236

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

Merged
merged 3 commits into from
Jul 14, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions ext/ffi/ffi.c
Original file line number Diff line number Diff line change
Expand Up @@ -4653,7 +4653,7 @@ ZEND_METHOD(FFI_CType, getStructFieldOffset) /* {{{ */

ptr = zend_hash_find_ptr(&type->record.fields, name);
if (!ptr) {
zend_throw_error(zend_ffi_exception_ce, "Wrong fileld name");
zend_throw_error(zend_ffi_exception_ce, "Wrong field name");
RETURN_THROWS();
}
RETURN_LONG(ptr->offset);
Expand All @@ -4680,7 +4680,7 @@ ZEND_METHOD(FFI_CType, getStructFieldType) /* {{{ */

ptr = zend_hash_find_ptr(&type->record.fields, name);
if (!ptr) {
zend_throw_error(zend_ffi_exception_ce, "Wrong fileld name");
zend_throw_error(zend_ffi_exception_ce, "Wrong field name");
RETURN_THROWS();
}

Expand Down Expand Up @@ -4730,7 +4730,7 @@ ZEND_METHOD(FFI_CType, getFuncReturnType) /* {{{ */
}
/* }}} */

ZEND_METHOD(FFI_CType, getFuncArgCount) /* {{{ */
ZEND_METHOD(FFI_CType, getFuncParameterCount) /* {{{ */
{
zend_ffi_ctype *ctype = (zend_ffi_ctype*)(Z_OBJ_P(ZEND_THIS));
zend_ffi_type *type;
Expand All @@ -4748,7 +4748,7 @@ ZEND_METHOD(FFI_CType, getFuncArgCount) /* {{{ */
}
/* }}} */

ZEND_METHOD(FFI_CType, getFuncArgType) /* {{{ */
ZEND_METHOD(FFI_CType, getFuncParameterType) /* {{{ */
{
zend_ffi_ctype *ctype = (zend_ffi_ctype*)(Z_OBJ_P(ZEND_THIS));
zend_ffi_type *type, *ptr;
Expand Down
4 changes: 2 additions & 2 deletions ext/ffi/ffi.stub.php
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,8 @@ public function getStructFieldType(string $field_name): CType {}

public function getFuncABI(): int {}
public function getFuncReturnType(): CType {}
public function getFuncArgCount(): int {}
public function getFuncArgType(int $arg_index): CType {}
public function getFuncParameterCount(): int {}
public function getFuncParameterType(int $index): CType {}
}

class Exception extends \Error {
Expand Down
16 changes: 8 additions & 8 deletions ext/ffi/ffi_arginfo.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* This is a generated file, edit the .stub.php file instead.
* Stub hash: bdfc4211d30630290aaf5046dd4ae72936982703 */
* Stub hash: 2675462a253edd2a0ea6106b9640f0d1a5a09489 */

ZEND_BEGIN_ARG_WITH_RETURN_OBJ_INFO_EX(arginfo_class_FFI_cdef, 0, 0, FFI, 0)
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, code, IS_STRING, 0, "\"\"")
Expand Down Expand Up @@ -115,10 +115,10 @@ ZEND_END_ARG_INFO()

#define arginfo_class_FFI_CType_getFuncReturnType arginfo_class_FFI_CType_getArrayElementType

#define arginfo_class_FFI_CType_getFuncArgCount arginfo_class_FFI_CType_getKind
#define arginfo_class_FFI_CType_getFuncParameterCount arginfo_class_FFI_CType_getKind

ZEND_BEGIN_ARG_WITH_RETURN_OBJ_INFO_EX(arginfo_class_FFI_CType_getFuncArgType, 0, 1, FFI\\CType, 0)
ZEND_ARG_TYPE_INFO(0, arg_index, IS_LONG, 0)
ZEND_BEGIN_ARG_WITH_RETURN_OBJ_INFO_EX(arginfo_class_FFI_CType_getFuncParameterType, 0, 1, FFI\\CType, 0)
ZEND_ARG_TYPE_INFO(0, index, IS_LONG, 0)
ZEND_END_ARG_INFO()


Expand Down Expand Up @@ -153,8 +153,8 @@ ZEND_METHOD(FFI_CType, getStructFieldOffset);
ZEND_METHOD(FFI_CType, getStructFieldType);
ZEND_METHOD(FFI_CType, getFuncABI);
ZEND_METHOD(FFI_CType, getFuncReturnType);
ZEND_METHOD(FFI_CType, getFuncArgCount);
ZEND_METHOD(FFI_CType, getFuncArgType);
ZEND_METHOD(FFI_CType, getFuncParameterCount);
ZEND_METHOD(FFI_CType, getFuncParameterType);


static const zend_function_entry class_FFI_methods[] = {
Expand Down Expand Up @@ -199,8 +199,8 @@ static const zend_function_entry class_FFI_CType_methods[] = {
ZEND_ME(FFI_CType, getStructFieldType, arginfo_class_FFI_CType_getStructFieldType, ZEND_ACC_PUBLIC)
ZEND_ME(FFI_CType, getFuncABI, arginfo_class_FFI_CType_getFuncABI, ZEND_ACC_PUBLIC)
ZEND_ME(FFI_CType, getFuncReturnType, arginfo_class_FFI_CType_getFuncReturnType, ZEND_ACC_PUBLIC)
ZEND_ME(FFI_CType, getFuncArgCount, arginfo_class_FFI_CType_getFuncArgCount, ZEND_ACC_PUBLIC)
ZEND_ME(FFI_CType, getFuncArgType, arginfo_class_FFI_CType_getFuncArgType, ZEND_ACC_PUBLIC)
ZEND_ME(FFI_CType, getFuncParameterCount, arginfo_class_FFI_CType_getFuncParameterCount, ZEND_ACC_PUBLIC)
ZEND_ME(FFI_CType, getFuncParameterType, arginfo_class_FFI_CType_getFuncParameterType, ZEND_ACC_PUBLIC)
ZEND_FE_END
};

Expand Down
6 changes: 3 additions & 3 deletions ext/ffi/tests/046.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,9 @@ $x = FFI::type("void (*)(double,int32_t)");
var_dump($x->getKind() === $x::TYPE_POINTER);
var_dump($x->getPointerType()->getKind() === $x::TYPE_FUNC);
var_dump($x->getPointerType()->getFuncReturnType()->getKind() === $x::TYPE_VOID);
var_dump($x->getPointerType()->getFuncArgCount());
var_dump($x->getPointerType()->getFuncArgType(0)->getKind() === $x::TYPE_DOUBLE);
var_dump($x->getPointerType()->getFuncArgType(1)->getKind() === $x::TYPE_SINT32);
var_dump($x->getPointerType()->getFuncParameterCount());
var_dump($x->getPointerType()->getFuncParameterType(0)->getKind() === $x::TYPE_DOUBLE);
var_dump($x->getPointerType()->getFuncParameterType(1)->getKind() === $x::TYPE_SINT32);
?>
--EXPECT--
bool(true)
Expand Down
2 changes: 1 addition & 1 deletion ext/ffi/tests/bug80847.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Bug #80847 (Nested structs)
ffi
--SKIPIF--
<?php
if (PHP_OS_FAMILY == 'Windows' && ((1 << 31) > 0)) die('xfail libffi doesn\'t properly support passing big strctures by value on Windows/64');
if (PHP_OS_FAMILY == 'Windows' && ((1 << 31) > 0)) die('xfail libffi doesn\'t properly support passing big structures by value on Windows/64');
?>
--FILE--
<?php
Expand Down