OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "src/api.h" | 5 #include "src/api.h" |
6 | 6 |
7 #include <string.h> // For memcpy, strlen. | 7 #include <string.h> // For memcpy, strlen. |
8 #ifdef V8_USE_ADDRESS_SANITIZER | 8 #ifdef V8_USE_ADDRESS_SANITIZER |
9 #include <sanitizer/asan_interface.h> | 9 #include <sanitizer/asan_interface.h> |
10 #endif // V8_USE_ADDRESS_SANITIZER | 10 #endif // V8_USE_ADDRESS_SANITIZER |
(...skipping 838 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
849 i_isolate, callback, data, signature, length, false); | 849 i_isolate, callback, data, signature, length, false); |
850 } | 850 } |
851 | 851 |
852 | 852 |
853 Local<Signature> Signature::New(Isolate* isolate, | 853 Local<Signature> Signature::New(Isolate* isolate, |
854 Handle<FunctionTemplate> receiver, int argc, | 854 Handle<FunctionTemplate> receiver, int argc, |
855 Handle<FunctionTemplate> argv[]) { | 855 Handle<FunctionTemplate> argv[]) { |
856 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); | 856 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); |
857 LOG_API(i_isolate, "Signature::New"); | 857 LOG_API(i_isolate, "Signature::New"); |
858 ENTER_V8(i_isolate); | 858 ENTER_V8(i_isolate); |
859 i::Handle<i::Struct> struct_obj = | |
860 i_isolate->factory()->NewStruct(i::SIGNATURE_INFO_TYPE); | |
861 i::Handle<i::SignatureInfo> obj = | 859 i::Handle<i::SignatureInfo> obj = |
862 i::Handle<i::SignatureInfo>::cast(struct_obj); | 860 Utils::OpenHandle(*Signature::New(isolate, receiver)); |
863 if (!receiver.IsEmpty()) obj->set_receiver(*Utils::OpenHandle(*receiver)); | |
864 if (argc > 0) { | 861 if (argc > 0) { |
865 i::Handle<i::FixedArray> args = i_isolate->factory()->NewFixedArray(argc); | 862 i::Handle<i::FixedArray> args = i_isolate->factory()->NewFixedArray(argc); |
866 for (int i = 0; i < argc; i++) { | 863 for (int i = 0; i < argc; i++) { |
867 if (!argv[i].IsEmpty()) | 864 if (!argv[i].IsEmpty()) |
868 args->set(i, *Utils::OpenHandle(*argv[i])); | 865 args->set(i, *Utils::OpenHandle(*argv[i])); |
869 } | 866 } |
870 obj->set_args(*args); | 867 obj->set_args(*args); |
871 } | 868 } |
872 return Utils::ToLocal(obj); | 869 return Utils::ToLocal(obj); |
873 } | 870 } |
874 | 871 |
875 | 872 |
| 873 Local<Signature> Signature::New(Isolate* isolate, |
| 874 Handle<FunctionTemplate> receiver) { |
| 875 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); |
| 876 LOG_API(i_isolate, "Signature::New"); |
| 877 ENTER_V8(i_isolate); |
| 878 i::Handle<i::Struct> struct_obj = |
| 879 i_isolate->factory()->NewStruct(i::SIGNATURE_INFO_TYPE); |
| 880 // TODO(jochen): Replace SignatureInfo with FunctionTemplateInfo once the |
| 881 // deprecated API is deleted. |
| 882 i::Handle<i::SignatureInfo> obj = |
| 883 i::Handle<i::SignatureInfo>::cast(struct_obj); |
| 884 if (!receiver.IsEmpty()) obj->set_receiver(*Utils::OpenHandle(*receiver)); |
| 885 return Utils::ToLocal(obj); |
| 886 } |
| 887 |
| 888 |
876 Local<AccessorSignature> AccessorSignature::New( | 889 Local<AccessorSignature> AccessorSignature::New( |
877 Isolate* isolate, | 890 Isolate* isolate, |
878 Handle<FunctionTemplate> receiver) { | 891 Handle<FunctionTemplate> receiver) { |
879 return Utils::AccessorSignatureToLocal(Utils::OpenHandle(*receiver)); | 892 return Utils::AccessorSignatureToLocal(Utils::OpenHandle(*receiver)); |
880 } | 893 } |
881 | 894 |
882 | 895 |
883 Local<TypeSwitch> TypeSwitch::New(Handle<FunctionTemplate> type) { | 896 Local<TypeSwitch> TypeSwitch::New(Handle<FunctionTemplate> type) { |
884 Handle<FunctionTemplate> types[1] = { type }; | 897 Handle<FunctionTemplate> types[1] = { type }; |
885 return TypeSwitch::New(1, types); | 898 return TypeSwitch::New(1, types); |
(...skipping 6740 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7626 Isolate* isolate = reinterpret_cast<Isolate*>(info.GetIsolate()); | 7639 Isolate* isolate = reinterpret_cast<Isolate*>(info.GetIsolate()); |
7627 Address callback_address = | 7640 Address callback_address = |
7628 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); | 7641 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); |
7629 VMState<EXTERNAL> state(isolate); | 7642 VMState<EXTERNAL> state(isolate); |
7630 ExternalCallbackScope call_scope(isolate, callback_address); | 7643 ExternalCallbackScope call_scope(isolate, callback_address); |
7631 callback(info); | 7644 callback(info); |
7632 } | 7645 } |
7633 | 7646 |
7634 | 7647 |
7635 } } // namespace v8::internal | 7648 } } // namespace v8::internal |
OLD | NEW |