Skip to content

Commit 8530915

Browse files
committed
Consolidate PHP 5 and 7 struct definitions into one file
1 parent 52266fb commit 8530915

File tree

4 files changed

+297
-449
lines changed

4 files changed

+297
-449
lines changed

php_phongo_classes.h

Lines changed: 70 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,76 @@
1919
#ifndef PHONGO_CLASSES_H
2020
#define PHONGO_CLASSES_H
2121

22+
#include "php_phongo_structs.h"
23+
2224
#if PHP_VERSION_ID >= 70000
23-
# include "php_phongo_structs-7.h"
25+
26+
static inline php_phongo_bulkwrite_t* php_bulkwrite_fetch_object(zend_object *obj) {
27+
return (php_phongo_bulkwrite_t *)((char *)obj - XtOffsetOf(php_phongo_bulkwrite_t, std));
28+
}
29+
static inline php_phongo_command_t* php_command_fetch_object(zend_object *obj) {
30+
return (php_phongo_command_t *)((char *)obj - XtOffsetOf(php_phongo_command_t, std));
31+
}
32+
static inline php_phongo_cursor_t* php_cursor_fetch_object(zend_object *obj) {
33+
return (php_phongo_cursor_t *)((char *)obj - XtOffsetOf(php_phongo_cursor_t, std));
34+
}
35+
static inline php_phongo_cursorid_t* php_cursorid_fetch_object(zend_object *obj) {
36+
return (php_phongo_cursorid_t *)((char *)obj - XtOffsetOf(php_phongo_cursorid_t, std));
37+
}
38+
static inline php_phongo_manager_t* php_manager_fetch_object(zend_object *obj) {
39+
return (php_phongo_manager_t *)((char *)obj - XtOffsetOf(php_phongo_manager_t, std));
40+
}
41+
static inline php_phongo_query_t* php_query_fetch_object(zend_object *obj) {
42+
return (php_phongo_query_t *)((char *)obj - XtOffsetOf(php_phongo_query_t, std));
43+
}
44+
static inline php_phongo_readconcern_t* php_readconcern_fetch_object(zend_object *obj) {
45+
return (php_phongo_readconcern_t *)((char *)obj - XtOffsetOf(php_phongo_readconcern_t, std));
46+
}
47+
static inline php_phongo_readpreference_t* php_readpreference_fetch_object(zend_object *obj) {
48+
return (php_phongo_readpreference_t *)((char *)obj - XtOffsetOf(php_phongo_readpreference_t, std));
49+
}
50+
static inline php_phongo_server_t* php_server_fetch_object(zend_object *obj) {
51+
return (php_phongo_server_t *)((char *)obj - XtOffsetOf(php_phongo_server_t, std));
52+
}
53+
static inline php_phongo_writeconcern_t* php_writeconcern_fetch_object(zend_object *obj) {
54+
return (php_phongo_writeconcern_t *)((char *)obj - XtOffsetOf(php_phongo_writeconcern_t, std));
55+
}
56+
static inline php_phongo_writeconcernerror_t* php_writeconcernerror_fetch_object(zend_object *obj) {
57+
return (php_phongo_writeconcernerror_t *)((char *)obj - XtOffsetOf(php_phongo_writeconcernerror_t, std));
58+
}
59+
static inline php_phongo_writeerror_t* php_writeerror_fetch_object(zend_object *obj) {
60+
return (php_phongo_writeerror_t *)((char *)obj - XtOffsetOf(php_phongo_writeerror_t, std));
61+
}
62+
static inline php_phongo_writeresult_t* php_writeresult_fetch_object(zend_object *obj) {
63+
return (php_phongo_writeresult_t *)((char *)obj - XtOffsetOf(php_phongo_writeresult_t, std));
64+
}
65+
static inline php_phongo_binary_t* php_binary_fetch_object(zend_object *obj) {
66+
return (php_phongo_binary_t *)((char *)obj - XtOffsetOf(php_phongo_binary_t, std));
67+
}
68+
static inline php_phongo_decimal128_t* php_decimal128_fetch_object(zend_object *obj) {
69+
return (php_phongo_decimal128_t *)((char *)obj - XtOffsetOf(php_phongo_decimal128_t, std));
70+
}
71+
static inline php_phongo_javascript_t* php_javascript_fetch_object(zend_object *obj) {
72+
return (php_phongo_javascript_t *)((char *)obj - XtOffsetOf(php_phongo_javascript_t, std));
73+
}
74+
static inline php_phongo_maxkey_t* php_maxkey_fetch_object(zend_object *obj) {
75+
return (php_phongo_maxkey_t *)((char *)obj - XtOffsetOf(php_phongo_maxkey_t, std));
76+
}
77+
static inline php_phongo_minkey_t* php_minkey_fetch_object(zend_object *obj) {
78+
return (php_phongo_minkey_t *)((char *)obj - XtOffsetOf(php_phongo_minkey_t, std));
79+
}
80+
static inline php_phongo_objectid_t* php_objectid_fetch_object(zend_object *obj) {
81+
return (php_phongo_objectid_t *)((char *)obj - XtOffsetOf(php_phongo_objectid_t, std));
82+
}
83+
static inline php_phongo_regex_t* php_regex_fetch_object(zend_object *obj) {
84+
return (php_phongo_regex_t *)((char *)obj - XtOffsetOf(php_phongo_regex_t, std));
85+
}
86+
static inline php_phongo_timestamp_t* php_timestamp_fetch_object(zend_object *obj) {
87+
return (php_phongo_timestamp_t *)((char *)obj - XtOffsetOf(php_phongo_timestamp_t, std));
88+
}
89+
static inline php_phongo_utcdatetime_t* php_utcdatetime_fetch_object(zend_object *obj) {
90+
return (php_phongo_utcdatetime_t *)((char *)obj - XtOffsetOf(php_phongo_utcdatetime_t, std));
91+
}
2492

2593
# define Z_COMMAND_OBJ_P(zv) (php_command_fetch_object(Z_OBJ_P(zv)))
2694
# define Z_CURSOR_OBJ_P(zv) (php_cursor_fetch_object(Z_OBJ_P(zv)))
@@ -70,8 +138,6 @@
70138

71139
#else
72140

73-
# include "php_phongo_structs-5.h"
74-
75141
# define Z_COMMAND_OBJ_P(zv) ((php_phongo_command_t *)zend_object_store_get_object(zv TSRMLS_CC))
76142
# define Z_CURSOR_OBJ_P(zv) ((php_phongo_cursor_t *)zend_object_store_get_object(zv TSRMLS_CC))
77143
# define Z_CURSORID_OBJ_P(zv) ((php_phongo_cursorid_t *)zend_object_store_get_object(zv TSRMLS_CC))
@@ -117,6 +183,7 @@
117183
# define Z_OBJ_REGEX(zo) ((php_phongo_regex_t *)zo)
118184
# define Z_OBJ_TIMESTAMP(zo) ((php_phongo_timestamp_t *)zo)
119185
# define Z_OBJ_UTCDATETIME(zo) ((php_phongo_utcdatetime_t *)zo)
186+
120187
#endif
121188

122189
typedef struct {

php_phongo_structs-5.h

Lines changed: 0 additions & 189 deletions
This file was deleted.

0 commit comments

Comments
 (0)