OLD | NEW |
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 964 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
975 void FunctionTemplate::Inherit(v8::Handle<FunctionTemplate> value) { | 975 void FunctionTemplate::Inherit(v8::Handle<FunctionTemplate> value) { |
976 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); | 976 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); |
977 if (IsDeadCheck(isolate, "v8::FunctionTemplate::Inherit()")) return; | 977 if (IsDeadCheck(isolate, "v8::FunctionTemplate::Inherit()")) return; |
978 ENTER_V8(isolate); | 978 ENTER_V8(isolate); |
979 Utils::OpenHandle(this)->set_parent_template(*Utils::OpenHandle(*value)); | 979 Utils::OpenHandle(this)->set_parent_template(*Utils::OpenHandle(*value)); |
980 } | 980 } |
981 | 981 |
982 | 982 |
983 template<typename Callback> | 983 template<typename Callback> |
984 static Local<FunctionTemplate> FunctionTemplateNew( | 984 static Local<FunctionTemplate> FunctionTemplateNew( |
985 Callback callback_in, | 985 Callback callback, |
986 v8::Handle<Value> data, | 986 v8::Handle<Value> data, |
987 v8::Handle<Signature> signature, | 987 v8::Handle<Signature> signature, |
988 int length) { | 988 int length) { |
989 i::Isolate* isolate = i::Isolate::Current(); | 989 i::Isolate* isolate = i::Isolate::Current(); |
990 EnsureInitializedForIsolate(isolate, "v8::FunctionTemplate::New()"); | 990 EnsureInitializedForIsolate(isolate, "v8::FunctionTemplate::New()"); |
991 LOG_API(isolate, "FunctionTemplate::New"); | 991 LOG_API(isolate, "FunctionTemplate::New"); |
992 ENTER_V8(isolate); | 992 ENTER_V8(isolate); |
993 i::Handle<i::Struct> struct_obj = | 993 i::Handle<i::Struct> struct_obj = |
994 isolate->factory()->NewStruct(i::FUNCTION_TEMPLATE_INFO_TYPE); | 994 isolate->factory()->NewStruct(i::FUNCTION_TEMPLATE_INFO_TYPE); |
995 i::Handle<i::FunctionTemplateInfo> obj = | 995 i::Handle<i::FunctionTemplateInfo> obj = |
996 i::Handle<i::FunctionTemplateInfo>::cast(struct_obj); | 996 i::Handle<i::FunctionTemplateInfo>::cast(struct_obj); |
997 InitializeFunctionTemplate(obj); | 997 InitializeFunctionTemplate(obj); |
998 int next_serial_number = isolate->next_serial_number(); | 998 int next_serial_number = isolate->next_serial_number(); |
999 isolate->set_next_serial_number(next_serial_number + 1); | 999 isolate->set_next_serial_number(next_serial_number + 1); |
1000 obj->set_serial_number(i::Smi::FromInt(next_serial_number)); | 1000 obj->set_serial_number(i::Smi::FromInt(next_serial_number)); |
1001 if (callback_in != 0) { | 1001 if (callback != 0) { |
1002 if (data.IsEmpty()) data = v8::Undefined(); | 1002 if (data.IsEmpty()) data = v8::Undefined(); |
1003 InvocationCallback callback = | |
1004 i::CallbackTable::Register(isolate, callback_in); | |
1005 Utils::ToLocal(obj)->SetCallHandler(callback, data); | 1003 Utils::ToLocal(obj)->SetCallHandler(callback, data); |
1006 } | 1004 } |
1007 obj->set_length(length); | 1005 obj->set_length(length); |
1008 obj->set_undetectable(false); | 1006 obj->set_undetectable(false); |
1009 obj->set_needs_access_check(false); | 1007 obj->set_needs_access_check(false); |
1010 | 1008 |
1011 if (!signature.IsEmpty()) | 1009 if (!signature.IsEmpty()) |
1012 obj->set_signature(*Utils::OpenHandle(*signature)); | 1010 obj->set_signature(*Utils::OpenHandle(*signature)); |
1013 return Utils::ToLocal(obj); | 1011 return Utils::ToLocal(obj); |
1014 } | 1012 } |
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1218 | 1216 |
1219 | 1217 |
1220 #define SET_FIELD_WRAPPED(obj, setter, cdata) do { \ | 1218 #define SET_FIELD_WRAPPED(obj, setter, cdata) do { \ |
1221 i::Handle<i::Object> foreign = FromCData(cdata); \ | 1219 i::Handle<i::Object> foreign = FromCData(cdata); \ |
1222 (obj)->setter(*foreign); \ | 1220 (obj)->setter(*foreign); \ |
1223 } while (false) | 1221 } while (false) |
1224 | 1222 |
1225 | 1223 |
1226 template<typename Callback> | 1224 template<typename Callback> |
1227 static void FunctionTemplateSetCallHandler(FunctionTemplate* function_template, | 1225 static void FunctionTemplateSetCallHandler(FunctionTemplate* function_template, |
1228 Callback callback, | 1226 Callback callback_in, |
1229 v8::Handle<Value> data) { | 1227 v8::Handle<Value> data) { |
1230 i::Isolate* isolate = Utils::OpenHandle(function_template)->GetIsolate(); | 1228 i::Isolate* isolate = Utils::OpenHandle(function_template)->GetIsolate(); |
1231 if (IsDeadCheck(isolate, "v8::FunctionTemplate::SetCallHandler()")) return; | 1229 if (IsDeadCheck(isolate, "v8::FunctionTemplate::SetCallHandler()")) return; |
1232 ENTER_V8(isolate); | 1230 ENTER_V8(isolate); |
1233 i::HandleScope scope(isolate); | 1231 i::HandleScope scope(isolate); |
1234 i::Handle<i::Struct> struct_obj = | 1232 i::Handle<i::Struct> struct_obj = |
1235 isolate->factory()->NewStruct(i::CALL_HANDLER_INFO_TYPE); | 1233 isolate->factory()->NewStruct(i::CALL_HANDLER_INFO_TYPE); |
1236 i::Handle<i::CallHandlerInfo> obj = | 1234 i::Handle<i::CallHandlerInfo> obj = |
1237 i::Handle<i::CallHandlerInfo>::cast(struct_obj); | 1235 i::Handle<i::CallHandlerInfo>::cast(struct_obj); |
| 1236 InvocationCallback callback = |
| 1237 i::CallbackTable::Register(isolate, callback_in); |
1238 SET_FIELD_WRAPPED(obj, set_callback, callback); | 1238 SET_FIELD_WRAPPED(obj, set_callback, callback); |
1239 if (data.IsEmpty()) data = v8::Undefined(); | 1239 if (data.IsEmpty()) data = v8::Undefined(); |
1240 obj->set_data(*Utils::OpenHandle(*data)); | 1240 obj->set_data(*Utils::OpenHandle(*data)); |
1241 Utils::OpenHandle(function_template)->set_call_code(*obj); | 1241 Utils::OpenHandle(function_template)->set_call_code(*obj); |
1242 } | 1242 } |
1243 | 1243 |
1244 void FunctionTemplate::SetCallHandler(InvocationCallback callback, | 1244 void FunctionTemplate::SetCallHandler(InvocationCallback callback, |
1245 v8::Handle<Value> data) { | 1245 v8::Handle<Value> data) { |
1246 FunctionTemplateSetCallHandler(this, callback, data); | 1246 FunctionTemplateSetCallHandler(this, callback, data); |
1247 } | 1247 } |
(...skipping 6623 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7871 | 7871 |
7872 v->VisitPointers(blocks_.first(), first_block_limit_); | 7872 v->VisitPointers(blocks_.first(), first_block_limit_); |
7873 | 7873 |
7874 for (int i = 1; i < blocks_.length(); i++) { | 7874 for (int i = 1; i < blocks_.length(); i++) { |
7875 v->VisitPointers(blocks_[i], &blocks_[i][kHandleBlockSize]); | 7875 v->VisitPointers(blocks_[i], &blocks_[i][kHandleBlockSize]); |
7876 } | 7876 } |
7877 } | 7877 } |
7878 | 7878 |
7879 | 7879 |
7880 } } // namespace v8::internal | 7880 } } // namespace v8::internal |
OLD | NEW |