diff options
author | Xinchen Hui <laruence@gmail.com> | 2014-04-23 00:17:29 +0800 |
---|---|---|
committer | Xinchen Hui <laruence@gmail.com> | 2014-04-23 00:17:29 +0800 |
commit | 97381369a3be5b917e968c33adb7b1af746ef904 (patch) | |
tree | 350bfd10b96e886471f46c23352b55bcd65658e2 /ext/sqlite3/php_sqlite3_structs.h | |
parent | c0b49a701a74f9be1f99f79c4334d4aecdf1f1c6 (diff) | |
download | php-git-97381369a3be5b917e968c33adb7b1af746ef904.tar.gz |
Refactored sqlite3 (all tests passes)
Diffstat (limited to 'ext/sqlite3/php_sqlite3_structs.h')
-rw-r--r-- | ext/sqlite3/php_sqlite3_structs.h | 38 |
1 files changed, 28 insertions, 10 deletions
diff --git a/ext/sqlite3/php_sqlite3_structs.h b/ext/sqlite3/php_sqlite3_structs.h index 5336d116fc..dd81317df2 100644 --- a/ext/sqlite3/php_sqlite3_structs.h +++ b/ext/sqlite3/php_sqlite3_structs.h @@ -43,7 +43,7 @@ struct php_sqlite3_bound_param { int name_len; long type; - zval *parameter; + zval parameter; }; struct php_sqlite3_fci { @@ -58,7 +58,7 @@ typedef struct _php_sqlite3_func { const char *func_name; int argc; - zval *func, *step, *fini; + zval func, step, fini; struct php_sqlite3_fci afunc, astep, afini; } php_sqlite3_func; @@ -67,13 +67,12 @@ typedef struct _php_sqlite3_collation { struct _php_sqlite3_collation *next; const char *collation_name; - zval *cmp_func; + zval cmp_func; struct php_sqlite3_fci fci; } php_sqlite3_collation; /* Structure for SQLite Database object. */ typedef struct _php_sqlite3_db_object { - zend_object zo; int initialised; sqlite3 *db; php_sqlite3_func *funcs; @@ -82,11 +81,18 @@ typedef struct _php_sqlite3_db_object { zend_bool exception; zend_llist free_list; + zend_object zo; } php_sqlite3_db_object; +static inline php_sqlite3_db_object *php_sqlite3_db_from_obj(zend_object *obj) { + return (php_sqlite3_db_object*)((char*)(obj) - XtOffsetOf(php_sqlite3_db_object, zo)); +} + +#define Z_SQLITE3_DB_P(zv) php_sqlite3_db_from_obj(Z_OBJ_P((zv))) + /* Structure for SQLite Database object. */ typedef struct _php_sqlite3_agg_context { - zval *zval_context; + zval zval_context; long row_count; } php_sqlite3_agg_context; @@ -95,34 +101,46 @@ typedef struct _php_sqlite3_result_object php_sqlite3_result; /* sqlite3 objects to be destroyed */ typedef struct _php_sqlite3_free_list { - zval *stmt_obj_zval; + zval stmt_obj_zval; php_sqlite3_stmt *stmt_obj; } php_sqlite3_free_list; /* Structure for SQLite Result object. */ struct _php_sqlite3_result_object { - zend_object zo; php_sqlite3_db_object *db_obj; php_sqlite3_stmt *stmt_obj; - zval *stmt_obj_zval; + zval stmt_obj_zval; int is_prepared_statement; int complete; + zend_object zo; }; +static inline php_sqlite3_result *php_sqlite3_result_from_obj(zend_object *obj) { + return (php_sqlite3_result*)((char*)(obj) - XtOffsetOf(php_sqlite3_result, zo)); +} + +#define Z_SQLITE3_RESULT_P(zv) php_sqlite3_result_from_obj(Z_OBJ_P((zv))) + /* Structure for SQLite Statement object. */ struct _php_sqlite3_stmt_object { - zend_object zo; sqlite3_stmt *stmt; php_sqlite3_db_object *db_obj; - zval *db_obj_zval; + zval db_obj_zval; int initialised; /* Keep track of the zvals for bound parameters */ HashTable *bound_params; + zend_object zo; }; +static inline php_sqlite3_stmt *php_sqlite3_stmt_from_obj(zend_object *obj) { + return (php_sqlite3_stmt*)((char*)(obj) - XtOffsetOf(php_sqlite3_stmt, zo)); +} + +#define Z_SQLITE3_STMT_P(zv) php_sqlite3_stmt_from_obj(Z_OBJ_P((zv))) + #endif |