MIRROR: javascript for ๐Ÿœ's, a tiny runtime with big ambitions
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

add DataView setInt16, setInt32, setFloat32, getFloat64, setFloat64 methods

+355 -19
+117
examples/spec/dataview.js
··· 1 + import { test, summary } from './helpers.js'; 2 + 3 + console.log('DataView Tests\n'); 4 + 5 + // Basic DataView creation 6 + const buffer = new ArrayBuffer(16); 7 + const dv = new DataView(buffer); 8 + 9 + test('DataView byteLength', dv.byteLength, 16); 10 + test('DataView byteOffset', dv.byteOffset, 0); 11 + 12 + // DataView with offset 13 + const dv2 = new DataView(buffer, 4); 14 + test('DataView with offset byteLength', dv2.byteLength, 12); 15 + test('DataView with offset byteOffset', dv2.byteOffset, 4); 16 + 17 + // DataView with offset and length 18 + const dv3 = new DataView(buffer, 4, 8); 19 + test('DataView with offset+length byteLength', dv3.byteLength, 8); 20 + test('DataView with offset+length byteOffset', dv3.byteOffset, 4); 21 + 22 + // Uint8 get/set 23 + dv.setUint8(0, 255); 24 + test('setUint8/getUint8', dv.getUint8(0), 255); 25 + 26 + dv.setUint8(1, 0); 27 + test('setUint8/getUint8 zero', dv.getUint8(1), 0); 28 + 29 + // Int16 get/set - Big Endian (default) 30 + dv.setInt16(0, 0x1234); 31 + test('setInt16 BE / getInt16 BE', dv.getInt16(0), 0x1234); 32 + test('setInt16 BE byte 0', dv.getUint8(0), 0x12); 33 + test('setInt16 BE byte 1', dv.getUint8(1), 0x34); 34 + 35 + // Int16 get/set - Little Endian 36 + dv.setInt16(2, 0x5678, true); 37 + test('setInt16 LE / getInt16 LE', dv.getInt16(2, true), 0x5678); 38 + test('setInt16 LE byte 0', dv.getUint8(2), 0x78); 39 + test('setInt16 LE byte 1', dv.getUint8(3), 0x56); 40 + 41 + // Read Int16 LE as BE and vice versa 42 + test('setInt16 LE / getInt16 BE', dv.getInt16(2, false), 0x7856); 43 + 44 + // Int32 get/set - Big Endian (default) 45 + dv.setInt32(4, 0x12345678); 46 + test('setInt32 BE / getInt32 BE', dv.getInt32(4), 0x12345678); 47 + test('setInt32 BE byte 0', dv.getUint8(4), 0x12); 48 + test('setInt32 BE byte 1', dv.getUint8(5), 0x34); 49 + test('setInt32 BE byte 2', dv.getUint8(6), 0x56); 50 + test('setInt32 BE byte 3', dv.getUint8(7), 0x78); 51 + 52 + // Int32 get/set - Little Endian 53 + dv.setInt32(8, 0xAABBCCDD, true); 54 + test('setInt32 LE / getInt32 LE', dv.getInt32(8, true), 0xAABBCCDD | 0); 55 + test('setInt32 LE byte 0', dv.getUint8(8), 0xDD); 56 + test('setInt32 LE byte 1', dv.getUint8(9), 0xCC); 57 + test('setInt32 LE byte 2', dv.getUint8(10), 0xBB); 58 + test('setInt32 LE byte 3', dv.getUint8(11), 0xAA); 59 + 60 + // Float32 get/set 61 + const testFloat = 3.14; 62 + dv.setFloat32(0, testFloat); 63 + const readFloat = dv.getFloat32(0); 64 + test('setFloat32/getFloat32 BE approx', Math.abs(readFloat - testFloat) < 0.001, true); 65 + 66 + dv.setFloat32(4, testFloat, true); 67 + const readFloatLE = dv.getFloat32(4, true); 68 + test('setFloat32/getFloat32 LE approx', Math.abs(readFloatLE - testFloat) < 0.001, true); 69 + 70 + // Float64 get/set 71 + const testDouble = 3.141592653589793; 72 + dv.setFloat64(0, testDouble); 73 + test('setFloat64/getFloat64 BE', dv.getFloat64(0), testDouble); 74 + 75 + dv.setFloat64(8, testDouble, true); 76 + test('setFloat64/getFloat64 LE', dv.getFloat64(8, true), testDouble); 77 + 78 + // Negative numbers 79 + dv.setInt16(0, -1234); 80 + test('setInt16/getInt16 negative BE', dv.getInt16(0), -1234); 81 + 82 + dv.setInt16(2, -1234, true); 83 + test('setInt16/getInt16 negative LE', dv.getInt16(2, true), -1234); 84 + 85 + dv.setInt32(4, -123456789); 86 + test('setInt32/getInt32 negative BE', dv.getInt32(4), -123456789); 87 + 88 + dv.setInt32(8, -123456789, true); 89 + test('setInt32/getInt32 negative LE', dv.getInt32(8, true), -123456789); 90 + 91 + // Test that DataView shares buffer with TypedArrays 92 + const sharedBuffer = new ArrayBuffer(8); 93 + const sharedDV = new DataView(sharedBuffer); 94 + const sharedU8 = new Uint8Array(sharedBuffer); 95 + 96 + sharedDV.setInt32(0, 0x01020304); 97 + test('DataView/TypedArray share buffer byte 0', sharedU8[0], 0x01); 98 + test('DataView/TypedArray share buffer byte 1', sharedU8[1], 0x02); 99 + test('DataView/TypedArray share buffer byte 2', sharedU8[2], 0x03); 100 + test('DataView/TypedArray share buffer byte 3', sharedU8[3], 0x04); 101 + 102 + // Modify via TypedArray, read via DataView 103 + sharedU8[4] = 0xAA; 104 + sharedU8[5] = 0xBB; 105 + sharedU8[6] = 0xCC; 106 + sharedU8[7] = 0xDD; 107 + test('TypedArray write / DataView read', sharedDV.getInt32(4), 0xAABBCCDD | 0); 108 + 109 + // Node.js style example from the prompt 110 + const exampleBuffer = new ArrayBuffer(16); 111 + const exampleView = new DataView(exampleBuffer); 112 + exampleView.setInt32(0, 123456); 113 + exampleView.setInt16(4, 32000); 114 + test('Node example getInt32', exampleView.getInt32(0), 123456); 115 + test('Node example getInt16', exampleView.getInt16(4), 32000); 116 + 117 + summary();
+4
include/ant.h
··· 58 58 bool js_truthy(struct js *, jsval_t); 59 59 void js_setmaxcss(struct js *, size_t); 60 60 61 + uint32_t js_to_uint32(double d); 62 + int32_t js_to_int32(double d); 63 + 61 64 bool js_chkargs(jsval_t *, int, const char *); 62 65 void js_set_filename(struct js *, const char *); 63 66 void js_stats(struct js *, size_t *total, size_t *min, size_t *cstacksize); ··· 91 94 jsval_t js_mkerr_typed(struct js *js, js_err_type_t err_type, const char *fmt, ...); 92 95 jsval_t js_mkfun(jsval_t (*fn)(struct js *, jsval_t *, int)); 93 96 jsval_t js_heavy_mkfun(struct js *js, jsval_t (*fn)(struct js *, jsval_t *, int), jsval_t data); 97 + jsval_t js_mkprop_fast(struct js *js, jsval_t obj, const char *key, size_t len, jsval_t v); 94 98 95 99 jsval_t js_call(struct js *js, jsval_t func, jsval_t *args, int nargs); 96 100 jsval_t js_call_with_this(struct js *js, jsval_t func, jsval_t this_val, jsval_t *args, int nargs);
+8 -2
src/ant.c
··· 722 722 return vdata(proto) == vdata(expected_proto); 723 723 } 724 724 725 - static uint32_t js_to_uint32(double d) { 725 + uint32_t js_to_uint32(double d) { 726 726 if (!isfinite(d) || d == 0) return 0; 727 727 double sign = (d < 0) ? -1.0 : 1.0; 728 728 double posInt = sign * floor(fabs(d)); ··· 731 731 return (uint32_t) val; 732 732 } 733 733 734 - static int32_t js_to_int32(double d) { 734 + int32_t js_to_int32(double d) { 735 735 uint32_t uint32 = js_to_uint32(d); 736 736 if (uint32 >= 2147483648U) return (int32_t)(uint32 - 4294967296.0); 737 737 return (int32_t) uint32; ··· 3159 3159 3160 3160 jsoff_t prop_header = (b & ~(3U | FLAGMASK)) | T_PROP | flags; 3161 3161 return mkentity(js, prop_header, buf, sizeof(buf)); 3162 + } 3163 + 3164 + jsval_t js_mkprop_fast(struct js *js, jsval_t obj, const char *key, size_t len, jsval_t v) { 3165 + jsval_t k = js_mkstr(js, key, len); 3166 + if (is_err(k)) return k; 3167 + return mkprop_fast(js, obj, k, v, 0); 3162 3168 } 3163 3169 3164 3170 static jsval_t mkslot(struct js *js, jsval_t obj, internal_slot_t slot, jsval_t v) {
+226 -17
src/modules/buffer.c
··· 56 56 static jsval_t js_dataview_getUint8(struct js *js, jsval_t *args, int nargs); 57 57 static jsval_t js_dataview_setUint8(struct js *js, jsval_t *args, int nargs); 58 58 static jsval_t js_dataview_getInt16(struct js *js, jsval_t *args, int nargs); 59 + static jsval_t js_dataview_setInt16(struct js *js, jsval_t *args, int nargs); 59 60 static jsval_t js_dataview_getInt32(struct js *js, jsval_t *args, int nargs); 61 + static jsval_t js_dataview_setInt32(struct js *js, jsval_t *args, int nargs); 60 62 static jsval_t js_dataview_getFloat32(struct js *js, jsval_t *args, int nargs); 63 + static jsval_t js_dataview_setFloat32(struct js *js, jsval_t *args, int nargs); 64 + static jsval_t js_dataview_getFloat64(struct js *js, jsval_t *args, int nargs); 65 + static jsval_t js_dataview_setFloat64(struct js *js, jsval_t *args, int nargs); 61 66 static jsval_t js_buffer_toString(struct js *js, jsval_t *args, int nargs); 62 67 static jsval_t js_buffer_toBase64(struct js *js, jsval_t *args, int nargs); 63 68 static jsval_t js_buffer_write(struct js *js, jsval_t *args, int nargs); ··· 583 588 buffer->ref_count++; 584 589 585 590 jsval_t obj = js_mkobj(js); 586 - js_set(js, obj, "_dataview_data", js_mknum((double)(uintptr_t)dv_data)); 591 + jsval_t proto = js_get_ctor_proto(js, "DataView", 8); 592 + if (js_type(proto) == JS_OBJ) js_set_proto(js, obj, proto); 593 + 594 + js_set_slot(js, obj, SLOT_DATA, js_mknum((double)(uintptr_t)dv_data)); 587 595 js_set(js, obj, "byteLength", js_mknum((double)byte_length)); 588 596 js_set(js, obj, "byteOffset", js_mknum((double)byte_offset)); 589 - js_set(js, obj, "getUint8", js_mkfun(js_dataview_getUint8)); 590 - js_set(js, obj, "setUint8", js_mkfun(js_dataview_setUint8)); 591 - js_set(js, obj, "getInt16", js_mkfun(js_dataview_getInt16)); 592 - js_set(js, obj, "getInt32", js_mkfun(js_dataview_getInt32)); 593 - js_set(js, obj, "getFloat32", js_mkfun(js_dataview_getFloat32)); 594 597 595 598 return obj; 596 599 } ··· 600 603 if (nargs < 1) return js_mkerr(js, "getUint8 requires byteOffset"); 601 604 602 605 jsval_t this_val = js_getthis(js); 603 - jsval_t dv_data_val = js_get(js, this_val, "_dataview_data"); 606 + jsval_t dv_data_val = js_get_slot(js, this_val, SLOT_DATA); 604 607 605 608 if (js_type(dv_data_val) != JS_NUM) { 606 609 return js_mkerr(js, "Not a DataView"); ··· 622 625 if (nargs < 2) return js_mkerr(js, "setUint8 requires byteOffset and value"); 623 626 624 627 jsval_t this_val = js_getthis(js); 625 - jsval_t dv_data_val = js_get(js, this_val, "_dataview_data"); 628 + jsval_t dv_data_val = js_get_slot(js, this_val, SLOT_DATA); 626 629 627 630 if (js_type(dv_data_val) != JS_NUM) { 628 631 return js_mkerr(js, "Not a DataView"); ··· 630 633 631 634 DataViewData *dv = (DataViewData *)(uintptr_t)js_getnum(dv_data_val); 632 635 size_t offset = (size_t)js_getnum(args[0]); 633 - uint8_t value = (uint8_t)js_getnum(args[1]); 636 + uint8_t value = (uint8_t)js_to_uint32(js_getnum(args[1])); 634 637 635 638 if (offset >= dv->byte_length) { 636 639 return js_mkerr(js, "Offset out of bounds"); ··· 645 648 if (nargs < 1) return js_mkerr(js, "getInt16 requires byteOffset"); 646 649 647 650 jsval_t this_val = js_getthis(js); 648 - jsval_t dv_data_val = js_get(js, this_val, "_dataview_data"); 651 + jsval_t dv_data_val = js_get_slot(js, this_val, SLOT_DATA); 649 652 650 653 if (js_type(dv_data_val) != JS_NUM) { 651 654 return js_mkerr(js, "Not a DataView"); ··· 676 679 if (nargs < 1) return js_mkerr(js, "getInt32 requires byteOffset"); 677 680 678 681 jsval_t this_val = js_getthis(js); 679 - jsval_t dv_data_val = js_get(js, this_val, "_dataview_data"); 682 + jsval_t dv_data_val = js_get_slot(js, this_val, SLOT_DATA); 680 683 681 684 if (js_type(dv_data_val) != JS_NUM) { 682 685 return js_mkerr(js, "Not a DataView"); ··· 707 710 if (nargs < 1) return js_mkerr(js, "getFloat32 requires byteOffset"); 708 711 709 712 jsval_t this_val = js_getthis(js); 710 - jsval_t dv_data_val = js_get(js, this_val, "_dataview_data"); 713 + jsval_t dv_data_val = js_get_slot(js, this_val, SLOT_DATA); 711 714 712 715 if (js_type(dv_data_val) != JS_NUM) { 713 716 return js_mkerr(js, "Not a DataView"); ··· 735 738 return js_mknum((double)value); 736 739 } 737 740 741 + // DataView.prototype.setInt16(byteOffset, value, littleEndian) 742 + static jsval_t js_dataview_setInt16(struct js *js, jsval_t *args, int nargs) { 743 + if (nargs < 2) return js_mkerr(js, "setInt16 requires byteOffset and value"); 744 + 745 + jsval_t this_val = js_getthis(js); 746 + jsval_t dv_data_val = js_get_slot(js, this_val, SLOT_DATA); 747 + 748 + if (js_type(dv_data_val) != JS_NUM) { 749 + return js_mkerr(js, "Not a DataView"); 750 + } 751 + 752 + DataViewData *dv = (DataViewData *)(uintptr_t)js_getnum(dv_data_val); 753 + size_t offset = (size_t)js_getnum(args[0]); 754 + int16_t value = (int16_t)js_to_int32(js_getnum(args[1])); 755 + bool little_endian = (nargs > 2 && js_truthy(js, args[2])); 756 + 757 + if (offset + 2 > dv->byte_length) { 758 + return js_mkerr(js, "Offset out of bounds"); 759 + } 760 + 761 + uint8_t *ptr = dv->buffer->data + dv->byte_offset + offset; 762 + 763 + if (little_endian) { 764 + ptr[0] = (uint8_t)(value & 0xFF); 765 + ptr[1] = (uint8_t)((value >> 8) & 0xFF); 766 + } else { 767 + ptr[0] = (uint8_t)((value >> 8) & 0xFF); 768 + ptr[1] = (uint8_t)(value & 0xFF); 769 + } 770 + 771 + return js_mkundef(); 772 + } 773 + 774 + // DataView.prototype.setInt32(byteOffset, value, littleEndian) 775 + static jsval_t js_dataview_setInt32(struct js *js, jsval_t *args, int nargs) { 776 + if (nargs < 2) return js_mkerr(js, "setInt32 requires byteOffset and value"); 777 + 778 + jsval_t this_val = js_getthis(js); 779 + jsval_t dv_data_val = js_get_slot(js, this_val, SLOT_DATA); 780 + 781 + if (js_type(dv_data_val) != JS_NUM) { 782 + return js_mkerr(js, "Not a DataView"); 783 + } 784 + 785 + DataViewData *dv = (DataViewData *)(uintptr_t)js_getnum(dv_data_val); 786 + size_t offset = (size_t)js_getnum(args[0]); 787 + int32_t value = js_to_int32(js_getnum(args[1])); 788 + bool little_endian = (nargs > 2 && js_truthy(js, args[2])); 789 + 790 + if (offset + 4 > dv->byte_length) { 791 + return js_mkerr(js, "Offset out of bounds"); 792 + } 793 + 794 + uint8_t *ptr = dv->buffer->data + dv->byte_offset + offset; 795 + 796 + if (little_endian) { 797 + ptr[0] = (uint8_t)(value & 0xFF); 798 + ptr[1] = (uint8_t)((value >> 8) & 0xFF); 799 + ptr[2] = (uint8_t)((value >> 16) & 0xFF); 800 + ptr[3] = (uint8_t)((value >> 24) & 0xFF); 801 + } else { 802 + ptr[0] = (uint8_t)((value >> 24) & 0xFF); 803 + ptr[1] = (uint8_t)((value >> 16) & 0xFF); 804 + ptr[2] = (uint8_t)((value >> 8) & 0xFF); 805 + ptr[3] = (uint8_t)(value & 0xFF); 806 + } 807 + 808 + return js_mkundef(); 809 + } 810 + 811 + // DataView.prototype.setFloat32(byteOffset, value, littleEndian) 812 + static jsval_t js_dataview_setFloat32(struct js *js, jsval_t *args, int nargs) { 813 + if (nargs < 2) return js_mkerr(js, "setFloat32 requires byteOffset and value"); 814 + 815 + jsval_t this_val = js_getthis(js); 816 + jsval_t dv_data_val = js_get_slot(js, this_val, SLOT_DATA); 817 + 818 + if (js_type(dv_data_val) != JS_NUM) { 819 + return js_mkerr(js, "Not a DataView"); 820 + } 821 + 822 + DataViewData *dv = (DataViewData *)(uintptr_t)js_getnum(dv_data_val); 823 + size_t offset = (size_t)js_getnum(args[0]); 824 + float value = (float)js_getnum(args[1]); 825 + bool little_endian = (nargs > 2 && js_truthy(js, args[2])); 826 + 827 + if (offset + 4 > dv->byte_length) { 828 + return js_mkerr(js, "Offset out of bounds"); 829 + } 830 + 831 + uint8_t *ptr = dv->buffer->data + dv->byte_offset + offset; 832 + uint32_t bits; 833 + memcpy(&bits, &value, 4); 834 + 835 + if (little_endian) { 836 + ptr[0] = (uint8_t)(bits & 0xFF); 837 + ptr[1] = (uint8_t)((bits >> 8) & 0xFF); 838 + ptr[2] = (uint8_t)((bits >> 16) & 0xFF); 839 + ptr[3] = (uint8_t)((bits >> 24) & 0xFF); 840 + } else { 841 + ptr[0] = (uint8_t)((bits >> 24) & 0xFF); 842 + ptr[1] = (uint8_t)((bits >> 16) & 0xFF); 843 + ptr[2] = (uint8_t)((bits >> 8) & 0xFF); 844 + ptr[3] = (uint8_t)(bits & 0xFF); 845 + } 846 + 847 + return js_mkundef(); 848 + } 849 + 850 + // DataView.prototype.getFloat64(byteOffset, littleEndian) 851 + static jsval_t js_dataview_getFloat64(struct js *js, jsval_t *args, int nargs) { 852 + if (nargs < 1) return js_mkerr(js, "getFloat64 requires byteOffset"); 853 + 854 + jsval_t this_val = js_getthis(js); 855 + jsval_t dv_data_val = js_get_slot(js, this_val, SLOT_DATA); 856 + 857 + if (js_type(dv_data_val) != JS_NUM) { 858 + return js_mkerr(js, "Not a DataView"); 859 + } 860 + 861 + DataViewData *dv = (DataViewData *)(uintptr_t)js_getnum(dv_data_val); 862 + size_t offset = (size_t)js_getnum(args[0]); 863 + bool little_endian = (nargs > 1 && js_truthy(js, args[1])); 864 + 865 + if (offset + 8 > dv->byte_length) { 866 + return js_mkerr(js, "Offset out of bounds"); 867 + } 868 + 869 + uint8_t *ptr = dv->buffer->data + dv->byte_offset + offset; 870 + uint64_t bits; 871 + 872 + if (little_endian) { 873 + bits = (uint64_t)ptr[0] | ((uint64_t)ptr[1] << 8) | ((uint64_t)ptr[2] << 16) | ((uint64_t)ptr[3] << 24) | 874 + ((uint64_t)ptr[4] << 32) | ((uint64_t)ptr[5] << 40) | ((uint64_t)ptr[6] << 48) | ((uint64_t)ptr[7] << 56); 875 + } else { 876 + bits = ((uint64_t)ptr[0] << 56) | ((uint64_t)ptr[1] << 48) | ((uint64_t)ptr[2] << 40) | ((uint64_t)ptr[3] << 32) | 877 + ((uint64_t)ptr[4] << 24) | ((uint64_t)ptr[5] << 16) | ((uint64_t)ptr[6] << 8) | (uint64_t)ptr[7]; 878 + } 879 + 880 + double value; 881 + memcpy(&value, &bits, 8); 882 + return js_mknum(value); 883 + } 884 + 885 + // DataView.prototype.setFloat64(byteOffset, value, littleEndian) 886 + static jsval_t js_dataview_setFloat64(struct js *js, jsval_t *args, int nargs) { 887 + if (nargs < 2) return js_mkerr(js, "setFloat64 requires byteOffset and value"); 888 + 889 + jsval_t this_val = js_getthis(js); 890 + jsval_t dv_data_val = js_get_slot(js, this_val, SLOT_DATA); 891 + 892 + if (js_type(dv_data_val) != JS_NUM) { 893 + return js_mkerr(js, "Not a DataView"); 894 + } 895 + 896 + DataViewData *dv = (DataViewData *)(uintptr_t)js_getnum(dv_data_val); 897 + size_t offset = (size_t)js_getnum(args[0]); 898 + double value = js_getnum(args[1]); 899 + bool little_endian = (nargs > 2 && js_truthy(js, args[2])); 900 + 901 + if (offset + 8 > dv->byte_length) { 902 + return js_mkerr(js, "Offset out of bounds"); 903 + } 904 + 905 + uint8_t *ptr = dv->buffer->data + dv->byte_offset + offset; 906 + uint64_t bits; 907 + memcpy(&bits, &value, 8); 908 + 909 + if (little_endian) { 910 + ptr[0] = (uint8_t)(bits & 0xFF); 911 + ptr[1] = (uint8_t)((bits >> 8) & 0xFF); 912 + ptr[2] = (uint8_t)((bits >> 16) & 0xFF); 913 + ptr[3] = (uint8_t)((bits >> 24) & 0xFF); 914 + ptr[4] = (uint8_t)((bits >> 32) & 0xFF); 915 + ptr[5] = (uint8_t)((bits >> 40) & 0xFF); 916 + ptr[6] = (uint8_t)((bits >> 48) & 0xFF); 917 + ptr[7] = (uint8_t)((bits >> 56) & 0xFF); 918 + } else { 919 + ptr[0] = (uint8_t)((bits >> 56) & 0xFF); 920 + ptr[1] = (uint8_t)((bits >> 48) & 0xFF); 921 + ptr[2] = (uint8_t)((bits >> 40) & 0xFF); 922 + ptr[3] = (uint8_t)((bits >> 32) & 0xFF); 923 + ptr[4] = (uint8_t)((bits >> 24) & 0xFF); 924 + ptr[5] = (uint8_t)((bits >> 16) & 0xFF); 925 + ptr[6] = (uint8_t)((bits >> 8) & 0xFF); 926 + ptr[7] = (uint8_t)(bits & 0xFF); 927 + } 928 + 929 + return js_mkundef(); 930 + } 931 + 738 932 // Buffer.from(array/string/buffer) 739 933 static jsval_t js_buffer_from(struct js *js, jsval_t *args, int nargs) { 740 934 if (nargs < 1) { ··· 932 1126 js_set(js, arraybuffer_proto, get_toStringTag_sym_key(), js_mkstr(js, "ArrayBuffer", 11)); 933 1127 934 1128 js_set_slot(js, arraybuffer_ctor_obj, SLOT_CFUNC, js_mkfun(js_arraybuffer_constructor)); 935 - js_setprop(js, arraybuffer_ctor_obj, js_mkstr(js, "prototype", 9), arraybuffer_proto); 1129 + js_mkprop_fast(js, arraybuffer_ctor_obj, "prototype", 9, arraybuffer_proto); 1130 + js_mkprop_fast(js, arraybuffer_ctor_obj, "name", 4, ANT_STRING("ArrayBuffer")); 1131 + js_set_descriptor(js, arraybuffer_ctor_obj, "name", 4, 0); 936 1132 js_set(js, glob, "ArrayBuffer", js_obj_to_func(arraybuffer_ctor_obj)); 937 1133 938 1134 #define SETUP_TYPEDARRAY(name) \ ··· 959 1155 SETUP_TYPEDARRAY(BigInt64Array); 960 1156 SETUP_TYPEDARRAY(BigUint64Array); 961 1157 962 - jsval_t dataview_constructor = js_mkfun(js_dataview_constructor); 1158 + jsval_t dataview_ctor_obj = js_mkobj(js); 963 1159 jsval_t dataview_proto = js_mkobj(js); 1160 + 964 1161 js_set(js, dataview_proto, "getUint8", js_mkfun(js_dataview_getUint8)); 965 1162 js_set(js, dataview_proto, "setUint8", js_mkfun(js_dataview_setUint8)); 966 1163 js_set(js, dataview_proto, "getInt16", js_mkfun(js_dataview_getInt16)); 1164 + js_set(js, dataview_proto, "setInt16", js_mkfun(js_dataview_setInt16)); 967 1165 js_set(js, dataview_proto, "getInt32", js_mkfun(js_dataview_getInt32)); 1166 + js_set(js, dataview_proto, "setInt32", js_mkfun(js_dataview_setInt32)); 968 1167 js_set(js, dataview_proto, "getFloat32", js_mkfun(js_dataview_getFloat32)); 969 - js_set(js, dataview_constructor, "prototype", dataview_proto); 970 - js_set(js, glob, "DataView", dataview_constructor); 1168 + js_set(js, dataview_proto, "setFloat32", js_mkfun(js_dataview_setFloat32)); 1169 + js_set(js, dataview_proto, "getFloat64", js_mkfun(js_dataview_getFloat64)); 1170 + js_set(js, dataview_proto, "setFloat64", js_mkfun(js_dataview_setFloat64)); 1171 + js_set(js, dataview_proto, get_toStringTag_sym_key(), js_mkstr(js, "DataView", 8)); 1172 + 1173 + js_set_slot(js, dataview_ctor_obj, SLOT_CFUNC, js_mkfun(js_dataview_constructor)); 1174 + js_mkprop_fast(js, dataview_ctor_obj, "prototype", 9, dataview_proto); 1175 + js_mkprop_fast(js, dataview_ctor_obj, "name", 4, ANT_STRING("DataView")); 1176 + js_set_descriptor(js, dataview_ctor_obj, "name", 4, 0); 1177 + js_set(js, glob, "DataView", js_obj_to_func(dataview_ctor_obj)); 971 1178 972 1179 jsval_t sharedarraybuffer_ctor_obj = js_mkobj(js); 973 1180 jsval_t sharedarraybuffer_proto = js_mkobj(js); ··· 976 1183 js_set(js, sharedarraybuffer_proto, get_toStringTag_sym_key(), js_mkstr(js, "SharedArrayBuffer", 17)); 977 1184 978 1185 js_set_slot(js, sharedarraybuffer_ctor_obj, SLOT_CFUNC, js_mkfun(js_sharedarraybuffer_constructor)); 979 - js_setprop(js, sharedarraybuffer_ctor_obj, js_mkstr(js, "prototype", 9), sharedarraybuffer_proto); 1186 + js_mkprop_fast(js, sharedarraybuffer_ctor_obj, "prototype", 9, sharedarraybuffer_proto); 1187 + js_mkprop_fast(js, sharedarraybuffer_ctor_obj, "name", 4, ANT_STRING("SharedArrayBuffer")); 1188 + js_set_descriptor(js, sharedarraybuffer_ctor_obj, "name", 4, 0); 980 1189 js_set(js, glob, "SharedArrayBuffer", js_obj_to_func(sharedarraybuffer_ctor_obj)); 981 1190 982 1191 jsval_t buffer_obj = js_mkobj(js);