@@ -56,6 +56,7 @@ class JsHasPropertyMsg : public MessageToJs {
5656 }
5757protected:
5858 virtual void InJs (ObjectMapper *m) {
59+ TRACE (" > JsHasPropertyMsg" );
5960 retval_.SetBool (false );
6061 v8::Local<v8::Object> jsObj = Nan::To<v8::Object>(object_.ToJs (m))
6162 .ToLocalChecked ();
@@ -99,20 +100,23 @@ class JsHasPropertyMsg : public MessageToJs {
99100 }
100101 }
101102 }
103+ TRACE (" < JsHasPropertyMsg" );
102104 }
103105};
104106
105107#if USE_MAGIC_ISSET
106108
107109PHP_METHOD (JsObject, __isset) {
108110 zval *member;
111+ TRACE (" >" );
109112 PARSE_PARAMS (__isset, " z/" , &member);
110113 convert_to_string (member);
111114 JsHasPropertyMsg msg (obj->channel , obj->id , member, 0 );
112115 obj->channel ->Send (&msg);
113116 msg.WaitForResponse ();
114117 THROW_IF_EXCEPTION (" JS exception thrown during __isset of \" %*s\" " ,
115118 Z_STRLEN_P (member), Z_STRVAL_P (member));
119+ TRACE (" <" );
116120 RETURN_BOOL (msg.retval_ .AsBool ());
117121}
118122
@@ -125,6 +129,7 @@ static int node_php_jsobject_has_property(zval *object, zval *member, int has_se
125129 * 1 (set) whether property exists and is true-ish - empty()
126130 * 2 (exists) whether property exists - property_exists()
127131 */
132+ TRACE (" >" );
128133 if (Z_TYPE_P (member) != IS_STRING) {
129134 return false ;
130135 }
@@ -135,6 +140,7 @@ static int node_php_jsobject_has_property(zval *object, zval *member, int has_se
135140 msg.WaitForResponse ();
136141 // ok, result is in msg.retval_ or msg.exception_
137142 if (msg.HasException ()) { return false ; /* sigh */ }
143+ TRACE (" <" );
138144 return msg.retval_ .AsBool ();
139145}
140146#endif /* USE_MAGIC_ISSET */
@@ -150,6 +156,7 @@ class JsReadPropertyMsg : public MessageToJs {
150156 }
151157protected:
152158 virtual void InJs (ObjectMapper *m) {
159+ TRACE (" > JsReadPropertyMsg" );
153160 v8::Local<v8::Object> jsObj = Nan::To<v8::Object>(object_.ToJs (m))
154161 .ToLocalChecked ();
155162 v8::Local<v8::String> jsKey = Nan::To<v8::String>(member_.ToJs (m))
@@ -165,11 +172,13 @@ class JsReadPropertyMsg : public MessageToJs {
165172 } else {
166173 retval_.SetNull ();
167174 }
175+ TRACE (" < JsReadPropertyMsg" );
168176 }
169177};
170178
171179
172180PHP_METHOD (JsObject, __get) {
181+ TRACE (" >" );
173182 zval *member;
174183 PARSE_PARAMS (__get, " z/" , &member);
175184 convert_to_string (member);
@@ -179,6 +188,7 @@ PHP_METHOD(JsObject, __get) {
179188 THROW_IF_EXCEPTION (" JS exception thrown during __get of \" %*s\" " ,
180189 Z_STRLEN_P (member), Z_STRVAL_P (member));
181190 msg.retval_ .ToPhp (obj->channel , return_value, return_value_ptr TSRMLS_CC);
191+ TRACE (" <" );
182192}
183193
184194class JsWritePropertyMsg : public MessageToJs {
@@ -192,6 +202,7 @@ class JsWritePropertyMsg : public MessageToJs {
192202 }
193203protected:
194204 virtual void InJs (ObjectMapper *m) {
205+ TRACE (" > HasPropertyMsg" );
195206 v8::Local<v8::Object> jsObj = Nan::To<v8::Object>(object_.ToJs (m))
196207 .ToLocalChecked ();
197208 v8::Local<v8::String> jsKey = Nan::To<v8::String>(member_.ToJs (m))
@@ -201,11 +212,13 @@ class JsWritePropertyMsg : public MessageToJs {
201212 if (Nan::Set (jsObj, jsKey, jsVal).FromMaybe (false )) {
202213 retval_.SetBool (true );
203214 }
215+ TRACE (" < HasPropertyMsg" );
204216 }
205217};
206218
207219PHP_METHOD (JsObject, __set) {
208220 zval *member; zval *value;
221+ TRACE (" >" );
209222 PARSE_PARAMS (__set, " z/z" , &member, &value);
210223 convert_to_string (member);
211224 JsWritePropertyMsg msg (obj->channel , obj->id , member, value);
@@ -214,6 +227,7 @@ PHP_METHOD(JsObject, __set) {
214227 THROW_IF_EXCEPTION (" JS exception thrown during __set of \" %*s\" " ,
215228 Z_STRLEN_P (member), Z_STRVAL_P (member));
216229 msg.retval_ .ToPhp (obj->channel , return_value, return_value_ptr TSRMLS_CC);
230+ TRACE (" <" );
217231}
218232
219233class JsDeletePropertyMsg : public MessageToJs {
@@ -226,6 +240,7 @@ class JsDeletePropertyMsg : public MessageToJs {
226240 }
227241protected:
228242 virtual void InJs (ObjectMapper *m) {
243+ TRACE (" > DeletePropertyMsg" );
229244 v8::Local<v8::Object> jsObj = Nan::To<v8::Object>(object_.ToJs (m))
230245 .ToLocalChecked ();
231246 v8::Local<v8::String> jsKey = Nan::To<v8::String>(member_.ToJs (m))
@@ -234,11 +249,13 @@ class JsDeletePropertyMsg : public MessageToJs {
234249 if (Nan::Delete (jsObj, jsKey).FromMaybe (false )) {
235250 retval_.SetBool (true );
236251 }
252+ TRACE (" < DeletePropertyMsg" );
237253 }
238254};
239255
240256PHP_METHOD (JsObject, __unset) {
241257 zval *member;
258+ TRACE (" >" );
242259 PARSE_PARAMS (__unset, " z/" , &member);
243260 convert_to_string (member);
244261 JsDeletePropertyMsg msg (obj->channel , obj->id , member);
@@ -247,6 +264,7 @@ PHP_METHOD(JsObject, __unset) {
247264 THROW_IF_EXCEPTION (" JS exception thrown during __unset of \" %*s\" " ,
248265 Z_STRLEN_P (member), Z_STRVAL_P (member));
249266 msg.retval_ .ToPhp (obj->channel , return_value, return_value_ptr TSRMLS_CC);
267+ TRACE (" <" );
250268}
251269
252270class JsInvokeMethodMsg : public MessageToJs {
@@ -265,6 +283,7 @@ class JsInvokeMethodMsg : public MessageToJs {
265283 Value &Argv (int n) { return argv_[n]; }
266284 protected:
267285 virtual void InJs (ObjectMapper *m) {
286+ TRACE (" > JsInvokeMethodMsg" );
268287 Nan::MaybeLocal<v8::Object> jsObj =
269288 Nan::To<v8::Object>(object_.ToJs (m));
270289 if (jsObj.IsEmpty ()) {
@@ -291,11 +310,13 @@ class JsInvokeMethodMsg : public MessageToJs {
291310 if (!result.IsEmpty ()) {
292311 retval_.Set (m, result.ToLocalChecked ());
293312 }
313+ TRACE (" < JsInvokeMethodMsg" );
294314 }
295315};
296316
297317PHP_METHOD (JsObject, __call) {
298318 zval *member; zval *args;
319+ TRACE (" >" );
299320 PARSE_PARAMS (__unset, " z/a" , &member, &args);
300321 convert_to_string (member);
301322 HashTable *arrht = Z_ARRVAL_P (args);
@@ -315,6 +336,7 @@ PHP_METHOD(JsObject, __call) {
315336 THROW_IF_EXCEPTION (" JS exception thrown during __call of \" %*s\" " ,
316337 Z_STRLEN_P (member), Z_STRVAL_P (member));
317338 msg.retval_ .ToPhp (obj->channel , return_value, return_value_ptr TSRMLS_CC);
339+ TRACE (" <" );
318340}
319341
320342
@@ -324,25 +346,30 @@ PHP_METHOD(JsObject, __call) {
324346 * for dimensions as well, so that $obj['foo'] acts like $obj->foo. */
325347
326348static int node_php_jsobject_has_dimension (zval *obj, zval *idx, int chk_type TSRMLS_DC) {
349+ TRACE (" >" );
327350 // thunk!
328351 if (chk_type == 0 ) { chk_type = 2 ; }
329352 // use standard has_property method with new chk_type
330353 return node_php_jsobject_handlers.has_property (obj, idx, chk_type ZEND_HASH_KEY_NULL TSRMLS_CC);
331354}
332355static zval *node_php_jsobject_read_dimension (zval *obj, zval *off, int type TSRMLS_DC) {
356+ TRACE (" >" );
333357 // use standard read_property method
334358 return node_php_jsobject_handlers.read_property (obj, off, type ZEND_HASH_KEY_NULL TSRMLS_CC);
335359}
336360static void node_php_jsobject_write_dimension (zval *obj, zval *off, zval *val TSRMLS_DC) {
361+ TRACE (" >" );
337362 // use standard write_property method
338363 node_php_jsobject_handlers.write_property (obj, off, val ZEND_HASH_KEY_NULL TSRMLS_CC);
339364}
340365static void node_php_jsobject_unset_dimension (zval *obj, zval *off TSRMLS_DC) {
366+ TRACE (" >" );
341367 // use standard unset_property method
342368 node_php_jsobject_handlers.unset_property (obj, off ZEND_HASH_KEY_NULL TSRMLS_CC);
343369}
344370
345371static void node_php_jsobject_free_storage (void *object, zend_object_handle handle TSRMLS_DC) {
372+ TRACE (" >" );
346373 node_php_jsobject *c = (node_php_jsobject *) object;
347374
348375#if 0
@@ -369,9 +396,11 @@ static void node_php_jsobject_free_storage(void *object, zend_object_handle hand
369396 // another JS->PHP call first, which would revive the PHP-side wrapper.
370397
371398 efree (object);
399+ TRACE (" <" );
372400}
373401
374402static zend_object_value node_php_jsobject_new (zend_class_entry *ce TSRMLS_DC) {
403+ TRACE (" >" );
375404 zend_object_value retval;
376405 node_php_jsobject *c;
377406
@@ -382,10 +411,12 @@ static zend_object_value node_php_jsobject_new(zend_class_entry *ce TSRMLS_DC) {
382411 retval.handle = zend_objects_store_put (c, NULL , (zend_objects_free_object_storage_t ) node_php_jsobject_free_storage, NULL TSRMLS_CC);
383412 retval.handlers = &node_php_jsobject_handlers;
384413
414+ TRACE (" <" );
385415 return retval;
386416}
387417
388418void node_php_embed::node_php_jsobject_create (zval *res, JsMessageChannel *channel, objid_t id TSRMLS_DC) {
419+ TRACE (" >" );
389420 node_php_jsobject *c;
390421
391422 object_init_ex (res, php_ce_jsobject);
@@ -400,15 +431,18 @@ void node_php_embed::node_php_jsobject_create(zval *res, JsMessageChannel *chann
400431
401432 ctx->node_php_jsobjects.push_front(c);
402433#endif
434+ TRACE (" <" );
403435}
404436
405437#define STUB_METHOD (name ) \
406438PHP_METHOD (JsObject, name) { \
439+ TRACE (" >" ); \
407440 zend_throw_exception ( \
408441 zend_exception_get_default (TSRMLS_C), \
409442 " Can't directly construct, serialize, or unserialize JsObject." , \
410443 0 TSRMLS_CC \
411444 ); \
445+ TRACE (" <" ); \
412446 RETURN_FALSE; \
413447}
414448
@@ -456,6 +490,7 @@ static const zend_function_entry node_php_jsobject_methods[] = {
456490
457491
458492PHP_MINIT_FUNCTION (node_php_jsobject_class) {
493+ TRACE (" > PHP_MINIT_FUNCTION" );
459494 zend_class_entry ce;
460495 /* JsObject Class */
461496 INIT_CLASS_ENTRY (ce, " JsObject" , node_php_jsobject_methods);
@@ -488,5 +523,6 @@ PHP_MINIT_FUNCTION(node_php_jsobject_class) {
488523 node_php_jsobject_handlers.has_dimension = node_php_jsobject_has_dimension;
489524 node_php_jsobject_handlers.unset_dimension = node_php_jsobject_unset_dimension;
490525
526+ TRACE (" < PHP_MINIT_FUNCTION" );
491527 return SUCCESS;
492528}
0 commit comments