From 7fd624c7898e3f1c0d01703f9dd8890612ef1ccd Mon Sep 17 00:00:00 2001 From: Guest0x0 Date: Fri, 24 Jan 2025 06:35:06 +0000 Subject: [PATCH] add `ffi_util` package for FFI related util & add `@ffi_util.RawFunction` type for capture-free function --- ffi_util/ffi_util.mbti | 11 +++++++++++ ffi_util/moon.pkg.json | 1 + ffi_util/raw_function.mbt | 4 ++++ 3 files changed, 16 insertions(+) create mode 100644 ffi_util/ffi_util.mbti create mode 100644 ffi_util/moon.pkg.json create mode 100644 ffi_util/raw_function.mbt diff --git a/ffi_util/ffi_util.mbti b/ffi_util/ffi_util.mbti new file mode 100644 index 000000000..51ac09400 --- /dev/null +++ b/ffi_util/ffi_util.mbti @@ -0,0 +1,11 @@ +package moonbitlang/core/ffi_util + +// Values + +// Types and methods +pub type RawFunction + +// Type aliases + +// Traits + diff --git a/ffi_util/moon.pkg.json b/ffi_util/moon.pkg.json new file mode 100644 index 000000000..0967ef424 --- /dev/null +++ b/ffi_util/moon.pkg.json @@ -0,0 +1 @@ +{} diff --git a/ffi_util/raw_function.mbt b/ffi_util/raw_function.mbt new file mode 100644 index 000000000..34939490b --- /dev/null +++ b/ffi_util/raw_function.mbt @@ -0,0 +1,4 @@ +/// A compiler builtin type for raw functions, i.e. functions without any capture. +/// This is useful when passing callbacks to FFI. +/// Here `T` must be a function type in `RawFunction[T]` +pub type RawFunction[T]