1
0
forked from mirrors/0ad

Second (main) commit for the SpiderMonkey upgrade.

This commit contains all the required changes to our source files and
build scripts (hopefully).
A next commit will remove the old stuff of SpiderMonkey 1.8.5.

Spcial thanks to:
 - H4writer who helped a lot mainly with the performance issues we
had/have, but also with other problems or questions.
 - Leper for the review.
 - Historic_bruno for implementing the build scripts on Mac OS X and
testing on the Mac.
 - The people from the #jsapi channel and from
mozilla.dev.tech.js-engine who answered a lot of questions and helped
solving problems.
 - All the other people who helped

Refs #1886
Fixes #2442
Fixes #2416

This was SVN commit r14877.
This commit is contained in:
Yves
2014-03-28 20:26:32 +00:00
parent 6f6b841af3
commit e9e05f4efc
58 changed files with 1661 additions and 1378 deletions
+8 -32
View File
@@ -17,19 +17,24 @@
#include "precompiled.h"
#include "ScriptInterface.h"
#include "ScriptVal.h"
#include "js/jsapi.h"
struct Unrooter
{
Unrooter(JSContext* cx) : cx(cx) { }
void operator()(jsval* p) { JS_RemoveValueRoot(cx, p); delete p; }
void operator()(jsval* p)
{
JSAutoRequest rq(cx);
JS_RemoveValueRoot(cx, p); delete p;
}
JSContext* cx;
};
CScriptValRooted::CScriptValRooted(JSContext* cx, jsval val)
{
JSAutoRequest rq(cx);
jsval* p = new jsval(val);
JS_AddNamedValueRoot(cx, p, "CScriptValRooted");
m_Val = boost::shared_ptr<jsval>(p, Unrooter(cx));
@@ -37,6 +42,7 @@ CScriptValRooted::CScriptValRooted(JSContext* cx, jsval val)
CScriptValRooted::CScriptValRooted(JSContext* cx, CScriptVal val)
{
JSAutoRequest rq(cx);
jsval* p = new jsval(val.get());
JS_AddNamedValueRoot(cx, p, "CScriptValRooted");
m_Val = boost::shared_ptr<jsval>(p, Unrooter(cx));
@@ -64,33 +70,3 @@ bool CScriptValRooted::uninitialised() const
{
return !m_Val;
}
AutoJSIdArray::AutoJSIdArray(JSContext* cx, JSIdArray* ida) :
m_Context(cx), m_IdArray(ida)
{
}
AutoJSIdArray::~AutoJSIdArray()
{
if (m_IdArray)
JS_DestroyIdArray(m_Context, m_IdArray);
}
JSIdArray* AutoJSIdArray::get() const
{
return m_IdArray;
}
size_t AutoJSIdArray::length() const
{
if (!m_IdArray)
return 0;
return m_IdArray->length;
}
jsid AutoJSIdArray::operator[](size_t i) const
{
if (!(m_IdArray && i < (size_t)m_IdArray->length))
return JSID_VOID;
return m_IdArray->vector[i];
}