webassembly/proxy_c: Provide constants for fixed JsProxy refs.

Signed-off-by: Damien George <damien@micropython.org>
This commit is contained in:
Damien George
2025-07-21 14:59:07 +10:00
parent f6e23fdef1
commit 9b61bb93f9
3 changed files with 6 additions and 2 deletions

View File

@@ -35,7 +35,7 @@
void mp_module_js_attr(mp_obj_t self_in, qstr attr, mp_obj_t *dest) {
mp_obj_jsproxy_t global_this;
global_this.ref = 0;
global_this.ref = MP_OBJ_JSPROXY_REF_GLOBAL_THIS;
mp_obj_jsproxy_attr(MP_OBJ_FROM_PTR(&global_this), attr, dest);
}

View File

@@ -202,7 +202,7 @@ void proxy_convert_mp_to_js_obj_cside(mp_obj_t obj, uint32_t *out) {
out[2] = (uintptr_t)str;
} else if (obj == mp_const_undefined) {
kind = PROXY_KIND_MP_JSPROXY;
out[1] = 1;
out[1] = MP_OBJ_JSPROXY_REF_UNDEFINED;
} else if (mp_obj_is_jsproxy(obj)) {
kind = PROXY_KIND_MP_JSPROXY;
out[1] = mp_obj_jsproxy_get_ref(obj);

View File

@@ -28,6 +28,10 @@
#include "py/obj.h"
// Fixed JsProxy references.
#define MP_OBJ_JSPROXY_REF_GLOBAL_THIS (0)
#define MP_OBJ_JSPROXY_REF_UNDEFINED (1)
// proxy value number of items
#define PVN (3)