44
44
45
45
PHONGO_API zend_class_entry * php_phongo_javascript_ce ;
46
46
47
+ zend_object_handlers php_phongo_handler_javascript ;
47
48
48
49
/* {{{ proto BSON\Javascript Javascript::__construct(string $javascript[, array|object $document])
49
50
* The string is JavaScript code. The document is a mapping from identifiers to values, representing the scope in which the string should be evaluated
@@ -119,12 +120,43 @@ zend_object_value php_phongo_javascript_create_object(zend_class_entry *class_ty
119
120
object_properties_init (& intern -> std , class_type );
120
121
121
122
retval .handle = zend_objects_store_put (intern , (zend_objects_store_dtor_t ) zend_objects_destroy_object , php_phongo_javascript_free_object , NULL TSRMLS_CC );
122
- retval .handlers = phongo_get_std_object_handlers () ;
123
+ retval .handlers = & php_phongo_handler_javascript ;
123
124
124
125
intern -> document = NULL ;
125
126
126
127
return retval ;
127
128
} /* }}} */
129
+
130
+ HashTable * php_phongo_javascript_get_debug_info (zval * object , int * is_temp TSRMLS_DC ) /* {{{ */
131
+ {
132
+ php_phongo_javascript_t * intern ;
133
+ zval retval = zval_used_for_init ;
134
+
135
+
136
+ * is_temp = 1 ;
137
+ intern = (php_phongo_javascript_t * )zend_object_store_get_object (object TSRMLS_CC );
138
+
139
+ array_init (& retval );
140
+
141
+ add_assoc_stringl_ex (& retval , ZEND_STRS ("javascript" ), intern -> javascript , intern -> javascript_len , 1 );
142
+
143
+ if (intern -> document ) {
144
+ php_phongo_bson_state state = PHONGO_BSON_STATE_INITIALIZER ;
145
+
146
+ MAKE_STD_ZVAL (state .zchild );
147
+
148
+ if (bson_to_zval (bson_get_data (intern -> document ), intern -> document -> len , & state )) {
149
+ Z_ADDREF_P (state .zchild );
150
+ add_assoc_zval_ex (& retval , ZEND_STRS ("scope" ), state .zchild );
151
+ } else {
152
+ add_assoc_null_ex (& retval , ZEND_STRS ("scope" ));
153
+ }
154
+
155
+ zval_ptr_dtor (& state .zchild );
156
+ }
157
+
158
+ return Z_ARRVAL (retval );
159
+ } /* }}} */
128
160
/* }}} */
129
161
130
162
/* {{{ PHP_MINIT_FUNCTION */
@@ -140,6 +172,8 @@ PHP_MINIT_FUNCTION(Javascript)
140
172
141
173
zend_class_implements (php_phongo_javascript_ce TSRMLS_CC , 1 , php_phongo_type_ce );
142
174
175
+ memcpy (& php_phongo_handler_javascript , phongo_get_std_object_handlers (), sizeof (zend_object_handlers ));
176
+ php_phongo_handler_javascript .get_debug_info = php_phongo_javascript_get_debug_info ;
143
177
144
178
return SUCCESS ;
145
179
}
0 commit comments