Merge revision 644 and 725 changes:

- Add new CefV8StackTrace and CefV8StackFrame interfaces to support retrieval of the JavaScript stack trace for the currently active V8 context (issue #682).
- Add CefV8Context::Eval method for synchronous JavaScript execution that returns a value or exception (issue #444).
- Refactor V8 unit tests (issue #480).

git-svn-id: https://chromiumembedded.googlecode.com/svn/branches/963@726 5089003a-bbd8-11dd-ad1f-f1f9622dbc98
This commit is contained in:
Marshall Greenblatt
2012-07-25 09:54:04 +00:00
parent a0feffdba6
commit 939b5a2008
20 changed files with 2587 additions and 1757 deletions

View File

@@ -13,6 +13,7 @@
#include "libcef_dll/cpptoc/browser_cpptoc.h"
#include "libcef_dll/cpptoc/frame_cpptoc.h"
#include "libcef_dll/cpptoc/v8context_cpptoc.h"
#include "libcef_dll/cpptoc/v8exception_cpptoc.h"
#include "libcef_dll/cpptoc/v8value_cpptoc.h"
@@ -160,6 +161,71 @@ int CEF_CALLBACK v8context_is_same(struct _cef_v8context_t* self,
}
int CEF_CALLBACK v8context_eval(struct _cef_v8context_t* self,
const cef_string_t* code, struct _cef_v8value_t** retval,
struct _cef_v8exception_t** exception)
{
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
DCHECK(self);
if (!self)
return 0;
// Verify param: code; type: string_byref_const
DCHECK(code);
if (!code)
return 0;
// Verify param: retval; type: refptr_same_byref
DCHECK(retval);
if (!retval)
return 0;
// Verify param: exception; type: refptr_same_byref
DCHECK(exception);
if (!exception)
return 0;
// Translate param: retval; type: refptr_same_byref
CefRefPtr<CefV8Value> retvalPtr;
if (retval && *retval)
retvalPtr = CefV8ValueCppToC::Unwrap(*retval);
CefV8Value* retvalOrig = retvalPtr.get();
// Translate param: exception; type: refptr_same_byref
CefRefPtr<CefV8Exception> exceptionPtr;
if (exception && *exception)
exceptionPtr = CefV8ExceptionCppToC::Unwrap(*exception);
CefV8Exception* exceptionOrig = exceptionPtr.get();
// Execute
bool _retval = CefV8ContextCppToC::Get(self)->Eval(
CefString(code),
retvalPtr,
exceptionPtr);
// Restore param: retval; type: refptr_same_byref
if (retval) {
if (retvalPtr.get()) {
if (retvalPtr.get() != retvalOrig) {
*retval = CefV8ValueCppToC::Wrap(retvalPtr);
}
} else {
*retval = NULL;
}
}
// Restore param: exception; type: refptr_same_byref
if (exception) {
if (exceptionPtr.get()) {
if (exceptionPtr.get() != exceptionOrig) {
*exception = CefV8ExceptionCppToC::Wrap(exceptionPtr);
}
} else {
*exception = NULL;
}
}
// Return type: bool
return _retval;
}
// CONSTRUCTOR - Do not edit by hand.
@@ -172,6 +238,7 @@ CefV8ContextCppToC::CefV8ContextCppToC(CefV8Context* cls)
struct_.struct_.enter = v8context_enter;
struct_.struct_.exit = v8context_exit;
struct_.struct_.is_same = v8context_is_same;
struct_.struct_.eval = v8context_eval;
}
#ifndef NDEBUG

View File

@@ -0,0 +1,156 @@
// Copyright (c) 2012 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. If making changes by
// hand only do so within the body of existing method and function
// implementations. See the translator.README.txt file in the tools directory
// for more information.
//
#include "libcef_dll/cpptoc/v8stack_frame_cpptoc.h"
// MEMBER FUNCTIONS - Body may be edited by hand.
cef_string_userfree_t CEF_CALLBACK v8stack_frame_get_script_name(
struct _cef_v8stack_frame_t* self)
{
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
DCHECK(self);
if (!self)
return NULL;
// Execute
CefString _retval = CefV8StackFrameCppToC::Get(self)->GetScriptName();
// Return type: string
return _retval.DetachToUserFree();
}
cef_string_userfree_t CEF_CALLBACK v8stack_frame_get_script_name_or_source_url(
struct _cef_v8stack_frame_t* self)
{
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
DCHECK(self);
if (!self)
return NULL;
// Execute
CefString _retval = CefV8StackFrameCppToC::Get(
self)->GetScriptNameOrSourceURL();
// Return type: string
return _retval.DetachToUserFree();
}
cef_string_userfree_t CEF_CALLBACK v8stack_frame_get_function_name(
struct _cef_v8stack_frame_t* self)
{
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
DCHECK(self);
if (!self)
return NULL;
// Execute
CefString _retval = CefV8StackFrameCppToC::Get(self)->GetFunctionName();
// Return type: string
return _retval.DetachToUserFree();
}
int CEF_CALLBACK v8stack_frame_get_line_number(
struct _cef_v8stack_frame_t* self)
{
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
DCHECK(self);
if (!self)
return 0;
// Execute
int _retval = CefV8StackFrameCppToC::Get(self)->GetLineNumber();
// Return type: simple
return _retval;
}
int CEF_CALLBACK v8stack_frame_get_column(struct _cef_v8stack_frame_t* self)
{
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
DCHECK(self);
if (!self)
return 0;
// Execute
int _retval = CefV8StackFrameCppToC::Get(self)->GetColumn();
// Return type: simple
return _retval;
}
int CEF_CALLBACK v8stack_frame_is_eval(struct _cef_v8stack_frame_t* self)
{
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
DCHECK(self);
if (!self)
return 0;
// Execute
bool _retval = CefV8StackFrameCppToC::Get(self)->IsEval();
// Return type: bool
return _retval;
}
int CEF_CALLBACK v8stack_frame_is_constructor(struct _cef_v8stack_frame_t* self)
{
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
DCHECK(self);
if (!self)
return 0;
// Execute
bool _retval = CefV8StackFrameCppToC::Get(self)->IsConstructor();
// Return type: bool
return _retval;
}
// CONSTRUCTOR - Do not edit by hand.
CefV8StackFrameCppToC::CefV8StackFrameCppToC(CefV8StackFrame* cls)
: CefCppToC<CefV8StackFrameCppToC, CefV8StackFrame, cef_v8stack_frame_t>(
cls)
{
struct_.struct_.get_script_name = v8stack_frame_get_script_name;
struct_.struct_.get_script_name_or_source_url =
v8stack_frame_get_script_name_or_source_url;
struct_.struct_.get_function_name = v8stack_frame_get_function_name;
struct_.struct_.get_line_number = v8stack_frame_get_line_number;
struct_.struct_.get_column = v8stack_frame_get_column;
struct_.struct_.is_eval = v8stack_frame_is_eval;
struct_.struct_.is_constructor = v8stack_frame_is_constructor;
}
#ifndef NDEBUG
template<> long CefCppToC<CefV8StackFrameCppToC, CefV8StackFrame,
cef_v8stack_frame_t>::DebugObjCt = 0;
#endif

View File

@@ -0,0 +1,37 @@
// Copyright (c) 2012 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. If making changes by
// hand only do so within the body of existing method and function
// implementations. See the translator.README.txt file in the tools directory
// for more information.
//
#ifndef _V8STACKFRAME_CPPTOC_H
#define _V8STACKFRAME_CPPTOC_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/cpptoc/cpptoc.h"
// Wrap a C++ class with a C structure.
// This class may be instantiated and accessed DLL-side only.
class CefV8StackFrameCppToC
: public CefCppToC<CefV8StackFrameCppToC, CefV8StackFrame,
cef_v8stack_frame_t>
{
public:
CefV8StackFrameCppToC(CefV8StackFrame* cls);
virtual ~CefV8StackFrameCppToC() {}
};
#endif // BUILDING_CEF_SHARED
#endif // _V8STACKFRAME_CPPTOC_H

View File

@@ -0,0 +1,86 @@
// Copyright (c) 2012 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. If making changes by
// hand only do so within the body of existing method and function
// implementations. See the translator.README.txt file in the tools directory
// for more information.
//
#include "libcef_dll/cpptoc/v8stack_frame_cpptoc.h"
#include "libcef_dll/cpptoc/v8stack_trace_cpptoc.h"
// GLOBAL FUNCTIONS - Body may be edited by hand.
CEF_EXPORT cef_v8stack_trace_t* cef_v8stack_trace_get_current(int frame_limit)
{
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
// Execute
CefRefPtr<CefV8StackTrace> _retval = CefV8StackTrace::GetCurrent(
frame_limit);
// Return type: refptr_same
return CefV8StackTraceCppToC::Wrap(_retval);
}
// MEMBER FUNCTIONS - Body may be edited by hand.
int CEF_CALLBACK v8stack_trace_get_frame_count(
struct _cef_v8stack_trace_t* self)
{
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
DCHECK(self);
if (!self)
return 0;
// Execute
int _retval = CefV8StackTraceCppToC::Get(self)->GetFrameCount();
// Return type: simple
return _retval;
}
struct _cef_v8stack_frame_t* CEF_CALLBACK v8stack_trace_get_frame(
struct _cef_v8stack_trace_t* self, int index)
{
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
DCHECK(self);
if (!self)
return NULL;
// Execute
CefRefPtr<CefV8StackFrame> _retval = CefV8StackTraceCppToC::Get(
self)->GetFrame(
index);
// Return type: refptr_same
return CefV8StackFrameCppToC::Wrap(_retval);
}
// CONSTRUCTOR - Do not edit by hand.
CefV8StackTraceCppToC::CefV8StackTraceCppToC(CefV8StackTrace* cls)
: CefCppToC<CefV8StackTraceCppToC, CefV8StackTrace, cef_v8stack_trace_t>(
cls)
{
struct_.struct_.get_frame_count = v8stack_trace_get_frame_count;
struct_.struct_.get_frame = v8stack_trace_get_frame;
}
#ifndef NDEBUG
template<> long CefCppToC<CefV8StackTraceCppToC, CefV8StackTrace,
cef_v8stack_trace_t>::DebugObjCt = 0;
#endif

View File

@@ -0,0 +1,37 @@
// Copyright (c) 2012 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. If making changes by
// hand only do so within the body of existing method and function
// implementations. See the translator.README.txt file in the tools directory
// for more information.
//
#ifndef _V8STACKTRACE_CPPTOC_H
#define _V8STACKTRACE_CPPTOC_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/cpptoc/cpptoc.h"
// Wrap a C++ class with a C structure.
// This class may be instantiated and accessed DLL-side only.
class CefV8StackTraceCppToC
: public CefCppToC<CefV8StackTraceCppToC, CefV8StackTrace,
cef_v8stack_trace_t>
{
public:
CefV8StackTraceCppToC(CefV8StackTrace* cls);
virtual ~CefV8StackTraceCppToC() {}
};
#endif // BUILDING_CEF_SHARED
#endif // _V8STACKTRACE_CPPTOC_H