Add Date type support to CefV8Value (issue #190).

git-svn-id: https://chromiumembedded.googlecode.com/svn/trunk@242 5089003a-bbd8-11dd-ad1f-f1f9622dbc98
This commit is contained in:
Marshall Greenblatt 2011-05-23 17:43:53 +00:00
parent 26d7f043e2
commit 338b9c0cc9
16 changed files with 347 additions and 55 deletions

View File

@ -609,6 +609,7 @@
'include/internal/cef_string_map.h',
'include/internal/cef_string_types.h',
'include/internal/cef_string_wrappers.h',
'include/internal/cef_time.h',
'include/internal/cef_types.h',
'include/internal/cef_types_wrappers.h',
'libcef/browser_appcache_system.cc',
@ -670,6 +671,8 @@
'libcef/cef_string_types.cc',
'libcef/cef_thread.cc',
'libcef/cef_thread.h',
'libcef/cef_time.cc',
'libcef/cef_time_util.h',
'libcef/drag_download_file.cc',
'libcef/drag_download_file.h',
'libcef/dom_storage_area.cc',

View File

@ -1591,6 +1591,8 @@ public:
/*--cef()--*/
static CefRefPtr<CefV8Value> CreateDouble(double value);
/*--cef()--*/
static CefRefPtr<CefV8Value> CreateDate(const CefTime& date);
/*--cef()--*/
static CefRefPtr<CefV8Value> CreateString(const CefString& value);
/*--cef()--*/
static CefRefPtr<CefV8Value> CreateObject(CefRefPtr<CefBase> user_data);
@ -1615,6 +1617,8 @@ public:
/*--cef()--*/
virtual bool IsDouble() =0;
/*--cef()--*/
virtual bool IsDate() =0;
/*--cef()--*/
virtual bool IsString() =0;
/*--cef()--*/
virtual bool IsObject() =0;
@ -1637,6 +1641,8 @@ public:
/*--cef()--*/
virtual double GetDoubleValue() =0;
/*--cef()--*/
virtual CefTime GetDateValue() =0;
/*--cef()--*/
virtual CefString GetStringValue() =0;

View File

@ -1407,6 +1407,7 @@ typedef struct _cef_v8value_t
int (CEF_CALLBACK *is_bool)(struct _cef_v8value_t* self);
int (CEF_CALLBACK *is_int)(struct _cef_v8value_t* self);
int (CEF_CALLBACK *is_double)(struct _cef_v8value_t* self);
int (CEF_CALLBACK *is_date)(struct _cef_v8value_t* self);
int (CEF_CALLBACK *is_string)(struct _cef_v8value_t* self);
int (CEF_CALLBACK *is_object)(struct _cef_v8value_t* self);
int (CEF_CALLBACK *is_array)(struct _cef_v8value_t* self);
@ -1422,6 +1423,7 @@ typedef struct _cef_v8value_t
int (CEF_CALLBACK *get_bool_value)(struct _cef_v8value_t* self);
int (CEF_CALLBACK *get_int_value)(struct _cef_v8value_t* self);
double (CEF_CALLBACK *get_double_value)(struct _cef_v8value_t* self);
cef_time_t (CEF_CALLBACK *get_date_value)(struct _cef_v8value_t* self);
// The resulting string must be freed by calling cef_string_userfree_free().
cef_string_userfree_t (CEF_CALLBACK *get_string_value)(
struct _cef_v8value_t* self);
@ -1510,6 +1512,7 @@ CEF_EXPORT cef_v8value_t* cef_v8value_create_null();
CEF_EXPORT cef_v8value_t* cef_v8value_create_bool(int value);
CEF_EXPORT cef_v8value_t* cef_v8value_create_int(int value);
CEF_EXPORT cef_v8value_t* cef_v8value_create_double(double value);
CEF_EXPORT cef_v8value_t* cef_v8value_create_date(const cef_time_t* date);
CEF_EXPORT cef_v8value_t* cef_v8value_create_string(const cef_string_t* value);
CEF_EXPORT cef_v8value_t* cef_v8value_create_object(cef_base_t* user_data);
CEF_EXPORT cef_v8value_t* cef_v8value_create_object_with_accessor(

View File

@ -0,0 +1,70 @@
// Copyright (c) 2011 Marshall A. Greenblatt. All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
// * Neither the name of Google Inc. nor the name Chromium Embedded
// Framework nor the names of its contributors may be used to endorse
// or promote products derived from this software without specific prior
// written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#ifndef _CEF_TIME_H
#define _CEF_TIME_H
#ifdef __cplusplus
extern "C" {
#endif
#include "cef_export.h"
#include <time.h>
// Time information. Values should always be in UTC.
typedef struct _cef_time_t
{
int year; // Four digit year "2007"
int month; // 1-based month (values 1 = January, etc.)
int day_of_week; // 0-based day of week (0 = Sunday, etc.)
int day_of_month; // 1-based day of month (1-31)
int hour; // Hour within the current day (0-23)
int minute; // Minute within the current hour (0-59)
int second; // Second within the current minute (0-59 plus leap
// seconds which may take it up to 60).
int millisecond; // Milliseconds within the current second (0-999)
} cef_time_t;
// Converts cef_time_t to/from time_t. Returns true (1) on success and false (0)
// on failure.
CEF_EXPORT int cef_time_to_timet(const cef_time_t* cef_time, time_t* time);
CEF_EXPORT int cef_time_from_timet(time_t time, cef_time_t* cef_time);
// Converts cef_time_t to/from a double which is the number of seconds since
// epoch (Jan 1, 1970). Webkit uses this format to represent time. A value of 0
// means "not initialized". Returns true (1) on success and false (0) on
// failure.
CEF_EXPORT int cef_time_to_doublet(const cef_time_t* cef_time, double* time);
CEF_EXPORT int cef_time_from_doublet(double time, cef_time_t* cef_time);
#ifdef __cplusplus
}
#endif
#endif // _CEF_TIME_H

View File

@ -34,6 +34,7 @@
#include "cef_build.h"
#include "cef_string.h"
#include "cef_string_list.h"
#include "cef_time.h"
// Bring in platform-specific definitions.
#if defined(OS_WIN)
@ -271,20 +272,6 @@ typedef struct _cef_urlparts_t
cef_string_t query;
} cef_urlparts_t;
// Time information. Values should always be in UTC.
typedef struct _cef_time_t
{
int year; // Four digit year "2007"
int month; // 1-based month (values 1 = January, etc.)
int day_of_week; // 0-based day of week (0 = Sunday, etc.)
int day_of_month; // 1-based day of month (1-31)
int hour; // Hour within the current day (0-23)
int minute; // Minute within the current hour (0-59)
int second; // Second within the current minute (0-59 plus leap
// seconds which may take it up to 60).
int millisecond; // Milliseconds within the current second (0-999)
} cef_time_t;
// Cookie information.
typedef struct _cef_cookie_t
{

View File

@ -142,10 +142,7 @@ struct CefRectTraits {
static inline void set(const struct_type* src, struct_type* target, bool copy)
{
target->x = src->x;
target->y = src->y;
target->width = src->width;
target->height = src->height;
*target = *src;
}
};
@ -410,6 +407,54 @@ struct CefURLPartsTraits {
typedef CefStructBase<CefURLPartsTraits> CefURLParts;
struct CefTimeTraits {
typedef cef_time_t struct_type;
static inline void init(struct_type* s) {}
static inline void clear(struct_type* s) {}
static inline void set(const struct_type* src, struct_type* target, bool copy)
{
*target = *src;
}
};
// Class representing a time.
class CefTime : public CefStructBase<CefTimeTraits>
{
public:
typedef CefStructBase<CefTimeTraits> parent;
CefTime() : parent() {}
CefTime(const cef_time_t& r) : parent(r) {}
CefTime(time_t r) : parent() { SetTimeT(r); }
CefTime(double r) : parent() { SetDoubleT(r); }
// Converts to/from time_t.
void SetTimeT(time_t r) {
cef_time_from_timet(r, this);
}
time_t GetTimeT() const {
time_t time = 0;
cef_time_to_timet(this, &time);
return time;
}
// Converts to/from a double which is the number of seconds since epoch
// (Jan 1, 1970). Webkit uses this format to represent time. A value of 0
// means "not initialized".
void SetDoubleT(double r) {
cef_time_from_doublet(r, this);
}
double GetDoubleT() const {
double time = 0;
cef_time_to_doublet(this, &time);
return time;
}
};
struct CefCookieTraits {
typedef cef_cookie_t struct_type;

View File

@ -6,6 +6,7 @@
#include "browser_impl.h"
#include "browser_webkit_glue.h"
#include "cef_thread.h"
#include "cef_time_util.h"
#include "cef_process.h"
#include "../include/cef_nplugin.h"
@ -63,34 +64,6 @@ int GetThreadId(CefThreadId threadId)
return -1;
}
void SetCefTime(cef_time_t& cef_time, const base::Time& base_time)
{
base::Time::Exploded exploded;
base_time.UTCExplode(&exploded);
cef_time.year = exploded.year;
cef_time.month = exploded.month;
cef_time.day_of_week = exploded.day_of_week;
cef_time.day_of_month = exploded.day_of_month;
cef_time.hour = exploded.hour;
cef_time.minute = exploded.minute;
cef_time.second = exploded.second;
cef_time.millisecond = exploded.millisecond;
}
void SetBaseTime(base::Time& base_time, const cef_time_t& cef_time)
{
base::Time::Exploded exploded;
exploded.year = cef_time.year;
exploded.month = cef_time.month;
exploded.day_of_week = cef_time.day_of_week;
exploded.day_of_month = cef_time.day_of_month;
exploded.hour = cef_time.hour;
exploded.minute = cef_time.minute;
exploded.second = cef_time.second;
exploded.millisecond = cef_time.millisecond;
base_time = base::Time::FromUTCExploded(exploded);
}
void IOT_VisitCookies(net::CookieMonster* cookie_monster,
const net::CookieList& list,
CefRefPtr<CefCookieVisitor> visitor)
@ -108,11 +81,11 @@ void IOT_VisitCookies(net::CookieMonster* cookie_monster,
CefString(&cookie.path).FromString(cc.Path());
cookie.secure = cc.IsSecure();
cookie.httponly = cc.IsHttpOnly();
SetCefTime(cookie.creation, cc.CreationDate());
SetCefTime(cookie.last_access, cc.LastAccessDate());
cef_time_from_basetime(cc.CreationDate(), cookie.creation);
cef_time_from_basetime(cc.LastAccessDate(), cookie.last_access);
cookie.has_expires = cc.DoesExpire();
if (cookie.has_expires)
SetCefTime(cookie.expires, cc.ExpiryDate());
cef_time_from_basetime(cc.ExpiryDate(), cookie.expires);
bool deleteCookie = false;
bool keepLooping = visitor->Visit(cookie, count, total, deleteCookie);
@ -411,7 +384,7 @@ bool CefSetCookie(const CefString& url, const CefCookie& cookie)
base::Time expiration_time;
if (cookie.has_expires)
SetBaseTime(expiration_time, cookie.expires);
cef_time_to_basetime(cookie.expires, expiration_time);
return cookie_monster->SetCookieWithDetails(gurl, name, value, domain, path,
expiration_time, cookie.secure,

75
libcef/cef_time.cc Normal file
View File

@ -0,0 +1,75 @@
// Copyright (c) 2011 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.
#include "cef_time_util.h"
void cef_time_to_basetime(const cef_time_t& cef_time, base::Time& time)
{
base::Time::Exploded exploded;
exploded.year = cef_time.year;
exploded.month = cef_time.month;
exploded.day_of_week = cef_time.day_of_week;
exploded.day_of_month = cef_time.day_of_month;
exploded.hour = cef_time.hour;
exploded.minute = cef_time.minute;
exploded.second = cef_time.second;
exploded.millisecond = cef_time.millisecond;
time = base::Time::FromUTCExploded(exploded);
}
void cef_time_from_basetime(const base::Time& time, cef_time_t& cef_time)
{
base::Time::Exploded exploded;
time.UTCExplode(&exploded);
cef_time.year = exploded.year;
cef_time.month = exploded.month;
cef_time.day_of_week = exploded.day_of_week;
cef_time.day_of_month = exploded.day_of_month;
cef_time.hour = exploded.hour;
cef_time.minute = exploded.minute;
cef_time.second = exploded.second;
cef_time.millisecond = exploded.millisecond;
}
CEF_EXPORT int cef_time_to_timet(const cef_time_t* cef_time, time_t* time)
{
if (!cef_time || !time)
return 0;
base::Time base_time;
cef_time_to_basetime(*cef_time, base_time);
*time = base_time.ToTimeT();
return 1;
}
CEF_EXPORT int cef_time_from_timet(time_t time, cef_time_t* cef_time)
{
if (!cef_time)
return 0;
base::Time base_time = base::Time::FromTimeT(time);
cef_time_from_basetime(base_time, *cef_time);
return 1;
}
CEF_EXPORT int cef_time_to_doublet(const cef_time_t* cef_time, double* time)
{
if (!cef_time || !time)
return 0;
base::Time base_time;
cef_time_to_basetime(*cef_time, base_time);
*time = base_time.ToDoubleT();
return 1;
}
CEF_EXPORT int cef_time_from_doublet(double time, cef_time_t* cef_time)
{
if (!cef_time)
return 0;
base::Time base_time = base::Time::FromDoubleT(time);
cef_time_from_basetime(base_time, *cef_time);
return 1;
}

15
libcef/cef_time_util.h Normal file
View File

@ -0,0 +1,15 @@
// Copyright (c) 2011 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.
#ifndef _CEF_TIME_UTIL_H
#define _CEF_TIME_UTIL_H
#include "include/internal/cef_time.h"
#include "base/time.h"
// Converts cef_time_t to/from a base::Time object.
void cef_time_to_basetime(const cef_time_t& cef_time, base::Time& time);
void cef_time_from_basetime(const base::Time& time, cef_time_t& cef_time);
#endif // _CEF_TIME_UTIL_H

View File

@ -433,6 +433,16 @@ CefRefPtr<CefV8Value> CefV8Value::CreateDouble(double value)
return new CefV8ValueImpl(v8::Number::New(value));
}
// static
CefRefPtr<CefV8Value> CefV8Value::CreateDate(const CefTime& date)
{
CEF_REQUIRE_VALID_CONTEXT(NULL);
CEF_REQUIRE_UI_THREAD(NULL);
v8::HandleScope handle_scope;
// Convert from seconds to milliseconds.
return new CefV8ValueImpl(v8::Date::New(date.GetDoubleT() * 1000));
}
// static
CefRefPtr<CefV8Value> CefV8Value::CreateString(const CefString& value)
{
@ -566,7 +576,13 @@ bool CefV8ValueImpl::IsInt()
bool CefV8ValueImpl::IsDouble()
{
CEF_REQUIRE_UI_THREAD(false);
return (GetHandle()->IsNumber() || GetHandle()->IsDate());
return GetHandle()->IsNumber();
}
bool CefV8ValueImpl::IsDate()
{
CEF_REQUIRE_UI_THREAD(false);
return GetHandle()->IsDate();
}
bool CefV8ValueImpl::IsString()
@ -639,6 +655,15 @@ double CefV8ValueImpl::GetDoubleValue()
return val->Value();
}
CefTime CefV8ValueImpl::GetDateValue()
{
CEF_REQUIRE_UI_THREAD(0.);
v8::HandleScope handle_scope;
v8::Local<v8::Number> val = GetHandle()->ToNumber();
// Convert from milliseconds to seconds.
return CefTime(val->Value() / 1000);
}
CefString CefV8ValueImpl::GetStringValue()
{
CefString rv;

View File

@ -114,6 +114,7 @@ public:
virtual bool IsBool() OVERRIDE;
virtual bool IsInt() OVERRIDE;
virtual bool IsDouble() OVERRIDE;
virtual bool IsDate() OVERRIDE;
virtual bool IsString() OVERRIDE;
virtual bool IsObject() OVERRIDE;
virtual bool IsArray() OVERRIDE;
@ -122,6 +123,7 @@ public:
virtual bool GetBoolValue() OVERRIDE;
virtual int GetIntValue() OVERRIDE;
virtual double GetDoubleValue() OVERRIDE;
virtual CefTime GetDateValue() OVERRIDE;
virtual CefString GetStringValue() OVERRIDE;
virtual bool HasValue(const CefString& key) OVERRIDE;
virtual bool HasValue(int index) OVERRIDE;

View File

@ -59,6 +59,18 @@ CEF_EXPORT cef_v8value_t* cef_v8value_create_double(double value)
return NULL;
}
CEF_EXPORT cef_v8value_t* cef_v8value_create_date(const cef_time_t* date)
{
DCHECK(date);
if (!date)
return NULL;
CefRefPtr<CefV8Value> impl = CefV8Value::CreateDate(*date);
if(impl.get())
return CefV8ValueCppToC::Wrap(impl);
return NULL;
}
CEF_EXPORT cef_v8value_t* cef_v8value_create_string(const cef_string_t* value)
{
CefRefPtr<CefV8Value> impl = CefV8Value::CreateString(CefString(value));
@ -166,6 +178,15 @@ int CEF_CALLBACK v8value_is_double(struct _cef_v8value_t* self)
return CefV8ValueCppToC::Get(self)->IsDouble();
}
int CEF_CALLBACK v8value_is_date(struct _cef_v8value_t* self)
{
DCHECK(self);
if (!self)
return 0;
return CefV8ValueCppToC::Get(self)->IsDate();
}
int CEF_CALLBACK v8value_is_string(struct _cef_v8value_t* self)
{
DCHECK(self);
@ -240,6 +261,15 @@ double CEF_CALLBACK v8value_get_double_value(struct _cef_v8value_t* self)
return CefV8ValueCppToC::Get(self)->GetDoubleValue();
}
cef_time_t CEF_CALLBACK v8value_get_date_value(struct _cef_v8value_t* self)
{
DCHECK(self);
if (!self)
return cef_time_t();
return CefV8ValueCppToC::Get(self)->GetDateValue();
}
cef_string_userfree_t CEF_CALLBACK v8value_get_string_value(
struct _cef_v8value_t* self)
{
@ -479,6 +509,7 @@ CefV8ValueCppToC::CefV8ValueCppToC(CefV8Value* cls)
struct_.struct_.is_bool = v8value_is_bool;
struct_.struct_.is_int = v8value_is_int;
struct_.struct_.is_double = v8value_is_double;
struct_.struct_.is_date = v8value_is_date;
struct_.struct_.is_string = v8value_is_string;
struct_.struct_.is_object = v8value_is_object;
struct_.struct_.is_array = v8value_is_array;
@ -487,6 +518,7 @@ CefV8ValueCppToC::CefV8ValueCppToC(CefV8Value* cls)
struct_.struct_.get_bool_value = v8value_get_bool_value;
struct_.struct_.get_int_value = v8value_get_int_value;
struct_.struct_.get_double_value = v8value_get_double_value;
struct_.struct_.get_date_value = v8value_get_date_value;
struct_.struct_.get_string_value = v8value_get_string_value;
struct_.struct_.has_value_bykey = v8value_has_value_bykey;
struct_.struct_.has_value_byindex = v8value_has_value_byindex;

View File

@ -60,6 +60,14 @@ CefRefPtr<CefV8Value> CefV8Value::CreateDouble(double value)
return NULL;
}
CefRefPtr<CefV8Value> CefV8Value::CreateDate(const CefTime& date)
{
cef_v8value_t* impl = cef_v8value_create_date(&date);
if(impl)
return CefV8ValueCToCpp::Wrap(impl);
return NULL;
}
CefRefPtr<CefV8Value> CefV8Value::CreateString(const CefString& value)
{
cef_v8value_t* impl = cef_v8value_create_string(value.GetStruct());
@ -163,6 +171,14 @@ bool CefV8ValueCToCpp::IsDouble()
return struct_->is_double(struct_)?true:false;
}
bool CefV8ValueCToCpp::IsDate()
{
if (CEF_MEMBER_MISSING(struct_, is_date))
return false;
return struct_->is_date(struct_)?true:false;
}
bool CefV8ValueCToCpp::IsString()
{
if(CEF_MEMBER_MISSING(struct_, is_string))
@ -227,6 +243,14 @@ double CefV8ValueCToCpp::GetDoubleValue()
return struct_->get_double_value(struct_);
}
CefTime CefV8ValueCToCpp::GetDateValue()
{
if (CEF_MEMBER_MISSING(struct_, get_date_value))
return CefTime();
return struct_->get_date_value(struct_);
}
CefString CefV8ValueCToCpp::GetStringValue()
{
CefString str;

View File

@ -36,6 +36,7 @@ public:
virtual bool IsBool() OVERRIDE;
virtual bool IsInt() OVERRIDE;
virtual bool IsDouble() OVERRIDE;
virtual bool IsDate() OVERRIDE;
virtual bool IsString() OVERRIDE;
virtual bool IsObject() OVERRIDE;
virtual bool IsArray() OVERRIDE;
@ -44,6 +45,7 @@ public:
virtual bool GetBoolValue() OVERRIDE;
virtual int GetIntValue() OVERRIDE;
virtual double GetDoubleValue() OVERRIDE;
virtual CefTime GetDateValue() OVERRIDE;
virtual CefString GetStringValue() OVERRIDE;
virtual bool HasValue(const CefString& key) OVERRIDE;
virtual bool HasValue(int index) OVERRIDE;

View File

@ -36,7 +36,7 @@ public:
if(name == "execute") {
g_V8TestV8HandlerExecuteCalled = true;
ASSERT_EQ((size_t)8, arguments.size());
ASSERT_EQ((size_t)9, arguments.size());
int argct = 0;
// basic types
@ -52,6 +52,18 @@ public:
ASSERT_EQ(true, arguments[argct]->GetBoolValue());
argct++;
ASSERT_TRUE(arguments[argct]->IsDate());
CefTime date = arguments[argct]->GetDateValue();
ASSERT_EQ(date.year, 2010);
ASSERT_EQ(date.month, 5);
ASSERT_EQ(date.day_of_month, 3);
ASSERT_EQ(date.day_of_week, 1);
ASSERT_EQ(date.hour, 12);
ASSERT_EQ(date.minute, 30);
ASSERT_EQ(date.second, 10);
ASSERT_EQ(date.millisecond, 100);
argct++;
ASSERT_TRUE(arguments[argct]->IsString());
ASSERT_EQ(arguments[argct]->GetStringValue(), "test string");
argct++;
@ -169,6 +181,19 @@ public:
ASSERT_TRUE(value->IsString());
ASSERT_EQ(value->GetStringValue(), "the string");
value = object->GetValue("dateVal");
ASSERT_TRUE(value.get() != NULL);
ASSERT_TRUE(value->IsDate());
CefTime date = value->GetDateValue();
ASSERT_EQ(date.year, 2010);
ASSERT_EQ(date.month, 5);
ASSERT_EQ(date.day_of_week, 1);
ASSERT_EQ(date.day_of_month, 3);
ASSERT_EQ(date.hour, 12);
ASSERT_EQ(date.minute, 30);
ASSERT_EQ(date.second, 10);
ASSERT_EQ(date.millisecond, 100);
value = object->GetValue("arrayVal");
ASSERT_TRUE(value.get() != NULL);
ASSERT_TRUE(value->IsArray());
@ -240,7 +265,8 @@ public:
"function func(a,b,c,d) { return a+b+(c?1:0)+parseFloat(d); }"
"function func2(a,b) { throw('My Exception'); }"
<< object << ".execute2("
" " << object << ".execute(5, 6.543, true, \"test string\","
" " << object << ".execute(5, 6.543, true,"
" new Date(Date.UTC(2010, 4, 3, 12, 30, 10, 100)), \"test string\","
" [7, 5.432, false, \"another string\"],"
" {arg0:2, arg1:3.433, arg2:true, arg3:\"some string\"}, func, func2)"
");"
@ -299,6 +325,9 @@ public:
ASSERT_TRUE(testObj->SetValue("stringVal",
CefV8Value::CreateString("the string")));
cef_time_t date = {2010, 5, 1, 3, 12, 30, 10, 100};
ASSERT_TRUE(testObj->SetValue("dateVal", CefV8Value::CreateDate(date)));
CefRefPtr<CefV8Value> testArray(CefV8Value::CreateArray());
ASSERT_TRUE(testArray.get() != NULL);
ASSERT_TRUE(testObj->SetValue("arrayVal", testArray));
@ -337,9 +366,9 @@ TEST(V8Test, Extension)
"if (!test)"
" test = {};"
"(function() {"
" test.execute = function(a,b,c,d,e,f,g,h) {"
" test.execute = function(a,b,c,d,e,f,g,h,i) {"
" native function execute();"
" return execute(a,b,c,d,e,f,g,h);"
" return execute(a,b,c,d,e,f,g,h,i);"
" };"
" test.execute2 = function(a) {"
" native function execute2();"

View File

@ -1070,6 +1070,7 @@ class obj_analysis:
'CefWindowHandle' : 'cef_window_handle_t',
'CefRect' : 'cef_rect_t',
'CefThreadId' : 'cef_thread_id_t',
'CefTime' : 'cef_time_t',
}
if value in simpletypes.keys():
return {