Add more types and APIs for attr_container (#1841)
Add more types for attr_container, e.g. uint8, uint32, uint64 Add more APIs for attr_container for int8, int16 and int32 types Rename fields of the union 'jvalue' and refactor some files that use attr_container
This commit is contained in:
@ -33,7 +33,7 @@
|
||||
</h1>
|
||||
<p>
|
||||
1. Download a simple runtime (build for ubuntu 20.04 64 bits, other platforms please build
|
||||
from the <a href="https://github.com/intel/wasm-micro-runtime">source code</a>)
|
||||
from the <a href="https://github.com/bytecodealliance/wasm-micro-runtime/tree/main/samples/simple">source code</a>)
|
||||
</p>
|
||||
<p>
|
||||
2. In the terminal: <code>cd ~/Download && ./simple -a 82.156.57.236</code>
|
||||
@ -44,7 +44,7 @@
|
||||
<h5>
|
||||
Notes:
|
||||
</h5> We also have a <strong>UI-enabled runtime</strong>, please <a
|
||||
href="../static/upload/simple">download here</a> and enjoy.</strong> It may require
|
||||
href="../static/upload/wasm_runtime_wgl">download here</a> and enjoy.</strong> It may require
|
||||
a few more setups.
|
||||
<p>Before running the UI-enabled runtime, please install some required softwares:</p>
|
||||
<p><code>sudo apt-get install libsdl2-2.0-0:i386</code> </p>
|
||||
|
||||
@ -16,14 +16,18 @@ import logging
|
||||
import os
|
||||
|
||||
attr_type_list = [
|
||||
"ATTR_NONE",
|
||||
"ATTR_TYPE_SHORT",
|
||||
"ATTR_TYPE_INT",
|
||||
"ATTR_TYPE_BYTE", # = ATTR_TYPE_INT8
|
||||
"ATTR_TYPE_SHORT",# = ATTR_TYPE_INT16
|
||||
"ATTR_TYPE_INT", # = ATTR_TYPE_INT32
|
||||
"ATTR_TYPE_INT64",
|
||||
"ATTR_TYPE_BYTE",
|
||||
"ATTR_TYPE_UINT8",
|
||||
"ATTR_TYPE_UINT16",
|
||||
"ATTR_TYPE_UINT32",
|
||||
"ATTR_TYPE_UINT64",
|
||||
"ATTR_TYPE_FLOAT",
|
||||
"ATTR_TYPE_DOUBLE",
|
||||
"ATTR_NONE",
|
||||
"ATTR_NONE",
|
||||
"ATTR_TYPE_BOOLEAN",
|
||||
"ATTR_TYPE_STRING",
|
||||
"ATTR_TYPE_BYTEARRAY"
|
||||
@ -140,26 +144,38 @@ def decode_attr_container(msg):
|
||||
attr_type = attr_type_list[int(type_index[0])]
|
||||
buf = buf[1 : ]
|
||||
|
||||
if attr_type == "ATTR_TYPE_SHORT":
|
||||
if attr_type == "ATTR_TYPE_BYTE": # = ATTR_TYPE_INT8
|
||||
(attr_value, ) = struct.unpack('@c', buf[0 : 1])
|
||||
buf = buf[1 : ]
|
||||
# continue
|
||||
elif attr_type == "ATTR_TYPE_SHORT": # = ATTR_TYPE_INT16
|
||||
(attr_value, ) = struct.unpack('@h', buf[0 : 2])
|
||||
buf = buf[2 : ]
|
||||
# continue
|
||||
elif attr_type == "ATTR_TYPE_INT":
|
||||
(attr_value, ) = struct.unpack('@I', buf[0 : 4])
|
||||
elif attr_type == "ATTR_TYPE_INT": # = ATTR_TYPE_INT32
|
||||
(attr_value, ) = struct.unpack('@i', buf[0 : 4])
|
||||
buf = buf[4 : ]
|
||||
# continue
|
||||
elif attr_type == "ATTR_TYPE_INT64":
|
||||
(attr_value, ) = struct.unpack('@q', buf[0 : 8])
|
||||
buf = buf[8 : ]
|
||||
# continue
|
||||
elif attr_type == "ATTR_TYPE_BYTE":
|
||||
(attr_value, ) = struct.unpack('@c', buf[0 : 1])
|
||||
elif attr_type == "ATTR_TYPE_UINT8":
|
||||
(attr_value, ) = struct.unpack('@B', buf[0 : 1])
|
||||
buf = buf[1 : ]
|
||||
# continue
|
||||
elif attr_type == "ATTR_TYPE_UINT16":
|
||||
(attr_value, ) = struct.unpack('@H', buf[0 : 2])
|
||||
buf = buf[2 : ]
|
||||
# continue
|
||||
elif attr_type == "ATTR_TYPE_UINT32":
|
||||
(attr_value, ) = struct.unpack('@I', buf[0 : 4])
|
||||
buf = buf[4 : ]
|
||||
# continue
|
||||
elif attr_type == "ATTR_TYPE_UINT64":
|
||||
(attr_value, ) = struct.unpack('@Q', buf[0 : 8])
|
||||
buf = buf[8 : ]
|
||||
# continue
|
||||
elif attr_type == "ATTR_TYPE_FLOAT":
|
||||
(attr_value, ) = struct.unpack('@f', buf[0 : 4])
|
||||
buf = buf[4 : ]
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Reference in New Issue
Block a user