Re: How to check if a custom class has a private object set?

Mihai Dobrescu <[email protected]> Fri, 16 Dec 2016 05:23:10 -0800 (PST)
Newsgroups gmane.comp.mozilla.devel.jseng
Message-ID <[email protected]>
On Friday, December 16, 2016 at 3:13:47 PM UTC+2, Mihai Dobrescu wrote:
> I have a class C with instance function F() and static function S().
> 
> I would call:
> 
> var c = new C();
> 
> c.F();
> 
> C.S(); << here crashes as explained
> 
> What I might do wrong, considering I try to extract an instance if there is one or not - when not a nullptr should be returned? I know this might be misleading, so the idea here is that I use generic template functions, even though I don't really use the object instance if any. But, anyway, when I need an instance, I should be able to check if there is something <> nullptr or not.

I think the question could be rephrased like this:

When a function is executed, being static, what is the meaning of the code below?

JS::CallArgs args = CallArgsFromVp(argc, vp);

JSObject* obj = &args.thisv().toObject();

What is the content of obj?

What is the outcome of JS_GetPrivate(obj)?

That obj won't have the required flag, but how could I tell that before?