- Add CefValue for wrapping various value types in a single object (issue #1607).

- Add IsSame() and IsEqual() methods for comparing CefValue* types.
- Improve CefValue* documentation.
This commit is contained in:
Marshall Greenblatt 2015-04-15 15:45:30 +02:00
parent 740ad72f90
commit 0369063810
23 changed files with 3281 additions and 185 deletions

View File

@ -290,6 +290,8 @@
'libcef_dll/cpptoc/v8stack_trace_cpptoc.h',
'libcef_dll/cpptoc/v8value_cpptoc.cc',
'libcef_dll/cpptoc/v8value_cpptoc.h',
'libcef_dll/cpptoc/value_cpptoc.cc',
'libcef_dll/cpptoc/value_cpptoc.h',
'libcef_dll/cpptoc/web_plugin_info_cpptoc.cc',
'libcef_dll/cpptoc/web_plugin_info_cpptoc.h',
'libcef_dll/ctocpp/web_plugin_info_visitor_ctocpp.cc',
@ -468,6 +470,8 @@
'libcef_dll/ctocpp/v8stack_trace_ctocpp.h',
'libcef_dll/ctocpp/v8value_ctocpp.cc',
'libcef_dll/ctocpp/v8value_ctocpp.h',
'libcef_dll/ctocpp/value_ctocpp.cc',
'libcef_dll/ctocpp/value_ctocpp.h',
'libcef_dll/ctocpp/web_plugin_info_ctocpp.cc',
'libcef_dll/ctocpp/web_plugin_info_ctocpp.h',
'libcef_dll/cpptoc/web_plugin_info_visitor_cpptoc.cc',

View File

@ -177,9 +177,9 @@ typedef struct _cef_v8handler_t {
///
// Structure that should be implemented to handle V8 accessor calls. Accessor
// identifiers are registered by calling cef_v8value_t::set_value_byaccessor().
// The functions of this structure will be called on the thread associated with
// the V8 accessor.
// identifiers are registered by calling cef_v8value_t::set_value(). The
// functions of this structure will be called on the thread associated with the
// V8 accessor.
///
typedef struct _cef_v8accessor_t {
///

View File

@ -44,9 +44,183 @@
extern "C" {
#endif
struct _cef_binary_value_t;
struct _cef_dictionary_value_t;
struct _cef_list_value_t;
///
// Structure that wraps other data value types. Complex types (binary,
// dictionary and list) will be referenced but not owned by this object. Can be
// used on any process and thread.
///
typedef struct _cef_value_t {
///
// Base structure.
///
cef_base_t base;
///
// Returns true (1) if the underlying data is valid. This will always be true
// (1) for simple types. For complex types (binary, dictionary and list) the
// underlying data may become invalid if owned by another object (e.g. list or
// dictionary) and that other object is then modified or destroyed. This value
// object can be re-used by calling Set*() even if the underlying data is
// invalid.
///
int (CEF_CALLBACK *is_valid)(struct _cef_value_t* self);
///
// Returns true (1) if the underlying data is owned by another object.
///
int (CEF_CALLBACK *is_owned)(struct _cef_value_t* self);
///
// Returns true (1) if the underlying data is read-only. Some APIs may expose
// read-only objects.
///
int (CEF_CALLBACK *is_read_only)(struct _cef_value_t* self);
///
// Returns true (1) if this object and |that| object have the same underlying
// data. If true (1) modifications to this object will also affect |that|
// object and vice-versa.
///
int (CEF_CALLBACK *is_same)(struct _cef_value_t* self,
struct _cef_value_t* that);
///
// Returns true (1) if this object and |that| object have an equivalent
// underlying value but are not necessarily the same object.
///
int (CEF_CALLBACK *is_equal)(struct _cef_value_t* self,
struct _cef_value_t* that);
///
// Returns a copy of this object. The underlying data will also be copied.
///
struct _cef_value_t* (CEF_CALLBACK *copy)(struct _cef_value_t* self);
///
// Returns the underlying value type.
///
cef_value_type_t (CEF_CALLBACK *get_type)(struct _cef_value_t* self);
///
// Returns the underlying value as type bool.
///
int (CEF_CALLBACK *get_bool)(struct _cef_value_t* self);
///
// Returns the underlying value as type int.
///
int (CEF_CALLBACK *get_int)(struct _cef_value_t* self);
///
// Returns the underlying value as type double.
///
double (CEF_CALLBACK *get_double)(struct _cef_value_t* self);
///
// Returns the underlying value 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_value_t* self);
///
// Returns the underlying value as type binary. The returned reference may
// become invalid if the value is owned by another object or if ownership is
// transferred to another object in the future. To maintain a reference to the
// value after assigning ownership to a dictionary or list pass this object to
// the set_value() function instead of passing the returned reference to
// set_binary().
///
struct _cef_binary_value_t* (CEF_CALLBACK *get_binary)(
struct _cef_value_t* self);
///
// Returns the underlying value as type dictionary. The returned reference may
// become invalid if the value is owned by another object or if ownership is
// transferred to another object in the future. To maintain a reference to the
// value after assigning ownership to a dictionary or list pass this object to
// the set_value() function instead of passing the returned reference to
// set_dictionary().
///
struct _cef_dictionary_value_t* (CEF_CALLBACK *get_dictionary)(
struct _cef_value_t* self);
///
// Returns the underlying value as type list. The returned reference may
// become invalid if the value is owned by another object or if ownership is
// transferred to another object in the future. To maintain a reference to the
// value after assigning ownership to a dictionary or list pass this object to
// the set_value() function instead of passing the returned reference to
// set_list().
///
struct _cef_list_value_t* (CEF_CALLBACK *get_list)(struct _cef_value_t* self);
///
// Sets the underlying value as type null. Returns true (1) if the value was
// set successfully.
///
int (CEF_CALLBACK *set_null)(struct _cef_value_t* self);
///
// Sets the underlying value as type bool. Returns true (1) if the value was
// set successfully.
///
int (CEF_CALLBACK *set_bool)(struct _cef_value_t* self, int value);
///
// Sets the underlying value as type int. Returns true (1) if the value was
// set successfully.
///
int (CEF_CALLBACK *set_int)(struct _cef_value_t* self, int value);
///
// Sets the underlying value as type double. Returns true (1) if the value was
// set successfully.
///
int (CEF_CALLBACK *set_double)(struct _cef_value_t* self, double value);
///
// Sets the underlying value as type string. Returns true (1) if the value was
// set successfully.
///
int (CEF_CALLBACK *set_string)(struct _cef_value_t* self,
const cef_string_t* value);
///
// Sets the underlying value as type binary. Returns true (1) if the value was
// set successfully. This object keeps a reference to |value| and ownership of
// the underlying data remains unchanged.
///
int (CEF_CALLBACK *set_binary)(struct _cef_value_t* self,
struct _cef_binary_value_t* value);
///
// Sets the underlying value as type dict. Returns true (1) if the value was
// set successfully. This object keeps a reference to |value| and ownership of
// the underlying data remains unchanged.
///
int (CEF_CALLBACK *set_dictionary)(struct _cef_value_t* self,
struct _cef_dictionary_value_t* value);
///
// Sets the underlying value as type list. Returns true (1) if the value was
// set successfully. This object keeps a reference to |value| and ownership of
// the underlying data remains unchanged.
///
int (CEF_CALLBACK *set_list)(struct _cef_value_t* self,
struct _cef_list_value_t* value);
} cef_value_t;
///
// Creates a new object.
///
CEF_EXPORT cef_value_t* cef_value_create();
///
// Structure representing a binary value. Can be used on any process and thread.
///
@ -57,8 +231,10 @@ typedef struct _cef_binary_value_t {
cef_base_t base;
///
// Returns true (1) if this object is valid. Do not call any other functions
// if this function returns false (0).
// Returns true (1) if this object is valid. This object may become invalid if
// the underlying data is owned by another object (e.g. list or dictionary)
// and that other object is then modified or destroyed. Do not call any other
// functions if this function returns false (0).
///
int (CEF_CALLBACK *is_valid)(struct _cef_binary_value_t* self);
@ -67,6 +243,20 @@ typedef struct _cef_binary_value_t {
///
int (CEF_CALLBACK *is_owned)(struct _cef_binary_value_t* self);
///
// Returns true (1) if this object and |that| object have the same underlying
// data.
///
int (CEF_CALLBACK *is_same)(struct _cef_binary_value_t* self,
struct _cef_binary_value_t* that);
///
// Returns true (1) if this object and |that| object have an equivalent
// underlying value but are not necessarily the same object.
///
int (CEF_CALLBACK *is_equal)(struct _cef_binary_value_t* self,
struct _cef_binary_value_t* that);
///
// Returns a copy of this object. The data in this object will also be copied.
///
@ -106,8 +296,10 @@ typedef struct _cef_dictionary_value_t {
cef_base_t base;
///
// Returns true (1) if this object is valid. Do not call any other functions
// if this function returns false (0).
// Returns true (1) if this object is valid. This object may become invalid if
// the underlying data is owned by another object (e.g. list or dictionary)
// and that other object is then modified or destroyed. Do not call any other
// functions if this function returns false (0).
///
int (CEF_CALLBACK *is_valid)(struct _cef_dictionary_value_t* self);
@ -122,6 +314,21 @@ typedef struct _cef_dictionary_value_t {
///
int (CEF_CALLBACK *is_read_only)(struct _cef_dictionary_value_t* self);
///
// Returns true (1) if this object and |that| object have the same underlying
// data. If true (1) modifications to this object will also affect |that|
// object and vice-versa.
///
int (CEF_CALLBACK *is_same)(struct _cef_dictionary_value_t* self,
struct _cef_dictionary_value_t* that);
///
// Returns true (1) if this object and |that| object have an equivalent
// underlying value but are not necessarily the same object.
///
int (CEF_CALLBACK *is_equal)(struct _cef_dictionary_value_t* self,
struct _cef_dictionary_value_t* that);
///
// Returns a writable copy of this object. If |exclude_NULL_children| is true
// (1) any NULL dictionaries or lists will be excluded from the copy.
@ -164,6 +371,16 @@ typedef struct _cef_dictionary_value_t {
cef_value_type_t (CEF_CALLBACK *get_type)(
struct _cef_dictionary_value_t* self, const cef_string_t* key);
///
// Returns the value at the specified key. For simple types the returned value
// will copy existing data and modifications to the value will not modify this
// object. For complex types (binary, dictionary and list) the returned value
// will reference existing data and modifications to the value will modify
// this object.
///
struct _cef_value_t* (CEF_CALLBACK *get_value)(
struct _cef_dictionary_value_t* self, const cef_string_t* key);
///
// Returns the value at the specified key as type bool.
///
@ -190,23 +407,39 @@ typedef struct _cef_dictionary_value_t {
struct _cef_dictionary_value_t* self, const cef_string_t* key);
///
// Returns the value at the specified key as type binary.
// Returns the value at the specified key as type binary. The returned value
// will reference existing data.
///
struct _cef_binary_value_t* (CEF_CALLBACK *get_binary)(
struct _cef_dictionary_value_t* self, const cef_string_t* key);
///
// Returns the value at the specified key as type dictionary.
// Returns the value at the specified key as type dictionary. The returned
// value will reference existing data and modifications to the value will
// modify this object.
///
struct _cef_dictionary_value_t* (CEF_CALLBACK *get_dictionary)(
struct _cef_dictionary_value_t* self, const cef_string_t* key);
///
// Returns the value at the specified key as type list.
// Returns the value at the specified key as type list. The returned value
// will reference existing data and modifications to the value will modify
// this object.
///
struct _cef_list_value_t* (CEF_CALLBACK *get_list)(
struct _cef_dictionary_value_t* self, const cef_string_t* key);
///
// Sets the value at the specified key. Returns true (1) if the value was set
// successfully. If |value| represents simple data then the underlying data
// will be copied and modifications to |value| will not modify this object. If
// |value| represents complex data (binary, dictionary or list) then the
// underlying data will be referenced and modifications to |value| will modify
// this object.
///
int (CEF_CALLBACK *set_value)(struct _cef_dictionary_value_t* self,
const cef_string_t* key, struct _cef_value_t* value);
///
// Sets the value at the specified key as type null. Returns true (1) if the
// value was set successfully.
@ -254,8 +487,7 @@ typedef struct _cef_dictionary_value_t {
///
// Sets the value at the specified key as type dict. Returns true (1) if the
// value was set successfully. After calling this function the |value| object
// will no longer be valid. If |value| is currently owned by another object
// value was set successfully. If |value| is currently owned by another object
// then the value will be copied and the |value| reference will not change.
// Otherwise, ownership will be transferred to this object and the |value|
// reference will be invalidated.
@ -265,8 +497,7 @@ typedef struct _cef_dictionary_value_t {
///
// Sets the value at the specified key as type list. Returns true (1) if the
// value was set successfully. After calling this function the |value| object
// will no longer be valid. If |value| is currently owned by another object
// value was set successfully. If |value| is currently owned by another object
// then the value will be copied and the |value| reference will not change.
// Otherwise, ownership will be transferred to this object and the |value|
// reference will be invalidated.
@ -292,8 +523,10 @@ typedef struct _cef_list_value_t {
cef_base_t base;
///
// Returns true (1) if this object is valid. Do not call any other functions
// if this function returns false (0).
// Returns true (1) if this object is valid. This object may become invalid if
// the underlying data is owned by another object (e.g. list or dictionary)
// and that other object is then modified or destroyed. Do not call any other
// functions if this function returns false (0).
///
int (CEF_CALLBACK *is_valid)(struct _cef_list_value_t* self);
@ -308,6 +541,21 @@ typedef struct _cef_list_value_t {
///
int (CEF_CALLBACK *is_read_only)(struct _cef_list_value_t* self);
///
// Returns true (1) if this object and |that| object have the same underlying
// data. If true (1) modifications to this object will also affect |that|
// object and vice-versa.
///
int (CEF_CALLBACK *is_same)(struct _cef_list_value_t* self,
struct _cef_list_value_t* that);
///
// Returns true (1) if this object and |that| object have an equivalent
// underlying value but are not necessarily the same object.
///
int (CEF_CALLBACK *is_equal)(struct _cef_list_value_t* self,
struct _cef_list_value_t* that);
///
// Returns a writable copy of this object.
///
@ -341,6 +589,16 @@ typedef struct _cef_list_value_t {
cef_value_type_t (CEF_CALLBACK *get_type)(struct _cef_list_value_t* self,
int index);
///
// Returns the value at the specified index. For simple types the returned
// value will copy existing data and modifications to the value will not
// modify this object. For complex types (binary, dictionary and list) the
// returned value will reference existing data and modifications to the value
// will modify this object.
///
struct _cef_value_t* (CEF_CALLBACK *get_value)(struct _cef_list_value_t* self,
int index);
///
// Returns the value at the specified index as type bool.
///
@ -364,23 +622,39 @@ typedef struct _cef_list_value_t {
struct _cef_list_value_t* self, int index);
///
// Returns the value at the specified index as type binary.
// 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);
///
// Returns the value at the specified index as type dictionary.
// 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.
///
struct _cef_dictionary_value_t* (CEF_CALLBACK *get_dictionary)(
struct _cef_list_value_t* self, int index);
///
// Returns the value at the specified index as type list.
// 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.
///
struct _cef_list_value_t* (CEF_CALLBACK *get_list)(
struct _cef_list_value_t* self, int index);
///
// Sets the value at the specified index. Returns true (1) if the value was
// set successfully. If |value| represents simple data then the underlying
// data will be copied and modifications to |value| will not modify this
// object. If |value| represents complex data (binary, dictionary or list)
// 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,
struct _cef_value_t* value);
///
// Sets the value at the specified index as type null. Returns true (1) if the
// value was set successfully.
@ -417,8 +691,7 @@ typedef struct _cef_list_value_t {
///
// Sets the value at the specified index as type binary. Returns true (1) if
// the value was set successfully. After calling this function the |value|
// object will no longer be valid. If |value| is currently owned by another
// the value was set successfully. If |value| is currently owned by another
// object then the value will be copied and the |value| reference will not
// change. Otherwise, ownership will be transferred to this object and the
// |value| reference will be invalidated.
@ -428,8 +701,7 @@ typedef struct _cef_list_value_t {
///
// Sets the value at the specified index as type dict. Returns true (1) if the
// value was set successfully. After calling this function the |value| object
// will no longer be valid. If |value| is currently owned by another object
// value was set successfully. If |value| is currently owned by another object
// then the value will be copied and the |value| reference will not change.
// Otherwise, ownership will be transferred to this object and the |value|
// reference will be invalidated.
@ -439,8 +711,7 @@ typedef struct _cef_list_value_t {
///
// Sets the value at the specified index as type list. Returns true (1) if the
// value was set successfully. After calling this function the |value| object
// will no longer be valid. If |value| is currently owned by another object
// value was set successfully. If |value| is currently owned by another object
// then the value will be copied and the |value| reference will not change.
// Otherwise, ownership will be transferred to this object and the |value|
// reference will be invalidated.

View File

@ -41,11 +41,195 @@
#include <vector>
#include "include/cef_base.h"
class CefBinaryValue;
class CefDictionaryValue;
class CefListValue;
typedef cef_value_type_t CefValueType;
///
// Class that wraps other data value types. Complex types (binary, dictionary
// and list) will be referenced but not owned by this object. Can be used on any
// process and thread.
///
/*--cef(source=library)--*/
class CefValue : public virtual CefBase {
public:
///
// Creates a new object.
///
/*--cef()--*/
static CefRefPtr<CefValue> Create();
///
// Returns true if the underlying data is valid. This will always be true for
// simple types. For complex types (binary, dictionary and list) the
// underlying data may become invalid if owned by another object (e.g. list or
// dictionary) and that other object is then modified or destroyed. This value
// object can be re-used by calling Set*() even if the underlying data is
// invalid.
///
/*--cef()--*/
virtual bool IsValid() =0;
///
// Returns true if the underlying data is owned by another object.
///
/*--cef()--*/
virtual bool IsOwned() =0;
///
// Returns true if the underlying data is read-only. Some APIs may expose
// read-only objects.
///
/*--cef()--*/
virtual bool IsReadOnly() =0;
///
// Returns true if this object and |that| object have the same underlying
// data. If true modifications to this object will also affect |that| object
// and vice-versa.
///
/*--cef()--*/
virtual bool IsSame(CefRefPtr<CefValue> that) =0;
///
// Returns true if this object and |that| object have an equivalent underlying
// value but are not necessarily the same object.
///
/*--cef()--*/
virtual bool IsEqual(CefRefPtr<CefValue> that) =0;
///
// Returns a copy of this object. The underlying data will also be copied.
///
/*--cef()--*/
virtual CefRefPtr<CefValue> Copy() =0;
///
// Returns the underlying value type.
///
/*--cef(default_retval=VTYPE_INVALID)--*/
virtual CefValueType GetType() =0;
///
// Returns the underlying value as type bool.
///
/*--cef()--*/
virtual bool GetBool() =0;
///
// Returns the underlying value as type int.
///
/*--cef()--*/
virtual int GetInt() =0;
///
// Returns the underlying value as type double.
///
/*--cef()--*/
virtual double GetDouble() =0;
///
// Returns the underlying value as type string.
///
/*--cef()--*/
virtual CefString GetString() =0;
///
// Returns the underlying value as type binary. The returned reference may
// become invalid if the value is owned by another object or if ownership is
// transferred to another object in the future. To maintain a reference to
// the value after assigning ownership to a dictionary or list pass this
// object to the SetValue() method instead of passing the returned reference
// to SetBinary().
///
/*--cef()--*/
virtual CefRefPtr<CefBinaryValue> GetBinary() =0;
///
// Returns the underlying value as type dictionary. The returned reference may
// become invalid if the value is owned by another object or if ownership is
// transferred to another object in the future. To maintain a reference to
// the value after assigning ownership to a dictionary or list pass this
// object to the SetValue() method instead of passing the returned reference
// to SetDictionary().
///
/*--cef()--*/
virtual CefRefPtr<CefDictionaryValue> GetDictionary() =0;
///
// Returns the underlying value as type list. The returned reference may
// become invalid if the value is owned by another object or if ownership is
// transferred to another object in the future. To maintain a reference to
// the value after assigning ownership to a dictionary or list pass this
// object to the SetValue() method instead of passing the returned reference
// to SetList().
///
/*--cef()--*/
virtual CefRefPtr<CefListValue> GetList() =0;
///
// Sets the underlying value as type null. Returns true if the value was set
// successfully.
///
/*--cef()--*/
virtual bool SetNull() =0;
///
// Sets the underlying value as type bool. Returns true if the value was set
// successfully.
///
/*--cef()--*/
virtual bool SetBool(bool value) =0;
///
// Sets the underlying value as type int. Returns true if the value was set
// successfully.
///
/*--cef()--*/
virtual bool SetInt(int value) =0;
///
// Sets the underlying value as type double. Returns true if the value was set
// successfully.
///
/*--cef()--*/
virtual bool SetDouble(double value) =0;
///
// Sets the underlying value as type string. Returns true if the value was set
// successfully.
///
/*--cef(optional_param=value)--*/
virtual bool SetString(const CefString& value) =0;
///
// Sets the underlying value as type binary. Returns true if the value was set
// successfully. This object keeps a reference to |value| and ownership of the
// underlying data remains unchanged.
///
/*--cef()--*/
virtual bool SetBinary(CefRefPtr<CefBinaryValue> value) =0;
///
// Sets the underlying value as type dict. Returns true if the value was set
// successfully. This object keeps a reference to |value| and ownership of the
// underlying data remains unchanged.
///
/*--cef()--*/
virtual bool SetDictionary(CefRefPtr<CefDictionaryValue> value) =0;
///
// Sets the underlying value as type list. Returns true if the value was set
// successfully. This object keeps a reference to |value| and ownership of the
// underlying data remains unchanged.
///
/*--cef()--*/
virtual bool SetList(CefRefPtr<CefListValue> value) =0;
};
///
// Class representing a binary value. Can be used on any process and thread.
///
@ -61,8 +245,10 @@ class CefBinaryValue : public virtual CefBase {
size_t data_size);
///
// Returns true if this object is valid. Do not call any other methods if this
// method returns false.
// Returns true if this object is valid. This object may become invalid if
// the underlying data is owned by another object (e.g. list or dictionary)
// and that other object is then modified or destroyed. Do not call any other
// methods if this method returns false.
///
/*--cef()--*/
virtual bool IsValid() =0;
@ -73,6 +259,20 @@ class CefBinaryValue : public virtual CefBase {
/*--cef()--*/
virtual bool IsOwned() =0;
///
// Returns true if this object and |that| object have the same underlying
// data.
///
/*--cef()--*/
virtual bool IsSame(CefRefPtr<CefBinaryValue> that) =0;
///
// Returns true if this object and |that| object have an equivalent underlying
// value but are not necessarily the same object.
///
/*--cef()--*/
virtual bool IsEqual(CefRefPtr<CefBinaryValue> that) =0;
///
// Returns a copy of this object. The data in this object will also be copied.
///
@ -111,8 +311,10 @@ class CefDictionaryValue : public virtual CefBase {
static CefRefPtr<CefDictionaryValue> Create();
///
// Returns true if this object is valid. Do not call any other methods if this
// method returns false.
// Returns true if this object is valid. This object may become invalid if
// the underlying data is owned by another object (e.g. list or dictionary)
// and that other object is then modified or destroyed. Do not call any other
// methods if this method returns false.
///
/*--cef()--*/
virtual bool IsValid() =0;
@ -130,6 +332,21 @@ class CefDictionaryValue : public virtual CefBase {
/*--cef()--*/
virtual bool IsReadOnly() =0;
///
// Returns true if this object and |that| object have the same underlying
// data. If true modifications to this object will also affect |that| object
// and vice-versa.
///
/*--cef()--*/
virtual bool IsSame(CefRefPtr<CefDictionaryValue> that) =0;
///
// Returns true if this object and |that| object have an equivalent underlying
// value but are not necessarily the same object.
///
/*--cef()--*/
virtual bool IsEqual(CefRefPtr<CefDictionaryValue> that) =0;
///
// Returns a writable copy of this object. If |exclude_empty_children| is true
// any empty dictionaries or lists will be excluded from the copy.
@ -174,6 +391,16 @@ class CefDictionaryValue : public virtual CefBase {
/*--cef(default_retval=VTYPE_INVALID)--*/
virtual CefValueType GetType(const CefString& key) =0;
///
// Returns the value at the specified key. For simple types the returned
// value will copy existing data and modifications to the value will not
// modify this object. For complex types (binary, dictionary and list) the
// returned value will reference existing data and modifications to the value
// will modify this object.
///
/*--cef()--*/
virtual CefRefPtr<CefValue> GetValue(const CefString& key) =0;
///
// Returns the value at the specified key as type bool.
///
@ -199,23 +426,39 @@ class CefDictionaryValue : public virtual CefBase {
virtual CefString GetString(const CefString& key) =0;
///
// Returns the value at the specified key as type binary.
// Returns the value at the specified key as type binary. The returned
// value will reference existing data.
///
/*--cef()--*/
virtual CefRefPtr<CefBinaryValue> GetBinary(const CefString& key) =0;
///
// Returns the value at the specified key as type dictionary.
// Returns the value at the specified key as type dictionary. The returned
// value will reference existing data and modifications to the value will
// modify this object.
///
/*--cef()--*/
virtual CefRefPtr<CefDictionaryValue> GetDictionary(const CefString& key) =0;
///
// Returns the value at the specified key as type list.
// Returns the value at the specified key as type list. The returned value
// will reference existing data and modifications to the value will modify
// this object.
///
/*--cef()--*/
virtual CefRefPtr<CefListValue> GetList(const CefString& key) =0;
///
// Sets the value at the specified key. Returns true if the value was set
// successfully. If |value| represents simple data then the underlying data
// will be copied and modifications to |value| will not modify this object. If
// |value| represents complex data (binary, dictionary or list) then the
// underlying data will be referenced and modifications to |value| will modify
// this object.
///
/*--cef()--*/
virtual bool SetValue(const CefString& key, CefRefPtr<CefValue> value) =0;
///
// Sets the value at the specified key as type null. Returns true if the
// value was set successfully.
@ -264,8 +507,7 @@ class CefDictionaryValue : public virtual CefBase {
///
// Sets the value at the specified key as type dict. Returns true if the
// value was set successfully. After calling this method the |value| object
// will no longer be valid. If |value| is currently owned by another object
// value was set successfully. If |value| is currently owned by another object
// then the value will be copied and the |value| reference will not change.
// Otherwise, ownership will be transferred to this object and the |value|
// reference will be invalidated.
@ -276,8 +518,7 @@ class CefDictionaryValue : public virtual CefBase {
///
// Sets the value at the specified key as type list. Returns true if the
// value was set successfully. After calling this method the |value| object
// will no longer be valid. If |value| is currently owned by another object
// value was set successfully. If |value| is currently owned by another object
// then the value will be copied and the |value| reference will not change.
// Otherwise, ownership will be transferred to this object and the |value|
// reference will be invalidated.
@ -301,8 +542,10 @@ class CefListValue : public virtual CefBase {
static CefRefPtr<CefListValue> Create();
///
// Returns true if this object is valid. Do not call any other methods if this
// method returns false.
// Returns true if this object is valid. This object may become invalid if
// the underlying data is owned by another object (e.g. list or dictionary)
// and that other object is then modified or destroyed. Do not call any other
// methods if this method returns false.
///
/*--cef()--*/
virtual bool IsValid() =0;
@ -320,6 +563,21 @@ class CefListValue : public virtual CefBase {
/*--cef()--*/
virtual bool IsReadOnly() =0;
///
// Returns true if this object and |that| object have the same underlying
// data. If true modifications to this object will also affect |that| object
// and vice-versa.
///
/*--cef()--*/
virtual bool IsSame(CefRefPtr<CefListValue> that) =0;
///
// Returns true if this object and |that| object have an equivalent underlying
// value but are not necessarily the same object.
///
/*--cef()--*/
virtual bool IsEqual(CefRefPtr<CefListValue> that) =0;
///
// Returns a writable copy of this object.
///
@ -357,6 +615,16 @@ class CefListValue : public virtual CefBase {
/*--cef(default_retval=VTYPE_INVALID,index_param=index)--*/
virtual CefValueType GetType(int index) =0;
///
// Returns the value at the specified index. For simple types the returned
// value will copy existing data and modifications to the value will not
// modify this object. For complex types (binary, dictionary and list) the
// returned value will reference existing data and modifications to the value
// will modify this object.
///
/*--cef(index_param=index)--*/
virtual CefRefPtr<CefValue> GetValue(int index) =0;
///
// Returns the value at the specified index as type bool.
///
@ -382,23 +650,39 @@ class CefListValue : public virtual CefBase {
virtual CefString GetString(int index) =0;
///
// Returns the value at the specified index as type binary.
// Returns the value at the specified index as type binary. The returned
// value will reference existing data.
///
/*--cef(index_param=index)--*/
virtual CefRefPtr<CefBinaryValue> GetBinary(int index) =0;
///
// Returns the value at the specified index as type dictionary.
// 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<CefDictionaryValue> GetDictionary(int index) =0;
///
// Returns the value at the specified index as type list.
// 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<CefListValue> GetList(int index) =0;
///
// Sets the value at the specified index. Returns true if the value was set
// successfully. If |value| represents simple data then the underlying data
// will be copied and modifications to |value| will not modify this object. If
// |value| represents complex data (binary, dictionary or list) then the
// underlying data will be referenced and modifications to |value| will modify
// this object.
///
/*--cef(index_param=index)--*/
virtual bool SetValue(int index, CefRefPtr<CefValue> value) =0;
///
// Sets the value at the specified index as type null. Returns true if the
// value was set successfully.
@ -436,8 +720,7 @@ class CefListValue : public virtual CefBase {
///
// Sets the value at the specified index as type binary. Returns true if the
// value was set successfully. After calling this method the |value| object
// will no longer be valid. If |value| is currently owned by another object
// value was set successfully. If |value| is currently owned by another object
// then the value will be copied and the |value| reference will not change.
// Otherwise, ownership will be transferred to this object and the |value|
// reference will be invalidated.
@ -447,8 +730,7 @@ class CefListValue : public virtual CefBase {
///
// Sets the value at the specified index as type dict. Returns true if the
// value was set successfully. After calling this method the |value| object
// will no longer be valid. If |value| is currently owned by another object
// value was set successfully. If |value| is currently owned by another object
// then the value will be copied and the |value| reference will not change.
// Otherwise, ownership will be transferred to this object and the |value|
// reference will be invalidated.
@ -458,8 +740,7 @@ class CefListValue : public virtual CefBase {
///
// Sets the value at the specified index as type list. Returns true if the
// value was set successfully. After calling this method the |value| object
// will no longer be valid. If |value| is currently owned by another object
// value was set successfully. If |value| is currently owned by another object
// then the value will be copied and the |value| reference will not change.
// Otherwise, ownership will be transferred to this object and the |value|
// reference will be invalidated.

View File

@ -7,6 +7,362 @@
#include <algorithm>
#include <vector>
// CefValueImpl implementation.
// static
CefRefPtr<CefValue> CefValue::Create() {
return new CefValueImpl(base::Value::CreateNullValue());
}
// static
CefRefPtr<CefValue> CefValueImpl::GetOrCreateRefOrCopy(
base::Value* value,
void* parent_value,
bool read_only,
CefValueController* controller) {
DCHECK(value);
if (value->IsType(base::Value::TYPE_BINARY)) {
base::BinaryValue* binary_value = static_cast<base::BinaryValue*>(value);
return new CefValueImpl(CefBinaryValueImpl::GetOrCreateRef(
binary_value, parent_value, controller));
}
if (value->IsType(base::Value::TYPE_DICTIONARY)) {
base::DictionaryValue* dict_value =
static_cast<base::DictionaryValue*>(value);
return new CefValueImpl(CefDictionaryValueImpl::GetOrCreateRef(
dict_value, parent_value, read_only, controller));
}
if (value->IsType(base::Value::TYPE_LIST)) {
base::ListValue* list_value = static_cast<base::ListValue*>(value);
return new CefValueImpl(CefListValueImpl::GetOrCreateRef(
list_value, parent_value, read_only, controller));
}
return new CefValueImpl(value->DeepCopy());
}
CefValueImpl::CefValueImpl() {
}
CefValueImpl::CefValueImpl(base::Value* value) {
SetValue(value);
}
CefValueImpl::CefValueImpl(CefRefPtr<CefBinaryValue> value)
: binary_value_(value) {
}
CefValueImpl::CefValueImpl(CefRefPtr<CefDictionaryValue> value)
: dictionary_value_(value) {
}
CefValueImpl::CefValueImpl(CefRefPtr<CefListValue> value)
: list_value_(value) {
}
CefValueImpl::~CefValueImpl() {
}
void CefValueImpl::SetValue(base::Value* value) {
base::AutoLock lock_scope(lock_);
SetValueInternal(value);
}
base::Value* CefValueImpl::CopyOrTransferValue(
void* new_parent_value,
bool new_read_only,
CefValueController* new_controller) {
base::AutoLock lock_scope(lock_);
if (binary_value_) {
base::BinaryValue* value =
static_cast<CefBinaryValueImpl*>(binary_value_.get())->
CopyOrDetachValue(new_controller);
binary_value_ = CefBinaryValueImpl::GetOrCreateRef(
value, new_parent_value, new_controller);
return value;
}
if (dictionary_value_) {
base::DictionaryValue* value =
static_cast<CefDictionaryValueImpl*>(dictionary_value_.get())->
CopyOrDetachValue(new_controller);
dictionary_value_ = CefDictionaryValueImpl::GetOrCreateRef(
value, new_parent_value, new_read_only, new_controller);
return value;
}
if (list_value_) {
base::ListValue* value =
static_cast<CefListValueImpl*>(list_value_.get())->
CopyOrDetachValue(new_controller);
list_value_ = CefListValueImpl::GetOrCreateRef(
value, new_parent_value, new_read_only, new_controller);
return value;
}
return value_->DeepCopy();
}
bool CefValueImpl::IsValid() {
base::AutoLock lock_scope(lock_);
if (binary_value_)
return binary_value_->IsValid();
if (dictionary_value_)
return dictionary_value_->IsValid();
if (list_value_)
return list_value_->IsValid();
return (value_ != NULL);
}
bool CefValueImpl::IsOwned() {
base::AutoLock lock_scope(lock_);
if (binary_value_)
return binary_value_->IsOwned();
if (dictionary_value_)
return dictionary_value_->IsOwned();
if (list_value_)
return list_value_->IsOwned();
return false;
}
bool CefValueImpl::IsReadOnly() {
base::AutoLock lock_scope(lock_);
if (binary_value_)
return true;
if (dictionary_value_)
return dictionary_value_->IsReadOnly();
if (list_value_)
return list_value_->IsReadOnly();
return false;
}
bool CefValueImpl::IsSame(CefRefPtr<CefValue> that) {
if (that.get() == this)
return true;
if (!that.get() || that->GetType() != GetType())
return false;
CefValueImpl* impl = static_cast<CefValueImpl*>(that.get());
base::AutoLock lock_scope(lock_);
base::AutoLock lock_scope2(impl->lock_);
if (binary_value_)
return binary_value_->IsSame(impl->binary_value_);
if (dictionary_value_)
return dictionary_value_->IsSame(impl->dictionary_value_);
if (list_value_)
return list_value_->IsSame(impl->list_value_);
// Simple types are never the same.
return false;
}
bool CefValueImpl::IsEqual(CefRefPtr<CefValue> that) {
if (that.get() == this)
return true;
if (!that.get() || that->GetType() != GetType())
return false;
CefValueImpl* impl = static_cast<CefValueImpl*>(that.get());
base::AutoLock lock_scope(lock_);
base::AutoLock lock_scope2(impl->lock_);
if (binary_value_)
return binary_value_->IsEqual(impl->binary_value_);
if (dictionary_value_)
return dictionary_value_->IsEqual(impl->dictionary_value_);
if (list_value_)
return list_value_->IsEqual(impl->list_value_);
if (!value_) // Invalid types are equal.
return true;
return value_->Equals(impl->value_.get());
}
CefRefPtr<CefValue> CefValueImpl::Copy() {
base::AutoLock lock_scope(lock_);
if (binary_value_)
return new CefValueImpl(binary_value_->Copy());
if (dictionary_value_)
return new CefValueImpl(dictionary_value_->Copy(false));
if (list_value_)
return new CefValueImpl(list_value_->Copy());
if (value_)
return new CefValueImpl(value_->DeepCopy());
return new CefValueImpl();
}
CefValueType CefValueImpl::GetType() {
base::AutoLock lock_scope(lock_);
if (binary_value_)
return VTYPE_BINARY;
if (dictionary_value_)
return VTYPE_DICTIONARY;
if (list_value_)
return VTYPE_LIST;
if (value_) {
switch (value_->GetType()) {
case base::Value::TYPE_NULL:
return VTYPE_NULL;
case base::Value::TYPE_BOOLEAN:
return VTYPE_BOOL;
case base::Value::TYPE_INTEGER:
return VTYPE_INT;
case base::Value::TYPE_DOUBLE:
return VTYPE_DOUBLE;
case base::Value::TYPE_STRING:
return VTYPE_STRING;
default:
NOTREACHED();
break;
}
}
return VTYPE_INVALID;
}
bool CefValueImpl::GetBool() {
base::AutoLock lock_scope(lock_);
bool ret_value = false;
if (value_)
value_->GetAsBoolean(&ret_value);
return ret_value;
}
int CefValueImpl::GetInt() {
base::AutoLock lock_scope(lock_);
int ret_value = 0;
if (value_)
value_->GetAsInteger(&ret_value);
return ret_value;
}
double CefValueImpl::GetDouble() {
base::AutoLock lock_scope(lock_);
double ret_value = 0;
if (value_)
value_->GetAsDouble(&ret_value);
return ret_value;
}
CefString CefValueImpl::GetString() {
base::AutoLock lock_scope(lock_);
std::string ret_value;
if (value_)
value_->GetAsString(&ret_value);
return ret_value;
}
CefRefPtr<CefBinaryValue> CefValueImpl::GetBinary() {
base::AutoLock lock_scope(lock_);
return binary_value_;
}
CefRefPtr<CefDictionaryValue> CefValueImpl::GetDictionary() {
base::AutoLock lock_scope(lock_);
return dictionary_value_;
}
CefRefPtr<CefListValue> CefValueImpl::GetList() {
base::AutoLock lock_scope(lock_);
return list_value_;
}
bool CefValueImpl::SetNull() {
SetValue(base::Value::CreateNullValue());
return true;
}
bool CefValueImpl::SetBool(bool value) {
SetValue(new base::FundamentalValue(value));
return true;
}
bool CefValueImpl::SetInt(int value) {
SetValue(new base::FundamentalValue(value));
return true;
}
bool CefValueImpl::SetDouble(double value) {
SetValue(new base::FundamentalValue(value));
return true;
}
bool CefValueImpl::SetString(const CefString& value) {
SetValue(new base::StringValue(value.ToString()));
return true;
}
bool CefValueImpl::SetBinary(CefRefPtr<CefBinaryValue> value) {
base::AutoLock lock_scope(lock_);
SetValueInternal(NULL);
binary_value_ = value;
return true;
}
bool CefValueImpl::SetDictionary(CefRefPtr<CefDictionaryValue> value) {
base::AutoLock lock_scope(lock_);
SetValueInternal(NULL);
dictionary_value_ = value;
return true;
}
bool CefValueImpl::SetList(CefRefPtr<CefListValue> value) {
base::AutoLock lock_scope(lock_);
SetValueInternal(NULL);
list_value_ = value;
return true;
}
void CefValueImpl::SetValueInternal(base::Value* value) {
lock_.AssertAcquired();
value_.reset(NULL);
binary_value_ = NULL;
dictionary_value_ = NULL;
list_value_ = NULL;
if (value) {
switch (value->GetType()) {
case base::Value::TYPE_BINARY:
binary_value_ = new CefBinaryValueImpl(
static_cast<base::BinaryValue*>(value), true);
return;
case base::Value::TYPE_DICTIONARY:
dictionary_value_ = new CefDictionaryValueImpl(
static_cast<base::DictionaryValue*>(value), true, false);
return;
case base::Value::TYPE_LIST:
list_value_ = new CefListValueImpl(
static_cast<base::ListValue*>(value), true, false);
return;
default:
value_.reset(value);
}
}
}
// CefBinaryValueImpl implementation.
@ -39,11 +395,19 @@ CefRefPtr<CefBinaryValue> CefBinaryValueImpl::GetOrCreateRef(
}
CefBinaryValueImpl::CefBinaryValueImpl(base::BinaryValue* value,
bool will_delete,
bool read_only)
bool will_delete)
: CefValueBase<CefBinaryValue, base::BinaryValue>(
value, NULL, will_delete ? kOwnerWillDelete : kOwnerNoDelete,
read_only, NULL) {
true, NULL) {
}
CefBinaryValueImpl::CefBinaryValueImpl(char* data,
size_t data_size,
bool copy)
: CefValueBase<CefBinaryValue, base::BinaryValue>(
copy ? base::BinaryValue::CreateWithCopiedBuffer(data, data_size) :
new base::BinaryValue(scoped_ptr<char[]>(data), data_size),
NULL, kOwnerWillDelete, true, NULL) {
}
base::BinaryValue* CefBinaryValueImpl::CopyValue() {
@ -67,6 +431,16 @@ base::BinaryValue* CefBinaryValueImpl::CopyOrDetachValue(
return new_value;
}
bool CefBinaryValueImpl::IsSameValue(const base::BinaryValue* that) {
CEF_VALUE_VERIFY_RETURN(false, false);
return (&const_value() == that);
}
bool CefBinaryValueImpl::IsEqualValue(const base::BinaryValue* that) {
CEF_VALUE_VERIFY_RETURN(false, false);
return const_value().Equals(that);
}
bool CefBinaryValueImpl::IsValid() {
return !detached();
}
@ -75,6 +449,28 @@ bool CefBinaryValueImpl::IsOwned() {
return !will_delete();
}
bool CefBinaryValueImpl::IsSame(CefRefPtr<CefBinaryValue> that) {
if (!that.get())
return false;
if (that.get() == this)
return true;
CEF_VALUE_VERIFY_RETURN(false, false);
return static_cast<CefBinaryValueImpl*>(that.get())->
IsSameValue(&const_value());
}
bool CefBinaryValueImpl::IsEqual(CefRefPtr<CefBinaryValue> that) {
if (!that.get())
return false;
if (that.get() == this)
return true;
CEF_VALUE_VERIFY_RETURN(false, false);
return static_cast<CefBinaryValueImpl*>(that.get())->
IsEqualValue(&const_value());
}
CefRefPtr<CefBinaryValue> CefBinaryValueImpl::Copy() {
CEF_VALUE_VERIFY_RETURN(false, NULL);
return new CefBinaryValueImpl(const_value().DeepCopy(), NULL,
@ -115,22 +511,12 @@ CefBinaryValueImpl::CefBinaryValueImpl(base::BinaryValue* value,
value, parent_value, value_mode, true, controller) {
}
CefBinaryValueImpl::CefBinaryValueImpl(char* data,
size_t data_size,
bool copy)
: CefValueBase<CefBinaryValue, base::BinaryValue>(
copy ? base::BinaryValue::CreateWithCopiedBuffer(data, data_size) :
new base::BinaryValue(scoped_ptr<char[]>(data), data_size),
NULL, kOwnerWillDelete, true, NULL) {
}
// CefDictionaryValueImpl implementation.
// static
CefRefPtr<CefDictionaryValue> CefDictionaryValue::Create() {
return new CefDictionaryValueImpl(new base::DictionaryValue(),
NULL, CefDictionaryValueImpl::kOwnerWillDelete, false, NULL);
return new CefDictionaryValueImpl(new base::DictionaryValue(), true, false);
}
// static
@ -176,6 +562,16 @@ base::DictionaryValue* CefDictionaryValueImpl::CopyOrDetachValue(
return new_value;
}
bool CefDictionaryValueImpl::IsSameValue(const base::DictionaryValue* that) {
CEF_VALUE_VERIFY_RETURN(false, false);
return (&const_value() == that);
}
bool CefDictionaryValueImpl::IsEqualValue(const base::DictionaryValue* that) {
CEF_VALUE_VERIFY_RETURN(false, false);
return const_value().Equals(that);
}
bool CefDictionaryValueImpl::IsValid() {
return !detached();
}
@ -188,6 +584,28 @@ bool CefDictionaryValueImpl::IsReadOnly() {
return read_only();
}
bool CefDictionaryValueImpl::IsSame(CefRefPtr<CefDictionaryValue> that) {
if (!that.get())
return false;
if (that.get() == this)
return true;
CEF_VALUE_VERIFY_RETURN(false, false);
return static_cast<CefDictionaryValueImpl*>(that.get())->
IsSameValue(&const_value());
}
bool CefDictionaryValueImpl::IsEqual(CefRefPtr<CefDictionaryValue> that) {
if (!that.get())
return false;
if (that.get() == this)
return true;
CEF_VALUE_VERIFY_RETURN(false, false);
return static_cast<CefDictionaryValueImpl*>(that.get())->
IsEqualValue(&const_value());
}
CefRefPtr<CefDictionaryValue> CefDictionaryValueImpl::Copy(
bool exclude_empty_children) {
CEF_VALUE_VERIFY_RETURN(false, NULL);
@ -268,6 +686,21 @@ CefValueType CefDictionaryValueImpl::GetType(const CefString& key) {
return VTYPE_INVALID;
}
CefRefPtr<CefValue> CefDictionaryValueImpl::GetValue(const CefString& key) {
CEF_VALUE_VERIFY_RETURN(false, NULL);
const base::Value* out_value = NULL;
if (const_value().GetWithoutPathExpansion(key, &out_value)) {
return CefValueImpl::GetOrCreateRefOrCopy(
const_cast<base::Value*>(out_value),
const_cast<base::DictionaryValue*>(&const_value()),
read_only(),
controller());
}
return NULL;
}
bool CefDictionaryValueImpl::GetBool(const CefString& key) {
CEF_VALUE_VERIFY_RETURN(false, false);
@ -373,83 +806,81 @@ CefRefPtr<CefListValue> CefDictionaryValueImpl::GetList(const CefString& key) {
return NULL;
}
bool CefDictionaryValueImpl::SetValue(const CefString& key,
CefRefPtr<CefValue> value) {
CEF_VALUE_VERIFY_RETURN(true, false);
CefValueImpl* impl = static_cast<CefValueImpl*>(value.get());
DCHECK(impl);
base::Value* new_value =
impl->CopyOrTransferValue(mutable_value(), false, controller());
SetInternal(key, new_value);
return true;
}
bool CefDictionaryValueImpl::SetNull(const CefString& key) {
CEF_VALUE_VERIFY_RETURN(true, false);
RemoveInternal(key);
mutable_value()->SetWithoutPathExpansion(key, base::Value::CreateNullValue());
SetInternal(key, base::Value::CreateNullValue());
return true;
}
bool CefDictionaryValueImpl::SetBool(const CefString& key, bool value) {
CEF_VALUE_VERIFY_RETURN(true, false);
RemoveInternal(key);
mutable_value()->SetWithoutPathExpansion(key,
new base::FundamentalValue(value));
SetInternal(key, new base::FundamentalValue(value));
return true;
}
bool CefDictionaryValueImpl::SetInt(const CefString& key, int value) {
CEF_VALUE_VERIFY_RETURN(true, false);
RemoveInternal(key);
mutable_value()->SetWithoutPathExpansion(key,
new base::FundamentalValue(value));
SetInternal(key, new base::FundamentalValue(value));
return true;
}
bool CefDictionaryValueImpl::SetDouble(const CefString& key, double value) {
CEF_VALUE_VERIFY_RETURN(true, false);
RemoveInternal(key);
mutable_value()->SetWithoutPathExpansion(key,
new base::FundamentalValue(value));
SetInternal(key, new base::FundamentalValue(value));
return true;
}
bool CefDictionaryValueImpl::SetString(const CefString& key,
const CefString& value) {
CEF_VALUE_VERIFY_RETURN(true, false);
RemoveInternal(key);
mutable_value()->SetWithoutPathExpansion(key,
new base::StringValue(value.ToString()));
SetInternal(key, new base::StringValue(value.ToString()));
return true;
}
bool CefDictionaryValueImpl::SetBinary(const CefString& key,
CefRefPtr<CefBinaryValue> value) {
CEF_VALUE_VERIFY_RETURN(true, false);
RemoveInternal(key);
CefBinaryValueImpl* impl = static_cast<CefBinaryValueImpl*>(value.get());
DCHECK(impl);
mutable_value()->SetWithoutPathExpansion(key,
impl->CopyOrDetachValue(controller()));
SetInternal(key, impl->CopyOrDetachValue(controller()));
return true;
}
bool CefDictionaryValueImpl::SetDictionary(
const CefString& key, CefRefPtr<CefDictionaryValue> value) {
CEF_VALUE_VERIFY_RETURN(true, false);
RemoveInternal(key);
CefDictionaryValueImpl* impl =
static_cast<CefDictionaryValueImpl*>(value.get());
DCHECK(impl);
mutable_value()->SetWithoutPathExpansion(key,
impl->CopyOrDetachValue(controller()));
SetInternal(key, impl->CopyOrDetachValue(controller()));
return true;
}
bool CefDictionaryValueImpl::SetList(const CefString& key,
CefRefPtr<CefListValue> value) {
CEF_VALUE_VERIFY_RETURN(true, false);
RemoveInternal(key);
CefListValueImpl* impl = static_cast<CefListValueImpl*>(value.get());
DCHECK(impl);
mutable_value()->SetWithoutPathExpansion(key,
impl->CopyOrDetachValue(controller()));
SetInternal(key, impl->CopyOrDetachValue(controller()));
return true;
}
@ -470,6 +901,13 @@ bool CefDictionaryValueImpl::RemoveInternal(const CefString& key) {
return true;
}
void CefDictionaryValueImpl::SetInternal(const CefString& key,
base::Value* value) {
DCHECK(value);
RemoveInternal(key);
mutable_value()->SetWithoutPathExpansion(key, value);
}
CefDictionaryValueImpl::CefDictionaryValueImpl(
base::DictionaryValue* value,
void* parent_value,
@ -485,8 +923,7 @@ CefDictionaryValueImpl::CefDictionaryValueImpl(
// static
CefRefPtr<CefListValue> CefListValue::Create() {
return new CefListValueImpl(new base::ListValue(),
NULL, CefListValueImpl::kOwnerWillDelete, false, NULL);
return new CefListValueImpl(new base::ListValue(), true, false);
}
// static
@ -532,6 +969,16 @@ base::ListValue* CefListValueImpl::CopyOrDetachValue(
return new_value;
}
bool CefListValueImpl::IsSameValue(const base::ListValue* that) {
CEF_VALUE_VERIFY_RETURN(false, false);
return (&const_value() == that);
}
bool CefListValueImpl::IsEqualValue(const base::ListValue* that) {
CEF_VALUE_VERIFY_RETURN(false, false);
return const_value().Equals(that);
}
bool CefListValueImpl::IsValid() {
return !detached();
}
@ -544,6 +991,28 @@ bool CefListValueImpl::IsReadOnly() {
return read_only();
}
bool CefListValueImpl::IsSame(CefRefPtr<CefListValue> that) {
if (!that.get())
return false;
if (that.get() == this)
return true;
CEF_VALUE_VERIFY_RETURN(false, false);
return static_cast<CefListValueImpl*>(that.get())->
IsSameValue(&const_value());
}
bool CefListValueImpl::IsEqual(CefRefPtr<CefListValue> that) {
if (!that.get())
return false;
if (that.get() == this)
return true;
CEF_VALUE_VERIFY_RETURN(false, false);
return static_cast<CefListValueImpl*>(that.get())->
IsEqualValue(&const_value());
}
CefRefPtr<CefListValue> CefListValueImpl::Copy() {
CEF_VALUE_VERIFY_RETURN(false, NULL);
@ -614,6 +1083,21 @@ CefValueType CefListValueImpl::GetType(int index) {
return VTYPE_INVALID;
}
CefRefPtr<CefValue> CefListValueImpl::GetValue(int index) {
CEF_VALUE_VERIFY_RETURN(false, NULL);
const base::Value* out_value = NULL;
if (const_value().Get(index, &out_value)) {
return CefValueImpl::GetOrCreateRefOrCopy(
const_cast<base::Value*>(out_value),
const_cast<base::ListValue*>(&const_value()),
read_only(),
controller());
}
return NULL;
}
bool CefListValueImpl::GetBool(int index) {
CEF_VALUE_VERIFY_RETURN(false, false);
@ -717,53 +1201,45 @@ CefRefPtr<CefListValue> CefListValueImpl::GetList(int index) {
return NULL;
}
bool CefListValueImpl::SetValue(int index, CefRefPtr<CefValue> value) {
CEF_VALUE_VERIFY_RETURN(true, false);
CefValueImpl* impl = static_cast<CefValueImpl*>(value.get());
DCHECK(impl);
base::Value* new_value =
impl->CopyOrTransferValue(mutable_value(), false, controller());
SetInternal(index, new_value);
return true;
}
bool CefListValueImpl::SetNull(int index) {
CEF_VALUE_VERIFY_RETURN(true, false);
base::Value* new_value = base::Value::CreateNullValue();
if (RemoveInternal(index))
mutable_value()->Insert(index, new_value);
else
mutable_value()->Set(index, new_value);
SetInternal(index, base::Value::CreateNullValue());
return true;
}
bool CefListValueImpl::SetBool(int index, bool value) {
CEF_VALUE_VERIFY_RETURN(true, false);
base::Value* new_value = new base::FundamentalValue(value);
if (RemoveInternal(index))
mutable_value()->Insert(index, new_value);
else
mutable_value()->Set(index, new_value);
SetInternal(index, new base::FundamentalValue(value));
return true;
}
bool CefListValueImpl::SetInt(int index, int value) {
CEF_VALUE_VERIFY_RETURN(true, false);
base::Value* new_value = new base::FundamentalValue(value);
if (RemoveInternal(index))
mutable_value()->Insert(index, new_value);
else
mutable_value()->Set(index, new_value);
SetInternal(index, new base::FundamentalValue(value));
return true;
}
bool CefListValueImpl::SetDouble(int index, double value) {
CEF_VALUE_VERIFY_RETURN(true, false);
base::Value* new_value = new base::FundamentalValue(value);
if (RemoveInternal(index))
mutable_value()->Insert(index, new_value);
else
mutable_value()->Set(index, new_value);
SetInternal(index, new base::FundamentalValue(value));
return true;
}
bool CefListValueImpl::SetString(int index, const CefString& value) {
CEF_VALUE_VERIFY_RETURN(true, false);
base::Value* new_value = new base::StringValue(value.ToString());
if (RemoveInternal(index))
mutable_value()->Insert(index, new_value);
else
mutable_value()->Set(index, new_value);
SetInternal(index, new base::StringValue(value.ToString()));
return true;
}
@ -773,11 +1249,7 @@ bool CefListValueImpl::SetBinary(int index, CefRefPtr<CefBinaryValue> value) {
CefBinaryValueImpl* impl = static_cast<CefBinaryValueImpl*>(value.get());
DCHECK(impl);
base::Value* new_value = impl->CopyOrDetachValue(controller());
if (RemoveInternal(index))
mutable_value()->Insert(index, new_value);
else
mutable_value()->Set(index, new_value);
SetInternal(index, impl->CopyOrDetachValue(controller()));
return true;
}
@ -789,11 +1261,7 @@ bool CefListValueImpl::SetDictionary(int index,
static_cast<CefDictionaryValueImpl*>(value.get());
DCHECK(impl);
base::Value* new_value = impl->CopyOrDetachValue(controller());
if (RemoveInternal(index))
mutable_value()->Insert(index, new_value);
else
mutable_value()->Set(index, new_value);
SetInternal(index, impl->CopyOrDetachValue(controller()));
return true;
}
@ -803,11 +1271,7 @@ bool CefListValueImpl::SetList(int index, CefRefPtr<CefListValue> value) {
CefListValueImpl* impl = static_cast<CefListValueImpl*>(value.get());
DCHECK(impl);
base::Value* new_value = impl->CopyOrDetachValue(controller());
if (RemoveInternal(index))
mutable_value()->Insert(index, new_value);
else
mutable_value()->Set(index, new_value);
SetInternal(index, impl->CopyOrDetachValue(controller()));
return true;
}
@ -828,6 +1292,14 @@ bool CefListValueImpl::RemoveInternal(int index) {
return true;
}
void CefListValueImpl::SetInternal(int index, base::Value* value) {
DCHECK(value);
if (RemoveInternal(index))
mutable_value()->Insert(index, value);
else
mutable_value()->Set(index, value);
}
CefListValueImpl::CefListValueImpl(
base::ListValue* value,
void* parent_value,

View File

@ -15,6 +15,83 @@
#include "base/threading/platform_thread.h"
// CefValue implementation
class CefValueImpl : public CefValue {
public:
// Get or create a reference to a complex value or copy a simple value.
static CefRefPtr<CefValue> GetOrCreateRefOrCopy(
base::Value* value,
void* parent_value,
bool read_only,
CefValueController* controller);
CefValueImpl();
// Take ownership of |value|. Do not pass in a value owned by something else
// (use GetOrCreateRefOrCopy instead).
explicit CefValueImpl(base::Value* value);
// Keep a reference to |value|.
explicit CefValueImpl(CefRefPtr<CefBinaryValue> value);
explicit CefValueImpl(CefRefPtr<CefDictionaryValue> value);
explicit CefValueImpl(CefRefPtr<CefListValue> value);
~CefValueImpl() override;
// Take ownership of |value|. Do not pass in a value owned by something else
// (use GetOrCreateRefOrCopy or Set*() instead).
void SetValue(base::Value* value);
// Copy a simple value or transfer ownership of a complex value. If ownership
// of the value is tranferred then this object's internal reference to the
// value will be updated and remain valid.
base::Value* CopyOrTransferValue(void* new_parent_value,
bool new_read_only,
CefValueController* new_controller);
// CefValue methods.
bool IsValid() override;
bool IsOwned() override;
bool IsReadOnly() override;
bool IsSame(CefRefPtr<CefValue> that) override;
bool IsEqual(CefRefPtr<CefValue> that) override;
CefRefPtr<CefValue> Copy() override;
CefValueType GetType() override;
bool GetBool() override;
int GetInt() override;
double GetDouble() override;
CefString GetString() override;
CefRefPtr<CefBinaryValue> GetBinary() override;
CefRefPtr<CefDictionaryValue> GetDictionary() override;
CefRefPtr<CefListValue> GetList() override;
bool SetNull() override;
bool SetBool(bool value) override;
bool SetInt(int value) override;
bool SetDouble(double value) override;
bool SetString(const CefString& value) override;
bool SetBinary(CefRefPtr<CefBinaryValue> value) override;
bool SetDictionary(CefRefPtr<CefDictionaryValue> value) override;
bool SetList(CefRefPtr<CefListValue> value) override;
private:
void SetValueInternal(base::Value* value);
// Access to all members must be protected by |lock_|.
base::Lock lock_;
// Simple values only.
scoped_ptr<base::Value> value_;
// Complex values.
CefRefPtr<CefBinaryValue> binary_value_;
CefRefPtr<CefDictionaryValue> dictionary_value_;
CefRefPtr<CefListValue> list_value_;
IMPLEMENT_REFCOUNTING(CefValueImpl);
DISALLOW_COPY_AND_ASSIGN(CefValueImpl);
};
// CefBinaryValue implementation
class CefBinaryValueImpl
: public CefValueBase<CefBinaryValue, base::BinaryValue> {
@ -25,21 +102,36 @@ class CefBinaryValueImpl
void* parent_value,
CefValueController* controller);
// Simple constructor for referencing existing value objects.
// Reference an existing value (set |will_delete| to false) or take ownership
// of an existing value (set |will_delete| to true). When referencing an
// existing value you must explicitly call Detach(NULL) when |value| is no
// longer valid. Use GetOrCreateRef instead of this constructor if |value| is
// owned by some other object and you do not plan to explicitly call
// Detach(NULL).
CefBinaryValueImpl(base::BinaryValue* value,
bool will_delete,
bool read_only);
bool will_delete);
// If |copy| is false this object will take ownership of the specified |data|
// buffer instead of copying it.
CefBinaryValueImpl(char* data,
size_t data_size,
bool copy);
// Return a copy of the value.
base::BinaryValue* CopyValue();
// If a reference return a copy of the value otherwise detach the value to the
// specified |new_controller|.
// If this value is a reference then return a copy. Otherwise, detach and
// transfer ownership of the value.
base::BinaryValue* CopyOrDetachValue(CefValueController* new_controller);
bool IsSameValue(const base::BinaryValue* that);
bool IsEqualValue(const base::BinaryValue* that);
// CefBinaryValue methods.
bool IsValid() override;
bool IsOwned() override;
bool IsSame(CefRefPtr<CefBinaryValue> that) override;
bool IsEqual(CefRefPtr<CefBinaryValue> that) override;
CefRefPtr<CefBinaryValue> Copy() override;
size_t GetSize() override;
size_t GetData(void* buffer,
@ -53,14 +145,6 @@ class CefBinaryValueImpl
void* parent_value,
ValueMode value_mode,
CefValueController* controller);
// If |copy| is false this object will take ownership of the specified |data|
// buffer instead of copying it.
CefBinaryValueImpl(char* data,
size_t data_size,
bool copy);
// For the Create() method.
friend class CefBinaryValue;
DISALLOW_COPY_AND_ASSIGN(CefBinaryValueImpl);
};
@ -77,7 +161,12 @@ class CefDictionaryValueImpl
bool read_only,
CefValueController* controller);
// Simple constructor for referencing existing value objects.
// Reference an existing value (set |will_delete| to false) or take ownership
// of an existing value (set |will_delete| to true). When referencing an
// existing value you must explicitly call Detach(NULL) when |value| is no
// longer valid. Use GetOrCreateRef instead of this constructor if |value| is
// owned by some other object and you do not plan to explicitly call
// Detach(NULL).
CefDictionaryValueImpl(base::DictionaryValue* value,
bool will_delete,
bool read_only);
@ -85,14 +174,19 @@ class CefDictionaryValueImpl
// Return a copy of the value.
base::DictionaryValue* CopyValue();
// If a reference return a copy of the value otherwise detach the value to the
// specified |new_controller|.
// If this value is a reference then return a copy. Otherwise, detach and
// transfer ownership of the value.
base::DictionaryValue* CopyOrDetachValue(CefValueController* new_controller);
bool IsSameValue(const base::DictionaryValue* that);
bool IsEqualValue(const base::DictionaryValue* that);
// CefDictionaryValue methods.
bool IsValid() override;
bool IsOwned() override;
bool IsReadOnly() override;
bool IsSame(CefRefPtr<CefDictionaryValue> that) override;
bool IsEqual(CefRefPtr<CefDictionaryValue> that) override;
CefRefPtr<CefDictionaryValue> Copy(
bool exclude_empty_children) override;
size_t GetSize() override;
@ -101,6 +195,7 @@ class CefDictionaryValueImpl
bool GetKeys(KeyList& keys) override;
bool Remove(const CefString& key) override;
CefValueType GetType(const CefString& key) override;
CefRefPtr<CefValue> GetValue(const CefString& key) override;
bool GetBool(const CefString& key) override;
int GetInt(const CefString& key) override;
double GetDouble(const CefString& key) override;
@ -109,6 +204,7 @@ class CefDictionaryValueImpl
CefRefPtr<CefDictionaryValue> GetDictionary(
const CefString& key) override;
CefRefPtr<CefListValue> GetList(const CefString& key) override;
bool SetValue(const CefString& key, CefRefPtr<CefValue> value) override;
bool SetNull(const CefString& key) override;
bool SetBool(const CefString& key, bool value) override;
bool SetInt(const CefString& key, int value) override;
@ -131,9 +227,7 @@ class CefDictionaryValueImpl
CefValueController* controller);
bool RemoveInternal(const CefString& key);
// For the Create() method.
friend class CefDictionaryValue;
void SetInternal(const CefString& key, base::Value* value);
DISALLOW_COPY_AND_ASSIGN(CefDictionaryValueImpl);
};
@ -150,7 +244,12 @@ class CefListValueImpl
bool read_only,
CefValueController* controller);
// Simple constructor for referencing existing value objects.
// Reference an existing value (set |will_delete| to false) or take ownership
// of an existing value (set |will_delete| to true). When referencing an
// existing value you must explicitly call Detach(NULL) when |value| is no
// longer valid. Use GetOrCreateRef instead of this constructor if |value| is
// owned by some other object and you do not plan to explicitly call
// Detach(NULL).
CefListValueImpl(base::ListValue* value,
bool will_delete,
bool read_only);
@ -158,20 +257,26 @@ class CefListValueImpl
// Return a copy of the value.
base::ListValue* CopyValue();
// If a reference return a copy of the value otherwise detach the value to the
// specified |new_controller|.
// If this value is a reference then return a copy. Otherwise, detach and
// transfer ownership of the value.
base::ListValue* CopyOrDetachValue(CefValueController* new_controller);
bool IsSameValue(const base::ListValue* that);
bool IsEqualValue(const base::ListValue* that);
/// CefListValue methods.
bool IsValid() override;
bool IsOwned() override;
bool IsReadOnly() override;
bool IsSame(CefRefPtr<CefListValue> that) override;
bool IsEqual(CefRefPtr<CefListValue> that) override;
CefRefPtr<CefListValue> Copy() override;
bool SetSize(size_t size) override;
size_t GetSize() override;
bool Clear() override;
bool Remove(int index) override;
CefValueType GetType(int index) override;
CefRefPtr<CefValue> GetValue(int index) override;
bool GetBool(int index) override;
int GetInt(int index) override;
double GetDouble(int index) override;
@ -179,6 +284,7 @@ class CefListValueImpl
CefRefPtr<CefBinaryValue> GetBinary(int index) override;
CefRefPtr<CefDictionaryValue> GetDictionary(int index) override;
CefRefPtr<CefListValue> GetList(int index) override;
bool SetValue(int index, CefRefPtr<CefValue> value) override;
bool SetNull(int index) override;
bool SetBool(int index, bool value) override;
bool SetInt(int index, int value) override;
@ -198,9 +304,7 @@ class CefListValueImpl
CefValueController* controller);
bool RemoveInternal(int index);
// For the Create() method.
friend class CefListValue;
void SetInternal(int index, base::Value* value);
DISALLOW_COPY_AND_ASSIGN(CefListValueImpl);
};

View File

@ -64,6 +64,46 @@ int CEF_CALLBACK binary_value_is_owned(struct _cef_binary_value_t* self) {
return _retval;
}
int CEF_CALLBACK binary_value_is_same(struct _cef_binary_value_t* self,
struct _cef_binary_value_t* that) {
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
DCHECK(self);
if (!self)
return 0;
// Verify param: that; type: refptr_same
DCHECK(that);
if (!that)
return 0;
// Execute
bool _retval = CefBinaryValueCppToC::Get(self)->IsSame(
CefBinaryValueCppToC::Unwrap(that));
// Return type: bool
return _retval;
}
int CEF_CALLBACK binary_value_is_equal(struct _cef_binary_value_t* self,
struct _cef_binary_value_t* that) {
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
DCHECK(self);
if (!self)
return 0;
// Verify param: that; type: refptr_same
DCHECK(that);
if (!that)
return 0;
// Execute
bool _retval = CefBinaryValueCppToC::Get(self)->IsEqual(
CefBinaryValueCppToC::Unwrap(that));
// Return type: bool
return _retval;
}
struct _cef_binary_value_t* CEF_CALLBACK binary_value_copy(
struct _cef_binary_value_t* self) {
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
@ -122,6 +162,8 @@ CefBinaryValueCppToC::CefBinaryValueCppToC(CefBinaryValue* cls)
: CefCppToC<CefBinaryValueCppToC, CefBinaryValue, cef_binary_value_t>(cls) {
struct_.struct_.is_valid = binary_value_is_valid;
struct_.struct_.is_owned = binary_value_is_owned;
struct_.struct_.is_same = binary_value_is_same;
struct_.struct_.is_equal = binary_value_is_equal;
struct_.struct_.copy = binary_value_copy;
struct_.struct_.get_size = binary_value_get_size;
struct_.struct_.get_data = binary_value_get_data;

View File

@ -13,6 +13,7 @@
#include "libcef_dll/cpptoc/binary_value_cpptoc.h"
#include "libcef_dll/cpptoc/dictionary_value_cpptoc.h"
#include "libcef_dll/cpptoc/list_value_cpptoc.h"
#include "libcef_dll/cpptoc/value_cpptoc.h"
#include "libcef_dll/transfer_util.h"
@ -76,6 +77,46 @@ int CEF_CALLBACK dictionary_value_is_read_only(
return _retval;
}
int CEF_CALLBACK dictionary_value_is_same(struct _cef_dictionary_value_t* self,
struct _cef_dictionary_value_t* that) {
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
DCHECK(self);
if (!self)
return 0;
// Verify param: that; type: refptr_same
DCHECK(that);
if (!that)
return 0;
// Execute
bool _retval = CefDictionaryValueCppToC::Get(self)->IsSame(
CefDictionaryValueCppToC::Unwrap(that));
// Return type: bool
return _retval;
}
int CEF_CALLBACK dictionary_value_is_equal(struct _cef_dictionary_value_t* self,
struct _cef_dictionary_value_t* that) {
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
DCHECK(self);
if (!self)
return 0;
// Verify param: that; type: refptr_same
DCHECK(that);
if (!that)
return 0;
// Execute
bool _retval = CefDictionaryValueCppToC::Get(self)->IsEqual(
CefDictionaryValueCppToC::Unwrap(that));
// Return type: bool
return _retval;
}
struct _cef_dictionary_value_t* CEF_CALLBACK dictionary_value_copy(
struct _cef_dictionary_value_t* self, int exclude_empty_children) {
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
@ -210,6 +251,26 @@ cef_value_type_t CEF_CALLBACK dictionary_value_get_type(
return _retval;
}
cef_value_t* CEF_CALLBACK dictionary_value_get_value(
struct _cef_dictionary_value_t* self, const cef_string_t* key) {
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
DCHECK(self);
if (!self)
return NULL;
// Verify param: key; type: string_byref_const
DCHECK(key);
if (!key)
return NULL;
// Execute
CefRefPtr<CefValue> _retval = CefDictionaryValueCppToC::Get(self)->GetValue(
CefString(key));
// Return type: refptr_same
return CefValueCppToC::Wrap(_retval);
}
int CEF_CALLBACK dictionary_value_get_bool(struct _cef_dictionary_value_t* self,
const cef_string_t* key) {
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
@ -353,6 +414,32 @@ struct _cef_list_value_t* CEF_CALLBACK dictionary_value_get_list(
return CefListValueCppToC::Wrap(_retval);
}
int CEF_CALLBACK dictionary_value_set_value(
struct _cef_dictionary_value_t* self, const cef_string_t* key,
cef_value_t* value) {
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
DCHECK(self);
if (!self)
return 0;
// Verify param: key; type: string_byref_const
DCHECK(key);
if (!key)
return 0;
// Verify param: value; type: refptr_same
DCHECK(value);
if (!value)
return 0;
// Execute
bool _retval = CefDictionaryValueCppToC::Get(self)->SetValue(
CefString(key),
CefValueCppToC::Unwrap(value));
// Return type: bool
return _retval;
}
int CEF_CALLBACK dictionary_value_set_null(struct _cef_dictionary_value_t* self,
const cef_string_t* key) {
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
@ -546,6 +633,8 @@ CefDictionaryValueCppToC::CefDictionaryValueCppToC(CefDictionaryValue* cls)
struct_.struct_.is_valid = dictionary_value_is_valid;
struct_.struct_.is_owned = dictionary_value_is_owned;
struct_.struct_.is_read_only = dictionary_value_is_read_only;
struct_.struct_.is_same = dictionary_value_is_same;
struct_.struct_.is_equal = dictionary_value_is_equal;
struct_.struct_.copy = dictionary_value_copy;
struct_.struct_.get_size = dictionary_value_get_size;
struct_.struct_.clear = dictionary_value_clear;
@ -553,6 +642,7 @@ CefDictionaryValueCppToC::CefDictionaryValueCppToC(CefDictionaryValue* cls)
struct_.struct_.get_keys = dictionary_value_get_keys;
struct_.struct_.remove = dictionary_value_remove;
struct_.struct_.get_type = dictionary_value_get_type;
struct_.struct_.get_value = dictionary_value_get_value;
struct_.struct_.get_bool = dictionary_value_get_bool;
struct_.struct_.get_int = dictionary_value_get_int;
struct_.struct_.get_double = dictionary_value_get_double;
@ -560,6 +650,7 @@ CefDictionaryValueCppToC::CefDictionaryValueCppToC(CefDictionaryValue* cls)
struct_.struct_.get_binary = dictionary_value_get_binary;
struct_.struct_.get_dictionary = dictionary_value_get_dictionary;
struct_.struct_.get_list = dictionary_value_get_list;
struct_.struct_.set_value = dictionary_value_set_value;
struct_.struct_.set_null = dictionary_value_set_null;
struct_.struct_.set_bool = dictionary_value_set_bool;
struct_.struct_.set_int = dictionary_value_set_int;

View File

@ -13,6 +13,7 @@
#include "libcef_dll/cpptoc/binary_value_cpptoc.h"
#include "libcef_dll/cpptoc/dictionary_value_cpptoc.h"
#include "libcef_dll/cpptoc/list_value_cpptoc.h"
#include "libcef_dll/cpptoc/value_cpptoc.h"
// GLOBAL FUNCTIONS - Body may be edited by hand.
@ -72,6 +73,46 @@ int CEF_CALLBACK list_value_is_read_only(struct _cef_list_value_t* self) {
return _retval;
}
int CEF_CALLBACK list_value_is_same(struct _cef_list_value_t* self,
struct _cef_list_value_t* that) {
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
DCHECK(self);
if (!self)
return 0;
// Verify param: that; type: refptr_same
DCHECK(that);
if (!that)
return 0;
// Execute
bool _retval = CefListValueCppToC::Get(self)->IsSame(
CefListValueCppToC::Unwrap(that));
// Return type: bool
return _retval;
}
int CEF_CALLBACK list_value_is_equal(struct _cef_list_value_t* self,
struct _cef_list_value_t* that) {
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
DCHECK(self);
if (!self)
return 0;
// Verify param: that; type: refptr_same
DCHECK(that);
if (!that)
return 0;
// Execute
bool _retval = CefListValueCppToC::Get(self)->IsEqual(
CefListValueCppToC::Unwrap(that));
// Return type: bool
return _retval;
}
struct _cef_list_value_t* CEF_CALLBACK list_value_copy(
struct _cef_list_value_t* self) {
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
@ -170,6 +211,26 @@ cef_value_type_t CEF_CALLBACK list_value_get_type(
return _retval;
}
cef_value_t* CEF_CALLBACK list_value_get_value(struct _cef_list_value_t* self,
int 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<CefValue> _retval = CefListValueCppToC::Get(self)->GetValue(
index);
// Return type: refptr_same
return CefValueCppToC::Wrap(_retval);
}
int CEF_CALLBACK list_value_get_bool(struct _cef_list_value_t* self,
int index) {
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
@ -310,6 +371,31 @@ 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) {
// 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)
return 0;
// Execute
bool _retval = CefListValueCppToC::Get(self)->SetValue(
index,
CefValueCppToC::Unwrap(value));
// Return type: bool
return _retval;
}
int CEF_CALLBACK list_value_set_null(struct _cef_list_value_t* self,
int index) {
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
@ -498,12 +584,15 @@ CefListValueCppToC::CefListValueCppToC(CefListValue* cls)
struct_.struct_.is_valid = list_value_is_valid;
struct_.struct_.is_owned = list_value_is_owned;
struct_.struct_.is_read_only = list_value_is_read_only;
struct_.struct_.is_same = list_value_is_same;
struct_.struct_.is_equal = list_value_is_equal;
struct_.struct_.copy = list_value_copy;
struct_.struct_.set_size = list_value_set_size;
struct_.struct_.get_size = list_value_get_size;
struct_.struct_.clear = list_value_clear;
struct_.struct_.remove = list_value_remove;
struct_.struct_.get_type = list_value_get_type;
struct_.struct_.get_value = list_value_get_value;
struct_.struct_.get_bool = list_value_get_bool;
struct_.struct_.get_int = list_value_get_int;
struct_.struct_.get_double = list_value_get_double;
@ -511,6 +600,7 @@ CefListValueCppToC::CefListValueCppToC(CefListValue* cls)
struct_.struct_.get_binary = list_value_get_binary;
struct_.struct_.get_dictionary = list_value_get_dictionary;
struct_.struct_.get_list = list_value_get_list;
struct_.struct_.set_value = list_value_set_value;
struct_.struct_.set_null = list_value_set_null;
struct_.struct_.set_bool = list_value_set_bool;
struct_.struct_.set_int = list_value_set_int;

View File

@ -0,0 +1,415 @@
// Copyright (c) 2015 The Chromium Embedded Framework Authors. All rights
// reserved. Use of this source code is governed by a BSD-style license that
// can be found in the LICENSE file.
//
// ---------------------------------------------------------------------------
//
// This file was generated by the CEF translator tool. If making changes by
// hand only do so within the body of existing method and function
// implementations. See the translator.README.txt file in the tools directory
// for more information.
//
#include "libcef_dll/cpptoc/binary_value_cpptoc.h"
#include "libcef_dll/cpptoc/dictionary_value_cpptoc.h"
#include "libcef_dll/cpptoc/list_value_cpptoc.h"
#include "libcef_dll/cpptoc/value_cpptoc.h"
// GLOBAL FUNCTIONS - Body may be edited by hand.
CEF_EXPORT cef_value_t* cef_value_create() {
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
// Execute
CefRefPtr<CefValue> _retval = CefValue::Create();
// Return type: refptr_same
return CefValueCppToC::Wrap(_retval);
}
// MEMBER FUNCTIONS - Body may be edited by hand.
int CEF_CALLBACK value_is_valid(struct _cef_value_t* self) {
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
DCHECK(self);
if (!self)
return 0;
// Execute
bool _retval = CefValueCppToC::Get(self)->IsValid();
// Return type: bool
return _retval;
}
int CEF_CALLBACK value_is_owned(struct _cef_value_t* self) {
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
DCHECK(self);
if (!self)
return 0;
// Execute
bool _retval = CefValueCppToC::Get(self)->IsOwned();
// Return type: bool
return _retval;
}
int CEF_CALLBACK value_is_read_only(struct _cef_value_t* self) {
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
DCHECK(self);
if (!self)
return 0;
// Execute
bool _retval = CefValueCppToC::Get(self)->IsReadOnly();
// Return type: bool
return _retval;
}
int CEF_CALLBACK value_is_same(struct _cef_value_t* self,
struct _cef_value_t* that) {
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
DCHECK(self);
if (!self)
return 0;
// Verify param: that; type: refptr_same
DCHECK(that);
if (!that)
return 0;
// Execute
bool _retval = CefValueCppToC::Get(self)->IsSame(
CefValueCppToC::Unwrap(that));
// Return type: bool
return _retval;
}
int CEF_CALLBACK value_is_equal(struct _cef_value_t* self,
struct _cef_value_t* that) {
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
DCHECK(self);
if (!self)
return 0;
// Verify param: that; type: refptr_same
DCHECK(that);
if (!that)
return 0;
// Execute
bool _retval = CefValueCppToC::Get(self)->IsEqual(
CefValueCppToC::Unwrap(that));
// Return type: bool
return _retval;
}
struct _cef_value_t* CEF_CALLBACK value_copy(struct _cef_value_t* self) {
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
DCHECK(self);
if (!self)
return NULL;
// Execute
CefRefPtr<CefValue> _retval = CefValueCppToC::Get(self)->Copy();
// Return type: refptr_same
return CefValueCppToC::Wrap(_retval);
}
cef_value_type_t CEF_CALLBACK value_get_type(struct _cef_value_t* self) {
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
DCHECK(self);
if (!self)
return VTYPE_INVALID;
// Execute
cef_value_type_t _retval = CefValueCppToC::Get(self)->GetType();
// Return type: simple
return _retval;
}
int CEF_CALLBACK value_get_bool(struct _cef_value_t* self) {
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
DCHECK(self);
if (!self)
return 0;
// Execute
bool _retval = CefValueCppToC::Get(self)->GetBool();
// Return type: bool
return _retval;
}
int CEF_CALLBACK value_get_int(struct _cef_value_t* self) {
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
DCHECK(self);
if (!self)
return 0;
// Execute
int _retval = CefValueCppToC::Get(self)->GetInt();
// Return type: simple
return _retval;
}
double CEF_CALLBACK value_get_double(struct _cef_value_t* self) {
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
DCHECK(self);
if (!self)
return 0;
// Execute
double _retval = CefValueCppToC::Get(self)->GetDouble();
// Return type: simple
return _retval;
}
cef_string_userfree_t CEF_CALLBACK value_get_string(struct _cef_value_t* self) {
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
DCHECK(self);
if (!self)
return NULL;
// Execute
CefString _retval = CefValueCppToC::Get(self)->GetString();
// Return type: string
return _retval.DetachToUserFree();
}
struct _cef_binary_value_t* CEF_CALLBACK value_get_binary(
struct _cef_value_t* self) {
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
DCHECK(self);
if (!self)
return NULL;
// Execute
CefRefPtr<CefBinaryValue> _retval = CefValueCppToC::Get(self)->GetBinary();
// Return type: refptr_same
return CefBinaryValueCppToC::Wrap(_retval);
}
struct _cef_dictionary_value_t* CEF_CALLBACK value_get_dictionary(
struct _cef_value_t* self) {
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
DCHECK(self);
if (!self)
return NULL;
// Execute
CefRefPtr<CefDictionaryValue> _retval = CefValueCppToC::Get(
self)->GetDictionary();
// Return type: refptr_same
return CefDictionaryValueCppToC::Wrap(_retval);
}
struct _cef_list_value_t* CEF_CALLBACK value_get_list(
struct _cef_value_t* self) {
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
DCHECK(self);
if (!self)
return NULL;
// Execute
CefRefPtr<CefListValue> _retval = CefValueCppToC::Get(self)->GetList();
// Return type: refptr_same
return CefListValueCppToC::Wrap(_retval);
}
int CEF_CALLBACK value_set_null(struct _cef_value_t* self) {
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
DCHECK(self);
if (!self)
return 0;
// Execute
bool _retval = CefValueCppToC::Get(self)->SetNull();
// Return type: bool
return _retval;
}
int CEF_CALLBACK value_set_bool(struct _cef_value_t* self, int value) {
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
DCHECK(self);
if (!self)
return 0;
// Execute
bool _retval = CefValueCppToC::Get(self)->SetBool(
value?true:false);
// Return type: bool
return _retval;
}
int CEF_CALLBACK value_set_int(struct _cef_value_t* self, int value) {
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
DCHECK(self);
if (!self)
return 0;
// Execute
bool _retval = CefValueCppToC::Get(self)->SetInt(
value);
// Return type: bool
return _retval;
}
int CEF_CALLBACK value_set_double(struct _cef_value_t* self, double value) {
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
DCHECK(self);
if (!self)
return 0;
// Execute
bool _retval = CefValueCppToC::Get(self)->SetDouble(
value);
// Return type: bool
return _retval;
}
int CEF_CALLBACK value_set_string(struct _cef_value_t* self,
const cef_string_t* value) {
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
DCHECK(self);
if (!self)
return 0;
// Unverified params: value
// Execute
bool _retval = CefValueCppToC::Get(self)->SetString(
CefString(value));
// Return type: bool
return _retval;
}
int CEF_CALLBACK value_set_binary(struct _cef_value_t* self,
struct _cef_binary_value_t* value) {
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
DCHECK(self);
if (!self)
return 0;
// Verify param: value; type: refptr_same
DCHECK(value);
if (!value)
return 0;
// Execute
bool _retval = CefValueCppToC::Get(self)->SetBinary(
CefBinaryValueCppToC::Unwrap(value));
// Return type: bool
return _retval;
}
int CEF_CALLBACK value_set_dictionary(struct _cef_value_t* self,
struct _cef_dictionary_value_t* value) {
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
DCHECK(self);
if (!self)
return 0;
// Verify param: value; type: refptr_same
DCHECK(value);
if (!value)
return 0;
// Execute
bool _retval = CefValueCppToC::Get(self)->SetDictionary(
CefDictionaryValueCppToC::Unwrap(value));
// Return type: bool
return _retval;
}
int CEF_CALLBACK value_set_list(struct _cef_value_t* self,
struct _cef_list_value_t* value) {
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
DCHECK(self);
if (!self)
return 0;
// Verify param: value; type: refptr_same
DCHECK(value);
if (!value)
return 0;
// Execute
bool _retval = CefValueCppToC::Get(self)->SetList(
CefListValueCppToC::Unwrap(value));
// Return type: bool
return _retval;
}
// CONSTRUCTOR - Do not edit by hand.
CefValueCppToC::CefValueCppToC(CefValue* cls)
: CefCppToC<CefValueCppToC, CefValue, cef_value_t>(cls) {
struct_.struct_.is_valid = value_is_valid;
struct_.struct_.is_owned = value_is_owned;
struct_.struct_.is_read_only = value_is_read_only;
struct_.struct_.is_same = value_is_same;
struct_.struct_.is_equal = value_is_equal;
struct_.struct_.copy = value_copy;
struct_.struct_.get_type = value_get_type;
struct_.struct_.get_bool = value_get_bool;
struct_.struct_.get_int = value_get_int;
struct_.struct_.get_double = value_get_double;
struct_.struct_.get_string = value_get_string;
struct_.struct_.get_binary = value_get_binary;
struct_.struct_.get_dictionary = value_get_dictionary;
struct_.struct_.get_list = value_get_list;
struct_.struct_.set_null = value_set_null;
struct_.struct_.set_bool = value_set_bool;
struct_.struct_.set_int = value_set_int;
struct_.struct_.set_double = value_set_double;
struct_.struct_.set_string = value_set_string;
struct_.struct_.set_binary = value_set_binary;
struct_.struct_.set_dictionary = value_set_dictionary;
struct_.struct_.set_list = value_set_list;
}
#ifndef NDEBUG
template<> base::AtomicRefCount CefCppToC<CefValueCppToC, CefValue,
cef_value_t>::DebugObjCt = 0;
#endif

View File

@ -0,0 +1,35 @@
// Copyright (c) 2015 The Chromium Embedded Framework Authors. All rights
// reserved. Use of this source code is governed by a BSD-style license that
// can be found in the LICENSE file.
//
// ---------------------------------------------------------------------------
//
// This file was generated by the CEF translator tool. If making changes by
// hand only do so within the body of existing method and function
// implementations. See the translator.README.txt file in the tools directory
// for more information.
//
#ifndef CEF_LIBCEF_DLL_CPPTOC_VALUE_CPPTOC_H_
#define CEF_LIBCEF_DLL_CPPTOC_VALUE_CPPTOC_H_
#pragma once
#ifndef BUILDING_CEF_SHARED
#pragma message("Warning: "__FILE__" may be accessed DLL-side only")
#else // BUILDING_CEF_SHARED
#include "include/cef_values.h"
#include "include/capi/cef_values_capi.h"
#include "libcef_dll/cpptoc/cpptoc.h"
// Wrap a C++ class with a C structure.
// This class may be instantiated and accessed DLL-side only.
class CefValueCppToC
: public CefCppToC<CefValueCppToC, CefValue, cef_value_t> {
public:
explicit CefValueCppToC(CefValue* cls);
};
#endif // BUILDING_CEF_SHARED
#endif // CEF_LIBCEF_DLL_CPPTOC_VALUE_CPPTOC_H_

View File

@ -62,6 +62,44 @@ bool CefBinaryValueCToCpp::IsOwned() {
return _retval?true:false;
}
bool CefBinaryValueCToCpp::IsSame(CefRefPtr<CefBinaryValue> that) {
if (CEF_MEMBER_MISSING(struct_, is_same))
return false;
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
// Verify param: that; type: refptr_same
DCHECK(that.get());
if (!that.get())
return false;
// Execute
int _retval = struct_->is_same(struct_,
CefBinaryValueCToCpp::Unwrap(that));
// Return type: bool
return _retval?true:false;
}
bool CefBinaryValueCToCpp::IsEqual(CefRefPtr<CefBinaryValue> that) {
if (CEF_MEMBER_MISSING(struct_, is_equal))
return false;
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
// Verify param: that; type: refptr_same
DCHECK(that.get());
if (!that.get())
return false;
// Execute
int _retval = struct_->is_equal(struct_,
CefBinaryValueCToCpp::Unwrap(that));
// Return type: bool
return _retval?true:false;
}
CefRefPtr<CefBinaryValue> CefBinaryValueCToCpp::Copy() {
if (CEF_MEMBER_MISSING(struct_, copy))
return NULL;

View File

@ -35,6 +35,8 @@ class CefBinaryValueCToCpp
// CefBinaryValue methods
virtual bool IsValid() OVERRIDE;
virtual bool IsOwned() OVERRIDE;
virtual bool IsSame(CefRefPtr<CefBinaryValue> that) OVERRIDE;
virtual bool IsEqual(CefRefPtr<CefBinaryValue> that) OVERRIDE;
virtual CefRefPtr<CefBinaryValue> Copy() OVERRIDE;
virtual size_t GetSize() OVERRIDE;
virtual size_t GetData(void* buffer, size_t buffer_size,

View File

@ -13,6 +13,7 @@
#include "libcef_dll/ctocpp/binary_value_ctocpp.h"
#include "libcef_dll/ctocpp/dictionary_value_ctocpp.h"
#include "libcef_dll/ctocpp/list_value_ctocpp.h"
#include "libcef_dll/ctocpp/value_ctocpp.h"
#include "libcef_dll/transfer_util.h"
@ -70,6 +71,44 @@ bool CefDictionaryValueCToCpp::IsReadOnly() {
return _retval?true:false;
}
bool CefDictionaryValueCToCpp::IsSame(CefRefPtr<CefDictionaryValue> that) {
if (CEF_MEMBER_MISSING(struct_, is_same))
return false;
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
// Verify param: that; type: refptr_same
DCHECK(that.get());
if (!that.get())
return false;
// Execute
int _retval = struct_->is_same(struct_,
CefDictionaryValueCToCpp::Unwrap(that));
// Return type: bool
return _retval?true:false;
}
bool CefDictionaryValueCToCpp::IsEqual(CefRefPtr<CefDictionaryValue> that) {
if (CEF_MEMBER_MISSING(struct_, is_equal))
return false;
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
// Verify param: that; type: refptr_same
DCHECK(that.get());
if (!that.get())
return false;
// Execute
int _retval = struct_->is_equal(struct_,
CefDictionaryValueCToCpp::Unwrap(that));
// Return type: bool
return _retval?true:false;
}
CefRefPtr<CefDictionaryValue> CefDictionaryValueCToCpp::Copy(
bool exclude_empty_children) {
if (CEF_MEMBER_MISSING(struct_, copy))
@ -195,6 +234,25 @@ CefValueType CefDictionaryValueCToCpp::GetType(const CefString& key) {
return _retval;
}
CefRefPtr<CefValue> CefDictionaryValueCToCpp::GetValue(const CefString& key) {
if (CEF_MEMBER_MISSING(struct_, get_value))
return NULL;
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
// Verify param: key; type: string_byref_const
DCHECK(!key.empty());
if (key.empty())
return NULL;
// Execute
cef_value_t* _retval = struct_->get_value(struct_,
key.GetStruct());
// Return type: refptr_same
return CefValueCToCpp::Wrap(_retval);
}
bool CefDictionaryValueCToCpp::GetBool(const CefString& key) {
if (CEF_MEMBER_MISSING(struct_, get_bool))
return false;
@ -333,6 +391,31 @@ CefRefPtr<CefListValue> CefDictionaryValueCToCpp::GetList(
return CefListValueCToCpp::Wrap(_retval);
}
bool CefDictionaryValueCToCpp::SetValue(const CefString& key,
CefRefPtr<CefValue> value) {
if (CEF_MEMBER_MISSING(struct_, set_value))
return false;
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
// Verify param: key; type: string_byref_const
DCHECK(!key.empty());
if (key.empty())
return false;
// Verify param: value; type: refptr_same
DCHECK(value.get());
if (!value.get())
return false;
// Execute
int _retval = struct_->set_value(struct_,
key.GetStruct(),
CefValueCToCpp::Unwrap(value));
// Return type: bool
return _retval?true:false;
}
bool CefDictionaryValueCToCpp::SetNull(const CefString& key) {
if (CEF_MEMBER_MISSING(struct_, set_null))
return false;

View File

@ -36,6 +36,8 @@ class CefDictionaryValueCToCpp
virtual bool IsValid() OVERRIDE;
virtual bool IsOwned() OVERRIDE;
virtual bool IsReadOnly() OVERRIDE;
virtual bool IsSame(CefRefPtr<CefDictionaryValue> that) OVERRIDE;
virtual bool IsEqual(CefRefPtr<CefDictionaryValue> that) OVERRIDE;
virtual CefRefPtr<CefDictionaryValue> Copy(
bool exclude_empty_children) OVERRIDE;
virtual size_t GetSize() OVERRIDE;
@ -44,6 +46,7 @@ class CefDictionaryValueCToCpp
virtual bool GetKeys(KeyList& keys) OVERRIDE;
virtual bool Remove(const CefString& key) OVERRIDE;
virtual CefValueType GetType(const CefString& key) OVERRIDE;
virtual CefRefPtr<CefValue> GetValue(const CefString& key) OVERRIDE;
virtual bool GetBool(const CefString& key) OVERRIDE;
virtual int GetInt(const CefString& key) OVERRIDE;
virtual double GetDouble(const CefString& key) OVERRIDE;
@ -52,6 +55,8 @@ class CefDictionaryValueCToCpp
virtual CefRefPtr<CefDictionaryValue> GetDictionary(
const CefString& key) OVERRIDE;
virtual CefRefPtr<CefListValue> GetList(const CefString& key) OVERRIDE;
virtual bool SetValue(const CefString& key,
CefRefPtr<CefValue> value) OVERRIDE;
virtual bool SetNull(const CefString& key) OVERRIDE;
virtual bool SetBool(const CefString& key, bool value) OVERRIDE;
virtual bool SetInt(const CefString& key, int value) OVERRIDE;

View File

@ -13,6 +13,7 @@
#include "libcef_dll/ctocpp/binary_value_ctocpp.h"
#include "libcef_dll/ctocpp/dictionary_value_ctocpp.h"
#include "libcef_dll/ctocpp/list_value_ctocpp.h"
#include "libcef_dll/ctocpp/value_ctocpp.h"
// STATIC METHODS - Body may be edited by hand.
@ -69,6 +70,44 @@ bool CefListValueCToCpp::IsReadOnly() {
return _retval?true:false;
}
bool CefListValueCToCpp::IsSame(CefRefPtr<CefListValue> that) {
if (CEF_MEMBER_MISSING(struct_, is_same))
return false;
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
// Verify param: that; type: refptr_same
DCHECK(that.get());
if (!that.get())
return false;
// Execute
int _retval = struct_->is_same(struct_,
CefListValueCToCpp::Unwrap(that));
// Return type: bool
return _retval?true:false;
}
bool CefListValueCToCpp::IsEqual(CefRefPtr<CefListValue> that) {
if (CEF_MEMBER_MISSING(struct_, is_equal))
return false;
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
// Verify param: that; type: refptr_same
DCHECK(that.get());
if (!that.get())
return false;
// Execute
int _retval = struct_->is_equal(struct_,
CefListValueCToCpp::Unwrap(that));
// Return type: bool
return _retval?true:false;
}
CefRefPtr<CefListValue> CefListValueCToCpp::Copy() {
if (CEF_MEMBER_MISSING(struct_, copy))
return NULL;
@ -160,6 +199,25 @@ CefValueType CefListValueCToCpp::GetType(int index) {
return _retval;
}
CefRefPtr<CefValue> CefListValueCToCpp::GetValue(int index) {
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);
// Return type: refptr_same
return CefValueCToCpp::Wrap(_retval);
}
bool CefListValueCToCpp::GetBool(int index) {
if (CEF_MEMBER_MISSING(struct_, get_bool))
return false;
@ -295,6 +353,30 @@ CefRefPtr<CefListValue> CefListValueCToCpp::GetList(int index) {
return CefListValueCToCpp::Wrap(_retval);
}
bool CefListValueCToCpp::SetValue(int index, CefRefPtr<CefValue> value) {
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())
return false;
// Execute
int _retval = struct_->set_value(struct_,
index,
CefValueCToCpp::Unwrap(value));
// Return type: bool
return _retval?true:false;
}
bool CefListValueCToCpp::SetNull(int index) {
if (CEF_MEMBER_MISSING(struct_, set_null))
return false;

View File

@ -34,12 +34,15 @@ class CefListValueCToCpp
virtual bool IsValid() OVERRIDE;
virtual bool IsOwned() OVERRIDE;
virtual bool IsReadOnly() OVERRIDE;
virtual bool IsSame(CefRefPtr<CefListValue> that) OVERRIDE;
virtual bool IsEqual(CefRefPtr<CefListValue> that) OVERRIDE;
virtual CefRefPtr<CefListValue> Copy() OVERRIDE;
virtual bool SetSize(size_t size) OVERRIDE;
virtual size_t GetSize() OVERRIDE;
virtual bool Clear() OVERRIDE;
virtual bool Remove(int index) OVERRIDE;
virtual CefValueType GetType(int index) OVERRIDE;
virtual CefRefPtr<CefValue> GetValue(int index) OVERRIDE;
virtual bool GetBool(int index) OVERRIDE;
virtual int GetInt(int index) OVERRIDE;
virtual double GetDouble(int index) OVERRIDE;
@ -47,6 +50,7 @@ class CefListValueCToCpp
virtual CefRefPtr<CefBinaryValue> GetBinary(int index) OVERRIDE;
virtual CefRefPtr<CefDictionaryValue> GetDictionary(int index) OVERRIDE;
virtual CefRefPtr<CefListValue> GetList(int index) OVERRIDE;
virtual bool SetValue(int index, CefRefPtr<CefValue> value) OVERRIDE;
virtual bool SetNull(int index) OVERRIDE;
virtual bool SetBool(int index, bool value) OVERRIDE;
virtual bool SetInt(int index, int value) OVERRIDE;

View File

@ -0,0 +1,363 @@
// Copyright (c) 2015 The Chromium Embedded Framework Authors. All rights
// reserved. Use of this source code is governed by a BSD-style license that
// can be found in the LICENSE file.
//
// ---------------------------------------------------------------------------
//
// This file was generated by the CEF translator tool. If making changes by
// hand only do so within the body of existing method and function
// implementations. See the translator.README.txt file in the tools directory
// for more information.
//
#include "libcef_dll/ctocpp/binary_value_ctocpp.h"
#include "libcef_dll/ctocpp/dictionary_value_ctocpp.h"
#include "libcef_dll/ctocpp/list_value_ctocpp.h"
#include "libcef_dll/ctocpp/value_ctocpp.h"
// STATIC METHODS - Body may be edited by hand.
CefRefPtr<CefValue> CefValue::Create() {
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
// Execute
cef_value_t* _retval = cef_value_create();
// Return type: refptr_same
return CefValueCToCpp::Wrap(_retval);
}
// VIRTUAL METHODS - Body may be edited by hand.
bool CefValueCToCpp::IsValid() {
if (CEF_MEMBER_MISSING(struct_, is_valid))
return false;
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
// Execute
int _retval = struct_->is_valid(struct_);
// Return type: bool
return _retval?true:false;
}
bool CefValueCToCpp::IsOwned() {
if (CEF_MEMBER_MISSING(struct_, is_owned))
return false;
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
// Execute
int _retval = struct_->is_owned(struct_);
// Return type: bool
return _retval?true:false;
}
bool CefValueCToCpp::IsReadOnly() {
if (CEF_MEMBER_MISSING(struct_, is_read_only))
return false;
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
// Execute
int _retval = struct_->is_read_only(struct_);
// Return type: bool
return _retval?true:false;
}
bool CefValueCToCpp::IsSame(CefRefPtr<CefValue> that) {
if (CEF_MEMBER_MISSING(struct_, is_same))
return false;
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
// Verify param: that; type: refptr_same
DCHECK(that.get());
if (!that.get())
return false;
// Execute
int _retval = struct_->is_same(struct_,
CefValueCToCpp::Unwrap(that));
// Return type: bool
return _retval?true:false;
}
bool CefValueCToCpp::IsEqual(CefRefPtr<CefValue> that) {
if (CEF_MEMBER_MISSING(struct_, is_equal))
return false;
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
// Verify param: that; type: refptr_same
DCHECK(that.get());
if (!that.get())
return false;
// Execute
int _retval = struct_->is_equal(struct_,
CefValueCToCpp::Unwrap(that));
// Return type: bool
return _retval?true:false;
}
CefRefPtr<CefValue> CefValueCToCpp::Copy() {
if (CEF_MEMBER_MISSING(struct_, copy))
return NULL;
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
// Execute
cef_value_t* _retval = struct_->copy(struct_);
// Return type: refptr_same
return CefValueCToCpp::Wrap(_retval);
}
CefValueType CefValueCToCpp::GetType() {
if (CEF_MEMBER_MISSING(struct_, get_type))
return VTYPE_INVALID;
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
// Execute
cef_value_type_t _retval = struct_->get_type(struct_);
// Return type: simple
return _retval;
}
bool CefValueCToCpp::GetBool() {
if (CEF_MEMBER_MISSING(struct_, get_bool))
return false;
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
// Execute
int _retval = struct_->get_bool(struct_);
// Return type: bool
return _retval?true:false;
}
int CefValueCToCpp::GetInt() {
if (CEF_MEMBER_MISSING(struct_, get_int))
return 0;
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
// Execute
int _retval = struct_->get_int(struct_);
// Return type: simple
return _retval;
}
double CefValueCToCpp::GetDouble() {
if (CEF_MEMBER_MISSING(struct_, get_double))
return 0;
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
// Execute
double _retval = struct_->get_double(struct_);
// Return type: simple
return _retval;
}
CefString CefValueCToCpp::GetString() {
if (CEF_MEMBER_MISSING(struct_, get_string))
return CefString();
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
// Execute
cef_string_userfree_t _retval = struct_->get_string(struct_);
// Return type: string
CefString _retvalStr;
_retvalStr.AttachToUserFree(_retval);
return _retvalStr;
}
CefRefPtr<CefBinaryValue> CefValueCToCpp::GetBinary() {
if (CEF_MEMBER_MISSING(struct_, get_binary))
return NULL;
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
// Execute
cef_binary_value_t* _retval = struct_->get_binary(struct_);
// Return type: refptr_same
return CefBinaryValueCToCpp::Wrap(_retval);
}
CefRefPtr<CefDictionaryValue> CefValueCToCpp::GetDictionary() {
if (CEF_MEMBER_MISSING(struct_, get_dictionary))
return NULL;
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
// Execute
cef_dictionary_value_t* _retval = struct_->get_dictionary(struct_);
// Return type: refptr_same
return CefDictionaryValueCToCpp::Wrap(_retval);
}
CefRefPtr<CefListValue> CefValueCToCpp::GetList() {
if (CEF_MEMBER_MISSING(struct_, get_list))
return NULL;
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
// Execute
cef_list_value_t* _retval = struct_->get_list(struct_);
// Return type: refptr_same
return CefListValueCToCpp::Wrap(_retval);
}
bool CefValueCToCpp::SetNull() {
if (CEF_MEMBER_MISSING(struct_, set_null))
return false;
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
// Execute
int _retval = struct_->set_null(struct_);
// Return type: bool
return _retval?true:false;
}
bool CefValueCToCpp::SetBool(bool value) {
if (CEF_MEMBER_MISSING(struct_, set_bool))
return false;
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
// Execute
int _retval = struct_->set_bool(struct_,
value);
// Return type: bool
return _retval?true:false;
}
bool CefValueCToCpp::SetInt(int value) {
if (CEF_MEMBER_MISSING(struct_, set_int))
return false;
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
// Execute
int _retval = struct_->set_int(struct_,
value);
// Return type: bool
return _retval?true:false;
}
bool CefValueCToCpp::SetDouble(double value) {
if (CEF_MEMBER_MISSING(struct_, set_double))
return false;
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
// Execute
int _retval = struct_->set_double(struct_,
value);
// Return type: bool
return _retval?true:false;
}
bool CefValueCToCpp::SetString(const CefString& value) {
if (CEF_MEMBER_MISSING(struct_, set_string))
return false;
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
// Unverified params: value
// Execute
int _retval = struct_->set_string(struct_,
value.GetStruct());
// Return type: bool
return _retval?true:false;
}
bool CefValueCToCpp::SetBinary(CefRefPtr<CefBinaryValue> value) {
if (CEF_MEMBER_MISSING(struct_, set_binary))
return false;
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
// Verify param: value; type: refptr_same
DCHECK(value.get());
if (!value.get())
return false;
// Execute
int _retval = struct_->set_binary(struct_,
CefBinaryValueCToCpp::Unwrap(value));
// Return type: bool
return _retval?true:false;
}
bool CefValueCToCpp::SetDictionary(CefRefPtr<CefDictionaryValue> value) {
if (CEF_MEMBER_MISSING(struct_, set_dictionary))
return false;
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
// Verify param: value; type: refptr_same
DCHECK(value.get());
if (!value.get())
return false;
// Execute
int _retval = struct_->set_dictionary(struct_,
CefDictionaryValueCToCpp::Unwrap(value));
// Return type: bool
return _retval?true:false;
}
bool CefValueCToCpp::SetList(CefRefPtr<CefListValue> value) {
if (CEF_MEMBER_MISSING(struct_, set_list))
return false;
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
// Verify param: value; type: refptr_same
DCHECK(value.get());
if (!value.get())
return false;
// Execute
int _retval = struct_->set_list(struct_,
CefListValueCToCpp::Unwrap(value));
// Return type: bool
return _retval?true:false;
}
#ifndef NDEBUG
template<> base::AtomicRefCount CefCToCpp<CefValueCToCpp, CefValue,
cef_value_t>::DebugObjCt = 0;
#endif

View File

@ -0,0 +1,60 @@
// Copyright (c) 2015 The Chromium Embedded Framework Authors. All rights
// reserved. Use of this source code is governed by a BSD-style license that
// can be found in the LICENSE file.
//
// ---------------------------------------------------------------------------
//
// This file was generated by the CEF translator tool. If making changes by
// hand only do so within the body of existing method and function
// implementations. See the translator.README.txt file in the tools directory
// for more information.
//
#ifndef CEF_LIBCEF_DLL_CTOCPP_VALUE_CTOCPP_H_
#define CEF_LIBCEF_DLL_CTOCPP_VALUE_CTOCPP_H_
#pragma once
#ifndef USING_CEF_SHARED
#pragma message("Warning: "__FILE__" may be accessed wrapper-side only")
#else // USING_CEF_SHARED
#include "include/cef_values.h"
#include "include/capi/cef_values_capi.h"
#include "libcef_dll/ctocpp/ctocpp.h"
// Wrap a C structure with a C++ class.
// This class may be instantiated and accessed wrapper-side only.
class CefValueCToCpp
: public CefCToCpp<CefValueCToCpp, CefValue, cef_value_t> {
public:
explicit CefValueCToCpp(cef_value_t* str)
: CefCToCpp<CefValueCToCpp, CefValue, cef_value_t>(str) {}
// CefValue methods
virtual bool IsValid() OVERRIDE;
virtual bool IsOwned() OVERRIDE;
virtual bool IsReadOnly() OVERRIDE;
virtual bool IsSame(CefRefPtr<CefValue> that) OVERRIDE;
virtual bool IsEqual(CefRefPtr<CefValue> that) OVERRIDE;
virtual CefRefPtr<CefValue> Copy() OVERRIDE;
virtual CefValueType GetType() OVERRIDE;
virtual bool GetBool() OVERRIDE;
virtual int GetInt() OVERRIDE;
virtual double GetDouble() OVERRIDE;
virtual CefString GetString() OVERRIDE;
virtual CefRefPtr<CefBinaryValue> GetBinary() OVERRIDE;
virtual CefRefPtr<CefDictionaryValue> GetDictionary() OVERRIDE;
virtual CefRefPtr<CefListValue> GetList() OVERRIDE;
virtual bool SetNull() OVERRIDE;
virtual bool SetBool(bool value) OVERRIDE;
virtual bool SetInt(int value) OVERRIDE;
virtual bool SetDouble(double value) OVERRIDE;
virtual bool SetString(const CefString& value) OVERRIDE;
virtual bool SetBinary(CefRefPtr<CefBinaryValue> value) OVERRIDE;
virtual bool SetDictionary(CefRefPtr<CefDictionaryValue> value) OVERRIDE;
virtual bool SetList(CefRefPtr<CefListValue> value) OVERRIDE;
};
#endif // USING_CEF_SHARED
#endif // CEF_LIBCEF_DLL_CTOCPP_VALUE_CTOCPP_H_

View File

@ -70,6 +70,7 @@
#include "libcef_dll/cpptoc/v8stack_frame_cpptoc.h"
#include "libcef_dll/cpptoc/v8stack_trace_cpptoc.h"
#include "libcef_dll/cpptoc/v8value_cpptoc.h"
#include "libcef_dll/cpptoc/value_cpptoc.h"
#include "libcef_dll/cpptoc/web_plugin_info_cpptoc.h"
#include "libcef_dll/cpptoc/xml_reader_cpptoc.h"
#include "libcef_dll/cpptoc/zip_reader_cpptoc.h"
@ -267,6 +268,7 @@ CEF_EXPORT void cef_shutdown() {
DCHECK(base::AtomicRefCountIsZero(&CefV8StackFrameCppToC::DebugObjCt));
DCHECK(base::AtomicRefCountIsZero(&CefV8StackTraceCppToC::DebugObjCt));
DCHECK(base::AtomicRefCountIsZero(&CefV8ValueCppToC::DebugObjCt));
DCHECK(base::AtomicRefCountIsZero(&CefValueCppToC::DebugObjCt));
DCHECK(base::AtomicRefCountIsZero(&CefWebPluginInfoCppToC::DebugObjCt));
DCHECK(base::AtomicRefCountIsZero(
&CefWebPluginInfoVisitorCToCpp::DebugObjCt));

View File

@ -110,6 +110,7 @@
#include "libcef_dll/ctocpp/v8stack_frame_ctocpp.h"
#include "libcef_dll/ctocpp/v8stack_trace_ctocpp.h"
#include "libcef_dll/ctocpp/v8value_ctocpp.h"
#include "libcef_dll/ctocpp/value_ctocpp.h"
#include "libcef_dll/ctocpp/web_plugin_info_ctocpp.h"
#include "libcef_dll/ctocpp/xml_reader_ctocpp.h"
#include "libcef_dll/ctocpp/zip_reader_ctocpp.h"
@ -259,6 +260,7 @@ CEF_GLOBAL void CefShutdown() {
DCHECK(base::AtomicRefCountIsZero(&CefV8StackFrameCToCpp::DebugObjCt));
DCHECK(base::AtomicRefCountIsZero(&CefV8StackTraceCToCpp::DebugObjCt));
DCHECK(base::AtomicRefCountIsZero(&CefV8ValueCToCpp::DebugObjCt));
DCHECK(base::AtomicRefCountIsZero(&CefValueCToCpp::DebugObjCt));
DCHECK(base::AtomicRefCountIsZero(&CefWebPluginInfoCToCpp::DebugObjCt));
DCHECK(base::AtomicRefCountIsZero(
&CefWebPluginInfoVisitorCppToC::DebugObjCt));

View File

@ -115,6 +115,9 @@ void TestBinaryEqual(CefRefPtr<CefBinaryValue> val1,
EXPECT_TRUE(val1.get());
EXPECT_TRUE(val2.get());
EXPECT_TRUE(val1->IsEqual(val2));
EXPECT_TRUE(val2->IsEqual(val1));
size_t data_size = val1->GetSize();
EXPECT_EQ(data_size, val2->GetSize());
@ -139,6 +142,9 @@ void TestDictionaryEqual(CefRefPtr<CefDictionaryValue> val1,
EXPECT_TRUE(val1.get());
EXPECT_TRUE(val2.get());
EXPECT_TRUE(val1->IsEqual(val2));
EXPECT_TRUE(val2->IsEqual(val1));
EXPECT_EQ(val1->GetSize(), val2->GetSize());
CefDictionaryValue::KeyList keys;
@ -184,6 +190,9 @@ void TestListEqual(CefRefPtr<CefListValue> val1,
EXPECT_TRUE(val1.get());
EXPECT_TRUE(val2.get());
EXPECT_TRUE(val1->IsEqual(val2));
EXPECT_TRUE(val2->IsEqual(val1));
int size = static_cast<int>(val1->GetSize());
EXPECT_EQ(size, static_cast<int>(val2->GetSize()));

View File

@ -47,7 +47,7 @@ const char* kStringValue = "My string value";
// Test a binary value.
void TestBinary(CefRefPtr<CefBinaryValue> value, char* data, size_t data_size) {
// Testing requires strings longer than 15 characters.
EXPECT_GT(data_size, (size_t)15);
EXPECT_GT(data_size, 15U);
EXPECT_EQ(data_size, value->GetSize());
@ -63,7 +63,7 @@ void TestBinary(CefRefPtr<CefBinaryValue> value, char* data, size_t data_size) {
memset(buff, 0, data_size+1);
old_char = data[15];
data[15] = 0;
EXPECT_EQ((size_t)10, value->GetData(buff, 10, 5));
EXPECT_EQ(10U, value->GetData(buff, 10, 5));
EXPECT_TRUE(!strcmp(buff, data+5));
data[15] = old_char;
@ -71,7 +71,7 @@ void TestBinary(CefRefPtr<CefBinaryValue> value, char* data, size_t data_size) {
memset(buff, 0, data_size+1);
old_char = data[0];
data[0] = '.';
EXPECT_EQ((size_t)1, value->GetData(buff, 1, 0));
EXPECT_EQ(1U, value->GetData(buff, 1, 0));
EXPECT_EQ(old_char, buff[0]);
data[0] = old_char;
@ -178,7 +178,7 @@ void TestDictionaryDictionary(CefRefPtr<CefDictionaryValue> value,
EXPECT_FALSE(dictionary_value->IsOwned());
EXPECT_FALSE(dictionary_value->IsReadOnly());
EXPECT_TRUE(dictionary_value->SetInt(kIntKey, kIntValue));
EXPECT_EQ((size_t)1, dictionary_value->GetSize());
EXPECT_EQ(1U, dictionary_value->GetSize());
EXPECT_FALSE(value->HasKey(kDictionaryKey));
EXPECT_TRUE(value->SetDictionary(kDictionaryKey, dictionary_value));
EXPECT_FALSE(dictionary_value->IsValid()); // Value should be detached
@ -189,7 +189,7 @@ void TestDictionaryDictionary(CefRefPtr<CefDictionaryValue> value,
EXPECT_TRUE(dictionary_value->IsValid());
EXPECT_TRUE(dictionary_value->IsOwned());
EXPECT_FALSE(dictionary_value->IsReadOnly());
EXPECT_EQ((size_t)1, dictionary_value->GetSize());
EXPECT_EQ(1U, dictionary_value->GetSize());
EXPECT_EQ(kIntValue, dictionary_value->GetInt(kIntKey));
}
@ -202,7 +202,7 @@ void TestDictionaryList(CefRefPtr<CefDictionaryValue> value,
EXPECT_FALSE(list_value->IsOwned());
EXPECT_FALSE(list_value->IsReadOnly());
EXPECT_TRUE(list_value->SetInt(0, kIntValue));
EXPECT_EQ((size_t)1, list_value->GetSize());
EXPECT_EQ(1U, list_value->GetSize());
EXPECT_FALSE(value->HasKey(kListKey));
EXPECT_TRUE(value->SetList(kListKey, list_value));
EXPECT_FALSE(list_value->IsValid()); // Value should be detached
@ -213,7 +213,7 @@ void TestDictionaryList(CefRefPtr<CefDictionaryValue> value,
EXPECT_TRUE(list_value->IsValid());
EXPECT_TRUE(list_value->IsOwned());
EXPECT_FALSE(list_value->IsReadOnly());
EXPECT_EQ((size_t)1, list_value->GetSize());
EXPECT_EQ(1U, list_value->GetSize());
EXPECT_EQ(kIntValue, list_value->GetInt(0));
}
@ -225,7 +225,7 @@ void TestDictionary(CefRefPtr<CefDictionaryValue> value,
CefRefPtr<CefListValue> list_value;
// Test the size.
EXPECT_EQ((size_t)0, value->GetSize());
EXPECT_EQ(0U, value->GetSize());
TestDictionaryNull(value);
TestDictionaryBool(value);
@ -237,7 +237,7 @@ void TestDictionary(CefRefPtr<CefDictionaryValue> value,
TestDictionaryList(value, list_value);
// Test the size.
EXPECT_EQ((size_t)8, value->GetSize());
EXPECT_EQ(8U, value->GetSize());
// Test copy.
CefRefPtr<CefDictionaryValue> copy = value->Copy(false);
@ -272,7 +272,7 @@ void TestDictionary(CefRefPtr<CefDictionaryValue> value,
EXPECT_FALSE(list_value->IsValid()); // Value should be detached
// Test the size.
EXPECT_EQ((size_t)0, value->GetSize());
EXPECT_EQ(0U, value->GetSize());
// Re-add some values.
TestDictionaryNull(value);
@ -280,11 +280,11 @@ void TestDictionary(CefRefPtr<CefDictionaryValue> value,
TestDictionaryDictionary(value, dictionary_value);
// Test the size.
EXPECT_EQ((size_t)3, value->GetSize());
EXPECT_EQ(3U, value->GetSize());
// Clear the values.
EXPECT_TRUE(value->Clear());
EXPECT_EQ((size_t)0, value->GetSize());
EXPECT_EQ(0U, value->GetSize());
EXPECT_FALSE(dictionary_value->IsValid()); // Value should be detached
}
@ -363,8 +363,8 @@ void TestListString(CefRefPtr<CefListValue> value, int index) {
// Test list binary value.
void TestListBinary(CefRefPtr<CefListValue> value, int index,
char* binary_data, size_t binary_data_size,
CefRefPtr<CefBinaryValue>& binary_value) {
char* binary_data, size_t binary_data_size,
CefRefPtr<CefBinaryValue>& binary_value) {
binary_value = CefBinaryValue::Create(binary_data, binary_data_size);
EXPECT_TRUE(binary_value.get());
EXPECT_TRUE(binary_value->IsValid());
@ -392,7 +392,7 @@ void TestListDictionary(CefRefPtr<CefListValue> value, int index,
EXPECT_FALSE(dictionary_value->IsOwned());
EXPECT_FALSE(dictionary_value->IsReadOnly());
EXPECT_TRUE(dictionary_value->SetInt(kIntKey, kIntValue));
EXPECT_EQ((size_t)1, dictionary_value->GetSize());
EXPECT_EQ(1U, dictionary_value->GetSize());
CefValueType type = value->GetType(index);
EXPECT_TRUE(type == VTYPE_INVALID || type == VTYPE_NULL);
@ -405,7 +405,7 @@ void TestListDictionary(CefRefPtr<CefListValue> value, int index,
EXPECT_TRUE(dictionary_value->IsValid());
EXPECT_TRUE(dictionary_value->IsOwned());
EXPECT_FALSE(dictionary_value->IsReadOnly());
EXPECT_EQ((size_t)1, dictionary_value->GetSize());
EXPECT_EQ(1U, dictionary_value->GetSize());
EXPECT_EQ(kIntValue, dictionary_value->GetInt(kIntKey));
}
@ -418,7 +418,7 @@ void TestListList(CefRefPtr<CefListValue> value, int index,
EXPECT_FALSE(list_value->IsOwned());
EXPECT_FALSE(list_value->IsReadOnly());
EXPECT_TRUE(list_value->SetInt(0, kIntValue));
EXPECT_EQ((size_t)1, list_value->GetSize());
EXPECT_EQ(1U, list_value->GetSize());
CefValueType type = value->GetType(index);
EXPECT_TRUE(type == VTYPE_INVALID || type == VTYPE_NULL);
@ -431,7 +431,7 @@ void TestListList(CefRefPtr<CefListValue> value, int index,
EXPECT_TRUE(list_value->IsValid());
EXPECT_TRUE(list_value->IsOwned());
EXPECT_FALSE(list_value->IsReadOnly());
EXPECT_EQ((size_t)1, list_value->GetSize());
EXPECT_EQ(1U, list_value->GetSize());
EXPECT_EQ(kIntValue, list_value->GetInt(0));
}
@ -443,11 +443,11 @@ void TestList(CefRefPtr<CefListValue> value,
CefRefPtr<CefListValue> list_value;
// Test the size.
EXPECT_EQ((size_t)0, value->GetSize());
EXPECT_EQ(0U, value->GetSize());
// Set the size.
EXPECT_TRUE(value->SetSize(8));
EXPECT_EQ((size_t)8, value->GetSize());
EXPECT_EQ(8U, value->GetSize());
EXPECT_EQ(VTYPE_NULL, value->GetType(kNullIndex));
TestListNull(value, kNullIndex);
@ -468,7 +468,7 @@ void TestList(CefRefPtr<CefListValue> value,
TestListList(value, kListIndex, list_value);
// Test the size.
EXPECT_EQ((size_t)8, value->GetSize());
EXPECT_EQ(8U, value->GetSize());
// Test copy.
CefRefPtr<CefListValue> copy = value->Copy();
@ -476,31 +476,31 @@ void TestList(CefRefPtr<CefListValue> value,
// Test removal (in reverse order so indexes stay valid).
EXPECT_TRUE(value->Remove(kListIndex));
EXPECT_EQ((size_t)7, value->GetSize());
EXPECT_EQ(7U, value->GetSize());
EXPECT_FALSE(list_value->IsValid()); // Value should be detached
EXPECT_TRUE(value->Remove(kDictionaryIndex));
EXPECT_EQ((size_t)6, value->GetSize());
EXPECT_EQ(6U, value->GetSize());
EXPECT_FALSE(dictionary_value->IsValid()); // Value should be detached
EXPECT_TRUE(value->Remove(kBinaryIndex));
EXPECT_EQ((size_t)5, value->GetSize());
EXPECT_EQ(5U, value->GetSize());
EXPECT_FALSE(binary_value->IsValid()); // Value should be detached
EXPECT_TRUE(value->Remove(kStringIndex));
EXPECT_EQ((size_t)4, value->GetSize());
EXPECT_EQ(4U, value->GetSize());
EXPECT_TRUE(value->Remove(kDoubleIndex));
EXPECT_EQ((size_t)3, value->GetSize());
EXPECT_EQ(3U, value->GetSize());
EXPECT_TRUE(value->Remove(kIntIndex));
EXPECT_EQ((size_t)2, value->GetSize());
EXPECT_EQ(2U, value->GetSize());
EXPECT_TRUE(value->Remove(kBoolIndex));
EXPECT_EQ((size_t)1, value->GetSize());
EXPECT_EQ(1U, value->GetSize());
EXPECT_TRUE(value->Remove(kNullIndex));
EXPECT_EQ((size_t)0, value->GetSize());
EXPECT_EQ(0U, value->GetSize());
// Re-add some values.
EXPECT_EQ(VTYPE_INVALID, value->GetType(0));
@ -511,11 +511,11 @@ void TestList(CefRefPtr<CefListValue> value,
TestListList(value, 2, list_value);
// Test the size.
EXPECT_EQ((size_t)3, value->GetSize());
EXPECT_EQ(3U, value->GetSize());
// Clear the values.
EXPECT_TRUE(value->Clear());
EXPECT_EQ((size_t)0, value->GetSize());
EXPECT_EQ(0U, value->GetSize());
EXPECT_FALSE(list_value->IsValid()); // Value should be detached
// Add some values in random order.
@ -531,11 +531,11 @@ void TestList(CefRefPtr<CefListValue> value,
EXPECT_EQ(VTYPE_INT, value->GetType(2));
// Test the size.
EXPECT_EQ((size_t)3, value->GetSize());
EXPECT_EQ(3U, value->GetSize());
// Clear some values.
EXPECT_TRUE(value->SetSize(1));
EXPECT_EQ((size_t)1, value->GetSize());
EXPECT_EQ(1U, value->GetSize());
EXPECT_FALSE(list_value->IsValid()); // Value should be detached
EXPECT_EQ(VTYPE_BOOL, value->GetType(0));
@ -544,7 +544,7 @@ void TestList(CefRefPtr<CefListValue> value,
// Clear all values.
EXPECT_TRUE(value->Clear());
EXPECT_EQ((size_t)0, value->GetSize());
EXPECT_EQ(0U, value->GetSize());
}
// Used to test access of list data on a different thread.
@ -568,6 +568,58 @@ class ListTask : public CefTask {
IMPLEMENT_REFCOUNTING(ListTask);
};
void CreateAndCompareCopy(CefRefPtr<CefValue> value) {
CefRefPtr<CefValue> value2 = value->Copy();
EXPECT_TRUE(value->IsEqual(value));
EXPECT_TRUE(value->IsSame(value));
EXPECT_TRUE(value2->IsEqual(value2));
EXPECT_TRUE(value2->IsSame(value2));
EXPECT_TRUE(value->IsEqual(value2));
EXPECT_FALSE(value->IsSame(value2));
EXPECT_TRUE(value2->IsEqual(value));
EXPECT_FALSE(value2->IsSame(value));
}
CefRefPtr<CefBinaryValue> CreateBinaryValue() {
char binary_data[] = "This is my test data";
const size_t binary_data_size = sizeof(binary_data) - 1;
CefRefPtr<CefBinaryValue> binary_value =
CefBinaryValue::Create(binary_data, binary_data_size);
EXPECT_TRUE(binary_value.get());
EXPECT_TRUE(binary_value->IsValid());
EXPECT_FALSE(binary_value->IsOwned());
TestBinary(binary_value, binary_data, binary_data_size);
return binary_value;
}
CefRefPtr<CefListValue> CreateListValue() {
CefRefPtr<CefListValue> list_value = CefListValue::Create();
EXPECT_TRUE(list_value.get());
EXPECT_TRUE(list_value->IsValid());
EXPECT_FALSE(list_value->IsOwned());
EXPECT_FALSE(list_value->IsReadOnly());
EXPECT_TRUE(list_value->SetInt(0, kIntValue));
EXPECT_TRUE(list_value->SetInt(1, kDoubleValue));
return list_value;
}
const char* kKey1 = "key1";
const char* kKey2 = "key2";
CefRefPtr<CefDictionaryValue> CreateDictionaryValue() {
// Create the dictionary.
CefRefPtr<CefDictionaryValue> dict_value = CefDictionaryValue::Create();
EXPECT_TRUE(dict_value.get());
EXPECT_TRUE(dict_value->IsValid());
EXPECT_FALSE(dict_value->IsOwned());
EXPECT_FALSE(dict_value->IsReadOnly());
EXPECT_TRUE(dict_value->SetInt(kKey1, kIntValue));
EXPECT_TRUE(dict_value->SetInt(kKey2, kDoubleValue));
return dict_value;
}
} // namespace
@ -734,3 +786,592 @@ TEST(ValuesTest, ListDetachment) {
EXPECT_FALSE(list_value2->IsValid());
EXPECT_FALSE(list_value3->IsValid());
}
// Test get/set of a CefValue simple types.
TEST(ValuesTest, ValueSimple) {
CefRefPtr<CefValue> value = CefValue::Create();
EXPECT_TRUE(value.get());
EXPECT_TRUE(value->IsValid());
EXPECT_FALSE(value->IsReadOnly());
EXPECT_FALSE(value->IsOwned());
EXPECT_EQ(VTYPE_NULL, value->GetType());
CreateAndCompareCopy(value);
EXPECT_TRUE(value->SetBool(true));
EXPECT_EQ(VTYPE_BOOL, value->GetType());
EXPECT_EQ(true, value->GetBool());
EXPECT_TRUE(value->IsValid());
EXPECT_FALSE(value->IsReadOnly());
EXPECT_FALSE(value->IsOwned());
CreateAndCompareCopy(value);
EXPECT_TRUE(value->SetBool(false));
EXPECT_EQ(VTYPE_BOOL, value->GetType());
EXPECT_EQ(false, value->GetBool());
EXPECT_TRUE(value->IsValid());
EXPECT_FALSE(value->IsReadOnly());
EXPECT_FALSE(value->IsOwned());
CreateAndCompareCopy(value);
EXPECT_TRUE(value->SetInt(3));
EXPECT_EQ(VTYPE_INT, value->GetType());
EXPECT_EQ(3, value->GetInt());
EXPECT_TRUE(value->IsValid());
EXPECT_FALSE(value->IsReadOnly());
EXPECT_FALSE(value->IsOwned());
CreateAndCompareCopy(value);
EXPECT_TRUE(value->SetDouble(5.665));
EXPECT_EQ(VTYPE_DOUBLE, value->GetType());
EXPECT_EQ(5.665, value->GetDouble());
EXPECT_TRUE(value->IsValid());
EXPECT_FALSE(value->IsReadOnly());
EXPECT_FALSE(value->IsOwned());
CreateAndCompareCopy(value);
const char* str = "Test string";
EXPECT_TRUE(value->SetString(str));
EXPECT_EQ(VTYPE_STRING, value->GetType());
EXPECT_STREQ(str, value->GetString().ToString().data());
EXPECT_TRUE(value->IsValid());
EXPECT_FALSE(value->IsReadOnly());
EXPECT_FALSE(value->IsOwned());
CreateAndCompareCopy(value);
EXPECT_TRUE(value->SetNull());
EXPECT_EQ(VTYPE_NULL, value->GetType());
EXPECT_TRUE(value->IsValid());
EXPECT_FALSE(value->IsReadOnly());
EXPECT_FALSE(value->IsOwned());
CreateAndCompareCopy(value);
}
// Test association of a CefValue simple type with a CefListValue.
TEST(ValuesTest, ValueSimpleToList) {
const double double_value = 5.665;
CefRefPtr<CefValue> value = CefValue::Create();
EXPECT_TRUE(value->SetDouble(double_value));
// Add the value to the target list.
CefRefPtr<CefListValue> target_list = CefListValue::Create();
EXPECT_TRUE(target_list->SetValue(0, value));
// Test the value in the target list.
EXPECT_EQ(VTYPE_DOUBLE, target_list->GetType(0));
EXPECT_EQ(double_value, target_list->GetDouble(0));
// Get the value from the target list.
CefRefPtr<CefValue> value2 = target_list->GetValue(0);
EXPECT_TRUE(value2.get());
EXPECT_FALSE(value2->IsOwned());
EXPECT_FALSE(value2->IsReadOnly());
EXPECT_EQ(VTYPE_DOUBLE, value2->GetType());
EXPECT_EQ(double_value, value2->GetDouble());
// Values are equal but not the same.
EXPECT_TRUE(value->IsEqual(value2));
EXPECT_TRUE(value2->IsEqual(value));
EXPECT_FALSE(value->IsSame(value2));
EXPECT_FALSE(value2->IsSame(value));
// Change the value in the target list.
EXPECT_TRUE(target_list->SetInt(0, 5));
EXPECT_EQ(VTYPE_INT, target_list->GetType(0));
EXPECT_EQ(5, target_list->GetInt(0));
// The other values are still valid.
EXPECT_TRUE(value->IsValid());
EXPECT_TRUE(value2->IsValid());
}
// Test association of a CefValue simple type with a CefDictionaryValue.
TEST(ValuesTest, ValueSimpleToDictionary) {
const double double_value = 5.665;
const char* key = "key";
CefRefPtr<CefValue> value = CefValue::Create();
EXPECT_TRUE(value->SetDouble(double_value));
// Add the value to the target dictionary.
CefRefPtr<CefDictionaryValue> target_dict = CefDictionaryValue::Create();
EXPECT_TRUE(target_dict->SetValue(key, value));
// Test the value in the target dictionary.
EXPECT_EQ(VTYPE_DOUBLE, target_dict->GetType(key));
EXPECT_EQ(double_value, target_dict->GetDouble(key));
// Get the value from the target dictionary.
CefRefPtr<CefValue> value2 = target_dict->GetValue(key);
EXPECT_TRUE(value2.get());
EXPECT_FALSE(value2->IsOwned());
EXPECT_FALSE(value2->IsReadOnly());
EXPECT_EQ(VTYPE_DOUBLE, value2->GetType());
EXPECT_EQ(double_value, value2->GetDouble());
// Values are equal but not the same.
EXPECT_TRUE(value->IsEqual(value2));
EXPECT_TRUE(value2->IsEqual(value));
EXPECT_FALSE(value->IsSame(value2));
EXPECT_FALSE(value2->IsSame(value));
// Change the value in the target dictionary.
EXPECT_TRUE(target_dict->SetInt(key, 5));
EXPECT_EQ(VTYPE_INT, target_dict->GetType(key));
EXPECT_EQ(5, target_dict->GetInt(key));
// The other values are still valid.
EXPECT_TRUE(value->IsValid());
EXPECT_TRUE(value2->IsValid());
}
// Test get/set of a CefValue binary type.
TEST(ValuesTest, ValueBinary) {
// Create the binary.
CefRefPtr<CefBinaryValue> binary_value = CreateBinaryValue();
// Create the value.
CefRefPtr<CefValue> value = CefValue::Create();
EXPECT_TRUE(value->SetBinary(binary_value));
EXPECT_EQ(VTYPE_BINARY, value->GetType());
EXPECT_TRUE(value->IsValid());
EXPECT_TRUE(value->IsReadOnly()); // Binary values are always read-only.
EXPECT_FALSE(value->IsOwned());
CreateAndCompareCopy(value);
// Get the binary reference from the value.
CefRefPtr<CefBinaryValue> binary_value2 = value->GetBinary();
EXPECT_TRUE(binary_value2.get());
EXPECT_TRUE(binary_value2->IsValid());
EXPECT_FALSE(binary_value2->IsOwned());
// The binaries are the same and equal.
TestBinaryEqual(binary_value, binary_value2);
EXPECT_TRUE(binary_value->IsSame(binary_value2));
EXPECT_TRUE(binary_value2->IsSame(binary_value));
}
// Test association of a CefValue binary with a CefListValue.
TEST(ValuesTest, ValueBinaryToList) {
// Create the binary.
CefRefPtr<CefBinaryValue> binary_value = CreateBinaryValue();
// Add the binary to a value.
CefRefPtr<CefValue> value = CefValue::Create();
EXPECT_TRUE(value->SetBinary(binary_value));
// Add the value to the target list.
CefRefPtr<CefListValue> target_list = CefListValue::Create();
EXPECT_TRUE(target_list->SetValue(0, value));
// The binary value is now owned by the target list.
EXPECT_FALSE(binary_value->IsValid());
// The value is still valid and points to the new reference list.
EXPECT_TRUE(value->IsValid());
CefRefPtr<CefBinaryValue> binary_value2 = value->GetBinary();
CefRefPtr<CefBinaryValue> binary_value3 = target_list->GetBinary(0);
CefRefPtr<CefValue> value2 = target_list->GetValue(0);
CefRefPtr<CefBinaryValue> binary_value4 = value2->GetBinary();
// All values are owned by the target list.
EXPECT_TRUE(value->IsOwned());
EXPECT_TRUE(value2->IsOwned());
EXPECT_TRUE(binary_value2->IsOwned());
EXPECT_TRUE(binary_value3->IsOwned());
EXPECT_TRUE(binary_value4->IsOwned());
// All values are the same.
EXPECT_TRUE(binary_value2->IsSame(binary_value3));
TestBinaryEqual(binary_value2, binary_value3);
EXPECT_TRUE(binary_value2->IsSame(binary_value4));
TestBinaryEqual(binary_value2, binary_value4);
// Change the value to something else.
EXPECT_TRUE(target_list->SetInt(0, kIntValue));
EXPECT_EQ(VTYPE_INT, target_list->GetType(0));
EXPECT_EQ(kIntValue, target_list->GetInt(0));
// Now the references are invalid.
EXPECT_FALSE(value->IsValid());
EXPECT_FALSE(value2->IsValid());
EXPECT_FALSE(binary_value2->IsValid());
EXPECT_FALSE(binary_value3->IsValid());
EXPECT_FALSE(binary_value4->IsValid());
// Verify that adding a binary to a list directly invalidates both the binary
// and the value that references it.
binary_value = CreateBinaryValue();
value = CefValue::Create();
EXPECT_TRUE(value->SetBinary(binary_value));
target_list->SetBinary(0, binary_value);
EXPECT_FALSE(binary_value->IsValid());
EXPECT_FALSE(value->IsValid());
}
// Test association of a CefValue binary with a CefDictionaryValue.
TEST(ValuesTest, ValueBinaryToDictionary) {
const char* key = "key";
// Create the binary.
CefRefPtr<CefBinaryValue> binary_value = CreateBinaryValue();
// Add the binary to a value.
CefRefPtr<CefValue> value = CefValue::Create();
EXPECT_TRUE(value->SetBinary(binary_value));
// Add the value to the target dictionary.
CefRefPtr<CefDictionaryValue> target_dict = CefDictionaryValue::Create();
EXPECT_TRUE(target_dict->SetValue(key, value));
// The list value is now owned by the target dictionary.
EXPECT_FALSE(binary_value->IsValid());
// The value is still valid and points to the new reference list.
EXPECT_TRUE(value->IsValid());
CefRefPtr<CefBinaryValue> binary_value2 = value->GetBinary();
CefRefPtr<CefBinaryValue> binary_value3 = target_dict->GetBinary(key);
CefRefPtr<CefValue> value2 = target_dict->GetValue(key);
CefRefPtr<CefBinaryValue> binary_value4 = value2->GetBinary();
// All values are owned by the target dictionary.
EXPECT_TRUE(value->IsOwned());
EXPECT_TRUE(value2->IsOwned());
EXPECT_TRUE(binary_value2->IsOwned());
EXPECT_TRUE(binary_value3->IsOwned());
EXPECT_TRUE(binary_value4->IsOwned());
// All values are the same.
EXPECT_TRUE(binary_value2->IsSame(binary_value3));
TestBinaryEqual(binary_value2, binary_value3);
EXPECT_TRUE(binary_value2->IsSame(binary_value4));
TestBinaryEqual(binary_value2, binary_value4);
// Change the value to something else.
EXPECT_TRUE(target_dict->SetInt(key, kIntValue));
EXPECT_EQ(VTYPE_INT, target_dict->GetType(key));
EXPECT_EQ(kIntValue, target_dict->GetInt(key));
// Now the references are invalid.
EXPECT_FALSE(value->IsValid());
EXPECT_FALSE(value2->IsValid());
EXPECT_FALSE(binary_value2->IsValid());
EXPECT_FALSE(binary_value3->IsValid());
EXPECT_FALSE(binary_value4->IsValid());
// Verify that adding a binary to a dictionary directly invalidates both the
// binary and the value that references it.
binary_value = CreateBinaryValue();
value = CefValue::Create();
EXPECT_TRUE(value->SetBinary(binary_value));
target_dict->SetBinary(key, binary_value);
EXPECT_FALSE(binary_value->IsValid());
EXPECT_FALSE(value->IsValid());
}
// Test get/set of a CefValue list type.
TEST(ValuesTest, ValueList) {
// Create the list.
CefRefPtr<CefListValue> list_value = CreateListValue();
// Create the value.
CefRefPtr<CefValue> value = CefValue::Create();
EXPECT_TRUE(value->SetList(list_value));
EXPECT_EQ(VTYPE_LIST, value->GetType());
EXPECT_TRUE(value->IsValid());
EXPECT_FALSE(value->IsReadOnly());
EXPECT_FALSE(value->IsOwned());
CreateAndCompareCopy(value);
// Get the list reference from the value.
CefRefPtr<CefListValue> list_value2 = value->GetList();
EXPECT_TRUE(list_value2.get());
EXPECT_TRUE(list_value2->IsValid());
EXPECT_FALSE(list_value2->IsOwned());
EXPECT_FALSE(list_value2->IsReadOnly());
// The lists are the same and equal.
TestListEqual(list_value, list_value2);
EXPECT_TRUE(list_value->IsSame(list_value2));
EXPECT_TRUE(list_value2->IsSame(list_value));
// Change a value in one list and verify that it's changed in the other list.
EXPECT_TRUE(list_value->SetString(0, kStringValue));
EXPECT_EQ(VTYPE_STRING, list_value->GetType(0));
EXPECT_STREQ(kStringValue, list_value->GetString(0).ToString().data());
}
// Test association of a CefValue list with a CefListValue.
TEST(ValuesTest, ValueListToList) {
// Create the list.
CefRefPtr<CefListValue> list_value = CreateListValue();
// Add the list to a value.
CefRefPtr<CefValue> value = CefValue::Create();
EXPECT_TRUE(value->SetList(list_value));
// Add the value to the target list.
CefRefPtr<CefListValue> target_list = CefListValue::Create();
EXPECT_TRUE(target_list->SetValue(0, value));
// The list value is now owned by the target list.
EXPECT_FALSE(list_value->IsValid());
// The value is still valid and points to the new reference list.
EXPECT_TRUE(value->IsValid());
CefRefPtr<CefListValue> list_value2 = value->GetList();
CefRefPtr<CefListValue> list_value3 = target_list->GetList(0);
CefRefPtr<CefValue> value2 = target_list->GetValue(0);
CefRefPtr<CefListValue> list_value4 = value2->GetList();
// All values are owned by the target list.
EXPECT_TRUE(value->IsOwned());
EXPECT_TRUE(value2->IsOwned());
EXPECT_TRUE(list_value2->IsOwned());
EXPECT_TRUE(list_value3->IsOwned());
EXPECT_TRUE(list_value4->IsOwned());
// All values are the same.
EXPECT_TRUE(list_value2->IsSame(list_value3));
TestListEqual(list_value2, list_value3);
EXPECT_TRUE(list_value2->IsSame(list_value4));
TestListEqual(list_value2, list_value4);
// Change the value to something else.
EXPECT_TRUE(target_list->SetInt(0, kIntValue));
EXPECT_EQ(VTYPE_INT, target_list->GetType(0));
EXPECT_EQ(kIntValue, target_list->GetInt(0));
// Now the references are invalid.
EXPECT_FALSE(value->IsValid());
EXPECT_FALSE(value2->IsValid());
EXPECT_FALSE(list_value2->IsValid());
EXPECT_FALSE(list_value3->IsValid());
EXPECT_FALSE(list_value4->IsValid());
// Verify that adding a list to a list directly invalidates both the list
// and the value that references it.
list_value = CreateListValue();
value = CefValue::Create();
EXPECT_TRUE(value->SetList(list_value));
target_list->SetList(0, list_value);
EXPECT_FALSE(list_value->IsValid());
EXPECT_FALSE(value->IsValid());
}
// Test association of a CefValue list with a CefDictionaryValue.
TEST(ValuesTest, ValueListToDictionary) {
const char* key = "key";
// Create the list.
CefRefPtr<CefListValue> list_value = CreateListValue();
// Add the list to a value.
CefRefPtr<CefValue> value = CefValue::Create();
EXPECT_TRUE(value->SetList(list_value));
// Add the value to the target dictionary.
CefRefPtr<CefDictionaryValue> target_dict = CefDictionaryValue::Create();
EXPECT_TRUE(target_dict->SetValue(key, value));
// The list value is now owned by the target dictionary.
EXPECT_FALSE(list_value->IsValid());
// The value is still valid and points to the new reference list.
EXPECT_TRUE(value->IsValid());
CefRefPtr<CefListValue> list_value2 = value->GetList();
CefRefPtr<CefListValue> list_value3 = target_dict->GetList(key);
CefRefPtr<CefValue> value2 = target_dict->GetValue(key);
CefRefPtr<CefListValue> list_value4 = value2->GetList();
// All values are owned by the target dictionary.
EXPECT_TRUE(value->IsOwned());
EXPECT_TRUE(value2->IsOwned());
EXPECT_TRUE(list_value2->IsOwned());
EXPECT_TRUE(list_value3->IsOwned());
EXPECT_TRUE(list_value4->IsOwned());
// All values are the same.
EXPECT_TRUE(list_value2->IsSame(list_value3));
TestListEqual(list_value2, list_value3);
EXPECT_TRUE(list_value2->IsSame(list_value4));
TestListEqual(list_value2, list_value4);
// Change the value to something else.
EXPECT_TRUE(target_dict->SetInt(key, kIntValue));
EXPECT_EQ(VTYPE_INT, target_dict->GetType(key));
EXPECT_EQ(kIntValue, target_dict->GetInt(key));
// Now the references are invalid.
EXPECT_FALSE(value->IsValid());
EXPECT_FALSE(value2->IsValid());
EXPECT_FALSE(list_value2->IsValid());
EXPECT_FALSE(list_value3->IsValid());
EXPECT_FALSE(list_value4->IsValid());
// Verify that adding a list to a dictionary directly invalidates both the
// list and the value that references it.
list_value = CreateListValue();
value = CefValue::Create();
EXPECT_TRUE(value->SetList(list_value));
target_dict->SetList(key, list_value);
EXPECT_FALSE(list_value->IsValid());
EXPECT_FALSE(value->IsValid());
}
// Test get/set of a CefValue dictionary type.
TEST(ValuesTest, ValueDictionary) {
// Create the dictionary.
CefRefPtr<CefDictionaryValue> dict_value = CreateDictionaryValue();
// Create the value.
CefRefPtr<CefValue> value = CefValue::Create();
EXPECT_TRUE(value->SetDictionary(dict_value));
EXPECT_EQ(VTYPE_DICTIONARY, value->GetType());
EXPECT_TRUE(value->IsValid());
EXPECT_FALSE(value->IsReadOnly());
EXPECT_FALSE(value->IsOwned());
CreateAndCompareCopy(value);
// Get the dictionary reference from the value.
CefRefPtr<CefDictionaryValue> dict_value2 = value->GetDictionary();
EXPECT_TRUE(dict_value2.get());
EXPECT_TRUE(dict_value2->IsValid());
EXPECT_FALSE(dict_value2->IsOwned());
EXPECT_FALSE(dict_value2->IsReadOnly());
// The dictionaries are the same and equal.
TestDictionaryEqual(dict_value, dict_value2);
EXPECT_TRUE(dict_value->IsSame(dict_value2));
EXPECT_TRUE(dict_value2->IsSame(dict_value));
// Change a value in one dictionary and verify that it's changed in the other
// dictionary.
EXPECT_TRUE(dict_value->SetString(kKey1, kStringValue));
EXPECT_EQ(VTYPE_STRING, dict_value->GetType(kKey1));
EXPECT_STREQ(kStringValue, dict_value->GetString(kKey1).ToString().data());
}
// Test association of a CefValue dictionary with a CefListValue.
TEST(ValuesTest, ValueDictionaryToList) {
// Create the dictionary.
CefRefPtr<CefDictionaryValue> dict_value = CreateDictionaryValue();
// Add the list to a value.
CefRefPtr<CefValue> value = CefValue::Create();
EXPECT_TRUE(value->SetDictionary(dict_value));
// Add the value to the target list.
CefRefPtr<CefListValue> target_list = CefListValue::Create();
EXPECT_TRUE(target_list->SetValue(0, value));
// The list value is now owned by the target list.
EXPECT_FALSE(dict_value->IsValid());
// The value is still valid and points to the new reference list.
EXPECT_TRUE(value->IsValid());
CefRefPtr<CefDictionaryValue> dict_value2 = value->GetDictionary();
CefRefPtr<CefDictionaryValue> dict_value3 = target_list->GetDictionary(0);
CefRefPtr<CefValue> value2 = target_list->GetValue(0);
CefRefPtr<CefDictionaryValue> dict_value4 = value2->GetDictionary();
// All values are owned by the target list.
EXPECT_TRUE(value->IsOwned());
EXPECT_TRUE(value2->IsOwned());
EXPECT_TRUE(dict_value2->IsOwned());
EXPECT_TRUE(dict_value3->IsOwned());
EXPECT_TRUE(dict_value4->IsOwned());
// All values are the same.
EXPECT_TRUE(dict_value2->IsSame(dict_value3));
TestDictionaryEqual(dict_value2, dict_value3);
EXPECT_TRUE(dict_value2->IsSame(dict_value4));
TestDictionaryEqual(dict_value2, dict_value4);
// Change the value to something else.
EXPECT_TRUE(target_list->SetInt(0, kIntValue));
EXPECT_EQ(VTYPE_INT, target_list->GetType(0));
EXPECT_EQ(kIntValue, target_list->GetInt(0));
// Now the references are invalid.
EXPECT_FALSE(value->IsValid());
EXPECT_FALSE(value2->IsValid());
EXPECT_FALSE(dict_value2->IsValid());
EXPECT_FALSE(dict_value3->IsValid());
EXPECT_FALSE(dict_value4->IsValid());
// Verify that adding a dictionary to a list directly invalidates both the
// dictionary and the value that references it.
dict_value = CreateDictionaryValue();
value = CefValue::Create();
EXPECT_TRUE(value->SetDictionary(dict_value));
target_list->SetDictionary(0, dict_value);
EXPECT_FALSE(dict_value->IsValid());
EXPECT_FALSE(value->IsValid());
}
// Test association of a CefValue dictionary with a CefDictionaryValue.
TEST(ValuesTest, ValueDictionaryToDictionary) {
const char* key = "key";
// Create the dictionary.
CefRefPtr<CefDictionaryValue> dict_value = CreateDictionaryValue();
// Add the list to a value.
CefRefPtr<CefValue> value = CefValue::Create();
EXPECT_TRUE(value->SetDictionary(dict_value));
// Add the value to the target dictionary.
CefRefPtr<CefDictionaryValue> target_dict = CefDictionaryValue::Create();
EXPECT_TRUE(target_dict->SetValue(key, value));
// The list value is now owned by the target dictionary.
EXPECT_FALSE(dict_value->IsValid());
// The value is still valid and points to the new reference list.
EXPECT_TRUE(value->IsValid());
CefRefPtr<CefDictionaryValue> dict_value2 = value->GetDictionary();
CefRefPtr<CefDictionaryValue> dict_value3 = target_dict->GetDictionary(key);
CefRefPtr<CefValue> value2 = target_dict->GetValue(key);
CefRefPtr<CefDictionaryValue> dict_value4 = value2->GetDictionary();
// All values are owned by the target dictionary.
EXPECT_TRUE(value->IsOwned());
EXPECT_TRUE(value2->IsOwned());
EXPECT_TRUE(dict_value2->IsOwned());
EXPECT_TRUE(dict_value3->IsOwned());
EXPECT_TRUE(dict_value4->IsOwned());
// All values are the same.
EXPECT_TRUE(dict_value2->IsSame(dict_value3));
TestDictionaryEqual(dict_value2, dict_value3);
EXPECT_TRUE(dict_value2->IsSame(dict_value4));
TestDictionaryEqual(dict_value2, dict_value4);
// Change the value to something else.
EXPECT_TRUE(target_dict->SetInt(key, kIntValue));
EXPECT_EQ(VTYPE_INT, target_dict->GetType(key));
EXPECT_EQ(kIntValue, target_dict->GetInt(key));
// Now the references are invalid.
EXPECT_FALSE(value->IsValid());
EXPECT_FALSE(value2->IsValid());
EXPECT_FALSE(dict_value2->IsValid());
EXPECT_FALSE(dict_value3->IsValid());
EXPECT_FALSE(dict_value4->IsValid());
// Verify that adding a dictionary to a dictionary directly invalidates both
// the dictionary and the value that references it.
dict_value = CreateDictionaryValue();
value = CefValue::Create();
EXPECT_TRUE(value->SetDictionary(dict_value));
target_dict->SetDictionary(key, dict_value);
EXPECT_FALSE(dict_value->IsValid());
EXPECT_FALSE(value->IsValid());
}