}
/* }}} */
-void zend_ffi_make_func_type(zend_ffi_dcl *dcl, HashTable *args) /* {{{ */
+void zend_ffi_make_func_type(zend_ffi_dcl *dcl, HashTable *args, zend_ffi_dcl *nested_dcl) /* {{{ */
{
zend_ffi_type *type;
zend_ffi_type *ret_type;
arg_type = ZEND_FFI_TYPE(arg_type);
if (arg_type->kind == ZEND_FFI_TYPE_VOID) {
if (zend_hash_num_elements(args) != 1) {
+ zend_ffi_cleanup_dcl(nested_dcl);
zend_ffi_cleanup_dcl(dcl);
zend_hash_destroy(args);
pefree(args, FFI_G(persistent));
}
if (zend_ffi_validate_func_ret_type(ret_type) != SUCCESS) {
+ zend_ffi_cleanup_dcl(nested_dcl);
zend_ffi_cleanup_dcl(dcl);
if (args) {
zend_hash_destroy(args);
#endif
default:
type->func.abi = FFI_DEFAULT_ABI;
+ zend_ffi_cleanup_dcl(nested_dcl);
+ if (args) {
+ zend_hash_destroy(args);
+ pefree(args, FFI_G(persistent));
+ }
+ _zend_ffi_type_dtor(type);
zend_ffi_parser_error("unsupported calling convention line %d", FFI_G(line));
break;
}
")"
{nested = 1;}
)
- array_or_function_declarators(dcl)?
+ array_or_function_declarators(dcl, &nested_dcl)?
{if (nested) zend_ffi_nested_declaration(dcl, &nested_dcl);}
;
")"
{nested = 1;}
)?
- array_or_function_declarators(dcl)?
+ array_or_function_declarators(dcl, &nested_dcl)?
{if (nested) zend_ffi_nested_declaration(dcl, &nested_dcl);}
;
| ID(name, name_len)
| /* empty */
)
- array_or_function_declarators(dcl)?
+ array_or_function_declarators(dcl, &nested_dcl)?
{if (nested) zend_ffi_nested_declaration(dcl, &nested_dcl);}
;
)+
;
-array_or_function_declarators(zend_ffi_dcl *dcl):
+array_or_function_declarators(zend_ffi_dcl *dcl, zend_ffi_dcl *nested_dcl):
{zend_ffi_dcl dummy = ZEND_FFI_ATTR_INIT;}
{zend_ffi_val len = {.kind = ZEND_FFI_VAL_EMPTY};}
{HashTable *args = NULL;}
)
)
"]"
- array_or_function_declarators(dcl)?
+ array_or_function_declarators(dcl, nested_dcl)?
{dcl->attr |= attr;}
{zend_ffi_make_array_type(dcl, &len);}
| "("
{attr |= ZEND_FFI_ATTR_VARIADIC;}
)?
")"
- array_or_function_declarators(dcl)?
+ array_or_function_declarators(dcl, nested_dcl)?
{dcl->attr |= attr;}
- {zend_ffi_make_func_type(dcl, args);}
+ {zend_ffi_make_func_type(dcl, args, nested_dcl);}
// | "(" (ID ("," ID)*)? ")" // TODO: ANSI function not-implemented ???
)
;
static int parse_abstract_declarator(int sym, zend_ffi_dcl *dcl);
static int parse_parameter_declarator(int sym, zend_ffi_dcl *dcl, const char **name, size_t *name_len);
static int parse_pointer(int sym, zend_ffi_dcl *dcl);
-static int parse_array_or_function_declarators(int sym, zend_ffi_dcl *dcl);
+static int parse_array_or_function_declarators(int sym, zend_ffi_dcl *dcl, zend_ffi_dcl *nested_dcl);
static int parse_parameter_declaration(int sym, HashTable **args);
static int parse_type_name(int sym, zend_ffi_dcl *dcl);
static int parse_attributes(int sym, zend_ffi_dcl *dcl);
yy_error_sym("unexpected", sym);
}
if (sym == YY__LBRACK || sym == YY__LPAREN) {
- sym = parse_array_or_function_declarators(sym, dcl);
+ sym = parse_array_or_function_declarators(sym, dcl, &nested_dcl);
}
if (nested) zend_ffi_nested_declaration(dcl, &nested_dcl);
return sym;
nested = 1;
}
if (sym == YY__LBRACK || sym == YY__LPAREN) {
- sym = parse_array_or_function_declarators(sym, dcl);
+ sym = parse_array_or_function_declarators(sym, dcl, &nested_dcl);
}
if (nested) zend_ffi_nested_declaration(dcl, &nested_dcl);
return sym;
yy_error_sym("unexpected", sym);
}
if (sym == YY__LBRACK || sym == YY__LPAREN) {
- sym = parse_array_or_function_declarators(sym, dcl);
+ sym = parse_array_or_function_declarators(sym, dcl, &nested_dcl);
}
if (nested) zend_ffi_nested_declaration(dcl, &nested_dcl);
return sym;
return sym;
}
-static int parse_array_or_function_declarators(int sym, zend_ffi_dcl *dcl) {
+static int parse_array_or_function_declarators(int sym, zend_ffi_dcl *dcl, zend_ffi_dcl *nested_dcl) {
int sym2;
const unsigned char *save_pos;
const unsigned char *save_text;
}
sym = get_sym();
if (sym == YY__LBRACK || sym == YY__LPAREN) {
- sym = parse_array_or_function_declarators(sym, dcl);
+ sym = parse_array_or_function_declarators(sym, dcl, nested_dcl);
}
dcl->attr |= attr;
zend_ffi_make_array_type(dcl, &len);
}
sym = get_sym();
if (sym == YY__LBRACK || sym == YY__LPAREN) {
- sym = parse_array_or_function_declarators(sym, dcl);
+ sym = parse_array_or_function_declarators(sym, dcl, nested_dcl);
}
dcl->attr |= attr;
- zend_ffi_make_func_type(dcl, args);
+ zend_ffi_make_func_type(dcl, args, nested_dcl);
} else {
yy_error_sym("unexpected", sym);
}
void zend_ffi_adjust_struct_size(zend_ffi_dcl *dcl);
void zend_ffi_make_pointer_type(zend_ffi_dcl *dcl);
void zend_ffi_make_array_type(zend_ffi_dcl *dcl, zend_ffi_val *len);
-void zend_ffi_make_func_type(zend_ffi_dcl *dcl, HashTable *args);
+void zend_ffi_make_func_type(zend_ffi_dcl *dcl, HashTable *args, zend_ffi_dcl *nested_dcl);
void zend_ffi_add_arg(HashTable **args, const char *name, size_t name_len, zend_ffi_dcl *arg_dcl);
void zend_ffi_declare(const char *name, size_t name_len, zend_ffi_dcl *dcl);
void zend_ffi_add_attribute(zend_ffi_dcl *dcl, const char *name, size_t name_len);