mirror of
https://bitbucket.org/chromiumembedded/cef
synced 2025-06-05 21:39:12 +02:00
- 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:
53
libcef_dll/ctocpp/v8accessor_ctocpp.cc
Normal file
53
libcef_dll/ctocpp/v8accessor_ctocpp.cc
Normal file
@@ -0,0 +1,53 @@
|
||||
// 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 static and
|
||||
// virtual method implementations. See the translator.README.txt file in the
|
||||
// tools directory for more information.
|
||||
//
|
||||
|
||||
#include "libcef_dll/cpptoc/v8value_cpptoc.h"
|
||||
#include "libcef_dll/ctocpp/v8accessor_ctocpp.h"
|
||||
|
||||
|
||||
// VIRTUAL METHODS - Body may be edited by hand.
|
||||
|
||||
bool CefV8AccessorCToCpp::Get(const CefString& name,
|
||||
const CefRefPtr<CefV8Value> object, CefRefPtr<CefV8Value>& retval)
|
||||
{
|
||||
if(CEF_MEMBER_MISSING(struct_, get))
|
||||
return false;
|
||||
|
||||
cef_v8value_t* retvalStruct = NULL;
|
||||
|
||||
int rv = struct_->get(struct_, name.GetStruct(),
|
||||
CefV8ValueCppToC::Wrap(object), &retvalStruct);
|
||||
if(retvalStruct)
|
||||
retval = CefV8ValueCppToC::Unwrap(retvalStruct);
|
||||
|
||||
return rv ? true : false;
|
||||
}
|
||||
|
||||
bool CefV8AccessorCToCpp::Set(const CefString& name,
|
||||
const CefRefPtr<CefV8Value> object, const CefRefPtr<CefV8Value> value)
|
||||
{
|
||||
if(CEF_MEMBER_MISSING(struct_, set))
|
||||
return false;
|
||||
|
||||
int rv = struct_->set(struct_, name.GetStruct(),
|
||||
CefV8ValueCppToC::Wrap(object),
|
||||
CefV8ValueCppToC::Wrap(value));
|
||||
|
||||
return rv ? true : false;
|
||||
}
|
||||
|
||||
|
||||
#ifdef _DEBUG
|
||||
template<> long CefCToCpp<CefV8AccessorCToCpp, CefV8Accessor,
|
||||
cef_v8accessor_t>::DebugObjCt = 0;
|
||||
#endif
|
||||
|
42
libcef_dll/ctocpp/v8accessor_ctocpp.h
Normal file
42
libcef_dll/ctocpp/v8accessor_ctocpp.h
Normal file
@@ -0,0 +1,42 @@
|
||||
// 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_CTOCPP_H
|
||||
#define _V8ACCESSOR_CTOCPP_H
|
||||
|
||||
#ifndef BUILDING_CEF_SHARED
|
||||
#pragma message("Warning: "__FILE__" may be accessed DLL-side only")
|
||||
#else // BUILDING_CEF_SHARED
|
||||
|
||||
#include "include/cef.h"
|
||||
#include "include/cef_capi.h"
|
||||
#include "libcef_dll/ctocpp/ctocpp.h"
|
||||
|
||||
// Wrap a C structure with a C++ class.
|
||||
// This class may be instantiated and accessed DLL-side only.
|
||||
class CefV8AccessorCToCpp
|
||||
: public CefCToCpp<CefV8AccessorCToCpp, CefV8Accessor, cef_v8accessor_t>
|
||||
{
|
||||
public:
|
||||
CefV8AccessorCToCpp(cef_v8accessor_t* str)
|
||||
: CefCToCpp<CefV8AccessorCToCpp, CefV8Accessor, cef_v8accessor_t>(str) {}
|
||||
virtual ~CefV8AccessorCToCpp() {}
|
||||
|
||||
// CefV8Accessor methods
|
||||
virtual bool Get(const CefString& name, const CefRefPtr<CefV8Value> object,
|
||||
CefRefPtr<CefV8Value>& retval);
|
||||
virtual bool Set(const CefString& name, const CefRefPtr<CefV8Value> object,
|
||||
const CefRefPtr<CefV8Value> value);
|
||||
};
|
||||
|
||||
#endif // BUILDING_CEF_SHARED
|
||||
#endif // _V8ACCESSOR_CTOCPP_H
|
||||
|
@@ -73,6 +73,22 @@ CefRefPtr<CefV8Value> CefV8ContextCToCpp::GetGlobal()
|
||||
return NULL;
|
||||
}
|
||||
|
||||
bool CefV8ContextCToCpp::Enter()
|
||||
{
|
||||
if(CEF_MEMBER_MISSING(struct_, enter))
|
||||
return false;
|
||||
|
||||
return struct_->enter(struct_)?true:false;
|
||||
}
|
||||
|
||||
bool CefV8ContextCToCpp::Exit()
|
||||
{
|
||||
if(CEF_MEMBER_MISSING(struct_, exit))
|
||||
return false;
|
||||
|
||||
return struct_->exit(struct_)?true:false;
|
||||
}
|
||||
|
||||
|
||||
#ifdef _DEBUG
|
||||
template<> long CefCToCpp<CefV8ContextCToCpp, CefV8Context,
|
||||
|
@@ -34,6 +34,8 @@ public:
|
||||
virtual CefRefPtr<CefBrowser> GetBrowser();
|
||||
virtual CefRefPtr<CefFrame> GetFrame();
|
||||
virtual CefRefPtr<CefV8Value> GetGlobal();
|
||||
virtual bool Enter();
|
||||
virtual bool Exit();
|
||||
};
|
||||
|
||||
#endif // USING_CEF_SHARED
|
||||
|
@@ -11,6 +11,7 @@
|
||||
//
|
||||
|
||||
#include "libcef_dll/cpptoc/base_cpptoc.h"
|
||||
#include "libcef_dll/cpptoc/v8accessor_cpptoc.h"
|
||||
#include "libcef_dll/cpptoc/v8handler_cpptoc.h"
|
||||
#include "libcef_dll/ctocpp/v8context_ctocpp.h"
|
||||
#include "libcef_dll/ctocpp/v8value_ctocpp.h"
|
||||
@@ -79,6 +80,24 @@ CefRefPtr<CefV8Value> CefV8Value::CreateObject(CefRefPtr<CefBase> user_data)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
CefRefPtr<CefV8Value> CefV8Value::CreateObject(CefRefPtr<CefBase> user_data,
|
||||
CefRefPtr<CefV8Accessor> accessor)
|
||||
{
|
||||
cef_base_t* baseStruct = NULL;
|
||||
if(user_data)
|
||||
baseStruct = CefBaseCppToC::Wrap(user_data);
|
||||
|
||||
cef_v8accessor_t* accessorStruct = NULL;
|
||||
if(accessor)
|
||||
accessorStruct = CefV8AccessorCppToC::Wrap(accessor);
|
||||
|
||||
cef_v8value_t* impl = cef_v8value_create_object_with_accessor(baseStruct,
|
||||
accessorStruct);
|
||||
if(impl)
|
||||
return CefV8ValueCToCpp::Wrap(impl);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
CefRefPtr<CefV8Value> CefV8Value::CreateArray()
|
||||
{
|
||||
cef_v8value_t* impl = cef_v8value_create_array();
|
||||
@@ -176,6 +195,14 @@ bool CefV8ValueCToCpp::IsFunction()
|
||||
return struct_->is_function(struct_)?true:false;
|
||||
}
|
||||
|
||||
bool CefV8ValueCToCpp::IsSame(CefRefPtr<CefV8Value> that)
|
||||
{
|
||||
if(CEF_MEMBER_MISSING(struct_, is_same))
|
||||
return false;
|
||||
|
||||
return struct_->is_same(struct_, CefV8ValueCToCpp::Unwrap(that))?true:false;
|
||||
}
|
||||
|
||||
bool CefV8ValueCToCpp::GetBoolValue()
|
||||
{
|
||||
if(CEF_MEMBER_MISSING(struct_, get_bool_value))
|
||||
@@ -285,6 +312,16 @@ bool CefV8ValueCToCpp::SetValue(int index, CefRefPtr<CefV8Value> value)
|
||||
CefV8ValueCToCpp::Unwrap(value))?true:false;
|
||||
}
|
||||
|
||||
bool CefV8ValueCToCpp::SetValue(const CefString& key, AccessControl settings,
|
||||
PropertyAttribute attribute)
|
||||
{
|
||||
if(CEF_MEMBER_MISSING(struct_, set_value_byaccessor))
|
||||
return false;
|
||||
|
||||
return struct_->set_value_byaccessor(struct_, key.GetStruct(),
|
||||
settings, attribute)?true:false;
|
||||
}
|
||||
|
||||
bool CefV8ValueCToCpp::GetKeys(std::vector<CefString>& keys)
|
||||
{
|
||||
if(CEF_MEMBER_MISSING(struct_, get_keys))
|
||||
|
@@ -40,6 +40,7 @@ public:
|
||||
virtual bool IsObject();
|
||||
virtual bool IsArray();
|
||||
virtual bool IsFunction();
|
||||
virtual bool IsSame(CefRefPtr<CefV8Value> that);
|
||||
virtual bool GetBoolValue();
|
||||
virtual int GetIntValue();
|
||||
virtual double GetDoubleValue();
|
||||
@@ -52,6 +53,8 @@ public:
|
||||
virtual CefRefPtr<CefV8Value> GetValue(int index);
|
||||
virtual bool SetValue(const CefString& key, CefRefPtr<CefV8Value> value);
|
||||
virtual bool SetValue(int index, CefRefPtr<CefV8Value> value);
|
||||
virtual bool SetValue(const CefString& key, AccessControl settings,
|
||||
PropertyAttribute attribute);
|
||||
virtual bool GetKeys(std::vector<CefString>& keys);
|
||||
virtual CefRefPtr<CefBase> GetUserData();
|
||||
virtual int GetArrayLength();
|
||||
|
Reference in New Issue
Block a user