1
0
forked from mirrors/0ad

Add a function to query a global object, including JS classes, from C++

The latter are not properties of the global object but stored within the
global lexical environment.
This is not currently needed, but will be useful for future diffs.
Update Vector2D/3D querying.

Taken from D2746

This was SVN commit r24406.
This commit is contained in:
wraitii
2020-12-17 17:51:18 +00:00
parent 25b8cfc6b8
commit e22a915351
3 changed files with 41 additions and 2 deletions
@@ -160,7 +160,7 @@ template<> void ScriptInterface::ToJSVal<CFixedVector3D>(const ScriptRequest& rq
{
JS::RootedObject global(rq.cx, rq.glob);
JS::RootedValue valueVector3D(rq.cx);
if (!JS_GetProperty(rq.cx, global, "Vector3D", &valueVector3D))
if (!ScriptInterface::GetGlobalProperty(rq, "Vector3D", &valueVector3D))
FAIL_VOID("Failed to get Vector3D constructor");
JS::RootedValueArray<3> args(rq.cx);
@@ -196,7 +196,7 @@ template<> void ScriptInterface::ToJSVal<CFixedVector2D>(const ScriptRequest& rq
{
JS::RootedObject global(rq.cx, rq.glob);
JS::RootedValue valueVector2D(rq.cx);
if (!JS_GetProperty(rq.cx, global, "Vector2D", &valueVector2D))
if (!ScriptInterface::GetGlobalProperty(rq, "Vector2D", &valueVector2D))
FAIL_VOID("Failed to get Vector2D constructor");
JS::RootedValueArray<2> args(rq.cx);