From cdd2a40469f2228bb8ebed2b5db3091512f501d2 Mon Sep 17 00:00:00 2001 From: Marshall Greenblatt Date: Fri, 4 Nov 2016 14:38:59 -0400 Subject: [PATCH] Change index parameter type from int to size_t (issue #1491) --- include/capi/cef_values_capi.h | 41 ++++--- include/cef_values.h | 76 ++++++------ include/internal/cef_string_list.h | 4 +- include/internal/cef_string_map.h | 6 +- include/internal/cef_string_multimap.h | 10 +- libcef/common/string_list_impl.cc | 9 +- libcef/common/string_map_impl.cc | 20 ++- libcef/common/string_multimap_impl.cc | 31 +++-- libcef/common/values_impl.cc | 42 +++---- libcef/common/values_impl.h | 42 +++---- libcef_dll/cpptoc/list_value_cpptoc.cc | 124 ++++--------------- libcef_dll/ctocpp/list_value_ctocpp.cc | 129 +++----------------- libcef_dll/ctocpp/list_value_ctocpp.h | 39 +++--- libcef_dll/transfer_util.cc | 12 +- tests/unittests/parser_unittest.cc | 12 +- tests/unittests/process_message_unittest.cc | 4 +- tests/unittests/string_unittest.cc | 76 ++++++------ tests/unittests/test_util.cc | 6 +- tests/unittests/values_unittest.cc | 22 ++-- 19 files changed, 272 insertions(+), 433 deletions(-) diff --git a/include/capi/cef_values_capi.h b/include/capi/cef_values_capi.h index 6434489f8..d27eedce3 100644 --- a/include/capi/cef_values_capi.h +++ b/include/capi/cef_values_capi.h @@ -581,13 +581,13 @@ typedef struct _cef_list_value_t { /// // Removes the value at the specified index. /// - int (CEF_CALLBACK *remove)(struct _cef_list_value_t* self, int index); + int (CEF_CALLBACK *remove)(struct _cef_list_value_t* self, size_t index); /// // Returns the value type at the specified index. /// cef_value_type_t (CEF_CALLBACK *get_type)(struct _cef_list_value_t* self, - int index); + size_t index); /// // Returns the value at the specified index. For simple types the returned @@ -597,36 +597,37 @@ typedef struct _cef_list_value_t { // will modify this object. /// struct _cef_value_t* (CEF_CALLBACK *get_value)(struct _cef_list_value_t* self, - int index); + size_t index); /// // Returns the value at the specified index as type bool. /// - int (CEF_CALLBACK *get_bool)(struct _cef_list_value_t* self, int index); + int (CEF_CALLBACK *get_bool)(struct _cef_list_value_t* self, size_t index); /// // Returns the value at the specified index as type int. /// - int (CEF_CALLBACK *get_int)(struct _cef_list_value_t* self, int index); + int (CEF_CALLBACK *get_int)(struct _cef_list_value_t* self, size_t index); /// // Returns the value at the specified index as type double. /// - double (CEF_CALLBACK *get_double)(struct _cef_list_value_t* self, int index); + double (CEF_CALLBACK *get_double)(struct _cef_list_value_t* self, + size_t index); /// // Returns the value at the specified index as type string. /// // The resulting string must be freed by calling cef_string_userfree_free(). cef_string_userfree_t (CEF_CALLBACK *get_string)( - struct _cef_list_value_t* self, int index); + struct _cef_list_value_t* self, size_t index); /// // Returns the value at the specified index as type binary. The returned value // will reference existing data. /// struct _cef_binary_value_t* (CEF_CALLBACK *get_binary)( - struct _cef_list_value_t* self, int index); + struct _cef_list_value_t* self, size_t index); /// // Returns the value at the specified index as type dictionary. The returned @@ -634,7 +635,7 @@ typedef struct _cef_list_value_t { // modify this object. /// struct _cef_dictionary_value_t* (CEF_CALLBACK *get_dictionary)( - struct _cef_list_value_t* self, int index); + struct _cef_list_value_t* self, size_t index); /// // Returns the value at the specified index as type list. The returned value @@ -642,7 +643,7 @@ typedef struct _cef_list_value_t { // this object. /// struct _cef_list_value_t* (CEF_CALLBACK *get_list)( - struct _cef_list_value_t* self, int index); + struct _cef_list_value_t* self, size_t index); /// // Sets the value at the specified index. Returns true (1) if the value was @@ -652,41 +653,41 @@ typedef struct _cef_list_value_t { // then the underlying data will be referenced and modifications to |value| // will modify this object. /// - int (CEF_CALLBACK *set_value)(struct _cef_list_value_t* self, int index, + int (CEF_CALLBACK *set_value)(struct _cef_list_value_t* self, size_t index, struct _cef_value_t* value); /// // Sets the value at the specified index as type null. Returns true (1) if the // value was set successfully. /// - int (CEF_CALLBACK *set_null)(struct _cef_list_value_t* self, int index); + int (CEF_CALLBACK *set_null)(struct _cef_list_value_t* self, size_t index); /// // Sets the value at the specified index as type bool. Returns true (1) if the // value was set successfully. /// - int (CEF_CALLBACK *set_bool)(struct _cef_list_value_t* self, int index, + int (CEF_CALLBACK *set_bool)(struct _cef_list_value_t* self, size_t index, int value); /// // Sets the value at the specified index as type int. Returns true (1) if the // value was set successfully. /// - int (CEF_CALLBACK *set_int)(struct _cef_list_value_t* self, int index, + int (CEF_CALLBACK *set_int)(struct _cef_list_value_t* self, size_t index, int value); /// // Sets the value at the specified index as type double. Returns true (1) if // the value was set successfully. /// - int (CEF_CALLBACK *set_double)(struct _cef_list_value_t* self, int index, + int (CEF_CALLBACK *set_double)(struct _cef_list_value_t* self, size_t index, double value); /// // Sets the value at the specified index as type string. Returns true (1) if // the value was set successfully. /// - int (CEF_CALLBACK *set_string)(struct _cef_list_value_t* self, int index, + int (CEF_CALLBACK *set_string)(struct _cef_list_value_t* self, size_t index, const cef_string_t* value); /// @@ -696,7 +697,7 @@ typedef struct _cef_list_value_t { // change. Otherwise, ownership will be transferred to this object and the // |value| reference will be invalidated. /// - int (CEF_CALLBACK *set_binary)(struct _cef_list_value_t* self, int index, + int (CEF_CALLBACK *set_binary)(struct _cef_list_value_t* self, size_t index, struct _cef_binary_value_t* value); /// @@ -706,8 +707,8 @@ typedef struct _cef_list_value_t { // Otherwise, ownership will be transferred to this object and the |value| // reference will be invalidated. /// - int (CEF_CALLBACK *set_dictionary)(struct _cef_list_value_t* self, int index, - struct _cef_dictionary_value_t* value); + int (CEF_CALLBACK *set_dictionary)(struct _cef_list_value_t* self, + size_t index, struct _cef_dictionary_value_t* value); /// // Sets the value at the specified index as type list. Returns true (1) if the @@ -716,7 +717,7 @@ typedef struct _cef_list_value_t { // Otherwise, ownership will be transferred to this object and the |value| // reference will be invalidated. /// - int (CEF_CALLBACK *set_list)(struct _cef_list_value_t* self, int index, + int (CEF_CALLBACK *set_list)(struct _cef_list_value_t* self, size_t index, struct _cef_list_value_t* value); } cef_list_value_t; diff --git a/include/cef_values.h b/include/cef_values.h index 6ab6adffc..86fa40ef6 100644 --- a/include/cef_values.h +++ b/include/cef_values.h @@ -606,14 +606,14 @@ class CefListValue : public virtual CefBase { /// // Removes the value at the specified index. /// - /*--cef(index_param=index)--*/ - virtual bool Remove(int index) =0; + /*--cef()--*/ + virtual bool Remove(size_t index) =0; /// // Returns the value type at the specified index. /// - /*--cef(default_retval=VTYPE_INVALID,index_param=index)--*/ - virtual CefValueType GetType(int index) =0; + /*--cef(default_retval=VTYPE_INVALID)--*/ + virtual CefValueType GetType(size_t index) =0; /// // Returns the value at the specified index. For simple types the returned @@ -622,55 +622,55 @@ class CefListValue : public virtual CefBase { // returned value will reference existing data and modifications to the value // will modify this object. /// - /*--cef(index_param=index)--*/ - virtual CefRefPtr GetValue(int index) =0; + /*--cef()--*/ + virtual CefRefPtr GetValue(size_t index) =0; /// // Returns the value at the specified index as type bool. /// - /*--cef(index_param=index)--*/ - virtual bool GetBool(int index) =0; + /*--cef()--*/ + virtual bool GetBool(size_t index) =0; /// // Returns the value at the specified index as type int. /// - /*--cef(index_param=index)--*/ - virtual int GetInt(int index) =0; + /*--cef()--*/ + virtual int GetInt(size_t index) =0; /// // Returns the value at the specified index as type double. /// - /*--cef(index_param=index)--*/ - virtual double GetDouble(int index) =0; + /*--cef()--*/ + virtual double GetDouble(size_t index) =0; /// // Returns the value at the specified index as type string. /// - /*--cef(index_param=index)--*/ - virtual CefString GetString(int index) =0; + /*--cef()--*/ + virtual CefString GetString(size_t index) =0; /// // Returns the value at the specified index as type binary. The returned // value will reference existing data. /// - /*--cef(index_param=index)--*/ - virtual CefRefPtr GetBinary(int index) =0; + /*--cef()--*/ + virtual CefRefPtr GetBinary(size_t index) =0; /// // Returns the value at the specified index as type dictionary. The returned // value will reference existing data and modifications to the value will // modify this object. /// - /*--cef(index_param=index)--*/ - virtual CefRefPtr GetDictionary(int index) =0; + /*--cef()--*/ + virtual CefRefPtr GetDictionary(size_t index) =0; /// // Returns the value at the specified index as type list. The returned // value will reference existing data and modifications to the value will // modify this object. /// - /*--cef(index_param=index)--*/ - virtual CefRefPtr GetList(int index) =0; + /*--cef()--*/ + virtual CefRefPtr GetList(size_t index) =0; /// // Sets the value at the specified index. Returns true if the value was set @@ -680,43 +680,43 @@ class CefListValue : public virtual CefBase { // underlying data will be referenced and modifications to |value| will modify // this object. /// - /*--cef(index_param=index)--*/ - virtual bool SetValue(int index, CefRefPtr value) =0; + /*--cef()--*/ + virtual bool SetValue(size_t index, CefRefPtr value) =0; /// // Sets the value at the specified index as type null. Returns true if the // value was set successfully. /// - /*--cef(index_param=index)--*/ - virtual bool SetNull(int index) =0; + /*--cef()--*/ + virtual bool SetNull(size_t index) =0; /// // Sets the value at the specified index as type bool. Returns true if the // value was set successfully. /// - /*--cef(index_param=index)--*/ - virtual bool SetBool(int index, bool value) =0; + /*--cef()--*/ + virtual bool SetBool(size_t index, bool value) =0; /// // Sets the value at the specified index as type int. Returns true if the // value was set successfully. /// - /*--cef(index_param=index)--*/ - virtual bool SetInt(int index, int value) =0; + /*--cef()--*/ + virtual bool SetInt(size_t index, int value) =0; /// // Sets the value at the specified index as type double. Returns true if the // value was set successfully. /// - /*--cef(index_param=index)--*/ - virtual bool SetDouble(int index, double value) =0; + /*--cef()--*/ + virtual bool SetDouble(size_t index, double value) =0; /// // Sets the value at the specified index as type string. Returns true if the // value was set successfully. /// - /*--cef(optional_param=value,index_param=index)--*/ - virtual bool SetString(int index, const CefString& value) =0; + /*--cef(optional_param=value)--*/ + virtual bool SetString(size_t index, const CefString& value) =0; /// // Sets the value at the specified index as type binary. Returns true if the @@ -725,8 +725,8 @@ class CefListValue : public virtual CefBase { // Otherwise, ownership will be transferred to this object and the |value| // reference will be invalidated. /// - /*--cef(index_param=index)--*/ - virtual bool SetBinary(int index, CefRefPtr value) =0; + /*--cef()--*/ + virtual bool SetBinary(size_t index, CefRefPtr value) =0; /// // Sets the value at the specified index as type dict. Returns true if the @@ -735,8 +735,8 @@ class CefListValue : public virtual CefBase { // Otherwise, ownership will be transferred to this object and the |value| // reference will be invalidated. /// - /*--cef(index_param=index)--*/ - virtual bool SetDictionary(int index, CefRefPtr value) =0; + /*--cef()--*/ + virtual bool SetDictionary(size_t index, CefRefPtr value) =0; /// // Sets the value at the specified index as type list. Returns true if the @@ -745,8 +745,8 @@ class CefListValue : public virtual CefBase { // Otherwise, ownership will be transferred to this object and the |value| // reference will be invalidated. /// - /*--cef(index_param=index)--*/ - virtual bool SetList(int index, CefRefPtr value) =0; + /*--cef()--*/ + virtual bool SetList(size_t index, CefRefPtr value) =0; }; #endif // CEF_INCLUDE_CEF_VALUES_H_ diff --git a/include/internal/cef_string_list.h b/include/internal/cef_string_list.h index 52a0abf2f..79c0509f0 100644 --- a/include/internal/cef_string_list.h +++ b/include/internal/cef_string_list.h @@ -51,14 +51,14 @@ CEF_EXPORT cef_string_list_t cef_string_list_alloc(); /// // Return the number of elements in the string list. /// -CEF_EXPORT int cef_string_list_size(cef_string_list_t list); +CEF_EXPORT size_t cef_string_list_size(cef_string_list_t list); /// // Retrieve the value at the specified zero-based string list index. Returns // true (1) if the value was successfully retrieved. /// CEF_EXPORT int cef_string_list_value(cef_string_list_t list, - int index, cef_string_t* value); + size_t index, cef_string_t* value); /// // Append a new value at the end of the string list. diff --git a/include/internal/cef_string_map.h b/include/internal/cef_string_map.h index 93eea2a55..a22f33a78 100644 --- a/include/internal/cef_string_map.h +++ b/include/internal/cef_string_map.h @@ -51,7 +51,7 @@ CEF_EXPORT cef_string_map_t cef_string_map_alloc(); /// // Return the number of elements in the string map. /// -CEF_EXPORT int cef_string_map_size(cef_string_map_t map); +CEF_EXPORT size_t cef_string_map_size(cef_string_map_t map); /// // Return the value assigned to the specified key. @@ -63,13 +63,13 @@ CEF_EXPORT int cef_string_map_find(cef_string_map_t map, /// // Return the key at the specified zero-based string map index. /// -CEF_EXPORT int cef_string_map_key(cef_string_map_t map, int index, +CEF_EXPORT int cef_string_map_key(cef_string_map_t map, size_t index, cef_string_t* key); /// // Return the value at the specified zero-based string map index. /// -CEF_EXPORT int cef_string_map_value(cef_string_map_t map, int index, +CEF_EXPORT int cef_string_map_value(cef_string_map_t map, size_t index, cef_string_t* value); /// diff --git a/include/internal/cef_string_multimap.h b/include/internal/cef_string_multimap.h index cd3904244..ee9325b37 100644 --- a/include/internal/cef_string_multimap.h +++ b/include/internal/cef_string_multimap.h @@ -52,12 +52,12 @@ CEF_EXPORT cef_string_multimap_t cef_string_multimap_alloc(); /// // Return the number of elements in the string multimap. /// -CEF_EXPORT int cef_string_multimap_size(cef_string_multimap_t map); +CEF_EXPORT size_t cef_string_multimap_size(cef_string_multimap_t map); /// // Return the number of values with the specified key. /// -CEF_EXPORT int cef_string_multimap_find_count(cef_string_multimap_t map, +CEF_EXPORT size_t cef_string_multimap_find_count(cef_string_multimap_t map, const cef_string_t* key); /// @@ -65,19 +65,19 @@ CEF_EXPORT int cef_string_multimap_find_count(cef_string_multimap_t map, /// CEF_EXPORT int cef_string_multimap_enumerate(cef_string_multimap_t map, const cef_string_t* key, - int value_index, + size_t value_index, cef_string_t* value); /// // Return the key at the specified zero-based string multimap index. /// -CEF_EXPORT int cef_string_multimap_key(cef_string_multimap_t map, int index, +CEF_EXPORT int cef_string_multimap_key(cef_string_multimap_t map, size_t index, cef_string_t* key); /// // Return the value at the specified zero-based string multimap index. /// -CEF_EXPORT int cef_string_multimap_value(cef_string_multimap_t map, int index, +CEF_EXPORT int cef_string_multimap_value(cef_string_multimap_t map, size_t index, cef_string_t* value); /// diff --git a/libcef/common/string_list_impl.cc b/libcef/common/string_list_impl.cc index 8db72cbeb..09aff868a 100644 --- a/libcef/common/string_list_impl.cc +++ b/libcef/common/string_list_impl.cc @@ -12,20 +12,19 @@ CEF_EXPORT cef_string_list_t cef_string_list_alloc() { return new StringList; } -CEF_EXPORT int cef_string_list_size(cef_string_list_t list) { +CEF_EXPORT size_t cef_string_list_size(cef_string_list_t list) { DCHECK(list); StringList* impl = reinterpret_cast(list); return impl->size(); } -CEF_EXPORT int cef_string_list_value(cef_string_list_t list, int index, +CEF_EXPORT int cef_string_list_value(cef_string_list_t list, size_t index, cef_string_t* value) { DCHECK(list); DCHECK(value); StringList* impl = reinterpret_cast(list); - DCHECK_GE(index, 0); - DCHECK_LT(index, static_cast(impl->size())); - if (index < 0 || index >= static_cast(impl->size())) + DCHECK_LT(index, impl->size()); + if (index >= impl->size()) return false; const CefString& str = (*impl)[index]; return cef_string_copy(str.c_str(), str.length(), value); diff --git a/libcef/common/string_map_impl.cc b/libcef/common/string_map_impl.cc index 9538ab05e..9b8c6075e 100644 --- a/libcef/common/string_map_impl.cc +++ b/libcef/common/string_map_impl.cc @@ -12,7 +12,7 @@ CEF_EXPORT cef_string_map_t cef_string_map_alloc() { return new StringMap; } -CEF_EXPORT int cef_string_map_size(cef_string_map_t map) { +CEF_EXPORT size_t cef_string_map_size(cef_string_map_t map) { DCHECK(map); StringMap* impl = reinterpret_cast(map); return impl->size(); @@ -32,36 +32,34 @@ CEF_EXPORT int cef_string_map_find(cef_string_map_t map, return cef_string_set(val.c_str(), val.length(), value, true); } -CEF_EXPORT int cef_string_map_key(cef_string_map_t map, int index, +CEF_EXPORT int cef_string_map_key(cef_string_map_t map, size_t index, cef_string_t* key) { DCHECK(map); DCHECK(key); StringMap* impl = reinterpret_cast(map); - DCHECK_GE(index, 0); - DCHECK_LT(index, static_cast(impl->size())); - if (index < 0 || index >= static_cast(impl->size())) + DCHECK_LT(index, impl->size()); + if (index >= impl->size()) return 0; StringMap::const_iterator it = impl->begin(); - for (int ct = 0; it != impl->end(); ++it, ct++) { + for (size_t ct = 0; it != impl->end(); ++it, ct++) { if (ct == index) return cef_string_set(it->first.c_str(), it->first.length(), key, true); } return 0; } -CEF_EXPORT int cef_string_map_value(cef_string_map_t map, int index, +CEF_EXPORT int cef_string_map_value(cef_string_map_t map, size_t index, cef_string_t* value) { DCHECK(map); DCHECK(value); StringMap* impl = reinterpret_cast(map); - DCHECK_GE(index, 0); - DCHECK_LT(index, static_cast(impl->size())); - if (index < 0 || index >= static_cast(impl->size())) + DCHECK_LT(index, impl->size()); + if (index >= impl->size()) return 0; StringMap::const_iterator it = impl->begin(); - for (int ct = 0; it != impl->end(); ++it, ct++) { + for (size_t ct = 0; it != impl->end(); ++it, ct++) { if (ct == index) { return cef_string_set(it->second.c_str(), it->second.length(), value, true); diff --git a/libcef/common/string_multimap_impl.cc b/libcef/common/string_multimap_impl.cc index 594ca90dd..886fa814e 100644 --- a/libcef/common/string_multimap_impl.cc +++ b/libcef/common/string_multimap_impl.cc @@ -12,13 +12,13 @@ CEF_EXPORT cef_string_multimap_t cef_string_multimap_alloc() { return new StringMultimap; } -CEF_EXPORT int cef_string_multimap_size(cef_string_multimap_t map) { +CEF_EXPORT size_t cef_string_multimap_size(cef_string_multimap_t map) { DCHECK(map); StringMultimap* impl = reinterpret_cast(map); return impl->size(); } -CEF_EXPORT int cef_string_multimap_find_count(cef_string_multimap_t map, +CEF_EXPORT size_t cef_string_multimap_find_count(cef_string_multimap_t map, const cef_string_t* key) { DCHECK(map); DCHECK(key); @@ -28,7 +28,7 @@ CEF_EXPORT int cef_string_multimap_find_count(cef_string_multimap_t map, CEF_EXPORT int cef_string_multimap_enumerate(cef_string_multimap_t map, const cef_string_t* key, - int value_index, + size_t value_index, cef_string_t* value) { DCHECK(map); DCHECK(key); @@ -37,15 +37,14 @@ CEF_EXPORT int cef_string_multimap_enumerate(cef_string_multimap_t map, StringMultimap* impl = reinterpret_cast(map); CefString key_str(key); - DCHECK_GE(value_index, 0); - DCHECK_LT(value_index, static_cast(impl->count(key_str))); - if (value_index < 0 || value_index >= static_cast(impl->count(key_str))) + DCHECK_LT(value_index, impl->count(key_str)); + if (value_index >= impl->count(key_str)) return 0; std::pair range_it = impl->equal_range(key_str); - int count = value_index; + size_t count = value_index; while (count-- && range_it.first != range_it.second) range_it.first++; @@ -56,36 +55,34 @@ CEF_EXPORT int cef_string_multimap_enumerate(cef_string_multimap_t map, return cef_string_set(val.c_str(), val.length(), value, true); } -CEF_EXPORT int cef_string_multimap_key(cef_string_multimap_t map, int index, +CEF_EXPORT int cef_string_multimap_key(cef_string_multimap_t map, size_t index, cef_string_t* key) { DCHECK(map); DCHECK(key); StringMultimap* impl = reinterpret_cast(map); - DCHECK_GE(index, 0); - DCHECK_LT(index, static_cast(impl->size())); - if (index < 0 || index >= static_cast(impl->size())) + DCHECK_LT(index, impl->size()); + if (index >= impl->size()) return 0; StringMultimap::const_iterator it = impl->begin(); - for (int ct = 0; it != impl->end(); ++it, ct++) { + for (size_t ct = 0; it != impl->end(); ++it, ct++) { if (ct == index) return cef_string_set(it->first.c_str(), it->first.length(), key, true); } return 0; } -CEF_EXPORT int cef_string_multimap_value(cef_string_multimap_t map, int index, +CEF_EXPORT int cef_string_multimap_value(cef_string_multimap_t map, size_t index, cef_string_t* value) { DCHECK(map); DCHECK(value); StringMultimap* impl = reinterpret_cast(map); - DCHECK_GE(index, 0); - DCHECK_LT(index, static_cast(impl->size())); - if (index < 0 || index >= static_cast(impl->size())) + DCHECK_LT(index, impl->size()); + if (index >= impl->size()) return 0; StringMultimap::const_iterator it = impl->begin(); - for (int ct = 0; it != impl->end(); ++it, ct++) { + for (size_t ct = 0; it != impl->end(); ++it, ct++) { if (ct == index) { return cef_string_set(it->second.c_str(), it->second.length(), value, true); diff --git a/libcef/common/values_impl.cc b/libcef/common/values_impl.cc index 02bb9a844..db554434e 100644 --- a/libcef/common/values_impl.cc +++ b/libcef/common/values_impl.cc @@ -1130,12 +1130,12 @@ bool CefListValueImpl::Clear() { return true; } -bool CefListValueImpl::Remove(int index) { +bool CefListValueImpl::Remove(size_t index) { CEF_VALUE_VERIFY_RETURN(true, false); return RemoveInternal(index); } -CefValueType CefListValueImpl::GetType(int index) { +CefValueType CefListValueImpl::GetType(size_t index) { CEF_VALUE_VERIFY_RETURN(false, VTYPE_INVALID); const base::Value* out_value = NULL; @@ -1163,7 +1163,7 @@ CefValueType CefListValueImpl::GetType(int index) { return VTYPE_INVALID; } -CefRefPtr CefListValueImpl::GetValue(int index) { +CefRefPtr CefListValueImpl::GetValue(size_t index) { CEF_VALUE_VERIFY_RETURN(false, NULL); const base::Value* out_value = NULL; @@ -1178,7 +1178,7 @@ CefRefPtr CefListValueImpl::GetValue(int index) { return NULL; } -bool CefListValueImpl::GetBool(int index) { +bool CefListValueImpl::GetBool(size_t index) { CEF_VALUE_VERIFY_RETURN(false, false); const base::Value* out_value = NULL; @@ -1190,7 +1190,7 @@ bool CefListValueImpl::GetBool(int index) { return ret_value; } -int CefListValueImpl::GetInt(int index) { +int CefListValueImpl::GetInt(size_t index) { CEF_VALUE_VERIFY_RETURN(false, 0); const base::Value* out_value = NULL; @@ -1202,7 +1202,7 @@ int CefListValueImpl::GetInt(int index) { return ret_value; } -double CefListValueImpl::GetDouble(int index) { +double CefListValueImpl::GetDouble(size_t index) { CEF_VALUE_VERIFY_RETURN(false, 0); const base::Value* out_value = NULL; @@ -1214,7 +1214,7 @@ double CefListValueImpl::GetDouble(int index) { return ret_value; } -CefString CefListValueImpl::GetString(int index) { +CefString CefListValueImpl::GetString(size_t index) { CEF_VALUE_VERIFY_RETURN(false, CefString()); const base::Value* out_value = NULL; @@ -1226,7 +1226,7 @@ CefString CefListValueImpl::GetString(int index) { return ret_value; } -CefRefPtr CefListValueImpl::GetBinary(int index) { +CefRefPtr CefListValueImpl::GetBinary(size_t index) { CEF_VALUE_VERIFY_RETURN(false, NULL); const base::Value* out_value = NULL; @@ -1242,7 +1242,7 @@ CefRefPtr CefListValueImpl::GetBinary(int index) { return NULL; } -CefRefPtr CefListValueImpl::GetDictionary(int index) { +CefRefPtr CefListValueImpl::GetDictionary(size_t index) { CEF_VALUE_VERIFY_RETURN(false, NULL); const base::Value* out_value = NULL; @@ -1262,7 +1262,7 @@ CefRefPtr CefListValueImpl::GetDictionary(int index) { return NULL; } -CefRefPtr CefListValueImpl::GetList(int index) { +CefRefPtr CefListValueImpl::GetList(size_t index) { CEF_VALUE_VERIFY_RETURN(false, NULL); const base::Value* out_value = NULL; @@ -1281,7 +1281,7 @@ CefRefPtr CefListValueImpl::GetList(int index) { return NULL; } -bool CefListValueImpl::SetValue(int index, CefRefPtr value) { +bool CefListValueImpl::SetValue(size_t index, CefRefPtr value) { CEF_VALUE_VERIFY_RETURN(true, false); CefValueImpl* impl = static_cast(value.get()); @@ -1293,37 +1293,37 @@ bool CefListValueImpl::SetValue(int index, CefRefPtr value) { return true; } -bool CefListValueImpl::SetNull(int index) { +bool CefListValueImpl::SetNull(size_t index) { CEF_VALUE_VERIFY_RETURN(true, false); SetInternal(index, base::Value::CreateNullValue().release()); return true; } -bool CefListValueImpl::SetBool(int index, bool value) { +bool CefListValueImpl::SetBool(size_t index, bool value) { CEF_VALUE_VERIFY_RETURN(true, false); SetInternal(index, new base::FundamentalValue(value)); return true; } -bool CefListValueImpl::SetInt(int index, int value) { +bool CefListValueImpl::SetInt(size_t index, int value) { CEF_VALUE_VERIFY_RETURN(true, false); SetInternal(index, new base::FundamentalValue(value)); return true; } -bool CefListValueImpl::SetDouble(int index, double value) { +bool CefListValueImpl::SetDouble(size_t index, double value) { CEF_VALUE_VERIFY_RETURN(true, false); SetInternal(index, new base::FundamentalValue(value)); return true; } -bool CefListValueImpl::SetString(int index, const CefString& value) { +bool CefListValueImpl::SetString(size_t index, const CefString& value) { CEF_VALUE_VERIFY_RETURN(true, false); SetInternal(index, new base::StringValue(value.ToString())); return true; } -bool CefListValueImpl::SetBinary(int index, CefRefPtr value) { +bool CefListValueImpl::SetBinary(size_t index, CefRefPtr value) { CEF_VALUE_VERIFY_RETURN(true, false); CefBinaryValueImpl* impl = static_cast(value.get()); @@ -1333,7 +1333,7 @@ bool CefListValueImpl::SetBinary(int index, CefRefPtr value) { return true; } -bool CefListValueImpl::SetDictionary(int index, +bool CefListValueImpl::SetDictionary(size_t index, CefRefPtr value) { CEF_VALUE_VERIFY_RETURN(true, false); @@ -1345,7 +1345,7 @@ bool CefListValueImpl::SetDictionary(int index, return true; } -bool CefListValueImpl::SetList(int index, CefRefPtr value) { +bool CefListValueImpl::SetList(size_t index, CefRefPtr value) { CEF_VALUE_VERIFY_RETURN(true, false); CefListValueImpl* impl = static_cast(value.get()); @@ -1355,7 +1355,7 @@ bool CefListValueImpl::SetList(int index, CefRefPtr value) { return true; } -bool CefListValueImpl::RemoveInternal(int index) { +bool CefListValueImpl::RemoveInternal(size_t index) { std::unique_ptr out_value; if (!mutable_value()->Remove(index, &out_value)) return false; @@ -1372,7 +1372,7 @@ bool CefListValueImpl::RemoveInternal(int index) { return true; } -void CefListValueImpl::SetInternal(int index, base::Value* value) { +void CefListValueImpl::SetInternal(size_t index, base::Value* value) { DCHECK(value); if (RemoveInternal(index)) mutable_value()->Insert(index, base::WrapUnique(value)); diff --git a/libcef/common/values_impl.h b/libcef/common/values_impl.h index 78fe739d3..85f8bdb7d 100644 --- a/libcef/common/values_impl.h +++ b/libcef/common/values_impl.h @@ -318,26 +318,26 @@ class CefListValueImpl bool SetSize(size_t size) override; size_t GetSize() override; bool Clear() override; - bool Remove(int index) override; - CefValueType GetType(int index) override; - CefRefPtr GetValue(int index) override; - bool GetBool(int index) override; - int GetInt(int index) override; - double GetDouble(int index) override; - CefString GetString(int index) override; - CefRefPtr GetBinary(int index) override; - CefRefPtr GetDictionary(int index) override; - CefRefPtr GetList(int index) override; - bool SetValue(int index, CefRefPtr value) override; - bool SetNull(int index) override; - bool SetBool(int index, bool value) override; - bool SetInt(int index, int value) override; - bool SetDouble(int index, double value) override; - bool SetString(int index, const CefString& value) override; - bool SetBinary(int index, CefRefPtr value) override; - bool SetDictionary(int index, + bool Remove(size_t index) override; + CefValueType GetType(size_t index) override; + CefRefPtr GetValue(size_t index) override; + bool GetBool(size_t index) override; + int GetInt(size_t index) override; + double GetDouble(size_t index) override; + CefString GetString(size_t index) override; + CefRefPtr GetBinary(size_t index) override; + CefRefPtr GetDictionary(size_t index) override; + CefRefPtr GetList(size_t index) override; + bool SetValue(size_t index, CefRefPtr value) override; + bool SetNull(size_t index) override; + bool SetBool(size_t index, bool value) override; + bool SetInt(size_t index, int value) override; + bool SetDouble(size_t index, double value) override; + bool SetString(size_t index, const CefString& value) override; + bool SetBinary(size_t index, CefRefPtr value) override; + bool SetDictionary(size_t index, CefRefPtr value) override; - bool SetList(int index, CefRefPtr value) override; + bool SetList(size_t index, CefRefPtr value) override; private: // See the CefValueBase constructor for usage. @@ -347,8 +347,8 @@ class CefListValueImpl bool read_only, CefValueController* controller); - bool RemoveInternal(int index); - void SetInternal(int index, base::Value* value); + bool RemoveInternal(size_t index); + void SetInternal(size_t index, base::Value* value); DISALLOW_COPY_AND_ASSIGN(CefListValueImpl); }; diff --git a/libcef_dll/cpptoc/list_value_cpptoc.cc b/libcef_dll/cpptoc/list_value_cpptoc.cc index c7b4dd4ff..3eaf91142 100644 --- a/libcef_dll/cpptoc/list_value_cpptoc.cc +++ b/libcef_dll/cpptoc/list_value_cpptoc.cc @@ -174,16 +174,13 @@ int CEF_CALLBACK list_value_clear(struct _cef_list_value_t* self) { return _retval; } -int CEF_CALLBACK list_value_remove(struct _cef_list_value_t* self, int index) { +int CEF_CALLBACK list_value_remove(struct _cef_list_value_t* self, + size_t index) { // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING DCHECK(self); if (!self) return 0; - // Verify param: index; type: simple_byval - DCHECK_GE(index, 0); - if (index < 0) - return 0; // Execute bool _retval = CefListValueCppToC::Get(self)->Remove( @@ -194,16 +191,12 @@ int CEF_CALLBACK list_value_remove(struct _cef_list_value_t* self, int index) { } cef_value_type_t CEF_CALLBACK list_value_get_type( - struct _cef_list_value_t* self, int index) { + struct _cef_list_value_t* self, size_t index) { // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING DCHECK(self); if (!self) return VTYPE_INVALID; - // Verify param: index; type: simple_byval - DCHECK_GE(index, 0); - if (index < 0) - return VTYPE_INVALID; // Execute cef_value_type_t _retval = CefListValueCppToC::Get(self)->GetType( @@ -214,16 +207,12 @@ cef_value_type_t CEF_CALLBACK list_value_get_type( } cef_value_t* CEF_CALLBACK list_value_get_value(struct _cef_list_value_t* self, - int index) { + size_t index) { // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING DCHECK(self); if (!self) return NULL; - // Verify param: index; type: simple_byval - DCHECK_GE(index, 0); - if (index < 0) - return NULL; // Execute CefRefPtr _retval = CefListValueCppToC::Get(self)->GetValue( @@ -234,16 +223,12 @@ cef_value_t* CEF_CALLBACK list_value_get_value(struct _cef_list_value_t* self, } int CEF_CALLBACK list_value_get_bool(struct _cef_list_value_t* self, - int index) { + size_t index) { // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING DCHECK(self); if (!self) return 0; - // Verify param: index; type: simple_byval - DCHECK_GE(index, 0); - if (index < 0) - return 0; // Execute bool _retval = CefListValueCppToC::Get(self)->GetBool( @@ -253,16 +238,13 @@ int CEF_CALLBACK list_value_get_bool(struct _cef_list_value_t* self, return _retval; } -int CEF_CALLBACK list_value_get_int(struct _cef_list_value_t* self, int index) { +int CEF_CALLBACK list_value_get_int(struct _cef_list_value_t* self, + size_t index) { // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING DCHECK(self); if (!self) return 0; - // Verify param: index; type: simple_byval - DCHECK_GE(index, 0); - if (index < 0) - return 0; // Execute int _retval = CefListValueCppToC::Get(self)->GetInt( @@ -273,16 +255,12 @@ int CEF_CALLBACK list_value_get_int(struct _cef_list_value_t* self, int index) { } double CEF_CALLBACK list_value_get_double(struct _cef_list_value_t* self, - int index) { + size_t index) { // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING DCHECK(self); if (!self) return 0; - // Verify param: index; type: simple_byval - DCHECK_GE(index, 0); - if (index < 0) - return 0; // Execute double _retval = CefListValueCppToC::Get(self)->GetDouble( @@ -293,16 +271,12 @@ double CEF_CALLBACK list_value_get_double(struct _cef_list_value_t* self, } cef_string_userfree_t CEF_CALLBACK list_value_get_string( - struct _cef_list_value_t* self, int index) { + struct _cef_list_value_t* self, size_t index) { // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING DCHECK(self); if (!self) return NULL; - // Verify param: index; type: simple_byval - DCHECK_GE(index, 0); - if (index < 0) - return NULL; // Execute CefString _retval = CefListValueCppToC::Get(self)->GetString( @@ -313,16 +287,12 @@ cef_string_userfree_t CEF_CALLBACK list_value_get_string( } cef_binary_value_t* CEF_CALLBACK list_value_get_binary( - struct _cef_list_value_t* self, int index) { + struct _cef_list_value_t* self, size_t index) { // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING DCHECK(self); if (!self) return NULL; - // Verify param: index; type: simple_byval - DCHECK_GE(index, 0); - if (index < 0) - return NULL; // Execute CefRefPtr _retval = CefListValueCppToC::Get(self)->GetBinary( @@ -333,16 +303,12 @@ cef_binary_value_t* CEF_CALLBACK list_value_get_binary( } cef_dictionary_value_t* CEF_CALLBACK list_value_get_dictionary( - struct _cef_list_value_t* self, int index) { + struct _cef_list_value_t* self, size_t index) { // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING DCHECK(self); if (!self) return NULL; - // Verify param: index; type: simple_byval - DCHECK_GE(index, 0); - if (index < 0) - return NULL; // Execute CefRefPtr _retval = CefListValueCppToC::Get( @@ -354,16 +320,12 @@ cef_dictionary_value_t* CEF_CALLBACK list_value_get_dictionary( } struct _cef_list_value_t* CEF_CALLBACK list_value_get_list( - struct _cef_list_value_t* self, int index) { + struct _cef_list_value_t* self, size_t index) { // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING DCHECK(self); if (!self) return NULL; - // Verify param: index; type: simple_byval - DCHECK_GE(index, 0); - if (index < 0) - return NULL; // Execute CefRefPtr _retval = CefListValueCppToC::Get(self)->GetList( @@ -373,17 +335,13 @@ struct _cef_list_value_t* CEF_CALLBACK list_value_get_list( return CefListValueCppToC::Wrap(_retval); } -int CEF_CALLBACK list_value_set_value(struct _cef_list_value_t* self, int index, - cef_value_t* value) { +int CEF_CALLBACK list_value_set_value(struct _cef_list_value_t* self, + size_t index, cef_value_t* value) { // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING DCHECK(self); if (!self) return 0; - // Verify param: index; type: simple_byval - DCHECK_GE(index, 0); - if (index < 0) - return 0; // Verify param: value; type: refptr_same DCHECK(value); if (!value) @@ -399,16 +357,12 @@ int CEF_CALLBACK list_value_set_value(struct _cef_list_value_t* self, int index, } int CEF_CALLBACK list_value_set_null(struct _cef_list_value_t* self, - int index) { + size_t index) { // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING DCHECK(self); if (!self) return 0; - // Verify param: index; type: simple_byval - DCHECK_GE(index, 0); - if (index < 0) - return 0; // Execute bool _retval = CefListValueCppToC::Get(self)->SetNull( @@ -418,17 +372,13 @@ int CEF_CALLBACK list_value_set_null(struct _cef_list_value_t* self, return _retval; } -int CEF_CALLBACK list_value_set_bool(struct _cef_list_value_t* self, int index, - int value) { +int CEF_CALLBACK list_value_set_bool(struct _cef_list_value_t* self, + size_t index, int value) { // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING DCHECK(self); if (!self) return 0; - // Verify param: index; type: simple_byval - DCHECK_GE(index, 0); - if (index < 0) - return 0; // Execute bool _retval = CefListValueCppToC::Get(self)->SetBool( @@ -439,17 +389,13 @@ int CEF_CALLBACK list_value_set_bool(struct _cef_list_value_t* self, int index, return _retval; } -int CEF_CALLBACK list_value_set_int(struct _cef_list_value_t* self, int index, - int value) { +int CEF_CALLBACK list_value_set_int(struct _cef_list_value_t* self, + size_t index, int value) { // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING DCHECK(self); if (!self) return 0; - // Verify param: index; type: simple_byval - DCHECK_GE(index, 0); - if (index < 0) - return 0; // Execute bool _retval = CefListValueCppToC::Get(self)->SetInt( @@ -461,16 +407,12 @@ int CEF_CALLBACK list_value_set_int(struct _cef_list_value_t* self, int index, } int CEF_CALLBACK list_value_set_double(struct _cef_list_value_t* self, - int index, double value) { + size_t index, double value) { // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING DCHECK(self); if (!self) return 0; - // Verify param: index; type: simple_byval - DCHECK_GE(index, 0); - if (index < 0) - return 0; // Execute bool _retval = CefListValueCppToC::Get(self)->SetDouble( @@ -482,16 +424,12 @@ int CEF_CALLBACK list_value_set_double(struct _cef_list_value_t* self, } int CEF_CALLBACK list_value_set_string(struct _cef_list_value_t* self, - int index, const cef_string_t* value) { + size_t index, const cef_string_t* value) { // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING DCHECK(self); if (!self) return 0; - // Verify param: index; type: simple_byval - DCHECK_GE(index, 0); - if (index < 0) - return 0; // Unverified params: value // Execute @@ -504,16 +442,12 @@ int CEF_CALLBACK list_value_set_string(struct _cef_list_value_t* self, } int CEF_CALLBACK list_value_set_binary(struct _cef_list_value_t* self, - int index, cef_binary_value_t* value) { + size_t index, cef_binary_value_t* value) { // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING DCHECK(self); if (!self) return 0; - // Verify param: index; type: simple_byval - DCHECK_GE(index, 0); - if (index < 0) - return 0; // Verify param: value; type: refptr_same DCHECK(value); if (!value) @@ -529,16 +463,12 @@ int CEF_CALLBACK list_value_set_binary(struct _cef_list_value_t* self, } int CEF_CALLBACK list_value_set_dictionary(struct _cef_list_value_t* self, - int index, cef_dictionary_value_t* value) { + size_t index, cef_dictionary_value_t* value) { // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING DCHECK(self); if (!self) return 0; - // Verify param: index; type: simple_byval - DCHECK_GE(index, 0); - if (index < 0) - return 0; // Verify param: value; type: refptr_same DCHECK(value); if (!value) @@ -553,17 +483,13 @@ int CEF_CALLBACK list_value_set_dictionary(struct _cef_list_value_t* self, return _retval; } -int CEF_CALLBACK list_value_set_list(struct _cef_list_value_t* self, int index, - struct _cef_list_value_t* value) { +int CEF_CALLBACK list_value_set_list(struct _cef_list_value_t* self, + size_t index, struct _cef_list_value_t* value) { // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING DCHECK(self); if (!self) return 0; - // Verify param: index; type: simple_byval - DCHECK_GE(index, 0); - if (index < 0) - return 0; // Verify param: value; type: refptr_same DCHECK(value); if (!value) diff --git a/libcef_dll/ctocpp/list_value_ctocpp.cc b/libcef_dll/ctocpp/list_value_ctocpp.cc index 333464768..7743aaab8 100644 --- a/libcef_dll/ctocpp/list_value_ctocpp.cc +++ b/libcef_dll/ctocpp/list_value_ctocpp.cc @@ -170,18 +170,13 @@ bool CefListValueCToCpp::Clear() { return _retval?true:false; } -bool CefListValueCToCpp::Remove(int index) { +bool CefListValueCToCpp::Remove(size_t index) { cef_list_value_t* _struct = GetStruct(); if (CEF_MEMBER_MISSING(_struct, remove)) return false; // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING - // Verify param: index; type: simple_byval - DCHECK_GE(index, 0); - if (index < 0) - return false; - // Execute int _retval = _struct->remove(_struct, index); @@ -190,18 +185,13 @@ bool CefListValueCToCpp::Remove(int index) { return _retval?true:false; } -CefValueType CefListValueCToCpp::GetType(int index) { +CefValueType CefListValueCToCpp::GetType(size_t index) { cef_list_value_t* _struct = GetStruct(); if (CEF_MEMBER_MISSING(_struct, get_type)) return VTYPE_INVALID; // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING - // Verify param: index; type: simple_byval - DCHECK_GE(index, 0); - if (index < 0) - return VTYPE_INVALID; - // Execute cef_value_type_t _retval = _struct->get_type(_struct, index); @@ -210,18 +200,13 @@ CefValueType CefListValueCToCpp::GetType(int index) { return _retval; } -CefRefPtr CefListValueCToCpp::GetValue(int index) { +CefRefPtr CefListValueCToCpp::GetValue(size_t index) { cef_list_value_t* _struct = GetStruct(); if (CEF_MEMBER_MISSING(_struct, get_value)) return NULL; // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING - // Verify param: index; type: simple_byval - DCHECK_GE(index, 0); - if (index < 0) - return NULL; - // Execute cef_value_t* _retval = _struct->get_value(_struct, index); @@ -230,18 +215,13 @@ CefRefPtr CefListValueCToCpp::GetValue(int index) { return CefValueCToCpp::Wrap(_retval); } -bool CefListValueCToCpp::GetBool(int index) { +bool CefListValueCToCpp::GetBool(size_t index) { cef_list_value_t* _struct = GetStruct(); if (CEF_MEMBER_MISSING(_struct, get_bool)) return false; // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING - // Verify param: index; type: simple_byval - DCHECK_GE(index, 0); - if (index < 0) - return false; - // Execute int _retval = _struct->get_bool(_struct, index); @@ -250,18 +230,13 @@ bool CefListValueCToCpp::GetBool(int index) { return _retval?true:false; } -int CefListValueCToCpp::GetInt(int index) { +int CefListValueCToCpp::GetInt(size_t index) { cef_list_value_t* _struct = GetStruct(); if (CEF_MEMBER_MISSING(_struct, get_int)) return 0; // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING - // Verify param: index; type: simple_byval - DCHECK_GE(index, 0); - if (index < 0) - return 0; - // Execute int _retval = _struct->get_int(_struct, index); @@ -270,18 +245,13 @@ int CefListValueCToCpp::GetInt(int index) { return _retval; } -double CefListValueCToCpp::GetDouble(int index) { +double CefListValueCToCpp::GetDouble(size_t index) { cef_list_value_t* _struct = GetStruct(); if (CEF_MEMBER_MISSING(_struct, get_double)) return 0; // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING - // Verify param: index; type: simple_byval - DCHECK_GE(index, 0); - if (index < 0) - return 0; - // Execute double _retval = _struct->get_double(_struct, index); @@ -290,18 +260,13 @@ double CefListValueCToCpp::GetDouble(int index) { return _retval; } -CefString CefListValueCToCpp::GetString(int index) { +CefString CefListValueCToCpp::GetString(size_t index) { cef_list_value_t* _struct = GetStruct(); if (CEF_MEMBER_MISSING(_struct, get_string)) return CefString(); // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING - // Verify param: index; type: simple_byval - DCHECK_GE(index, 0); - if (index < 0) - return CefString(); - // Execute cef_string_userfree_t _retval = _struct->get_string(_struct, index); @@ -312,18 +277,13 @@ CefString CefListValueCToCpp::GetString(int index) { return _retvalStr; } -CefRefPtr CefListValueCToCpp::GetBinary(int index) { +CefRefPtr CefListValueCToCpp::GetBinary(size_t index) { cef_list_value_t* _struct = GetStruct(); if (CEF_MEMBER_MISSING(_struct, get_binary)) return NULL; // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING - // Verify param: index; type: simple_byval - DCHECK_GE(index, 0); - if (index < 0) - return NULL; - // Execute cef_binary_value_t* _retval = _struct->get_binary(_struct, index); @@ -332,18 +292,13 @@ CefRefPtr CefListValueCToCpp::GetBinary(int index) { return CefBinaryValueCToCpp::Wrap(_retval); } -CefRefPtr CefListValueCToCpp::GetDictionary(int index) { +CefRefPtr CefListValueCToCpp::GetDictionary(size_t index) { cef_list_value_t* _struct = GetStruct(); if (CEF_MEMBER_MISSING(_struct, get_dictionary)) return NULL; // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING - // Verify param: index; type: simple_byval - DCHECK_GE(index, 0); - if (index < 0) - return NULL; - // Execute cef_dictionary_value_t* _retval = _struct->get_dictionary(_struct, index); @@ -352,18 +307,13 @@ CefRefPtr CefListValueCToCpp::GetDictionary(int index) { return CefDictionaryValueCToCpp::Wrap(_retval); } -CefRefPtr CefListValueCToCpp::GetList(int index) { +CefRefPtr CefListValueCToCpp::GetList(size_t index) { cef_list_value_t* _struct = GetStruct(); if (CEF_MEMBER_MISSING(_struct, get_list)) return NULL; // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING - // Verify param: index; type: simple_byval - DCHECK_GE(index, 0); - if (index < 0) - return NULL; - // Execute cef_list_value_t* _retval = _struct->get_list(_struct, index); @@ -372,17 +322,13 @@ CefRefPtr CefListValueCToCpp::GetList(int index) { return CefListValueCToCpp::Wrap(_retval); } -bool CefListValueCToCpp::SetValue(int index, CefRefPtr value) { +bool CefListValueCToCpp::SetValue(size_t index, CefRefPtr value) { cef_list_value_t* _struct = GetStruct(); if (CEF_MEMBER_MISSING(_struct, set_value)) return false; // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING - // Verify param: index; type: simple_byval - DCHECK_GE(index, 0); - if (index < 0) - return false; // Verify param: value; type: refptr_same DCHECK(value.get()); if (!value.get()) @@ -397,18 +343,13 @@ bool CefListValueCToCpp::SetValue(int index, CefRefPtr value) { return _retval?true:false; } -bool CefListValueCToCpp::SetNull(int index) { +bool CefListValueCToCpp::SetNull(size_t index) { cef_list_value_t* _struct = GetStruct(); if (CEF_MEMBER_MISSING(_struct, set_null)) return false; // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING - // Verify param: index; type: simple_byval - DCHECK_GE(index, 0); - if (index < 0) - return false; - // Execute int _retval = _struct->set_null(_struct, index); @@ -417,18 +358,13 @@ bool CefListValueCToCpp::SetNull(int index) { return _retval?true:false; } -bool CefListValueCToCpp::SetBool(int index, bool value) { +bool CefListValueCToCpp::SetBool(size_t index, bool value) { cef_list_value_t* _struct = GetStruct(); if (CEF_MEMBER_MISSING(_struct, set_bool)) return false; // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING - // Verify param: index; type: simple_byval - DCHECK_GE(index, 0); - if (index < 0) - return false; - // Execute int _retval = _struct->set_bool(_struct, index, @@ -438,18 +374,13 @@ bool CefListValueCToCpp::SetBool(int index, bool value) { return _retval?true:false; } -bool CefListValueCToCpp::SetInt(int index, int value) { +bool CefListValueCToCpp::SetInt(size_t index, int value) { cef_list_value_t* _struct = GetStruct(); if (CEF_MEMBER_MISSING(_struct, set_int)) return false; // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING - // Verify param: index; type: simple_byval - DCHECK_GE(index, 0); - if (index < 0) - return false; - // Execute int _retval = _struct->set_int(_struct, index, @@ -459,18 +390,13 @@ bool CefListValueCToCpp::SetInt(int index, int value) { return _retval?true:false; } -bool CefListValueCToCpp::SetDouble(int index, double value) { +bool CefListValueCToCpp::SetDouble(size_t index, double value) { cef_list_value_t* _struct = GetStruct(); if (CEF_MEMBER_MISSING(_struct, set_double)) return false; // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING - // Verify param: index; type: simple_byval - DCHECK_GE(index, 0); - if (index < 0) - return false; - // Execute int _retval = _struct->set_double(_struct, index, @@ -480,17 +406,13 @@ bool CefListValueCToCpp::SetDouble(int index, double value) { return _retval?true:false; } -bool CefListValueCToCpp::SetString(int index, const CefString& value) { +bool CefListValueCToCpp::SetString(size_t index, const CefString& value) { cef_list_value_t* _struct = GetStruct(); if (CEF_MEMBER_MISSING(_struct, set_string)) return false; // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING - // Verify param: index; type: simple_byval - DCHECK_GE(index, 0); - if (index < 0) - return false; // Unverified params: value // Execute @@ -502,17 +424,14 @@ bool CefListValueCToCpp::SetString(int index, const CefString& value) { return _retval?true:false; } -bool CefListValueCToCpp::SetBinary(int index, CefRefPtr value) { +bool CefListValueCToCpp::SetBinary(size_t index, + CefRefPtr value) { cef_list_value_t* _struct = GetStruct(); if (CEF_MEMBER_MISSING(_struct, set_binary)) return false; // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING - // Verify param: index; type: simple_byval - DCHECK_GE(index, 0); - if (index < 0) - return false; // Verify param: value; type: refptr_same DCHECK(value.get()); if (!value.get()) @@ -527,7 +446,7 @@ bool CefListValueCToCpp::SetBinary(int index, CefRefPtr value) { return _retval?true:false; } -bool CefListValueCToCpp::SetDictionary(int index, +bool CefListValueCToCpp::SetDictionary(size_t index, CefRefPtr value) { cef_list_value_t* _struct = GetStruct(); if (CEF_MEMBER_MISSING(_struct, set_dictionary)) @@ -535,10 +454,6 @@ bool CefListValueCToCpp::SetDictionary(int index, // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING - // Verify param: index; type: simple_byval - DCHECK_GE(index, 0); - if (index < 0) - return false; // Verify param: value; type: refptr_same DCHECK(value.get()); if (!value.get()) @@ -553,17 +468,13 @@ bool CefListValueCToCpp::SetDictionary(int index, return _retval?true:false; } -bool CefListValueCToCpp::SetList(int index, CefRefPtr value) { +bool CefListValueCToCpp::SetList(size_t index, CefRefPtr value) { cef_list_value_t* _struct = GetStruct(); if (CEF_MEMBER_MISSING(_struct, set_list)) return false; // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING - // Verify param: index; type: simple_byval - DCHECK_GE(index, 0); - if (index < 0) - return false; // Verify param: value; type: refptr_same DCHECK(value.get()); if (!value.get()) diff --git a/libcef_dll/ctocpp/list_value_ctocpp.h b/libcef_dll/ctocpp/list_value_ctocpp.h index 919021488..9a7d44581 100644 --- a/libcef_dll/ctocpp/list_value_ctocpp.h +++ b/libcef_dll/ctocpp/list_value_ctocpp.h @@ -39,25 +39,26 @@ class CefListValueCToCpp bool SetSize(size_t size) OVERRIDE; size_t GetSize() OVERRIDE; bool Clear() OVERRIDE; - bool Remove(int index) OVERRIDE; - CefValueType GetType(int index) OVERRIDE; - CefRefPtr GetValue(int index) OVERRIDE; - bool GetBool(int index) OVERRIDE; - int GetInt(int index) OVERRIDE; - double GetDouble(int index) OVERRIDE; - CefString GetString(int index) OVERRIDE; - CefRefPtr GetBinary(int index) OVERRIDE; - CefRefPtr GetDictionary(int index) OVERRIDE; - CefRefPtr GetList(int index) OVERRIDE; - bool SetValue(int index, CefRefPtr value) OVERRIDE; - bool SetNull(int index) OVERRIDE; - bool SetBool(int index, bool value) OVERRIDE; - bool SetInt(int index, int value) OVERRIDE; - bool SetDouble(int index, double value) OVERRIDE; - bool SetString(int index, const CefString& value) OVERRIDE; - bool SetBinary(int index, CefRefPtr value) OVERRIDE; - bool SetDictionary(int index, CefRefPtr value) OVERRIDE; - bool SetList(int index, CefRefPtr value) OVERRIDE; + bool Remove(size_t index) OVERRIDE; + CefValueType GetType(size_t index) OVERRIDE; + CefRefPtr GetValue(size_t index) OVERRIDE; + bool GetBool(size_t index) OVERRIDE; + int GetInt(size_t index) OVERRIDE; + double GetDouble(size_t index) OVERRIDE; + CefString GetString(size_t index) OVERRIDE; + CefRefPtr GetBinary(size_t index) OVERRIDE; + CefRefPtr GetDictionary(size_t index) OVERRIDE; + CefRefPtr GetList(size_t index) OVERRIDE; + bool SetValue(size_t index, CefRefPtr value) OVERRIDE; + bool SetNull(size_t index) OVERRIDE; + bool SetBool(size_t index, bool value) OVERRIDE; + bool SetInt(size_t index, int value) OVERRIDE; + bool SetDouble(size_t index, double value) OVERRIDE; + bool SetString(size_t index, const CefString& value) OVERRIDE; + bool SetBinary(size_t index, CefRefPtr value) OVERRIDE; + bool SetDictionary(size_t index, + CefRefPtr value) OVERRIDE; + bool SetList(size_t index, CefRefPtr value) OVERRIDE; }; #endif // USING_CEF_SHARED diff --git a/libcef_dll/transfer_util.cc b/libcef_dll/transfer_util.cc index e9d8d4e22..b35460f21 100644 --- a/libcef_dll/transfer_util.cc +++ b/libcef_dll/transfer_util.cc @@ -7,10 +7,10 @@ void transfer_string_list_contents(cef_string_list_t fromList, StringList& toList) { - int size = cef_string_list_size(fromList); + size_t size = cef_string_list_size(fromList); CefString value; - for(int i = 0; i < size; i++) { + for(size_t i = 0; i < size; i++) { cef_string_list_value(fromList, i, value.GetWritableStruct()); toList.push_back(value); } @@ -27,10 +27,10 @@ void transfer_string_list_contents(const StringList& fromList, void transfer_string_map_contents(cef_string_map_t fromMap, StringMap& toMap) { - int size = cef_string_map_size(fromMap); + size_t size = cef_string_map_size(fromMap); CefString key, value; - for(int i = 0; i < size; ++i) { + for(size_t i = 0; i < size; ++i) { cef_string_map_key(fromMap, i, key.GetWritableStruct()); cef_string_map_value(fromMap, i, value.GetWritableStruct()); @@ -49,10 +49,10 @@ void transfer_string_map_contents(const StringMap& fromMap, void transfer_string_multimap_contents(cef_string_multimap_t fromMap, StringMultimap& toMap) { - int size = cef_string_multimap_size(fromMap); + size_t size = cef_string_multimap_size(fromMap); CefString key, value; - for(int i = 0; i < size; ++i) { + for(size_t i = 0; i < size; ++i) { cef_string_multimap_key(fromMap, i, key.GetWritableStruct()); cef_string_multimap_value(fromMap, i, value.GetWritableStruct()); diff --git a/tests/unittests/parser_unittest.cc b/tests/unittests/parser_unittest.cc index 52a698864..16825add9 100644 --- a/tests/unittests/parser_unittest.cc +++ b/tests/unittests/parser_unittest.cc @@ -309,7 +309,7 @@ TEST(ParserTest, ParseJSONNull) { CefRefPtr dict = value->GetDictionary(); CefDictionaryValue::KeyList key_list; EXPECT_TRUE(dict->GetKeys(key_list)); - EXPECT_EQ((size_t)1, key_list.size()); + EXPECT_EQ(1U, key_list.size()); EXPECT_EQ("key1", key_list[0].ToString()); EXPECT_EQ(VTYPE_NULL, dict->GetType("key1")); @@ -342,7 +342,7 @@ TEST(ParserTest, ParseJSONDictionary) { CefRefPtr dict = value->GetDictionary(); CefDictionaryValue::KeyList key_list; EXPECT_TRUE(dict->GetKeys(key_list)); - EXPECT_EQ((size_t)3, key_list.size()); + EXPECT_EQ(3U, key_list.size()); EXPECT_EQ("key1", key_list[0].ToString()); EXPECT_EQ("key2", key_list[1].ToString()); EXPECT_EQ("key3", key_list[2].ToString()); @@ -354,7 +354,7 @@ TEST(ParserTest, ParseJSONDictionary) { CefRefPtr key3 = dict->GetList("key3"); EXPECT_TRUE(NULL != key3); EXPECT_TRUE(key3->IsValid()); - EXPECT_EQ((size_t)3, key3->GetSize()); + EXPECT_EQ(3U, key3->GetSize()); EXPECT_EQ(1, key3->GetInt(0)); EXPECT_EQ(2, key3->GetInt(1)); EXPECT_EQ(3, key3->GetInt(2)); @@ -375,7 +375,7 @@ TEST(ParserTest, ParseJSONList) { CefRefPtr list = value->GetList(); EXPECT_TRUE(NULL != list); EXPECT_TRUE(list->IsValid()); - EXPECT_EQ((size_t)3, list->GetSize()); + EXPECT_EQ(3U, list->GetSize()); EXPECT_EQ(VTYPE_STRING, list->GetType(0)); EXPECT_EQ(list->GetString(0), "value1"); @@ -385,9 +385,9 @@ TEST(ParserTest, ParseJSONList) { CefRefPtr dict = list->GetDictionary(2); CefDictionaryValue::KeyList key_list2; EXPECT_TRUE(dict->GetKeys(key_list2)); - EXPECT_EQ((size_t)1, key_list2.size()); + EXPECT_EQ(1U, key_list2.size()); CefRefPtr list2 = dict->GetList("key3"); - EXPECT_EQ((size_t)3, list2->GetSize()); + EXPECT_EQ(3U, list2->GetSize()); EXPECT_EQ(1, list2->GetInt(0)); EXPECT_EQ(2, list2->GetInt(1)); EXPECT_EQ(3, list2->GetInt(2)); diff --git a/tests/unittests/process_message_unittest.cc b/tests/unittests/process_message_unittest.cc index b96257e74..cfb60f6fc 100644 --- a/tests/unittests/process_message_unittest.cc +++ b/tests/unittests/process_message_unittest.cc @@ -25,7 +25,7 @@ CefRefPtr CreateTestMessage() { CefRefPtr args = msg->GetArgumentList(); EXPECT_TRUE(args.get()); - int index = 0; + size_t index = 0; args->SetNull(index++); args->SetInt(index++, 5); args->SetDouble(index++, 10.543); @@ -33,7 +33,7 @@ CefRefPtr CreateTestMessage() { args->SetString(index++, "test string"); args->SetList(index++, args->Copy()); - EXPECT_EQ((size_t)index, args->GetSize()); + EXPECT_EQ(index, args->GetSize()); return msg; } diff --git a/tests/unittests/string_unittest.cc b/tests/unittests/string_unittest.cc index 26c6cf50b..8436b0125 100644 --- a/tests/unittests/string_unittest.cc +++ b/tests/unittests/string_unittest.cc @@ -170,32 +170,32 @@ TEST(StringTest, List) { CefString str; int ret; - EXPECT_EQ(cef_string_list_size(listPtr), 3); + EXPECT_EQ(cef_string_list_size(listPtr), 3U); - ret = cef_string_list_value(listPtr, 0, str.GetWritableStruct()); + ret = cef_string_list_value(listPtr, 0U, str.GetWritableStruct()); EXPECT_TRUE(ret); EXPECT_EQ(str, "String 1"); - ret = cef_string_list_value(listPtr, 1, str.GetWritableStruct()); + ret = cef_string_list_value(listPtr, 1U, str.GetWritableStruct()); EXPECT_TRUE(ret); EXPECT_EQ(str, "String 2"); - ret = cef_string_list_value(listPtr, 2, str.GetWritableStruct()); + ret = cef_string_list_value(listPtr, 2U, str.GetWritableStruct()); EXPECT_TRUE(ret); EXPECT_EQ(str, "String 3"); cef_string_list_t listPtr2 = cef_string_list_copy(listPtr); cef_string_list_clear(listPtr); - EXPECT_EQ(cef_string_list_size(listPtr), 0); + EXPECT_EQ(cef_string_list_size(listPtr), 0U); cef_string_list_free(listPtr); - EXPECT_EQ(cef_string_list_size(listPtr2), 3); + EXPECT_EQ(cef_string_list_size(listPtr2), 3U); - ret = cef_string_list_value(listPtr2, 0, str.GetWritableStruct()); + ret = cef_string_list_value(listPtr2, 0U, str.GetWritableStruct()); EXPECT_TRUE(ret); EXPECT_EQ(str, "String 1"); - ret = cef_string_list_value(listPtr2, 1, str.GetWritableStruct()); + ret = cef_string_list_value(listPtr2, 1U, str.GetWritableStruct()); EXPECT_TRUE(ret); EXPECT_EQ(str, "String 2"); - ret = cef_string_list_value(listPtr2, 2, str.GetWritableStruct()); + ret = cef_string_list_value(listPtr2, 2U, str.GetWritableStruct()); EXPECT_TRUE(ret); EXPECT_EQ(str, "String 3"); @@ -237,26 +237,26 @@ TEST(StringTest, Map) { CefString str; int ret; - EXPECT_EQ(cef_string_map_size(mapPtr), 3); + EXPECT_EQ(cef_string_map_size(mapPtr), 3U); - ret = cef_string_map_key(mapPtr, 0, str.GetWritableStruct()); + ret = cef_string_map_key(mapPtr, 0U, str.GetWritableStruct()); EXPECT_TRUE(ret); EXPECT_EQ(str, "Key 1"); - ret = cef_string_map_value(mapPtr, 0, str.GetWritableStruct()); + ret = cef_string_map_value(mapPtr, 0U, str.GetWritableStruct()); EXPECT_TRUE(ret); EXPECT_EQ(str, "String 1"); - ret = cef_string_map_key(mapPtr, 1, str.GetWritableStruct()); + ret = cef_string_map_key(mapPtr, 1U, str.GetWritableStruct()); EXPECT_TRUE(ret); EXPECT_EQ(str, "Key 2"); - ret = cef_string_map_value(mapPtr, 1, str.GetWritableStruct()); + ret = cef_string_map_value(mapPtr, 1U, str.GetWritableStruct()); EXPECT_TRUE(ret); EXPECT_EQ(str, "String 2"); - ret = cef_string_map_key(mapPtr, 2, str.GetWritableStruct()); + ret = cef_string_map_key(mapPtr, 2U, str.GetWritableStruct()); EXPECT_TRUE(ret); EXPECT_EQ(str, "Key 3"); - ret = cef_string_map_value(mapPtr, 2, str.GetWritableStruct()); + ret = cef_string_map_value(mapPtr, 2U, str.GetWritableStruct()); EXPECT_TRUE(ret); EXPECT_EQ(str, "String 3"); @@ -267,7 +267,7 @@ TEST(StringTest, Map) { EXPECT_EQ(str, "String 2"); cef_string_map_clear(mapPtr); - EXPECT_EQ(cef_string_map_size(mapPtr), 0); + EXPECT_EQ(cef_string_map_size(mapPtr), 0U); cef_string_map_free(mapPtr); } @@ -295,9 +295,9 @@ TEST(StringTest, Multimap) { // Either of "String 2" or "String 2.1" is fine since // std::multimap provides no guarantee wrt the order of // values with the same key. - EXPECT_EQ(same_key_it->second.ToString().find("String 2"), (size_t)0); - EXPECT_EQ((++same_key_it)->second.ToString().find("String 2"), (size_t)0); - EXPECT_EQ(map.count("Key 2"), (size_t)2); + EXPECT_EQ(same_key_it->second.ToString().find("String 2"), 0U); + EXPECT_EQ((++same_key_it)->second.ToString().find("String 2"), 0U); + EXPECT_EQ(map.count("Key 2"), 2U); EXPECT_EQ(map.find("Key 1")->second, "String 1"); EXPECT_EQ(map.find("Key 3")->second, "String 3"); @@ -313,53 +313,53 @@ TEST(StringTest, Multimap) { CefString str; int ret; - EXPECT_EQ(cef_string_multimap_size(mapPtr), 4); + EXPECT_EQ(cef_string_multimap_size(mapPtr), 4U); - ret = cef_string_multimap_key(mapPtr, 0, str.GetWritableStruct()); + ret = cef_string_multimap_key(mapPtr, 0U, str.GetWritableStruct()); EXPECT_TRUE(ret); EXPECT_EQ(str, "Key 1"); - ret = cef_string_multimap_value(mapPtr, 0, str.GetWritableStruct()); + ret = cef_string_multimap_value(mapPtr, 0U, str.GetWritableStruct()); EXPECT_TRUE(ret); EXPECT_EQ(str, "String 1"); - ret = cef_string_multimap_key(mapPtr, 1, str.GetWritableStruct()); + ret = cef_string_multimap_key(mapPtr, 1U, str.GetWritableStruct()); EXPECT_TRUE(ret); EXPECT_EQ(str, "Key 2"); - ret = cef_string_multimap_value(mapPtr, 1, str.GetWritableStruct()); + ret = cef_string_multimap_value(mapPtr, 1U, str.GetWritableStruct()); EXPECT_TRUE(ret); - EXPECT_EQ(str.ToString().find("String 2"), (size_t)0); + EXPECT_EQ(str.ToString().find("String 2"), 0U); - ret = cef_string_multimap_key(mapPtr, 2, str.GetWritableStruct()); + ret = cef_string_multimap_key(mapPtr, 2U, str.GetWritableStruct()); EXPECT_TRUE(ret); EXPECT_EQ(str, "Key 2"); - ret = cef_string_multimap_value(mapPtr, 2, str.GetWritableStruct()); + ret = cef_string_multimap_value(mapPtr, 2U, str.GetWritableStruct()); EXPECT_TRUE(ret); - EXPECT_EQ(str.ToString().find("String 2"), (size_t)0); + EXPECT_EQ(str.ToString().find("String 2"), 0U); - ret = cef_string_multimap_key(mapPtr, 3, str.GetWritableStruct()); + ret = cef_string_multimap_key(mapPtr, 3U, str.GetWritableStruct()); EXPECT_TRUE(ret); EXPECT_EQ(str, "Key 3"); - ret = cef_string_multimap_value(mapPtr, 3, str.GetWritableStruct()); + ret = cef_string_multimap_value(mapPtr, 3U, str.GetWritableStruct()); EXPECT_TRUE(ret); EXPECT_EQ(str, "String 3"); CefString key; key.FromASCII("Key 2"); - ret = cef_string_multimap_find_count(mapPtr, key.GetStruct()); - EXPECT_EQ(ret, 2); + size_t size = cef_string_multimap_find_count(mapPtr, key.GetStruct()); + EXPECT_EQ(size, 2U); ret = cef_string_multimap_enumerate(mapPtr, - key.GetStruct(), 0, str.GetWritableStruct()); + key.GetStruct(), 0U, str.GetWritableStruct()); EXPECT_TRUE(ret); - EXPECT_EQ(str.ToString().find("String 2"), (size_t)0); + EXPECT_EQ(str.ToString().find("String 2"), 0U); ret = cef_string_multimap_enumerate(mapPtr, - key.GetStruct(), 1, str.GetWritableStruct()); + key.GetStruct(), 1U, str.GetWritableStruct()); EXPECT_TRUE(ret); - EXPECT_EQ(str.ToString().find("String 2"), (size_t)0); + EXPECT_EQ(str.ToString().find("String 2"), 0U); cef_string_multimap_clear(mapPtr); - EXPECT_EQ(cef_string_multimap_size(mapPtr), 0); + EXPECT_EQ(cef_string_multimap_size(mapPtr), 0U); cef_string_multimap_free(mapPtr); } diff --git a/tests/unittests/test_util.cc b/tests/unittests/test_util.cc index 3109d7ec5..f3a5b5646 100644 --- a/tests/unittests/test_util.cc +++ b/tests/unittests/test_util.cc @@ -209,10 +209,10 @@ void TestListEqual(CefRefPtr val1, EXPECT_TRUE(val1->IsEqual(val2)); EXPECT_TRUE(val2->IsEqual(val1)); - int size = static_cast(val1->GetSize()); - EXPECT_EQ(size, static_cast(val2->GetSize())); + size_t size = val1->GetSize(); + EXPECT_EQ(size, val2->GetSize()); - for (int i = 0; i < size; ++i) { + for (size_t i = 0; i < size; ++i) { CefValueType type = val1->GetType(i); EXPECT_EQ(type, val2->GetType(i)); switch (type) { diff --git a/tests/unittests/values_unittest.cc b/tests/unittests/values_unittest.cc index 9bd8d1185..2ea4e5814 100644 --- a/tests/unittests/values_unittest.cc +++ b/tests/unittests/values_unittest.cc @@ -310,7 +310,7 @@ class DictionaryTask : public CefTask { // LIST TEST HELPERS // Test list null value. -void TestListNull(CefRefPtr value, int index) { +void TestListNull(CefRefPtr value, size_t index) { CefValueType type = value->GetType(index); EXPECT_TRUE(type == VTYPE_INVALID || type == VTYPE_NULL); @@ -319,7 +319,7 @@ void TestListNull(CefRefPtr value, int index) { } // Test list bool value. -void TestListBool(CefRefPtr value, int index) { +void TestListBool(CefRefPtr value, size_t index) { CefValueType type = value->GetType(index); EXPECT_TRUE(type == VTYPE_INVALID || type == VTYPE_NULL); @@ -329,7 +329,7 @@ void TestListBool(CefRefPtr value, int index) { } // Test list int value. -void TestListInt(CefRefPtr value, int index) { +void TestListInt(CefRefPtr value, size_t index) { CefValueType type = value->GetType(index); EXPECT_TRUE(type == VTYPE_INVALID || type == VTYPE_NULL); @@ -339,7 +339,7 @@ void TestListInt(CefRefPtr value, int index) { } // Test list double value. -void TestListDouble(CefRefPtr value, int index) { +void TestListDouble(CefRefPtr value, size_t index) { CefValueType type = value->GetType(index); EXPECT_TRUE(type == VTYPE_INVALID || type == VTYPE_NULL); @@ -349,7 +349,7 @@ void TestListDouble(CefRefPtr value, int index) { } // Test list string value. -void TestListString(CefRefPtr value, int index) { +void TestListString(CefRefPtr value, size_t index) { CefValueType type = value->GetType(index); EXPECT_TRUE(type == VTYPE_INVALID || type == VTYPE_NULL); @@ -359,7 +359,7 @@ void TestListString(CefRefPtr value, int index) { } // Test list binary value. -void TestListBinary(CefRefPtr value, int index, +void TestListBinary(CefRefPtr value, size_t index, char* binary_data, size_t binary_data_size, CefRefPtr& binary_value) { binary_value = CefBinaryValue::Create(binary_data, binary_data_size); @@ -381,7 +381,7 @@ void TestListBinary(CefRefPtr value, int index, } // Test list dictionary value. -void TestListDictionary(CefRefPtr value, int index, +void TestListDictionary(CefRefPtr value, size_t index, CefRefPtr& dictionary_value) { dictionary_value = CefDictionaryValue::Create(); EXPECT_TRUE(dictionary_value.get()); @@ -407,7 +407,7 @@ void TestListDictionary(CefRefPtr value, int index, } // Test list list value. -void TestListList(CefRefPtr value, int index, +void TestListList(CefRefPtr value, size_t index, CefRefPtr& list_value) { list_value = CefListValue::Create(); EXPECT_TRUE(list_value.get()); @@ -467,6 +467,12 @@ void TestList(CefRefPtr value, // Test the size. EXPECT_EQ(8U, value->GetSize()); + // Test various operations with invalid index. + EXPECT_FALSE(list_value->Remove(9U)); + EXPECT_TRUE(list_value->GetType(10U) == VTYPE_INVALID); + EXPECT_FALSE(list_value->GetValue(11U).get() != nullptr && + list_value->GetValue(11U)->IsValid()); + // Test copy. CefRefPtr copy = value->Copy(); TestListEqual(value, copy);