Commit c5e56c8363a166290fc0601d5d74244a2e272ec1
1 parent
a827e58d
no message
Showing
5 changed files
with
363 additions
and
44 deletions
Show diff stats
anubis_dev/library/network/tools.anubis
| ... | ... | @@ -141,8 +141,8 @@ public define Int64 |
| 141 | 141 | b2 = int8_to_int32(force_nth(2, src)), |
| 142 | 142 | b1 = int8_to_int32(force_nth(1, src)), |
| 143 | 143 | b0 = int8_to_int32(force_nth(0, src)), |
| 144 | - int64( b0 | (b1 << 8) | (b2 << 16) | (b3 << 24), | |
| 145 | - b4 | (b5 << 8) | (b6 << 16) | (b7 << 24)). | |
| 144 | + int64( b4 | (b5 << 8) | (b6 << 16) | (b7 << 24), //high | |
| 145 | + b0 | (b1 << 8) | (b2 << 16) | (b3 << 24)). //low | |
| 146 | 146 | |
| 147 | 147 | public define Maybe(Float) |
| 148 | 148 | lendian_to_host_Float64 | ... | ... |
anubis_dev/library/system/convert.anubis
| ... | ... | @@ -5,29 +5,136 @@ read system/string.anubis |
| 5 | 5 | |
| 6 | 6 | //TODO manage the real endianness of the host |
| 7 | 7 | |
| 8 | + | |
| 9 | +public define ByteArray reverse(ByteArray source). | |
| 10 | + | |
| 11 | +public define ByteArray | |
| 12 | + to_ByteArray | |
| 13 | + ( | |
| 14 | + Bool value | |
| 15 | + )= | |
| 16 | + with ba = constant_byte_array(1,0), | |
| 17 | + if value then | |
| 18 | + forget(put(ba,0,1)); | |
| 19 | + ba | |
| 20 | + else | |
| 21 | + //already to 0, then return the ByteArray | |
| 22 | + ba. | |
| 23 | + | |
| 24 | +public define ByteArray | |
| 25 | + to_ByteArray | |
| 26 | + ( | |
| 27 | + Int8 value | |
| 28 | + )= | |
| 29 | + constant_byte_array(1,value). | |
| 30 | + | |
| 31 | + | |
| 8 | 32 | public define ByteArray |
| 9 | 33 | host_to_lendian_Int16_ByteArray |
| 10 | 34 | ( |
| 11 | - Int16 value, | |
| 35 | + Int16 value, | |
| 12 | 36 | ) = |
| 13 | - with ba = constant_byte_array(2,0), | |
| 14 | - forget(put(ba,0,value.low)); | |
| 15 | - forget(put(ba,1,value.high)); | |
| 37 | + //create the ByteArray which will receive the result | |
| 38 | + with ba = constant_byte_array(2, 0), | |
| 39 | + | |
| 40 | + if host_endian is | |
| 41 | + { | |
| 42 | + little then | |
| 43 | + forget(put(ba,1,value.high)); | |
| 44 | + forget(put(ba,0,value.low )), | |
| 45 | + big then | |
| 46 | + forget(put(ba,1,value.low)); | |
| 47 | + forget(put(ba,0,value.high)) | |
| 48 | + }; | |
| 49 | + //return the result ByteArray | |
| 16 | 50 | ba. |
| 17 | - | |
| 18 | - | |
| 51 | + | |
| 19 | 52 | public define ByteArray |
| 20 | 53 | host_to_lendian_Int32_ByteArray |
| 21 | 54 | ( |
| 22 | 55 | Int32 value, |
| 23 | 56 | ) = |
| 24 | - with ba = constant_byte_array(4, 0), | |
| 25 | - forget(put(ba,0,truncate_to_int8( value>>24) )); | |
| 26 | - forget(put(ba,1,truncate_to_int8((value>>16) & 0xFF))); | |
| 27 | - forget(put(ba,2,truncate_to_int8((value>>8) & 0xFF))); | |
| 28 | - forget(put(ba,3,truncate_to_int8( value & 0xFF))); | |
| 29 | - ba. | |
| 57 | + //create the ByteArray which will receive the result | |
| 58 | + with ba = constant_byte_array(4, 0), | |
| 59 | + | |
| 60 | + if host_endian is | |
| 61 | + { | |
| 62 | + little then | |
| 63 | + forget(put(ba,3,truncate_to_int8( value>>24) )); | |
| 64 | + forget(put(ba,2,truncate_to_int8((value>>16) & 0xFF))); | |
| 65 | + forget(put(ba,1,truncate_to_int8((value>>8) & 0xFF))); | |
| 66 | + forget(put(ba,0,truncate_to_int8( value & 0xFF))), | |
| 67 | + big then | |
| 68 | + forget(put(ba,0,truncate_to_int8( value>>24) )); | |
| 69 | + forget(put(ba,1,truncate_to_int8((value>>16) & 0xFF))); | |
| 70 | + forget(put(ba,2,truncate_to_int8((value>>8) & 0xFF))); | |
| 71 | + forget(put(ba,3,truncate_to_int8( value & 0xFF))) | |
| 72 | + }; | |
| 73 | + //return the result ByteArray | |
| 74 | + ba. | |
| 75 | + | |
| 76 | +public define ByteArray | |
| 77 | + host_to_lendian_Int64_ByteArray | |
| 78 | + ( | |
| 79 | + Int64 value, | |
| 80 | + ) = | |
| 81 | + if host_endian is | |
| 82 | + { | |
| 83 | + little then | |
| 84 | + host_to_lendian_Int32_ByteArray(value.low) + | |
| 85 | + host_to_lendian_Int32_ByteArray(value.high), | |
| 86 | + big then | |
| 87 | + host_to_lendian_Int32_ByteArray(value.high) + | |
| 88 | + host_to_lendian_Int32_ByteArray(value.low) | |
| 89 | + }. | |
| 90 | + | |
| 91 | + | |
| 92 | +public define ByteArray | |
| 93 | + host_to_lendian_Float64_ByteArray | |
| 94 | + ( | |
| 95 | + Float value | |
| 96 | + )= | |
| 97 | + with ba = serialize(value), | |
| 98 | + if host_endian is | |
| 99 | + { | |
| 100 | + little then ba, | |
| 101 | + big then reverse(ba) | |
| 102 | + }. | |
| 30 | 103 | |
| 104 | +public define ByteArray | |
| 105 | + host_to_lendian_Float32_ByteArray | |
| 106 | + ( | |
| 107 | + Float32 val | |
| 108 | + )= | |
| 109 | + host_to_lendian_Int32_ByteArray(val.value). | |
| 110 | + | |
| 111 | +public define ByteArray | |
| 112 | + host_to_lendian_B_Point_ByteArray | |
| 113 | + ( | |
| 114 | + B_Point value | |
| 115 | + ) = | |
| 116 | + host_to_lendian_Float32_ByteArray(value.x) + | |
| 117 | + host_to_lendian_Float32_ByteArray(value.y). | |
| 118 | + | |
| 119 | +public define ByteArray | |
| 120 | + host_to_lendian_B_Rect_ByteArray | |
| 121 | + ( | |
| 122 | + B_Rect value | |
| 123 | + ) = | |
| 124 | + if value is | |
| 125 | + { | |
| 126 | + rect(left_top, right_bottom) then | |
| 127 | + host_to_lendian_B_Point_ByteArray(left_top) + | |
| 128 | + host_to_lendian_B_Point_ByteArray(right_bottom), | |
| 129 | + | |
| 130 | + rect(left, top, right, bottom) then | |
| 131 | + host_to_lendian_Float32_ByteArray(left) + | |
| 132 | + host_to_lendian_Float32_ByteArray(top) + | |
| 133 | + host_to_lendian_Float32_ByteArray(right) + | |
| 134 | + host_to_lendian_Float32_ByteArray(bottom) | |
| 135 | + } | |
| 136 | + . | |
| 137 | + | |
| 31 | 138 | define ByteArray |
| 32 | 139 | reverse |
| 33 | 140 | ( | ... | ... |
anubis_dev/library/system/files.anubis
anubis_dev/library/system/muscle.anubis
| ... | ... | @@ -28,14 +28,9 @@ public define Int32 _CURRENT_PROTOCOL_VERSION = 1347235888. // 'PM00' -- our mag |
| 28 | 28 | public type Message:... |
| 29 | 29 | |
| 30 | 30 | define Maybe(Message) unflatten_message ( RAddr(Int8) stream ). |
| 31 | +define Maybe(ByteArray) flatten_message ( Message msg ). | |
| 31 | 32 | |
| 32 | 33 | |
| 33 | -public type B_Point: | |
| 34 | - point(Float32 x, Float32 y). | |
| 35 | - | |
| 36 | -public type B_Rect: | |
| 37 | - rect(B_Point up_left, B_Point down_right), | |
| 38 | - rect(Float32 x, Float32 y, Float32 x1, Float32 y1). | |
| 39 | 34 | |
| 40 | 35 | type Muscle_object: |
| 41 | 36 | b_bool(Bool), |
| ... | ... | @@ -87,6 +82,31 @@ public type Message: |
| 87 | 82 | Var(List(Message_field)) fields |
| 88 | 83 | ). |
| 89 | 84 | |
| 85 | +define Int32 | |
| 86 | + get_Int32_type_code | |
| 87 | + ( | |
| 88 | + Muscle_type type_code | |
| 89 | + )= | |
| 90 | + if type_code is | |
| 91 | + { | |
| 92 | + b_any_t then _B_ANY_TYPE, | |
| 93 | + b_bool_t then _B_BOOL_TYPE, | |
| 94 | + b_double_t then _B_DOUBLE_TYPE, | |
| 95 | + b_float_t then _B_FLOAT_TYPE, | |
| 96 | + b_int64_t then _B_INT64_TYPE, | |
| 97 | + b_int32_t then _B_INT32_TYPE, | |
| 98 | + b_int16_t then _B_INT16_TYPE, | |
| 99 | + b_int8_t then _B_INT8_TYPE, | |
| 100 | + b_message_t then _B_MESSAGE_TYPE, | |
| 101 | + b_pointer_t then _B_POINTER_TYPE, | |
| 102 | + b_point_t then _B_POINT_TYPE, | |
| 103 | + b_rect_t then _B_RECT_TYPE, | |
| 104 | + b_string_t then _B_STRING_TYPE, | |
| 105 | + b_custom_t(v)then v, | |
| 106 | + b_raw_t then _B_RAW_TYPE, | |
| 107 | + } | |
| 108 | + . | |
| 109 | + | |
| 90 | 110 | define Maybe(Muscle_type) |
| 91 | 111 | get_muscle_type |
| 92 | 112 | ( |
| ... | ... | @@ -108,12 +128,16 @@ define Maybe(Muscle_type) |
| 108 | 128 | success(b_int8_t) |
| 109 | 129 | else if type_code = _B_MESSAGE_TYPE then |
| 110 | 130 | success(b_message_t) |
| 111 | - else if type_code = _B_STRING_TYPE then | |
| 112 | - success(b_string_t) | |
| 131 | + else if type_code = _B_POINTER_TYPE then | |
| 132 | + success(b_message_t) | |
| 113 | 133 | else if type_code = _B_POINT_TYPE then |
| 114 | 134 | success(b_point_t) |
| 115 | 135 | else if type_code = _B_RECT_TYPE then |
| 116 | 136 | success(b_rect_t) |
| 137 | + else if type_code = _B_STRING_TYPE then | |
| 138 | + success(b_string_t) | |
| 139 | + else if type_code = _B_RAW_TYPE then | |
| 140 | + success(b_raw_t) | |
| 117 | 141 | else |
| 118 | 142 | print("muscle custom type " + to_hexa(type_code) + "\n"); |
| 119 | 143 | success(b_custom_t(type_code)). |
| ... | ... | @@ -124,7 +148,7 @@ public define One |
| 124 | 148 | ( |
| 125 | 149 | Message msg |
| 126 | 150 | )= |
| 127 | - print("Message: what = " + *msg.what + ", ASCII = \"" + to_ascii(*msg.what) + "\", Hexa = 0x" + to_hexa(*msg.what) + | |
| 151 | + print("Message: what = " + *msg.what + ", ASCII = \"" + to_ascii(*msg.what) + "\", Hexa = 0x" + to_hexa(*msg.what) + "\n" + | |
| 128 | 152 | "entry count=" + *msg.numField +"\n"). |
| 129 | 153 | |
| 130 | 154 | |
| ... | ... | @@ -670,14 +694,175 @@ define Maybe(List(Message_field)) |
| 670 | 694 | }. |
| 671 | 695 | |
| 672 | 696 | define Maybe(ByteArray) |
| 697 | + flatten_items | |
| 698 | + ( | |
| 699 | + Muscle_type type_code, | |
| 700 | + List(Muscle_object) m_o, | |
| 701 | + ByteArray so_far | |
| 702 | + )= | |
| 703 | + if m_o is | |
| 704 | + { | |
| 705 | + [] then success(so_far), | |
| 706 | + [h . t] then | |
| 707 | + if h is | |
| 708 | + { | |
| 709 | + b_bool(data) then | |
| 710 | + flatten_items(type_code, t, so_far + to_ByteArray(data)), | |
| 711 | + | |
| 712 | + b_double(data) then | |
| 713 | + flatten_items(type_code, t, so_far + host_to_lendian_Float64_ByteArray(data)), | |
| 714 | + | |
| 715 | + b_float(data) then | |
| 716 | + flatten_items(type_code, t, so_far + host_to_lendian_Float32_ByteArray(data)), | |
| 717 | + | |
| 718 | + b_int64(data) then | |
| 719 | + flatten_items(type_code, t, so_far + host_to_lendian_Int64_ByteArray(data)), | |
| 720 | + | |
| 721 | + b_int32(data) then | |
| 722 | + flatten_items(type_code, t, so_far + host_to_lendian_Int32_ByteArray(data)), | |
| 723 | + | |
| 724 | + b_int16(data) then | |
| 725 | + flatten_items(type_code, t, so_far + host_to_lendian_Int16_ByteArray(data)), | |
| 726 | + | |
| 727 | + b_int8(data) then | |
| 728 | + flatten_items(type_code, t, so_far + to_ByteArray(data)), | |
| 729 | + | |
| 730 | + b_message(data) then | |
| 731 | + with result = flatten_message(data), | |
| 732 | + if result is | |
| 733 | + { | |
| 734 | + failure then failure, | |
| 735 | + success(message) then | |
| 736 | + flatten_items(type_code, t, so_far + host_to_lendian_Int32_ByteArray(length(message)) + message), | |
| 737 | + } | |
| 738 | + b_pointer(data) then | |
| 739 | + flatten_items(type_code, t, so_far + host_to_lendian_Int32_ByteArray(data)), | |
| 740 | + | |
| 741 | + b_point(data) then | |
| 742 | + flatten_items(type_code, t, so_far + host_to_lendian_B_Point_ByteArray(data)), | |
| 743 | + | |
| 744 | + b_rect(data) then | |
| 745 | + flatten_items(type_code, t, so_far + host_to_lendian_B_Rect_ByteArray(data)), | |
| 746 | + b_string(data) then | |
| 747 | + flatten_items(type_code, t, so_far + host_to_lendian_Int32_ByteArray(length(data)+1) | |
| 748 | + + to_byte_array(data) | |
| 749 | + + constant_byte_array(1,0)), | |
| 750 | + | |
| 751 | + b_custom(data) then | |
| 752 | + flatten_items(type_code, t, so_far + host_to_lendian_Int32_ByteArray(length(data)) + data), | |
| 753 | + b_raw(data) then | |
| 754 | + flatten_items(type_code, t, so_far + host_to_lendian_Int32_ByteArray(length(data)) + data) | |
| 755 | + } | |
| 756 | + }. | |
| 757 | + | |
| 758 | +define Maybe(ByteArray) | |
| 759 | + flatten_one_field | |
| 760 | + ( | |
| 761 | + Muscle_type type_code, | |
| 762 | + List(Muscle_object) m_o | |
| 763 | + )= | |
| 764 | + with result = flatten_items(type_code, m_o, constant_byte_array(0, 0)), | |
| 765 | + if result is | |
| 766 | + { | |
| 767 | + failure then failure | |
| 768 | + success(flat_items) then | |
| 769 | + if type_code is | |
| 770 | + { | |
| 771 | + b_any_t then failure, | |
| 772 | + | |
| 773 | + b_bool_t then | |
| 774 | + success(host_to_lendian_Int32_ByteArray(length(m_o)) + flat_items ) | |
| 775 | + | |
| 776 | + b_double_t then | |
| 777 | + success(host_to_lendian_Int32_ByteArray(length(m_o)<<3) + flat_items ) | |
| 778 | + | |
| 779 | + b_float_t then | |
| 780 | + success(host_to_lendian_Int32_ByteArray(length(m_o)<<2) + flat_items ) | |
| 781 | + b_int64_t then | |
| 782 | + success(host_to_lendian_Int32_ByteArray(length(m_o)<<3) + flat_items ) | |
| 783 | + b_int32_t then | |
| 784 | + success(host_to_lendian_Int32_ByteArray(length(m_o)<<2) + flat_items ) | |
| 785 | + b_int16_t then | |
| 786 | + success(host_to_lendian_Int32_ByteArray(length(m_o)<<1) + flat_items ) | |
| 787 | + b_int8_t then | |
| 788 | + success(host_to_lendian_Int32_ByteArray(length(m_o)) + flat_items ) | |
| 789 | + b_message_t then | |
| 790 | + success(host_to_lendian_Int32_ByteArray(length(flat_items)) + flat_items ) | |
| 791 | + b_pointer_t then | |
| 792 | + success(host_to_lendian_Int32_ByteArray(length(m_o)) + flat_items ) | |
| 793 | + b_point_t then | |
| 794 | + success(host_to_lendian_Int32_ByteArray(length(m_o)<<3) + flat_items ) | |
| 795 | + b_rect_t then | |
| 796 | + success(host_to_lendian_Int32_ByteArray(length(m_o)<<4) + flat_items ) | |
| 797 | + b_string_t then | |
| 798 | + success(host_to_lendian_Int32_ByteArray(length(flat_items) + 4) + //size of all items | |
| 799 | + host_to_lendian_Int32_ByteArray(length(m_o)) + //number of items | |
| 800 | + flat_items ) | |
| 801 | + b_custom_t(Int32 _0) then | |
| 802 | + success(host_to_lendian_Int32_ByteArray(length(flat_items) + 4) + //size of all items | |
| 803 | + host_to_lendian_Int32_ByteArray(length(m_o)) + //number of items | |
| 804 | + flat_items ) | |
| 805 | + b_raw_t then | |
| 806 | + success(host_to_lendian_Int32_ByteArray(length(flat_items) + 4) + //size of all items | |
| 807 | + host_to_lendian_Int32_ByteArray(length(m_o)) + //number of items | |
| 808 | + flat_items ) | |
| 809 | + } | |
| 810 | + } | |
| 811 | + . | |
| 812 | + | |
| 813 | +define Maybe(ByteArray) | |
| 814 | + flatten_fields | |
| 815 | + ( | |
| 816 | + List(Message_field) fields, | |
| 817 | + ByteArray so_far | |
| 818 | + )= | |
| 819 | + if fields is | |
| 820 | + { | |
| 821 | + [ ] then failure, | |
| 822 | + [ h . t ] then | |
| 823 | + //write size of name + 1 for NULL erminated string | |
| 824 | + with flatten_header = host_to_lendian_Int32_ByteArray(length(h.name)+1) + | |
| 825 | + //write the name + NULL | |
| 826 | + to_byte_array(h.name) + constant_byte_array(1,0) + | |
| 827 | + //write the type_code of the field | |
| 828 | + host_to_lendian_Int32_ByteArray(get_Int32_type_code(h.type_code)) | |
| 829 | + , | |
| 830 | + | |
| 831 | + if flatten_one_field(h.type_code , *h.items) is | |
| 832 | + { | |
| 833 | + failure then failure, | |
| 834 | + success(flatten_body) then | |
| 835 | + if t is | |
| 836 | + { | |
| 837 | + [] then success(so_far + flatten_header + flatten_body), | |
| 838 | + [_ ._] then flatten_fields(t, so_far + flatten_header + flatten_body ) | |
| 839 | + } | |
| 840 | + } | |
| 841 | + }. | |
| 842 | + | |
| 843 | + /** | |
| 844 | + * Converts the given Message into a flattened buffer of bytes (ByteArray) that can be saved to disk | |
| 845 | + * or sent over a network, and later converted back into an identical Message type. | |
| 846 | + * @param msg The message to be flatten | |
| 847 | + * @return failure if any error occur otherwise the ByteArray with the flattened message | |
| 848 | + */ | |
| 849 | +define Maybe(ByteArray) | |
| 673 | 850 | flatten_message |
| 674 | 851 | ( |
| 675 | 852 | Message msg |
| 676 | 853 | )= |
| 677 | - with flatten_message = host_to_lendian_Int32_ByteArray(_CURRENT_PROTOCOL_VERSION) + | |
| 678 | - host_to_lendian_Int32_ByteArray(*msg.what), | |
| 679 | - success(flatten_message). | |
| 680 | - | |
| 854 | + with message_header = | |
| 855 | + host_to_lendian_Int32_ByteArray(_CURRENT_PROTOCOL_VERSION) + | |
| 856 | + host_to_lendian_Int32_ByteArray(*msg.what) + | |
| 857 | + host_to_lendian_Int32_ByteArray(length(*msg.fields)), | |
| 858 | + | |
| 859 | + if flatten_fields(*msg.fields, to_byte_array("")) is | |
| 860 | + { | |
| 861 | + failure then failure | |
| 862 | + success(flattened_fields) then success(message_header + flattened_fields) | |
| 863 | + }. | |
| 864 | + | |
| 865 | + | |
| 681 | 866 | /* Format: 0. Protocol revision number (4 bytes, always set to CURRENT_PROTOCOL_VERSION) */ |
| 682 | 867 | /* 1. 'what' code (4 bytes) */ |
| 683 | 868 | /* 2. Number of entries (4 bytes) */ |
| ... | ... | @@ -1403,7 +1588,7 @@ global define One |
| 1403 | 1588 | ( |
| 1404 | 1589 | List(String) args |
| 1405 | 1590 | ) = |
| 1406 | - if (Maybe(RAddr(Int8)))file("c:/muscle/python/test.msg", read) is | |
| 1591 | + if (Maybe(RAddr(Int8)))file("c:/muscle/python/test_multi_msg.msg", read) is | |
| 1407 | 1592 | { |
| 1408 | 1593 | failure then print("Open file Error\n"), |
| 1409 | 1594 | success(source) then |
| ... | ... | @@ -1412,18 +1597,31 @@ global define One |
| 1412 | 1597 | failure then print("File Message ERROR \n"), |
| 1413 | 1598 | success(message) then |
| 1414 | 1599 | print("File Message decoded\n"); |
| 1415 | - print_to_stream(message); | |
| 1416 | - if find_message(message, "message") is | |
| 1417 | - { | |
| 1418 | - failure then print("Can't find message \"message\" \n"), | |
| 1419 | - success(sub_message) then | |
| 1420 | - forget(add_string(sub_message, "toto", "tata")); | |
| 1421 | - if find_string(sub_message, "toto") is | |
| 1600 | + print_to_stream(message);/* | |
| 1601 | + if find_message(message, "message") is | |
| 1602 | + { | |
| 1603 | + failure then print("Can't find message \"message\" \n"), | |
| 1604 | + success(sub_message) then | |
| 1605 | + forget(add_string(sub_message, "toto", "tata")); | |
| 1606 | + if find_string(sub_message, "toto") is | |
| 1607 | + { | |
| 1608 | + failure then print("can't find string \"string\" \n"), | |
| 1609 | + success(the_string) then print("the string found is [" + the_string + "] \n") | |
| 1610 | + | |
| 1611 | + } | |
| 1612 | + };*/ | |
| 1613 | + if flatten_message(message) is | |
| 1614 | + { | |
| 1615 | + failure then print("Can't flatten message\n"), | |
| 1616 | + success(ba_msg) then | |
| 1617 | + //now write the result into file | |
| 1618 | + if file("c:/muscle/python/Anubis.test_multi_msg.msg", new) is | |
| 1422 | 1619 | { |
| 1423 | - failure then print("can't find string \"string\" \n"), | |
| 1424 | - success(the_string) then print("the string found is [" + the_string + "] \n") | |
| 1620 | + failure then print("Can't open file \n"), | |
| 1621 | + success(fd) then forget(write(weaken(fd), ba_msg)) | |
| 1425 | 1622 | } |
| 1426 | - } | |
| 1623 | + | |
| 1624 | + } | |
| 1427 | 1625 | } |
| 1428 | 1626 | } |
| 1429 | 1627 | . | ... | ... |
anubis_dev/library/system/types.anubis
| ... | ... | @@ -2,10 +2,29 @@ |
| 2 | 2 | |
| 3 | 3 | read tools/basis.anubis |
| 4 | 4 | |
| 5 | +public type Endian: | |
| 6 | + little, | |
| 7 | + big. | |
| 8 | + | |
| 9 | +public define Endian host_endian = little. | |
| 5 | 10 | |
| 6 | 11 | public type Int16: |
| 7 | 12 | int16(Int8 high, Int8 low). |
| 13 | + | |
| 14 | +public type Int64: | |
| 15 | + int64(Int32 high, Int32 low). | |
| 16 | + | |
| 17 | +public type Float32: | |
| 18 | + float32(Int32 value). | |
| 19 | + | |
| 20 | +public type B_Point: | |
| 21 | + point(Float32 x, Float32 y). | |
| 8 | 22 | |
| 23 | +public type B_Rect: | |
| 24 | + rect(B_Point left_top, B_Point right_bottom), | |
| 25 | + rect(Float32 left, Float32 top, Float32 right, Float32 bottom). | |
| 26 | + | |
| 27 | + | |
| 9 | 28 | public define Int32 |
| 10 | 29 | to_Int32 |
| 11 | 30 | ( |
| ... | ... | @@ -21,13 +40,8 @@ public define String |
| 21 | 40 | Int16 i + String s = |
| 22 | 41 | integer_to_string(to_Int32(i)) + s. |
| 23 | 42 | |
| 24 | -public type Int64: | |
| 25 | - int64(Int32 high, Int32 low). | |
| 26 | 43 | |
| 27 | 44 | |
| 28 | -public type Float32: | |
| 29 | - float32(Int32 value). | |
| 30 | - | |
| 31 | 45 | |
| 32 | 46 | define Bool |
| 33 | 47 | compare_all_bytes | ... | ... |