- Add support for entering a V8 context asynchronously (issue #203).

- Add support for V8 accessors (issue #203).

git-svn-id: https://chromiumembedded.googlecode.com/svn/trunk@215 5089003a-bbd8-11dd-ad1f-f1f9622dbc98
This commit is contained in:
Marshall Greenblatt
2011-04-07 01:58:49 +00:00
parent 36f3f3d021
commit 7ec29b5d87
19 changed files with 772 additions and 17 deletions

View File

@ -0,0 +1,77 @@
// Copyright (c) 2010 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.
//
// ---------------------------------------------------------------------------
//
// A portion of this file was generated by the CEF translator tool. When
// making changes by hand only do so within the body of existing function
// implementations. See the translator.README.txt file in the tools directory
// for more information.
//
#include "libcef_dll/cpptoc/v8accessor_cpptoc.h"
#include "libcef_dll/ctocpp/v8value_ctocpp.h"
// MEMBER FUNCTIONS - Body may be edited by hand.
int CEF_CALLBACK v8accessor_get(struct _cef_v8accessor_t* self,
const cef_string_t* name, struct _cef_v8value_t* object,
struct _cef_v8value_t** retval)
{
DCHECK(self);
if(!self)
return 0;
CefRefPtr<CefV8Value> objectPtr;
if(object)
objectPtr = CefV8ValueCToCpp::Wrap(object);
CefRefPtr<CefV8Value> retValPtr;
bool rv = CefV8AccessorCppToC::Get(self)->Get(CefString(name), objectPtr,
retValPtr);
if(rv) {
if(retValPtr.get() && retval)
*retval = CefV8ValueCToCpp::Unwrap(retValPtr);
}
return rv;
}
int CEF_CALLBACK v8accessor_set(struct _cef_v8accessor_t* self,
const cef_string_t* name, struct _cef_v8value_t* object,
struct _cef_v8value_t* value)
{
DCHECK(self);
if(!self)
return 0;
CefRefPtr<CefV8Value> objectPtr;
if(object)
objectPtr = CefV8ValueCToCpp::Wrap(object);
CefRefPtr<CefV8Value> valuePtr;
if(value)
valuePtr = CefV8ValueCToCpp::Wrap(value);
bool rv = CefV8AccessorCppToC::Get(self)->Set(CefString(name), objectPtr,
valuePtr);
return rv;
}
// CONSTRUCTOR - Do not edit by hand.
CefV8AccessorCppToC::CefV8AccessorCppToC(CefV8Accessor* cls)
: CefCppToC<CefV8AccessorCppToC, CefV8Accessor, cef_v8accessor_t>(cls)
{
struct_.struct_.get = v8accessor_get;
struct_.struct_.set = v8accessor_set;
}
#ifdef _DEBUG
template<> long CefCppToC<CefV8AccessorCppToC, CefV8Accessor,
cef_v8accessor_t>::DebugObjCt = 0;
#endif

View File

@ -0,0 +1,34 @@
// Copyright (c) 2010 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 and should not edited
// by hand. See the translator.README.txt file in the tools directory for
// more information.
//
#ifndef _V8ACCESSOR_CPPTOC_H
#define _V8ACCESSOR_CPPTOC_H
#ifndef USING_CEF_SHARED
#pragma message("Warning: "__FILE__" may be accessed wrapper-side only")
#else // USING_CEF_SHARED
#include "include/cef.h"
#include "include/cef_capi.h"
#include "libcef_dll/cpptoc/cpptoc.h"
// Wrap a C++ class with a C structure.
// This class may be instantiated and accessed wrapper-side only.
class CefV8AccessorCppToC
: public CefCppToC<CefV8AccessorCppToC, CefV8Accessor, cef_v8accessor_t>
{
public:
CefV8AccessorCppToC(CefV8Accessor* cls);
virtual ~CefV8AccessorCppToC() {}
};
#endif // USING_CEF_SHARED
#endif // _V8ACCESSOR_CPPTOC_H

View File

@ -79,6 +79,26 @@ struct _cef_v8value_t* CEF_CALLBACK v8context_get_global(
return NULL;
}
int CEF_CALLBACK v8context_enter(struct _cef_v8context_t* self)
{
DCHECK(self);
if(!self)
return false;
CefRefPtr<CefV8Context> contextPtr = CefV8ContextCppToC::Get(self);
return contextPtr->Enter();
}
int CEF_CALLBACK v8context_exit(struct _cef_v8context_t* self)
{
DCHECK(self);
if(!self)
return false;
CefRefPtr<CefV8Context> contextPtr = CefV8ContextCppToC::Get(self);
return contextPtr->Exit();
}
// CONSTRUCTOR - Do not edit by hand.
@ -88,6 +108,8 @@ CefV8ContextCppToC::CefV8ContextCppToC(CefV8Context* cls)
struct_.struct_.get_browser = v8context_get_browser;
struct_.struct_.get_frame = v8context_get_frame;
struct_.struct_.get_global = v8context_get_global;
struct_.struct_.enter = v8context_enter;
struct_.struct_.exit = v8context_exit;
}
#ifdef _DEBUG

View File

@ -13,6 +13,7 @@
#include "libcef_dll/cpptoc/v8context_cpptoc.h"
#include "libcef_dll/cpptoc/v8value_cpptoc.h"
#include "libcef_dll/ctocpp/base_ctocpp.h"
#include "libcef_dll/ctocpp/v8accessor_ctocpp.h"
#include "libcef_dll/ctocpp/v8handler_ctocpp.h"
@ -78,6 +79,23 @@ CEF_EXPORT cef_v8value_t* cef_v8value_create_object(cef_base_t* user_data)
return NULL;
}
CEF_EXPORT cef_v8value_t* cef_v8value_create_object_with_accessor(
cef_base_t* user_data, cef_v8accessor_t* accessor)
{
CefRefPtr<CefBase> basePtr;
if(user_data)
basePtr = CefBaseCToCpp::Wrap(user_data);
CefRefPtr<CefV8Accessor> accessorPtr;
if(accessor)
accessorPtr = CefV8AccessorCToCpp::Wrap(accessor);
CefRefPtr<CefV8Value> impl = CefV8Value::CreateObject(basePtr, accessorPtr);
if(impl.get())
return CefV8ValueCppToC::Wrap(impl);
return NULL;
}
CEF_EXPORT cef_v8value_t* cef_v8value_create_array()
{
CefRefPtr<CefV8Value> impl = CefV8Value::CreateArray();
@ -184,6 +202,17 @@ int CEF_CALLBACK v8value_is_function(struct _cef_v8value_t* self)
return CefV8ValueCppToC::Get(self)->IsFunction();
}
int CEF_CALLBACK v8value_is_same(struct _cef_v8value_t* self,
struct _cef_v8value_t* that)
{
DCHECK(self);
if(!self)
return 0;
CefRefPtr<CefV8Value> thatPtr = CefV8ValueCppToC::Unwrap(that);
return CefV8ValueCppToC::Get(self)->IsSame(thatPtr);
}
int CEF_CALLBACK v8value_get_bool_value(struct _cef_v8value_t* self)
{
DCHECK(self);
@ -308,6 +337,18 @@ int CEF_CALLBACK v8value_set_value_byindex(struct _cef_v8value_t* self,
return CefV8ValueCppToC::Get(self)->SetValue(index, valuePtr);
}
int CEF_CALLBACK v8value_set_value_byaccessor(struct _cef_v8value_t* self,
const cef_string_t* key, enum cef_v8_accesscontrol_t settings,
enum cef_v8_propertyattribute_t attribute)
{
DCHECK(self);
if(!self)
return 0;
return CefV8ValueCppToC::Get(self)->SetValue(CefString(key),
settings, attribute);
}
int CEF_CALLBACK v8value_get_keys(struct _cef_v8value_t* self,
cef_string_list_t keys)
{
@ -442,6 +483,7 @@ CefV8ValueCppToC::CefV8ValueCppToC(CefV8Value* cls)
struct_.struct_.is_object = v8value_is_object;
struct_.struct_.is_array = v8value_is_array;
struct_.struct_.is_function = v8value_is_function;
struct_.struct_.is_same = v8value_is_same;
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;
@ -454,6 +496,7 @@ CefV8ValueCppToC::CefV8ValueCppToC(CefV8Value* cls)
struct_.struct_.get_value_byindex = v8value_get_value_byindex;
struct_.struct_.set_value_bykey = v8value_set_value_bykey;
struct_.struct_.set_value_byindex = v8value_set_value_byindex;
struct_.struct_.set_value_byaccessor = v8value_set_value_byaccessor;
struct_.struct_.get_keys = v8value_get_keys;
struct_.struct_.get_user_data = v8value_get_user_data;
struct_.struct_.get_array_length = v8value_get_array_length;