[packages/php-pecl-ffi] new, version 0.4 (svn branch diff)

glen glen at pld-linux.org
Wed Aug 13 00:11:00 CEST 2014


commit d67e37e83ad41fd284edffdb6e2d11e33d99338d
Author: Elan Ruusamäe <glen at delfi.ee>
Date:   Wed Aug 13 01:10:28 2014 +0300

    new, version 0.4 (svn branch diff)

 branch.diff       | 2128 +++++++++++++++++++++++++++++++++++++++++++++++++++++
 php-pecl-ffi.spec |   82 +++
 2 files changed, 2210 insertions(+)
---
diff --git a/php-pecl-ffi.spec b/php-pecl-ffi.spec
new file mode 100644
index 0000000..c4ba2e3
--- /dev/null
+++ b/php-pecl-ffi.spec
@@ -0,0 +1,82 @@
+#
+# Conditional build:
+%bcond_without	tests		# build without tests
+
+%define		php_name	php%{?php_suffix}
+%define		modname	ffi
+Summary:	%{modname} - Foreign Function Interface
+Name:		%{php_name}-pecl-%{modname}
+Version:	0.4
+Release:	1
+License:	PHP 3.01
+Group:		Development/Languages/PHP
+Source0:	http://pecl.php.net/get/%{modname}-0.3.tgz
+# Source0-md5:	3ec0153672981bf7a8895758264bf3b4
+Patch0:		branch.diff
+URL:		http://pecl.php.net/package/ffi/
+%{?with_tests:BuildRequires:    %{php_name}-cli}
+BuildRequires:	%{php_name}-devel
+BuildRequires:	rpmbuild(macros) >= 1.666
+%{?requires_php_extension}
+Provides:	php(ffi) = %{version}
+BuildRoot:	%{tmpdir}/%{name}-%{version}-root-%(id -u -n)
+
+%description
+FFI is a multi-platform extension for PHP 5 that allows you to bind to
+functions from arbitrary shared libraries and call them.
+
+%prep
+%setup -qc
+mv %{modname}-*/* .
+%patch0 -p0
+
+%build
+phpize
+%configure
+%{__make}
+
+%if %{with tests}
+# simple module load test
+%{__php} -n -q \
+	-d extension_dir=modules \
+	-d extension=%{modname}.so \
+	-m > modules.log
+grep %{modname} modules.log
+
+export NO_INTERACTION=1 REPORT_EXIT_STATUS=1 MALLOC_CHECK_=2
+%{__make} test \
+	PHP_EXECUTABLE=%{__php}
+%endif
+
+%install
+rm -rf $RPM_BUILD_ROOT
+%{__make} install \
+	EXTENSION_DIR=%{php_extensiondir} \
+	INSTALL_ROOT=$RPM_BUILD_ROOT
+
+install -d $RPM_BUILD_ROOT%{php_sysconfdir}/conf.d
+cat <<'EOF' > $RPM_BUILD_ROOT%{php_sysconfdir}/conf.d/%{modname}.ini
+; Enable %{modname} extension module
+extension=%{modname}.so
+EOF
+
+install -d $RPM_BUILD_ROOT%{_examplesdir}/%{name}-%{version}
+cp -a examples/* $RPM_BUILD_ROOT%{_examplesdir}/%{name}-%{version}
+
+%clean
+rm -rf $RPM_BUILD_ROOT
+
+%post
+%php_webserver_restart
+
+%postun
+if [ "$1" = 0 ]; then
+	%php_webserver_restart
+fi
+
+%files
+%defattr(644,root,root,755)
+%doc CREDITS EXPERIMENTAL
+%config(noreplace) %verify(not md5 mtime size) %{php_sysconfdir}/conf.d/%{modname}.ini
+%attr(755,root,root) %{php_extensiondir}/%{modname}.so
+%{_examplesdir}/%{name}-%{version}
diff --git a/branch.diff b/branch.diff
new file mode 100644
index 0000000..b14534b
--- /dev/null
+++ b/branch.diff
@@ -0,0 +1,2128 @@
+Index: php_ffi.c
+===================================================================
+--- php_ffi.c	(.../tags/RELEASE_0_3)
++++ php_ffi.c	(.../trunk)
+@@ -12,7 +12,7 @@
+   | obtain it through the world-wide-web, please send a note to          |
+   | license at php.net so we can mail you a copy immediately.               |
+   +----------------------------------------------------------------------+
+-  | Author: Wez Furlong <wez at thebrainroom.com>                           |
++  | Author: Wez Furlong  <wez at php.net>                                   |
+   +----------------------------------------------------------------------+
+ */
+ 
+@@ -41,7 +41,7 @@
+  *
+  * Every user visible function must have an entry in ffi_functions[].
+  */
+-function_entry ffi_functions[] = {
++zend_function_entry ffi_functions[] = {
+ 	{NULL, NULL, NULL}	/* Must be the last line in ffi_functions[] */
+ };
+ /* }}} */
+@@ -57,7 +57,7 @@
+ 	PHP_RINIT(ffi),
+ 	PHP_RSHUTDOWN(ffi),
+ 	PHP_MINFO(ffi),
+-	"0.3",
++	PHP_FFI_VERSION,
+ 	STANDARD_MODULE_PROPERTIES
+ };
+ /* }}} */
+@@ -93,11 +93,11 @@
+ {
+ 	zend_class_entry ce;
+ 
+-	INIT_CLASS_ENTRY(ce, "ffi", php_ffi_context_funcs);
++	INIT_CLASS_ENTRY(ce, "FFI", php_ffi_context_funcs);
+ 	ce.create_object = php_ffi_context_object_new;
+ 	php_ffi_context_class_entry = zend_register_internal_class(&ce TSRMLS_CC);
+ 
+-	INIT_CLASS_ENTRY(ce, "ffi_struct", NULL);
++	INIT_CLASS_ENTRY(ce, "FFIStruct", NULL);
+ 	ce.create_object = php_ffi_struct_object_new;
+ 	php_ffi_struct_class_entry = zend_register_internal_class(&ce TSRMLS_CC);
+ 		
+@@ -144,6 +144,7 @@
+ {
+ 	php_info_print_table_start();
+ 	php_info_print_table_header(2, "ffi support", "enabled");
++	php_info_print_table_row(2, "extension version", PHP_FFI_VERSION);
+ /*	php_info_print_table_row(2, "ffi library version", PHP_LIBFFI_VERSION); */
+ 	php_info_print_table_end();
+ 
+
+Property changes on: php_ffi.c
+___________________________________________________________________
+Modified: cvs2svn:cvs-rev
+## -1 +1 ##
+-1.5
+\ No newline at end of property
++1.8
+\ No newline at end of property
+Index: php_ffi_internal.h
+===================================================================
+--- php_ffi_internal.h	(.../tags/RELEASE_0_3)
++++ php_ffi_internal.h	(.../trunk)
+@@ -12,7 +12,7 @@
+    | obtain it through the world-wide-web, please send a note to          |
+    | license at php.net so we can mail you a copy immediately.               |
+    +----------------------------------------------------------------------+
+-   | Author: Wez Furlong  <wez at thebrainroom.com>                          |
++   | Author: Wez Furlong  <wez at php.net>                                   |
+    +----------------------------------------------------------------------+
+  */
+ 
+@@ -21,10 +21,6 @@
+ 
+ #include "ffi.h"
+ 
+-#ifdef PHP_WIN32
+-# define SINT64	INT64
+-#endif
+-
+ typedef struct {
+ 	DL_HANDLE handle;		/* handle to the library */
+ 	char *libname;			/* name of the library (for error messages) */
+@@ -146,7 +142,7 @@
+ 
+ #define CTX_FETCH(x)	(php_ffi_context*)zend_object_store_get_object(x TSRMLS_CC)
+ #define STRUCT_FETCH(x)	(php_ffi_struct*)zend_object_store_get_object(x TSRMLS_CC)
+-#define PHP_FFI_THROW(msg)	zend_throw_exception(zend_exception_get_default(), msg, 0 TSRMLS_CC)
++#define PHP_FFI_THROW(msg)	zend_throw_exception(zend_exception_get_default(TSRMLS_C), msg, 0 TSRMLS_CC)
+ 
+ int php_ffi_zval_to_native(void **mem, int *need_free, zval *val, struct php_ffi_typed_arg *argtype TSRMLS_DC);
+ int php_ffi_native_to_zval(void *mem, struct php_ffi_typed_arg *argtype, zval *val TSRMLS_DC);
+
+Property changes on: php_ffi_internal.h
+___________________________________________________________________
+Modified: cvs2svn:cvs-rev
+## -1 +1 ##
+-1.7
+\ No newline at end of property
++1.9
+\ No newline at end of property
+Index: ffi_parser_util.c
+===================================================================
+--- ffi_parser_util.c	(.../tags/RELEASE_0_3)
++++ ffi_parser_util.c	(.../trunk)
+@@ -12,7 +12,7 @@
+   | obtain it through the world-wide-web, please send a note to          |
+   | license at php.net so we can mail you a copy immediately.               |
+   +----------------------------------------------------------------------+
+-  | Author: Wez Furlong  <wez at thebrainroom.com>                          |
++  | Author: Wez Furlong  <wez at php.net>                                   |
+   +----------------------------------------------------------------------+
+ */
+ 
+@@ -121,11 +121,11 @@
+ 	CTX_TSRMLS_FETCH();
+ 
+ 	tdef.nfields = ctx->n_args;
+-	tdef.ffi_t.elements = emalloc((tdef.nfields + 1) * sizeof(ffi_type *));
++	tdef.ffi_t.elements = safe_emalloc((tdef.nfields + 1), sizeof(ffi_type *), 0);
+ 	tdef.ffi_t.elements[tdef.nfields] = NULL; /* ffi wants a NULL terminated array */
+ 	tdef.struct_name = estrndup(struct_name.val, struct_name.len);
+-	tdef.field_names = emalloc(tdef.nfields * sizeof(char*));
+-	tdef.field_types = emalloc(tdef.nfields * sizeof(struct php_ffi_field_def));
++	tdef.field_names = safe_emalloc(tdef.nfields, sizeof(char*), 0);
++	tdef.field_types = safe_emalloc(tdef.nfields, sizeof(struct php_ffi_field_def), 0);
+ 	
+ 	for (i = 0; i < tdef.nfields; i++) {
+ 		tdef.field_types[i].offset = offset;
+
+Property changes on: ffi_parser_util.c
+___________________________________________________________________
+Modified: cvs2svn:cvs-rev
+## -1 +1 ##
+-1.2
+\ No newline at end of property
++1.3
+\ No newline at end of property
+Index: php_ffi.h
+===================================================================
+--- php_ffi.h	(.../tags/RELEASE_0_3)
++++ php_ffi.h	(.../trunk)
+@@ -12,7 +12,7 @@
+   | obtain it through the world-wide-web, please send a note to          |
+   | license at php.net so we can mail you a copy immediately.               |
+   +----------------------------------------------------------------------+
+-  | Author: Wez Furlong  <wez at thebrainroom.com>                          |
++  | Author: Wez Furlong  <wez at php.net>                                   |
+   +----------------------------------------------------------------------+
+ */
+ 
+@@ -24,6 +24,8 @@
+ extern zend_module_entry ffi_module_entry;
+ #define phpext_ffi_ptr &ffi_module_entry
+ 
++#define PHP_FFI_VERSION "0.4.0-dev"
++
+ #ifdef PHP_WIN32
+ #define PHP_FFI_API __declspec(dllexport)
+ #else
+@@ -30,6 +32,13 @@
+ #define PHP_FFI_API
+ #endif
+ 
++#ifndef  Z_SET_REFCOUNT_P
++# if PHP_MAJOR_VERSION < 6 && (PHP_MAJOR_VERSION == 5 && PHP_MINOR_VERSION < 3)
++#  define Z_SET_REFCOUNT_P(pz, rc)  pz->refcount = rc 
++#  define Z_UNSET_ISREF_P(pz) pz->is_ref = 0 
++# endif
++#endif
++
+ #ifdef ZTS
+ #include "TSRM.h"
+ #endif
+@@ -43,8 +52,8 @@
+ zend_object_value php_ffi_context_object_new(zend_class_entry *ce TSRMLS_DC);
+ zend_object_value php_ffi_struct_object_new(zend_class_entry *ce TSRMLS_DC);
+ extern zend_class_entry *php_ffi_struct_class_entry, *php_ffi_context_class_entry;
+-extern function_entry php_ffi_struct_funcs[];
+-extern function_entry php_ffi_context_funcs[];
++extern zend_function_entry php_ffi_struct_funcs[];
++extern zend_function_entry php_ffi_context_funcs[];
+ 
+ /* 
+   	Declare any global variables you may need between the BEGIN
+
+Property changes on: php_ffi.h
+___________________________________________________________________
+Modified: cvs2svn:cvs-rev
+## -1 +1 ##
+-1.4
+\ No newline at end of property
++1.6
+\ No newline at end of property
+Index: ffi_parser.c
+===================================================================
+--- ffi_parser.c	(.../tags/RELEASE_0_3)
++++ ffi_parser.c	(.../trunk)
+@@ -1,10 +1,10 @@
+ /* Driver template for the LEMON parser generator.
+ ** The author disclaims copyright to this source code.
+ */
+-/* First off, code is include which follows the "include" declaration
+-** in the input file. */
++/* First off, code is included that follows the "include" declaration
++** in the input grammar file. */
+ #include <stdio.h>
+-#line 7 "..\\pecl\\ffi\\ffi_parser.y"
++#line 7 "/home/wez.net/src/pecl-ffi/ffi_parser.y"
+ 
+ /*
+    +----------------------------------------------------------------------+
+@@ -20,7 +20,7 @@
+    | obtain it through the world-wide-web, please send a note to          |
+    | license at php.net so we can mail you a copy immediately.               |
+    +----------------------------------------------------------------------+
+-   | Author: Wez Furlong  <wez at thebrainroom.com>                          |
++   | Author: Wez Furlong  <wez at php.net>                                   |
+    +----------------------------------------------------------------------+
+  */
+ 
+@@ -89,8 +89,7 @@
+ 	}
+ 	return tokbuf;
+ }
+-
+-#line 94 "..\\pecl\\ffi\\ffi_parser.c"
++#line 93 "/home/wez.net/src/pecl-ffi/ffi_parser.c"
+ /* Next is all token values, in a form suitable for use by makeheaders.
+ ** This section will be null unless lemon is run with the -m switch.
+ */
+@@ -129,7 +128,8 @@
+ **                       This is typically a union of many types, one of
+ **                       which is php_ffi_parserTOKENTYPE.  The entry in the union
+ **                       for base tokens is called "yy0".
+-**    YYSTACKDEPTH       is the maximum depth of the parser's stack.
++**    YYSTACKDEPTH       is the maximum depth of the parser's stack.  If
++**                       zero the stack is dynamically sized using realloc()
+ **    php_ffi_parserARG_SDECL     A static variable declaration for the %extra_argument
+ **    php_ffi_parserARG_PDECL     A parameter declaration for the %extra_argument
+ **    php_ffi_parserARG_STORE     Code to store %extra_argument into yypParser
+@@ -139,16 +139,17 @@
+ **    YYERRORSYMBOL      is the code number of the error symbol.  If not
+ **                       defined, then do no error processing.
+ */
+-/*  */
+ #define YYCODETYPE unsigned char
+ #define YYNOCODE 35
+ #define YYACTIONTYPE unsigned char
+ #define php_ffi_parserTOKENTYPE  php_ffi_tokentype 
+ typedef union {
++  int yyinit;
+   php_ffi_parserTOKENTYPE yy0;
+-  int yy69;
+ } YYMINORTYPE;
++#ifndef YYSTACKDEPTH
+ #define YYSTACKDEPTH 100
++#endif
+ #define php_ffi_parserARG_SDECL  struct php_ffi_def_context *ctx ;
+ #define php_ffi_parserARG_PDECL , struct php_ffi_def_context *ctx 
+ #define php_ffi_parserARG_FETCH  struct php_ffi_def_context *ctx  = yypParser->ctx 
+@@ -155,13 +156,16 @@
+ #define php_ffi_parserARG_STORE yypParser->ctx  = ctx 
+ #define YYNSTATE 60
+ #define YYNRULE 29
+-#define YYERRORSYMBOL 22
+-#define YYERRSYMDT yy69
+ #define YY_NO_ACTION      (YYNSTATE+YYNRULE+2)
+ #define YY_ACCEPT_ACTION  (YYNSTATE+YYNRULE+1)
+ #define YY_ERROR_ACTION   (YYNSTATE+YYNRULE)
+ 
+-/* Next are that tables used to determine what action to take based on the
++/* The yyzerominor constant is used to initialize instances of
++** YYMINORTYPE objects to zero. */
++static const YYMINORTYPE yyzerominor = { 0 };
++
++
++/* Next are the tables used to determine what action to take based on the
+ ** current state and lookahead token.  These tables are used to implement
+ ** functions that take a state number and lookahead value and return an
+ ** action integer.  
+@@ -208,59 +212,51 @@
+ **                     shifting non-terminals after a reduce.
+ **  yy_default[]       Default action for each state.
+ */
+-static YYACTIONTYPE yy_action[] = {
+- /*     0 */    50,   25,   29,    7,   41,   47,   23,   24,   50,    5,
+- /*    10 */     4,    7,    2,   90,    1,    6,   30,    5,    4,   62,
+- /*    20 */     2,   28,    3,    6,   19,    8,   28,   50,   40,   19,
+- /*    30 */     8,   19,    8,   40,   13,   56,   49,   87,   72,   13,
+- /*    40 */    56,   17,   19,    8,   11,   19,    8,   83,   67,   10,
+- /*    50 */    16,   34,   17,   68,   25,   17,   32,   38,   35,   23,
+- /*    60 */    20,   53,   38,   35,   37,   38,   35,   36,   11,   42,
+- /*    70 */    41,   43,   67,    9,    9,   86,   31,   18,   76,   61,
+- /*    80 */    33,   85,   12,   15,   39,   73,   60,   21,   44,   75,
+- /*    90 */    22,   45,   46,   71,   48,   82,   51,   26,   52,   14,
+- /*   100 */    54,   27,   55,   57,   58,   59,
++static const YYACTIONTYPE yy_action[] = {
++ /*     0 */    90,   15,    1,   40,   41,   42,   43,   32,   29,   33,
++ /*    10 */    39,    1,   40,   41,   42,   43,   55,   29,   33,   47,
++ /*    20 */    16,    9,   17,   48,   13,    9,   18,   48,   45,   23,
++ /*    30 */    21,   11,   21,   14,   19,    3,   50,    3,   28,   25,
++ /*    40 */    28,   53,   28,   35,   27,   45,   27,   57,   27,   46,
++ /*    50 */    16,   30,   33,   37,   60,    8,   44,   10,   20,    2,
++ /*    60 */    49,   22,   24,    7,   51,    4,   91,   26,   34,   52,
++ /*    70 */    54,    5,   12,   91,   91,   31,    6,   58,   36,   56,
++ /*    80 */    38,   59,
+ };
+-static YYCODETYPE yy_lookahead[] = {
+- /*     0 */    18,   18,   18,   21,   25,   26,   23,   24,   18,   27,
+- /*    10 */    28,   21,   30,   31,   32,   33,    5,   27,   28,    0,
+- /*    20 */    30,    2,   32,   33,    5,    6,    2,   18,    9,    5,
+- /*    30 */     6,    5,    6,    9,   15,   16,   27,   11,    5,   15,
+- /*    40 */    16,   15,    5,    6,    1,    5,    6,   10,    5,    1,
+- /*    50 */     7,   13,   15,    5,   18,   15,   17,   18,   19,   23,
+- /*    60 */    24,   17,   18,   19,   17,   18,   19,    3,    1,    3,
+- /*    70 */    25,   26,    5,   20,   20,   11,    8,    5,   12,    0,
+- /*    80 */    11,   11,   29,   29,    5,    5,    0,   10,    5,   12,
+- /*    90 */    13,    4,   14,    5,   12,   10,    5,    5,    8,    5,
+- /*   100 */    11,   13,   13,   18,    5,   13,
++static const YYCODETYPE yy_lookahead[] = {
++ /*     0 */    18,   19,   20,   21,   22,   23,   24,   29,   30,   27,
++ /*    10 */    19,   20,   21,   22,   23,   24,   29,   30,   27,   25,
++ /*    20 */    26,    2,    3,    4,    5,    2,    3,    4,    1,   27,
++ /*    30 */    27,   12,   27,   14,   31,   32,   31,   32,   27,   28,
++ /*    40 */    27,   28,   27,   28,   33,    1,   33,   22,   33,   25,
++ /*    50 */    26,    4,   27,   27,    0,    4,    1,    4,   16,   15,
++ /*    60 */     8,    4,    4,   13,    8,    6,   34,    7,    4,    8,
++ /*    70 */     4,    9,    9,   34,   34,   10,    6,    8,    7,   11,
++ /*    80 */     4,    8,
+ };
+ #define YY_SHIFT_USE_DFLT (-1)
+-static signed char yy_shift_ofst[] = {
+- /*     0 */    24,   86,   19,   79,   -1,   -1,   -1,   -1,   67,   48,
+- /*    10 */    -1,   -1,   88,   94,   43,   33,   40,   72,   67,   80,
+- /*    20 */    77,   77,   -1,   37,   85,   92,   88,   -1,   40,   11,
+- /*    30 */    68,   26,   69,   38,   -1,   64,   26,   70,   79,   -1,
+- /*    40 */    83,   66,   83,   77,   87,   78,   -1,   82,   40,   -1,
+- /*    50 */    91,   90,   26,   89,   89,   -1,   40,   99,   92,   -1,
++#define YY_SHIFT_MAX 38
++static const signed char yy_shift_ofst[] = {
++ /*     0 */    19,   19,   23,   23,   23,   23,   23,   23,   44,   27,
++ /*    10 */    27,   47,   47,   23,   23,   54,   55,   51,   53,   42,
++ /*    20 */    52,   57,   56,   58,   59,   60,   61,   62,   66,   63,
++ /*    30 */    65,   68,   50,   64,   70,   71,   69,   76,   73,
+ };
+-#define YY_REDUCE_USE_DFLT (-22)
+-static signed char yy_reduce_ofst[] = {
+- /*     0 */   -18,  -22,  -10,  -22,  -22,  -22,  -22,  -22,   53,  -22,
+- /*    10 */   -22,  -22,  -22,  -22,   54,  -22,   36,  -22,   54,  -22,
+- /*    20 */   -22,  -22,  -22,  -17,  -22,  -22,  -22,  -22,  -16,  -22,
+- /*    30 */   -22,   39,  -22,  -22,  -22,  -22,   47,  -22,  -22,  -22,
+- /*    40 */   -21,  -22,   45,  -22,  -22,  -22,  -22,  -22,    9,  -22,
+- /*    50 */   -22,  -22,   44,  -22,  -22,  -22,   85,  -22,  -22,  -22,
++#define YY_REDUCE_USE_DFLT (-23)
++#define YY_REDUCE_MAX 14
++static const signed char yy_reduce_ofst[] = {
++ /*     0 */   -18,   -9,    3,    5,   11,   13,   15,   25,   -6,   24,
++ /*    10 */    -6,  -22,  -13,    2,   26,
+ };
+-static YYACTIONTYPE yy_default[] = {
+- /*     0 */    89,   89,   89,   89,   63,   64,   65,   66,   89,   89,
+- /*    10 */    70,   69,   89,   89,   89,   89,   89,   89,   89,   89,
+- /*    20 */    89,   89,   81,   89,   89,   89,   89,   84,   89,   89,
+- /*    30 */    89,   89,   89,   89,   74,   89,   89,   89,   89,   88,
+- /*    40 */    89,   89,   89,   89,   89,   89,   77,   89,   89,   78,
+- /*    50 */    89,   89,   89,   89,   89,   79,   89,   89,   89,   80,
++static const YYACTIONTYPE yy_default[] = {
++ /*     0 */    89,   62,   89,   83,   87,   87,   87,   89,   67,   67,
++ /*    10 */    67,   89,   89,   89,   89,   89,   68,   89,   89,   89,
++ /*    20 */    89,   89,   89,   89,   89,   89,   89,   86,   89,   76,
++ /*    30 */    89,   89,   89,   89,   89,   89,   89,   89,   89,   61,
++ /*    40 */    63,   64,   65,   66,   70,   69,   71,   72,   73,   81,
++ /*    50 */    82,   84,   74,   85,   88,   75,   77,   78,   79,   80,
+ };
+-#define YY_SZ_ACTTAB (sizeof(yy_action)/sizeof(yy_action[0]))
++#define YY_SZ_ACTTAB (int)(sizeof(yy_action)/sizeof(yy_action[0]))
+ 
+ /* The next table maps tokens into fallback tokens.  If a construct
+ ** like the following:
+@@ -267,7 +263,7 @@
+ ** 
+ **      %fallback ID X Y Z.
+ **
+-** appears in the grammer, then ID becomes a fallback token for X, Y,
++** appears in the grammar, then ID becomes a fallback token for X, Y,
+ ** and Z.  Whenever one of the tokens X, Y, or Z is input to the parser
+ ** but it does not parse, the type of the token is changed to ID and
+ ** the parse is retried before an error is thrown.
+@@ -290,11 +286,11 @@
+ **      It is sometimes called the "minor" token.
+ */
+ struct yyStackEntry {
+-  int stateno;       /* The state-number */
+-  int major;         /* The major token value.  This is the code
+-                     ** number for the token at this stack level */
+-  YYMINORTYPE minor; /* The user-supplied minor token value.  This
+-                     ** is the value of the token  */
++  YYACTIONTYPE stateno;  /* The state-number */
++  YYCODETYPE major;      /* The major token value.  This is the code
++                         ** number for the token at this stack level */
++  YYMINORTYPE minor;     /* The user-supplied minor token value.  This
++                         ** is the value of the token  */
+ };
+ typedef struct yyStackEntry yyStackEntry;
+ 
+@@ -302,10 +298,17 @@
+ ** the following structure */
+ struct yyParser {
+   int yyidx;                    /* Index of top element in stack */
++#ifdef YYTRACKMAXSTACKDEPTH
++  int yyidxMax;                 /* Maximum value of yyidx */
++#endif
+   int yyerrcnt;                 /* Shifts left before out of the error */
+-  yyStackEntry *yytop;          /* Pointer to the top stack element */
+   php_ffi_parserARG_SDECL                /* A place to hold %extra_argument */
++#if YYSTACKDEPTH<=0
++  int yystksz;                  /* Current side of the stack */
++  yyStackEntry *yystack;        /* The parser's stack */
++#else
+   yyStackEntry yystack[YYSTACKDEPTH];  /* The parser's stack */
++#endif
+ };
+ typedef struct yyParser yyParser;
+ 
+@@ -312,7 +315,7 @@
+ #ifndef NDEBUG
+ #include <stdio.h>
+ static FILE *yyTraceFILE = 0;
+-static const char *yyTracePrompt = 0;
++static char *yyTracePrompt = 0;
+ #endif /* NDEBUG */
+ 
+ #ifndef NDEBUG
+@@ -333,7 +336,7 @@
+ ** Outputs:
+ ** None.
+ */
+-void php_ffi_parserTrace(FILE *TraceFILE, const char *zTracePrompt){
++void php_ffi_parserTrace(FILE *TraceFILE, char *zTracePrompt){
+   yyTraceFILE = TraceFILE;
+   yyTracePrompt = zTracePrompt;
+   if( yyTraceFILE==0 ) yyTracePrompt = 0;
+@@ -344,16 +347,16 @@
+ #ifndef NDEBUG
+ /* For tracing shifts, the names of all terminals and nonterminals
+ ** are required.  The following table supplies these names */
+-static const char *yyTokenName[] = { 
+-  "$",             "ASTERISK",      "CALLBACK",      "COMMA",       
+-  "EQUALS",        "IDENT",         "INTRINSIC",     "LBRACE",      
+-  "LPAREN",        "LSQUARE",       "RBRACE",        "RPAREN",      
+-  "RSQUARE",       "SEMI",          "STRING",        "STRUCT",      
+-  "TYPEDEF",       "arg_list",      "arg_type",      "argument",    
+-  "asterisk_list",  "callback_def",  "error",         "field_def",   
+-  "field_list",    "func_attribute",  "func_attribute_list",  "func_proto",  
+-  "func_proto_with_attributes",  "optional_asterisk_list",  "top_item",      "top_level",   
+-  "top_list",      "type_def",    
++static const char *const yyTokenName[] = { 
++  "$",             "ASTERISK",      "INTRINSIC",     "STRUCT",      
++  "IDENT",         "CALLBACK",      "LPAREN",        "RPAREN",      
++  "SEMI",          "COMMA",         "EQUALS",        "STRING",      
++  "LSQUARE",       "RSQUARE",       "TYPEDEF",       "LBRACE",      
++  "RBRACE",        "error",         "top_level",     "top_list",    
++  "top_item",      "func_proto_with_attributes",  "func_proto",    "type_def",    
++  "callback_def",  "optional_asterisk_list",  "asterisk_list",  "arg_type",    
++  "arg_list",      "func_attribute_list",  "func_attribute",  "field_list",  
++  "field_def",     "argument",    
+ };
+ #endif /* NDEBUG */
+ 
+@@ -360,7 +363,7 @@
+ #ifndef NDEBUG
+ /* For tracing reduce actions, the names of all rules are required.
+ */
+-static const char *yyRuleName[] = {
++static const char *const yyRuleName[] = {
+  /*   0 */ "top_level ::= top_list",
+  /*   1 */ "top_list ::= top_item top_list",
+  /*   2 */ "top_list ::= top_item",
+@@ -393,21 +396,29 @@
+ };
+ #endif /* NDEBUG */
+ 
++
++#if YYSTACKDEPTH<=0
+ /*
+-** This function returns the symbolic name associated with a token
+-** value.
++** Try to increase the size of the parser stack.
+ */
+-const char *php_ffi_parserTokenName(int tokenType){
++static void yyGrowStack(yyParser *p){
++  int newSize;
++  yyStackEntry *pNew;
++
++  newSize = p->yystksz*2 + 100;
++  pNew = realloc(p->yystack, newSize*sizeof(pNew[0]));
++  if( pNew ){
++    p->yystack = pNew;
++    p->yystksz = newSize;
+ #ifndef NDEBUG
+-  if( tokenType>0 && (unsigned int) tokenType<(sizeof(yyTokenName)/sizeof(yyTokenName[0])) ){
+-    return yyTokenName[tokenType];
+-  }else{
+-    return "Unknown";
++    if( yyTraceFILE ){
++      fprintf(yyTraceFILE,"%sStack grows to %d entries!\n",
++              yyTracePrompt, p->yystksz);
++    }
++#endif
+   }
+-#else
+-  return "";
++}
+ #endif
+-}
+ 
+ /* 
+ ** This function allocates a new parser.
+@@ -426,6 +437,14 @@
+   pParser = (yyParser*)(*mallocProc)( (size_t)sizeof(yyParser) );
+   if( pParser ){
+     pParser->yyidx = -1;
++#ifdef YYTRACKMAXSTACKDEPTH
++    pParser->yyidxMax = 0;
++#endif
++#if YYSTACKDEPTH<=0
++    pParser->yystack = NULL;
++    pParser->yystksz = 0;
++    yyGrowStack(pParser);
++#endif
+   }
+   return pParser;
+ }
+@@ -435,7 +454,12 @@
+ ** "yymajor" is the symbol code, and "yypminor" is a pointer to
+ ** the value.
+ */
+-static void yy_destructor(YYCODETYPE yymajor, YYMINORTYPE *yypminor){
++static void yy_destructor(
++  yyParser *yypParser,    /* The parser */
++  YYCODETYPE yymajor,     /* Type code for object to destroy */
++  YYMINORTYPE *yypminor   /* The object to be destroyed */
++){
++  php_ffi_parserARG_FETCH;
+   switch( yymajor ){
+     /* Here is inserted the actions which take place when a
+     ** terminal or non-terminal is destroyed.  This can happen
+@@ -461,6 +485,7 @@
+ */
+ static int yy_pop_parser_stack(yyParser *pParser){
+   YYCODETYPE yymajor;
++  yyStackEntry *yytos = &pParser->yystack[pParser->yyidx];
+ 
+   if( pParser->yyidx<0 ) return 0;
+ #ifndef NDEBUG
+@@ -467,13 +492,12 @@
+   if( yyTraceFILE && pParser->yyidx>=0 ){
+     fprintf(yyTraceFILE,"%sPopping %s\n",
+       yyTracePrompt,
+-      yyTokenName[pParser->yytop->major]);
++      yyTokenName[yytos->major]);
+   }
+ #endif
+-  yymajor = pParser->yytop->major;
+-  yy_destructor( yymajor, &pParser->yytop->minor);
++  yymajor = yytos->major;
++  yy_destructor(pParser, yymajor, &yytos->minor);
+   pParser->yyidx--;
+-  pParser->yytop--;
+   return yymajor;
+ }
+ 
+@@ -496,10 +520,23 @@
+   yyParser *pParser = (yyParser*)p;
+   if( pParser==0 ) return;
+   while( pParser->yyidx>=0 ) yy_pop_parser_stack(pParser);
++#if YYSTACKDEPTH<=0
++  free(pParser->yystack);
++#endif
+   (*freeProc)((void*)pParser);
+ }
+ 
+ /*
++** Return the peak depth of the stack for a parser.
++*/
++#ifdef YYTRACKMAXSTACKDEPTH
++int php_ffi_parserStackPeak(void *p){
++  yyParser *pParser = (yyParser*)p;
++  return pParser->yyidxMax;
++}
++#endif
++
++/*
+ ** Find the appropriate action for a parser given the terminal
+ ** look-ahead token iLookAhead.
+ **
+@@ -509,34 +546,47 @@
+ */
+ static int yy_find_shift_action(
+   yyParser *pParser,        /* The parser */
+-  int iLookAhead            /* The look-ahead token */
++  YYCODETYPE iLookAhead     /* The look-ahead token */
+ ){
+   int i;
++  int stateno = pParser->yystack[pParser->yyidx].stateno;
+  
+-  /* if( pParser->yyidx<0 ) return YY_NO_ACTION;  */
+-  i = yy_shift_ofst[pParser->yytop->stateno];
+-  if( i==YY_SHIFT_USE_DFLT ){
+-    return yy_default[pParser->yytop->stateno];
++  if( stateno>YY_SHIFT_MAX || (i = yy_shift_ofst[stateno])==YY_SHIFT_USE_DFLT ){
++    return yy_default[stateno];
+   }
+-  if( iLookAhead==YYNOCODE ){
+-    return YY_NO_ACTION;
+-  }
++  assert( iLookAhead!=YYNOCODE );
+   i += iLookAhead;
+-  if( i<0 || (unsigned int)i>=YY_SZ_ACTTAB || yy_lookahead[i]!=iLookAhead ){
++  if( i<0 || i>=YY_SZ_ACTTAB || yy_lookahead[i]!=iLookAhead ){
++    if( iLookAhead>0 ){
+ #ifdef YYFALLBACK
+-    int iFallback;            /* Fallback token */
+-    if( iLookAhead<sizeof(yyFallback)/sizeof(yyFallback[0])
+-           && (iFallback = yyFallback[iLookAhead])!=0 ){
++      YYCODETYPE iFallback;            /* Fallback token */
++      if( iLookAhead<sizeof(yyFallback)/sizeof(yyFallback[0])
++             && (iFallback = yyFallback[iLookAhead])!=0 ){
+ #ifndef NDEBUG
+-      if( yyTraceFILE ){
+-        fprintf(yyTraceFILE, "%sFALLBACK %s => %s\n",
+-           yyTracePrompt, yyTokenName[iLookAhead], yyTokenName[iFallback]);
++        if( yyTraceFILE ){
++          fprintf(yyTraceFILE, "%sFALLBACK %s => %s\n",
++             yyTracePrompt, yyTokenName[iLookAhead], yyTokenName[iFallback]);
++        }
++#endif
++        return yy_find_shift_action(pParser, iFallback);
+       }
+ #endif
+-      return yy_find_shift_action(pParser, iFallback);
++#ifdef YYWILDCARD
++      {
++        int j = i - iLookAhead + YYWILDCARD;
++        if( j>=0 && j<YY_SZ_ACTTAB && yy_lookahead[j]==YYWILDCARD ){
++#ifndef NDEBUG
++          if( yyTraceFILE ){
++            fprintf(yyTraceFILE, "%sWILDCARD %s => %s\n",
++               yyTracePrompt, yyTokenName[iLookAhead], yyTokenName[YYWILDCARD]);
++          }
++#endif /* NDEBUG */
++          return yy_action[j];
++        }
++      }
++#endif /* YYWILDCARD */
+     }
+-#endif
+-    return yy_default[pParser->yytop->stateno];
++    return yy_default[stateno];
+   }else{
+     return yy_action[i];
+   }
+@@ -551,27 +601,50 @@
+ ** return YY_NO_ACTION.
+ */
+ static int yy_find_reduce_action(
+-  yyParser *pParser,        /* The parser */
+-  int iLookAhead            /* The look-ahead token */
++  int stateno,              /* Current state number */
++  YYCODETYPE iLookAhead     /* The look-ahead token */
+ ){
+   int i;
+- 
+-  i = yy_reduce_ofst[pParser->yytop->stateno];
+-  if( i==YY_REDUCE_USE_DFLT ){
+-    return yy_default[pParser->yytop->stateno];
++#ifdef YYERRORSYMBOL
++  if( stateno>YY_REDUCE_MAX ){
++    return yy_default[stateno];
+   }
+-  if( iLookAhead==YYNOCODE ){
+-    return YY_NO_ACTION;
+-  }
++#else
++  assert( stateno<=YY_REDUCE_MAX );
++#endif
++  i = yy_reduce_ofst[stateno];
++  assert( i!=YY_REDUCE_USE_DFLT );
++  assert( iLookAhead!=YYNOCODE );
+   i += iLookAhead;
+-  if( i<0 || (unsigned int)i>=YY_SZ_ACTTAB || yy_lookahead[i]!=iLookAhead ){
+-    return yy_default[pParser->yytop->stateno];
+-  }else{
+-    return yy_action[i];
++#ifdef YYERRORSYMBOL
++  if( i<0 || i>=YY_SZ_ACTTAB || yy_lookahead[i]!=iLookAhead ){
++    return yy_default[stateno];
+   }
++#else
++  assert( i>=0 && i<YY_SZ_ACTTAB );
++  assert( yy_lookahead[i]==iLookAhead );
++#endif
++  return yy_action[i];
+ }
+ 
+ /*
++** The following routine is called if the stack overflows.
++*/
++static void yyStackOverflow(yyParser *yypParser, YYMINORTYPE *yypMinor){
++   php_ffi_parserARG_FETCH;
++   yypParser->yyidx--;
++#ifndef NDEBUG
++   if( yyTraceFILE ){
++     fprintf(yyTraceFILE,"%sStack Overflow!\n",yyTracePrompt);
++   }
++#endif
++   while( yypParser->yyidx>=0 ) yy_pop_parser_stack(yypParser);
++   /* Here code is inserted which will execute if the parser
++   ** stack every overflows */
++   php_ffi_parserARG_STORE; /* Suppress warning about unused %extra_argument var */
++}
++
++/*
+ ** Perform a shift action.
+ */
+ static void yy_shift(
+@@ -578,28 +651,33 @@
+   yyParser *yypParser,          /* The parser to be shifted */
+   int yyNewState,               /* The new state to shift in */
+   int yyMajor,                  /* The major token to shift in */
+-  YYMINORTYPE *yypMinor         /* Pointer ot the minor token to shift in */
++  YYMINORTYPE *yypMinor         /* Pointer to the minor token to shift in */
+ ){
++  yyStackEntry *yytos;
+   yypParser->yyidx++;
+-  yypParser->yytop++;
++#ifdef YYTRACKMAXSTACKDEPTH
++  if( yypParser->yyidx>yypParser->yyidxMax ){
++    yypParser->yyidxMax = yypParser->yyidx;
++  }
++#endif
++#if YYSTACKDEPTH>0 
+   if( yypParser->yyidx>=YYSTACKDEPTH ){
+-     php_ffi_parserARG_FETCH;
+-     yypParser->yyidx--;
+-     yypParser->yytop--;
+-#ifndef NDEBUG
+-     if( yyTraceFILE ){
+-       fprintf(yyTraceFILE,"%sStack Overflow!\n",yyTracePrompt);
+-     }
++    yyStackOverflow(yypParser, yypMinor);
++    return;
++  }
++#else
++  if( yypParser->yyidx>=yypParser->yystksz ){
++    yyGrowStack(yypParser);
++    if( yypParser->yyidx>=yypParser->yystksz ){
++      yyStackOverflow(yypParser, yypMinor);
++      return;
++    }
++  }
+ #endif
+-     while( yypParser->yyidx>=0 ) yy_pop_parser_stack(yypParser);
+-     /* Here code is inserted which will execute if the parser
+-     ** stack every overflows */
+-     php_ffi_parserARG_STORE; /* Suppress warning about unused %extra_argument var */
+-     return;
+-  }
+-  yypParser->yytop->stateno = yyNewState;
+-  yypParser->yytop->major = yyMajor;
+-  yypParser->yytop->minor = *yypMinor;
++  yytos = &yypParser->yystack[yypParser->yyidx];
++  yytos->stateno = (YYACTIONTYPE)yyNewState;
++  yytos->major = (YYCODETYPE)yyMajor;
++  yytos->minor = *yypMinor;
+ #ifndef NDEBUG
+   if( yyTraceFILE && yypParser->yyidx>0 ){
+     int i;
+@@ -615,39 +693,39 @@
+ /* The following table contains information about every rule that
+ ** is used during the reduce.
+ */
+-static struct {
++static const struct {
+   YYCODETYPE lhs;         /* Symbol on the left-hand side of the rule */
+   unsigned char nrhs;     /* Number of right-hand side symbols in the rule */
+ } yyRuleInfo[] = {
+-  { 31, 1 },
+-  { 32, 2 },
+-  { 32, 1 },
+-  { 30, 1 },
+-  { 30, 1 },
+-  { 30, 1 },
+-  { 30, 1 },
+-  { 29, 0 },
+-  { 29, 1 },
++  { 18, 1 },
++  { 19, 2 },
++  { 19, 1 },
+   { 20, 1 },
+-  { 20, 2 },
+-  { 18, 2 },
+-  { 18, 3 },
+-  { 18, 1 },
+-  { 21, 7 },
+-  { 26, 3 },
++  { 20, 1 },
++  { 20, 1 },
++  { 20, 1 },
++  { 25, 0 },
++  { 25, 1 },
+   { 26, 1 },
+-  { 25, 3 },
+-  { 28, 4 },
+-  { 27, 6 },
+-  { 33, 4 },
+-  { 33, 6 },
+-  { 24, 2 },
+-  { 24, 1 },
+-  { 23, 3 },
+-  { 17, 3 },
+-  { 17, 1 },
+-  { 17, 0 },
+-  { 19, 2 },
++  { 26, 2 },
++  { 27, 2 },
++  { 27, 3 },
++  { 27, 1 },
++  { 24, 7 },
++  { 29, 3 },
++  { 29, 1 },
++  { 30, 3 },
++  { 21, 4 },
++  { 22, 6 },
++  { 23, 4 },
++  { 23, 6 },
++  { 31, 2 },
++  { 31, 1 },
++  { 32, 3 },
++  { 28, 3 },
++  { 28, 1 },
++  { 28, 0 },
++  { 33, 2 },
+ };
+ 
+ static void yy_accept(yyParser*);  /* Forward Declaration */
+@@ -666,15 +744,33 @@
+   yyStackEntry *yymsp;            /* The top of the parser's stack */
+   int yysize;                     /* Amount to pop the stack */
+   php_ffi_parserARG_FETCH;
+-  yymsp = yypParser->yytop;
++  yymsp = &yypParser->yystack[yypParser->yyidx];
+ #ifndef NDEBUG
+   if( yyTraceFILE && yyruleno>=0 
+-        && (unsigned int)yyruleno<sizeof(yyRuleName)/sizeof(yyRuleName[0]) ){
++        && yyruleno<(int)(sizeof(yyRuleName)/sizeof(yyRuleName[0])) ){
+     fprintf(yyTraceFILE, "%sReduce [%s].\n", yyTracePrompt,
+       yyRuleName[yyruleno]);
+   }
+ #endif /* NDEBUG */
+ 
++  /* Silence complaints from purify about yygotominor being uninitialized
++  ** in some cases when it is copied into the stack after the following
++  ** switch.  yygotominor is uninitialized when a rule reduces that does
++  ** not set the value of its left-hand side nonterminal.  Leaving the
++  ** value of the nonterminal uninitialized is utterly harmless as long
++  ** as the value is never used.  So really the only thing this code
++  ** accomplishes is to quieten purify.  
++  **
++  ** 2007-01-16:  The wireshark project (www.wireshark.org) reports that
++  ** without this code, their parser segfaults.  I'm not sure what there
++  ** parser is doing to make this happen.  This is the second bug report
++  ** from wireshark this week.  Clearly they are stressing Lemon in ways
++  ** that it has not been previously stressed...  (SQLite ticket #2172)
++  */
++  /*memset(&yygotominor, 0, sizeof(yygotominor));*/
++  yygotominor = yyzerominor;
++
++
+   switch( yyruleno ){
+   /* Beginning here are the reduction cases.  A typical example
+   ** follows:
+@@ -684,97 +780,79 @@
+   **  #line <lineno> <thisfile>
+   **     break;
+   */
+-      case 0:
+-        /* No destructor defined for top_list */
++      case 0: /* top_level ::= top_list */
++      case 1: /* top_list ::= top_item top_list */
++      case 2: /* top_list ::= top_item */
++      case 3: /* top_item ::= func_proto_with_attributes */
++      case 4: /* top_item ::= func_proto */
++      case 5: /* top_item ::= type_def */
++      case 6: /* top_item ::= callback_def */
++      case 15: /* func_attribute_list ::= func_attribute COMMA func_attribute_list */
++      case 16: /* func_attribute_list ::= func_attribute */
++      case 18: /* func_proto_with_attributes ::= LSQUARE func_attribute_list RSQUARE func_proto */
++      case 22: /* field_list ::= field_def field_list */
++      case 23: /* field_list ::= field_def */
++      case 25: /* arg_list ::= argument COMMA arg_list */
++      case 26: /* arg_list ::= argument */
++      case 27: /* arg_list ::= */
++#line 93 "/home/wez.net/src/pecl-ffi/ffi_parser.y"
++{
++}
++#line 802 "/home/wez.net/src/pecl-ffi/ffi_parser.c"
+         break;
+-      case 1:
+-        /* No destructor defined for top_item */
+-        /* No destructor defined for top_list */
+-        break;
+-      case 2:
+-        /* No destructor defined for top_item */
+-        break;
+-      case 3:
+-        /* No destructor defined for func_proto_with_attributes */
+-        break;
+-      case 4:
+-        /* No destructor defined for func_proto */
+-        break;
+-      case 5:
+-        /* No destructor defined for type_def */
+-        break;
+-      case 6:
+-        /* No destructor defined for callback_def */
+-        break;
+-      case 7:
+-#line 102 "..\\pecl\\ffi\\ffi_parser.y"
++      case 7: /* optional_asterisk_list ::= */
++#line 102 "/home/wez.net/src/pecl-ffi/ffi_parser.y"
+ { yygotominor.yy0.type.ptr_levels = 0; }
+-#line 712 "..\\pecl\\ffi\\ffi_parser.c"
++#line 807 "/home/wez.net/src/pecl-ffi/ffi_parser.c"
+         break;
+-      case 8:
+-#line 103 "..\\pecl\\ffi\\ffi_parser.y"
++      case 8: /* optional_asterisk_list ::= asterisk_list */
++#line 103 "/home/wez.net/src/pecl-ffi/ffi_parser.y"
+ { yygotominor.yy0 = yymsp[0].minor.yy0; }
+-#line 717 "..\\pecl\\ffi\\ffi_parser.c"
++#line 812 "/home/wez.net/src/pecl-ffi/ffi_parser.c"
+         break;
+-      case 9:
+-#line 105 "..\\pecl\\ffi\\ffi_parser.y"
++      case 9: /* asterisk_list ::= ASTERISK */
++#line 105 "/home/wez.net/src/pecl-ffi/ffi_parser.y"
+ { yygotominor.yy0.type.ptr_levels = 1; }
+-#line 722 "..\\pecl\\ffi\\ffi_parser.c"
+-        /* No destructor defined for ASTERISK */
++#line 817 "/home/wez.net/src/pecl-ffi/ffi_parser.c"
+         break;
+-      case 10:
+-#line 106 "..\\pecl\\ffi\\ffi_parser.y"
++      case 10: /* asterisk_list ::= asterisk_list ASTERISK */
++#line 106 "/home/wez.net/src/pecl-ffi/ffi_parser.y"
+ { yygotominor.yy0 = yymsp[-1].minor.yy0; yygotominor.yy0.type.ptr_levels++; }
+-#line 728 "..\\pecl\\ffi\\ffi_parser.c"
+-        /* No destructor defined for ASTERISK */
++#line 822 "/home/wez.net/src/pecl-ffi/ffi_parser.c"
+         break;
+-      case 11:
+-#line 108 "..\\pecl\\ffi\\ffi_parser.y"
++      case 11: /* arg_type ::= INTRINSIC optional_asterisk_list */
++#line 108 "/home/wez.net/src/pecl-ffi/ffi_parser.y"
+ { yygotominor.yy0 = yymsp[-1].minor.yy0; yygotominor.yy0.type.ptr_levels = yymsp[0].minor.yy0.type.ptr_levels; }
+-#line 734 "..\\pecl\\ffi\\ffi_parser.c"
++#line 827 "/home/wez.net/src/pecl-ffi/ffi_parser.c"
+         break;
+-      case 12:
+-#line 109 "..\\pecl\\ffi\\ffi_parser.y"
++      case 12: /* arg_type ::= STRUCT IDENT optional_asterisk_list */
++#line 109 "/home/wez.net/src/pecl-ffi/ffi_parser.y"
+ {
+    	yygotominor.yy0.type.intrinsic_type = FFI_TYPE_STRUCT;
+ 	yygotominor.yy0.type.struct_name = yymsp[-1].minor.yy0.ident;
+    	yygotominor.yy0.type.ptr_levels = yymsp[0].minor.yy0.type.ptr_levels;
+ }
+-#line 743 "..\\pecl\\ffi\\ffi_parser.c"
+-        /* No destructor defined for STRUCT */
++#line 836 "/home/wez.net/src/pecl-ffi/ffi_parser.c"
+         break;
+-      case 13:
+-#line 115 "..\\pecl\\ffi\\ffi_parser.y"
++      case 13: /* arg_type ::= IDENT */
++#line 115 "/home/wez.net/src/pecl-ffi/ffi_parser.y"
+ {
+ 	CTX_TSRMLS_FETCH();
+ 	/* TODO: lookup ident (including callback types) */
+ 	php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unrecognized type name `%s'", get_ident_string(yymsp[0].minor.yy0.ident));	
+ }
+-#line 753 "..\\pecl\\ffi\\ffi_parser.c"
++#line 845 "/home/wez.net/src/pecl-ffi/ffi_parser.c"
+         break;
+-      case 14:
+-#line 123 "..\\pecl\\ffi\\ffi_parser.y"
++      case 14: /* callback_def ::= CALLBACK arg_type IDENT LPAREN arg_list RPAREN SEMI */
++#line 123 "/home/wez.net/src/pecl-ffi/ffi_parser.y"
+ {
+ 	CTX_TSRMLS_FETCH();
+ 	php_error_docref(NULL TSRMLS_CC, E_WARNING, "callback support not complete");	
+ }
+-#line 761 "..\\pecl\\ffi\\ffi_parser.c"
+-        /* No destructor defined for CALLBACK */
+-        /* No destructor defined for LPAREN */
+-        /* No destructor defined for arg_list */
+-        /* No destructor defined for RPAREN */
+-        /* No destructor defined for SEMI */
++#line 853 "/home/wez.net/src/pecl-ffi/ffi_parser.c"
+         break;
+-      case 15:
+-        /* No destructor defined for func_attribute */
+-        /* No destructor defined for COMMA */
+-        /* No destructor defined for func_attribute_list */
+-        break;
+-      case 16:
+-        /* No destructor defined for func_attribute */
+-        break;
+-      case 17:
+-#line 131 "..\\pecl\\ffi\\ffi_parser.y"
++      case 17: /* func_attribute ::= IDENT EQUALS STRING */
++#line 131 "/home/wez.net/src/pecl-ffi/ffi_parser.y"
+ {
+ 	if (IDENT_EQUALS("lib", yymsp[-2].minor.yy0.ident)) {
+ 		ctx->libname = yymsp[0].minor.yy0.ident;
+@@ -783,90 +861,70 @@
+ 		php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unsupported attribute %s", get_ident_string(yymsp[-2].minor.yy0.ident));
+ 	}
+ }
+-#line 786 "..\\pecl\\ffi\\ffi_parser.c"
+-        /* No destructor defined for EQUALS */
++#line 865 "/home/wez.net/src/pecl-ffi/ffi_parser.c"
+         break;
+-      case 18:
+-        /* No destructor defined for LSQUARE */
+-        /* No destructor defined for func_attribute_list */
+-        /* No destructor defined for RSQUARE */
+-        break;
+-      case 19:
+-#line 142 "..\\pecl\\ffi\\ffi_parser.y"
++      case 19: /* func_proto ::= arg_type IDENT LPAREN arg_list RPAREN SEMI */
++#line 142 "/home/wez.net/src/pecl-ffi/ffi_parser.y"
+ {
+ 	yygotominor.yy0.func = php_ffi_parser_register_func(ctx, yymsp[-5].minor.yy0.type, yymsp[-4].minor.yy0.ident);
+ 	ctx->n_args = 0;
+ }
+-#line 800 "..\\pecl\\ffi\\ffi_parser.c"
+-        /* No destructor defined for LPAREN */
+-        /* No destructor defined for arg_list */
+-        /* No destructor defined for RPAREN */
+-        /* No destructor defined for SEMI */
++#line 873 "/home/wez.net/src/pecl-ffi/ffi_parser.c"
+         break;
+-      case 20:
+-#line 147 "..\\pecl\\ffi\\ffi_parser.y"
++      case 20: /* type_def ::= TYPEDEF arg_type IDENT SEMI */
++#line 147 "/home/wez.net/src/pecl-ffi/ffi_parser.y"
+ {
+ 	CTX_TSRMLS_FETCH();
+ 	php_error_docref(NULL TSRMLS_CC, E_WARNING, "aliasing typedefs are not yet implemented");
+ }
+-#line 812 "..\\pecl\\ffi\\ffi_parser.c"
+-        /* No destructor defined for TYPEDEF */
+-        /* No destructor defined for SEMI */
++#line 881 "/home/wez.net/src/pecl-ffi/ffi_parser.c"
+         break;
+-      case 21:
+-#line 152 "..\\pecl\\ffi\\ffi_parser.y"
++      case 21: /* type_def ::= STRUCT IDENT LBRACE field_list RBRACE SEMI */
++#line 152 "/home/wez.net/src/pecl-ffi/ffi_parser.y"
+ {
+ 	php_ffi_parser_register_type(ctx, yymsp[-4].minor.yy0.ident);	
+ 	ctx->n_args = 0;
+ }
+-#line 822 "..\\pecl\\ffi\\ffi_parser.c"
+-        /* No destructor defined for STRUCT */
+-        /* No destructor defined for LBRACE */
+-        /* No destructor defined for field_list */
+-        /* No destructor defined for RBRACE */
+-        /* No destructor defined for SEMI */
++#line 889 "/home/wez.net/src/pecl-ffi/ffi_parser.c"
+         break;
+-      case 22:
+-        /* No destructor defined for field_def */
+-        /* No destructor defined for field_list */
+-        break;
+-      case 23:
+-        /* No destructor defined for field_def */
+-        break;
+-      case 24:
+-#line 160 "..\\pecl\\ffi\\ffi_parser.y"
++      case 24: /* field_def ::= arg_type IDENT SEMI */
++#line 160 "/home/wez.net/src/pecl-ffi/ffi_parser.y"
+ {
+ 	php_ffi_parser_add_arg(ctx, yymsp[-2].minor.yy0.type, yymsp[-1].minor.yy0.ident);
+ }
+-#line 841 "..\\pecl\\ffi\\ffi_parser.c"
+-        /* No destructor defined for SEMI */
++#line 896 "/home/wez.net/src/pecl-ffi/ffi_parser.c"
+         break;
+-      case 25:
+-        /* No destructor defined for argument */
+-        /* No destructor defined for COMMA */
+-        /* No destructor defined for arg_list */
+-        break;
+-      case 26:
+-        /* No destructor defined for argument */
+-        break;
+-      case 27:
+-        break;
+-      case 28:
+-#line 168 "..\\pecl\\ffi\\ffi_parser.y"
++      case 28: /* argument ::= arg_type IDENT */
++#line 168 "/home/wez.net/src/pecl-ffi/ffi_parser.y"
+ {
+ 	php_ffi_parser_add_arg(ctx, yymsp[-1].minor.yy0.type, yymsp[0].minor.yy0.ident);
+ }
+-#line 859 "..\\pecl\\ffi\\ffi_parser.c"
++#line 903 "/home/wez.net/src/pecl-ffi/ffi_parser.c"
+         break;
+   };
+   yygoto = yyRuleInfo[yyruleno].lhs;
+   yysize = yyRuleInfo[yyruleno].nrhs;
+   yypParser->yyidx -= yysize;
+-  yypParser->yytop -= yysize;
+-  yyact = yy_find_reduce_action(yypParser,yygoto);
++  yyact = yy_find_reduce_action(yymsp[-yysize].stateno,(YYCODETYPE)yygoto);
+   if( yyact < YYNSTATE ){
+-    yy_shift(yypParser,yyact,yygoto,&yygotominor);
+-  }else if( yyact == YYNSTATE + YYNRULE + 1 ){
++#ifdef NDEBUG
++    /* If we are not debugging and the reduce action popped at least
++    ** one element off the stack, then we can push the new element back
++    ** onto the stack here, and skip the stack overflow test in yy_shift().
++    ** That gives a significant speed improvement. */
++    if( yysize ){
++      yypParser->yyidx++;
++      yymsp -= yysize-1;
++      yymsp->stateno = (YYACTIONTYPE)yyact;
++      yymsp->major = (YYCODETYPE)yygoto;
++      yymsp->minor = yygotominor;
++    }else
++#endif
++    {
++      yy_shift(yypParser,yyact,yygoto,&yygotominor);
++    }
++  }else{
++    assert( yyact == YYNSTATE + YYNRULE + 1 );
+     yy_accept(yypParser);
+   }
+ }
+@@ -886,9 +944,9 @@
+   while( yypParser->yyidx>=0 ) yy_pop_parser_stack(yypParser);
+   /* Here code is inserted which will be executed whenever the
+   ** parser fails */
+-#line 5 "..\\pecl\\ffi\\ffi_parser.y"
++#line 5 "/home/wez.net/src/pecl-ffi/ffi_parser.y"
+  ctx->failed = 1; printf("FAIL: parser failed - %d errors\n", ctx->errors); 
+-#line 891 "..\\pecl\\ffi\\ffi_parser.c"
++#line 950 "/home/wez.net/src/pecl-ffi/ffi_parser.c"
+   php_ffi_parserARG_STORE; /* Suppress warning about unused %extra_argument variable */
+ }
+ 
+@@ -902,9 +960,9 @@
+ ){
+   php_ffi_parserARG_FETCH;
+ #define TOKEN (yyminor.yy0)
+-#line 6 "..\\pecl\\ffi\\ffi_parser.y"
++#line 6 "/home/wez.net/src/pecl-ffi/ffi_parser.y"
+  ctx->errors++; printf("SYNTAX: entering error recovery near token %s\n", php_ffi_get_token_string(yymajor, TOKEN)); 
+-#line 907 "..\\pecl\\ffi\\ffi_parser.c"
++#line 966 "/home/wez.net/src/pecl-ffi/ffi_parser.c"
+   php_ffi_parserARG_STORE; /* Suppress warning about unused %extra_argument variable */
+ }
+ 
+@@ -954,18 +1012,26 @@
+   YYMINORTYPE yyminorunion;
+   int yyact;            /* The parser action. */
+   int yyendofinput;     /* True if we are at the end of input */
++#ifdef YYERRORSYMBOL
+   int yyerrorhit = 0;   /* True if yymajor has invoked an error */
++#endif
+   yyParser *yypParser;  /* The parser */
+ 
+   /* (re)initialize the parser, if necessary */
+   yypParser = (yyParser*)yyp;
+   if( yypParser->yyidx<0 ){
+-    if( yymajor==0 ) return;
++#if YYSTACKDEPTH<=0
++    if( yypParser->yystksz <=0 ){
++      /*memset(&yyminorunion, 0, sizeof(yyminorunion));*/
++      yyminorunion = yyzerominor;
++      yyStackOverflow(yypParser, &yyminorunion);
++      return;
++    }
++#endif
+     yypParser->yyidx = 0;
+     yypParser->yyerrcnt = -1;
+-    yypParser->yytop = &yypParser->yystack[0];
+-    yypParser->yytop->stateno = 0;
+-    yypParser->yytop->major = 0;
++    yypParser->yystack[0].stateno = 0;
++    yypParser->yystack[0].major = 0;
+   }
+   yyminorunion.yy0 = yyminor;
+   yyendofinput = (yymajor==0);
+@@ -978,18 +1044,19 @@
+ #endif
+ 
+   do{
+-    yyact = yy_find_shift_action(yypParser,yymajor);
++    yyact = yy_find_shift_action(yypParser,(YYCODETYPE)yymajor);
+     if( yyact<YYNSTATE ){
++      assert( !yyendofinput );  /* Impossible to shift the $ token */
+       yy_shift(yypParser,yyact,yymajor,&yyminorunion);
+       yypParser->yyerrcnt--;
+-      if( yyendofinput && yypParser->yyidx>=0 ){
+-        yymajor = 0;
+-      }else{
+-        yymajor = YYNOCODE;
+-      }
++      yymajor = YYNOCODE;
+     }else if( yyact < YYNSTATE + YYNRULE ){
+       yy_reduce(yypParser,yyact-YYNSTATE);
+-    }else if( yyact == YY_ERROR_ACTION ){
++    }else{
++      assert( yyact == YY_ERROR_ACTION );
++#ifdef YYERRORSYMBOL
++      int yymx;
++#endif
+ #ifndef NDEBUG
+       if( yyTraceFILE ){
+         fprintf(yyTraceFILE,"%sSyntax Error!\n",yyTracePrompt);
+@@ -1018,7 +1085,8 @@
+       if( yypParser->yyerrcnt<0 ){
+         yy_syntax_error(yypParser,yymajor,yyminorunion);
+       }
+-      if( yypParser->yytop->major==YYERRORSYMBOL || yyerrorhit ){
++      yymx = yypParser->yystack[yypParser->yyidx].major;
++      if( yymx==YYERRORSYMBOL || yyerrorhit ){
+ #ifndef NDEBUG
+         if( yyTraceFILE ){
+           fprintf(yyTraceFILE,"%sDiscard input token %s\n",
+@@ -1025,21 +1093,23 @@
+              yyTracePrompt,yyTokenName[yymajor]);
+         }
+ #endif
+-        yy_destructor(yymajor,&yyminorunion);
++        yy_destructor(yypParser, (YYCODETYPE)yymajor,&yyminorunion);
+         yymajor = YYNOCODE;
+       }else{
+          while(
+           yypParser->yyidx >= 0 &&
+-          yypParser->yytop->major != YYERRORSYMBOL &&
+-          (yyact = yy_find_shift_action(yypParser,YYERRORSYMBOL)) >= YYNSTATE
++          yymx != YYERRORSYMBOL &&
++          (yyact = yy_find_reduce_action(
++                        yypParser->yystack[yypParser->yyidx].stateno,
++                        YYERRORSYMBOL)) >= YYNSTATE
+         ){
+           yy_pop_parser_stack(yypParser);
+         }
+         if( yypParser->yyidx < 0 || yymajor==0 ){
+-          yy_destructor(yymajor,&yyminorunion);
++          yy_destructor(yypParser,(YYCODETYPE)yymajor,&yyminorunion);
+           yy_parse_failed(yypParser);
+           yymajor = YYNOCODE;
+-        }else if( yypParser->yytop->major!=YYERRORSYMBOL ){
++        }else if( yymx!=YYERRORSYMBOL ){
+           YYMINORTYPE u2;
+           u2.YYERRSYMDT = 0;
+           yy_shift(yypParser,yyact,YYERRORSYMBOL,&u2);
+@@ -1061,25 +1131,13 @@
+         yy_syntax_error(yypParser,yymajor,yyminorunion);
+       }
+       yypParser->yyerrcnt = 3;
+-      yy_destructor(yymajor,&yyminorunion);
++      yy_destructor(yypParser,(YYCODETYPE)yymajor,&yyminorunion);
+       if( yyendofinput ){
+         yy_parse_failed(yypParser);
+       }
+       yymajor = YYNOCODE;
+ #endif
+-    }else{
+-      yy_accept(yypParser);
+-      yymajor = YYNOCODE;
+     }
+   }while( yymajor!=YYNOCODE && yypParser->yyidx>=0 );
+   return;
+ }
+-
+-/*
+-Local variables:
+-tab-width: 4
+-c-basic-offset: 4
+-End:
+-vim600: noet sw=4 ts=4 fdm=marker
+-vim<600: noet sw=4 ts=4
+-*/
+Index: tests/001.phpt
+===================================================================
+--- tests/001.phpt	(.../tags/RELEASE_0_3)
++++ tests/001.phpt	(.../trunk)
+@@ -2,9 +2,6 @@
+ Check for ffi presence
+ --SKIPIF--
+ <?php if (!extension_loaded("ffi")) print "skip"; ?>
+---POST--
+---GET--
+---INI--
+ --FILE--
+ <?php 
+ echo "ffi extension is available";
+
+Property changes on: tests/001.phpt
+___________________________________________________________________
+Modified: cvs2svn:cvs-rev
+## -1 +1 ##
+-1.1
+\ No newline at end of property
++1.2
+\ No newline at end of property
+Index: tests
+===================================================================
+--- tests	(.../tags/RELEASE_0_3)
++++ tests	(.../trunk)
+
+Property changes on: tests
+___________________________________________________________________
+Added: svn:ignore
+## -0,0 +1,7 ##
++phpt.*
++*.mem
++*.diff
++*.log
++*.exp
++*.out
++*.php
+Index: ffi_parser.h
+===================================================================
+--- ffi_parser.h	(.../tags/RELEASE_0_3)
++++ ffi_parser.h	(.../trunk)
+@@ -1,16 +1,16 @@
+ #define PHP_FFI_TOK_ASTERISK                        1
+-#define PHP_FFI_TOK_CALLBACK                        2
+-#define PHP_FFI_TOK_COMMA                           3
+-#define PHP_FFI_TOK_EQUALS                          4
+-#define PHP_FFI_TOK_IDENT                           5
+-#define PHP_FFI_TOK_INTRINSIC                       6
+-#define PHP_FFI_TOK_LBRACE                          7
+-#define PHP_FFI_TOK_LPAREN                          8
+-#define PHP_FFI_TOK_LSQUARE                         9
+-#define PHP_FFI_TOK_RBRACE                         10
+-#define PHP_FFI_TOK_RPAREN                         11
+-#define PHP_FFI_TOK_RSQUARE                        12
+-#define PHP_FFI_TOK_SEMI                           13
+-#define PHP_FFI_TOK_STRING                         14
+-#define PHP_FFI_TOK_STRUCT                         15
+-#define PHP_FFI_TOK_TYPEDEF                        16
++#define PHP_FFI_TOK_INTRINSIC                       2
++#define PHP_FFI_TOK_STRUCT                          3
++#define PHP_FFI_TOK_IDENT                           4
++#define PHP_FFI_TOK_CALLBACK                        5
++#define PHP_FFI_TOK_LPAREN                          6
++#define PHP_FFI_TOK_RPAREN                          7
++#define PHP_FFI_TOK_SEMI                            8
++#define PHP_FFI_TOK_COMMA                           9
++#define PHP_FFI_TOK_EQUALS                         10
++#define PHP_FFI_TOK_STRING                         11
++#define PHP_FFI_TOK_LSQUARE                        12
++#define PHP_FFI_TOK_RSQUARE                        13
++#define PHP_FFI_TOK_TYPEDEF                        14
++#define PHP_FFI_TOK_LBRACE                         15
++#define PHP_FFI_TOK_RBRACE                         16
+Index: ffi_int64.c
+===================================================================
+--- ffi_int64.c	(.../tags/RELEASE_0_3)
++++ ffi_int64.c	(.../trunk)
+@@ -12,7 +12,7 @@
+    | obtain it through the world-wide-web, please send a note to          |
+    | license at php.net so we can mail you a copy immediately.               |
+    +----------------------------------------------------------------------+
+-   | Author: Wez Furlong  <wez at thebrainroom.com>                          |
++   | Author: Wez Furlong  <wez at php.net>                                   |
+    +----------------------------------------------------------------------+
+  */
+ 
+Index: ffi_library.c
+===================================================================
+--- ffi_library.c	(.../tags/RELEASE_0_3)
++++ ffi_library.c	(.../trunk)
+@@ -12,7 +12,7 @@
+    | obtain it through the world-wide-web, please send a note to          |
+    | license at php.net so we can mail you a copy immediately.               |
+    +----------------------------------------------------------------------+
+-   | Author: Wez Furlong  <wez at thebrainroom.com>                          |
++   | Author: Wez Furlong  <wez at php.net>                                   |
+    +----------------------------------------------------------------------+
+  */
+ 
+@@ -26,7 +26,7 @@
+ #include "php_ini.h"
+ #include "ext/standard/info.h"
+ #include "php_ffi.h"
+-#include "Zend/zend_default_classes.h"
++#include "Zend/zend_exceptions.h"
+ #include "Zend/zend_object_handlers.h"
+ 
+ #include "php_ffi_internal.h"
+@@ -150,7 +150,7 @@
+ 			case '=': tok = PHP_FFI_TOK_EQUALS; break;
+ 			case ',': tok = PHP_FFI_TOK_COMMA; break;
+ 			default:
+-				if (isalpha(*c)) {
++				if (isalpha(*c) || *c == '_') {
+ 		  			while (isalnum(*c) || *c == '_') {
+   						c++;
+ 					}
+@@ -224,7 +224,7 @@
+ 	parse_defs(obj, funcdefs);
+ }
+ 
+-function_entry php_ffi_context_funcs[] = {
++zend_function_entry php_ffi_context_funcs[] = {
+ 	{ "__construct", PHP_FN(php_ffi_context_create_instance), NULL },
+ 	{ NULL, NULL, NULL }
+ };
+@@ -279,7 +279,7 @@
+ 	}
+ }
+ 
+-static zval *php_ffi_property_read(zval *object, zval *member, zend_bool silent TSRMLS_DC)
++static zval *php_ffi_property_read(zval *object, zval *member, int type TSRMLS_DC)
+ {
+ 	zval *return_value;
+ 	php_ffi_context *obj;
+@@ -299,7 +299,7 @@
+ 	PHP_FFI_THROW("ffi_libraries have no properties");
+ }
+ 
+-static zval *php_ffi_read_dimension(zval *object, zval *offset TSRMLS_DC)
++static zval *php_ffi_read_dimension(zval *object, zval *offset, int type TSRMLS_DC)
+ {
+ 	zval *return_value;
+ 
+@@ -395,12 +395,21 @@
+ 	return func;
+ }
+ 
+-static union _zend_function *php_ffi_method_get(zval *object, char *name, int len TSRMLS_DC)
++static union _zend_function *php_ffi_method_get(
++#if PHP_API_VERSION >= 20041225
++	zval **object_pp,
++#else
++	zval *object,
++#endif
++	char *name, int len TSRMLS_DC)
+ {
+ 	zend_internal_function *f;
+ 	php_ffi_context *obj;
+ 	php_ffi_function *func;
+-	
++#if PHP_API_VERSION >= 20041225
++	zval *object = *object_pp;
++#endif
++
+ 	obj = CTX_FETCH(object);
+ 
+ 	func = bind_func(obj, name, len TSRMLS_CC);
+@@ -407,6 +416,7 @@
+ 
+ 	if (func == NULL) {
+ 		if (obj->ce != php_ffi_context_class_entry) {
++#if 0
+ 			zend_internal_function *call_user_call = emalloc(sizeof(zend_internal_function));
+ 		        call_user_call->type = ZEND_INTERNAL_FUNCTION;
+ 		        call_user_call->handler = zend_std_call_user_call;
+@@ -417,6 +427,9 @@
+ 		        call_user_call->function_name = estrndup(name, len);
+ 
+ 		        return (union _zend_function *)call_user_call;
++#else
++			php_error_docref(NULL TSRMLS_CC, E_ERROR, "this doesn't work right now (unable to call %s)", name);
++#endif
+ 		}
+ 
+ 		return NULL;
+@@ -565,14 +578,8 @@
+ 	return -1;
+ }
+ 
+-static int php_ffi_object_cast(zval *readobj, zval *writeobj, int type, int should_free TSRMLS_DC)
++static int php_ffi_object_cast(zval *readobj, zval *writeobj, int type TSRMLS_DC)
+ {
+-	if (should_free) {
+-		zval_dtor(writeobj);
+-	}
+-
+-	ZVAL_NULL(writeobj);
+-
+ 	return FAILURE;
+ }
+ 
+@@ -583,8 +590,8 @@
+ 	php_ffi_read_dimension,
+ 	php_ffi_write_dimension,
+ 	NULL,
+-	php_ffi_object_get,
+-	php_ffi_object_set,
++	NULL, /* php_ffi_object_get, */
++	NULL, /* php_ffi_object_set, */
+ 	php_ffi_property_exists,
+ 	php_ffi_property_delete,
+ 	php_ffi_dimension_exists,
+@@ -596,7 +603,8 @@
+ 	php_ffi_class_entry_get,
+ 	php_ffi_class_name_get,
+ 	php_ffi_objects_compare,
+-	php_ffi_object_cast
++	php_ffi_object_cast,
++	NULL, /* count */
+ };
+ 
+ void php_ffi_context_dtor(void *object, zend_object_handle handle TSRMLS_DC)
+@@ -637,7 +645,7 @@
+ 	zend_hash_init(&obj->types, 2, NULL, php_ffi_type_dtor, 0);
+ 	obj->ce = ce;
+ 	
+-	retval.handle = zend_objects_store_put(obj, php_ffi_context_dtor, php_ffi_object_clone TSRMLS_CC);
++	retval.handle = zend_objects_store_put(obj, php_ffi_context_dtor, NULL, php_ffi_object_clone TSRMLS_CC);
+ 	retval.handlers = &php_ffi_object_handlers;
+ 
+ 	return retval;
+
+Property changes on: ffi_library.c
+___________________________________________________________________
+Modified: cvs2svn:cvs-rev
+## -1 +1 ##
+-1.12
+\ No newline at end of property
++1.18
+\ No newline at end of property
+Index: examples/ctype.php
+===================================================================
+--- examples/ctype.php	(.../tags/RELEASE_0_3)
++++ examples/ctype.php	(.../trunk)
+@@ -1,4 +1,8 @@
+ <?php
++	if (!extension_loaded('ffi')) {
++		die("Please install FFI extension.\n");
++	}
++
+ 	/* FFI implementation of ext/ctype */
+ 
+ class ctype extends ffi
+@@ -47,5 +51,5 @@
+ }
+ 
+ 	$ctype = new ctype();
+-	var_dump($ctype->ctype_isdigit(7343));
++	var_dump($ctype->ctype_isdigit("7343"));
+ ?>
+\ No newline at end of file
+
+Property changes on: examples/ctype.php
+___________________________________________________________________
+Modified: cvs2svn:cvs-rev
+## -1 +1 ##
+-1.2
+\ No newline at end of property
++1.3
+\ No newline at end of property
+Index: examples/statgrab.php
+===================================================================
+--- examples/statgrab.php	(.../tags/RELEASE_0_3)
++++ examples/statgrab.php	(.../trunk)
+@@ -0,0 +1,136 @@
++<?php
++
++/* Interface to libstatgrab library via ffi */
++
++
++class statg extends ffi
++{
++	function __construct()
++	{
++		parent::__construct(<<<EOD
++struct load_stat_t {
++	double min1;
++	double min5;
++	double min15;
++};
++
++struct cpu_percent_t {
++	float user;
++	float kernel;
++	float idle;
++	float iowait;
++	float swap;
++	float nice;
++	long time_taken;
++};
++
++struct cpu_states_t {
++	sint64 user;
++	sint64 kernel;
++	sint64 idle;
++	sint64 iowait;
++	sint64 swap;
++	sint64 nice;
++	sint64 total;
++	long systime;
++};
++
++struct diskio_stat_t {
++	char *disk_name;
++	sint64 read_bytes;
++	sint64 write_bytes;
++	long systime;
++};
++
++struct general_stat_t {
++	char *os_name;
++	char *os_release;
++	char *os_version;
++	char *platform;
++	char *hostname;
++	long uptime;
++};
++
++struct mem_stat_t {
++	sint64 total;
++	sint64 free;
++	sint64 used;
++	sint64 cache;
++};
++
++struct swap_stat_t {
++	sint64 total;
++	sint64 used;
++	sint64 free;
++};
++
++struct network_stat_t {
++	char *interface_name;
++	sint64 tx;
++	sint64 rx;
++	long systime;
++};
++
++struct page_stat_t {
++	sint64 pages_pagein;
++	sint64 pages_pageout;
++	long systime;
++};
++
++struct process_stat_t {
++	int total;
++	int running;
++	int sleeping;
++	int stopped;
++	int zombie;
++};
++
++struct user_stat_t {
++	char *name_list;
++	int num_entries;
++};
++
++[lib='libstatgrab.so'] 
++	struct load_stat_t *get_load_stats();
++	struct cpu_percent_t *cpu_percent_usage();
++	struct cpu_states_t *get_cpu_totals();
++	struct cpu_states_t *get_cpu_diff();
++	struct diskio_stat_t *get_diskio_stats(int entries);
++	struct diskio_stat_t *get_diskio_stats_diff(int entries);
++	struct general_stat_t *get_general_stats();
++	struct mem_stat_t *get_memory_stats();
++	struct swap_stat_t *get_swap_stats();
++	struct network_stat_t *get_network_stats(int entries);
++	struct network_stat_t *get_network_stats_diff(int entries);
++	struct page_stat_t *get_page_stats();
++	struct page_stat_t *get_page_stats_diff();
++	struct process_stat_t *get_process_stats();
++	struct user_stat_t *get_user_stats();
++	void statgrab_init();
++	int statgrab_drop_privileges();
++
++EOD
++		
++		);
++
++		/* some initialization routines */
++		$this->statgrab_init();
++		if ($this->statgrab_drop_privileges() != 0) {
++			throw new Exception('Failed to initialize statgrab');
++		}
++	}
++}
++
++/* Sample usage */
++
++$ffi = new statg();
++
++$ls = $ffi->get_load_stats();
++var_dump($ls->min1, $ls->min5, $ls->min15);
++
++$ps = $ffi->get_process_stats();
++var_dump($ps->total);
++
++$us = $ffi->get_user_stats();
++var_dump($us->name_list);
++?>
+\ No newline at end of file
+
+Property changes on: examples/statgrab.php
+___________________________________________________________________
+Added: cvs2svn:cvs-rev
+## -0,0 +1 ##
++1.1
+\ No newline at end of property
+Added: svn:keywords
+## -0,0 +1 ##
++Id Rev Revision Date LastChangedDate LastChangedRevision Author LastChangedBy HeadURL URL
+\ No newline at end of property
+Added: svn:eol-style
+## -0,0 +1 ##
++native
+\ No newline at end of property
+Index: ffi_parser.y
+===================================================================
+--- ffi_parser.y	(.../tags/RELEASE_0_3)
++++ ffi_parser.y	(.../trunk)
+@@ -19,7 +19,7 @@
+    | obtain it through the world-wide-web, please send a note to          |
+    | license at php.net so we can mail you a copy immediately.               |
+    +----------------------------------------------------------------------+
+-   | Author: Wez Furlong  <wez at thebrainroom.com>                          |
++   | Author: Wez Furlong  <wez at php.net>                                   |
+    +----------------------------------------------------------------------+
+  */
+ 
+Index: ffi_struct.c
+===================================================================
+--- ffi_struct.c	(.../tags/RELEASE_0_3)
++++ ffi_struct.c	(.../trunk)
+@@ -12,7 +12,7 @@
+    | obtain it through the world-wide-web, please send a note to          |
+    | license at php.net so we can mail you a copy immediately.               |
+    +----------------------------------------------------------------------+
+-   | Author: Wez Furlong  <wez at thebrainroom.com>                          |
++   | Author: Wez Furlong  <wez at php.net>                                   |
+    +----------------------------------------------------------------------+
+  */
+ 
+@@ -26,7 +26,7 @@
+ #include "php_ini.h"
+ #include "ext/standard/info.h"
+ #include "php_ffi.h"
+-#include "Zend/zend_default_classes.h"
++#include "Zend/zend_exceptions.h"
+ 
+ #include "php_ffi_internal.h"
+ 
+@@ -69,7 +69,7 @@
+ 	}
+ }
+ 
+-static zval *php_ffi_struct_property_read(zval *object, zval *member, zend_bool silent TSRMLS_DC)
++static zval *php_ffi_struct_property_read(zval *object, zval *member, int type TSRMLS_DC)
+ {
+ 	zval *return_value;
+ 	php_ffi_struct *obj;
+@@ -77,12 +77,12 @@
+ 
+ 	MAKE_STD_ZVAL(return_value);
+ 	ZVAL_NULL(return_value);
+-	return_value->refcount = 0;
+-	return_value->is_ref = 0;
++	Z_SET_REFCOUNT_P(return_value, 0);
++	Z_UNSET_ISREF_P(return_value);
+ 
+ 	obj = STRUCT_FETCH(object);
+ 
+-	if (strcmp(Z_STRVAL_P(member), "__as_binary") == 0) {
++	if (strcmp(Z_STRVAL_P(member), "__asBinary") == 0) {
+ 		ZVAL_STRINGL(return_value, obj->mem, obj->memlen, 1);
+ 		return return_value;
+ 	} else if (strcmp(Z_STRVAL_P(member), "__sizeof") == 0) {
+@@ -116,7 +116,7 @@
+ 
+ 	obj = STRUCT_FETCH(object);
+ 
+-	if (strcmp(Z_STRVAL_P(member), "__as_binary") == 0) {
++	if (strcmp(Z_STRVAL_P(member), "__asBinary") == 0) {
+ 		if (Z_TYPE_P(value) != IS_STRING)  {
+ 			PHP_FFI_THROW("__as_binary value in assignment *MUST* be a string");
+ 			return;
+@@ -147,14 +147,14 @@
+ 	PHP_FFI_THROW("no such property");
+ }
+ 
+-static zval *php_ffi_struct_read_dimension(zval *object, zval *offset TSRMLS_DC)
++static zval *php_ffi_struct_read_dimension(zval *object, zval *offset, int type TSRMLS_DC)
+ {
+ 	zval *return_value;
+ 
+ 	MAKE_STD_ZVAL(return_value);
+ 	ZVAL_NULL(return_value);
+-	return_value->refcount = 0;
+-	return_value->is_ref = 0;
++	Z_SET_REFCOUNT_P(return_value, 0);
++	Z_UNSET_ISREF_P(return_value);
+ 
+ 	PHP_FFI_THROW("no dimension support yet");
+ 	return return_value;
+@@ -178,7 +178,6 @@
+ 
+ static int php_ffi_struct_property_exists(zval *object, zval *member, int check_empty TSRMLS_DC)
+ {
+-	zval *return_value;
+ 	php_ffi_struct *obj;
+ 	int i;
+ 
+@@ -217,12 +216,9 @@
+ 
+ static union _zend_function *php_ffi_struct_method_get(zval *object, char *name, int len TSRMLS_DC)
+ {
+-	zend_internal_function *f;
+-	php_ffi_struct *obj;
+-	php_ffi_function *func;
+-	
+-	obj = STRUCT_FETCH(object);
+-
++#if 0
++	php_ffi_struct *obj = STRUCT_FETCH(object);
++#endif
+ 	/* TODO: worry about pointers to functions? */
+ 	
+ 	return NULL;
+@@ -275,14 +271,8 @@
+ 	return -1;
+ }
+ 
+-static int php_ffi_struct_object_cast(zval *readobj, zval *writeobj, int type, int should_free TSRMLS_DC)
++static int php_ffi_struct_object_cast(zval *readobj, zval *writeobj, int type TSRMLS_DC)
+ {
+-	if (should_free) {
+-		zval_dtor(writeobj);
+-	}
+-
+-	ZVAL_NULL(writeobj);
+-
+ 	return FAILURE;
+ }
+ 
+@@ -293,8 +283,8 @@
+ 	php_ffi_struct_read_dimension,
+ 	php_ffi_struct_write_dimension,
+ 	NULL,
+-	php_ffi_struct_object_get,
+-	php_ffi_struct_object_set,
++	NULL, /* php_ffi_struct_object_get, */
++	NULL, /* php_ffi_struct_object_set, */
+ 	php_ffi_struct_property_exists,
+ 	php_ffi_struct_property_delete,
+ 	php_ffi_struct_dimension_exists,
+@@ -306,7 +296,8 @@
+ 	php_ffi_struct_class_entry_get,
+ 	php_ffi_struct_class_name_get,
+ 	php_ffi_struct_objects_compare,
+-	php_ffi_struct_object_cast
++	php_ffi_struct_object_cast,
++	NULL, /* count */
+ };
+ 
+ void php_ffi_struct_dtor(void *object, zend_object_handle handle TSRMLS_DC)
+@@ -344,7 +335,7 @@
+ 
+ 	obj = ecalloc(1, sizeof(*obj));
+ 	
+-	retval.handle = zend_objects_store_put(obj, php_ffi_struct_dtor, php_ffi_struct_object_clone TSRMLS_CC);
++	retval.handle = zend_objects_store_put(obj, php_ffi_struct_dtor, NULL, php_ffi_struct_object_clone TSRMLS_CC);
+ 	retval.handlers = &php_ffi_struct_object_handlers;
+ 
+ 	return retval;
+@@ -489,7 +480,7 @@
+ 
+ 			Z_TYPE_P(val) = IS_OBJECT;
+ 			Z_OBJ_HANDLE_P(val) = zend_objects_store_put(str,
+-					php_ffi_struct_dtor, php_ffi_struct_object_clone TSRMLS_CC);
++					php_ffi_struct_dtor, NULL, php_ffi_struct_object_clone TSRMLS_CC);
+ 			Z_OBJ_HT_P(val) = &php_ffi_struct_object_handlers;
+ 			return 1;
+ 		}
+
+Property changes on: ffi_struct.c
+___________________________________________________________________
+Modified: cvs2svn:cvs-rev
+## -1 +1 ##
+-1.11
+\ No newline at end of property
++1.18
+\ No newline at end of property
+Index: package.xml
+===================================================================
+Cannot display: file marked as a binary type.
+svn:mime-type = application/xml
+Index: package.xml
+===================================================================
+--- package.xml	(.../tags/RELEASE_0_3)
++++ package.xml	(.../trunk)
+
+Property changes on: package.xml
+___________________________________________________________________
+Modified: cvs2svn:cvs-rev
+## -1 +1 ##
+-1.5
+\ No newline at end of property
++1.6
+\ No newline at end of property
+Deleted: svn:mime-type
+## -1 +0,0 ##
+-application/xml
+\ No newline at end of property
+Index: ffi.php
+===================================================================
+--- ffi.php	(.../tags/RELEASE_0_3)
++++ ffi.php	(.../trunk)
+@@ -0,0 +1,19 @@
++<?
++if(!extension_loaded('ffi')) {
++	dl('ffi.' . PHP_SHLIB_SUFFIX);
++}
++$module = 'ffi';
++$functions = get_extension_funcs($module);
++echo "Functions available in the test extension:<br>\n";
++foreach($functions as $func) {
++    echo $func."<br>\n";
++}
++echo "<br>\n";
++$function = 'confirm_' . $module . '_compiled';
++if (extension_loaded($module)) {
++	$str = $function($module);
++} else {
++	$str = "Module $module is not compiled into PHP";
++}
++echo "$str\n";
++?>
+
+Property changes on: ffi.php
+___________________________________________________________________
+Added: cvs2svn:cvs-rev
+## -0,0 +1 ##
++1.1
+\ No newline at end of property
+Added: svn:keywords
+## -0,0 +1 ##
++Id Rev Revision Date LastChangedDate LastChangedRevision Author LastChangedBy HeadURL URL
+\ No newline at end of property
+Added: svn:eol-style
+## -0,0 +1 ##
++native
+\ No newline at end of property
+Index: libffi/src/x86/ffi64.c
+===================================================================
+--- libffi/src/x86/ffi64.c	(.../tags/RELEASE_0_3)
++++ libffi/src/x86/ffi64.c	(.../trunk)
+@@ -288,7 +288,7 @@
+   gprcount = ssecount = 0;
+   if (ecif->cif->rtype->type != FFI_TYPE_VOID 
+       && examine_argument (ecif->cif->rtype, 1, &g, &s) == 0)
+-    (void *)stack->gpr[gprcount++] = ecif->rvalue;
++    stack->gpr[gprcount++] = ecif->rvalue;
+ 
+   for (i=ecif->cif->nargs, p_arg=ecif->cif->arg_types, p_argv = ecif->avalue;
+        i!=0; i--, p_arg++, p_argv++)
+Index: libffi/src/x86/win32-msvc.c
+===================================================================
+--- libffi/src/x86/win32-msvc.c	(.../tags/RELEASE_0_3)
++++ libffi/src/x86/win32-msvc.c	(.../trunk)
+@@ -3,7 +3,7 @@
+ 	     Copyright (c) 2001  John Beniton
+ 	     Copyright (c) 2002  Ranjit Mathew
+ 	
+-	Ported to MSVC Intel syntax by Wez Furlong <wez at thebrainroom.com>		
++	Ported to MSVC Intel syntax by Wez Furlong <wez at php.net>		
+  
+    X86 Foreign Function Interface
+  
+Index: libffi/src/x86
+===================================================================
+--- libffi/src/x86	(.../tags/RELEASE_0_3)
++++ libffi/src/x86	(.../trunk)
+
+Property changes on: libffi/src/x86
+___________________________________________________________________
+Added: svn:ignore
+## -0,0 +1 ##
++*.lo
+Index: libffi/src
+===================================================================
+--- libffi/src	(.../tags/RELEASE_0_3)
++++ libffi/src	(.../trunk)
+
+Property changes on: libffi/src
+___________________________________________________________________
+Added: svn:ignore
+## -0,0 +1 ##
++*.lo
+Index: libffi/include/ffi.h.in
+===================================================================
+--- libffi/include/ffi.h.in	(.../tags/RELEASE_0_3)
++++ libffi/include/ffi.h.in	(.../trunk)
+@@ -101,15 +101,20 @@
+ # define SINT32 long
+ #endif
+ 
+-#if SIZEOF_INT == 8
+-# define UINT64  unsigned int
+-# define SINT64  int
+-#elif SIZEOF_LONG == 8
+-# define UINT64  unsigned long
+-# define SINT64  long
+-#elif SIZEOF_LONG_LONG == 8
+-# define UINT64  unsigned long long
+-# define SINT64  long long
++#ifdef PHP_WIN32
++# define UINT64  unsigned __int64
++# define SINT64  __int64
++#else
++# if SIZEOF_INT == 8
++#  define UINT64  unsigned int
++#  define SINT64  int
++# elif SIZEOF_LONG == 8
++#  define UINT64  unsigned long
++#  define SINT64  long
++# elif SIZEOF_LONG_LONG == 8
++#  define UINT64  unsigned long long
++#  define SINT64  long long
++# endif
+ #endif
+ 
+ #if SIZEOF_INT == 2
+
+Property changes on: libffi/include/ffi.h.in
+___________________________________________________________________
+Modified: cvs2svn:cvs-rev
+## -1 +1 ##
+-1.1
+\ No newline at end of property
++1.2
+\ No newline at end of property
+Index: libffi/include/fficonfig.h
+===================================================================
+--- libffi/include/fficonfig.h	(.../tags/RELEASE_0_3)
++++ libffi/include/fficonfig.h	(.../trunk)
+@@ -15,6 +15,8 @@
+ # define HAVE_MEMCPY 1
+ # define STDC_HEADERS 1
+ # define __i386__ 1
++#elif HAVE_CONFIG_H
++# include "config.h"
+ #else
+ # include "php_config.h"
+ #endif
+
+Property changes on: libffi/include/fficonfig.h
+___________________________________________________________________
+Modified: cvs2svn:cvs-rev
+## -1 +1 ##
+-1.1
+\ No newline at end of property
++1.2
+\ No newline at end of property
+Index: libffi/include
+===================================================================
+--- libffi/include	(.../tags/RELEASE_0_3)
++++ libffi/include	(.../trunk)
+
+Property changes on: libffi/include
+___________________________________________________________________
+Added: svn:ignore
+## -0,0 +1 ##
++ffi.h
+Index: .
+===================================================================
+--- .	(.../tags/RELEASE_0_3)
++++ .	(.../trunk)
+
+Property changes on: .
+___________________________________________________________________
+Added: svn:ignore
+## -0,0 +1,30 ##
++.deps
++*.lo
++*.la
++ffi_parser.out
++autom4te.cache
++configure
++config.log
++config.guess
++run-tests.php
++config.sub
++ltmain.sh
++Makefile.fragments
++Makefile.objects
++Makefile.global
++mkinstalldirs
++config.nice
++include
++configure.in
++build
++config.h.in
++autom4te.cache
++acinclude.m4
++missing
++aclocal.m4
++install-sh
++config.h
++modules
++Makefile
++config.status
++libtool
================================================================

---- gitweb:

http://git.pld-linux.org/gitweb.cgi/packages/php-pecl-ffi.git/commitdiff/d67e37e83ad41fd284edffdb6e2d11e33d99338d



More information about the pld-cvs-commit mailing list