[wasm-api] Make ref types actual pointers on the wasm side

This commit is contained in:
Behdad Esfahbod 2023-02-23 15:03:03 -07:00
parent cbd5c554fb
commit d38f02ab30
5 changed files with 18 additions and 19 deletions

View File

@ -35,7 +35,7 @@ namespace wasm {
void void
buffer_copy_contents (HB_WASM_EXEC_ENV_COMPOUND buffer_copy_contents (HB_WASM_EXEC_ENV_COMPOUND
buffer_t bufferref) ptr_t(buffer_t) bufferref)
{ {
HB_RETURN_TYPE (buffer_contents_t, ret); HB_RETURN_TYPE (buffer_contents_t, ret);
HB_REF2OBJ (buffer); HB_REF2OBJ (buffer);

View File

@ -33,7 +33,7 @@ namespace wasm {
void void
face_reference_table (HB_WASM_EXEC_ENV_COMPOUND face_reference_table (HB_WASM_EXEC_ENV_COMPOUND
face_t faceref, ptr_t(face_t) faceref,
tag_t table_tag) tag_t table_tag)
{ {
HB_RETURN_TYPE (blob_t, ret); HB_RETURN_TYPE (blob_t, ret);

View File

@ -31,9 +31,9 @@ namespace hb {
namespace wasm { namespace wasm {
face_t ptr_t(face_t)
font_get_face (HB_WASM_EXEC_ENV font_get_face (HB_WASM_EXEC_ENV
font_t fontref) ptr_t(font_t) fontref)
{ {
HB_REF2OBJ (font); HB_REF2OBJ (font);

View File

@ -65,9 +65,6 @@ HB_WASM_BEGIN_DECLS
#ifndef bool_t #ifndef bool_t
#define bool_t uint32_t #define bool_t uint32_t
#endif #endif
#ifndef ref_t
#define ref_t uint32_t
#endif
#ifndef ptr_t #ifndef ptr_t
#define ptr_t(type_t) type_t * #define ptr_t(type_t) type_t *
#endif #endif
@ -78,10 +75,6 @@ typedef uint32_t hb_mask_t;
typedef uint32_t tag_t; typedef uint32_t tag_t;
#define TAG(c1,c2,c3,c4) ((tag_t)((((uint32_t)(c1)&0xFF)<<24)|(((uint32_t)(c2)&0xFF)<<16)|(((uint32_t)(c3)&0xFF)<<8)|((uint32_t)(c4)&0xFF))) #define TAG(c1,c2,c3,c4) ((tag_t)((((uint32_t)(c1)&0xFF)<<24)|(((uint32_t)(c2)&0xFF)<<16)|(((uint32_t)(c3)&0xFF)<<8)|((uint32_t)(c4)&0xFF)))
typedef ref_t face_t;
typedef ref_t font_t;
typedef ref_t buffer_t;
/* blob */ /* blob */
@ -124,28 +117,34 @@ typedef struct
/* TODO buffer_contents_free */ /* TODO buffer_contents_free */
typedef struct buffer_t buffer_t;
HB_WASM_API_COMPOUND (buffer_contents_t, buffer_copy_contents) (HB_WASM_EXEC_ENV_COMPOUND HB_WASM_API_COMPOUND (buffer_contents_t, buffer_copy_contents) (HB_WASM_EXEC_ENV_COMPOUND
buffer_t bufferref); ptr_t(buffer_t));
/* face */ /* face */
typedef struct face_t face_t;
HB_WASM_API_COMPOUND (blob_t, face_reference_table) (HB_WASM_EXEC_ENV_COMPOUND HB_WASM_API_COMPOUND (blob_t, face_reference_table) (HB_WASM_EXEC_ENV_COMPOUND
face_t faceref, ptr_t(face_t),
tag_t table_tag); tag_t table_tag);
/* font */ /* font */
HB_WASM_API (face_t, font_get_face) (HB_WASM_EXEC_ENV typedef struct font_t font_t;
font_t fontref);
HB_WASM_API (ptr_t(face_t), font_get_face) (HB_WASM_EXEC_ENV
ptr_t(font_t));
/* shape interface */ /* shape interface */
HB_WASM_INTERFACE (bool_t, shape) (HB_WASM_EXEC_ENV HB_WASM_INTERFACE (bool_t, shape) (HB_WASM_EXEC_ENV
font_t fontref, ptr_t(font_t),
buffer_t bufferref); ptr_t(buffer_t));
HB_WASM_END_DECLS HB_WASM_END_DECLS

View File

@ -8,9 +8,9 @@ void debugprint1 (char *s, int32_t);
void debugprint2 (char *s, int32_t, int32_t); void debugprint2 (char *s, int32_t, int32_t);
bool_t bool_t
shape (font_t font, buffer_t buffer) shape (font_t *font, buffer_t *buffer)
{ {
face_t face = font_get_face (font); face_t *face = font_get_face (font);
blob_t blob = face_reference_table (face, TAG ('c','m','a','p')); blob_t blob = face_reference_table (face, TAG ('c','m','a','p'));