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

Side by Side Diff: src/api.cc

Issue 11631002: Extend API to allow setting length property for function templates. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Support length as argument to FunctionTempalte::New Created 8 years 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') | src/factory.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 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 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 1035 matching lines...) Expand 10 before | Expand all | Expand 10 after
1046 1046
1047 void FunctionTemplate::Inherit(v8::Handle<FunctionTemplate> value) { 1047 void FunctionTemplate::Inherit(v8::Handle<FunctionTemplate> value) {
1048 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); 1048 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
1049 if (IsDeadCheck(isolate, "v8::FunctionTemplate::Inherit()")) return; 1049 if (IsDeadCheck(isolate, "v8::FunctionTemplate::Inherit()")) return;
1050 ENTER_V8(isolate); 1050 ENTER_V8(isolate);
1051 Utils::OpenHandle(this)->set_parent_template(*Utils::OpenHandle(*value)); 1051 Utils::OpenHandle(this)->set_parent_template(*Utils::OpenHandle(*value));
1052 } 1052 }
1053 1053
1054 1054
1055 Local<FunctionTemplate> FunctionTemplate::New(InvocationCallback callback, 1055 Local<FunctionTemplate> FunctionTemplate::New(InvocationCallback callback,
1056 v8::Handle<Value> data, v8::Handle<Signature> signature) { 1056 v8::Handle<Value> data, v8::Handle<Signature> signature, int length) {
1057 i::Isolate* isolate = i::Isolate::Current(); 1057 i::Isolate* isolate = i::Isolate::Current();
1058 EnsureInitializedForIsolate(isolate, "v8::FunctionTemplate::New()"); 1058 EnsureInitializedForIsolate(isolate, "v8::FunctionTemplate::New()");
1059 LOG_API(isolate, "FunctionTemplate::New"); 1059 LOG_API(isolate, "FunctionTemplate::New");
1060 ENTER_V8(isolate); 1060 ENTER_V8(isolate);
1061 i::Handle<i::Struct> struct_obj = 1061 i::Handle<i::Struct> struct_obj =
1062 isolate->factory()->NewStruct(i::FUNCTION_TEMPLATE_INFO_TYPE); 1062 isolate->factory()->NewStruct(i::FUNCTION_TEMPLATE_INFO_TYPE);
1063 i::Handle<i::FunctionTemplateInfo> obj = 1063 i::Handle<i::FunctionTemplateInfo> obj =
1064 i::Handle<i::FunctionTemplateInfo>::cast(struct_obj); 1064 i::Handle<i::FunctionTemplateInfo>::cast(struct_obj);
1065 InitializeFunctionTemplate(obj); 1065 InitializeFunctionTemplate(obj);
1066 int next_serial_number = isolate->next_serial_number(); 1066 int next_serial_number = isolate->next_serial_number();
1067 isolate->set_next_serial_number(next_serial_number + 1); 1067 isolate->set_next_serial_number(next_serial_number + 1);
1068 obj->set_serial_number(i::Smi::FromInt(next_serial_number)); 1068 obj->set_serial_number(i::Smi::FromInt(next_serial_number));
1069 if (callback != 0) { 1069 if (callback != 0) {
1070 if (data.IsEmpty()) data = v8::Undefined(); 1070 if (data.IsEmpty()) data = v8::Undefined();
1071 Utils::ToLocal(obj)->SetCallHandler(callback, data); 1071 Utils::ToLocal(obj)->SetCallHandler(callback, data);
1072 } 1072 }
1073 obj->set_length(length);
1073 obj->set_undetectable(false); 1074 obj->set_undetectable(false);
1074 obj->set_needs_access_check(false); 1075 obj->set_needs_access_check(false);
1075 1076
1076 if (!signature.IsEmpty()) 1077 if (!signature.IsEmpty())
1077 obj->set_signature(*Utils::OpenHandle(*signature)); 1078 obj->set_signature(*Utils::OpenHandle(*signature));
1078 return Utils::ToLocal(obj); 1079 return Utils::ToLocal(obj);
1079 } 1080 }
1080 1081
1081 1082
1082 Local<Signature> Signature::New(Handle<FunctionTemplate> receiver, 1083 Local<Signature> Signature::New(Handle<FunctionTemplate> receiver,
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after
1233 Local<ObjectTemplate> templ = 1234 Local<ObjectTemplate> templ =
1234 ObjectTemplate::New(v8::Handle<FunctionTemplate>(this)); 1235 ObjectTemplate::New(v8::Handle<FunctionTemplate>(this));
1235 Utils::OpenHandle(this)->set_instance_template(*Utils::OpenHandle(*templ)); 1236 Utils::OpenHandle(this)->set_instance_template(*Utils::OpenHandle(*templ));
1236 } 1237 }
1237 i::Handle<i::ObjectTemplateInfo> result(i::ObjectTemplateInfo::cast( 1238 i::Handle<i::ObjectTemplateInfo> result(i::ObjectTemplateInfo::cast(
1238 Utils::OpenHandle(this)->instance_template())); 1239 Utils::OpenHandle(this)->instance_template()));
1239 return Utils::ToLocal(result); 1240 return Utils::ToLocal(result);
1240 } 1241 }
1241 1242
1242 1243
1244 void FunctionTemplate::SetLength(int length) {
1245 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
1246 if (IsDeadCheck(isolate, "v8::FunctionTemplate::SetLength()")) return;
1247 ENTER_V8(isolate);
1248 Utils::OpenHandle(this)->set_length(length);
1249 }
1250
1251
1243 void FunctionTemplate::SetClassName(Handle<String> name) { 1252 void FunctionTemplate::SetClassName(Handle<String> name) {
1244 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); 1253 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
1245 if (IsDeadCheck(isolate, "v8::FunctionTemplate::SetClassName()")) return; 1254 if (IsDeadCheck(isolate, "v8::FunctionTemplate::SetClassName()")) return;
1246 ENTER_V8(isolate); 1255 ENTER_V8(isolate);
1247 Utils::OpenHandle(this)->set_class_name(*Utils::OpenHandle(*name)); 1256 Utils::OpenHandle(this)->set_class_name(*Utils::OpenHandle(*name));
1248 } 1257 }
1249 1258
1250 1259
1251 void FunctionTemplate::SetHiddenPrototype(bool value) { 1260 void FunctionTemplate::SetHiddenPrototype(bool value) {
1252 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); 1261 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
(...skipping 5451 matching lines...) Expand 10 before | Expand all | Expand 10 after
6704 6713
6705 v->VisitPointers(blocks_.first(), first_block_limit_); 6714 v->VisitPointers(blocks_.first(), first_block_limit_);
6706 6715
6707 for (int i = 1; i < blocks_.length(); i++) { 6716 for (int i = 1; i < blocks_.length(); i++) {
6708 v->VisitPointers(blocks_[i], &blocks_[i][kHandleBlockSize]); 6717 v->VisitPointers(blocks_[i], &blocks_[i][kHandleBlockSize]);
6709 } 6718 }
6710 } 6719 }
6711 6720
6712 6721
6713 } } // namespace v8::internal 6722 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « include/v8.h ('k') | src/factory.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698