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:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user