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 833 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
844 // function templates when the isolate is created for serialization. | 844 // function templates when the isolate is created for serialization. |
845 DCHECK(!i_isolate->serializer_enabled()); | 845 DCHECK(!i_isolate->serializer_enabled()); |
846 LOG_API(i_isolate, "FunctionTemplate::New"); | 846 LOG_API(i_isolate, "FunctionTemplate::New"); |
847 ENTER_V8(i_isolate); | 847 ENTER_V8(i_isolate); |
848 return FunctionTemplateNew( | 848 return FunctionTemplateNew( |
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, | |
855 Handle<FunctionTemplate> argv[]) { | |
856 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); | |
857 LOG_API(i_isolate, "Signature::New"); | |
858 ENTER_V8(i_isolate); | |
859 i::Handle<i::SignatureInfo> obj = | |
860 Utils::OpenHandle(*Signature::New(isolate, receiver)); | |
861 if (argc > 0) { | |
862 i::Handle<i::FixedArray> args = i_isolate->factory()->NewFixedArray(argc); | |
863 for (int i = 0; i < argc; i++) { | |
864 if (!argv[i].IsEmpty()) | |
865 args->set(i, *Utils::OpenHandle(*argv[i])); | |
866 } | |
867 obj->set_args(*args); | |
868 } | |
869 return Utils::ToLocal(obj); | |
870 } | |
871 | |
872 | |
873 Local<Signature> Signature::New(Isolate* isolate, | |
874 Handle<FunctionTemplate> receiver) { | 854 Handle<FunctionTemplate> receiver) { |
875 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); | 855 return Utils::SignatureToLocal(Utils::OpenHandle(*receiver)); |
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 } | 856 } |
887 | 857 |
888 | 858 |
889 Local<AccessorSignature> AccessorSignature::New( | 859 Local<AccessorSignature> AccessorSignature::New( |
890 Isolate* isolate, | 860 Isolate* isolate, |
891 Handle<FunctionTemplate> receiver) { | 861 Handle<FunctionTemplate> receiver) { |
892 return Utils::AccessorSignatureToLocal(Utils::OpenHandle(*receiver)); | 862 return Utils::AccessorSignatureToLocal(Utils::OpenHandle(*receiver)); |
893 } | 863 } |
894 | 864 |
895 | 865 |
(...skipping 6743 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7639 Isolate* isolate = reinterpret_cast<Isolate*>(info.GetIsolate()); | 7609 Isolate* isolate = reinterpret_cast<Isolate*>(info.GetIsolate()); |
7640 Address callback_address = | 7610 Address callback_address = |
7641 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); | 7611 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); |
7642 VMState<EXTERNAL> state(isolate); | 7612 VMState<EXTERNAL> state(isolate); |
7643 ExternalCallbackScope call_scope(isolate, callback_address); | 7613 ExternalCallbackScope call_scope(isolate, callback_address); |
7644 callback(info); | 7614 callback(info); |
7645 } | 7615 } |
7646 | 7616 |
7647 | 7617 |
7648 } } // namespace v8::internal | 7618 } } // namespace v8::internal |
OLD | NEW |