@@ -47,20 +47,20 @@ PHONGO_API zend_class_entry *php_phongo_javascript_ce;
4747zend_object_handlers php_phongo_handler_javascript ;
4848
4949/* 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 )
5151{
5252 if (scope && Z_TYPE_P (scope ) != IS_OBJECT && Z_TYPE_P (scope ) != IS_ARRAY && Z_TYPE_P (scope ) != IS_NULL ) {
5353 return false;
5454 }
5555
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 ;
5858
5959 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 );
6262 } else {
63- intern -> document = NULL ;
63+ intern -> scope = NULL ;
6464 }
6565
6666 return true;
@@ -70,47 +70,47 @@ static bool php_phongo_javascript_init(php_phongo_javascript_t *intern, const ch
7070static bool php_phongo_javascript_init_from_hash (php_phongo_javascript_t * intern , HashTable * props TSRMLS_DC )
7171{
7272#if PHP_VERSION_ID >= 70000
73- zval * javascript , * scope ;
73+ zval * code , * scope ;
7474
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 ) {
7676 scope = zend_hash_str_find (props , "scope" , sizeof ("scope" )- 1 );
7777
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 );
7979 }
8080#else
81- zval * * javascript , * * scope ;
81+ zval * * code , * * scope ;
8282
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 ) {
8484 zval * tmp = zend_hash_find (props , "scope" , sizeof ("scope" ), (void * * ) & scope ) == SUCCESS ? * scope : NULL ;
8585
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 );
8787 }
8888#endif
8989 return false;
9090}
9191
92- /* {{{ proto BSON\Javascript Javascript::__construct(string $javascript [, array|object $document ])
92+ /* {{{ proto BSON\Javascript Javascript::__construct(string $code [, array|object $scope ])
9393 * The string is JavaScript code. The document is a mapping from identifiers to values, representing the scope in which the string should be evaluated
9494 * NOTE: eJSON does not support this type :( */
9595PHP_METHOD (Javascript , __construct )
9696{
9797 php_phongo_javascript_t * intern ;
9898 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 ;
102102
103103
104104 zend_replace_error_handling (EH_THROW , phongo_exception_from_phongo_domain (PHONGO_ERROR_INVALID_ARGUMENT ), & error_handling TSRMLS_CC );
105105 intern = Z_JAVASCRIPT_OBJ_P (getThis ());
106106
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 ) {
108108 zend_restore_error_handling (& error_handling TSRMLS_CC );
109109 return ;
110110 }
111111 zend_restore_error_handling (& error_handling TSRMLS_CC );
112112
113- php_phongo_javascript_init (intern , javascript , javascript_len , document TSRMLS_CC );
113+ php_phongo_javascript_init (intern , code , code_len , scope TSRMLS_CC );
114114}
115115/* }}} */
116116
@@ -189,12 +189,12 @@ static void php_phongo_javascript_free_object(phongo_free_object_arg *object TSR
189189
190190 zend_object_std_dtor (& intern -> std TSRMLS_CC );
191191
192- if (intern -> javascript ) {
193- efree (intern -> javascript );
192+ if (intern -> code ) {
193+ efree (intern -> code );
194194 }
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 ;
198198 }
199199
200200#if PHP_VERSION_ID < 70000
@@ -210,8 +210,6 @@ phongo_create_object_retval php_phongo_javascript_create_object(zend_class_entry
210210 zend_object_std_init (& intern -> std , class_type TSRMLS_CC );
211211 object_properties_init (& intern -> std , class_type );
212212
213- intern -> document = NULL ;
214-
215213#if PHP_VERSION_ID >= 70000
216214 intern -> std .handlers = & php_phongo_handler_javascript ;
217215
@@ -235,21 +233,21 @@ HashTable *php_phongo_javascript_get_properties(zval *object TSRMLS_DC) /* {{{ *
235233 intern = Z_JAVASCRIPT_OBJ_P (object );
236234 props = zend_std_get_properties (object TSRMLS_CC );
237235
238- if (!intern -> javascript ) {
236+ if (!intern -> code ) {
239237 return props ;
240238 }
241239
242240#if PHP_VERSION_ID >= 70000
243241 {
244- zval javascript ;
242+ zval code ;
245243
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 );
248246
249- if (intern -> document ) {
247+ if (intern -> scope ) {
250248 php_phongo_bson_state state = PHONGO_BSON_STATE_INITIALIZER ;
251249
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 )) {
253251 Z_ADDREF (state .zchild );
254252 zend_hash_str_update (props , "scope" , sizeof ("scope" )- 1 , & state .zchild );
255253 } else {
@@ -264,16 +262,16 @@ HashTable *php_phongo_javascript_get_properties(zval *object TSRMLS_DC) /* {{{ *
264262 }
265263#else
266264 {
267- zval * javascript ;
265+ zval * code ;
268266
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 );
272270
273- if (intern -> document ) {
271+ if (intern -> scope ) {
274272 php_phongo_bson_state state = PHONGO_BSON_STATE_INITIALIZER ;
275273
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 )) {
277275 Z_ADDREF_P (state .zchild );
278276 zend_hash_update (props , "scope" , sizeof ("scope" ), & state .zchild , sizeof (state .zchild ), NULL );
279277 } else {
0 commit comments