Skip to content

Commit da74e54

Browse files
authored
Merge pull request #696 from bytecodealliance/main
Merge bytecodealliance:main into wenyongh:main
2 parents c197b34 + 965edff commit da74e54

File tree

47 files changed

+1130
-306
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+1130
-306
lines changed

.github/workflows/build_wamr_vscode_ext.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,14 @@ jobs:
3232
working-directory: test-tools/wamr-ide/VSCode-Extension
3333

3434
- name: generate wamr ide vscode extension
35+
env:
36+
credentials: ${{ secrets.TOKEN }}
3537
run: |
3638
npm install -g vsce
3739
rm -rf node_modules
3840
npm install
3941
vsce package
42+
vsce publish -p ${{ secrets.TOKEN }}
4043
working-directory: test-tools/wamr-ide/VSCode-Extension
4144

4245
- name: compress the vscode extension

.github/workflows/release_process.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,7 @@ jobs:
150150
release_wamr_ide_vscode_ext:
151151
needs: [create_tag, create_release]
152152
uses: ./.github/workflows/build_wamr_vscode_ext.yml
153+
secrets: inherit
153154
with:
154155
upload_url: ${{ needs.create_release.outputs.upload_url }}
155156
ver_num: ${{ needs.create_tag.outputs.new_ver }}

core/app-framework/app-native-shared/attr_container.c

Lines changed: 155 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,14 @@
77

88
typedef union jvalue {
99
bool z;
10-
int8_t b;
11-
uint16_t c;
12-
int16_t s;
13-
int32_t i;
14-
int64_t j;
10+
int8_t i8;
11+
uint8_t u8;
12+
int16_t i16;
13+
uint16_t u16;
14+
int32_t i32;
15+
uint32_t u32;
16+
int64_t i64;
17+
uint64_t u64;
1518
float f;
1619
double d;
1720
} jvalue;
@@ -27,7 +30,9 @@ get_int16(const char *buf)
2730
static inline uint16_t
2831
get_uint16(const char *buf)
2932
{
30-
return get_int16(buf);
33+
uint16_t ret;
34+
bh_memcpy_s(&ret, sizeof(uint16_t), buf, sizeof(uint16_t));
35+
return ret;
3136
}
3237

3338
static inline int32_t
@@ -41,7 +46,9 @@ get_int32(const char *buf)
4146
static inline uint32_t
4247
get_uint32(const char *buf)
4348
{
44-
return get_int32(buf);
49+
uint32_t ret;
50+
bh_memcpy_s(&ret, sizeof(uint32_t), buf, sizeof(uint32_t));
51+
return ret;
4552
}
4653

4754
static inline int64_t
@@ -55,7 +62,9 @@ get_int64(const char *buf)
5562
static inline uint64_t
5663
get_uint64(const char *buf)
5764
{
58-
return get_int64(buf);
65+
uint64_t ret;
66+
bh_memcpy_s(&ret, sizeof(uint64_t), buf, sizeof(uint64_t));
67+
return ret;
5968
}
6069

6170
static inline void
@@ -145,8 +154,8 @@ attr_container_get_attr_next(const char *curr_attr)
145154
p += sizeof(uint16_t) + get_uint16(p);
146155
type = *p++;
147156

148-
/* Short type to Boolean type */
149-
if (type >= ATTR_TYPE_SHORT && type <= ATTR_TYPE_BOOLEAN) {
157+
/* Byte type to Boolean type */
158+
if (type >= ATTR_TYPE_BYTE && type <= ATTR_TYPE_BOOLEAN) {
150159
p += 1 << (type & 3);
151160
return p;
152161
}
@@ -342,7 +351,7 @@ attr_container_set_attr(attr_container_t **p_attr_cont, const char *key,
342351

343352
/* key len + key + '\0' + type */
344353
attr_len = sizeof(uint16_t) + strlen(key) + 1 + 1;
345-
if (type >= ATTR_TYPE_SHORT && type <= ATTR_TYPE_BOOLEAN)
354+
if (type >= ATTR_TYPE_BYTE && type <= ATTR_TYPE_BOOLEAN)
346355
attr_len += 1 << (type & 3);
347356
else if (type == ATTR_TYPE_STRING)
348357
attr_len += sizeof(uint16_t) + value_length;
@@ -362,7 +371,7 @@ attr_container_set_attr(attr_container_t **p_attr_cont, const char *key,
362371
p += str_len;
363372

364373
*p++ = type;
365-
if (type >= ATTR_TYPE_SHORT && type <= ATTR_TYPE_BOOLEAN)
374+
if (type >= ATTR_TYPE_BYTE && type <= ATTR_TYPE_BOOLEAN)
366375
bh_memcpy_s(p, 1 << (type & 3), value, 1 << (type & 3));
367376
else if (type == ATTR_TYPE_STRING) {
368377
set_uint16(p, value_length);
@@ -460,13 +469,37 @@ attr_container_set_short(attr_container_t **p_attr_cont, const char *key,
460469
2);
461470
}
462471

472+
bool
473+
attr_container_set_int16(attr_container_t **p_attr_cont, const char *key,
474+
int16_t value)
475+
{
476+
return attr_container_set_attr(p_attr_cont, key, ATTR_TYPE_INT16, &value,
477+
2);
478+
}
479+
463480
bool
464481
attr_container_set_int(attr_container_t **p_attr_cont, const char *key,
465482
int value)
466483
{
467484
return attr_container_set_attr(p_attr_cont, key, ATTR_TYPE_INT, &value, 4);
468485
}
469486

487+
bool
488+
attr_container_set_int32(attr_container_t **p_attr_cont, const char *key,
489+
int32_t value)
490+
{
491+
return attr_container_set_attr(p_attr_cont, key, ATTR_TYPE_INT32, &value,
492+
4);
493+
}
494+
495+
bool
496+
attr_container_set_uint32(attr_container_t **p_attr_cont, const char *key,
497+
uint32_t value)
498+
{
499+
return attr_container_set_attr(p_attr_cont, key, ATTR_TYPE_UINT32, &value,
500+
4);
501+
}
502+
470503
bool
471504
attr_container_set_int64(attr_container_t **p_attr_cont, const char *key,
472505
int64_t value)
@@ -475,13 +508,36 @@ attr_container_set_int64(attr_container_t **p_attr_cont, const char *key,
475508
8);
476509
}
477510

511+
bool
512+
attr_container_set_uint64(attr_container_t **p_attr_cont, const char *key,
513+
uint64_t value)
514+
{
515+
return attr_container_set_attr(p_attr_cont, key, ATTR_TYPE_UINT64, &value,
516+
8);
517+
}
518+
478519
bool
479520
attr_container_set_byte(attr_container_t **p_attr_cont, const char *key,
480521
int8_t value)
481522
{
482523
return attr_container_set_attr(p_attr_cont, key, ATTR_TYPE_BYTE, &value, 1);
483524
}
484525

526+
bool
527+
attr_container_set_int8(attr_container_t **p_attr_cont, const char *key,
528+
int8_t value)
529+
{
530+
return attr_container_set_attr(p_attr_cont, key, ATTR_TYPE_INT8, &value, 1);
531+
}
532+
533+
bool
534+
attr_container_set_uint8(attr_container_t **p_attr_cont, const char *key,
535+
uint8_t value)
536+
{
537+
return attr_container_set_attr(p_attr_cont, key, ATTR_TYPE_UINT8, &value,
538+
1);
539+
}
540+
485541
bool
486542
attr_container_set_uint16(attr_container_t **p_attr_cont, const char *key,
487543
uint16_t value)
@@ -552,7 +608,7 @@ attr_container_get_attr(const attr_container_t *attr_cont, const char *key)
552608

553609
if (!(attr_addr = attr_container_find_attr(attr_cont, key))) {
554610
attr_container_printf("Get attribute failed: lookup key failed.\r\n");
555-
return false;
611+
return NULL;
556612
}
557613

558614
/* key len + key + '\0' */
@@ -566,14 +622,17 @@ attr_container_get_attr(const attr_container_t *attr_cont, const char *key)
566622
uint8_t type; \
567623
if (!addr) \
568624
return 0; \
569-
val.j = 0; \
625+
val.i64 = 0; \
570626
type = *(uint8_t *)addr++; \
571627
switch (type) { \
572-
case ATTR_TYPE_SHORT: \
573-
case ATTR_TYPE_INT: \
628+
case ATTR_TYPE_BYTE: /* = ATTR_TYPE_INT8 */ \
629+
case ATTR_TYPE_SHORT: /* = ATTR_TYPE_INT16 */ \
630+
case ATTR_TYPE_INT: /* = ATTR_TYPE_INT32 */ \
574631
case ATTR_TYPE_INT64: \
575-
case ATTR_TYPE_BYTE: \
632+
case ATTR_TYPE_UINT8: \
576633
case ATTR_TYPE_UINT16: \
634+
case ATTR_TYPE_UINT32: \
635+
case ATTR_TYPE_UINT64: \
577636
case ATTR_TYPE_FLOAT: \
578637
case ATTR_TYPE_DOUBLE: \
579638
case ATTR_TYPE_BOOLEAN: \
@@ -608,31 +667,67 @@ attr_container_get_attr(const attr_container_t *attr_cont, const char *key)
608667
short
609668
attr_container_get_as_short(const attr_container_t *attr_cont, const char *key)
610669
{
611-
TEMPLATE_ATTR_BUF_TO_VALUE(attr_cont, key, s);
670+
TEMPLATE_ATTR_BUF_TO_VALUE(attr_cont, key, i16);
671+
}
672+
673+
int16_t
674+
attr_container_get_as_int16(const attr_container_t *attr_cont, const char *key)
675+
{
676+
return (int16_t)attr_container_get_as_short(attr_cont, key);
612677
}
613678

614679
int
615680
attr_container_get_as_int(const attr_container_t *attr_cont, const char *key)
616681
{
617-
TEMPLATE_ATTR_BUF_TO_VALUE(attr_cont, key, i);
682+
TEMPLATE_ATTR_BUF_TO_VALUE(attr_cont, key, i32);
683+
}
684+
685+
int32_t
686+
attr_container_get_as_int32(const attr_container_t *attr_cont, const char *key)
687+
{
688+
return (int32_t)attr_container_get_as_int(attr_cont, key);
689+
}
690+
691+
uint32_t
692+
attr_container_get_as_uint32(const attr_container_t *attr_cont, const char *key)
693+
{
694+
return (uint32_t)attr_container_get_as_int(attr_cont, key);
618695
}
619696

620697
int64_t
621698
attr_container_get_as_int64(const attr_container_t *attr_cont, const char *key)
622699
{
623-
TEMPLATE_ATTR_BUF_TO_VALUE(attr_cont, key, j);
700+
TEMPLATE_ATTR_BUF_TO_VALUE(attr_cont, key, i64);
701+
}
702+
703+
uint64_t
704+
attr_container_get_as_uint64(const attr_container_t *attr_cont, const char *key)
705+
{
706+
return (uint64_t)attr_container_get_as_int64(attr_cont, key);
624707
}
625708

626709
int8_t
627710
attr_container_get_as_byte(const attr_container_t *attr_cont, const char *key)
628711
{
629-
TEMPLATE_ATTR_BUF_TO_VALUE(attr_cont, key, b);
712+
TEMPLATE_ATTR_BUF_TO_VALUE(attr_cont, key, i8);
713+
}
714+
715+
int8_t
716+
attr_container_get_as_int8(const attr_container_t *attr_cont, const char *key)
717+
{
718+
return attr_container_get_as_byte(attr_cont, key);
719+
}
720+
721+
uint8_t
722+
attr_container_get_as_uint8(const attr_container_t *attr_cont, const char *key)
723+
{
724+
return (uint8_t)attr_container_get_as_byte(attr_cont, key);
630725
}
631726

632727
uint16_t
633728
attr_container_get_as_uint16(const attr_container_t *attr_cont, const char *key)
634729
{
635-
TEMPLATE_ATTR_BUF_TO_VALUE(attr_cont, key, s);
730+
return (uint16_t)attr_container_get_as_short(attr_cont, key);
636731
}
637732

638733
float
@@ -671,11 +766,14 @@ attr_container_get_as_bytearray(const attr_container_t *attr_cont,
671766

672767
type = *(uint8_t *)addr++;
673768
switch (type) {
674-
case ATTR_TYPE_SHORT:
675-
case ATTR_TYPE_INT:
769+
case ATTR_TYPE_BYTE: /* = ATTR_TYPE_INT8 */
770+
case ATTR_TYPE_SHORT: /* = ATTR_TYPE_INT16 */
771+
case ATTR_TYPE_INT: /* = ATTR_TYPE_INT32 */
676772
case ATTR_TYPE_INT64:
677-
case ATTR_TYPE_BYTE:
773+
case ATTR_TYPE_UINT8:
678774
case ATTR_TYPE_UINT16:
775+
case ATTR_TYPE_UINT32:
776+
case ATTR_TYPE_UINT64:
679777
case ATTR_TYPE_FLOAT:
680778
case ATTR_TYPE_DOUBLE:
681779
case ATTR_TYPE_BOOLEAN:
@@ -807,34 +905,52 @@ attr_container_dump(const attr_container_t *attr_cont)
807905
attr_container_printf(" key: %s", key);
808906

809907
switch (type) {
810-
case ATTR_TYPE_SHORT:
811-
bh_memcpy_s(&value.s, sizeof(int16_t), p, sizeof(int16_t));
908+
case ATTR_TYPE_BYTE: /* = ATTR_TYPE_INT8 */
909+
bh_memcpy_s(&value.i8, 1, p, 1);
910+
attr_container_printf(", type: byte, value: 0x%x\n",
911+
value.i8 & 0xFF);
912+
p++;
913+
break;
914+
case ATTR_TYPE_SHORT: /* = ATTR_TYPE_INT16 */
915+
bh_memcpy_s(&value.i16, sizeof(int16_t), p, sizeof(int16_t));
812916
attr_container_printf(", type: short, value: 0x%x\n",
813-
value.s & 0xFFFF);
917+
value.i16 & 0xFFFF);
814918
p += 2;
815919
break;
816-
case ATTR_TYPE_INT:
817-
bh_memcpy_s(&value.i, sizeof(int32_t), p, sizeof(int32_t));
818-
attr_container_printf(", type: int, value: 0x%x\n", value.i);
920+
case ATTR_TYPE_INT: /* = ATTR_TYPE_INT32 */
921+
bh_memcpy_s(&value.i32, sizeof(int32_t), p, sizeof(int32_t));
922+
attr_container_printf(", type: int, value: 0x%x\n", value.i32);
819923
p += 4;
820924
break;
821925
case ATTR_TYPE_INT64:
822-
bh_memcpy_s(&value.j, sizeof(uint64_t), p, sizeof(uint64_t));
926+
bh_memcpy_s(&value.i64, sizeof(int64_t), p, sizeof(int64_t));
823927
attr_container_printf(", type: int64, value: 0x%llx\n",
824-
(long long unsigned int)(value.j));
928+
(long long unsigned int)(value.i64));
825929
p += 8;
826930
break;
827-
case ATTR_TYPE_BYTE:
828-
bh_memcpy_s(&value.b, 1, p, 1);
829-
attr_container_printf(", type: byte, value: 0x%x\n",
830-
value.b & 0xFF);
931+
case ATTR_TYPE_UINT8:
932+
bh_memcpy_s(&value.u8, 1, p, 1);
933+
attr_container_printf(", type: uint8, value: 0x%x\n", value.u8);
831934
p++;
832935
break;
833936
case ATTR_TYPE_UINT16:
834-
bh_memcpy_s(&value.c, sizeof(uint16_t), p, sizeof(uint16_t));
835-
attr_container_printf(", type: uint16, value: 0x%x\n", value.c);
937+
bh_memcpy_s(&value.u16, sizeof(uint16_t), p, sizeof(uint16_t));
938+
attr_container_printf(", type: uint16, value: 0x%x\n",
939+
value.u16);
836940
p += 2;
837941
break;
942+
case ATTR_TYPE_UINT32:
943+
bh_memcpy_s(&value.u32, sizeof(uint32_t), p, sizeof(uint32_t));
944+
attr_container_printf(", type: uint32, value: 0x%x\n",
945+
value.u32);
946+
p += 4;
947+
break;
948+
case ATTR_TYPE_UINT64:
949+
bh_memcpy_s(&value.u64, sizeof(uint64_t), p, sizeof(uint64_t));
950+
attr_container_printf(", type: int64, value: 0x%llx\n",
951+
(long long unsigned int)(value.u64));
952+
p += 8;
953+
break;
838954
case ATTR_TYPE_FLOAT:
839955
bh_memcpy_s(&value.f, sizeof(float), p, sizeof(float));
840956
attr_container_printf(", type: float, value: %f\n", value.f);

0 commit comments

Comments
 (0)