Various ApiCheck-related cleanups.

R=mstarzinger@chromium.org

Review URL: https://codereview.chromium.org/130933003

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@18551 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent 5c65572d
This diff is collapsed.
...@@ -196,7 +196,12 @@ class RegisteredExtension { ...@@ -196,7 +196,12 @@ class RegisteredExtension {
class Utils { class Utils {
public: public:
static bool ReportApiFailure(const char* location, const char* message); static inline bool ApiCheck(bool condition,
const char* location,
const char* message) {
if (!condition) Utils::ReportApiFailure(location, message);
return condition;
}
static Local<FunctionTemplate> ToFunctionTemplate(NeanderObject obj); static Local<FunctionTemplate> ToFunctionTemplate(NeanderObject obj);
static Local<ObjectTemplate> ToObjectTemplate(NeanderObject obj); static Local<ObjectTemplate> ToObjectTemplate(NeanderObject obj);
...@@ -303,6 +308,9 @@ OPEN_HANDLE_LIST(DECLARE_OPEN_HANDLE) ...@@ -303,6 +308,9 @@ OPEN_HANDLE_LIST(DECLARE_OPEN_HANDLE)
static inline v8::internal::Handle<To> OpenHandle(v8::Local<From> handle) { static inline v8::internal::Handle<To> OpenHandle(v8::Local<From> handle) {
return OpenHandle(*handle); return OpenHandle(*handle);
} }
private:
static void ReportApiFailure(const char* location, const char* message);
}; };
......
...@@ -2293,9 +2293,9 @@ bool Genesis::InstallExtension(Isolate* isolate, ...@@ -2293,9 +2293,9 @@ bool Genesis::InstallExtension(Isolate* isolate,
current = current->next(); current = current->next();
} }
// Didn't find the extension; fail. // Didn't find the extension; fail.
if (current == NULL) { if (!Utils::ApiCheck(current != NULL,
v8::Utils::ReportApiFailure( "v8::Context::New()",
"v8::Context::New()", "Cannot find required extension"); "Cannot find required extension")) {
return false; return false;
} }
return InstallExtension(isolate, current, extension_states); return InstallExtension(isolate, current, extension_states);
...@@ -2310,9 +2310,9 @@ bool Genesis::InstallExtension(Isolate* isolate, ...@@ -2310,9 +2310,9 @@ bool Genesis::InstallExtension(Isolate* isolate,
if (extension_states->get_state(current) == INSTALLED) return true; if (extension_states->get_state(current) == INSTALLED) return true;
// The current node has already been visited so there must be a // The current node has already been visited so there must be a
// cycle in the dependency graph; fail. // cycle in the dependency graph; fail.
if (extension_states->get_state(current) == VISITED) { if (!Utils::ApiCheck(extension_states->get_state(current) != VISITED,
v8::Utils::ReportApiFailure( "v8::Context::New()",
"v8::Context::New()", "Circular extension dependency"); "Circular extension dependency")) {
return false; return false;
} }
ASSERT(extension_states->get_state(current) == UNVISITED); ASSERT(extension_states->get_state(current) == UNVISITED);
......
...@@ -63,9 +63,9 @@ Object** HandleScope::Extend(Isolate* isolate) { ...@@ -63,9 +63,9 @@ Object** HandleScope::Extend(Isolate* isolate) {
ASSERT(result == current->limit); ASSERT(result == current->limit);
// Make sure there's at least one scope on the stack and that the // Make sure there's at least one scope on the stack and that the
// top of the scope stack isn't a barrier. // top of the scope stack isn't a barrier.
if (current->level == 0) { if (!Utils::ApiCheck(current->level != 0,
Utils::ReportApiFailure("v8::HandleScope::CreateHandle()", "v8::HandleScope::CreateHandle()",
"Cannot create a handle without a HandleScope"); "Cannot create a handle without a HandleScope")) {
return NULL; return NULL;
} }
HandleScopeImplementer* impl = isolate->handle_scope_implementer(); HandleScopeImplementer* impl = isolate->handle_scope_implementer();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment