简体   繁体   中英

Can I get the source text of JavaScript functions in C++ callback function using google v8?

I am embeding google v8 into my C++ program. I want to get the source code of Javascript functions passed as arguments into my C++ function. For example:

function ComputePixel(nir, red, blue) {
    return (nir-red)/(blue-red)
}
var layer = L8.function(ComputePixel, {
    ‘nir': L8.select('B5'),
    ‘red': L8.select('B4'),
    ‘blue': L8.select('B2’) })

Here "L8.function" is my C++ callback function. Is there any way I get can the complete source of ComputePixel in my C++ function?

You should be able to call ToString on it:

v8::String::Utf8Value str(args[0]->ToString());

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM