Improve wasm api call method usability

This commit is contained in:
Andrey Antukh 2024-11-19 13:28:30 +01:00
parent db2eb2c420
commit 884414d5cf
2 changed files with 87 additions and 67 deletions

View file

@ -0,0 +1,16 @@
;; This Source Code Form is subject to the terms of the Mozilla Public
;; License, v. 2.0. If a copy of the MPL was not distributed with this
;; file, You can obtain one at http://mozilla.org/MPL/2.0/.
;;
;; Copyright (c) KALEIDOS INC
(ns app.render-wasm.helpers
#?(:cljs (:require-macros [app.render-wasm.helpers])))
(defmacro call
"A helper for easy call wasm defined function in a module."
[module name & params]
(let [fn-sym (with-meta (gensym "fn-") {:tag 'function})]
`(let [~fn-sym (cljs.core/unchecked-get ~module ~name)]
(~fn-sym ~@params))))