summaryrefslogtreecommitdiffstats
path: root/toolkit/components/uniffi-bindgen-gecko-js/src/templates/js/CallbackInterface.jsm
diff options
context:
space:
mode:
Diffstat (limited to 'toolkit/components/uniffi-bindgen-gecko-js/src/templates/js/CallbackInterface.jsm')
-rw-r--r--toolkit/components/uniffi-bindgen-gecko-js/src/templates/js/CallbackInterface.jsm23
1 files changed, 23 insertions, 0 deletions
diff --git a/toolkit/components/uniffi-bindgen-gecko-js/src/templates/js/CallbackInterface.jsm b/toolkit/components/uniffi-bindgen-gecko-js/src/templates/js/CallbackInterface.jsm
new file mode 100644
index 0000000000..74192e46cb
--- /dev/null
+++ b/toolkit/components/uniffi-bindgen-gecko-js/src/templates/js/CallbackInterface.jsm
@@ -0,0 +1,23 @@
+{%- let cbi = ci.get_callback_interface_definition(name).unwrap() %}
+{#- See CallbackInterfaceRuntime.jsm and CallbackInterfaceHandler.jsm for the callback interface handler definition, referenced here as `{{ cbi.handler() }}` #}
+class {{ ffi_converter }} extends FfiConverter {
+ static lower(callbackObj) {
+ return {{ cbi.handler() }}.storeCallbackObj(callbackObj)
+ }
+
+ static lift(handleId) {
+ return {{ cbi.handler() }}.getCallbackObj(handleId)
+ }
+
+ static read(dataStream) {
+ return this.lift(dataStream.readInt64())
+ }
+
+ static write(dataStream, callbackObj) {
+ dataStream.writeInt64(this.lower(callbackObj))
+ }
+
+ static computeSize(callbackObj) {
+ return 8;
+ }
+}