Style cleanup by leper, preparing the SpiderMonkey update. Refs #3708

This was SVN commit r18579.
This commit is contained in:
Itms
2016-08-02 16:12:11 +00:00
parent f7ff71e8d5
commit 72ca6c5f80
7 changed files with 17 additions and 23 deletions
@@ -64,7 +64,7 @@ template<> void ScriptInterface::ToJSVal<SDL_Event_>(JSContext* cx, JS::MutableH
// SET(obj, "state", (int)val.ev.key.state); // (not in wsdl.h)
JS::RootedObject keysym(cx, JS_NewObject(cx, nullptr, JS::NullPtr(), JS::NullPtr()));
if (! keysym)
if (!keysym)
{
ret.setUndefined();
return;
+7 -9
View File
@@ -376,11 +376,9 @@ ScriptInterface_impl::ScriptInterface_impl(const char* nativeScopeName, const sh
JS::RootedValue ret(m_cx);
JS_CallFunctionName(m_cx, testingFunctionsObj, "gcPreserveCode", JS::HandleValueArray::empty(), &ret);
JS_DefineProperty(m_cx, m_glob, "global", globalRootedVal, JSPROP_ENUMERATE | JSPROP_READONLY
| JSPROP_PERMANENT);
JS_DefineProperty(m_cx, m_glob, "global", globalRootedVal, JSPROP_ENUMERATE | JSPROP_READONLY | JSPROP_PERMANENT);
m_nativeScope = JS_DefineObject(m_cx, m_glob, nativeScopeName, NULL, NULL, JSPROP_ENUMERATE | JSPROP_READONLY
| JSPROP_PERMANENT);
m_nativeScope = JS_DefineObject(m_cx, m_glob, nativeScopeName, NULL, NULL, JSPROP_ENUMERATE | JSPROP_READONLY | JSPROP_PERMANENT);
JS_DefineFunction(m_cx, globalRootedVal, "print", ::print, 0, JSPROP_ENUMERATE | JSPROP_READONLY | JSPROP_PERMANENT);
JS_DefineFunction(m_cx, globalRootedVal, "log", ::logmsg, 1, JSPROP_ENUMERATE | JSPROP_READONLY | JSPROP_PERMANENT);
@@ -651,7 +649,7 @@ bool ScriptInterface::SetProperty_(JS::HandleValue obj, const char* name, JS::Ha
return false;
JS::RootedObject object(m->m_cx, &obj.toObject());
if (! JS_DefineProperty(m->m_cx, object, name, value, attrs))
if (!JS_DefineProperty(m->m_cx, object, name, value, attrs))
return false;
return true;
}
@@ -688,7 +686,7 @@ bool ScriptInterface::SetPropertyInt_(JS::HandleValue obj, int name, JS::HandleV
return false;
JS::RootedObject object(m->m_cx, &obj.toObject());
if (! JS_DefinePropertyById(m->m_cx, object, INT_TO_JSID(name), value, NULL, NULL, attrs))
if (!JS_DefinePropertyById(m->m_cx, object, INT_TO_JSID(name), value, NULL, NULL, attrs))
return false;
return true;
}
@@ -769,7 +767,7 @@ bool ScriptInterface::EnumeratePropertyNamesWithPrefix(JS::HandleValue objVal, c
return false;
}
if(objVal.isNull())
if (objVal.isNull())
return true; // reached the end of the prototype chain
JS::RootedObject obj(m->m_cx, &objVal.toObject());
@@ -793,7 +791,7 @@ bool ScriptInterface::EnumeratePropertyNamesWithPrefix(JS::HandleValue objVal, c
size_t prefixLen = strlen(prefix) * sizeof(char);
JS_EncodeStringToBuffer(m->m_cx, name, &buf[0], prefixLen);
buf[len-1]= '\0';
if(0 == strcmp(&buf[0], prefix))
if (0 == strcmp(&buf[0], prefix))
{
size_t len;
const char16_t* chars = JS_GetStringCharsAndLength(m->m_cx, name, &len);
@@ -806,7 +804,7 @@ bool ScriptInterface::EnumeratePropertyNamesWithPrefix(JS::HandleValue objVal, c
if (JS_GetPrototype(m->m_cx, obj, &prototype))
{
JS::RootedValue prototypeVal(m->m_cx, JS::ObjectOrNullValue(prototype));
if (! EnumeratePropertyNamesWithPrefix(prototypeVal, prefix, out))
if (!EnumeratePropertyNamesWithPrefix(prototypeVal, prefix, out))
return false;
}
+2 -2
View File
@@ -421,8 +421,8 @@ private:
}
DefPersistentRooted<JSObject*> m_Prototype;
JSClass* m_Class;
JSNative m_Constructor;
JSClass* m_Class;
JSNative m_Constructor;
};
void Register(const char* name, JSNative fptr, size_t nargs);
+1 -1
View File
@@ -227,7 +227,7 @@ void ScriptRuntime::MaybeIncrementalGC(double delay)
// A hack to make sure we never exceed the runtime size because we can't collect the memory
// fast enough.
if(gcBytes > m_RuntimeSize / 2)
if (gcBytes > m_RuntimeSize / 2)
{
if (JS::IsIncrementalGCInProgress(m_rt))
{
+4 -4
View File
@@ -53,10 +53,10 @@ public:
*/
void MaybeIncrementalGC(double delay);
void ShrinkingGC();
void RegisterContext(JSContext* cx);
void UnRegisterContext(JSContext* cx);
/**
* Registers an object to be freed/finalized by the ScriptRuntime. Freeing is
* guaranteed to happen after the next minor GC has completed, but might also
@@ -70,7 +70,7 @@ public:
JSRuntime* m_rt;
private:
void PrepareContextsForIncrementalGC();
void GCCallbackMember();
@@ -80,7 +80,7 @@ private:
std::list<JSContext*> m_Contexts;
std::vector<std::shared_ptr<void> > m_FinalizationListObjectIdCache;
static bool m_Initialized;
int m_RuntimeSize;
int m_HeapGrowthBytesGCTrigger;
int m_LastGCBytes;
@@ -23,7 +23,7 @@
#include "ps/CLogger.h"
#include "scriptinterface/ScriptInterface.h"
#include "scriptinterface/ScriptExtraHeaders.h" // for JSDOUBLE_IS_INT32, typed arrays
#include "scriptinterface/ScriptExtraHeaders.h"
#include "SerializedScriptTypes.h"
static u8 GetArrayType(JSArrayBufferViewType arrayType)
@@ -296,10 +296,6 @@ void CBinarySerializerScriptImpl::HandleScriptVal(JS::HandleValue val)
}
// Find all properties (ordered by insertion time)
// (Note that we don't do any rooting, because we assume nothing is going to trigger GC.
// I'm not absolute certain that's necessarily a valid assumption.)
JS::AutoIdArray ida (cx, JS_Enumerate(cx, obj));
if (!ida)
throw PSERROR_Serialize_ScriptError("JS_Enumerate failed");
@@ -269,7 +269,7 @@ void CComponentManager::Script_RegisterComponentType_Common(ScriptInterface::CxP
return; // error
proto = protoVal.toObjectOrNull();
if (!componentManager->m_ScriptInterface.EnumeratePropertyNamesWithPrefix(protoVal, "On", methods))
return; // error