@@ -47,20 +47,20 @@ PHONGO_API zend_class_entry *php_phongo_javascript_ce;
47
47
zend_object_handlers php_phongo_handler_javascript ;
48
48
49
49
/* Initialize the object from a string and return whether it was successful. */
50
- static bool php_phongo_javascript_init (php_phongo_javascript_t * intern , const char * javascript , phongo_zpp_char_len javascript_len , zval * scope TSRMLS_DC )
50
+ static bool php_phongo_javascript_init (php_phongo_javascript_t * intern , const char * code , phongo_zpp_char_len code_len , zval * scope TSRMLS_DC )
51
51
{
52
52
if (scope && Z_TYPE_P (scope ) != IS_OBJECT && Z_TYPE_P (scope ) != IS_ARRAY && Z_TYPE_P (scope ) != IS_NULL ) {
53
53
return false;
54
54
}
55
55
56
- intern -> javascript = estrndup (javascript , javascript_len );
57
- intern -> javascript_len = javascript_len ;
56
+ intern -> code = estrndup (code , code_len );
57
+ intern -> code_len = code_len ;
58
58
59
59
if (scope && (Z_TYPE_P (scope ) == IS_OBJECT || Z_TYPE_P (scope ) == IS_ARRAY )) {
60
- intern -> document = bson_new ();
61
- phongo_zval_to_bson (scope , PHONGO_BSON_NONE , intern -> document , NULL TSRMLS_CC );
60
+ intern -> scope = bson_new ();
61
+ phongo_zval_to_bson (scope , PHONGO_BSON_NONE , intern -> scope , NULL TSRMLS_CC );
62
62
} else {
63
- intern -> document = NULL ;
63
+ intern -> scope = NULL ;
64
64
}
65
65
66
66
return true;
@@ -70,47 +70,47 @@ static bool php_phongo_javascript_init(php_phongo_javascript_t *intern, const ch
70
70
static bool php_phongo_javascript_init_from_hash (php_phongo_javascript_t * intern , HashTable * props TSRMLS_DC )
71
71
{
72
72
#if PHP_VERSION_ID >= 70000
73
- zval * javascript , * scope ;
73
+ zval * code , * scope ;
74
74
75
- if ((javascript = zend_hash_str_find (props , "javascript " , sizeof ("javascript " )- 1 )) && Z_TYPE_P (javascript ) == IS_STRING ) {
75
+ if ((code = zend_hash_str_find (props , "code " , sizeof ("code " )- 1 )) && Z_TYPE_P (code ) == IS_STRING ) {
76
76
scope = zend_hash_str_find (props , "scope" , sizeof ("scope" )- 1 );
77
77
78
- return php_phongo_javascript_init (intern , Z_STRVAL_P (javascript ), Z_STRLEN_P (javascript ), scope TSRMLS_CC );
78
+ return php_phongo_javascript_init (intern , Z_STRVAL_P (code ), Z_STRLEN_P (code ), scope TSRMLS_CC );
79
79
}
80
80
#else
81
- zval * * javascript , * * scope ;
81
+ zval * * code , * * scope ;
82
82
83
- if (zend_hash_find (props , "javascript " , sizeof ("javascript " ), (void * * ) & javascript ) == SUCCESS && Z_TYPE_PP (javascript ) == IS_STRING ) {
83
+ if (zend_hash_find (props , "code " , sizeof ("code " ), (void * * ) & code ) == SUCCESS && Z_TYPE_PP (code ) == IS_STRING ) {
84
84
zval * tmp = zend_hash_find (props , "scope" , sizeof ("scope" ), (void * * ) & scope ) == SUCCESS ? * scope : NULL ;
85
85
86
- return php_phongo_javascript_init (intern , Z_STRVAL_PP (javascript ), Z_STRLEN_PP (javascript ), tmp TSRMLS_CC );
86
+ return php_phongo_javascript_init (intern , Z_STRVAL_PP (code ), Z_STRLEN_PP (code ), tmp TSRMLS_CC );
87
87
}
88
88
#endif
89
89
return false;
90
90
}
91
91
92
- /* {{{ proto BSON\Javascript Javascript::__construct(string $javascript [, array|object $document ])
92
+ /* {{{ proto BSON\Javascript Javascript::__construct(string $code [, array|object $scope ])
93
93
* The string is JavaScript code. The document is a mapping from identifiers to values, representing the scope in which the string should be evaluated
94
94
* NOTE: eJSON does not support this type :( */
95
95
PHP_METHOD (Javascript , __construct )
96
96
{
97
97
php_phongo_javascript_t * intern ;
98
98
zend_error_handling error_handling ;
99
- char * javascript ;
100
- phongo_zpp_char_len javascript_len ;
101
- zval * document = NULL ;
99
+ char * code ;
100
+ phongo_zpp_char_len code_len ;
101
+ zval * scope = NULL ;
102
102
103
103
104
104
zend_replace_error_handling (EH_THROW , phongo_exception_from_phongo_domain (PHONGO_ERROR_INVALID_ARGUMENT ), & error_handling TSRMLS_CC );
105
105
intern = Z_JAVASCRIPT_OBJ_P (getThis ());
106
106
107
- if (zend_parse_parameters (ZEND_NUM_ARGS () TSRMLS_CC , "s|A!" , & javascript , & javascript_len , & document ) == FAILURE ) {
107
+ if (zend_parse_parameters (ZEND_NUM_ARGS () TSRMLS_CC , "s|A!" , & code , & code_len , & scope ) == FAILURE ) {
108
108
zend_restore_error_handling (& error_handling TSRMLS_CC );
109
109
return ;
110
110
}
111
111
zend_restore_error_handling (& error_handling TSRMLS_CC );
112
112
113
- php_phongo_javascript_init (intern , javascript , javascript_len , document TSRMLS_CC );
113
+ php_phongo_javascript_init (intern , code , code_len , scope TSRMLS_CC );
114
114
}
115
115
/* }}} */
116
116
@@ -189,12 +189,12 @@ static void php_phongo_javascript_free_object(phongo_free_object_arg *object TSR
189
189
190
190
zend_object_std_dtor (& intern -> std TSRMLS_CC );
191
191
192
- if (intern -> javascript ) {
193
- efree (intern -> javascript );
192
+ if (intern -> code ) {
193
+ efree (intern -> code );
194
194
}
195
- if (intern -> document ) {
196
- bson_destroy (intern -> document );
197
- intern -> document = NULL ;
195
+ if (intern -> scope ) {
196
+ bson_destroy (intern -> scope );
197
+ intern -> scope = NULL ;
198
198
}
199
199
200
200
#if PHP_VERSION_ID < 70000
@@ -210,8 +210,6 @@ phongo_create_object_retval php_phongo_javascript_create_object(zend_class_entry
210
210
zend_object_std_init (& intern -> std , class_type TSRMLS_CC );
211
211
object_properties_init (& intern -> std , class_type );
212
212
213
- intern -> document = NULL ;
214
-
215
213
#if PHP_VERSION_ID >= 70000
216
214
intern -> std .handlers = & php_phongo_handler_javascript ;
217
215
@@ -235,21 +233,21 @@ HashTable *php_phongo_javascript_get_properties(zval *object TSRMLS_DC) /* {{{ *
235
233
intern = Z_JAVASCRIPT_OBJ_P (object );
236
234
props = zend_std_get_properties (object TSRMLS_CC );
237
235
238
- if (!intern -> javascript ) {
236
+ if (!intern -> code ) {
239
237
return props ;
240
238
}
241
239
242
240
#if PHP_VERSION_ID >= 70000
243
241
{
244
- zval javascript ;
242
+ zval code ;
245
243
246
- ZVAL_STRING (& javascript , intern -> javascript );
247
- zend_hash_str_update (props , "javascript " , sizeof ("javascript " )- 1 , & javascript );
244
+ ZVAL_STRING (& code , intern -> code );
245
+ zend_hash_str_update (props , "code " , sizeof ("code " )- 1 , & code );
248
246
249
- if (intern -> document ) {
247
+ if (intern -> scope ) {
250
248
php_phongo_bson_state state = PHONGO_BSON_STATE_INITIALIZER ;
251
249
252
- if (phongo_bson_to_zval_ex (bson_get_data (intern -> document ), intern -> document -> len , & state )) {
250
+ if (phongo_bson_to_zval_ex (bson_get_data (intern -> scope ), intern -> scope -> len , & state )) {
253
251
Z_ADDREF (state .zchild );
254
252
zend_hash_str_update (props , "scope" , sizeof ("scope" )- 1 , & state .zchild );
255
253
} else {
@@ -264,16 +262,16 @@ HashTable *php_phongo_javascript_get_properties(zval *object TSRMLS_DC) /* {{{ *
264
262
}
265
263
#else
266
264
{
267
- zval * javascript ;
265
+ zval * code ;
268
266
269
- MAKE_STD_ZVAL (javascript );
270
- ZVAL_STRING (javascript , intern -> javascript , 1 );
271
- zend_hash_update (props , "javascript " , sizeof ("javascript " ), & javascript , sizeof (javascript ), NULL );
267
+ MAKE_STD_ZVAL (code );
268
+ ZVAL_STRING (code , intern -> code , 1 );
269
+ zend_hash_update (props , "code " , sizeof ("code " ), & code , sizeof (code ), NULL );
272
270
273
- if (intern -> document ) {
271
+ if (intern -> scope ) {
274
272
php_phongo_bson_state state = PHONGO_BSON_STATE_INITIALIZER ;
275
273
276
- if (phongo_bson_to_zval_ex (bson_get_data (intern -> document ), intern -> document -> len , & state )) {
274
+ if (phongo_bson_to_zval_ex (bson_get_data (intern -> scope ), intern -> scope -> len , & state )) {
277
275
Z_ADDREF_P (state .zchild );
278
276
zend_hash_update (props , "scope" , sizeof ("scope" ), & state .zchild , sizeof (state .zchild ), NULL );
279
277
} else {
0 commit comments