From 42d121ae79ce547f1bbe82b9fa771725604546d3 Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Thu, 23 Feb 2023 11:05:19 -0700 Subject: [PATCH] [wasm] Add hb-wasm-api.cc --- src/hb-wasm-api-list.hh | 1 - src/hb-wasm-api.cc | 45 +++++++++++++++++++++++++++++++++++++++++ src/hb-wasm-api.hh | 20 ------------------ src/hb-wasm-shape.cc | 1 + src/meson.build | 2 +- 5 files changed, 47 insertions(+), 22 deletions(-) create mode 100644 src/hb-wasm-api.cc diff --git a/src/hb-wasm-api-list.hh b/src/hb-wasm-api-list.hh index a20782b7e..11ec2b618 100644 --- a/src/hb-wasm-api-list.hh +++ b/src/hb-wasm-api-list.hh @@ -27,7 +27,6 @@ #include "hb-wasm-api.hh" -#include "hb-wasm-font.hh" #ifdef HB_DEBUG_WASM namespace hb { namespace wasm { diff --git a/src/hb-wasm-api.cc b/src/hb-wasm-api.cc new file mode 100644 index 000000000..64537b50c --- /dev/null +++ b/src/hb-wasm-api.cc @@ -0,0 +1,45 @@ +/* + * Copyright © 2023 Behdad Esfahbod + * + * This is part of HarfBuzz, a text shaping library. + * + * Permission is hereby granted, without written agreement and without + * license or royalty fees, to use, copy, modify, and distribute this + * software and its documentation for any purpose, provided that the + * above copyright notice and the following two paragraphs appear in + * all copies of this software. + * + * IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR + * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES + * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN + * IF THE COPYRIGHT HOLDER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH + * DAMAGE. + * + * THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, + * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS + * ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO + * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. + */ + +#include "hb-wasm-api.hh" + + +#define nullref 0 +#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" + + +#undef nullref +#undef module_inst +#undef HB_WASM_EXEC_ENV +#undef HB_REF2OBJ +#undef HB_OBJ2REF diff --git a/src/hb-wasm-api.hh b/src/hb-wasm-api.hh index 27e8e7890..c696a9471 100644 --- a/src/hb-wasm-api.hh +++ b/src/hb-wasm-api.hh @@ -42,24 +42,4 @@ #undef HB_WASM_END_DECLS -#define nullref 0 -#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-api-list.hh" - - -#undef nullref -#undef module_inst -#undef HB_WASM_EXEC_ENV -#undef HB_REF2OBJ -#undef HB_OBJ2REF - - #endif /* HB_WASM_API_HH */ diff --git a/src/hb-wasm-shape.cc b/src/hb-wasm-shape.cc index 1a57915ab..ecb42dbe1 100644 --- a/src/hb-wasm-shape.cc +++ b/src/hb-wasm-shape.cc @@ -31,6 +31,7 @@ #ifdef HAVE_WASM #include "hb-wasm-api.hh" +#include "hb-wasm-api-list.hh" /* diff --git a/src/meson.build b/src/meson.build index f5a1ea975..1842bf44a 100644 --- a/src/meson.build +++ b/src/meson.build @@ -324,7 +324,7 @@ hb_glib_headers = files('hb-glib.h') hb_graphite2_sources = files('hb-graphite2.cc') hb_graphite2_headers = files('hb-graphite2.h') -hb_wasm_sources = files('hb-wasm-shape.cc') +hb_wasm_sources = files('hb-wasm-shape.cc', 'hb-wasm-api.cc') hb_wasm_headers = files() # System-dependent sources and headers