mirror of
https://bitbucket.org/chromiumembedded/cef
synced 2025-06-05 21:39:12 +02:00
Introduce CefV8Exception for returning detailed exception information from CefV8Value::ExecuteFunction*() and add the ability to re-throw exceptions. (issue #317).
git-svn-id: https://chromiumembedded.googlecode.com/svn/trunk@371 5089003a-bbd8-11dd-ad1f-f1f9622dbc98
This commit is contained in:
@ -11,6 +11,7 @@
|
||||
//
|
||||
|
||||
#include "libcef_dll/cpptoc/v8context_cpptoc.h"
|
||||
#include "libcef_dll/cpptoc/v8exception_cpptoc.h"
|
||||
#include "libcef_dll/cpptoc/v8value_cpptoc.h"
|
||||
#include "libcef_dll/ctocpp/base_ctocpp.h"
|
||||
#include "libcef_dll/ctocpp/v8accessor_ctocpp.h"
|
||||
@ -445,7 +446,7 @@ cef_v8handler_t* CEF_CALLBACK v8value_get_function_handler(
|
||||
int CEF_CALLBACK v8value_execute_function(struct _cef_v8value_t* self,
|
||||
struct _cef_v8value_t* object, size_t argumentCount,
|
||||
struct _cef_v8value_t* const* arguments, struct _cef_v8value_t** retval,
|
||||
cef_string_t* exception)
|
||||
cef_v8exception_t** exception, int rethrow_exception)
|
||||
{
|
||||
DCHECK(self);
|
||||
if(!self)
|
||||
@ -454,17 +455,21 @@ int CEF_CALLBACK v8value_execute_function(struct _cef_v8value_t* self,
|
||||
CefRefPtr<CefV8Value> objectPtr;
|
||||
if(object)
|
||||
objectPtr = CefV8ValueCppToC::Unwrap(object);
|
||||
CefV8ValueList argsList;
|
||||
for(size_t i = 0; i < argumentCount; i++) {
|
||||
argsList.push_back(CefV8ValueCppToC::Unwrap(arguments[i]));
|
||||
}
|
||||
CefRefPtr<CefV8Value> retvalPtr;
|
||||
|
||||
CefString exceptionStr(exception);
|
||||
CefV8ValueList argsList;
|
||||
for(size_t i = 0; i < argumentCount; i++)
|
||||
argsList.push_back(CefV8ValueCppToC::Unwrap(arguments[i]));
|
||||
|
||||
CefRefPtr<CefV8Value> retvalPtr;
|
||||
CefRefPtr<CefV8Exception> exceptionPtr;
|
||||
|
||||
bool rv = CefV8ValueCppToC::Get(self)->ExecuteFunction(objectPtr,
|
||||
argsList, retvalPtr, exceptionStr);
|
||||
if(retvalPtr.get() && retval)
|
||||
argsList, retvalPtr, exceptionPtr, rethrow_exception?true:false);
|
||||
|
||||
if( retvalPtr.get() && retval)
|
||||
*retval = CefV8ValueCppToC::Wrap(retvalPtr);
|
||||
if (exceptionPtr.get() && exception)
|
||||
*exception = CefV8ExceptionCppToC::Wrap(exceptionPtr);
|
||||
|
||||
return rv;
|
||||
}
|
||||
@ -473,7 +478,7 @@ int CEF_CALLBACK v8value_execute_function_with_context(
|
||||
struct _cef_v8value_t* self, cef_v8context_t* context,
|
||||
struct _cef_v8value_t* object, size_t argumentCount,
|
||||
struct _cef_v8value_t* const* arguments, struct _cef_v8value_t** retval,
|
||||
cef_string_t* exception)
|
||||
cef_v8exception_t** exception, int rethrow_exception)
|
||||
{
|
||||
DCHECK(self);
|
||||
if(!self)
|
||||
@ -482,20 +487,26 @@ int CEF_CALLBACK v8value_execute_function_with_context(
|
||||
CefRefPtr<CefV8Context> contextPtr;
|
||||
if(context)
|
||||
contextPtr = CefV8ContextCppToC::Unwrap(context);
|
||||
|
||||
CefRefPtr<CefV8Value> objectPtr;
|
||||
if(object)
|
||||
objectPtr = CefV8ValueCppToC::Unwrap(object);
|
||||
|
||||
CefV8ValueList argsList;
|
||||
for(size_t i = 0; i < argumentCount; i++) {
|
||||
for(size_t i = 0; i < argumentCount; i++)
|
||||
argsList.push_back(CefV8ValueCppToC::Unwrap(arguments[i]));
|
||||
}
|
||||
CefRefPtr<CefV8Value> retvalPtr;
|
||||
|
||||
CefString exceptionStr(exception);
|
||||
CefRefPtr<CefV8Value> retvalPtr;
|
||||
CefRefPtr<CefV8Exception> exceptionPtr;
|
||||
|
||||
bool rv = CefV8ValueCppToC::Get(self)->ExecuteFunctionWithContext(
|
||||
contextPtr, objectPtr, argsList, retvalPtr, exceptionStr);
|
||||
if(retvalPtr.get() && retval)
|
||||
contextPtr, objectPtr, argsList, retvalPtr, exceptionPtr,
|
||||
rethrow_exception?true:false);
|
||||
|
||||
if (retvalPtr.get() && retval)
|
||||
*retval = CefV8ValueCppToC::Wrap(retvalPtr);
|
||||
if (exceptionPtr.get() && exception)
|
||||
*exception = CefV8ExceptionCppToC::Wrap(exceptionPtr);
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
Reference in New Issue
Block a user