tbodt / v8py

Write Python APIs, then call them from JavaScript using the V8 engine.
GNU Lesser General Public License v3.0
443 stars 29 forks source link

Callback Function #30

Closed LinkTed closed 6 years ago

LinkTed commented 6 years ago

Hi, how can I call a python function every time a javascript object is create or access (With the Debugger class)? I need this for analysis purpose.

Thanks for your attention.

tbodt commented 6 years ago

I don't believe the V8 debugger API supports that.

LinkTed commented 6 years ago

It do not have to be a callback or something like that and it do not have to be with the Debugger. Is there maybe a way like in the test_indexed_property.py (but it have to be for every object) to call a function when a object is create or acess?

tbodt commented 6 years ago

For every object? You could add hooks to the functions in pyclasshandlers.cpp.

LinkTed commented 6 years ago

Thanks for your answer but it works only for Python object (which are exposed) when i add hooks in py_class_construct_callback and py_class_method_callback. I need hooks for every object for example:

// Hook for here
var s1 = new String();
// and here
var s2 = "Hello world!";
var r = s1.concat(s2);

Thanks for your help

tbodt commented 6 years ago

V8 doesn't support that. You could try and replace String with your own python class.