Skip to content

Commit 9b61bb9

Browse files
committed
webassembly/proxy_c: Provide constants for fixed JsProxy refs.
Signed-off-by: Damien George <[email protected]>
1 parent f6e23fd commit 9b61bb9

File tree

3 files changed

+6
-2
lines changed

3 files changed

+6
-2
lines changed

ports/webassembly/modjs.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535

3636
void mp_module_js_attr(mp_obj_t self_in, qstr attr, mp_obj_t *dest) {
3737
mp_obj_jsproxy_t global_this;
38-
global_this.ref = 0;
38+
global_this.ref = MP_OBJ_JSPROXY_REF_GLOBAL_THIS;
3939
mp_obj_jsproxy_attr(MP_OBJ_FROM_PTR(&global_this), attr, dest);
4040
}
4141

ports/webassembly/proxy_c.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ void proxy_convert_mp_to_js_obj_cside(mp_obj_t obj, uint32_t *out) {
202202
out[2] = (uintptr_t)str;
203203
} else if (obj == mp_const_undefined) {
204204
kind = PROXY_KIND_MP_JSPROXY;
205-
out[1] = 1;
205+
out[1] = MP_OBJ_JSPROXY_REF_UNDEFINED;
206206
} else if (mp_obj_is_jsproxy(obj)) {
207207
kind = PROXY_KIND_MP_JSPROXY;
208208
out[1] = mp_obj_jsproxy_get_ref(obj);

ports/webassembly/proxy_c.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,10 @@
2828

2929
#include "py/obj.h"
3030

31+
// Fixed JsProxy references.
32+
#define MP_OBJ_JSPROXY_REF_GLOBAL_THIS (0)
33+
#define MP_OBJ_JSPROXY_REF_UNDEFINED (1)
34+
3135
// proxy value number of items
3236
#define PVN (3)
3337

0 commit comments

Comments
 (0)