Lines Matching refs:type

74 	zend_ffi_type         *type;  member
120 zend_ffi_type *type; member
124 zend_ffi_type *type; member
144 zend_ffi_type *type; member
157 zend_ffi_type *type; member
193 zend_ffi_type *type; member
201 zend_ffi_type *type; member
221 static void _zend_ffi_type_dtor(zend_ffi_type *type);
224 static zend_ffi_type *zend_ffi_remember_type(zend_ffi_type *type);
227 static ZEND_COLD void zend_ffi_return_unsupported(zend_ffi_type *type);
228 static ZEND_COLD void zend_ffi_pass_unsupported(zend_ffi_type *type);
229 static ZEND_COLD void zend_ffi_assign_incompatible(zval *arg, zend_ffi_type *type);
233 static void *zend_ffi_create_callback(zend_ffi_type *type, zval *value);
236 static zend_always_inline void zend_ffi_type_dtor(zend_ffi_type *type) /* {{{ */ in zend_ffi_type_dtor() argument
238 if (UNEXPECTED(ZEND_FFI_TYPE_IS_OWNED(type))) { in zend_ffi_type_dtor()
239 _zend_ffi_type_dtor(type); in zend_ffi_type_dtor()
264 cdata->type = NULL; in zend_ffi_cdata_new()
324 dst_type = ZEND_FFI_TYPE(dst_type->pointer.type); in zend_ffi_is_compatible_type()
325 src_type = ZEND_FFI_TYPE(src_type->pointer.type); in zend_ffi_is_compatible_type()
336 dst_type = ZEND_FFI_TYPE(dst_type->array.type); in zend_ffi_is_compatible_type()
337 src_type = ZEND_FFI_TYPE(src_type->array.type); in zend_ffi_is_compatible_type()
343 dst_type = ZEND_FFI_TYPE(dst_type->pointer.type); in zend_ffi_is_compatible_type()
344 src_type = ZEND_FFI_TYPE(src_type->array.type); in zend_ffi_is_compatible_type()
356 static ffi_type* zend_ffi_face_struct_add_fields(ffi_type* t, zend_ffi_type *type, int *i, size_t s… in zend_ffi_face_struct_add_fields() argument
360 ZEND_HASH_MAP_FOREACH_PTR(&type->record.fields, field) { in zend_ffi_face_struct_add_fields()
361 switch (ZEND_FFI_TYPE(field->type)->kind) { in zend_ffi_face_struct_add_fields()
395 zend_ffi_type *field_type = ZEND_FFI_TYPE(field->type); in zend_ffi_face_struct_add_fields()
412 if (type->attr & ZEND_FFI_ATTR_UNION) { in zend_ffi_face_struct_add_fields()
420 static ffi_type *zend_ffi_make_fake_struct_type(zend_ffi_type *type) /* {{{ */ in zend_ffi_make_fake_struct_type() argument
423 uint32_t num_fields = !(type->attr & ZEND_FFI_ATTR_UNION) ? in zend_ffi_make_fake_struct_type()
424 zend_hash_num_elements(&type->record.fields) : 1; in zend_ffi_make_fake_struct_type()
429 t->size = type->size; in zend_ffi_make_fake_struct_type()
430 t->alignment = type->align; in zend_ffi_make_fake_struct_type()
431 t->type = FFI_TYPE_STRUCT; in zend_ffi_make_fake_struct_type()
434 t = zend_ffi_face_struct_add_fields(t, type, &i, size); in zend_ffi_make_fake_struct_type()
440 static ffi_type *zend_ffi_get_type(zend_ffi_type *type) /* {{{ */ in zend_ffi_get_type() argument
442 zend_ffi_type_kind kind = type->kind; in zend_ffi_get_type()
479 kind = type->enumeration.kind; in zend_ffi_get_type()
482 return zend_ffi_make_fake_struct_type(type); in zend_ffi_get_type()
490 static zend_never_inline zend_ffi_cdata *zend_ffi_cdata_to_zval_slow(void *ptr, zend_ffi_type *type in zend_ffi_cdata_to_zval_slow() argument
496 (type->kind < ZEND_FFI_TYPE_POINTER) ? in zend_ffi_cdata_to_zval_slow()
499 cdata->type = type; in zend_ffi_cdata_to_zval_slow()
506 …zend_ffi_cdata *zend_ffi_cdata_to_zval_slow_ptr(void *ptr, zend_ffi_type *type, zend_ffi_flags fla… in zend_ffi_cdata_to_zval_slow_ptr() argument
511 cdata->type = type; in zend_ffi_cdata_to_zval_slow_ptr()
519 …zend_ffi_cdata *zend_ffi_cdata_to_zval_slow_ret(void *ptr, zend_ffi_type *type, zend_ffi_flags fla… in zend_ffi_cdata_to_zval_slow_ret() argument
525 (type->kind < ZEND_FFI_TYPE_POINTER) ? in zend_ffi_cdata_to_zval_slow_ret()
528 cdata->type = type; in zend_ffi_cdata_to_zval_slow_ret()
530 if (type->kind == ZEND_FFI_TYPE_POINTER) { in zend_ffi_cdata_to_zval_slow_ret()
533 } else if (type->kind == ZEND_FFI_TYPE_STRUCT) { in zend_ffi_cdata_to_zval_slow_ret()
534 cdata->ptr = emalloc(type->size); in zend_ffi_cdata_to_zval_slow_ret()
536 memcpy(cdata->ptr, ptr, type->size); in zend_ffi_cdata_to_zval_slow_ret()
544 …d zend_ffi_cdata_to_zval(zend_ffi_cdata *cdata, void *ptr, zend_ffi_type *type, int read_type, zva… in zend_ffi_cdata_to_zval() argument
547 zend_ffi_type_kind kind = type->kind; in zend_ffi_cdata_to_zval()
593 kind = type->enumeration.kind; in zend_ffi_cdata_to_zval()
602 …} else if ((type->attr & ZEND_FFI_ATTR_CONST) && ZEND_FFI_TYPE(type->pointer.type)->kind == ZEND_F… in zend_ffi_cdata_to_zval()
608 cdata = zend_ffi_cdata_to_zval_slow_ret(ptr, type, flags); in zend_ffi_cdata_to_zval()
610 cdata = zend_ffi_cdata_to_zval_slow_ptr(ptr, type, flags); in zend_ffi_cdata_to_zval()
624 cdata = zend_ffi_cdata_to_zval_slow_ret(ptr, type, flags); in zend_ffi_cdata_to_zval()
626 cdata = zend_ffi_cdata_to_zval_slow(ptr, type, flags); in zend_ffi_cdata_to_zval()
680 if (ZEND_FFI_TYPE(field->type)->kind == ZEND_FFI_TYPE_CHAR in zend_ffi_bit_field_to_zval()
681 || ZEND_FFI_TYPE(field->type)->kind == ZEND_FFI_TYPE_SINT8 in zend_ffi_bit_field_to_zval()
682 || ZEND_FFI_TYPE(field->type)->kind == ZEND_FFI_TYPE_SINT16 in zend_ffi_bit_field_to_zval()
683 || ZEND_FFI_TYPE(field->type)->kind == ZEND_FFI_TYPE_SINT32 in zend_ffi_bit_field_to_zval()
684 || ZEND_FFI_TYPE(field->type)->kind == ZEND_FFI_TYPE_SINT64) { in zend_ffi_bit_field_to_zval()
736 static zend_always_inline zend_result zend_ffi_zval_to_cdata(void *ptr, zend_ffi_type *type, zval *… in zend_ffi_zval_to_cdata() argument
742 zend_ffi_type_kind kind = type->kind; in zend_ffi_zval_to_cdata()
747 if (zend_ffi_is_compatible_type(type, ZEND_FFI_TYPE(cdata->type)) && in zend_ffi_zval_to_cdata()
748 type->size == ZEND_FFI_TYPE(cdata->type)->size) { in zend_ffi_zval_to_cdata()
749 memcpy(ptr, cdata->ptr, type->size); in zend_ffi_zval_to_cdata()
810 zend_ffi_assign_incompatible(value, type); in zend_ffi_zval_to_cdata()
816 kind = type->enumeration.kind; in zend_ffi_zval_to_cdata()
825 if (zend_ffi_is_compatible_type(type, ZEND_FFI_TYPE(cdata->type))) { in zend_ffi_zval_to_cdata()
826 if (ZEND_FFI_TYPE(cdata->type)->kind == ZEND_FFI_TYPE_POINTER) { in zend_ffi_zval_to_cdata()
837 } else if (ZEND_FFI_TYPE(cdata->type)->kind != ZEND_FFI_TYPE_POINTER in zend_ffi_zval_to_cdata()
838 … && zend_ffi_is_compatible_type(ZEND_FFI_TYPE(type->pointer.type), ZEND_FFI_TYPE(cdata->type))) { in zend_ffi_zval_to_cdata()
847 } else if (ZEND_FFI_TYPE(type->pointer.type)->kind == ZEND_FFI_TYPE_FUNC) { in zend_ffi_zval_to_cdata()
848 void *callback = zend_ffi_create_callback(ZEND_FFI_TYPE(type->pointer.type), value); in zend_ffi_zval_to_cdata()
858 zend_ffi_assign_incompatible(value, type); in zend_ffi_zval_to_cdata()
864 zend_ffi_assign_incompatible(value, type); in zend_ffi_zval_to_cdata()
872 static size_t zend_ffi_arg_size(zend_ffi_type *type) /* {{{ */ in zend_ffi_arg_size() argument
877 ZEND_HASH_PACKED_FOREACH_PTR(type->func.args, arg_type) { in zend_ffi_arg_size()
885 …ys_inline zend_string *zend_ffi_mangled_func_name(zend_string *name, zend_ffi_type *type) /* {{{ */ in zend_ffi_mangled_func_name() argument
888 switch (type->func.abi) { in zend_ffi_mangled_func_name()
891 return strpprintf(0, "@%s@%zu", ZSTR_VAL(name), zend_ffi_arg_size(type)); in zend_ffi_mangled_func_name()
895 return strpprintf(0, "_%s@%zu", ZSTR_VAL(name), zend_ffi_arg_size(type)); in zend_ffi_mangled_func_name()
899 return strpprintf(0, "%s@@%zu", ZSTR_VAL(name), zend_ffi_arg_size(type)); in zend_ffi_mangled_func_name()
910 zend_ffi_type *type; member
928 if (callback_data->arg_types[i]->type == FFI_TYPE_STRUCT) { in zend_ffi_callback_hash_dtor()
932 if (callback_data->ret_type->type == FFI_TYPE_STRUCT) { in zend_ffi_callback_hash_dtor()
955 if (callback_data->type->func.args) { in zend_ffi_callback_trampoline()
959 ZEND_HASH_PACKED_FOREACH_PTR(callback_data->type->func.args, arg_type) { in zend_ffi_callback_trampoline()
984 ret_type = ZEND_FFI_TYPE(callback_data->type->func.ret_type); in zend_ffi_callback_trampoline()
993 static void *zend_ffi_create_callback(zend_ffi_type *type, zval *value) /* {{{ */ in zend_ffi_create_callback() argument
1002 if (type->attr & ZEND_FFI_ATTR_VARIADIC) { in zend_ffi_create_callback()
1012 arg_count = type->func.args ? zend_hash_num_elements(type->func.args) : 0; in zend_ffi_create_callback()
1026 callback_data->type = type; in zend_ffi_create_callback()
1031 if (type->func.args) { in zend_ffi_create_callback()
1035 ZEND_HASH_PACKED_FOREACH_PTR(type->func.args, arg_type) { in zend_ffi_create_callback()
1041 if (callback_data->arg_types[i]->type == FFI_TYPE_STRUCT) { in zend_ffi_create_callback()
1052 callback_data->ret_type = zend_ffi_get_type(ZEND_FFI_TYPE(type->func.ret_type)); in zend_ffi_create_callback()
1054 zend_ffi_return_unsupported(type->func.ret_type); in zend_ffi_create_callback()
1056 if (callback_data->arg_types[i]->type == FFI_TYPE_STRUCT) { in zend_ffi_create_callback()
1065 …if (ffi_prep_cif(&callback_data->cif, type->func.abi, callback_data->arg_count, callback_data->ret… in zend_ffi_create_callback()
1074 if (callback_data->arg_types[i]->type == FFI_TYPE_STRUCT) { in zend_ffi_create_callback()
1078 if (callback_data->ret_type->type == FFI_TYPE_STRUCT) { in zend_ffi_create_callback()
1104 zend_ffi_type *type = ZEND_FFI_TYPE(cdata->type); in zend_ffi_cdata_get() local
1118 zend_ffi_cdata_to_zval(cdata, cdata->ptr, type, BP_VAR_R, rv, 0, 0, 0); in zend_ffi_cdata_get()
1126 zend_ffi_type *type = ZEND_FFI_TYPE(cdata->type); in zend_ffi_cdata_set() local
1140 zend_ffi_zval_to_cdata(cdata->ptr, type, value); in zend_ffi_cdata_set()
1146 static zend_result zend_ffi_cdata_cast_object(zend_object *readobj, zval *writeobj, int type) /* {{… in zend_ffi_cdata_cast_object() argument
1148 if (type == IS_STRING) { in zend_ffi_cdata_cast_object()
1150 zend_ffi_type *ctype = ZEND_FFI_TYPE(cdata->type); in zend_ffi_cdata_cast_object()
1204 …} else if ((ctype->attr & ZEND_FFI_ATTR_CONST) && ZEND_FFI_TYPE(ctype->pointer.type)->kind == ZEND… in zend_ffi_cdata_cast_object()
1214 } else if (type == _IS_BOOL) { in zend_ffi_cdata_cast_object()
1226 zend_ffi_type *type = ZEND_FFI_TYPE(cdata->type); in zend_ffi_cdata_read_field() local
1230 if (cache_slot && *cache_slot == type) { in zend_ffi_cdata_read_field()
1233 if (type->kind == ZEND_FFI_TYPE_POINTER) { in zend_ffi_cdata_read_field()
1234 type = ZEND_FFI_TYPE(type->pointer.type); in zend_ffi_cdata_read_field()
1236 if (UNEXPECTED(type->kind != ZEND_FFI_TYPE_STRUCT)) { in zend_ffi_cdata_read_field()
1237 if (UNEXPECTED(type->kind != ZEND_FFI_TYPE_STRUCT)) { in zend_ffi_cdata_read_field()
1243 field = zend_hash_find_ptr(&type->record.fields, field_name); in zend_ffi_cdata_read_field()
1250 *cache_slot = type; in zend_ffi_cdata_read_field()
1255 if (ZEND_FFI_TYPE(cdata->type)->kind == ZEND_FFI_TYPE_POINTER) { in zend_ffi_cdata_read_field()
1266 type = ZEND_FFI_TYPE(type->pointer.type); in zend_ffi_cdata_read_field()
1277 zend_ffi_type *field_type = field->type; in zend_ffi_cdata_read_field()
1283 field->type = field_type = zend_ffi_remember_type(field_type); in zend_ffi_cdata_read_field()
1299 zend_ffi_type *type = ZEND_FFI_TYPE(cdata->type); in zend_ffi_cdata_write_field() local
1303 if (cache_slot && *cache_slot == type) { in zend_ffi_cdata_write_field()
1306 if (UNEXPECTED(type == NULL)) { in zend_ffi_cdata_write_field()
1310 if (type->kind == ZEND_FFI_TYPE_POINTER) { in zend_ffi_cdata_write_field()
1311 type = ZEND_FFI_TYPE(type->pointer.type); in zend_ffi_cdata_write_field()
1313 if (UNEXPECTED(type->kind != ZEND_FFI_TYPE_STRUCT)) { in zend_ffi_cdata_write_field()
1314 if (UNEXPECTED(type->kind != ZEND_FFI_TYPE_STRUCT)) { in zend_ffi_cdata_write_field()
1320 field = zend_hash_find_ptr(&type->record.fields, field_name); in zend_ffi_cdata_write_field()
1327 *cache_slot = type; in zend_ffi_cdata_write_field()
1332 if (ZEND_FFI_TYPE(cdata->type)->kind == ZEND_FFI_TYPE_POINTER) { in zend_ffi_cdata_write_field()
1362 zend_ffi_zval_to_cdata(ptr, ZEND_FFI_TYPE(field->type), value); in zend_ffi_cdata_write_field()
1373 zend_ffi_type *type = ZEND_FFI_TYPE(cdata->type); in zend_ffi_cdata_read_dim() local
1379 if (EXPECTED(type->kind == ZEND_FFI_TYPE_ARRAY)) { in zend_ffi_cdata_read_dim()
1380 if (UNEXPECTED((zend_ulong)(dim) >= (zend_ulong)type->array.length) in zend_ffi_cdata_read_dim()
1381 && (UNEXPECTED(dim < 0) || UNEXPECTED(type->array.length != 0))) { in zend_ffi_cdata_read_dim()
1386 …is_const = (cdata->flags & ZEND_FFI_FLAG_CONST) | (zend_ffi_flags)(type->attr & ZEND_FFI_ATTR_CONS… in zend_ffi_cdata_read_dim()
1388 dim_type = type->array.type; in zend_ffi_cdata_read_dim()
1393 type->array.type = dim_type = zend_ffi_remember_type(dim_type); in zend_ffi_cdata_read_dim()
1403 } else if (EXPECTED(type->kind == ZEND_FFI_TYPE_POINTER)) { in zend_ffi_cdata_read_dim()
1404 …is_const = (cdata->flags & ZEND_FFI_FLAG_CONST) | (zend_ffi_flags)(type->attr & ZEND_FFI_ATTR_CONS… in zend_ffi_cdata_read_dim()
1405 dim_type = type->pointer.type; in zend_ffi_cdata_read_dim()
1410 type->pointer.type = dim_type = zend_ffi_remember_type(dim_type); in zend_ffi_cdata_read_dim()
1431 zend_ffi_type *type = ZEND_FFI_TYPE(cdata->type); in zend_ffi_cdata_write_dim() local
1442 if (EXPECTED(type->kind == ZEND_FFI_TYPE_ARRAY)) { in zend_ffi_cdata_write_dim()
1443 if (UNEXPECTED((zend_ulong)(dim) >= (zend_ulong)type->array.length) in zend_ffi_cdata_write_dim()
1444 && (UNEXPECTED(dim < 0) || UNEXPECTED(type->array.length != 0))) { in zend_ffi_cdata_write_dim()
1449 …is_const = (cdata->flags & ZEND_FFI_FLAG_CONST) | (zend_ffi_flags)(type->attr & ZEND_FFI_ATTR_CONS… in zend_ffi_cdata_write_dim()
1450 type = ZEND_FFI_TYPE(type->array.type); in zend_ffi_cdata_write_dim()
1457 ptr = (void*)(((char*)cdata->ptr) + type->size * dim); in zend_ffi_cdata_write_dim()
1458 } else if (EXPECTED(type->kind == ZEND_FFI_TYPE_POINTER)) { in zend_ffi_cdata_write_dim()
1459 …is_const = (cdata->flags & ZEND_FFI_FLAG_CONST) | (zend_ffi_flags)(type->attr & ZEND_FFI_ATTR_CONS… in zend_ffi_cdata_write_dim()
1460 type = ZEND_FFI_TYPE(type->pointer.type); in zend_ffi_cdata_write_dim()
1465 ptr = (void*)((*(char**)cdata->ptr) + type->size * dim); in zend_ffi_cdata_write_dim()
1476 zend_ffi_zval_to_cdata(ptr, type, value); in zend_ffi_cdata_write_dim()
1509 static bool zend_ffi_ctype_name(zend_ffi_ctype_name_buf *buf, const zend_ffi_type *type) /* {{{ */ in zend_ffi_ctype_name() argument
1515 switch (type->kind) { in zend_ffi_ctype_name()
1555 if (type->enumeration.tag_name) { in zend_ffi_ctype_name()
1556 …zend_ffi_ctype_name_prepend(buf, ZSTR_VAL(type->enumeration.tag_name), ZSTR_LEN(type->enumeration.… in zend_ffi_ctype_name()
1573 type = ZEND_FFI_TYPE(type->pointer.type); in zend_ffi_ctype_name()
1587 type = ZEND_FFI_TYPE(type->func.ret_type); in zend_ffi_ctype_name()
1600 if (type->attr & ZEND_FFI_ATTR_VLA) { in zend_ffi_ctype_name()
1604 } else if (!(type->attr & ZEND_FFI_ATTR_INCOMPLETE_ARRAY)) { in zend_ffi_ctype_name()
1606 char *s = zend_print_long_to_buf(str + sizeof(str) - 1, type->array.length); in zend_ffi_ctype_name()
1615 type = ZEND_FFI_TYPE(type->array.type); in zend_ffi_ctype_name()
1618 if (type->attr & ZEND_FFI_ATTR_UNION) { in zend_ffi_ctype_name()
1619 if (type->record.tag_name) { in zend_ffi_ctype_name()
1620 …zend_ffi_ctype_name_prepend(buf, ZSTR_VAL(type->record.tag_name), ZSTR_LEN(type->record.tag_name)); in zend_ffi_ctype_name()
1626 if (type->record.tag_name) { in zend_ffi_ctype_name()
1627 …zend_ffi_ctype_name_prepend(buf, ZSTR_VAL(type->record.tag_name), ZSTR_LEN(type->record.tag_name)); in zend_ffi_ctype_name()
1651 static ZEND_COLD void zend_ffi_return_unsupported(zend_ffi_type *type) /* {{{ */ in zend_ffi_return_unsupported() argument
1653 type = ZEND_FFI_TYPE(type); in zend_ffi_return_unsupported()
1654 if (type->kind == ZEND_FFI_TYPE_STRUCT) { in zend_ffi_return_unsupported()
1656 } else if (type->kind == ZEND_FFI_TYPE_ARRAY) { in zend_ffi_return_unsupported()
1664 static ZEND_COLD void zend_ffi_pass_unsupported(zend_ffi_type *type) /* {{{ */ in zend_ffi_pass_unsupported() argument
1666 type = ZEND_FFI_TYPE(type); in zend_ffi_pass_unsupported()
1667 if (type->kind == ZEND_FFI_TYPE_STRUCT) { in zend_ffi_pass_unsupported()
1669 } else if (type->kind == ZEND_FFI_TYPE_ARRAY) { in zend_ffi_pass_unsupported()
1677 static ZEND_COLD void zend_ffi_pass_incompatible(zval *arg, zend_ffi_type *type, uint32_t n, zend_e… in zend_ffi_pass_incompatible() argument
1682 if (!zend_ffi_ctype_name(&buf1, type)) { in zend_ffi_pass_incompatible()
1689 type = ZEND_FFI_TYPE(cdata->type); in zend_ffi_pass_incompatible()
1691 if (!zend_ffi_ctype_name(&buf2, type)) { in zend_ffi_pass_incompatible()
1704 static ZEND_COLD void zend_ffi_assign_incompatible(zval *arg, zend_ffi_type *type) /* {{{ */ in zend_ffi_assign_incompatible() argument
1709 if (!zend_ffi_ctype_name(&buf1, type)) { in zend_ffi_assign_incompatible()
1716 type = ZEND_FFI_TYPE(cdata->type); in zend_ffi_assign_incompatible()
1718 if (!zend_ffi_ctype_name(&buf2, type)) { in zend_ffi_assign_incompatible()
1731 static zend_string *zend_ffi_get_class_name(zend_string *prefix, const zend_ffi_type *type) /* {{{ … in zend_ffi_get_class_name() argument
1736 if (!zend_ffi_ctype_name(&buf, type)) { in zend_ffi_get_class_name()
1749 return zend_ffi_get_class_name(zobj->ce->name, ZEND_FFI_TYPE(cdata->type)); in zend_ffi_cdata_get_class_name()
1759 zend_ffi_type *type1 = ZEND_FFI_TYPE(cdata1->type); in zend_ffi_cdata_compare_objects()
1760 zend_ffi_type *type2 = ZEND_FFI_TYPE(cdata2->type); in zend_ffi_cdata_compare_objects()
1781 zend_ffi_type *type = ZEND_FFI_TYPE(cdata->type); in zend_ffi_cdata_count_elements() local
1783 if (type->kind != ZEND_FFI_TYPE_ARRAY) { in zend_ffi_cdata_count_elements()
1787 *count = type->array.length; in zend_ffi_cdata_count_elements()
1801 if (ZEND_FFI_TYPE_IS_OWNED(base_cdata->type)) { in zend_ffi_add()
1805 base_cdata->type = base_type; in zend_ffi_add()
1808 base_cdata->type = base_type = zend_ffi_remember_type(base_type); in zend_ffi_add()
1812 cdata->type = base_type; in zend_ffi_add()
1814 ptr_type = ZEND_FFI_TYPE(base_type)->pointer.type; in zend_ffi_add()
1823 ptr_type = base_type->array.type; in zend_ffi_add()
1829 base_type->array.type = ptr_type; in zend_ffi_add()
1832 base_type->array.type = ptr_type = zend_ffi_remember_type(ptr_type); in zend_ffi_add()
1836 new_type->pointer.type = ptr_type; in zend_ffi_add()
1838 cdata->type = ZEND_FFI_TYPE_MAKE_OWNED(new_type); in zend_ffi_add()
1857 zend_ffi_type *type1 = ZEND_FFI_TYPE(cdata1->type); in zend_ffi_cdata_do_operation()
1870 zend_ffi_type *type2 = ZEND_FFI_TYPE(cdata2->type); in zend_ffi_cdata_do_operation()
1877 t1 = ZEND_FFI_TYPE(type1->pointer.type); in zend_ffi_cdata_do_operation()
1880 t1 = ZEND_FFI_TYPE(type1->array.type); in zend_ffi_cdata_do_operation()
1884 t2 = ZEND_FFI_TYPE(type2->pointer.type); in zend_ffi_cdata_do_operation()
1887 t2 = ZEND_FFI_TYPE(type2->array.type); in zend_ffi_cdata_do_operation()
1907 zend_ffi_type *type2 = ZEND_FFI_TYPE(cdata2->type); in zend_ffi_cdata_do_operation()
1940 zend_ffi_type *type = ZEND_FFI_TYPE(cdata->type); in zend_ffi_cdata_it_valid() local
1942 return (iter->key >= 0 && iter->key < type->array.length) ? SUCCESS : FAILURE; in zend_ffi_cdata_it_valid()
1950 zend_ffi_type *type = ZEND_FFI_TYPE(cdata->type); in zend_ffi_cdata_it_get_current_data() local
1958 dim_type = type->array.type; in zend_ffi_cdata_it_get_current_data()
1963 type->array.type = dim_type = zend_ffi_remember_type(dim_type); in zend_ffi_cdata_it_get_current_data()
1969 …_R, &iter->value, (cdata->flags & ZEND_FFI_FLAG_CONST) | (zend_ffi_flags)(type->attr & ZEND_FFI_AT… in zend_ffi_cdata_it_get_current_data()
2009 zend_ffi_type *type = ZEND_FFI_TYPE(cdata->type); in zend_ffi_cdata_get_iterator() local
2012 if (type->kind != ZEND_FFI_TYPE_ARRAY) { in zend_ffi_cdata_get_iterator()
2035 zend_ffi_type *type = ZEND_FFI_TYPE(cdata->type); in zend_ffi_cdata_get_debug_info() local
2048 switch (type->kind) { in zend_ffi_cdata_get_debug_info()
2067 zend_ffi_cdata_to_zval(cdata, ptr, type, BP_VAR_R, &tmp, ZEND_FFI_FLAG_CONST, 0, 0); in zend_ffi_cdata_get_debug_info()
2080 } else if (ZEND_FFI_TYPE(type->pointer.type)->kind == ZEND_FFI_TYPE_VOID) { in zend_ffi_cdata_get_debug_info()
2087 …zend_ffi_cdata_to_zval(NULL, *(void**)ptr, ZEND_FFI_TYPE(type->pointer.type), BP_VAR_R, &tmp, ZEND… in zend_ffi_cdata_get_debug_info()
2095 ht = zend_new_array(zend_hash_num_elements(&type->record.fields)); in zend_ffi_cdata_get_debug_info()
2096 ZEND_HASH_MAP_FOREACH_STR_KEY_PTR(&type->record.fields, key, f) { in zend_ffi_cdata_get_debug_info()
2100 …nd_ffi_cdata_to_zval(NULL, f_ptr, ZEND_FFI_TYPE(f->type), BP_VAR_R, &tmp, ZEND_FFI_FLAG_CONST, 0, in zend_ffi_cdata_get_debug_info()
2111 ht = zend_new_array(type->array.length); in zend_ffi_cdata_get_debug_info()
2112 for (n = 0; n < type->array.length; n++) { in zend_ffi_cdata_get_debug_info()
2113 …zend_ffi_cdata_to_zval(NULL, ptr, ZEND_FFI_TYPE(type->array.type), BP_VAR_R, &tmp, ZEND_FFI_FLAG_C… in zend_ffi_cdata_get_debug_info()
2115 ptr = (void*)(((char*)ptr) + ZEND_FFI_TYPE(type->array.type)->size); in zend_ffi_cdata_get_debug_info()
2136 zend_ffi_type *type = ZEND_FFI_TYPE(cdata->type); in zend_ffi_cdata_get_closure() local
2139 if (type->kind != ZEND_FFI_TYPE_POINTER) { in zend_ffi_cdata_get_closure()
2145 type = ZEND_FFI_TYPE(type->pointer.type); in zend_ffi_cdata_get_closure()
2146 if (type->kind != ZEND_FFI_TYPE_FUNC) { in zend_ffi_cdata_get_closure()
2164 func->type = ZEND_INTERNAL_FUNCTION; in zend_ffi_cdata_get_closure()
2172 func->common.required_num_args = type->func.args ? zend_hash_num_elements(type->func.args) : 0; in zend_ffi_cdata_get_closure()
2180 func->internal_function.reserved[0] = type; in zend_ffi_cdata_get_closure()
2199 ctype->type = NULL; in zend_ffi_ctype_new()
2209 zend_ffi_type_dtor(ctype->type); in zend_ffi_ctype_free_obj()
2226 type1 = ZEND_FFI_TYPE(type1->pointer.type); in zend_ffi_is_same_type()
2227 type2 = ZEND_FFI_TYPE(type2->pointer.type); in zend_ffi_is_same_type()
2234 type1 = ZEND_FFI_TYPE(type1->array.type); in zend_ffi_is_same_type()
2235 type2 = ZEND_FFI_TYPE(type2->array.type); in zend_ffi_is_same_type()
2251 return zend_ffi_get_class_name(zobj->ce->name, ZEND_FFI_TYPE(ctype->type)); in zend_ffi_ctype_get_class_name()
2261 zend_ffi_type *type1 = ZEND_FFI_TYPE(ctype1->type); in zend_ffi_ctype_compare_objects()
2262 zend_ffi_type *type2 = ZEND_FFI_TYPE(ctype2->type); in zend_ffi_ctype_compare_objects()
2298 static void _zend_ffi_type_dtor(zend_ffi_type *type) /* {{{ */ in _zend_ffi_type_dtor() argument
2300 type = ZEND_FFI_TYPE(type); in _zend_ffi_type_dtor()
2302 switch (type->kind) { in _zend_ffi_type_dtor()
2304 if (type->enumeration.tag_name) { in _zend_ffi_type_dtor()
2305 zend_string_release(type->enumeration.tag_name); in _zend_ffi_type_dtor()
2309 if (type->record.tag_name) { in _zend_ffi_type_dtor()
2310 zend_string_release(type->record.tag_name); in _zend_ffi_type_dtor()
2312 zend_hash_destroy(&type->record.fields); in _zend_ffi_type_dtor()
2315 zend_ffi_type_dtor(type->pointer.type); in _zend_ffi_type_dtor()
2318 zend_ffi_type_dtor(type->array.type); in _zend_ffi_type_dtor()
2321 if (type->func.args) { in _zend_ffi_type_dtor()
2322 zend_hash_destroy(type->func.args); in _zend_ffi_type_dtor()
2323 pefree(type->func.args, type->attr & ZEND_FFI_ATTR_PERSISTENT); in _zend_ffi_type_dtor()
2325 zend_ffi_type_dtor(type->func.ret_type); in _zend_ffi_type_dtor()
2330 pefree(type, type->attr & ZEND_FFI_ATTR_PERSISTENT); in _zend_ffi_type_dtor()
2336 zend_ffi_type *type = Z_PTR_P(zv); in zend_ffi_type_hash_dtor() local
2337 zend_ffi_type_dtor(type); in zend_ffi_type_hash_dtor()
2344 zend_ffi_type_dtor(field->type); in zend_ffi_field_hash_dtor()
2352 zend_ffi_type_dtor(field->type); in zend_ffi_field_hash_persistent_dtor()
2360 zend_ffi_type_dtor(sym->type); in zend_ffi_symbol_hash_dtor()
2368 zend_ffi_type_dtor(sym->type); in zend_ffi_symbol_hash_persistent_dtor()
2376 zend_ffi_type_dtor(tag->type); in zend_ffi_tag_hash_dtor()
2384 zend_ffi_type_dtor(tag->type); in zend_ffi_tag_hash_persistent_dtor()
2391 zend_ffi_type_dtor(cdata->type); in zend_ffi_cdata_dtor()
2461 zend_ffi_type *type = ZEND_FFI_TYPE(old_cdata->type); in zend_ffi_cdata_clone_obj() local
2465 if (type->kind < ZEND_FFI_TYPE_POINTER) { in zend_ffi_cdata_clone_obj()
2468 new_cdata->type = type; in zend_ffi_cdata_clone_obj()
2469 new_cdata->ptr = emalloc(type->size); in zend_ffi_cdata_clone_obj()
2470 memcpy(new_cdata->ptr, old_cdata->ptr, type->size); in zend_ffi_cdata_clone_obj()
2494 …zend_ffi_cdata_to_zval(NULL, sym->addr, ZEND_FFI_TYPE(sym->type), read_type, rv, (zend_ffi_flags)s… in zend_ffi_read_var()
2503 new_type->pointer.type = ZEND_FFI_TYPE(sym->type); in zend_ffi_read_var()
2507 cdata->type = ZEND_FFI_TYPE_MAKE_OWNED(new_type); in zend_ffi_read_var()
2541 zend_ffi_zval_to_cdata(sym->addr, ZEND_FFI_TYPE(sym->type), value); in zend_ffi_write_var()
2546 static zend_result zend_ffi_pass_arg(zval *arg, zend_ffi_type *type, ffi_type **pass_type, void **a… in zend_ffi_pass_arg() argument
2551 zend_ffi_type_kind kind = type->kind; in zend_ffi_pass_arg()
2620 && ((ZEND_FFI_TYPE(type->pointer.type)->kind == ZEND_FFI_TYPE_CHAR) in zend_ffi_pass_arg()
2621 || (ZEND_FFI_TYPE(type->pointer.type)->kind == ZEND_FFI_TYPE_VOID))) { in zend_ffi_pass_arg()
2627 if (zend_ffi_is_compatible_type(type, ZEND_FFI_TYPE(cdata->type))) { in zend_ffi_pass_arg()
2628 if (ZEND_FFI_TYPE(cdata->type)->kind == ZEND_FFI_TYPE_POINTER) { in zend_ffi_pass_arg()
2640 } else if (ZEND_FFI_TYPE(type->pointer.type)->kind == ZEND_FFI_TYPE_FUNC) { in zend_ffi_pass_arg()
2641 void *callback = zend_ffi_create_callback(ZEND_FFI_TYPE(type->pointer.type), arg); in zend_ffi_pass_arg()
2651 zend_ffi_pass_incompatible(arg, type, n, execute_data); in zend_ffi_pass_arg()
2662 zend_ffi_pass_incompatible(arg, type, n, execute_data); in zend_ffi_pass_arg()
2667 kind = type->enumeration.kind; in zend_ffi_pass_arg()
2673 if (zend_ffi_is_compatible_type(type, ZEND_FFI_TYPE(cdata->type))) { in zend_ffi_pass_arg()
2674 *pass_type = zend_ffi_make_fake_struct_type(type); in zend_ffi_pass_arg()
2679 zend_ffi_pass_incompatible(arg, type, n, execute_data); in zend_ffi_pass_arg()
2682 zend_ffi_pass_unsupported(type); in zend_ffi_pass_arg()
2725 zend_ffi_type *type = ZEND_FFI_TYPE(cdata->type); in zend_ffi_pass_var_arg() local
2727 return zend_ffi_pass_arg(arg, type, pass_type, arg_values, n, execute_data); in zend_ffi_pass_var_arg()
2740 zend_ffi_type *type = EX(func)->internal_function.reserved[0]; in ZEND_FUNCTION() local
2753 ZEND_ASSERT(type->kind == ZEND_FFI_TYPE_FUNC); in ZEND_FUNCTION()
2754 arg_count = type->func.args ? zend_hash_num_elements(type->func.args) : 0; in ZEND_FUNCTION()
2755 if (type->attr & ZEND_FFI_ATTR_VARIADIC) { in ZEND_FUNCTION()
2766 if (type->func.args) { in ZEND_FUNCTION()
2767 ZEND_HASH_PACKED_FOREACH_PTR(type->func.args, arg_type) { in ZEND_FUNCTION()
2787 ret_type = zend_ffi_get_type(ZEND_FFI_TYPE(type->func.ret_type)); in ZEND_FUNCTION()
2789 zend_ffi_return_unsupported(type->func.ret_type); in ZEND_FUNCTION()
2794 …if (ffi_prep_cif_var(&cif, type->func.abi, arg_count, EX_NUM_ARGS(), ret_type, arg_types) != FFI_O… in ZEND_FUNCTION()
2811 if (type->func.args) { in ZEND_FUNCTION()
2812 ZEND_HASH_PACKED_FOREACH_PTR(type->func.args, arg_type) { in ZEND_FUNCTION()
2824 ret_type = zend_ffi_get_type(ZEND_FFI_TYPE(type->func.ret_type)); in ZEND_FUNCTION()
2826 zend_ffi_return_unsupported(type->func.ret_type); in ZEND_FUNCTION()
2831 if (ffi_prep_cif(&cif, type->func.abi, arg_count, ret_type, arg_types) != FFI_OK) { in ZEND_FUNCTION()
2843 if (arg_types[n]->type == FFI_TYPE_STRUCT) { in ZEND_FUNCTION()
2847 if (ret_type->type == FFI_TYPE_STRUCT) { in ZEND_FUNCTION()
2856 if (ZEND_FFI_TYPE(type->func.ret_type)->kind != ZEND_FFI_TYPE_VOID) { in ZEND_FUNCTION()
2857 …zend_ffi_cdata_to_zval(NULL, ret, ZEND_FFI_TYPE(type->func.ret_type), BP_VAR_R, return_value, 0, 1… in ZEND_FUNCTION()
2877 zend_ffi_type *type; in zend_ffi_get_func() local
2909 type = ZEND_FFI_TYPE(sym->type); in zend_ffi_get_func()
2910 ZEND_ASSERT(type->kind == ZEND_FFI_TYPE_FUNC); in zend_ffi_get_func()
2917 func->common.type = ZEND_INTERNAL_FUNCTION; in zend_ffi_get_func()
2925 func->common.required_num_args = type->func.args ? zend_hash_num_elements(type->func.args) : 0; in zend_ffi_get_func()
2933 func->internal_function.reserved[0] = type; in zend_ffi_get_func()
3045 zend_string *mangled_name = zend_ffi_mangled_func_name(name, ZEND_FFI_TYPE(sym->type)); in ZEND_METHOD()
3071 static bool zend_ffi_same_types(zend_ffi_type *old, zend_ffi_type *type) /* {{{ */ in zend_ffi_same_types() argument
3073 if (old == type) { in zend_ffi_same_types()
3077 if (old->kind != type->kind in zend_ffi_same_types()
3078 || old->size != type->size in zend_ffi_same_types()
3079 || old->align != type->align in zend_ffi_same_types()
3080 || old->attr != type->attr) { in zend_ffi_same_types()
3086 return old->enumeration.kind == type->enumeration.kind; in zend_ffi_same_types()
3088 return old->array.length == type->array.length in zend_ffi_same_types()
3089 && zend_ffi_same_types(ZEND_FFI_TYPE(old->array.type), ZEND_FFI_TYPE(type->array.type)); in zend_ffi_same_types()
3091 return zend_ffi_same_types(ZEND_FFI_TYPE(old->pointer.type), ZEND_FFI_TYPE(type->pointer.type)); in zend_ffi_same_types()
3093 … if (zend_hash_num_elements(&old->record.fields) != zend_hash_num_elements(&type->record.fields)) { in zend_ffi_same_types()
3098 Bucket *b = type->record.fields.arData; in zend_ffi_same_types()
3118 || !zend_ffi_same_types(ZEND_FFI_TYPE(old_field->type), ZEND_FFI_TYPE(field->type))) { in zend_ffi_same_types()
3126 if (old->func.abi != type->func.abi in zend_ffi_same_types()
3127 …rgs ? zend_hash_num_elements(old->func.args) : 0) != (type->func.args ? zend_hash_num_elements(typ… in zend_ffi_same_types()
3128 … || !zend_ffi_same_types(ZEND_FFI_TYPE(old->func.ret_type), ZEND_FFI_TYPE(type->func.ret_type))) { in zend_ffi_same_types()
3132 zval *zv = type->func.args->arPacked; in zend_ffi_same_types()
3165 return zend_ffi_same_types(ZEND_FFI_TYPE(old->type), ZEND_FFI_TYPE(sym->type)); in zend_ffi_same_symbols()
3175 return zend_ffi_same_types(ZEND_FFI_TYPE(old->type), ZEND_FFI_TYPE(tag->type)); in zend_ffi_same_tags()
3179 static bool zend_ffi_subst_old_type(zend_ffi_type **dcl, zend_ffi_type *old, zend_ffi_type *type) /… in zend_ffi_subst_old_type() argument
3184 if (ZEND_FFI_TYPE(*dcl) == type) { in zend_ffi_subst_old_type()
3191 return zend_ffi_subst_old_type(&dcl_type->pointer.type, old, type); in zend_ffi_subst_old_type()
3193 return zend_ffi_subst_old_type(&dcl_type->array.type, old, type); in zend_ffi_subst_old_type()
3195 if (zend_ffi_subst_old_type(&dcl_type->func.ret_type, old, type)) { in zend_ffi_subst_old_type()
3202 if (zend_ffi_subst_old_type((zend_ffi_type**)&Z_PTR_P(zv), old, type)) { in zend_ffi_subst_old_type()
3210 if (zend_ffi_subst_old_type(&field->type, old, type)) { in zend_ffi_subst_old_type()
3221 static void zend_ffi_cleanup_type(zend_ffi_type *old, zend_ffi_type *type) /* {{{ */ in zend_ffi_cleanup_type() argument
3228 zend_ffi_subst_old_type(&sym->type, old, type); in zend_ffi_cleanup_type()
3233 zend_ffi_subst_old_type(&tag->type, old, type); in zend_ffi_cleanup_type()
3239 static zend_ffi_type *zend_ffi_remember_type(zend_ffi_type *type) /* {{{ */ in zend_ffi_remember_type() argument
3246 type->attr |= ZEND_FFI_ATTR_STORED; in zend_ffi_remember_type()
3247 zend_hash_next_index_insert_ptr(FFI_G(weak_types), ZEND_FFI_TYPE_MAKE_OWNED(type)); in zend_ffi_remember_type()
3248 return type; in zend_ffi_remember_type()
3382 zend_string *mangled_name = zend_ffi_mangled_func_name(name, ZEND_FFI_TYPE(sym->type)); in zend_ffi_load()
3404 if (ZEND_FFI_TYPE_IS_OWNED(sym->type) in zend_ffi_load()
3405 && ZEND_FFI_TYPE(old_sym->type) != ZEND_FFI_TYPE(sym->type)) { in zend_ffi_load()
3406 zend_ffi_type *type = ZEND_FFI_TYPE(sym->type); in zend_ffi_load() local
3407 zend_ffi_cleanup_type(ZEND_FFI_TYPE(old_sym->type), ZEND_FFI_TYPE(type)); in zend_ffi_load()
3408 zend_ffi_type_dtor(type); in zend_ffi_load()
3429 if (ZEND_FFI_TYPE_IS_OWNED(tag->type) in zend_ffi_load()
3430 && ZEND_FFI_TYPE(old_tag->type) != ZEND_FFI_TYPE(tag->type)) { in zend_ffi_load()
3431 zend_ffi_type *type = ZEND_FFI_TYPE(tag->type); in zend_ffi_load() local
3432 zend_ffi_cleanup_type(ZEND_FFI_TYPE(old_tag->type), ZEND_FFI_TYPE(type)); in zend_ffi_load()
3433 zend_ffi_type_dtor(type); in zend_ffi_load()
3465 zend_ffi_type_dtor(sym->type); in zend_ffi_load()
3480 zend_ffi_type_dtor(tag->type); in zend_ffi_load()
3585 zend_ffi_type_dtor(dcl->type); in zend_ffi_cleanup_dcl()
3586 dcl->type = NULL; in zend_ffi_cleanup_dcl()
3610 static zend_result zend_ffi_validate_vla(zend_ffi_type *type) /* {{{ */ in zend_ffi_validate_vla() argument
3612 if (!FFI_G(allow_vla) && (type->attr & ZEND_FFI_ATTR_VLA)) { in zend_ffi_validate_vla()
3620 static zend_result zend_ffi_validate_incomplete_type(zend_ffi_type *type, bool allow_incomplete_tag… in zend_ffi_validate_incomplete_type() argument
3622 if (!allow_incomplete_tag && (type->attr & ZEND_FFI_ATTR_INCOMPLETE_TAG)) { in zend_ffi_validate_incomplete_type()
3628 if (ZEND_FFI_TYPE(tag->type) == type) { in zend_ffi_validate_incomplete_type()
3629 if (type->kind == ZEND_FFI_TYPE_ENUM) { in zend_ffi_validate_incomplete_type()
3631 } else if (type->attr & ZEND_FFI_ATTR_UNION) { in zend_ffi_validate_incomplete_type()
3645 if (type == ZEND_FFI_TYPE(sym->type)) { in zend_ffi_validate_incomplete_type()
3653 } else if (!allow_incomplete_array && (type->attr & ZEND_FFI_ATTR_INCOMPLETE_ARRAY)) { in zend_ffi_validate_incomplete_type()
3656 } else if (!FFI_G(allow_vla) && (type->attr & ZEND_FFI_ATTR_VLA)) { in zend_ffi_validate_incomplete_type()
3664 static zend_result zend_ffi_validate_type(zend_ffi_type *type, bool allow_incomplete_tag, bool allo… in zend_ffi_validate_type() argument
3666 if (type->kind == ZEND_FFI_TYPE_VOID) { in zend_ffi_validate_type()
3670 return zend_ffi_validate_incomplete_type(type, allow_incomplete_tag, allow_incomplete_array); in zend_ffi_validate_type()
3674 static zend_result zend_ffi_validate_var_type(zend_ffi_type *type, bool allow_incomplete_array) /* … in zend_ffi_validate_var_type() argument
3676 if (type->kind == ZEND_FFI_TYPE_FUNC) { in zend_ffi_validate_var_type()
3680 return zend_ffi_validate_type(type, 0, allow_incomplete_array); in zend_ffi_validate_var_type()
3687 if (zend_ffi_validate_var_type(ZEND_FFI_TYPE(dcl->type), 0) == FAILURE) { in zend_ffi_validate_type_name()
3694 static bool zend_ffi_subst_type(zend_ffi_type **dcl, zend_ffi_type *type) /* {{{ */ in zend_ffi_subst_type() argument
3699 if (*dcl == type) { in zend_ffi_subst_type()
3700 *dcl = ZEND_FFI_TYPE_MAKE_OWNED(type); in zend_ffi_subst_type()
3706 return zend_ffi_subst_type(&dcl_type->pointer.type, type); in zend_ffi_subst_type()
3708 return zend_ffi_subst_type(&dcl_type->array.type, type); in zend_ffi_subst_type()
3710 if (zend_ffi_subst_type(&dcl_type->func.ret_type, type)) { in zend_ffi_subst_type()
3717 if (zend_ffi_subst_type((zend_ffi_type**)&Z_PTR_P(zv), type)) { in zend_ffi_subst_type()
3725 if (zend_ffi_subst_type(&field->type, type)) { in zend_ffi_subst_type()
3740 if (ZEND_FFI_TYPE_IS_OWNED(tag->type)) { in zend_ffi_tags_cleanup()
3741 zend_ffi_type *type = ZEND_FFI_TYPE(tag->type); in zend_ffi_tags_cleanup() local
3742 zend_ffi_subst_type(&dcl->type, type); in zend_ffi_tags_cleanup()
3743 tag->type = type; in zend_ffi_tags_cleanup()
3755 zend_ffi_type *type, *type_ptr; in ZEND_METHOD() local
3804 zend_ffi_type_dtor(dcl.type); in ZEND_METHOD()
3818 type = ZEND_FFI_TYPE(dcl.type); in ZEND_METHOD()
3834 type_ptr = dcl.type; in ZEND_METHOD()
3838 type_ptr = type = ctype->type; in ZEND_METHOD()
3839 if (ZEND_FFI_TYPE_IS_OWNED(type)) { in ZEND_METHOD()
3840 type = ZEND_FFI_TYPE(type); in ZEND_METHOD()
3841 if (!(type->attr & ZEND_FFI_ATTR_STORED)) { in ZEND_METHOD()
3844 ctype->type = type; in ZEND_METHOD()
3846 ctype->type = type_ptr = type = zend_ffi_remember_type(type); in ZEND_METHOD()
3852 if (type->size == 0) { in ZEND_METHOD()
3858 ptr = pemalloc(type->size, flags & ZEND_FFI_FLAG_PERSISTENT); in ZEND_METHOD()
3859 memset(ptr, 0, type->size); in ZEND_METHOD()
3862 if (type->kind < ZEND_FFI_TYPE_POINTER) { in ZEND_METHOD()
3865 cdata->type = type_ptr; in ZEND_METHOD()
3888 if (ZEND_FFI_TYPE(cdata->type)->kind == ZEND_FFI_TYPE_POINTER) { in ZEND_METHOD()
3914 zend_ffi_type *old_type, *type, *type_ptr; in ZEND_METHOD() local
3954 zend_ffi_type_dtor(dcl.type); in ZEND_METHOD()
3968 type = ZEND_FFI_TYPE(dcl.type); in ZEND_METHOD()
3984 type_ptr = dcl.type; in ZEND_METHOD()
3988 type_ptr = type = ctype->type; in ZEND_METHOD()
3989 if (ZEND_FFI_TYPE_IS_OWNED(type)) { in ZEND_METHOD()
3990 type = ZEND_FFI_TYPE(type); in ZEND_METHOD()
3991 if (!(type->attr & ZEND_FFI_ATTR_STORED)) { in ZEND_METHOD()
3994 ctype->type = type; in ZEND_METHOD()
3996 ctype->type = type_ptr = type = zend_ffi_remember_type(type); in ZEND_METHOD()
4003 if (type->kind < ZEND_FFI_TYPE_POINTER && Z_TYPE_P(zv) < IS_STRING) { in ZEND_METHOD()
4007 cdata->type = type_ptr; in ZEND_METHOD()
4008 cdata->ptr = emalloc(type->size); in ZEND_METHOD()
4009 zend_ffi_zval_to_cdata(cdata->ptr, type, zv); in ZEND_METHOD()
4015 } else if (type->kind == ZEND_FFI_TYPE_POINTER && Z_TYPE_P(zv) == IS_LONG) { in ZEND_METHOD()
4018 cdata->type = type_ptr; in ZEND_METHOD()
4025 } else if (type->kind == ZEND_FFI_TYPE_POINTER && Z_TYPE_P(zv) == IS_NULL) { in ZEND_METHOD()
4028 cdata->type = type_ptr; in ZEND_METHOD()
4042 old_type = ZEND_FFI_TYPE(old_cdata->type); in ZEND_METHOD()
4046 if (type->kind < ZEND_FFI_TYPE_POINTER) { in ZEND_METHOD()
4049 cdata->type = type_ptr; in ZEND_METHOD()
4052 && type->kind != ZEND_FFI_TYPE_POINTER in ZEND_METHOD()
4053 && ZEND_FFI_TYPE(old_type->pointer.type)->kind == ZEND_FFI_TYPE_VOID) { in ZEND_METHOD()
4057 && type->kind == ZEND_FFI_TYPE_POINTER in ZEND_METHOD()
4058 …end_ffi_is_compatible_type(ZEND_FFI_TYPE(old_type->array.type), ZEND_FFI_TYPE(type->pointer.type))… in ZEND_METHOD()
4062 && type->kind == ZEND_FFI_TYPE_ARRAY in ZEND_METHOD()
4063 …nd_ffi_is_compatible_type(ZEND_FFI_TYPE(old_type->pointer.type), ZEND_FFI_TYPE(type->array.type)))… in ZEND_METHOD()
4065 } else if (type->size > old_type->size) { in ZEND_METHOD()
4093 ZEND_METHOD(FFI, type) /* {{{ */ in ZEND_METHOD() argument
4126 zend_ffi_type_dtor(dcl.type); in ZEND_METHOD()
4152 ctype->type = dcl.type; in ZEND_METHOD()
4162 zend_ffi_type *type; in ZEND_METHOD() local
4174 type = cdata->type; in ZEND_METHOD()
4175 if (ZEND_FFI_TYPE_IS_OWNED(type)) { in ZEND_METHOD()
4176 type = ZEND_FFI_TYPE(type); in ZEND_METHOD()
4177 if (!(type->attr & ZEND_FFI_ATTR_STORED)) { in ZEND_METHOD()
4180 cdata->type = type; in ZEND_METHOD()
4181 type = ZEND_FFI_TYPE_MAKE_OWNED(type); in ZEND_METHOD()
4183 cdata->type = type = zend_ffi_remember_type(type); in ZEND_METHOD()
4193 ctype->type = type; in ZEND_METHOD()
4203 zend_ffi_type *type; in ZEND_METHOD() local
4214 type = ZEND_FFI_TYPE(ctype->type); in ZEND_METHOD()
4216 if (type->kind == ZEND_FFI_TYPE_FUNC) { in ZEND_METHOD()
4219 } else if (type->kind == ZEND_FFI_TYPE_ARRAY && (type->attr & ZEND_FFI_ATTR_INCOMPLETE_ARRAY)) { in ZEND_METHOD()
4222 } else if (type->kind == ZEND_FFI_TYPE_VOID) { in ZEND_METHOD()
4225 } else if (type->attr & ZEND_FFI_ATTR_INCOMPLETE_TAG) { in ZEND_METHOD()
4230 if (ZEND_FFI_TYPE_IS_OWNED(ctype->type)) { in ZEND_METHOD()
4231 if (!(type->attr & ZEND_FFI_ATTR_STORED)) { in ZEND_METHOD()
4234 ctype->type = type; in ZEND_METHOD()
4235 type = ZEND_FFI_TYPE_MAKE_OWNED(type); in ZEND_METHOD()
4237 ctype->type = type = zend_ffi_remember_type(type); in ZEND_METHOD()
4248 zend_ffi_type_dtor(type); in ZEND_METHOD()
4250 …} else if (ZEND_FFI_TYPE(type)->kind == ZEND_FFI_TYPE_ARRAY && (ZEND_FFI_TYPE(type)->attr & ZEND_F… in ZEND_METHOD()
4252 zend_ffi_type_dtor(type); in ZEND_METHOD()
4259 new_type->size = n * ZEND_FFI_TYPE(type)->size; in ZEND_METHOD()
4260 new_type->align = ZEND_FFI_TYPE(type)->align; in ZEND_METHOD()
4261 new_type->array.type = type; in ZEND_METHOD()
4268 type = ZEND_FFI_TYPE_MAKE_OWNED(new_type); in ZEND_METHOD()
4272 ctype->type = type; in ZEND_METHOD()
4280 zend_ffi_type *type, *new_type; in ZEND_METHOD() local
4297 type = ZEND_FFI_TYPE(cdata->type); in ZEND_METHOD()
4299 if (GC_REFCOUNT(&cdata->std) == 1 && Z_REFCOUNT_P(arg) == 1 && type->kind == ZEND_FFI_TYPE_POINTER in ZEND_METHOD()
4311 new_type->pointer.type = type; in ZEND_METHOD()
4314 new_cdata->type = ZEND_FFI_TYPE_MAKE_OWNED(new_type); in ZEND_METHOD()
4319 if (ZEND_FFI_TYPE_IS_OWNED(cdata->type)) { in ZEND_METHOD()
4321 cdata->type = type; in ZEND_METHOD()
4322 new_type->pointer.type = ZEND_FFI_TYPE_MAKE_OWNED(type); in ZEND_METHOD()
4338 zend_ffi_type *type; in ZEND_METHOD() local
4348 type = ZEND_FFI_TYPE(cdata->type); in ZEND_METHOD()
4351 type = ZEND_FFI_TYPE(ctype->type); in ZEND_METHOD()
4357 RETURN_LONG(type->size); in ZEND_METHOD()
4364 zend_ffi_type *type; in ZEND_METHOD() local
4374 type = ZEND_FFI_TYPE(cdata->type); in ZEND_METHOD()
4377 type = ZEND_FFI_TYPE(ctype->type); in ZEND_METHOD()
4383 RETURN_LONG(type->align); in ZEND_METHOD()
4403 type1 = ZEND_FFI_TYPE(cdata1->type); in ZEND_METHOD()
4423 type2 = ZEND_FFI_TYPE(cdata2->type); in ZEND_METHOD()
4467 type1 = ZEND_FFI_TYPE(cdata1->type); in ZEND_METHOD()
4491 type2 = ZEND_FFI_TYPE(cdata2->type); in ZEND_METHOD()
4521 zend_ffi_type *type; in ZEND_METHOD() local
4533 type = ZEND_FFI_TYPE(cdata->type); in ZEND_METHOD()
4534 if (type->kind == ZEND_FFI_TYPE_POINTER) { in ZEND_METHOD()
4538 if (type->kind != ZEND_FFI_TYPE_POINTER && size > type->size) { in ZEND_METHOD()
4552 zend_ffi_type *type; in ZEND_METHOD() local
4565 type = ZEND_FFI_TYPE(cdata->type); in ZEND_METHOD()
4567 if (type->kind == ZEND_FFI_TYPE_POINTER) { in ZEND_METHOD()
4571 if (type->kind != ZEND_FFI_TYPE_POINTER && size > type->size) { in ZEND_METHOD()
4578 …if (type->kind == ZEND_FFI_TYPE_POINTER && ZEND_FFI_TYPE(type->pointer.type)->kind == ZEND_FFI_TYP… in ZEND_METHOD()
4580 …} else if (type->kind == ZEND_FFI_TYPE_ARRAY && ZEND_FFI_TYPE(type->array.type)->kind == ZEND_FFI_… in ZEND_METHOD()
4595 zend_ffi_type *type; in ZEND_METHOD() local
4609 type = ZEND_FFI_TYPE(cdata->type); in ZEND_METHOD()
4611 if (type->kind != ZEND_FFI_TYPE_POINTER){ in ZEND_METHOD()
4631 if (!zend_ffi_ctype_name(&buf, ZEND_FFI_TYPE(ctype->type))) { in ZEND_METHOD()
4644 zend_ffi_type *type; in ZEND_METHOD() local
4650 type = ZEND_FFI_TYPE(ctype->type); in ZEND_METHOD()
4651 RETURN_LONG(type->kind); in ZEND_METHOD()
4658 zend_ffi_type *type; in ZEND_METHOD() local
4664 type = ZEND_FFI_TYPE(ctype->type); in ZEND_METHOD()
4665 RETURN_LONG(type->size); in ZEND_METHOD()
4672 zend_ffi_type *type; in ZEND_METHOD() local
4678 type = ZEND_FFI_TYPE(ctype->type); in ZEND_METHOD()
4679 RETURN_LONG(type->align); in ZEND_METHOD()
4686 zend_ffi_type *type; in ZEND_METHOD() local
4692 type = ZEND_FFI_TYPE(ctype->type); in ZEND_METHOD()
4693 RETURN_LONG(type->attr); in ZEND_METHOD()
4700 zend_ffi_type *type; in ZEND_METHOD() local
4706 type = ZEND_FFI_TYPE(ctype->type); in ZEND_METHOD()
4707 if (type->kind != ZEND_FFI_TYPE_ENUM) { in ZEND_METHOD()
4711 RETURN_LONG(type->enumeration.kind); in ZEND_METHOD()
4718 zend_ffi_type *type; in ZEND_METHOD() local
4725 type = ZEND_FFI_TYPE(ctype->type); in ZEND_METHOD()
4726 if (type->kind != ZEND_FFI_TYPE_ARRAY) { in ZEND_METHOD()
4732 ret->type = ZEND_FFI_TYPE(type->array.type); in ZEND_METHOD()
4740 zend_ffi_type *type; in ZEND_METHOD() local
4746 type = ZEND_FFI_TYPE(ctype->type); in ZEND_METHOD()
4747 if (type->kind != ZEND_FFI_TYPE_ARRAY) { in ZEND_METHOD()
4751 RETURN_LONG(type->array.length); in ZEND_METHOD()
4759 zend_ffi_type *type; in ZEND_METHOD() local
4765 type = ZEND_FFI_TYPE(ctype->type); in ZEND_METHOD()
4766 if (type->kind != ZEND_FFI_TYPE_POINTER) { in ZEND_METHOD()
4772 ret->type = ZEND_FFI_TYPE(type->pointer.type); in ZEND_METHOD()
4780 zend_ffi_type *type; in ZEND_METHOD() local
4789 type = ZEND_FFI_TYPE(ctype->type); in ZEND_METHOD()
4790 if (type->kind != ZEND_FFI_TYPE_STRUCT) { in ZEND_METHOD()
4795 ht = zend_new_array(zend_hash_num_elements(&type->record.fields)); in ZEND_METHOD()
4797 ZEND_HASH_MAP_FOREACH_STR_KEY(&type->record.fields, name) { in ZEND_METHOD()
4807 zend_ffi_type *type; in ZEND_METHOD() local
4815 type = ZEND_FFI_TYPE(ctype->type); in ZEND_METHOD()
4816 if (type->kind != ZEND_FFI_TYPE_STRUCT) { in ZEND_METHOD()
4821 ptr = zend_hash_find_ptr(&type->record.fields, name); in ZEND_METHOD()
4833 zend_ffi_type *type; in ZEND_METHOD() local
4842 type = ZEND_FFI_TYPE(ctype->type); in ZEND_METHOD()
4843 if (type->kind != ZEND_FFI_TYPE_STRUCT) { in ZEND_METHOD()
4848 ptr = zend_hash_find_ptr(&type->record.fields, name); in ZEND_METHOD()
4855 ret->type = ZEND_FFI_TYPE(ptr->type); in ZEND_METHOD()
4863 zend_ffi_type *type; in ZEND_METHOD() local
4869 type = ZEND_FFI_TYPE(ctype->type); in ZEND_METHOD()
4870 if (type->kind != ZEND_FFI_TYPE_FUNC) { in ZEND_METHOD()
4874 RETURN_LONG(type->func.abi); in ZEND_METHOD()
4882 zend_ffi_type *type; in ZEND_METHOD() local
4888 type = ZEND_FFI_TYPE(ctype->type); in ZEND_METHOD()
4889 if (type->kind != ZEND_FFI_TYPE_FUNC) { in ZEND_METHOD()
4895 ret->type = ZEND_FFI_TYPE(type->func.ret_type); in ZEND_METHOD()
4903 zend_ffi_type *type; in ZEND_METHOD() local
4909 type = ZEND_FFI_TYPE(ctype->type); in ZEND_METHOD()
4910 if (type->kind != ZEND_FFI_TYPE_FUNC) { in ZEND_METHOD()
4914 RETURN_LONG(type->func.args ? zend_hash_num_elements(type->func.args) : 0); in ZEND_METHOD()
4921 zend_ffi_type *type, *ptr; in ZEND_METHOD() local
4929 type = ZEND_FFI_TYPE(ctype->type); in ZEND_METHOD()
4930 if (type->kind != ZEND_FFI_TYPE_FUNC) { in ZEND_METHOD()
4935 if (!type->func.args) { in ZEND_METHOD()
4940 ptr = zend_hash_index_find_ptr(type->func.args, n); in ZEND_METHOD()
4947 ret->type = ZEND_FFI_TYPE(ptr); in ZEND_METHOD()
5074 static ZEND_COLD zval *zend_fake_read_dimension(zend_object *obj, zval *offset, int type, zval *rv)… in zend_fake_read_dimension() argument
5106 static ZEND_COLD zval *zend_fake_read_property(zend_object *obj, zend_string *member, int type, voi… in zend_fake_read_property() argument
5133 static zval *zend_fake_get_property_ptr_ptr(zend_object *obj, zend_string *member, int type, void *… in zend_fake_get_property_ptr_ptr() argument
5161 static zend_result zend_fake_cast_object(zend_object *obj, zval *result, int type) in zend_fake_cast_object() argument
5163 switch (type) { in zend_fake_cast_object()
5185 static ZEND_COLD zval *zend_ffi_free_read_dimension(zend_object *obj, zval *offset, int type, zval … in zend_ffi_free_read_dimension() argument
5211 static ZEND_COLD zval *zend_ffi_free_read_property(zend_object *obj, zend_string *member, int type,… in zend_ffi_free_read_property() argument
5602 …D_FFI_TYPE_POINTER, .size=sizeof(void*), .align=_Alignof(void*), .pointer.type = (zend_ffi_type*)&…
5606 const zend_ffi_type *type; member
5659 …als->types, zend_ffi_types[i].name, strlen(zend_ffi_types[i].name), (void*)zend_ffi_types[i].type);
5725 if (!dcl->type) {
5728 dcl->type = (zend_ffi_type*)&zend_ffi_type_void;
5731 dcl->type = (zend_ffi_type*)&zend_ffi_type_char;
5734 dcl->type = (zend_ffi_type*)&zend_ffi_type_sint8;
5738 dcl->type = (zend_ffi_type*)&zend_ffi_type_uint8;
5744 dcl->type = (zend_ffi_type*)&zend_ffi_type_sint16;
5748 dcl->type = (zend_ffi_type*)&zend_ffi_type_uint16;
5753 dcl->type = (zend_ffi_type*)&zend_ffi_type_sint32;
5757 dcl->type = (zend_ffi_type*)&zend_ffi_type_uint32;
5764 dcl->type = (zend_ffi_type*)&zend_ffi_type_sint32;
5766 dcl->type = (zend_ffi_type*)&zend_ffi_type_sint64;
5772 dcl->type = (zend_ffi_type*)&zend_ffi_type_uint32;
5774 dcl->type = (zend_ffi_type*)&zend_ffi_type_uint64;
5781 dcl->type = (zend_ffi_type*)&zend_ffi_type_sint64;
5785 dcl->type = (zend_ffi_type*)&zend_ffi_type_uint64;
5788 dcl->type = (zend_ffi_type*)&zend_ffi_type_float;
5791 dcl->type = (zend_ffi_type*)&zend_ffi_type_double;
5795 dcl->type = (zend_ffi_type*)&zend_ffi_type_double;
5797 dcl->type = (zend_ffi_type*)&zend_ffi_type_long_double;
5818 zend_ffi_type *type; local
5826 type = zend_hash_str_find_ptr(&FFI_G(types), name, name_len);
5827 if (type) {
5837 zend_ffi_type *type; local
5842 dcl->type = ZEND_FFI_TYPE(sym->type);
5849 type = zend_hash_str_find_ptr(&FFI_G(types), name, name_len);
5850 if (type) {
5851 dcl->type = type;
5871 switch (sym->type->kind) {
5900 zend_ffi_type *type = pemalloc(sizeof(zend_ffi_type), FFI_G(persistent)); local
5901 type->kind = ZEND_FFI_TYPE_ENUM;
5902 type->attr = FFI_G(default_type_attr) | (dcl->attr & ZEND_FFI_ENUM_ATTRS);
5903 type->enumeration.tag_name = NULL;
5904 if (type->attr & ZEND_FFI_ATTR_PACKED) {
5905 type->size = zend_ffi_type_uint8.size;
5906 type->align = zend_ffi_type_uint8.align;
5907 type->enumeration.kind = ZEND_FFI_TYPE_UINT8;
5909 type->size = zend_ffi_type_uint32.size;
5910 type->align = zend_ffi_type_uint32.align;
5911 type->enumeration.kind = ZEND_FFI_TYPE_UINT32;
5913 dcl->type = ZEND_FFI_TYPE_MAKE_OWNED(type);
5923 zend_ffi_type *enum_type = ZEND_FFI_TYPE(enum_dcl->type);
6021 sym->type = (zend_ffi_type*)sym_type;
6030 zend_ffi_type *type = pemalloc(sizeof(zend_ffi_type), FFI_G(persistent)); local
6031 type->kind = ZEND_FFI_TYPE_STRUCT;
6032 type->attr = FFI_G(default_type_attr) | (dcl->attr & ZEND_FFI_STRUCT_ATTRS);
6033 type->size = 0;
6034 type->align = dcl->align > 1 ? dcl->align : 1;
6036 type->attr |= ZEND_FFI_ATTR_UNION;
6038 dcl->type = ZEND_FFI_TYPE_MAKE_OWNED(type);
6039 type->record.tag_name = NULL;
6040 …zend_hash_init(&type->record.fields, 0, NULL, FFI_G(persistent) ? zend_ffi_field_hash_persistent_d…
6054 if (ZEND_FFI_TYPE(field->type)->attr & ZEND_FFI_ATTR_INCOMPLETE_ARRAY) {
6063 static zend_result zend_ffi_validate_field_type(zend_ffi_type *type, zend_ffi_type *struct_type) /*… argument
6065 if (type == struct_type) {
6068 } else if (zend_ffi_validate_var_type(type, 1) == FAILURE) {
6071 if (type->attr & ZEND_FFI_ATTR_INCOMPLETE_ARRAY) {
6083 zend_ffi_type *struct_type = ZEND_FFI_TYPE(struct_dcl->type);
6088 field_type = ZEND_FFI_TYPE(field_dcl->type);
6109 field->type = field_dcl->type;
6114 field_dcl->type = field_type; /* reset "owned" flag */
6117 zend_ffi_type_dtor(field->type);
6126 zend_ffi_type *struct_type = ZEND_FFI_TYPE(struct_dcl->type);
6133 field_type = ZEND_FFI_TYPE(field_dcl->type);
6162 new_field->type = field->type;
6167 field->type = ZEND_FFI_TYPE(field->type); /* reset "owned" flag */
6171 zend_ffi_type_dtor(new_field->type);
6187 zend_ffi_type_dtor(field_dcl->type);
6188 field_dcl->type = NULL;
6194 zend_ffi_type *struct_type = ZEND_FFI_TYPE(struct_dcl->type);
6200 field_type = ZEND_FFI_TYPE(field_dcl->type);
6277 field->type = field_dcl->type;
6280 field_dcl->type = field_type; /* reset "owned" flag */
6284 zend_ffi_type_dtor(field->type);
6296 zend_ffi_type *struct_type = ZEND_FFI_TYPE(dcl->type);
6311 zend_ffi_type *type = pemalloc(sizeof(zend_ffi_type), FFI_G(persistent)); local
6312 type->kind = ZEND_FFI_TYPE_POINTER;
6313 type->attr = FFI_G(default_type_attr) | (dcl->attr & ZEND_FFI_POINTER_ATTRS);
6314 type->size = sizeof(void*);
6315 type->align = _Alignof(void*);
6317 if (zend_ffi_validate_vla(ZEND_FFI_TYPE(dcl->type)) == FAILURE) {
6321 type->pointer.type = dcl->type;
6322 dcl->type = ZEND_FFI_TYPE_MAKE_OWNED(type);
6329 static zend_result zend_ffi_validate_array_element_type(zend_ffi_type *type) /* {{{ */ argument
6331 if (type->kind == ZEND_FFI_TYPE_FUNC) {
6334 } else if (type->kind == ZEND_FFI_TYPE_ARRAY && (type->attr & ZEND_FFI_ATTR_INCOMPLETE_ARRAY)) {
6338 return zend_ffi_validate_type(type, 0, 1);
6346 zend_ffi_type *type; local
6349 element_type = ZEND_FFI_TYPE(dcl->type);
6375 type = pemalloc(sizeof(zend_ffi_type), FFI_G(persistent));
6376 type->kind = ZEND_FFI_TYPE_ARRAY;
6377 type->attr = FFI_G(default_type_attr) | (dcl->attr & ZEND_FFI_ARRAY_ATTRS);
6378 type->size = length * element_type->size;
6379 type->align = element_type->align;
6380 type->array.type = dcl->type;
6381 type->array.length = length;
6382 dcl->type = ZEND_FFI_TYPE_MAKE_OWNED(type);
6389 static zend_result zend_ffi_validate_func_ret_type(zend_ffi_type *type) /* {{{ */ argument
6391 if (type->kind == ZEND_FFI_TYPE_FUNC) {
6394 } else if (type->kind == ZEND_FFI_TYPE_ARRAY) {
6398 return zend_ffi_validate_incomplete_type(type, 1, 0);
6404 zend_ffi_type *type; local
6408 ret_type = ZEND_FFI_TYPE(dcl->type);
6469 type = pemalloc(sizeof(zend_ffi_type), FFI_G(persistent));
6470 type->kind = ZEND_FFI_TYPE_FUNC;
6471 type->attr = FFI_G(default_type_attr) | (dcl->attr & ZEND_FFI_FUNC_ATTRS);
6472 type->size = sizeof(void*);
6473 type->align = 1;
6474 type->func.ret_type = dcl->type;
6478 type->func.abi = FFI_DEFAULT_ABI;
6482 type->func.abi = FFI_FASTCALL;
6487 type->func.abi = FFI_THISCALL;
6492 type->func.abi = FFI_STDCALL;
6497 type->func.abi = FFI_PASCAL;
6502 type->func.abi = FFI_REGISTER;
6507 type->func.abi = FFI_MS_CDECL;
6512 type->func.abi = FFI_SYSV;
6517 type->func.abi = FFI_VECTORCALL_PARTIAL;
6521 type->func.abi = FFI_DEFAULT_ABI;
6527 type->func.args = NULL;
6528 _zend_ffi_type_dtor(type);
6532 type->func.args = args;
6533 dcl->type = ZEND_FFI_TYPE_MAKE_OWNED(type);
6542 zend_ffi_type *type; local
6549 type = ZEND_FFI_TYPE(arg_dcl->type);
6550 if (type->kind == ZEND_FFI_TYPE_ARRAY) {
6551 if (ZEND_FFI_TYPE_IS_OWNED(arg_dcl->type)) {
6552 type->kind = ZEND_FFI_TYPE_POINTER;
6553 type->size = sizeof(void*);
6557 new_type->attr = FFI_G(default_type_attr) | (type->attr & ZEND_FFI_POINTER_ATTRS);
6560 new_type->pointer.type = ZEND_FFI_TYPE(type->array.type);
6561 arg_dcl->type = ZEND_FFI_TYPE_MAKE_OWNED(new_type);
6563 } else if (type->kind == ZEND_FFI_TYPE_FUNC) {
6569 new_type->pointer.type = arg_dcl->type;
6570 arg_dcl->type = ZEND_FFI_TYPE_MAKE_OWNED(new_type);
6572 if (zend_ffi_validate_incomplete_type(type, 1, 1) == FAILURE) {
6579 zend_hash_next_index_insert_ptr(*args, (void*)arg_dcl->type);
6596 && zend_ffi_is_same_type(ZEND_FFI_TYPE(sym->type), ZEND_FFI_TYPE(dcl->type))
6599 zend_ffi_type_dtor(dcl->type);
6603 zend_ffi_type *type = ZEND_FFI_TYPE(dcl->type); local
6605 if (type->kind == ZEND_FFI_TYPE_FUNC) {
6607 && zend_ffi_same_types(ZEND_FFI_TYPE(sym->type), type)) {
6609 zend_ffi_type_dtor(dcl->type);
6614 && zend_ffi_is_same_type(ZEND_FFI_TYPE(sym->type), type)
6617 zend_ffi_type_dtor(dcl->type);
6625 if (zend_ffi_validate_vla(ZEND_FFI_TYPE(dcl->type)) == FAILURE) {
6629 if (dcl->align && dcl->align > ZEND_FFI_TYPE(dcl->type)->align) {
6630 if (ZEND_FFI_TYPE_IS_OWNED(dcl->type)) {
6631 ZEND_FFI_TYPE(dcl->type)->align = dcl->align;
6633 zend_ffi_type *type = pemalloc(sizeof(zend_ffi_type), FFI_G(persistent)); local
6635 memcpy(type, ZEND_FFI_TYPE(dcl->type), sizeof(zend_ffi_type));
6636 type->attr |= FFI_G(default_type_attr);
6637 type->align = dcl->align;
6638 dcl->type = ZEND_FFI_TYPE_MAKE_OWNED(type);
6643 sym->type = dcl->type;
6645 dcl->type = ZEND_FFI_TYPE(dcl->type); /* reset "owned" flag */
6648 zend_ffi_type *type; local
6650 type = ZEND_FFI_TYPE(dcl->type);
6651 …if (zend_ffi_validate_type(type, (dcl->flags & ZEND_FFI_DCL_STORAGE_CLASS) == ZEND_FFI_DCL_EXTERN,…
6658 sym->kind = (type->kind == ZEND_FFI_TYPE_FUNC) ? ZEND_FFI_SYM_FUNC : ZEND_FFI_SYM_VAR;
6659 sym->type = dcl->type;
6661 dcl->type = type; /* reset "owned" flag */
6665 zend_ffi_type_dtor(dcl->type);
6675 zend_ffi_type *type; local
6683 zend_ffi_type *type = ZEND_FFI_TYPE(tag->type); local
6689 } else if (!incomplete && !(type->attr & ZEND_FFI_ATTR_INCOMPLETE_TAG)) {
6697 } else if (!incomplete && !(type->attr & ZEND_FFI_ATTR_INCOMPLETE_TAG)) {
6705 } else if (!incomplete && !(type->attr & ZEND_FFI_ATTR_INCOMPLETE_TAG)) {
6713 dcl->type = type;
6715 type->attr &= ~ZEND_FFI_ATTR_INCOMPLETE_TAG;
6724 type = ZEND_FFI_TYPE(dcl->type);
6725 type->record.tag_name = zend_string_copy(tag_name);
6729 type = ZEND_FFI_TYPE(dcl->type);
6730 type->record.tag_name = zend_string_copy(tag_name);
6734 type = ZEND_FFI_TYPE(dcl->type);
6735 type->enumeration.tag_name = zend_string_copy(tag_name);
6739 tag->type = ZEND_FFI_TYPE_MAKE_OWNED(dcl->type);
6740 dcl->type = ZEND_FFI_TYPE(dcl->type);
6742 dcl->type->attr |= ZEND_FFI_ATTR_INCOMPLETE_TAG;
6997 static zend_result zend_ffi_nested_type(zend_ffi_type *type, zend_ffi_type *nested_type) /* {{{ */ argument
7003 if (nested_type->pointer.type == &zend_ffi_type_char) {
7004 nested_type->pointer.type = type;
7005 return zend_ffi_validate_vla(ZEND_FFI_TYPE(type));
7007 return zend_ffi_nested_type(type, nested_type->pointer.type);
7012 if (nested_type->array.type == &zend_ffi_type_char) {
7013 nested_type->array.type = type;
7014 if (zend_ffi_validate_array_element_type(ZEND_FFI_TYPE(type)) == FAILURE) {
7018 if (zend_ffi_nested_type(type, nested_type->array.type) != SUCCESS) {
7022 nested_type->size = nested_type->array.length * ZEND_FFI_TYPE(nested_type->array.type)->size;
7023 nested_type->align = ZEND_FFI_TYPE(nested_type->array.type)->align;
7029 nested_type->func.ret_type = type;
7030 return zend_ffi_validate_func_ret_type(ZEND_FFI_TYPE(type));
7032 return zend_ffi_nested_type(type, nested_type->func.ret_type);
7045 if (!nested_dcl->type || nested_dcl->type == &zend_ffi_type_char) {
7046 nested_dcl->type = dcl->type;
7048 if (zend_ffi_nested_type(dcl->type, nested_dcl->type) == FAILURE) {
7053 dcl->type = nested_dcl->type;
7060 dcl->align = MAX(align_dcl->align, ZEND_FFI_TYPE(align_dcl->type)->align);
7444 switch (ZEND_FFI_TYPE(dcl->type)->kind) {
7571 zend_ffi_type_dtor(dcl->type);
7666 zend_ffi_type *type; local
7669 type = ZEND_FFI_TYPE(dcl->type);
7670 val->kind = (type->size > 0xffffffff) ? ZEND_FFI_VAL_UINT64 : ZEND_FFI_VAL_UINT32;
7671 val->u64 = type->size;
7672 zend_ffi_type_dtor(dcl->type);
7711 val->u64 = ZEND_FFI_TYPE(dcl->type)->align;
7712 zend_ffi_type_dtor(dcl->type);