You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Queryable protocols would allow cross-extension interop using common interfaces. SWI Prolog could declare built-in protocols for debug printing blobs, byte array access, etc. New protocols could be introduced in newer versions of SWI Prolog without breaking backwards compatibility.
Similar to COM, PL_blob_t could gain a method to query for a protocol by some sort of "GUID" atom. If a blob does not implement a protocol it returns NULL.
As an example, a protocol for fetching a byte array from a blob could be defined as (Rust syntax):
pubstructRawBlob{/// The pointer to the blob's data.////// This is managed by SWI Prolog for copied blobs.pubptr:*mutc_void,/// The length of the blob's data, for copied blobs.////// The length is unused by SWI Prolog for non-copy blobs.publen:usize,}pubstructRawBytes{ptr:*constu8,len:usize,}pubstructBytesProtocol{/// Returns the bytes from the blob's data payload.pubbytes_of:unsafeextern"C"fn(Atom) -> RawBytes,}
Then various types of blobs containing bytes could be defined. e.g. a blob for mmap'd data or large chunk of externally managed memory.
The text was updated successfully, but these errors were encountered:
Ah understood, I'll also cross-post there when I get a chance.
I see some potential. One could also consider implementing a blob type that supports protocols?
A singular blob type has to share the same handlers for acquire & release, and the registration of that blob type is unclear (does each library attempt to register it?).
Right now I'm experimenting with this idea by adding an extra flag to PL_blob_t and then storing the query function in the unused padding field. It seems like a good place to extend the type without changing the size of the structure.
Queryable protocols would allow cross-extension interop using common interfaces. SWI Prolog could declare built-in protocols for debug printing blobs, byte array access, etc. New protocols could be introduced in newer versions of SWI Prolog without breaking backwards compatibility.
Similar to COM,
PL_blob_t
could gain a method to query for a protocol by some sort of "GUID" atom. If a blob does not implement a protocol it returns NULL.As an example, a protocol for fetching a byte array from a blob could be defined as (Rust syntax):
Then various types of blobs containing bytes could be defined. e.g. a blob for mmap'd data or large chunk of externally managed memory.
The text was updated successfully, but these errors were encountered: