From 3ec17db44a271eae41ec91359b5f206471ac4ee7 Mon Sep 17 00:00:00 2001 From: amaitland Date: Fri, 7 Aug 2015 13:04:03 +1000 Subject: [PATCH] Make params const and pass by ref --- .../Serialization/JsObjectsSerialization.cpp | 4 +- .../Serialization/JsObjectsSerialization.h | 2 +- .../Serialization/ObjectsSerialization.cpp | 6 +- .../Serialization/ObjectsSerialization.h | 2 +- .../Internals/Serialization/Primitives.cpp | 56 +++++++++---------- .../Internals/Serialization/Primitives.h | 18 +++--- 6 files changed, 44 insertions(+), 44 deletions(-) diff --git a/CefSharp.Core/Internals/Serialization/JsObjectsSerialization.cpp b/CefSharp.Core/Internals/Serialization/JsObjectsSerialization.cpp index 8518be406..d1f6c9e45 100644 --- a/CefSharp.Core/Internals/Serialization/JsObjectsSerialization.cpp +++ b/CefSharp.Core/Internals/Serialization/JsObjectsSerialization.cpp @@ -13,7 +13,7 @@ namespace CefSharp { namespace Serialization { - void SerializeJsObject(JavascriptObject^ jsObject, CefRefPtr &list, int index) + void SerializeJsObject(JavascriptObject^ jsObject, const CefRefPtr &list, int index) { auto objList = CefListValue::Create(); SetInt64(jsObject->Id, objList, 0); @@ -66,7 +66,7 @@ namespace CefSharp list->SetList(index, objList); } - void SerializeJsObject(JavascriptRootObject^ object, CefRefPtr &list, int index) + void SerializeJsObject(JavascriptRootObject^ object, const CefRefPtr &list, int index) { auto subList = CefListValue::Create(); auto i = 0; diff --git a/CefSharp.Core/Internals/Serialization/JsObjectsSerialization.h b/CefSharp.Core/Internals/Serialization/JsObjectsSerialization.h index ab2afd4f3..da817a1cf 100644 --- a/CefSharp.Core/Internals/Serialization/JsObjectsSerialization.h +++ b/CefSharp.Core/Internals/Serialization/JsObjectsSerialization.h @@ -10,7 +10,7 @@ namespace CefSharp { namespace Serialization { - void SerializeJsObject(JavascriptRootObject^ object, CefRefPtr &list, int index); + void SerializeJsObject(JavascriptRootObject^ object, const CefRefPtr &list, int index); } } } \ No newline at end of file diff --git a/CefSharp.Core/Internals/Serialization/ObjectsSerialization.cpp b/CefSharp.Core/Internals/Serialization/ObjectsSerialization.cpp index 356042e1a..1edf92b9d 100644 --- a/CefSharp.Core/Internals/Serialization/ObjectsSerialization.cpp +++ b/CefSharp.Core/Internals/Serialization/ObjectsSerialization.cpp @@ -15,7 +15,7 @@ namespace CefSharp namespace Serialization { template - Object^ DeserializeObject(CefRefPtr list, TIndex index, IJavascriptCallbackFactory^ javascriptCallbackFactory) + Object^ DeserializeObject(const CefRefPtr& list, TIndex index, IJavascriptCallbackFactory^ javascriptCallbackFactory) { Object^ result = nullptr; auto type = list->GetType(index); @@ -88,8 +88,8 @@ namespace CefSharp return DateTime(1970, 1, 1, 0, 0, 0).AddSeconds(epoch).ToLocalTime(); } - template Object^ DeserializeObject(CefRefPtr list, int index, IJavascriptCallbackFactory^ javascriptCallbackFactory); - template Object^ DeserializeObject(CefRefPtr list, CefString index, IJavascriptCallbackFactory^ javascriptCallbackFactory); + template Object^ DeserializeObject(const CefRefPtr& list, int index, IJavascriptCallbackFactory^ javascriptCallbackFactory); + template Object^ DeserializeObject(const CefRefPtr& list, CefString index, IJavascriptCallbackFactory^ javascriptCallbackFactory); } } } \ No newline at end of file diff --git a/CefSharp.Core/Internals/Serialization/ObjectsSerialization.h b/CefSharp.Core/Internals/Serialization/ObjectsSerialization.h index 00a8737a9..87ba99e2a 100644 --- a/CefSharp.Core/Internals/Serialization/ObjectsSerialization.h +++ b/CefSharp.Core/Internals/Serialization/ObjectsSerialization.h @@ -17,7 +17,7 @@ namespace CefSharp //Deserializes data into Object from a given index of a CefListValue or CefDictionaryValue //IJavascriptCallbackFactory implementation should be passed to allow creation of valid javascript callbacks template - Object^ DeserializeObject(CefRefPtr list, TIndex index, IJavascriptCallbackFactory^ javascriptCallbackFactory); + Object^ DeserializeObject(const CefRefPtr& list, TIndex index, IJavascriptCallbackFactory^ javascriptCallbackFactory); //Converts CefTime to DateTime DateTime ConvertCefTimeToDateTime(CefTime time); diff --git a/CefSharp.Core/Internals/Serialization/Primitives.cpp b/CefSharp.Core/Internals/Serialization/Primitives.cpp index ce2cc91ef..a81c34437 100644 --- a/CefSharp.Core/Internals/Serialization/Primitives.cpp +++ b/CefSharp.Core/Internals/Serialization/Primitives.cpp @@ -23,7 +23,7 @@ namespace CefSharp }; template - bool IsType(PrimitiveType type, CefRefPtr list, TIndex index) + bool IsType(PrimitiveType type, const CefRefPtr& list, TIndex index) { auto result = list->GetType(index) == VTYPE_BINARY; if (result) @@ -37,7 +37,7 @@ namespace CefSharp } template - void SetInt64(const int64 &value, CefRefPtr list, TIndex index) + void SetInt64(const int64 &value, const CefRefPtr& list, TIndex index) { unsigned char mem[1 + sizeof(int64)]; mem[0] = static_cast(PrimitiveType::INT64); @@ -48,7 +48,7 @@ namespace CefSharp } template - int64 GetInt64(CefRefPtr list, TIndex index) + int64 GetInt64(const CefRefPtr& list, TIndex index) { int64 result; @@ -59,13 +59,13 @@ namespace CefSharp } template - bool IsInt64(CefRefPtr list, TIndex index) + bool IsInt64(const CefRefPtr& list, TIndex index) { return IsType(PrimitiveType::INT64, list, index); } template - void SetCefTime(const CefTime &value, CefRefPtr list, TIndex index) + void SetCefTime(const CefTime &value, const CefRefPtr& list, TIndex index) { auto doubleT = value.GetDoubleT(); unsigned char mem[1 + sizeof(double)]; @@ -77,7 +77,7 @@ namespace CefSharp } template - CefTime GetCefTime(CefRefPtr list, TIndex index) + CefTime GetCefTime(const CefRefPtr& list, TIndex index) { double doubleT; @@ -88,12 +88,12 @@ namespace CefSharp } template - bool IsCefTime(CefRefPtr list, TIndex index) + bool IsCefTime(const CefRefPtr& list, TIndex index) { return IsType(PrimitiveType::CEFTIME, list, index); } template - void SetJsCallback(JavascriptCallback^ value, CefRefPtr list, TIndex index) + void SetJsCallback(JavascriptCallback^ value, const CefRefPtr& list, TIndex index) { auto id = value->Id; auto browserId = value->BrowserId; @@ -108,7 +108,7 @@ namespace CefSharp } template - JavascriptCallback^ GetJsCallback(CefRefPtr list, TIndex index) + JavascriptCallback^ GetJsCallback(const CefRefPtr& list, TIndex index) { auto result = gcnew JavascriptCallback(); int64 id; @@ -125,31 +125,31 @@ namespace CefSharp } template - bool IsJsCallback(CefRefPtr list, TIndex index) + bool IsJsCallback(const CefRefPtr& list, TIndex index) { return IsType(PrimitiveType::JSCALLBACK, list, index); } - template void SetInt64(const int64 &value, CefRefPtr list, int index); - template void SetInt64(const int64 &value, CefRefPtr list, CefString index); - template int64 GetInt64(CefRefPtr list, int index); - template int64 GetInt64(CefRefPtr list, CefString index); - template bool IsInt64(CefRefPtr list, int index); - template bool IsInt64(CefRefPtr list, CefString index); + template void SetInt64(const int64 &value, const CefRefPtr& list, int index); + template void SetInt64(const int64 &value, const CefRefPtr& list, CefString index); + template int64 GetInt64(const CefRefPtr& list, int index); + template int64 GetInt64(const CefRefPtr& list, CefString index); + template bool IsInt64(const CefRefPtr& list, int index); + template bool IsInt64(const CefRefPtr& list, CefString index); - template void SetCefTime(const CefTime &value, CefRefPtr list, int index); - template void SetCefTime(const CefTime &value, CefRefPtr list, CefString index); - template CefTime GetCefTime(CefRefPtr list, int index); - template CefTime GetCefTime(CefRefPtr list, CefString index); - template bool IsCefTime(CefRefPtr list, int index); - template bool IsCefTime(CefRefPtr list, CefString index); + template void SetCefTime(const CefTime &value, const CefRefPtr& list, int index); + template void SetCefTime(const CefTime &value, const CefRefPtr& list, CefString index); + template CefTime GetCefTime(const CefRefPtr& list, int index); + template CefTime GetCefTime(const CefRefPtr& list, CefString index); + template bool IsCefTime(const CefRefPtr& list, int index); + template bool IsCefTime(const CefRefPtr& list, CefString index); - template void SetJsCallback(JavascriptCallback^ value, CefRefPtr list, int index); - template void SetJsCallback(JavascriptCallback^ value, CefRefPtr list, CefString index); - template JavascriptCallback^ GetJsCallback(CefRefPtr list, int index); - template JavascriptCallback^ GetJsCallback(CefRefPtr list, CefString index); - template bool IsJsCallback(CefRefPtr list, int index); - template bool IsJsCallback(CefRefPtr list, CefString index); + template void SetJsCallback(JavascriptCallback^ value, const CefRefPtr& list, int index); + template void SetJsCallback(JavascriptCallback^ value, const CefRefPtr& list, CefString index); + template JavascriptCallback^ GetJsCallback(const CefRefPtr& list, int index); + template JavascriptCallback^ GetJsCallback(const CefRefPtr& list, CefString index); + template bool IsJsCallback(const CefRefPtr& list, int index); + template bool IsJsCallback(const CefRefPtr& list, CefString index); } } } \ No newline at end of file diff --git a/CefSharp.Core/Internals/Serialization/Primitives.h b/CefSharp.Core/Internals/Serialization/Primitives.h index e451ae6ff..07403a5ad 100644 --- a/CefSharp.Core/Internals/Serialization/Primitives.h +++ b/CefSharp.Core/Internals/Serialization/Primitives.h @@ -13,25 +13,25 @@ namespace CefSharp //Functions to serialize/deserialize specific types into CefBinaryValue template - void SetInt64(const int64 &value, CefRefPtr list, TIndex index); + void SetInt64(const int64 &value, const CefRefPtr& list, TIndex index); template - int64 GetInt64(CefRefPtr list, TIndex index); + int64 GetInt64(const CefRefPtr& list, TIndex index); template - bool IsInt64(CefRefPtr list, TIndex index); + bool IsInt64(const CefRefPtr& list, TIndex index); template - void SetCefTime(const CefTime &value, CefRefPtr list, TIndex index); + void SetCefTime(const CefTime &value, const CefRefPtr& list, TIndex index); template - CefTime GetCefTime(CefRefPtr list, TIndex index); + CefTime GetCefTime(const CefRefPtr& list, TIndex index); template - bool IsCefTime(CefRefPtr list, TIndex index); + bool IsCefTime(const CefRefPtr& list, TIndex index); template - void SetJsCallback(JavascriptCallback^ value, CefRefPtr list, TIndex index); + void SetJsCallback(JavascriptCallback^ value, const CefRefPtr& list, TIndex index); template - JavascriptCallback^ GetJsCallback(CefRefPtr list, TIndex index); + JavascriptCallback^ GetJsCallback(const CefRefPtr& list, TIndex index); template - bool IsJsCallback(CefRefPtr list, TIndex index); + bool IsJsCallback(const CefRefPtr& list, TIndex index); } } } \ No newline at end of file