HomeWildfire Games

Add FromJSProperty helper function that gets the property of a JS object, thus…

Description

Add FromJSProperty helper function that gets the property of a JS object, thus reducing duplicate checks when getting many properties.

Differential Revision: https://code.wildfiregames.com/D338
Patch By: Vladislav
Refs: https://code.wildfiregames.com/D317

Event Timeline

leper added inline comments.
/ps/trunk/source/scriptinterface/ScriptConversions.h
98

I would have expected to see the hasProperty check here, or as a check of its own.

105

Why not just return ScriptInterface::FromJSVal(cx, value, out);?

vladislavbelov added inline comments.
/ps/trunk/source/scriptinterface/ScriptConversions.h
98

Do you mean:

if (!JS_HasProperty(cx, obj, name, &hasProperty) || !hasProperty)
    ...

?
hasProperty is just checked below.

105

True, just used style from other ScriptConversions functions.

leper added inline comments.Apr 17 2017, 10:01 PM
/ps/trunk/source/scriptinterface/ScriptConversions.h
98

Yes. But why is it checked there, doesn't seem like the place where one would expect that.

Just adding another if (!hasProperty) return false; would be ok too.

105

Quite a few of those are strange in more than that way, would be nice to improve that if we are adding new ones.

/ps/trunk/source/scriptinterface/ScriptConversions.h
105

No problem, but all people have different vision on style, even in a short period.

elexis added inline comments.Apr 18 2017, 1:16 AM
/ps/trunk/source/scriptinterface/ScriptConversions.h
105
leper added inline comments.Apr 18 2017, 1:37 AM
/ps/trunk/source/scriptinterface/ScriptConversions.h
105

Not sure what you'd want to extend there, since at that point there is nothing left to do. Any change that would occur there would most likely need to change something else too, and that should be done if we need it (which I doubt).