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

Side by Side Diff: src/api.cc

Issue 6883045: Add CallAsFunction method to the Object class in the API (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 9 years, 8 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
OLDNEW
1 // Copyright 2010 the V8 project authors. All rights reserved. 1 // Copyright 2010 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 3164 matching lines...) Expand 10 before | Expand all | Expand 10 after
3175 "v8::GetIndexedPropertiesExternalArrayDataLength()", 3175 "v8::GetIndexedPropertiesExternalArrayDataLength()",
3176 return 0); 3176 return 0);
3177 if (self->HasExternalArrayElements()) { 3177 if (self->HasExternalArrayElements()) {
3178 return i::ExternalArray::cast(self->elements())->length(); 3178 return i::ExternalArray::cast(self->elements())->length();
3179 } else { 3179 } else {
3180 return -1; 3180 return -1;
3181 } 3181 }
3182 } 3182 }
3183 3183
3184 3184
3185 Local<v8::Value> Object::Call(v8::Handle<v8::Object> recv, int argc,
3186 v8::Handle<v8::Value> argv[]) {
Mads Ager (chromium) 2011/04/28 11:53:05 Indentation is off.
3187 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
3188 ON_BAILOUT(isolate, "v8::Object::Call()", return Local<v8::Value>());
3189 LOG_API(isolate, "Object::Call");
3190 ENTER_V8(isolate);
3191 i::Object* raw_result = NULL;
3192 {
3193 i::HandleScope scope(isolate);
3194 i::Handle<i::JSObject> obj = Utils::OpenHandle(this);
3195 i::Handle<i::Object> recv_obj = Utils::OpenHandle(*recv);
3196 STATIC_ASSERT(sizeof(v8::Handle<v8::Value>) == sizeof(i::Object**));
3197 i::Object*** args = reinterpret_cast<i::Object***>(argv);
3198 i::Handle<i::JSFunction> fun;
3199 if (obj->IsJSFunction()) {
3200 fun = i::Handle<i::JSFunction>::cast(obj);
3201 } else {
3202 fun = i::Handle<i::JSFunction>::cast(
3203 i::Execution::GetFunctionDelegate(obj));
3204 recv_obj = obj;
3205 }
3206 EXCEPTION_PREAMBLE(isolate);
3207 i::Handle<i::Object> returned =
3208 i::Execution::Call(fun, recv_obj, argc, args, &has_pending_exception);
3209 EXCEPTION_BAILOUT_CHECK(isolate, Local<Object>());
3210 raw_result = *returned;
Mads Ager (chromium) 2011/04/28 11:53:05 Please use return scope.Close instead. That will g
3211 }
3212 i::Handle<i::Object> result(raw_result);
3213 return Utils::ToLocal(result);
3214 }
3215
3216
3185 Local<v8::Object> Function::NewInstance() const { 3217 Local<v8::Object> Function::NewInstance() const {
3186 return NewInstance(0, NULL); 3218 return NewInstance(0, NULL);
3187 } 3219 }
3188 3220
3189 3221
3190 Local<v8::Object> Function::NewInstance(int argc, 3222 Local<v8::Object> Function::NewInstance(int argc,
3191 v8::Handle<v8::Value> argv[]) const { 3223 v8::Handle<v8::Value> argv[]) const {
3192 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); 3224 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
3193 ON_BAILOUT(isolate, "v8::Function::NewInstance()", 3225 ON_BAILOUT(isolate, "v8::Function::NewInstance()",
3194 return Local<v8::Object>()); 3226 return Local<v8::Object>());
(...skipping 2479 matching lines...) Expand 10 before | Expand all | Expand 10 after
5674 5706
5675 5707
5676 char* HandleScopeImplementer::Iterate(ObjectVisitor* v, char* storage) { 5708 char* HandleScopeImplementer::Iterate(ObjectVisitor* v, char* storage) {
5677 HandleScopeImplementer* scope_implementer = 5709 HandleScopeImplementer* scope_implementer =
5678 reinterpret_cast<HandleScopeImplementer*>(storage); 5710 reinterpret_cast<HandleScopeImplementer*>(storage);
5679 scope_implementer->IterateThis(v); 5711 scope_implementer->IterateThis(v);
5680 return storage + ArchiveSpacePerThread(); 5712 return storage + ArchiveSpacePerThread();
5681 } 5713 }
5682 5714
5683 } } // namespace v8::internal 5715 } } // namespace v8::internal
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698