mirror of
https://gitea.wildfiregames.com/0ad/0ad.git
synced 2026-07-01 14:28:26 +00:00
Fix [19027] by using generic code for conversions and fixing a few other issues. Refs #3403. Reviewed by leper.
Also fix some of the warnings that jenkins showed. Differential Revision: https://code.wildfiregames.com/D24 This was SVN commit r19115.
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
/* Copyright (C) 2016 Wildfire Games.
|
||||
/* Copyright (C) 2017 Wildfire Games.
|
||||
* This file is part of 0 A.D.
|
||||
*
|
||||
* 0 A.D. is free software: you can redistribute it and/or modify
|
||||
@@ -17,8 +17,7 @@
|
||||
|
||||
#include "precompiled.h"
|
||||
|
||||
#include "scriptinterface/ScriptInterface.h"
|
||||
#include "scriptinterface/ScriptExtraHeaders.h" // for typed arrays
|
||||
#include "scriptinterface/ScriptConversions.h"
|
||||
|
||||
#include "maths/Fixed.h"
|
||||
#include "maths/FixedVector2D.h"
|
||||
@@ -299,21 +298,5 @@ template<> void ScriptInterface::ToJSVal<Grid<u16> >(JSContext* cx, JS::MutableH
|
||||
ret.setObject(*obj);
|
||||
}
|
||||
|
||||
// TODO: This is copy-pasted from scriptinterface/ScriptConversions.cpp (#define VECTOR stuff), would be nice to remove the duplication
|
||||
template<> void ScriptInterface::ToJSVal<std::vector<CFixedVector2D> >(JSContext* cx, JS::MutableHandleValue ret, const std::vector<CFixedVector2D>& val)
|
||||
{
|
||||
JSAutoRequest rq(cx);
|
||||
JS::RootedObject obj(cx, JS_NewArrayObject(cx, 0));
|
||||
if (!obj)
|
||||
{
|
||||
ret.setUndefined();
|
||||
return;
|
||||
}
|
||||
for (size_t i = 0; i < val.size(); ++i)
|
||||
{
|
||||
JS::RootedValue el(cx);
|
||||
ScriptInterface::ToJSVal<CFixedVector2D>(cx, &el, val[i]);
|
||||
JS_SetElement(cx, obj, i, el);
|
||||
}
|
||||
ret.setObject(*obj);
|
||||
}
|
||||
// define vectors
|
||||
JSVAL_VECTOR(CFixedVector2D)
|
||||
|
||||
Reference in New Issue
Block a user