@@ -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
@@ -233,21 +233,21 @@ HashTable *php_phongo_javascript_get_properties(zval *object TSRMLS_DC) /* {{{ *
233233 intern = Z_JAVASCRIPT_OBJ_P (object );
234234 props = zend_std_get_properties (object TSRMLS_CC );
235235
236- if (!intern -> javascript ) {
236+ if (!intern -> code ) {
237237 return props ;
238238 }
239239
240240#if PHP_VERSION_ID >= 70000
241241 {
242- zval javascript ;
242+ zval code ;
243243
244- ZVAL_STRING (& javascript , intern -> javascript );
245- 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 );
246246
247- if (intern -> document ) {
247+ if (intern -> scope ) {
248248 php_phongo_bson_state state = PHONGO_BSON_STATE_INITIALIZER ;
249249
250- 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 )) {
251251 Z_ADDREF (state .zchild );
252252 zend_hash_str_update (props , "scope" , sizeof ("scope" )- 1 , & state .zchild );
253253 } else {
@@ -262,16 +262,16 @@ HashTable *php_phongo_javascript_get_properties(zval *object TSRMLS_DC) /* {{{ *
262262 }
263263#else
264264 {
265- zval * javascript ;
265+ zval * code ;
266266
267- MAKE_STD_ZVAL (javascript );
268- ZVAL_STRING (javascript , intern -> javascript , 1 );
269- 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 );
270270
271- if (intern -> document ) {
271+ if (intern -> scope ) {
272272 php_phongo_bson_state state = PHONGO_BSON_STATE_INITIALIZER ;
273273
274- 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 )) {
275275 Z_ADDREF_P (state .zchild );
276276 zend_hash_update (props , "scope" , sizeof ("scope" ), & state .zchild , sizeof (state .zchild ), NULL );
277277 } else {
0 commit comments