OLD | NEW |
1 // Copyright 2011, Google Inc. | 1 // Copyright 2011, Google Inc. |
2 // All rights reserved. | 2 // All rights reserved. |
3 // | 3 // |
4 // Redistribution and use in source and binary forms, with or without | 4 // Redistribution and use in source and binary forms, with or without |
5 // modification, are permitted provided that the following conditions are | 5 // modification, are permitted provided that the following conditions are |
6 // met: | 6 // met: |
7 // | 7 // |
8 // * Redistributions of source code must retain the above copyright | 8 // * Redistributions of source code must retain the above copyright |
9 // notice, this list of conditions and the following disclaimer. | 9 // notice, this list of conditions and the following disclaimer. |
10 // * Redistributions in binary form must reproduce the above | 10 // * Redistributions in binary form must reproduce the above |
(...skipping 747 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
758 PassRefPtr<WTF::ArrayBufferView> DartUtilities::dartToArrayBufferView(Dart_Handl
e array, Dart_Handle& exception) | 758 PassRefPtr<WTF::ArrayBufferView> DartUtilities::dartToArrayBufferView(Dart_Handl
e array, Dart_Handle& exception) |
759 { | 759 { |
760 return dartToArrayBufferViewHelper(array, exception, false); | 760 return dartToArrayBufferViewHelper(array, exception, false); |
761 } | 761 } |
762 | 762 |
763 PassRefPtr<WTF::ArrayBufferView> DartUtilities::dartToExternalizedArrayBufferVie
w(Dart_Handle array, Dart_Handle& exception) | 763 PassRefPtr<WTF::ArrayBufferView> DartUtilities::dartToExternalizedArrayBufferVie
w(Dart_Handle array, Dart_Handle& exception) |
764 { | 764 { |
765 return dartToArrayBufferViewHelper(array, exception, true); | 765 return dartToArrayBufferViewHelper(array, exception, true); |
766 } | 766 } |
767 | 767 |
| 768 PassRefPtr<WTF::Int8Array> DartUtilities::dartToInt8ArrayWithNullCheck(Dart_Hand
le handle, Dart_Handle& exception) |
| 769 { |
| 770 return Dart_IsNull(handle) ? nullptr : dartToInt8Array(handle, exception); |
| 771 } |
| 772 |
768 PassRefPtr<WTF::Int8Array> DartUtilities::dartToInt8Array(Dart_Handle handle, Da
rt_Handle& exception) | 773 PassRefPtr<WTF::Int8Array> DartUtilities::dartToInt8Array(Dart_Handle handle, Da
rt_Handle& exception) |
769 { | 774 { |
770 RefPtr<ArrayBufferView> view = DartUtilities::dartToArrayBufferView(handle,
exception); | 775 RefPtr<ArrayBufferView> view = DartUtilities::dartToArrayBufferView(handle,
exception); |
771 if (exception) | 776 if (exception) |
772 return nullptr; | 777 return nullptr; |
773 if (view->type() == ArrayBufferView::TypeInt8) | 778 if (view->type() == ArrayBufferView::TypeInt8) |
774 return reinterpret_cast<Int8Array*>(view.get()); | 779 return reinterpret_cast<Int8Array*>(view.get()); |
775 exception = Dart_NewStringFromCString("Int8List expected"); | 780 exception = Dart_NewStringFromCString("Int8List expected"); |
776 return nullptr; | 781 return nullptr; |
777 } | 782 } |
778 | 783 |
| 784 PassRefPtr<WTF::Int8Array> DartUtilities::dartToInt8ArrayWithNullCheck(Dart_Nati
veArguments args, int idx, Dart_Handle& exception) |
| 785 { |
| 786 Dart_Handle object = Dart_GetNativeArgument(args, idx); |
| 787 return dartToInt8ArrayWithNullCheck(object, exception); |
| 788 } |
| 789 |
779 PassRefPtr<WTF::Int8Array> DartUtilities::dartToInt8Array(Dart_NativeArguments a
rgs, int idx, Dart_Handle& exception) | 790 PassRefPtr<WTF::Int8Array> DartUtilities::dartToInt8Array(Dart_NativeArguments a
rgs, int idx, Dart_Handle& exception) |
780 { | 791 { |
781 Dart_Handle object = Dart_GetNativeArgument(args, idx); | 792 Dart_Handle object = Dart_GetNativeArgument(args, idx); |
782 return dartToInt8Array(object, exception); | 793 return dartToInt8Array(object, exception); |
783 } | 794 } |
784 | 795 |
| 796 PassRefPtr<WTF::Int32Array> DartUtilities::dartToInt32ArrayWithNullCheck(Dart_Ha
ndle handle, Dart_Handle& exception) |
| 797 { |
| 798 return Dart_IsNull(handle) ? nullptr : dartToInt32Array(handle, exception); |
| 799 } |
| 800 |
785 PassRefPtr<WTF::Int32Array> DartUtilities::dartToInt32Array(Dart_Handle handle,
Dart_Handle& exception) | 801 PassRefPtr<WTF::Int32Array> DartUtilities::dartToInt32Array(Dart_Handle handle,
Dart_Handle& exception) |
786 { | 802 { |
787 RefPtr<ArrayBufferView> view = DartUtilities::dartToArrayBufferView(handle,
exception); | 803 RefPtr<ArrayBufferView> view = DartUtilities::dartToArrayBufferView(handle,
exception); |
788 if (exception) | 804 if (exception) |
789 return nullptr; | 805 return nullptr; |
790 if (view->type() == ArrayBufferView::TypeInt32) | 806 if (view->type() == ArrayBufferView::TypeInt32) |
791 return reinterpret_cast<Int32Array*>(view.get()); | 807 return reinterpret_cast<Int32Array*>(view.get()); |
792 exception = Dart_NewStringFromCString("Int32List expected"); | 808 exception = Dart_NewStringFromCString("Int32List expected"); |
793 return nullptr; | 809 return nullptr; |
794 } | 810 } |
795 | 811 |
| 812 PassRefPtr<WTF::Int32Array> DartUtilities::dartToInt32ArrayWithNullCheck(Dart_Na
tiveArguments args, int idx, Dart_Handle& exception) |
| 813 { |
| 814 Dart_Handle object = Dart_GetNativeArgument(args, idx); |
| 815 return dartToInt32ArrayWithNullCheck(object, exception); |
| 816 } |
| 817 |
796 PassRefPtr<WTF::Int32Array> DartUtilities::dartToInt32Array(Dart_NativeArguments
args, int idx, Dart_Handle& exception) | 818 PassRefPtr<WTF::Int32Array> DartUtilities::dartToInt32Array(Dart_NativeArguments
args, int idx, Dart_Handle& exception) |
797 { | 819 { |
798 Dart_Handle object = Dart_GetNativeArgument(args, idx); | 820 Dart_Handle object = Dart_GetNativeArgument(args, idx); |
799 return dartToInt32Array(object, exception); | 821 return dartToInt32Array(object, exception); |
800 } | 822 } |
801 | 823 |
| 824 PassRefPtr<WTF::Uint8ClampedArray> DartUtilities::dartToUint8ClampedArrayWithNul
lCheck(Dart_Handle handle, Dart_Handle& exception) |
| 825 { |
| 826 return Dart_IsNull(handle) ? nullptr : dartToUint8ClampedArray(handle, excep
tion); |
| 827 } |
| 828 |
802 PassRefPtr<WTF::Uint8ClampedArray> DartUtilities::dartToUint8ClampedArray(Dart_H
andle handle, Dart_Handle& exception) | 829 PassRefPtr<WTF::Uint8ClampedArray> DartUtilities::dartToUint8ClampedArray(Dart_H
andle handle, Dart_Handle& exception) |
803 { | 830 { |
804 RefPtr<ArrayBufferView> view = DartUtilities::dartToArrayBufferView(handle,
exception); | 831 RefPtr<ArrayBufferView> view = DartUtilities::dartToArrayBufferView(handle,
exception); |
805 if (exception) | 832 if (exception) |
806 return nullptr; | 833 return nullptr; |
807 if (view->type() == ArrayBufferView::TypeUint8Clamped) | 834 if (view->type() == ArrayBufferView::TypeUint8Clamped) |
808 return reinterpret_cast<Uint8ClampedArray*>(view.get()); | 835 return reinterpret_cast<Uint8ClampedArray*>(view.get()); |
809 exception = Dart_NewStringFromCString("Uint8ClampedList expected"); | 836 exception = Dart_NewStringFromCString("Uint8ClampedList expected"); |
810 return nullptr; | 837 return nullptr; |
811 } | 838 } |
812 | 839 |
| 840 PassRefPtr<WTF::Uint8ClampedArray> DartUtilities::dartToUint8ClampedArrayWithNul
lCheck(Dart_NativeArguments args, int idx, Dart_Handle& exception) |
| 841 { |
| 842 Dart_Handle object = Dart_GetNativeArgument(args, idx); |
| 843 return dartToUint8ClampedArrayWithNullCheck(object, exception); |
| 844 } |
| 845 |
813 PassRefPtr<WTF::Uint8ClampedArray> DartUtilities::dartToUint8ClampedArray(Dart_N
ativeArguments args, int idx, Dart_Handle& exception) | 846 PassRefPtr<WTF::Uint8ClampedArray> DartUtilities::dartToUint8ClampedArray(Dart_N
ativeArguments args, int idx, Dart_Handle& exception) |
814 { | 847 { |
815 Dart_Handle object = Dart_GetNativeArgument(args, idx); | 848 Dart_Handle object = Dart_GetNativeArgument(args, idx); |
816 return dartToUint8ClampedArray(object, exception); | 849 return dartToUint8ClampedArray(object, exception); |
817 } | 850 } |
818 | 851 |
| 852 PassRefPtr<WTF::Uint8Array> DartUtilities::dartToUint8ArrayWithNullCheck(Dart_Ha
ndle handle, Dart_Handle& exception) |
| 853 { |
| 854 return Dart_IsNull(handle) ? nullptr : dartToUint8Array(handle, exception); |
| 855 } |
| 856 |
819 PassRefPtr<WTF::Uint8Array> DartUtilities::dartToUint8Array(Dart_Handle handle,
Dart_Handle& exception) | 857 PassRefPtr<WTF::Uint8Array> DartUtilities::dartToUint8Array(Dart_Handle handle,
Dart_Handle& exception) |
820 { | 858 { |
821 RefPtr<ArrayBufferView> view = DartUtilities::dartToArrayBufferView(handle,
exception); | 859 RefPtr<ArrayBufferView> view = DartUtilities::dartToArrayBufferView(handle,
exception); |
822 if (exception) | 860 if (exception) |
823 return nullptr; | 861 return nullptr; |
824 if (view->type() == ArrayBufferView::TypeUint8) | 862 if (view->type() == ArrayBufferView::TypeUint8) |
825 return reinterpret_cast<Uint8Array*>(view.get()); | 863 return reinterpret_cast<Uint8Array*>(view.get()); |
826 exception = Dart_NewStringFromCString("Uint8List expected"); | 864 exception = Dart_NewStringFromCString("Uint8List expected"); |
827 return nullptr; | 865 return nullptr; |
828 } | 866 } |
829 | 867 |
| 868 PassRefPtr<WTF::Uint8Array> DartUtilities::dartToUint8ArrayWithNullCheck(Dart_Na
tiveArguments args, int idx, Dart_Handle& exception) |
| 869 { |
| 870 Dart_Handle object = Dart_GetNativeArgument(args, idx); |
| 871 return dartToUint8ArrayWithNullCheck(object, exception); |
| 872 } |
| 873 |
830 PassRefPtr<WTF::Uint8Array> DartUtilities::dartToUint8Array(Dart_NativeArguments
args, int idx, Dart_Handle& exception) | 874 PassRefPtr<WTF::Uint8Array> DartUtilities::dartToUint8Array(Dart_NativeArguments
args, int idx, Dart_Handle& exception) |
831 { | 875 { |
832 Dart_Handle object = Dart_GetNativeArgument(args, idx); | 876 Dart_Handle object = Dart_GetNativeArgument(args, idx); |
833 return dartToUint8Array(object, exception); | 877 return dartToUint8Array(object, exception); |
834 } | 878 } |
835 | 879 |
| 880 PassRefPtr<WTF::Float32Array> DartUtilities::dartToFloat32ArrayWithNullCheck(Dar
t_Handle handle, Dart_Handle& exception) |
| 881 { |
| 882 return Dart_IsNull(handle) ? nullptr : dartToFloat32Array(handle, exception)
; |
| 883 } |
| 884 |
836 PassRefPtr<WTF::Float32Array> DartUtilities::dartToFloat32Array(Dart_Handle hand
le, Dart_Handle& exception) | 885 PassRefPtr<WTF::Float32Array> DartUtilities::dartToFloat32Array(Dart_Handle hand
le, Dart_Handle& exception) |
837 { | 886 { |
838 RefPtr<ArrayBufferView> view = DartUtilities::dartToArrayBufferView(handle,
exception); | 887 RefPtr<ArrayBufferView> view = DartUtilities::dartToArrayBufferView(handle,
exception); |
839 if (exception) | 888 if (exception) |
840 return nullptr; | 889 return nullptr; |
841 if (view->type() == ArrayBufferView::TypeFloat32) | 890 if (view->type() == ArrayBufferView::TypeFloat32) |
842 return reinterpret_cast<Float32Array*>(view.get()); | 891 return reinterpret_cast<Float32Array*>(view.get()); |
843 exception = Dart_NewStringFromCString("Float32List expected"); | 892 exception = Dart_NewStringFromCString("Float32List expected"); |
844 return nullptr; | 893 return nullptr; |
845 } | 894 } |
846 | 895 |
| 896 PassRefPtr<WTF::Float32Array> DartUtilities::dartToFloat32ArrayWithNullCheck(Dar
t_NativeArguments args, int idx, Dart_Handle& exception) |
| 897 { |
| 898 Dart_Handle object = Dart_GetNativeArgument(args, idx); |
| 899 return dartToFloat32ArrayWithNullCheck(object, exception); |
| 900 } |
| 901 |
847 PassRefPtr<WTF::Float32Array> DartUtilities::dartToFloat32Array(Dart_NativeArgum
ents args, int idx, Dart_Handle& exception) | 902 PassRefPtr<WTF::Float32Array> DartUtilities::dartToFloat32Array(Dart_NativeArgum
ents args, int idx, Dart_Handle& exception) |
848 { | 903 { |
849 Dart_Handle object = Dart_GetNativeArgument(args, idx); | 904 Dart_Handle object = Dart_GetNativeArgument(args, idx); |
850 return dartToFloat32Array(object, exception); | 905 return dartToFloat32Array(object, exception); |
851 } | 906 } |
852 | 907 |
853 SQLValue DartUtilities::toSQLValue(Dart_Handle object, Dart_Handle& exception) | 908 SQLValue DartUtilities::toSQLValue(Dart_Handle object, Dart_Handle& exception) |
854 { | 909 { |
855 if (Dart_IsNull(object)) | 910 if (Dart_IsNull(object)) |
856 return SQLValue(); | 911 return SQLValue(); |
(...skipping 350 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1207 if (!v) { | 1262 if (!v) { |
1208 return 0; | 1263 return 0; |
1209 } | 1264 } |
1210 ASSERT(valueLen > 0 && static_cast<size_t>(valueLen) > strlen(v)); | 1265 ASSERT(valueLen > 0 && static_cast<size_t>(valueLen) > strlen(v)); |
1211 strncpy(value, v, valueLen); | 1266 strncpy(value, v, valueLen); |
1212 value[valueLen - 1] = '\0'; | 1267 value[valueLen - 1] = '\0'; |
1213 return strlen(value); | 1268 return strlen(value); |
1214 #endif | 1269 #endif |
1215 } | 1270 } |
1216 } | 1271 } |
OLD | NEW |