mirror of
https://bitbucket.org/chromiumembedded/cef
synced 2025-06-05 21:39:12 +02:00
- Add the CEF translator tool for generating the C API header and cpptoc/ctocpp wrapper files.
- Update to files generated by the CEF translator tool. This introduces minor changes in cef.h and cef_capi.h for naming and translation consistency. - C API global function names that were previously in the cef_create_classname*() format are now in the cef_classname_create*() format. - cef_frame_t::get_frame_names() now returns void instead of size_t. - cef_frame_t::execute_javascript() has been renamed to cef_frame_t::execute_java_script(). - The 'arguments' attribute of CefV8Handler::Execute() and CefV8Value::ExecuteFunction() is now const. git-svn-id: https://chromiumembedded.googlecode.com/svn/trunk@30 5089003a-bbd8-11dd-ad1f-f1f9622dbc98
This commit is contained in:
@ -1,330 +1,434 @@
|
||||
// Copyright (c) 2009 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.
|
||||
|
||||
// Copyright (c) 2009 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 "../precompiled_libcef.h"
|
||||
#include "cpptoc/v8value_cpptoc.h"
|
||||
#include "ctocpp/v8handler_ctocpp.h"
|
||||
|
||||
|
||||
int CEF_CALLBACK v8value_is_undefined(struct _cef_v8value_t* v8value)
|
||||
{
|
||||
DCHECK(v8value);
|
||||
if(!v8value)
|
||||
return 0;
|
||||
|
||||
return CefV8ValueCppToC::Get(v8value)->IsUndefined();
|
||||
}
|
||||
|
||||
int CEF_CALLBACK v8value_is_null(struct _cef_v8value_t* v8value)
|
||||
{
|
||||
DCHECK(v8value);
|
||||
if(!v8value)
|
||||
return 0;
|
||||
|
||||
return CefV8ValueCppToC::Get(v8value)->IsNull();
|
||||
}
|
||||
|
||||
int CEF_CALLBACK v8value_is_bool(struct _cef_v8value_t* v8value)
|
||||
{
|
||||
DCHECK(v8value);
|
||||
if(!v8value)
|
||||
return 0;
|
||||
|
||||
return CefV8ValueCppToC::Get(v8value)->IsBool();
|
||||
}
|
||||
|
||||
int CEF_CALLBACK v8value_is_int(struct _cef_v8value_t* v8value)
|
||||
{
|
||||
DCHECK(v8value);
|
||||
if(!v8value)
|
||||
return 0;
|
||||
|
||||
return CefV8ValueCppToC::Get(v8value)->IsInt();
|
||||
}
|
||||
|
||||
int CEF_CALLBACK v8value_is_double(struct _cef_v8value_t* v8value)
|
||||
{
|
||||
DCHECK(v8value);
|
||||
if(!v8value)
|
||||
return 0;
|
||||
|
||||
return CefV8ValueCppToC::Get(v8value)->IsDouble();
|
||||
}
|
||||
|
||||
int CEF_CALLBACK v8value_is_string(struct _cef_v8value_t* v8value)
|
||||
{
|
||||
DCHECK(v8value);
|
||||
if(!v8value)
|
||||
return 0;
|
||||
|
||||
return CefV8ValueCppToC::Get(v8value)->IsString();
|
||||
}
|
||||
|
||||
int CEF_CALLBACK v8value_is_object(struct _cef_v8value_t* v8value)
|
||||
{
|
||||
DCHECK(v8value);
|
||||
if(!v8value)
|
||||
return 0;
|
||||
|
||||
return CefV8ValueCppToC::Get(v8value)->IsObject();
|
||||
}
|
||||
|
||||
int CEF_CALLBACK v8value_is_array(struct _cef_v8value_t* v8value)
|
||||
{
|
||||
DCHECK(v8value);
|
||||
if(!v8value)
|
||||
return 0;
|
||||
|
||||
return CefV8ValueCppToC::Get(v8value)->IsArray();
|
||||
}
|
||||
|
||||
int CEF_CALLBACK v8value_is_function(struct _cef_v8value_t* v8value)
|
||||
{
|
||||
DCHECK(v8value);
|
||||
if(!v8value)
|
||||
return 0;
|
||||
|
||||
return CefV8ValueCppToC::Get(v8value)->IsFunction();
|
||||
}
|
||||
#include "cpptoc/v8value_cpptoc.h"
|
||||
#include "ctocpp/base_ctocpp.h"
|
||||
#include "ctocpp/v8handler_ctocpp.h"
|
||||
|
||||
int CEF_CALLBACK v8value_get_bool_value(struct _cef_v8value_t* v8value)
|
||||
{
|
||||
DCHECK(v8value);
|
||||
if(!v8value)
|
||||
return 0;
|
||||
|
||||
return CefV8ValueCppToC::Get(v8value)->GetBoolValue();
|
||||
}
|
||||
|
||||
int CEF_CALLBACK v8value_get_int_value(struct _cef_v8value_t* v8value)
|
||||
{
|
||||
DCHECK(v8value);
|
||||
if(!v8value)
|
||||
return 0;
|
||||
|
||||
return CefV8ValueCppToC::Get(v8value)->GetIntValue();
|
||||
}
|
||||
// GLOBAL FUNCTIONS - Body may be edited by hand.
|
||||
|
||||
double CEF_CALLBACK v8value_get_double_value(struct _cef_v8value_t* v8value)
|
||||
{
|
||||
DCHECK(v8value);
|
||||
if(!v8value)
|
||||
return 0;
|
||||
|
||||
return CefV8ValueCppToC::Get(v8value)->GetDoubleValue();
|
||||
}
|
||||
CEF_EXPORT cef_v8value_t* cef_v8value_create_undefined()
|
||||
{
|
||||
CefRefPtr<CefV8Value> impl = CefV8Value::CreateUndefined();
|
||||
if(impl.get())
|
||||
return CefV8ValueCppToC::Wrap(impl);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
cef_string_t CEF_CALLBACK v8value_get_string_value(struct _cef_v8value_t* v8value)
|
||||
{
|
||||
DCHECK(v8value);
|
||||
if(!v8value)
|
||||
return 0;
|
||||
|
||||
std::wstring valueStr = CefV8ValueCppToC::Get(v8value)->GetStringValue();
|
||||
if(!valueStr.empty())
|
||||
return cef_string_alloc(valueStr.c_str());
|
||||
return NULL;
|
||||
}
|
||||
|
||||
int CEF_CALLBACK v8value_has_value_bykey(struct _cef_v8value_t* v8value,
|
||||
const wchar_t* key)
|
||||
{
|
||||
DCHECK(v8value);
|
||||
if(!v8value)
|
||||
return 0;
|
||||
|
||||
std::wstring keyStr;
|
||||
if(key)
|
||||
keyStr = key;
|
||||
|
||||
return CefV8ValueCppToC::Get(v8value)->HasValue(keyStr);
|
||||
}
|
||||
CEF_EXPORT cef_v8value_t* cef_v8value_create_null()
|
||||
{
|
||||
CefRefPtr<CefV8Value> impl = CefV8Value::CreateNull();
|
||||
if(impl.get())
|
||||
return CefV8ValueCppToC::Wrap(impl);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
int CEF_CALLBACK v8value_has_value_byindex(struct _cef_v8value_t* v8value,
|
||||
int index)
|
||||
{
|
||||
DCHECK(v8value);
|
||||
if(!v8value)
|
||||
return 0;
|
||||
|
||||
return CefV8ValueCppToC::Get(v8value)->HasValue(index);
|
||||
}
|
||||
CEF_EXPORT cef_v8value_t* cef_v8value_create_bool(int value)
|
||||
{
|
||||
CefRefPtr<CefV8Value> impl = CefV8Value::CreateBool(value?true:false);
|
||||
if(impl.get())
|
||||
return CefV8ValueCppToC::Wrap(impl);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
int CEF_CALLBACK v8value_delete_value_bykey(struct _cef_v8value_t* v8value,
|
||||
const wchar_t* key)
|
||||
{
|
||||
DCHECK(v8value);
|
||||
if(!v8value)
|
||||
return 0;
|
||||
|
||||
std::wstring keyStr;
|
||||
if(key)
|
||||
keyStr = key;
|
||||
|
||||
return CefV8ValueCppToC::Get(v8value)->DeleteValue(keyStr);
|
||||
}
|
||||
CEF_EXPORT cef_v8value_t* cef_v8value_create_int(int value)
|
||||
{
|
||||
CefRefPtr<CefV8Value> impl = CefV8Value::CreateInt(value);
|
||||
if(impl.get())
|
||||
return CefV8ValueCppToC::Wrap(impl);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
int CEF_CALLBACK v8value_delete_value_byindex(struct _cef_v8value_t* v8value,
|
||||
int index)
|
||||
{
|
||||
DCHECK(v8value);
|
||||
if(!v8value)
|
||||
return 0;
|
||||
|
||||
return CefV8ValueCppToC::Get(v8value)->DeleteValue(index);
|
||||
}
|
||||
CEF_EXPORT cef_v8value_t* cef_v8value_create_double(double value)
|
||||
{
|
||||
CefRefPtr<CefV8Value> impl = CefV8Value::CreateDouble(value);
|
||||
if(impl.get())
|
||||
return CefV8ValueCppToC::Wrap(impl);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
CEF_EXPORT cef_v8value_t* cef_v8value_create_string(const wchar_t* value)
|
||||
{
|
||||
std::wstring valueStr;
|
||||
if(value)
|
||||
valueStr = value;
|
||||
|
||||
CefRefPtr<CefV8Value> impl = CefV8Value::CreateString(valueStr);
|
||||
if(impl.get())
|
||||
return CefV8ValueCppToC::Wrap(impl);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
CEF_EXPORT cef_v8value_t* cef_v8value_create_object(cef_base_t* user_data)
|
||||
{
|
||||
CefRefPtr<CefBase> basePtr;
|
||||
if(user_data)
|
||||
basePtr = CefBaseCToCpp::Wrap(user_data);
|
||||
|
||||
CefRefPtr<CefV8Value> impl = CefV8Value::CreateObject(basePtr);
|
||||
if(impl.get())
|
||||
return CefV8ValueCppToC::Wrap(impl);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
CEF_EXPORT cef_v8value_t* cef_v8value_create_array()
|
||||
{
|
||||
CefRefPtr<CefV8Value> impl = CefV8Value::CreateArray();
|
||||
if(impl.get())
|
||||
return CefV8ValueCppToC::Wrap(impl);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
CEF_EXPORT cef_v8value_t* cef_v8value_create_function(const wchar_t* name,
|
||||
cef_v8handler_t* handler)
|
||||
{
|
||||
std::wstring nameStr;
|
||||
if(name)
|
||||
nameStr = name;
|
||||
CefRefPtr<CefV8Handler> handlerPtr;
|
||||
if(handler)
|
||||
handlerPtr = CefV8HandlerCToCpp::Wrap(handler);
|
||||
|
||||
CefRefPtr<CefV8Value> impl = CefV8Value::CreateFunction(nameStr, handlerPtr);
|
||||
if(impl.get())
|
||||
return CefV8ValueCppToC::Wrap(impl);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
// MEMBER FUNCTIONS - Body may be edited by hand.
|
||||
|
||||
int CEF_CALLBACK v8value_is_undefined(struct _cef_v8value_t* self)
|
||||
{
|
||||
DCHECK(self);
|
||||
if(!self)
|
||||
return 0;
|
||||
|
||||
return CefV8ValueCppToC::Get(self)->IsUndefined();
|
||||
}
|
||||
|
||||
int CEF_CALLBACK v8value_is_null(struct _cef_v8value_t* self)
|
||||
{
|
||||
DCHECK(self);
|
||||
if(!self)
|
||||
return 0;
|
||||
|
||||
return CefV8ValueCppToC::Get(self)->IsNull();
|
||||
}
|
||||
|
||||
int CEF_CALLBACK v8value_is_bool(struct _cef_v8value_t* self)
|
||||
{
|
||||
DCHECK(self);
|
||||
if(!self)
|
||||
return 0;
|
||||
|
||||
return CefV8ValueCppToC::Get(self)->IsBool();
|
||||
}
|
||||
|
||||
int CEF_CALLBACK v8value_is_int(struct _cef_v8value_t* self)
|
||||
{
|
||||
DCHECK(self);
|
||||
if(!self)
|
||||
return 0;
|
||||
|
||||
return CefV8ValueCppToC::Get(self)->IsInt();
|
||||
}
|
||||
|
||||
int CEF_CALLBACK v8value_is_double(struct _cef_v8value_t* self)
|
||||
{
|
||||
DCHECK(self);
|
||||
if(!self)
|
||||
return 0;
|
||||
|
||||
return CefV8ValueCppToC::Get(self)->IsDouble();
|
||||
}
|
||||
|
||||
int CEF_CALLBACK v8value_is_string(struct _cef_v8value_t* self)
|
||||
{
|
||||
DCHECK(self);
|
||||
if(!self)
|
||||
return 0;
|
||||
|
||||
return CefV8ValueCppToC::Get(self)->IsString();
|
||||
}
|
||||
|
||||
int CEF_CALLBACK v8value_is_object(struct _cef_v8value_t* self)
|
||||
{
|
||||
DCHECK(self);
|
||||
if(!self)
|
||||
return 0;
|
||||
|
||||
return CefV8ValueCppToC::Get(self)->IsObject();
|
||||
}
|
||||
|
||||
int CEF_CALLBACK v8value_is_array(struct _cef_v8value_t* self)
|
||||
{
|
||||
DCHECK(self);
|
||||
if(!self)
|
||||
return 0;
|
||||
|
||||
return CefV8ValueCppToC::Get(self)->IsArray();
|
||||
}
|
||||
|
||||
int CEF_CALLBACK v8value_is_function(struct _cef_v8value_t* self)
|
||||
{
|
||||
DCHECK(self);
|
||||
if(!self)
|
||||
return 0;
|
||||
|
||||
return CefV8ValueCppToC::Get(self)->IsFunction();
|
||||
}
|
||||
|
||||
int CEF_CALLBACK v8value_get_bool_value(struct _cef_v8value_t* self)
|
||||
{
|
||||
DCHECK(self);
|
||||
if(!self)
|
||||
return 0;
|
||||
|
||||
return CefV8ValueCppToC::Get(self)->GetBoolValue();
|
||||
}
|
||||
|
||||
int CEF_CALLBACK v8value_get_int_value(struct _cef_v8value_t* self)
|
||||
{
|
||||
DCHECK(self);
|
||||
if(!self)
|
||||
return 0;
|
||||
|
||||
return CefV8ValueCppToC::Get(self)->GetIntValue();
|
||||
}
|
||||
|
||||
double CEF_CALLBACK v8value_get_double_value(struct _cef_v8value_t* self)
|
||||
{
|
||||
DCHECK(self);
|
||||
if(!self)
|
||||
return 0;
|
||||
|
||||
return CefV8ValueCppToC::Get(self)->GetDoubleValue();
|
||||
}
|
||||
|
||||
cef_string_t CEF_CALLBACK v8value_get_string_value(struct _cef_v8value_t* self)
|
||||
{
|
||||
DCHECK(self);
|
||||
if(!self)
|
||||
return 0;
|
||||
|
||||
std::wstring valueStr = CefV8ValueCppToC::Get(self)->GetStringValue();
|
||||
if(!valueStr.empty())
|
||||
return cef_string_alloc(valueStr.c_str());
|
||||
return NULL;
|
||||
}
|
||||
|
||||
int CEF_CALLBACK v8value_has_value_bykey(struct _cef_v8value_t* self,
|
||||
const wchar_t* key)
|
||||
{
|
||||
DCHECK(self);
|
||||
if(!self)
|
||||
return 0;
|
||||
|
||||
std::wstring keyStr;
|
||||
if(key)
|
||||
keyStr = key;
|
||||
|
||||
return CefV8ValueCppToC::Get(self)->HasValue(keyStr);
|
||||
}
|
||||
|
||||
int CEF_CALLBACK v8value_has_value_byindex(struct _cef_v8value_t* self,
|
||||
int index)
|
||||
{
|
||||
DCHECK(self);
|
||||
if(!self)
|
||||
return 0;
|
||||
|
||||
return CefV8ValueCppToC::Get(self)->HasValue(index);
|
||||
}
|
||||
|
||||
int CEF_CALLBACK v8value_delete_value_bykey(struct _cef_v8value_t* self,
|
||||
const wchar_t* key)
|
||||
{
|
||||
DCHECK(self);
|
||||
if(!self)
|
||||
return 0;
|
||||
|
||||
std::wstring keyStr;
|
||||
if(key)
|
||||
keyStr = key;
|
||||
|
||||
return CefV8ValueCppToC::Get(self)->DeleteValue(keyStr);
|
||||
}
|
||||
|
||||
int CEF_CALLBACK v8value_delete_value_byindex(struct _cef_v8value_t* self,
|
||||
int index)
|
||||
{
|
||||
DCHECK(self);
|
||||
if(!self)
|
||||
return 0;
|
||||
|
||||
return CefV8ValueCppToC::Get(self)->DeleteValue(index);
|
||||
}
|
||||
|
||||
struct _cef_v8value_t* CEF_CALLBACK v8value_get_value_bykey(
|
||||
struct _cef_v8value_t* v8value, const wchar_t* key)
|
||||
{
|
||||
DCHECK(v8value);
|
||||
if(!v8value)
|
||||
return 0;
|
||||
|
||||
std::wstring keyStr;
|
||||
if(key)
|
||||
keyStr = key;
|
||||
|
||||
CefRefPtr<CefV8Value> valuePtr =
|
||||
CefV8ValueCppToC::Get(v8value)->GetValue(keyStr);
|
||||
return CefV8ValueCppToC::Wrap(valuePtr);
|
||||
}
|
||||
struct _cef_v8value_t* self, const wchar_t* key)
|
||||
{
|
||||
DCHECK(self);
|
||||
if(!self)
|
||||
return 0;
|
||||
|
||||
std::wstring keyStr;
|
||||
if(key)
|
||||
keyStr = key;
|
||||
|
||||
CefRefPtr<CefV8Value> valuePtr =
|
||||
CefV8ValueCppToC::Get(self)->GetValue(keyStr);
|
||||
return CefV8ValueCppToC::Wrap(valuePtr);
|
||||
}
|
||||
|
||||
struct _cef_v8value_t* CEF_CALLBACK v8value_get_value_byindex(
|
||||
struct _cef_v8value_t* v8value, int index)
|
||||
{
|
||||
DCHECK(v8value);
|
||||
if(!v8value)
|
||||
return 0;
|
||||
|
||||
CefRefPtr<CefV8Value> valuePtr =
|
||||
CefV8ValueCppToC::Get(v8value)->GetValue(index);
|
||||
return CefV8ValueCppToC::Wrap(valuePtr);
|
||||
}
|
||||
struct _cef_v8value_t* self, int index)
|
||||
{
|
||||
DCHECK(self);
|
||||
if(!self)
|
||||
return 0;
|
||||
|
||||
int CEF_CALLBACK v8value_set_value_bykey(struct _cef_v8value_t* v8value,
|
||||
const wchar_t* key, struct _cef_v8value_t* new_value)
|
||||
{
|
||||
DCHECK(v8value);
|
||||
if(!v8value)
|
||||
return 0;
|
||||
|
||||
std::wstring keyStr;
|
||||
if(key)
|
||||
keyStr = key;
|
||||
|
||||
CefRefPtr<CefV8Value> valuePtr = CefV8ValueCppToC::Unwrap(new_value);
|
||||
return CefV8ValueCppToC::Get(v8value)->SetValue(keyStr, valuePtr);
|
||||
}
|
||||
CefRefPtr<CefV8Value> valuePtr =
|
||||
CefV8ValueCppToC::Get(self)->GetValue(index);
|
||||
return CefV8ValueCppToC::Wrap(valuePtr);
|
||||
}
|
||||
|
||||
int CEF_CALLBACK v8value_set_value_byindex(struct _cef_v8value_t* v8value,
|
||||
int index, struct _cef_v8value_t* new_value)
|
||||
{
|
||||
DCHECK(v8value);
|
||||
if(!v8value)
|
||||
return 0;
|
||||
|
||||
CefRefPtr<CefV8Value> valuePtr = CefV8ValueCppToC::Unwrap(new_value);
|
||||
return CefV8ValueCppToC::Get(v8value)->SetValue(index, valuePtr);
|
||||
}
|
||||
int CEF_CALLBACK v8value_set_value_bykey(struct _cef_v8value_t* self,
|
||||
const wchar_t* key, struct _cef_v8value_t* value)
|
||||
{
|
||||
DCHECK(self);
|
||||
if(!self)
|
||||
return 0;
|
||||
|
||||
int CEF_CALLBACK v8value_get_keys(struct _cef_v8value_t* v8value,
|
||||
cef_string_list_t list)
|
||||
{
|
||||
DCHECK(v8value);
|
||||
if(!v8value)
|
||||
return 0;
|
||||
|
||||
std::vector<std::wstring> keysList;
|
||||
CefV8ValueCppToC::Get(v8value)->GetKeys(keysList);
|
||||
size_t size = keysList.size();
|
||||
for(size_t i = 0; i < size; ++i)
|
||||
cef_string_list_append(list, keysList[i].c_str());
|
||||
return size;
|
||||
}
|
||||
std::wstring keyStr;
|
||||
if(key)
|
||||
keyStr = key;
|
||||
|
||||
struct _cef_base_t* CEF_CALLBACK v8value_get_user_data(
|
||||
struct _cef_v8value_t* v8value)
|
||||
{
|
||||
DCHECK(v8value);
|
||||
if(!v8value)
|
||||
return 0;
|
||||
|
||||
CefRefPtr<CefBase> base = CefV8ValueCppToC::Get(v8value)->GetUserData();
|
||||
if(base.get())
|
||||
return CefBaseCToCpp::Unwrap(base);
|
||||
return NULL;
|
||||
}
|
||||
CefRefPtr<CefV8Value> valuePtr = CefV8ValueCppToC::Unwrap(value);
|
||||
return CefV8ValueCppToC::Get(self)->SetValue(keyStr, valuePtr);
|
||||
}
|
||||
|
||||
int CEF_CALLBACK v8value_get_array_length(struct _cef_v8value_t* v8value)
|
||||
{
|
||||
DCHECK(v8value);
|
||||
if(!v8value)
|
||||
return 0;
|
||||
|
||||
return CefV8ValueCppToC::Get(v8value)->GetArrayLength();
|
||||
}
|
||||
int CEF_CALLBACK v8value_set_value_byindex(struct _cef_v8value_t* self,
|
||||
int index, struct _cef_v8value_t* value)
|
||||
{
|
||||
DCHECK(self);
|
||||
if(!self)
|
||||
return 0;
|
||||
|
||||
cef_string_t CEF_CALLBACK v8value_get_function_name(
|
||||
struct _cef_v8value_t* v8value)
|
||||
{
|
||||
DCHECK(v8value);
|
||||
if(!v8value)
|
||||
return 0;
|
||||
|
||||
std::wstring functionNameStr =
|
||||
CefV8ValueCppToC::Get(v8value)->GetFunctionName();
|
||||
if(!functionNameStr.empty())
|
||||
return cef_string_alloc(functionNameStr.c_str());
|
||||
return NULL;
|
||||
}
|
||||
CefRefPtr<CefV8Value> valuePtr = CefV8ValueCppToC::Unwrap(value);
|
||||
return CefV8ValueCppToC::Get(self)->SetValue(index, valuePtr);
|
||||
}
|
||||
|
||||
struct _cef_v8handler_t* CEF_CALLBACK v8value_get_function_handler(
|
||||
struct _cef_v8value_t* v8value)
|
||||
{
|
||||
DCHECK(v8value);
|
||||
if(!v8value)
|
||||
return 0;
|
||||
|
||||
CefRefPtr<CefV8Handler> handlerPtr =
|
||||
CefV8ValueCppToC::Get(v8value)->GetFunctionHandler();
|
||||
if(handlerPtr.get())
|
||||
return CefV8HandlerCToCpp::Unwrap(handlerPtr);
|
||||
return NULL;
|
||||
}
|
||||
int CEF_CALLBACK v8value_get_keys(struct _cef_v8value_t* self,
|
||||
cef_string_list_t keys)
|
||||
{
|
||||
DCHECK(self);
|
||||
if(!self)
|
||||
return 0;
|
||||
|
||||
int CEF_CALLBACK v8value_execute_function(struct _cef_v8value_t* v8value,
|
||||
struct _cef_v8value_t* object, size_t numargs,
|
||||
struct _cef_v8value_t** args, struct _cef_v8value_t** retval,
|
||||
cef_string_t* exception)
|
||||
{
|
||||
DCHECK(v8value);
|
||||
DCHECK(object);
|
||||
if(!v8value || !object)
|
||||
return 0;
|
||||
|
||||
CefRefPtr<CefV8Value> objectPtr = CefV8ValueCppToC::Unwrap(object);
|
||||
CefV8ValueList argsList;
|
||||
for(size_t i = 0; i < numargs; i++)
|
||||
argsList.push_back(CefV8ValueCppToC::Unwrap(args[i]));
|
||||
CefRefPtr<CefV8Value> retvalPtr;
|
||||
std::wstring exceptionStr;
|
||||
|
||||
bool rv = CefV8ValueCppToC::Get(v8value)->ExecuteFunction(objectPtr,
|
||||
argsList, retvalPtr, exceptionStr);
|
||||
if(retvalPtr.get() && retval)
|
||||
*retval = CefV8ValueCppToC::Wrap(retvalPtr);
|
||||
if(!exceptionStr.empty() && exception)
|
||||
*exception = cef_string_alloc(exceptionStr.c_str());
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
std::vector<std::wstring> keysList;
|
||||
CefV8ValueCppToC::Get(self)->GetKeys(keysList);
|
||||
size_t size = keysList.size();
|
||||
for(size_t i = 0; i < size; ++i)
|
||||
cef_string_list_append(keys, keysList[i].c_str());
|
||||
return size;
|
||||
}
|
||||
|
||||
CefV8ValueCppToC::CefV8ValueCppToC(CefV8Value* cls)
|
||||
: CefCppToC<CefV8ValueCppToC, CefV8Value, cef_v8value_t>(cls)
|
||||
{
|
||||
cef_base_t* CEF_CALLBACK v8value_get_user_data(struct _cef_v8value_t* self)
|
||||
{
|
||||
DCHECK(self);
|
||||
if(!self)
|
||||
return 0;
|
||||
|
||||
CefRefPtr<CefBase> base = CefV8ValueCppToC::Get(self)->GetUserData();
|
||||
if(base.get())
|
||||
return CefBaseCToCpp::Unwrap(base);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
int CEF_CALLBACK v8value_get_array_length(struct _cef_v8value_t* self)
|
||||
{
|
||||
DCHECK(self);
|
||||
if(!self)
|
||||
return 0;
|
||||
|
||||
return CefV8ValueCppToC::Get(self)->GetArrayLength();
|
||||
}
|
||||
|
||||
cef_string_t CEF_CALLBACK v8value_get_function_name(struct _cef_v8value_t* self)
|
||||
{
|
||||
DCHECK(self);
|
||||
if(!self)
|
||||
return 0;
|
||||
|
||||
std::wstring functionNameStr =
|
||||
CefV8ValueCppToC::Get(self)->GetFunctionName();
|
||||
if(!functionNameStr.empty())
|
||||
return cef_string_alloc(functionNameStr.c_str());
|
||||
return NULL;
|
||||
}
|
||||
|
||||
cef_v8handler_t* CEF_CALLBACK v8value_get_function_handler(
|
||||
struct _cef_v8value_t* self)
|
||||
{
|
||||
DCHECK(self);
|
||||
if(!self)
|
||||
return 0;
|
||||
|
||||
CefRefPtr<CefV8Handler> handlerPtr =
|
||||
CefV8ValueCppToC::Get(self)->GetFunctionHandler();
|
||||
if(handlerPtr.get())
|
||||
return CefV8HandlerCToCpp::Unwrap(handlerPtr);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
int CEF_CALLBACK v8value_execute_function(struct _cef_v8value_t* self,
|
||||
struct _cef_v8value_t* object, size_t argumentCount,
|
||||
const struct _cef_v8value_t** arguments, struct _cef_v8value_t** retval,
|
||||
cef_string_t* exception)
|
||||
{
|
||||
DCHECK(self);
|
||||
DCHECK(object);
|
||||
if(!self || !object)
|
||||
return 0;
|
||||
|
||||
CefRefPtr<CefV8Value> objectPtr = CefV8ValueCppToC::Unwrap(object);
|
||||
CefV8ValueList argsList;
|
||||
for(size_t i = 0; i < argumentCount; i++) {
|
||||
argsList.push_back(CefV8ValueCppToC::Unwrap(
|
||||
const_cast<cef_v8value_t*>(arguments[i])));
|
||||
}
|
||||
CefRefPtr<CefV8Value> retvalPtr;
|
||||
std::wstring exceptionStr;
|
||||
|
||||
bool rv = CefV8ValueCppToC::Get(self)->ExecuteFunction(objectPtr,
|
||||
argsList, retvalPtr, exceptionStr);
|
||||
if(retvalPtr.get() && retval)
|
||||
*retval = CefV8ValueCppToC::Wrap(retvalPtr);
|
||||
if(!exceptionStr.empty() && exception)
|
||||
*exception = cef_string_alloc(exceptionStr.c_str());
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
|
||||
// CONSTRUCTOR - Do not edit by hand.
|
||||
|
||||
CefV8ValueCppToC::CefV8ValueCppToC(CefV8Value* cls)
|
||||
: CefCppToC<CefV8ValueCppToC, CefV8Value, cef_v8value_t>(cls)
|
||||
{
|
||||
struct_.struct_.is_undefined = v8value_is_undefined;
|
||||
struct_.struct_.is_null = v8value_is_null;
|
||||
struct_.struct_.is_bool = v8value_is_bool;
|
||||
@ -351,9 +455,10 @@ CefV8ValueCppToC::CefV8ValueCppToC(CefV8Value* cls)
|
||||
struct_.struct_.get_array_length = v8value_get_array_length;
|
||||
struct_.struct_.get_function_name = v8value_get_function_name;
|
||||
struct_.struct_.get_function_handler = v8value_get_function_handler;
|
||||
struct_.struct_.execute_function = v8value_execute_function;
|
||||
}
|
||||
struct_.struct_.execute_function = v8value_execute_function;
|
||||
}
|
||||
|
||||
#ifdef _DEBUG
|
||||
long CefCppToC<CefV8ValueCppToC, CefV8Value, cef_v8value_t>::DebugObjCt = 0;
|
||||
#endif
|
||||
|
||||
|
Reference in New Issue
Block a user