diff --git a/source/gui/scripting/GuiScriptConversions.cpp b/source/gui/scripting/GuiScriptConversions.cpp index 9056335a1f..f92423b0b3 100644 --- a/source/gui/scripting/GuiScriptConversions.cpp +++ b/source/gui/scripting/GuiScriptConversions.cpp @@ -64,7 +64,7 @@ template<> void ScriptInterface::ToJSVal(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; diff --git a/source/scriptinterface/ScriptInterface.cpp b/source/scriptinterface/ScriptInterface.cpp index 80accdf435..9bad7a38b7 100644 --- a/source/scriptinterface/ScriptInterface.cpp +++ b/source/scriptinterface/ScriptInterface.cpp @@ -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; } diff --git a/source/scriptinterface/ScriptInterface.h b/source/scriptinterface/ScriptInterface.h index 38cdb4343d..ac4698682e 100644 --- a/source/scriptinterface/ScriptInterface.h +++ b/source/scriptinterface/ScriptInterface.h @@ -421,8 +421,8 @@ private: } DefPersistentRooted m_Prototype; - JSClass* m_Class; - JSNative m_Constructor; + JSClass* m_Class; + JSNative m_Constructor; }; void Register(const char* name, JSNative fptr, size_t nargs); diff --git a/source/scriptinterface/ScriptRuntime.cpp b/source/scriptinterface/ScriptRuntime.cpp index 1d63f1d5cd..5c97208ccf 100644 --- a/source/scriptinterface/ScriptRuntime.cpp +++ b/source/scriptinterface/ScriptRuntime.cpp @@ -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)) { diff --git a/source/scriptinterface/ScriptRuntime.h b/source/scriptinterface/ScriptRuntime.h index db081c3b8a..7bc0a509af 100644 --- a/source/scriptinterface/ScriptRuntime.h +++ b/source/scriptinterface/ScriptRuntime.h @@ -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 m_Contexts; std::vector > m_FinalizationListObjectIdCache; static bool m_Initialized; - + int m_RuntimeSize; int m_HeapGrowthBytesGCTrigger; int m_LastGCBytes; diff --git a/source/simulation2/serialization/BinarySerializer.cpp b/source/simulation2/serialization/BinarySerializer.cpp index e0cea3f663..a17b877723 100644 --- a/source/simulation2/serialization/BinarySerializer.cpp +++ b/source/simulation2/serialization/BinarySerializer.cpp @@ -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"); diff --git a/source/simulation2/system/ComponentManager.cpp b/source/simulation2/system/ComponentManager.cpp index 44a8db5f34..a97b16295e 100644 --- a/source/simulation2/system/ComponentManager.cpp +++ b/source/simulation2/system/ComponentManager.cpp @@ -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