[wasm-api] Add macros for ref handling
This commit is contained in:
parent
4c8a414a10
commit
62f3c7cf67
|
@ -41,7 +41,15 @@
|
||||||
#undef HB_WASM_BEGIN_DECLS
|
#undef HB_WASM_BEGIN_DECLS
|
||||||
#undef HB_WASM_END_DECLS
|
#undef HB_WASM_END_DECLS
|
||||||
|
|
||||||
|
|
||||||
|
#define nullref 0
|
||||||
#define module_inst wasm_runtime_get_module_inst (exec_env)
|
#define module_inst wasm_runtime_get_module_inst (exec_env)
|
||||||
|
#define HB_REF2OBJ(obj) \
|
||||||
|
hb_##obj##_t *obj = nullptr; \
|
||||||
|
(void) wasm_externref_ref2obj (obj##ref, (void **) &obj)
|
||||||
|
#define HB_OBJ2REF(obj) \
|
||||||
|
uint32_t obj##ref = nullref; \
|
||||||
|
(void) wasm_externref_obj2ref (module_inst, obj, &obj##ref)
|
||||||
|
|
||||||
|
|
||||||
#include "hb-wasm-font.hh"
|
#include "hb-wasm-font.hh"
|
||||||
|
@ -57,9 +65,12 @@ debugprint (HB_WASM_EXEC_ENV
|
||||||
}}
|
}}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
#undef nullref
|
||||||
#undef module_inst
|
#undef module_inst
|
||||||
#undef HB_WASM_EXEC_ENV
|
#undef HB_WASM_EXEC_ENV
|
||||||
|
#undef HB_REF2OBJ
|
||||||
|
#undef HB_OBJ2REF
|
||||||
|
|
||||||
|
|
||||||
/* Define an array of NativeSymbol for the APIs to be exported.
|
/* Define an array of NativeSymbol for the APIs to be exported.
|
||||||
|
|
|
@ -35,14 +35,13 @@ face_t
|
||||||
font_get_face (HB_WASM_EXEC_ENV
|
font_get_face (HB_WASM_EXEC_ENV
|
||||||
font_t fontref)
|
font_t fontref)
|
||||||
{
|
{
|
||||||
hb_font_t *font;
|
HB_REF2OBJ (font);
|
||||||
if (unlikely (!wasm_externref_ref2obj (fontref, (void **) &font)))
|
if (unlikely (!font))
|
||||||
return 0;
|
return nullref;
|
||||||
|
|
||||||
hb_face_t *face = hb_font_get_face (font);
|
hb_face_t *face = hb_font_get_face (font);
|
||||||
|
|
||||||
uint32_t faceref = 0;
|
HB_OBJ2REF (face);
|
||||||
(void) wasm_externref_obj2ref (module_inst, face, &faceref);
|
|
||||||
return faceref;
|
return faceref;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue