Skip to content

Commit

Permalink
Fix the signature of FFI::sizeof() and FFI::alignof()
Browse files Browse the repository at this point in the history
  • Loading branch information
kocsismate committed Dec 24, 2020
1 parent 34aefa3 commit ed19cb6
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 9 deletions.
4 changes: 2 additions & 2 deletions ext/ffi/ffi.c
Original file line number Diff line number Diff line change
Expand Up @@ -4165,7 +4165,7 @@ ZEND_METHOD(FFI, sizeof) /* {{{ */
type = ZEND_FFI_TYPE(ctype->type);
} else {
zend_wrong_parameter_class_error(1, "FFI\\CData or FFI\\CType", zv);
return;
RETURN_THROWS();
}

RETURN_LONG(type->size);
Expand All @@ -4191,7 +4191,7 @@ ZEND_METHOD(FFI, alignof) /* {{{ */
type = ZEND_FFI_TYPE(ctype->type);
} else {
zend_wrong_parameter_class_error(1, "FFI\\CData or FFI\\CType", zv);
return;
RETURN_THROWS();
}

RETURN_LONG(type->align);
Expand Down
14 changes: 10 additions & 4 deletions ext/ffi/ffi.stub.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,17 @@ public static function arrayType(FFI\CType $type, array $dimensions): ?FFI\CType
/** @prefer-ref $ptr */
public static function addr(FFI\CData $ptr): FFI\CData {}

/** @prefer-ref $ptr */
public static function sizeof(object $ptr): ?int {}
/**
* @param FFI\CData|FFI\CType $ptr
* @prefer-ref $ptr
*/
public static function sizeof($ptr): int {}

/** @prefer-ref $ptr */
public static function alignof(object $ptr): ?int {}
/**
* @param FFI\CData|FFI\CType $ptr
* @prefer-ref $ptr
*/
public static function alignof($ptr): int {}

/**
* @param FFI\CData|string $from
Expand Down
6 changes: 3 additions & 3 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: abd3bc186ae3f71f2b7eb1d47f3b6bab84fb2bda */
* Stub hash: f106049da816d8fef7bbfb40c5335245b57044e0 */

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 @@ -46,8 +46,8 @@ ZEND_BEGIN_ARG_WITH_RETURN_OBJ_INFO_EX(arginfo_class_FFI_addr, 0, 1, FFI\\CData,
ZEND_ARG_OBJ_INFO(ZEND_SEND_PREFER_REF, ptr, FFI\\CData, 0)
ZEND_END_ARG_INFO()

ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_FFI_sizeof, 0, 1, IS_LONG, 1)
ZEND_ARG_TYPE_INFO(ZEND_SEND_PREFER_REF, ptr, IS_OBJECT, 0)
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_FFI_sizeof, 0, 1, IS_LONG, 0)
ZEND_ARG_INFO(ZEND_SEND_PREFER_REF, ptr)
ZEND_END_ARG_INFO()

#define arginfo_class_FFI_alignof arginfo_class_FFI_sizeof
Expand Down

0 comments on commit ed19cb6

Please sign in to comment.