I run the following JS code in the Chrome console:

// Version 67.0.3396.87 (Official Build) (64-bit)

function Car(make) { this.make = make }
var car = new Car('Ferrari')
car instanceof Car // returns true

Now, on my C++ code I get ahold of car (by looking "car" up in the global 
context), and want to run the equivalent instanceof code, given only the 
class name "Car" as a string.  Notice that I do not have a C++ class / 
function backing up Car.

Just to make it clear, compiling and running "car instanceof Car" as JS 
code in my C++ code, works totally fine.

I naively tried to do something like this, which didn't work:

Local<Object> object = FindObject("car"); // this works
Local<FunctionTemplate> ft = FunctionTemplate::New(isolate);
Local<String> name = String::NewFromUtf8(
    isolate, "Car", NewStringType::kNormal).ToLocalChecked();
ft->SetClassName(name);
if (ft->HasInstance(object)) {
    // this never happens
}

How can I do this, without manually compiling / running JS code?

Thanks!

-- 
-- 
v8-users mailing list
v8-users@googlegroups.com
http://groups.google.com/group/v8-users
--- 
You received this message because you are subscribed to the Google Groups 
"v8-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to v8-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to