Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(264)

Side by Side Diff: src/api.cc

Issue 6964005: Add IsCallable method for Object in the API (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 9 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « include/v8.h ('k') | test/cctest/test-api.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2011 the V8 project authors. All rights reserved. 1 // Copyright 2011 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 3237 matching lines...) Expand 10 before | Expand all | Expand 10 after
3248 "v8::GetIndexedPropertiesExternalArrayDataLength()", 3248 "v8::GetIndexedPropertiesExternalArrayDataLength()",
3249 return 0); 3249 return 0);
3250 if (self->HasExternalArrayElements()) { 3250 if (self->HasExternalArrayElements()) {
3251 return i::ExternalArray::cast(self->elements())->length(); 3251 return i::ExternalArray::cast(self->elements())->length();
3252 } else { 3252 } else {
3253 return -1; 3253 return -1;
3254 } 3254 }
3255 } 3255 }
3256 3256
3257 3257
3258 bool v8::Object::IsCallable() {
3259 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
3260 ON_BAILOUT(isolate, "v8::Object::IsCallable()", return false);
3261 ENTER_V8(isolate);
3262 i::HandleScope scope(isolate);
3263 i::Handle<i::JSObject> obj = Utils::OpenHandle(this);
3264 if (obj->IsJSFunction())
Mads Ager (chromium) 2011/05/09 11:38:52 Either make this a one-liner or use braces.
3265 return true;
Mads Ager (chromium) 2011/05/09 11:38:52 Two-space indent please.
3266 return i::Execution::GetFunctionDelegate(obj)->IsJSFunction();
3267 }
3268
3269
3258 Local<v8::Value> Object::CallAsFunction(v8::Handle<v8::Object> recv, int argc, 3270 Local<v8::Value> Object::CallAsFunction(v8::Handle<v8::Object> recv, int argc,
3259 v8::Handle<v8::Value> argv[]) { 3271 v8::Handle<v8::Value> argv[]) {
3260 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); 3272 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
3261 ON_BAILOUT(isolate, "v8::Object::CallAsFunction()", 3273 ON_BAILOUT(isolate, "v8::Object::CallAsFunction()",
3262 return Local<v8::Value>()); 3274 return Local<v8::Value>());
3263 LOG_API(isolate, "Object::CallAsFunction"); 3275 LOG_API(isolate, "Object::CallAsFunction");
3264 ENTER_V8(isolate); 3276 ENTER_V8(isolate);
3265 i::HandleScope scope(isolate); 3277 i::HandleScope scope(isolate);
3266 i::Handle<i::JSObject> obj = Utils::OpenHandle(this); 3278 i::Handle<i::JSObject> obj = Utils::OpenHandle(this);
3267 i::Handle<i::Object> recv_obj = Utils::OpenHandle(*recv); 3279 i::Handle<i::Object> recv_obj = Utils::OpenHandle(*recv);
(...skipping 2560 matching lines...) Expand 10 before | Expand all | Expand 10 after
5828 5840
5829 5841
5830 char* HandleScopeImplementer::Iterate(ObjectVisitor* v, char* storage) { 5842 char* HandleScopeImplementer::Iterate(ObjectVisitor* v, char* storage) {
5831 HandleScopeImplementer* scope_implementer = 5843 HandleScopeImplementer* scope_implementer =
5832 reinterpret_cast<HandleScopeImplementer*>(storage); 5844 reinterpret_cast<HandleScopeImplementer*>(storage);
5833 scope_implementer->IterateThis(v); 5845 scope_implementer->IterateThis(v);
5834 return storage + ArchiveSpacePerThread(); 5846 return storage + ArchiveSpacePerThread();
5835 } 5847 }
5836 5848
5837 } } // namespace v8::internal 5849 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « include/v8.h ('k') | test/cctest/test-api.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698