how to check for undefined or null jsval in setProperty class hook

classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|

how to check for undefined or null jsval in setProperty class hook

Borislav Kapukaranov
Hi folks,

Another problem I came across is related to checking for corner cases in a setProperty class hook.
The hook is of type JSStrictPropertyOp(JSContext *cx, JSHandleObject obj, JSHandleId id, JSBool strict, JSMutableHandleValue vp).

I have a check in the hook as follows: "vp.get().isNullOrUndefined()".
Upon execution of an assign statement on my class instance with null or undefined value I get a SIGILL (Illegal Operand) error on this check's line.

I'm using spidermonkey 17.

Is this the proper way to handle nulls and undefined in this hook? Any ideas where should I look into?

Thanks,
Bobby
_______________________________________________
dev-tech-js-engine mailing list
[hidden email]
https://lists.mozilla.org/listinfo/dev-tech-js-engine
Reply | Threaded
Open this post in threaded view
|

Re: how to check for undefined or null jsval in setProperty class hook

Borislav Kapukaranov
Also tried JSVAL_IS_VOID(vp) and JSVAL_IS_NULL(vp) again with no luck.

_______________________________________________
dev-tech-js-engine mailing list
[hidden email]
https://lists.mozilla.org/listinfo/dev-tech-js-engine
Reply | Threaded
Open this post in threaded view
|

Re: how to check for undefined or null jsval in setProperty class hook

Tim-2
don't know if its the right answer but the following might work, this effectively gives you JSVAL_IS_OBJECT as was deprecated prior to js17

JSVAL_IS_NULL(obj) || !JSVAL_IS_PRIMITIVE(obj)


On 30/01/14 20:43, Borislav Kapukaranov wrote:
> Also tried JSVAL_IS_VOID(vp) and JSVAL_IS_NULL(vp) again with no luck.
>
> _______________________________________________
> dev-tech-js-engine mailing list
> [hidden email]
> https://lists.mozilla.org/listinfo/dev-tech-js-engine

_______________________________________________
dev-tech-js-engine mailing list
[hidden email]
https://lists.mozilla.org/listinfo/dev-tech-js-engine
Reply | Threaded
Open this post in threaded view
|

Re: how to check for undefined or null jsval in setProperty class hook

Borislav Kapukaranov
In reply to this post by Borislav Kapukaranov
>
> JSVAL_IS_NULL(obj) || !JSVAL_IS_PRIMITIVE(obj)
>

If this is true it will give me non-nul objects, which is not what I'm looking for.

I want to detect undefined and null jsvals.
The JSVAL_IS_NULL() crashes the process with SIGILL. Also the "vp.get().isNullOrUndefined()" call crashes the process in the same way.

I think this may have something to do with the mutable handle, cause I've seen it working with pure(not wrapped) jsval-s.
_______________________________________________
dev-tech-js-engine mailing list
[hidden email]
https://lists.mozilla.org/listinfo/dev-tech-js-engine
Reply | Threaded
Open this post in threaded view
|

Re: how to check for undefined or null jsval in setProperty class hook

Tim-2

On 30/01/14 23:21, Borislav Kapukaranov wrote:
>> JSVAL_IS_NULL(obj) || !JSVAL_IS_PRIMITIVE(obj)
>>
> If this is true it will give me non-nul objects, which is not what I'm looking for.
>
> I want to detect undefined and null jsvals.
> The JSVAL_IS_NULL() crashes the process with SIGILL. Also the "vp.get().isNullOrUndefined()" call crashes the process in the same way.
>
> I think this may have something to do with the mutable handle, cause I've seen it working with pure(not wrapped) jsval-s.
Are you using the C api? if so you have to jump through hoops and
dereference the wrapped values.

Also if so, do note that the C api is completely gone in the latest 24
release. It's C++ only from now on.
> _______________________________________________
> dev-tech-js-engine mailing list
> [hidden email]
> https://lists.mozilla.org/listinfo/dev-tech-js-engine

_______________________________________________
dev-tech-js-engine mailing list
[hidden email]
https://lists.mozilla.org/listinfo/dev-tech-js-engine
Reply | Threaded
Open this post in threaded view
|

Re: how to check for undefined or null jsval in setProperty class hook

Borislav Kapukaranov
In reply to this post by Borislav Kapukaranov
>
> > I think this may have something to do with the mutable handle, cause I've seen it working with pure(not wrapped) jsval-s.
>
> Are you using the C api? if so you have to jump through hoops and
>
> dereference the wrapped values.
>
>
>
> Also if so, do note that the C api is completely gone in the latest 24
>
> release. It's C++ only from now on.
>
> > _______________________________________________
>
> > dev-tech-js-engine mailing list
>
> > [hidden email]
>
> > https://lists.mozilla.org/listinfo/dev-tech-js-engine

I think on 17 no matter what you use it ends up in the same C api procedures that check the bits of type tags. Looking into it but no luck so far :(

Do you have other ideas?
_______________________________________________
dev-tech-js-engine mailing list
[hidden email]
https://lists.mozilla.org/listinfo/dev-tech-js-engine
Reply | Threaded
Open this post in threaded view
|

Re: how to check for undefined or null jsval in setProperty class hook

Tim-2

On 31/01/14 01:32, Borislav Kapukaranov wrote:

>>> I think this may have something to do with the mutable handle, cause I've seen it working with pure(not wrapped) jsval-s.
>> Are you using the C api? if so you have to jump through hoops and
>>
>> dereference the wrapped values.
>>
>>
>>
>> Also if so, do note that the C api is completely gone in the latest 24
>>
>> release. It's C++ only from now on.
>>
>>> _______________________________________________
>>> dev-tech-js-engine mailing list
>>> [hidden email]
>>> https://lists.mozilla.org/listinfo/dev-tech-js-engine
> I think on 17 no matter what you use it ends up in the same C api procedures that check the bits of type tags. Looking into it but no luck so far :(
>
> Do you have other ideas?
Post a code snippet?

Or better use c++ and 24. Its quite a pain to port from 17 to 24 anyway, so better to do it sooner rather than later.
> _______________________________________________
> dev-tech-js-engine mailing list
> [hidden email]
> https://lists.mozilla.org/listinfo/dev-tech-js-engine

_______________________________________________
dev-tech-js-engine mailing list
[hidden email]
https://lists.mozilla.org/listinfo/dev-tech-js-engine