Provide ScriptInterface CreateObject and CreateArray functions to replace Eval calls following 7c2e9027c2, 1c0536bf08 and later.

Differential Revision: https://code.wildfiregames.com/D2080
Previous version reviewed By: Krinkle
Comments By: historic_bruno, wraitii
This was SVN commit r22528.
This commit is contained in:
elexis
2019-07-22 19:35:14 +00:00
parent 6643613b54
commit b4626359f5
23 changed files with 316 additions and 192 deletions
+3 -2
View File
@@ -1,4 +1,4 @@
/* Copyright (C) 2018 Wildfire Games.
/* Copyright (C) 2019 Wildfire Games.
* This file is part of 0 A.D.
*
* 0 A.D. is free software: you can redistribute it and/or modify
@@ -982,7 +982,8 @@ std::string CSimulation2::GetAIData()
// Build single JSON string with array of AI data
JS::RootedValue ais(cx);
if (!scriptInterface.Eval("({})", &ais) || !scriptInterface.SetProperty(ais, "AIData", aiData))
if (!scriptInterface.CreateObject(&ais, "AIData", aiData))
return std::string();
return scriptInterface.StringifyJSON(&ais);