Revert several commits adding crossreferences in docs

Revert "Add functions header in builtin types"

This reverts commit 8c7a77aa92.

Revert "Add cross-link for tagged union type mention"

This reverts commit 5c1b2d3f7c.

Revert "Add section links to headers in docs"

This reverts commit 5175fdc5b3.
This commit is contained in:
Joshua Suskalo 2024-11-22 10:16:24 -05:00
parent 8c7a77aa92
commit 98cbf350f9
No known key found for this signature in database
GPG key ID: 9B6BA586EFF1B9F0
13 changed files with 147 additions and 151 deletions

View file

@ -1,7 +1,7 @@
<!DOCTYPE html PUBLIC ""
"">
<html><head><meta charset="UTF-8" /><title>Getting Started</title><link rel="stylesheet" type="text/css" href="css/default.css" /><link rel="stylesheet" type="text/css" href="css/highlight.css" /><script type="text/javascript" src="js/highlight.min.js"></script><script type="text/javascript" src="js/jquery.min.js"></script><script type="text/javascript" src="js/page_effects.js"></script><script>hljs.initHighlightingOnLoad();</script></head><body><div id="header"><h2>Generated by <a href="https://github.com/weavejester/codox">Codox</a></h2><h1><a href="index.html"><span class="project-title"><span class="project-name">coffi</span> <span class="project-version">v1.0.486</span></span></a></h1></div><div class="sidebar primary"><h3 class="no-link"><span class="inner">Project</span></h3><ul class="index-link"><li class="depth-1 "><a href="index.html"><div class="inner">Index</div></a></li></ul><h3 class="no-link"><span class="inner">Topics</span></h3><ul><li class="depth-1 current"><a href="01-Getting-Started.html"><div class="inner"><span>Getting Started</span></div></a></li><li class="depth-1 "><a href="02-Memory-Management.html"><div class="inner"><span>Memory Management</span></div></a></li><li class="depth-1 "><a href="03-Builtin-Types.html"><div class="inner"><span>Built-in Types **WIP**</span></div></a></li><li class="depth-1 "><a href="04-Custom-Types.html"><div class="inner"><span>Custom Types</span></div></a></li><li class="depth-1 "><a href="05-Low-Level-Wrappers.html"><div class="inner"><span>Low-Level Wrappers</span></div></a></li><li class="depth-1 "><a href="50-Data-Model.html"><div class="inner"><span>Data Model</span></div></a></li><li class="depth-1 "><a href="99-Benchmarks.html"><div class="inner"><span>Benchmarks **OUTDATED**</span></div></a></li></ul><h3 class="no-link"><span class="inner">Namespaces</span></h3><ul><li class="depth-1"><div class="no-link"><div class="inner"><span class="tree"><span class="top"></span><span class="bottom"></span></span><span>coffi</span></div></div></li><li class="depth-2 branch"><a href="coffi.ffi.html"><div class="inner"><span class="tree"><span class="top"></span><span class="bottom"></span></span><span>ffi</span></div></a></li><li class="depth-2 branch"><a href="coffi.layout.html"><div class="inner"><span class="tree"><span class="top"></span><span class="bottom"></span></span><span>layout</span></div></a></li><li class="depth-2"><a href="coffi.mem.html"><div class="inner"><span class="tree"><span class="top"></span><span class="bottom"></span></span><span>mem</span></div></a></li></ul></div><div class="document" id="content"><div class="doc"><div class="markdown"><h1><a href="#getting-started" id="getting-started"></a>Getting Started</h1>
<h2><a href="#installation-installation" id="installation-installation"></a>Installation {#installation}</h2>
<h2><a href="#installation" id="installation"></a>Installation</h2>
<p>This library is available on Clojars. Add one of the following entries to the <code>:deps</code> key of your <code>deps.edn</code>:</p>
<pre><code class="language-clojure">org.suskalo/coffi {:mvn/version "x.y.z"}
io.github.IGJoshua/coffi {:git/tag "x.y.z" :git/sha "abcdef0"}
@ -21,7 +21,7 @@ io.github.IGJoshua/coffi {:git/tag "x.y.z" :git/sha "abcdef0"}
</code></pre>
<p>Other build tools should provide similar functionality if you check their documentation.</p>
<p>When creating an executable jar file, you can avoid the need to pass this argument by adding the manifest attribute <code>Enable-Native-Access: ALL-UNNAMED</code> to your jar.</p>
<h2><a href="#basic-usage-usage" id="basic-usage-usage"></a>Basic Usage {#usage}</h2>
<h2><a href="#basic-usage" id="basic-usage"></a>Basic Usage</h2>
<p>There are two major components to coffi and interacting with native code: manipulating off-heap memory, and loading native code for use with Clojure.</p>
<p>In the simplest cases, the native functions you call will work exclusively with built-in types, for example the function <code>strlen</code> from libc.</p>
<pre><code class="language-clojure">(require '[coffi.mem :as mem :refer [defalias]])
@ -48,7 +48,7 @@ io.github.IGJoshua/coffi {:git/tag "x.y.z" :git/sha "abcdef0"}
</code></pre>
<p>This will load libz from the lib subdirectory of the current working directory. As you can see this requires the entire filename, including platform-specific file extensions.</p>
<p>If a library is attempted to be loaded but doesnt exist or otherwise cant be loaded, an exception is thrown. This can be convenient as any namespace with a <code>load-library</code> call at the top level cannot be required without the library being able to be loaded.</p>
<h3><a href="#primitive-types-primitive-types" id="primitive-types-primitive-types"></a>Primitive Types {#primitive-types}</h3>
<h3><a href="#primitive-types" id="primitive-types"></a>Primitive Types</h3>
<p>Coffi defines a basic set of primitive types:</p>
<ul>
<li>byte</li>
@ -61,7 +61,7 @@ io.github.IGJoshua/coffi {:git/tag "x.y.z" :git/sha "abcdef0"}
<li>pointer</li>
</ul>
<p>Each of these types maps to their C counterpart. Values of any of these primitive types except for <code>pointer</code> will be cast with their corresponding Clojure function when they are passed as arguments to native functions. Additionally, the <code>c-string</code> type is defined, although it is not primitive.</p>
<h3><a href="#composite-types-composite-types" id="composite-types-composite-types"></a>Composite Types {#composite-types}</h3>
<h3><a href="#composite-types" id="composite-types"></a>Composite Types</h3>
<p>In addition, some composite types are also defined in coffi, including struct and union types (unions will be discussed with serialization and deserialization). For an example C struct and function:</p>
<pre><code class="language-c">typedef struct point {
float x;
@ -117,14 +117,14 @@ Point zero(void) {
<p>Arrays are also supported via a type argument. Keep in mind that they are the array itself, and not a pointer to the array like you might see in certain cases in C.</p>
<pre><code class="language-clojure">[::mem/array ::mem/int 3]
</code></pre>
<h3><a href="#callbacks-callbacks" id="callbacks-callbacks"></a>Callbacks {#callbacks}</h3>
<h3><a href="#callbacks" id="callbacks"></a>Callbacks</h3>
<p>In addition to these composite types, there is also support for Clojure functions.</p>
<pre><code class="language-clojure">[::ffi/fn [::mem/c-string] ::mem/int]
</code></pre>
<p>Be aware though that if an exception is thrown out of a callback that is called from C, the JVM will crash. The resulting crash log should include the exception type and message in the registers section, but its important to be aware of all the same. Ideally you should test your callbacks before actually passing them to native code.</p>
<p>When writing a wrapper library for a C library, it may be a good choice to wrap all passed Clojure functions in an additional function which catches all throwables, potentially notifies the user in some manner (e.g. logging), and returns a default value. This is on the wrapper librarys developer to decide when and where this is appropriate, as in some cases no reasonable default return value can be determined and it is most sensible to simply crash the JVM. This is the reason that coffi defaults to this behavior, as in the authors opinion it is better to fail hard and fast rather than to attempt to produce a default and cause unexpected behavior later.</p>
<p>Another important thing to keep in mind is the expected lifetime of the function that you pass to native code. For example it is perfectly fine to pass an anonymous function to a native function if the callback will never be called again once the native function returns. If however it saves the callback for later use the JVM may collect it prematurely, causing a crash when the callback is later called by native code.</p>
<h3><a href="#variadic-functions-variadic-functions" id="variadic-functions-variadic-functions"></a>Variadic Functions {#variadic-functions}</h3>
<h3><a href="#variadic-functions" id="variadic-functions"></a>Variadic Functions</h3>
<p>Some native functions can take any number of arguments, and in these cases coffi provides <code>vacfn-factory</code> (for “varargs C function factory”).</p>
<pre><code class="language-clojure">(def printf-factory (ffi/vacfn-factory "printf" [::mem/c-string] ::mem/int))
</code></pre>
@ -136,7 +136,7 @@ Point zero(void) {
</code></pre>
<p>At the moment there is no equivalent to <code>defcfn</code> for varargs functions.</p>
<p>Some native functions that are variadic use the type <code>va_list</code> to make it easier for other languages to call them in their FFI. At the time of writing, coffi does not support va-list, however it is a planned feature.</p>
<h3><a href="#global-variables-globals" id="global-variables-globals"></a>Global Variables {#globals}</h3>
<h3><a href="#global-variables" id="global-variables"></a>Global Variables</h3>
<p>Some libraries include global variables or constants accessible through symbols. To start with, constant values stored in symbols can be fetched with <code>const</code>, or the parallel macro <code>defconst</code></p>
<pre><code class="language-clojure">(def some-const (ffi/const "some_const" ::mem/int))
(ffi/defconst some-const "some_const" ::mem/int)
@ -154,7 +154,7 @@ Point zero(void) {
<p>Be aware however that there is no synchronization on these types. The value being read is not read atomically, so you may see an inconsistent state if the value is being mutated on another thread.</p>
<p>A parallel function <code>fswap!</code> is also provided, but it does not provide any atomic semantics either.</p>
<p>The memory that backs the static variable can be fetched with the function <code>static-variable-segment</code>, which can be used to pass a pointer to the static variable to native functions that require it.</p>
<h3><a href="#complex-wrappers-complex-wrappers" id="complex-wrappers-complex-wrappers"></a>Complex Wrappers {#complex-wrappers}</h3>
<h3><a href="#complex-wrappers" id="complex-wrappers"></a>Complex Wrappers</h3>
<p>Some functions require more complex code to map nicely to a Clojure function. The <code>defcfn</code> macro provides facilities to wrap the native function with some Clojure code to make this easier.</p>
<pre><code class="language-clojure">(defcfn takes-array
"takes_array_with_count" [::mem/pointer ::mem/long] ::mem/void

View file

@ -1,14 +1,13 @@
<!DOCTYPE html PUBLIC ""
"">
<html><head><meta charset="UTF-8" /><title>Built-in Types **WIP**</title><link rel="stylesheet" type="text/css" href="css/default.css" /><link rel="stylesheet" type="text/css" href="css/highlight.css" /><script type="text/javascript" src="js/highlight.min.js"></script><script type="text/javascript" src="js/jquery.min.js"></script><script type="text/javascript" src="js/page_effects.js"></script><script>hljs.initHighlightingOnLoad();</script></head><body><div id="header"><h2>Generated by <a href="https://github.com/weavejester/codox">Codox</a></h2><h1><a href="index.html"><span class="project-title"><span class="project-name">coffi</span> <span class="project-version">v1.0.486</span></span></a></h1></div><div class="sidebar primary"><h3 class="no-link"><span class="inner">Project</span></h3><ul class="index-link"><li class="depth-1 "><a href="index.html"><div class="inner">Index</div></a></li></ul><h3 class="no-link"><span class="inner">Topics</span></h3><ul><li class="depth-1 "><a href="01-Getting-Started.html"><div class="inner"><span>Getting Started</span></div></a></li><li class="depth-1 "><a href="02-Memory-Management.html"><div class="inner"><span>Memory Management</span></div></a></li><li class="depth-1 current"><a href="03-Builtin-Types.html"><div class="inner"><span>Built-in Types **WIP**</span></div></a></li><li class="depth-1 "><a href="04-Custom-Types.html"><div class="inner"><span>Custom Types</span></div></a></li><li class="depth-1 "><a href="05-Low-Level-Wrappers.html"><div class="inner"><span>Low-Level Wrappers</span></div></a></li><li class="depth-1 "><a href="50-Data-Model.html"><div class="inner"><span>Data Model</span></div></a></li><li class="depth-1 "><a href="99-Benchmarks.html"><div class="inner"><span>Benchmarks **OUTDATED**</span></div></a></li></ul><h3 class="no-link"><span class="inner">Namespaces</span></h3><ul><li class="depth-1"><div class="no-link"><div class="inner"><span class="tree"><span class="top"></span><span class="bottom"></span></span><span>coffi</span></div></div></li><li class="depth-2 branch"><a href="coffi.ffi.html"><div class="inner"><span class="tree"><span class="top"></span><span class="bottom"></span></span><span>ffi</span></div></a></li><li class="depth-2 branch"><a href="coffi.layout.html"><div class="inner"><span class="tree"><span class="top"></span><span class="bottom"></span></span><span>layout</span></div></a></li><li class="depth-2"><a href="coffi.mem.html"><div class="inner"><span class="tree"><span class="top"></span><span class="bottom"></span></span><span>mem</span></div></a></li></ul></div><div class="document" id="content"><div class="doc"><div class="markdown"><h1><a href="#built-in-types-wip" id="built-in-types-wip"></a>Built-in Types <strong>WIP</strong></h1>
<h3><a href="#todo-primitives-primitives" id="todo-primitives-primitives"></a>TODO Primitives {#primitives}</h3>
<h3><a href="#todo-arrays-arrays" id="todo-arrays-arrays"></a>TODO Arrays {#arrays}</h3>
<h3><a href="#todo-pointers-pointers" id="todo-pointers-pointers"></a>TODO Pointers {#pointers}</h3>
<h3><a href="#todo-structs-structs" id="todo-structs-structs"></a>TODO Structs {#structs}</h3>
<h3><a href="#todo-enums-enums" id="todo-enums-enums"></a>TODO Enums {#enums}</h3>
<h3><a href="#todo-flagsets-flagsets" id="todo-flagsets-flagsets"></a>TODO Flagsets {#flagsets}</h3>
<h3><a href="#todo-functions-functions" id="todo-functions-functions"></a>TODO Functions {#functions}</h3>
<h3><a href="#unions-unions" id="unions-unions"></a>Unions {#unions}</h3>
<h3><a href="#primitives" id="primitives"></a>Primitives</h3>
<h3><a href="#arrays" id="arrays"></a>Arrays</h3>
<h3><a href="#pointers" id="pointers"></a>Pointers</h3>
<h3><a href="#structs" id="structs"></a>Structs</h3>
<h3><a href="#enums" id="enums"></a>Enums</h3>
<h3><a href="#flagsets" id="flagsets"></a>Flagsets</h3>
<h3><a href="#unions" id="unions"></a>Unions</h3>
<p>Unions in coffi are rather limited. They can be serialized, but not deserialized without external information.</p>
<pre><code class="language-clojure">[::mem/union
#{::mem/float ::mem/double}
@ -16,7 +15,7 @@
(float? %) ::mem/float
(double? %) ::mem/double)]
</code></pre>
<p>This is a minimal union in coffi. If the <code>:dispatch</code> keyword argument is not passed, then the union cannot be serialized, as coffi would not know which type to serialize the values as. In <a href="04-Custom-Types.md#tagged-union">the example with a tagged union</a>, a dispatch function was not provided because the type was only used for the native layout.</p>
<p>This is a minimal union in coffi. If the <code>:dispatch</code> keyword argument is not passed, then the union cannot be serialized, as coffi would not know which type to serialize the values as. In the example with a tagged union, a dispatch function was not provided because the type was only used for the native layout.</p>
<p>In addition to a dispatch function, when serializing a union an extract function may also be provided. In the case of the value in the tagged union from before, it could be represented for serialization purposes like so:</p>
<pre><code class="language-clojure">[::mem/union
#{::mem/int ::mem/c-string}
@ -27,5 +26,5 @@
</code></pre>
<p>This union however would not include the tag when serialized.</p>
<p>If a union is deserialized, then all that coffi does is to allocate a new segment of the appropriate size with an implicit arena so that it may later be garbage collected, and copies the data from the source segment into it. Its up to the user to call <code>deserialize-from</code> on that segment with the appropriate type.</p>
<h3><a href="#todo-raw-types-raw-types" id="todo-raw-types-raw-types"></a>TODO Raw Types {#raw-types}</h3>
<h3><a href="#raw-types" id="raw-types"></a>Raw Types</h3>
</div></div></div></body></html>

View file

@ -3,7 +3,7 @@
<html><head><meta charset="UTF-8" /><title>Custom Types</title><link rel="stylesheet" type="text/css" href="css/default.css" /><link rel="stylesheet" type="text/css" href="css/highlight.css" /><script type="text/javascript" src="js/highlight.min.js"></script><script type="text/javascript" src="js/jquery.min.js"></script><script type="text/javascript" src="js/page_effects.js"></script><script>hljs.initHighlightingOnLoad();</script></head><body><div id="header"><h2>Generated by <a href="https://github.com/weavejester/codox">Codox</a></h2><h1><a href="index.html"><span class="project-title"><span class="project-name">coffi</span> <span class="project-version">v1.0.486</span></span></a></h1></div><div class="sidebar primary"><h3 class="no-link"><span class="inner">Project</span></h3><ul class="index-link"><li class="depth-1 "><a href="index.html"><div class="inner">Index</div></a></li></ul><h3 class="no-link"><span class="inner">Topics</span></h3><ul><li class="depth-1 "><a href="01-Getting-Started.html"><div class="inner"><span>Getting Started</span></div></a></li><li class="depth-1 "><a href="02-Memory-Management.html"><div class="inner"><span>Memory Management</span></div></a></li><li class="depth-1 "><a href="03-Builtin-Types.html"><div class="inner"><span>Built-in Types **WIP**</span></div></a></li><li class="depth-1 current"><a href="04-Custom-Types.html"><div class="inner"><span>Custom Types</span></div></a></li><li class="depth-1 "><a href="05-Low-Level-Wrappers.html"><div class="inner"><span>Low-Level Wrappers</span></div></a></li><li class="depth-1 "><a href="50-Data-Model.html"><div class="inner"><span>Data Model</span></div></a></li><li class="depth-1 "><a href="99-Benchmarks.html"><div class="inner"><span>Benchmarks **OUTDATED**</span></div></a></li></ul><h3 class="no-link"><span class="inner">Namespaces</span></h3><ul><li class="depth-1"><div class="no-link"><div class="inner"><span class="tree"><span class="top"></span><span class="bottom"></span></span><span>coffi</span></div></div></li><li class="depth-2 branch"><a href="coffi.ffi.html"><div class="inner"><span class="tree"><span class="top"></span><span class="bottom"></span></span><span>ffi</span></div></a></li><li class="depth-2 branch"><a href="coffi.layout.html"><div class="inner"><span class="tree"><span class="top"></span><span class="bottom"></span></span><span>layout</span></div></a></li><li class="depth-2"><a href="coffi.mem.html"><div class="inner"><span class="tree"><span class="top"></span><span class="bottom"></span></span><span>mem</span></div></a></li></ul></div><div class="document" id="content"><div class="doc"><div class="markdown"><h1><a href="#custom-types" id="custom-types"></a>Custom Types</h1>
<p>Custom types with serializers and deserializers may be created. This is done using two sets of three multimethods which can be extended by the user. For any given type, only one set need be implemented.</p>
<p>Two examples of custom types are given here, one is a 3d vector, and the other an example of a tagged union.</p>
<h3><a href="#vector3-vector" id="vector3-vector"></a>Vector3 {#vector}</h3>
<h3><a href="#vector3" id="vector3"></a>Vector3</h3>
<p>For the vector type, it will serialize to a pointer to an array of three floats.</p>
<p>The multimethod <code>primitive-type</code> returns the primitive type that a given type serializes to. For this example, it should be a pointer.</p>
<pre><code class="language-clojure">(defmethod mem/primitive-type ::vector
@ -32,7 +32,7 @@
(deserialize ::vector))))
</code></pre>
<p>This function takes an arena and returns the deserialized vector, and it will free the pointer when the arena closes.</p>
<h3><a href="#tagged-union-tagged-union" id="tagged-union-tagged-union"></a>Tagged Union {#tagged-union}</h3>
<h3><a href="#tagged-union" id="tagged-union"></a>Tagged Union</h3>
<p>For the tagged union type, we will represent the value as a vector of a keyword naming the tag and the value. The type itself will need to take arguments, similar to <code>struct</code>. For example, if we were to represent a result type like in Rust, we might have the following values:</p>
<pre><code class="language-clojure">[:ok 5]
[:err "Invalid number format"]

View file

@ -1,7 +1,7 @@
<!DOCTYPE html PUBLIC ""
"">
<html><head><meta charset="UTF-8" /><title>Low-Level Wrappers</title><link rel="stylesheet" type="text/css" href="css/default.css" /><link rel="stylesheet" type="text/css" href="css/highlight.css" /><script type="text/javascript" src="js/highlight.min.js"></script><script type="text/javascript" src="js/jquery.min.js"></script><script type="text/javascript" src="js/page_effects.js"></script><script>hljs.initHighlightingOnLoad();</script></head><body><div id="header"><h2>Generated by <a href="https://github.com/weavejester/codox">Codox</a></h2><h1><a href="index.html"><span class="project-title"><span class="project-name">coffi</span> <span class="project-version">v1.0.486</span></span></a></h1></div><div class="sidebar primary"><h3 class="no-link"><span class="inner">Project</span></h3><ul class="index-link"><li class="depth-1 "><a href="index.html"><div class="inner">Index</div></a></li></ul><h3 class="no-link"><span class="inner">Topics</span></h3><ul><li class="depth-1 "><a href="01-Getting-Started.html"><div class="inner"><span>Getting Started</span></div></a></li><li class="depth-1 "><a href="02-Memory-Management.html"><div class="inner"><span>Memory Management</span></div></a></li><li class="depth-1 "><a href="03-Builtin-Types.html"><div class="inner"><span>Built-in Types **WIP**</span></div></a></li><li class="depth-1 "><a href="04-Custom-Types.html"><div class="inner"><span>Custom Types</span></div></a></li><li class="depth-1 current"><a href="05-Low-Level-Wrappers.html"><div class="inner"><span>Low-Level Wrappers</span></div></a></li><li class="depth-1 "><a href="50-Data-Model.html"><div class="inner"><span>Data Model</span></div></a></li><li class="depth-1 "><a href="99-Benchmarks.html"><div class="inner"><span>Benchmarks **OUTDATED**</span></div></a></li></ul><h3 class="no-link"><span class="inner">Namespaces</span></h3><ul><li class="depth-1"><div class="no-link"><div class="inner"><span class="tree"><span class="top"></span><span class="bottom"></span></span><span>coffi</span></div></div></li><li class="depth-2 branch"><a href="coffi.ffi.html"><div class="inner"><span class="tree"><span class="top"></span><span class="bottom"></span></span><span>ffi</span></div></a></li><li class="depth-2 branch"><a href="coffi.layout.html"><div class="inner"><span class="tree"><span class="top"></span><span class="bottom"></span></span><span>layout</span></div></a></li><li class="depth-2"><a href="coffi.mem.html"><div class="inner"><span class="tree"><span class="top"></span><span class="bottom"></span></span><span>mem</span></div></a></li></ul></div><div class="document" id="content"><div class="doc"><div class="markdown"><h1><a href="#low-level-wrappers" id="low-level-wrappers"></a>Low-Level Wrappers</h1>
<h3><a href="#unwrapped-native-handles-unwrapped-native-handles" id="unwrapped-native-handles-unwrapped-native-handles"></a>Unwrapped Native Handles {#unwrapped-native-handles}</h3>
<h3><a href="#unwrapped-native-handles" id="unwrapped-native-handles"></a>Unwrapped Native Handles</h3>
<p>Some native libraries work with handles to large amounts of data at once, making it undesirable to marshal data back and forth from Clojure, both because its not necessary to work with the data in Clojure directly, or also because of the high (de)serialization costs associated with marshaling. In cases like these, unwrapped native handles are desirable.</p>
<p>The functions <code>make-downcall</code> and <code>make-varargs-factory</code> are also provided to create raw function handles.</p>
<pre><code class="language-clojure">(def raw-strlen (ffi/make-downcall "strlen" [::mem/c-string] ::mem/long))
@ -15,7 +15,7 @@
</code></pre>
<p>Clojure functions serialized to this type will have their arguments and return value exactly match the types specified and will not perform any serialization or deserialization at their boundaries.</p>
<p>One important caveat to consider when writing wrappers for performance-sensitive functions is that the convenience macro <code>defcfn</code> that coffi provides will already perform no serialization or deserialization on primitive arguments and return types, so for functions with only primitive argument and return types there is no performance reason to choose unwrapped native handles over the convenience macro.</p>
<h3><a href="#manual-deserialization-manual-serdes" id="manual-deserialization-manual-serdes"></a>Manual (De)Serialization {#manual-serdes}</h3>
<h3><a href="#manual-deserialization" id="manual-deserialization"></a>Manual (De)Serialization</h3>
<p>Coffi uses multimethods to dispatch to (de)serialization functions to enable code thats generic over the types it operates on. However, in cases where you know the exact types that you will be (de)serializing and the multimethod dispatch overhead is too high a cost, it may be appropriate to manually handle (de)serializing data. This will often be done paired with <a href="#unwrapped-native-handles">Unwrapped Native Handles</a>.</p>
<p>Convenience functions are provided to both read and write all primitive types and addresses, including byte order.</p>
<p>As an example, when wrapping a function that returns an array of big-endian floats, the following code might be used.</p>

View file

@ -5,7 +5,7 @@
<p>An additional consideration when thinking about alternatives is the performance of each available option. Its an established fact that JNA (used by all three alternative libraries on JDK &lt;16) introduces more overhead when calling native code than JNI does.</p>
<p>In order to provide a benchmark to see how much of a difference the different native interfaces make, we can use <a href="https://github.com/hugoduncan/criterium">criterium</a> to benchmark each. <a href="https://www.glfw.org">GLFW</a>s <a href="https://www.glfw.org/docs/latest/group__input.html#gaa6cf4e7a77158a3b8fd00328b1720a4a"><code>glfwGetTime</code></a> function will be used for the test as it performs a simple operation, and is conveniently already wrapped in JNI by the excellent <a href="https://www.lwjgl.org/">LWJGL</a> library.</p>
<p>The following benchmarks were run on a Lenovo Thinkpad with an Intel i7-10610U running Manjaro Linux, using Clojure 1.10.3 on Java 17.</p>
<h3><a href="#jni-jni" id="jni-jni"></a>JNI {#jni}</h3>
<h3><a href="#jni" id="jni"></a>JNI</h3>
<p>The baseline for performance is the JNI. Using LWJGL its relatively simple to benchmark. The following Clojure CLI command will start a repl with LWJGL and criterium loaded.</p>
<pre><code class="language-sh">$ clj -Sdeps '{:deps {org.lwjgl/lwjgl {:mvn/version "3.2.3"}
org.lwjgl/lwjgl-glfw {:mvn/version "3.2.3"}
@ -40,7 +40,7 @@ nil
<pre><code class="language-clojure">user=&gt; bench/estimated-overhead-cache
6.400703613065185E-9
</code></pre>
<h3><a href="#coffi-coffi" id="coffi-coffi"></a>Coffi {#coffi}</h3>
<h3><a href="#coffi" id="coffi"></a>Coffi</h3>
<p>The dependencies when using coffi are simpler, but it also requires some JVM options to support the foreign access api.</p>
<pre><code class="language-sh">$ clj -Sdeps '{:deps {org.suskalo/coffi {:mvn/version "0.1.205"}
criterium/criterium {:mvn/version "0.4.6"}}}' \
@ -76,7 +76,7 @@ Execution time sample std-deviation : 1.598571 ns
nil
</code></pre>
<p>This result is about 1.3 ns faster, and while that is less than the standard deviation of 1.6, its quite close to it.</p>
<h3><a href="#clojure-jna-clojure-jna" id="clojure-jna-clojure-jna"></a>Clojure-JNA {#clojure-jna}</h3>
<h3><a href="#clojure-jna" id="clojure-jna"></a>Clojure-JNA</h3>
<p>Clojure-JNA uses the JNA library, which was designed to provide Java with an easy way to access native libraries, but which is known for not having the greatest performance. Since this is an older project, Im also including the clojure dependency to ensure the correct version is used.</p>
<pre><code class="language-sh">$ clj -Sdeps '{:deps {org.clojure/clojure {:mvn/version "1.10.3"}
net.n01se/clojure-jna {:mvn/version "1.0.0"}
@ -129,7 +129,7 @@ nil
</code></pre>
<p>This is much better, but is still about 3x slower than JNI, meaning the overhead from using JNA is still bigger than the function runtime.</p>
<p>This performance penalty is still small in the scope of longer-running functions, and so may not be a concern for your application, but it is something to be aware of.</p>
<h3><a href="#techjna-tech-jna" id="techjna-tech-jna"></a>tech.jna {#tech-jna}</h3>
<h3><a href="#techjna" id="techjna"></a>tech.jna</h3>
<p>The tech.jna library is similar in scope to Clojure-JNA, however was written to fit into an ecosystem of libraries meant for array-based programming for machine learning and data science.</p>
<pre><code class="language-sh">$ clj -Sdeps '{:deps {techascent/tech.jna {:mvn/version "4.05"}
criterium/criterium {:mvn/version "0.4.6"}}}'
@ -165,7 +165,7 @@ Execution time sample std-deviation : 14.557312 ns
nil
</code></pre>
<p>This version is even slower than Clojure-JNA. Im unsure where this overhead is coming from, but Ill admit that I havent looked at their implementations very closely.</p>
<h3><a href="#dtype-next-dtype-next" id="dtype-next-dtype-next"></a>dtype-next {#dtype-next}</h3>
<h3><a href="#dtype-next" id="dtype-next"></a>dtype-next</h3>
<p>The library dtype-next replaced tech.jna in the toolkit of the group working on machine learning and array-based programming, and it includes support for composite data types including structs, as well as primitive functions and callbacks.</p>
<p>In addition, dtype-next has two different ffi backends. First is JNA, which is usable on any JDK version, and is what well use for the first benchmark. Second is the Java 16 version of Project Panama, which will be shown next.</p>
<p>In order to use the dtype-next ffi with the JNA backend, the JNA library has to be included in the dependencies.</p>

View file

@ -1,6 +1,6 @@
# Getting Started
## Installation {#installation}
## Installation
This library is available on Clojars. Add one of the following entries to the
`:deps` key of your `deps.edn`:
@ -49,7 +49,7 @@ When creating an executable jar file, you can avoid the need to pass this
argument by adding the manifest attribute `Enable-Native-Access: ALL-UNNAMED` to
your jar.
## Basic Usage {#usage}
## Basic Usage
There are two major components to coffi and interacting with native code:
manipulating off-heap memory, and loading native code for use with Clojure.
@ -107,7 +107,7 @@ loaded, an exception is thrown. This can be convenient as any namespace with a
`load-library` call at the top level cannot be required without the library
being able to be loaded.
### Primitive Types {#primitive-types}
### Primitive Types
Coffi defines a basic set of primitive types:
- byte
@ -124,7 +124,7 @@ primitive types except for `pointer` will be cast with their corresponding
Clojure function when they are passed as arguments to native functions.
Additionally, the `c-string` type is defined, although it is not primitive.
### Composite Types {#composite-types}
### Composite Types
In addition, some composite types are also defined in coffi, including struct
and union types (unions will be discussed with serialization and
deserialization). For an example C struct and function:
@ -213,7 +213,7 @@ in C.
[::mem/array ::mem/int 3]
```
### Callbacks {#callbacks}
### Callbacks
In addition to these composite types, there is also support for Clojure
functions.
@ -244,7 +244,7 @@ again once the native function returns. If however it saves the callback for
later use the JVM may collect it prematurely, causing a crash when the callback
is later called by native code.
### Variadic Functions {#variadic-functions}
### Variadic Functions
Some native functions can take any number of arguments, and in these cases coffi
provides `vacfn-factory` (for "varargs C function factory").
@ -268,7 +268,7 @@ Some native functions that are variadic use the type `va_list` to make it easier
for other languages to call them in their FFI. At the time of writing, coffi
does not support va-list, however it is a planned feature.
### Global Variables {#globals}
### Global Variables
Some libraries include global variables or constants accessible through symbols.
To start with, constant values stored in symbols can be fetched with `const`, or
the parallel macro `defconst`
@ -309,7 +309,7 @@ The memory that backs the static variable can be fetched with the function
`static-variable-segment`, which can be used to pass a pointer to the static
variable to native functions that require it.
### Complex Wrappers {#complex-wrappers}
### Complex Wrappers
Some functions require more complex code to map nicely to a Clojure function.
The `defcfn` macro provides facilities to wrap the native function with some
Clojure code to make this easier.

View file

@ -1,20 +1,18 @@
# Built-in Types **WIP**
### TODO Primitives {#primitives}
### Primitives
### TODO Arrays {#arrays}
### Arrays
### TODO Pointers {#pointers}
### Pointers
### TODO Structs {#structs}
### Structs
### TODO Enums {#enums}
### Enums
### TODO Flagsets {#flagsets}
### Flagsets
### TODO Functions {#functions}
### Unions {#unions}
### Unions
Unions in coffi are rather limited. They can be serialized, but not deserialized
without external information.
@ -28,9 +26,8 @@ without external information.
This is a minimal union in coffi. If the `:dispatch` keyword argument is not
passed, then the union cannot be serialized, as coffi would not know which type
to serialize the values as. In [the example with a tagged
union](04-Custom-Types.md#tagged-union), a dispatch function was not provided
because the type was only used for the native layout.
to serialize the values as. In the example with a tagged union, a dispatch
function was not provided because the type was only used for the native layout.
In addition to a dispatch function, when serializing a union an extract function
may also be provided. In the case of the value in the tagged union from before,
@ -53,4 +50,4 @@ garbage collected, and copies the data from the source segment into it. It's up
to the user to call `deserialize-from` on that segment with the appropriate
type.
### TODO Raw Types {#raw-types}
### Raw Types

View file

@ -6,7 +6,7 @@ given type, only one set need be implemented.
Two examples of custom types are given here, one is a 3d vector, and the other
an example of a tagged union.
### Vector3 {#vector}
### Vector3
For the vector type, it will serialize to a pointer to an array of three floats.
The multimethod `primitive-type` returns the primitive type that a given type
@ -56,7 +56,7 @@ that takes a pointer exists, we could use this:
This function takes an arena and returns the deserialized vector, and it will
free the pointer when the arena closes.
### Tagged Union {#tagged-union}
### Tagged Union
For the tagged union type, we will represent the value as a vector of a keyword
naming the tag and the value. The type itself will need to take arguments,
similar to `struct`. For example, if we were to represent a result type like in

View file

@ -1,6 +1,6 @@
# Low-Level Wrappers
### Unwrapped Native Handles {#unwrapped-native-handles}
### Unwrapped Native Handles
Some native libraries work with handles to large amounts of data at once, making
it undesirable to marshal data back and forth from Clojure, both because it's
not necessary to work with the data in Clojure directly, or also because of the
@ -45,7 +45,7 @@ return types, so for functions with only primitive argument and return types
there is no performance reason to choose unwrapped native handles over the
convenience macro.
### Manual (De)Serialization {#manual-serdes}
### Manual (De)Serialization
Coffi uses multimethods to dispatch to (de)serialization functions to enable
code that's generic over the types it operates on. However, in cases where you
know the exact types that you will be (de)serializing and the multimethod

View file

@ -18,7 +18,7 @@ conveniently already wrapped in JNI by the excellent
The following benchmarks were run on a Lenovo Thinkpad with an Intel i7-10610U
running Manjaro Linux, using Clojure 1.10.3 on Java 17.
### JNI {#jni}
### JNI
The baseline for performance is the JNI. Using LWJGL it's relatively simple to
benchmark. The following Clojure CLI command will start a repl with LWJGL and
criterium loaded.
@ -70,7 +70,7 @@ user=> bench/estimated-overhead-cache
6.400703613065185E-9
```
### Coffi {#coffi}
### Coffi
The dependencies when using coffi are simpler, but it also requires some JVM
options to support the foreign access api.
@ -117,7 +117,7 @@ nil
This result is about 1.3 ns faster, and while that is less than the standard
deviation of 1.6, it's quite close to it.
### Clojure-JNA {#clojure-jna}
### Clojure-JNA
Clojure-JNA uses the JNA library, which was designed to provide Java with an
easy way to access native libraries, but which is known for not having the
greatest performance. Since this is an older project, I'm also including the
@ -192,7 +192,7 @@ This performance penalty is still small in the scope of longer-running
functions, and so may not be a concern for your application, but it is something
to be aware of.
### tech.jna {#tech-jna}
### tech.jna
The tech.jna library is similar in scope to Clojure-JNA, however was written to
fit into an ecosystem of libraries meant for array-based programming for machine
learning and data science.
@ -242,7 +242,7 @@ This version is even slower than Clojure-JNA. I'm unsure where this overhead is
coming from, but I'll admit that I haven't looked at their implementations very
closely.
### dtype-next {#dtype-next}
### dtype-next
The library dtype-next replaced tech.jna in the toolkit of the group working on
machine learning and array-based programming, and it includes support for
composite data types including structs, as well as primitive functions and

View file

@ -4,38 +4,38 @@
</div></div><div class="public anchor" id="var-cfn"><h3>cfn</h3><div class="usage"><code>(cfn symbol args ret)</code></div><div class="doc"><div class="markdown"><p>Constructs a Clojure function to call the native function referenced by <code>symbol</code>.</p>
<p>The function returned will serialize any passed arguments into the <code>args</code> types, and deserialize the return to the <code>ret</code> type.</p>
<p>If your <code>args</code> and <code>ret</code> are constants, then it is more efficient to call <a href="coffi.ffi.html#var-make-downcall">make-downcall</a> followed by <a href="coffi.ffi.html#var-make-serde-wrapper">make-serde-wrapper</a> because the latter has an inline definition which will result in less overhead from serdes.</p>
</div></div><div class="src-link"><a href="https://github.com/IGJoshua/coffi/blob/18fd49136364806c597d0420d20c2fe144a5cd45/src/clj/coffi/ffi.clj#L438">view source</a></div></div><div class="public anchor" id="var-const"><h3>const</h3><div class="usage"><code>(const symbol-or-addr type)</code></div><div class="doc"><div class="markdown"><p>Gets the value of a constant stored in <code>symbol-or-addr</code>.</p>
</div></div><div class="src-link"><a href="https://github.com/IGJoshua/coffi/blob/18fd49136364806c597d0420d20c2fe144a5cd45/src/clj/coffi/ffi.clj#L606">view source</a></div></div><div class="public anchor" id="var-defcfn"><h3>defcfn</h3><h4 class="type">macro</h4><div class="usage"><code>(defcfn name docstring? attr-map? symbol arg-types ret-type)</code><code>(defcfn name docstring? attr-map? symbol arg-types ret-type native-fn &amp; fn-tail)</code></div><div class="doc"><div class="markdown"><p>Defines a Clojure function which maps to a native function.</p>
</div></div><div class="src-link"><a href="https://github.com/IGJoshua/coffi/blob/58eaffdf543a3aa00436dafef2c65b247ad3f916/src/clj/coffi/ffi.clj#L438">view source</a></div></div><div class="public anchor" id="var-const"><h3>const</h3><div class="usage"><code>(const symbol-or-addr type)</code></div><div class="doc"><div class="markdown"><p>Gets the value of a constant stored in <code>symbol-or-addr</code>.</p>
</div></div><div class="src-link"><a href="https://github.com/IGJoshua/coffi/blob/58eaffdf543a3aa00436dafef2c65b247ad3f916/src/clj/coffi/ffi.clj#L606">view source</a></div></div><div class="public anchor" id="var-defcfn"><h3>defcfn</h3><h4 class="type">macro</h4><div class="usage"><code>(defcfn name docstring? attr-map? symbol arg-types ret-type)</code><code>(defcfn name docstring? attr-map? symbol arg-types ret-type native-fn &amp; fn-tail)</code></div><div class="doc"><div class="markdown"><p>Defines a Clojure function which maps to a native function.</p>
<p><code>name</code> is the symbol naming the resulting var. <code>symbol</code> is a symbol or string naming the library symbol to link against. <code>arg-types</code> is a vector of qualified keywords representing the argument types. <code>ret-type</code> is a single qualified keyword representing the return type. <code>fn-tail</code> is the body of the function (potentially with multiple arities) which wraps the native one. Inside the function, <code>native-fn</code> is bound to a function that will serialize its arguments, call the native function, and deserialize its return type. If any body is present, you must call this function in order to call the native code.</p>
<p>If no <code>fn-tail</code> is provided, then the resulting function will simply serialize the arguments according to <code>arg-types</code>, call the native function, and deserialize the return value.</p>
<p>The number of args in the <code>fn-tail</code> need not match the number of <code>arg-types</code> for the native function. It need only call the native wrapper function with the correct arguments.</p>
<p>See <a href="coffi.mem.html#var-serialize">serialize</a>, <a href="coffi.mem.html#var-deserialize">deserialize</a>, <a href="coffi.ffi.html#var-make-downcall">make-downcall</a>.</p>
</div></div><div class="src-link"><a href="https://github.com/IGJoshua/coffi/blob/18fd49136364806c597d0420d20c2fe144a5cd45/src/clj/coffi/ffi.clj#L780">view source</a></div></div><div class="public anchor" id="var-defconst"><h3>defconst</h3><h4 class="type">macro</h4><div class="usage"><code>(defconst symbol docstring? symbol-or-addr type)</code></div><div class="doc"><div class="markdown"><p>Defines a var named by <code>symbol</code> to be the value of the given <code>type</code> from <code>symbol-or-addr</code>.</p>
</div></div><div class="src-link"><a href="https://github.com/IGJoshua/coffi/blob/18fd49136364806c597d0420d20c2fe144a5cd45/src/clj/coffi/ffi.clj#L617">view source</a></div></div><div class="public anchor" id="var-defvar"><h3>defvar</h3><h4 class="type">macro</h4><div class="usage"><code>(defvar symbol docstring? symbol-or-addr type)</code></div><div class="doc"><div class="markdown"><p>Defines a var named by <code>symbol</code> to be a reference to the native memory from <code>symbol-or-addr</code>.</p>
</div></div><div class="src-link"><a href="https://github.com/IGJoshua/coffi/blob/18fd49136364806c597d0420d20c2fe144a5cd45/src/clj/coffi/ffi.clj#L683">view source</a></div></div><div class="public anchor" id="var-ensure-symbol"><h3>ensure-symbol</h3><div class="usage"><code>(ensure-symbol symbol-or-addr)</code></div><div class="doc"><div class="markdown"><p>Returns the argument if it is a <a href="null">MemorySegment</a>, otherwise calls <a href="coffi.ffi.html#var-find-symbol">find-symbol</a> on it.</p>
</div></div><div class="src-link"><a href="https://github.com/IGJoshua/coffi/blob/18fd49136364806c597d0420d20c2fe144a5cd45/src/clj/coffi/ffi.clj#L198">view source</a></div></div><div class="public anchor" id="var-find-symbol"><h3>find-symbol</h3><div class="usage"><code>(find-symbol sym)</code></div><div class="doc"><div class="markdown"><p>Gets the <a href="null">MemorySegment</a> of a symbol from the loaded libraries.</p>
</div></div><div class="src-link"><a href="https://github.com/IGJoshua/coffi/blob/18fd49136364806c597d0420d20c2fe144a5cd45/src/clj/coffi/ffi.clj#L38">view source</a></div></div><div class="public anchor" id="var-freset.21"><h3>freset!</h3><div class="usage"><code>(freset! static-var newval)</code></div><div class="doc"><div class="markdown"><p>Sets the value of <code>static-var</code> to <code>newval</code>, running it through <a href="coffi.mem.html#var-serialize">serialize</a>.</p>
</div></div><div class="src-link"><a href="https://github.com/IGJoshua/coffi/blob/18fd49136364806c597d0420d20c2fe144a5cd45/src/clj/coffi/ffi.clj#L647">view source</a></div></div><div class="public anchor" id="var-fswap.21"><h3>fswap!</h3><div class="usage"><code>(fswap! static-var f &amp; args)</code></div><div class="doc"><div class="markdown"><p>Non-atomically runs the function <code>f</code> over the value stored in <code>static-var</code>.</p>
</div></div><div class="src-link"><a href="https://github.com/IGJoshua/coffi/blob/58eaffdf543a3aa00436dafef2c65b247ad3f916/src/clj/coffi/ffi.clj#L780">view source</a></div></div><div class="public anchor" id="var-defconst"><h3>defconst</h3><h4 class="type">macro</h4><div class="usage"><code>(defconst symbol docstring? symbol-or-addr type)</code></div><div class="doc"><div class="markdown"><p>Defines a var named by <code>symbol</code> to be the value of the given <code>type</code> from <code>symbol-or-addr</code>.</p>
</div></div><div class="src-link"><a href="https://github.com/IGJoshua/coffi/blob/58eaffdf543a3aa00436dafef2c65b247ad3f916/src/clj/coffi/ffi.clj#L617">view source</a></div></div><div class="public anchor" id="var-defvar"><h3>defvar</h3><h4 class="type">macro</h4><div class="usage"><code>(defvar symbol docstring? symbol-or-addr type)</code></div><div class="doc"><div class="markdown"><p>Defines a var named by <code>symbol</code> to be a reference to the native memory from <code>symbol-or-addr</code>.</p>
</div></div><div class="src-link"><a href="https://github.com/IGJoshua/coffi/blob/58eaffdf543a3aa00436dafef2c65b247ad3f916/src/clj/coffi/ffi.clj#L683">view source</a></div></div><div class="public anchor" id="var-ensure-symbol"><h3>ensure-symbol</h3><div class="usage"><code>(ensure-symbol symbol-or-addr)</code></div><div class="doc"><div class="markdown"><p>Returns the argument if it is a <a href="null">MemorySegment</a>, otherwise calls <a href="coffi.ffi.html#var-find-symbol">find-symbol</a> on it.</p>
</div></div><div class="src-link"><a href="https://github.com/IGJoshua/coffi/blob/58eaffdf543a3aa00436dafef2c65b247ad3f916/src/clj/coffi/ffi.clj#L198">view source</a></div></div><div class="public anchor" id="var-find-symbol"><h3>find-symbol</h3><div class="usage"><code>(find-symbol sym)</code></div><div class="doc"><div class="markdown"><p>Gets the <a href="null">MemorySegment</a> of a symbol from the loaded libraries.</p>
</div></div><div class="src-link"><a href="https://github.com/IGJoshua/coffi/blob/58eaffdf543a3aa00436dafef2c65b247ad3f916/src/clj/coffi/ffi.clj#L38">view source</a></div></div><div class="public anchor" id="var-freset.21"><h3>freset!</h3><div class="usage"><code>(freset! static-var newval)</code></div><div class="doc"><div class="markdown"><p>Sets the value of <code>static-var</code> to <code>newval</code>, running it through <a href="coffi.mem.html#var-serialize">serialize</a>.</p>
</div></div><div class="src-link"><a href="https://github.com/IGJoshua/coffi/blob/58eaffdf543a3aa00436dafef2c65b247ad3f916/src/clj/coffi/ffi.clj#L647">view source</a></div></div><div class="public anchor" id="var-fswap.21"><h3>fswap!</h3><div class="usage"><code>(fswap! static-var f &amp; args)</code></div><div class="doc"><div class="markdown"><p>Non-atomically runs the function <code>f</code> over the value stored in <code>static-var</code>.</p>
<p>The value is deserialized before passing it to <code>f</code>, and serialized before putting the value into <code>static-var</code>.</p>
</div></div><div class="src-link"><a href="https://github.com/IGJoshua/coffi/blob/18fd49136364806c597d0420d20c2fe144a5cd45/src/clj/coffi/ffi.clj#L656">view source</a></div></div><div class="public anchor" id="var-load-library"><h3>load-library</h3><div class="usage"><code>(load-library path)</code></div><div class="doc"><div class="markdown"><p>Loads the library at <code>path</code>.</p>
</div></div><div class="src-link"><a href="https://github.com/IGJoshua/coffi/blob/18fd49136364806c597d0420d20c2fe144a5cd45/src/clj/coffi/ffi.clj#L33">view source</a></div></div><div class="public anchor" id="var-load-system-library"><h3>load-system-library</h3><div class="usage"><code>(load-system-library libname)</code></div><div class="doc"><div class="markdown"><p>Loads the library named <code>libname</code> from the systems load path.</p>
</div></div><div class="src-link"><a href="https://github.com/IGJoshua/coffi/blob/18fd49136364806c597d0420d20c2fe144a5cd45/src/clj/coffi/ffi.clj#L28">view source</a></div></div><div class="public anchor" id="var-make-downcall"><h3>make-downcall</h3><div class="usage"><code>(make-downcall symbol-or-addr args ret)</code></div><div class="doc"><div class="markdown"><p>Constructs a downcall function reference to <code>symbol-or-addr</code> with the given <code>args</code> and <code>ret</code> types.</p>
</div></div><div class="src-link"><a href="https://github.com/IGJoshua/coffi/blob/58eaffdf543a3aa00436dafef2c65b247ad3f916/src/clj/coffi/ffi.clj#L656">view source</a></div></div><div class="public anchor" id="var-load-library"><h3>load-library</h3><div class="usage"><code>(load-library path)</code></div><div class="doc"><div class="markdown"><p>Loads the library at <code>path</code>.</p>
</div></div><div class="src-link"><a href="https://github.com/IGJoshua/coffi/blob/58eaffdf543a3aa00436dafef2c65b247ad3f916/src/clj/coffi/ffi.clj#L33">view source</a></div></div><div class="public anchor" id="var-load-system-library"><h3>load-system-library</h3><div class="usage"><code>(load-system-library libname)</code></div><div class="doc"><div class="markdown"><p>Loads the library named <code>libname</code> from the systems load path.</p>
</div></div><div class="src-link"><a href="https://github.com/IGJoshua/coffi/blob/58eaffdf543a3aa00436dafef2c65b247ad3f916/src/clj/coffi/ffi.clj#L28">view source</a></div></div><div class="public anchor" id="var-make-downcall"><h3>make-downcall</h3><div class="usage"><code>(make-downcall symbol-or-addr args ret)</code></div><div class="doc"><div class="markdown"><p>Constructs a downcall function reference to <code>symbol-or-addr</code> with the given <code>args</code> and <code>ret</code> types.</p>
<p>The function returned takes only arguments whose types match exactly the <a href="coffi.mem.html#var-java-layout">java-layout</a> for that type, and returns an argument with exactly the <a href="coffi.mem.html#var-java-layout">java-layout</a> of the <code>ret</code> type. This function will perform no serialization or deserialization of arguments or the return type.</p>
<p>If the <code>ret</code> type is non-primitive, then the returned function will take a first argument of a <a href="null">SegmentAllocator</a>.</p>
</div></div><div class="src-link"><a href="https://github.com/IGJoshua/coffi/blob/18fd49136364806c597d0420d20c2fe144a5cd45/src/clj/coffi/ffi.clj#L206">view source</a></div></div><div class="public anchor" id="var-make-serde-varargs-wrapper"><h3>make-serde-varargs-wrapper</h3><div class="usage"><code>(make-serde-varargs-wrapper varargs-factory required-args ret-type)</code></div><div class="doc"><div class="markdown"><p>Constructs a wrapper function for the <code>varargs-factory</code> which produces functions that serialize the arguments and deserialize the return value.</p>
</div></div><div class="src-link"><a href="https://github.com/IGJoshua/coffi/blob/18fd49136364806c597d0420d20c2fe144a5cd45/src/clj/coffi/ffi.clj#L426">view source</a></div></div><div class="public anchor" id="var-make-serde-wrapper"><h3>make-serde-wrapper</h3><div class="usage"><code>(make-serde-wrapper downcall arg-types ret-type)</code></div><div class="doc"><div class="markdown"><p>Constructs a wrapper function for the <code>downcall</code> which serializes the arguments and deserializes the return value.</p>
</div></div><div class="src-link"><a href="https://github.com/IGJoshua/coffi/blob/18fd49136364806c597d0420d20c2fe144a5cd45/src/clj/coffi/ffi.clj#L407">view source</a></div></div><div class="public anchor" id="var-make-varargs-factory"><h3>make-varargs-factory</h3><div class="usage"><code>(make-varargs-factory symbol required-args ret)</code></div><div class="doc"><div class="markdown"><p>Returns a function for constructing downcalls with additional types for arguments.</p>
</div></div><div class="src-link"><a href="https://github.com/IGJoshua/coffi/blob/58eaffdf543a3aa00436dafef2c65b247ad3f916/src/clj/coffi/ffi.clj#L206">view source</a></div></div><div class="public anchor" id="var-make-serde-varargs-wrapper"><h3>make-serde-varargs-wrapper</h3><div class="usage"><code>(make-serde-varargs-wrapper varargs-factory required-args ret-type)</code></div><div class="doc"><div class="markdown"><p>Constructs a wrapper function for the <code>varargs-factory</code> which produces functions that serialize the arguments and deserialize the return value.</p>
</div></div><div class="src-link"><a href="https://github.com/IGJoshua/coffi/blob/58eaffdf543a3aa00436dafef2c65b247ad3f916/src/clj/coffi/ffi.clj#L426">view source</a></div></div><div class="public anchor" id="var-make-serde-wrapper"><h3>make-serde-wrapper</h3><div class="usage"><code>(make-serde-wrapper downcall arg-types ret-type)</code></div><div class="doc"><div class="markdown"><p>Constructs a wrapper function for the <code>downcall</code> which serializes the arguments and deserializes the return value.</p>
</div></div><div class="src-link"><a href="https://github.com/IGJoshua/coffi/blob/58eaffdf543a3aa00436dafef2c65b247ad3f916/src/clj/coffi/ffi.clj#L407">view source</a></div></div><div class="public anchor" id="var-make-varargs-factory"><h3>make-varargs-factory</h3><div class="usage"><code>(make-varargs-factory symbol required-args ret)</code></div><div class="doc"><div class="markdown"><p>Returns a function for constructing downcalls with additional types for arguments.</p>
<p>The <code>required-args</code> are the types of the first arguments passed to the downcall handle, and the values passed to the returned function are only the varargs types.</p>
<p>The returned function is memoized, so that only one downcall function will be generated per combination of argument types.</p>
<p>See <a href="coffi.ffi.html#var-make-downcall">make-downcall</a>.</p>
</div></div><div class="src-link"><a href="https://github.com/IGJoshua/coffi/blob/18fd49136364806c597d0420d20c2fe144a5cd45/src/clj/coffi/ffi.clj#L222">view source</a></div></div><div class="public anchor" id="var-reify-libspec"><h3>reify-libspec</h3><div class="usage"><code>(reify-libspec libspec)</code></div><div class="doc"><div class="markdown"><p>Loads all the symbols specified in the <code>libspec</code>.</p>
</div></div><div class="src-link"><a href="https://github.com/IGJoshua/coffi/blob/58eaffdf543a3aa00436dafef2c65b247ad3f916/src/clj/coffi/ffi.clj#L222">view source</a></div></div><div class="public anchor" id="var-reify-libspec"><h3>reify-libspec</h3><div class="usage"><code>(reify-libspec libspec)</code></div><div class="doc"><div class="markdown"><p>Loads all the symbols specified in the <code>libspec</code>.</p>
<p>The value of each key of the passed map is transformed as by <a href="coffi.ffi.html#var-reify-symbolspec">reify-symbolspec</a>.</p>
</div></div><div class="src-link"><a href="https://github.com/IGJoshua/coffi/blob/18fd49136364806c597d0420d20c2fe144a5cd45/src/clj/coffi/ffi.clj#L742">view source</a></div></div><div class="public anchor" id="var-reify-symbolspec"><h3>reify-symbolspec</h3><h4 class="type">multimethod</h4><div class="usage"></div><div class="doc"><div class="markdown"><p>Takes a spec for a symbol reference and returns a live value for that type.</p>
</div></div><div class="src-link"><a href="https://github.com/IGJoshua/coffi/blob/18fd49136364806c597d0420d20c2fe144a5cd45/src/clj/coffi/ffi.clj#L701">view source</a></div></div><div class="public anchor" id="var-static-variable"><h3>static-variable</h3><div class="usage"><code>(static-variable symbol-or-addr type)</code></div><div class="doc"><div class="markdown"><p>Constructs a reference to a mutable value stored in <code>symbol-or-addr</code>.</p>
</div></div><div class="src-link"><a href="https://github.com/IGJoshua/coffi/blob/58eaffdf543a3aa00436dafef2c65b247ad3f916/src/clj/coffi/ffi.clj#L742">view source</a></div></div><div class="public anchor" id="var-reify-symbolspec"><h3>reify-symbolspec</h3><h4 class="type">multimethod</h4><div class="usage"></div><div class="doc"><div class="markdown"><p>Takes a spec for a symbol reference and returns a live value for that type.</p>
</div></div><div class="src-link"><a href="https://github.com/IGJoshua/coffi/blob/58eaffdf543a3aa00436dafef2c65b247ad3f916/src/clj/coffi/ffi.clj#L701">view source</a></div></div><div class="public anchor" id="var-static-variable"><h3>static-variable</h3><div class="usage"><code>(static-variable symbol-or-addr type)</code></div><div class="doc"><div class="markdown"><p>Constructs a reference to a mutable value stored in <code>symbol-or-addr</code>.</p>
<p>The returned value can be dereferenced, and has metadata.</p>
<p>See <a href="coffi.ffi.html#var-freset.21">freset!</a>, <a href="coffi.ffi.html#var-fswap.21">fswap!</a>.</p>
</div></div><div class="src-link"><a href="https://github.com/IGJoshua/coffi/blob/18fd49136364806c597d0420d20c2fe144a5cd45/src/clj/coffi/ffi.clj#L672">view source</a></div></div><div class="public anchor" id="var-static-variable-segment"><h3>static-variable-segment</h3><div class="usage"><code>(static-variable-segment static-var)</code></div><div class="doc"><div class="markdown"><p>Gets the backing <a href="null">MemorySegment</a> from <code>static-var</code>.</p>
</div></div><div class="src-link"><a href="https://github.com/IGJoshua/coffi/blob/58eaffdf543a3aa00436dafef2c65b247ad3f916/src/clj/coffi/ffi.clj#L672">view source</a></div></div><div class="public anchor" id="var-static-variable-segment"><h3>static-variable-segment</h3><div class="usage"><code>(static-variable-segment static-var)</code></div><div class="doc"><div class="markdown"><p>Gets the backing <a href="null">MemorySegment</a> from <code>static-var</code>.</p>
<p>This is primarily useful when you need to pass the static variables address to a native function which takes an <a href="null">Addressable</a>.</p>
</div></div><div class="src-link"><a href="https://github.com/IGJoshua/coffi/blob/18fd49136364806c597d0420d20c2fe144a5cd45/src/clj/coffi/ffi.clj#L664">view source</a></div></div><div class="public anchor" id="var-vacfn-factory"><h3>vacfn-factory</h3><div class="usage"><code>(vacfn-factory symbol required-args ret)</code></div><div class="doc"><div class="markdown"><p>Constructs a varargs factory to call the native function referenced by <code>symbol</code>.</p>
</div></div><div class="src-link"><a href="https://github.com/IGJoshua/coffi/blob/58eaffdf543a3aa00436dafef2c65b247ad3f916/src/clj/coffi/ffi.clj#L664">view source</a></div></div><div class="public anchor" id="var-vacfn-factory"><h3>vacfn-factory</h3><div class="usage"><code>(vacfn-factory symbol required-args ret)</code></div><div class="doc"><div class="markdown"><p>Constructs a varargs factory to call the native function referenced by <code>symbol</code>.</p>
<p>The function returned takes any number of type arguments and returns a specialized Clojure function for calling the native function with those arguments.</p>
</div></div><div class="src-link"><a href="https://github.com/IGJoshua/coffi/blob/18fd49136364806c597d0420d20c2fe144a5cd45/src/clj/coffi/ffi.clj#L453">view source</a></div></div></div></body></html>
</div></div><div class="src-link"><a href="https://github.com/IGJoshua/coffi/blob/58eaffdf543a3aa00436dafef2c65b247ad3f916/src/clj/coffi/ffi.clj#L453">view source</a></div></div></div></body></html>

View file

@ -3,4 +3,4 @@
<html><head><meta charset="UTF-8" /><title>coffi.layout documentation</title><link rel="stylesheet" type="text/css" href="css/default.css" /><link rel="stylesheet" type="text/css" href="css/highlight.css" /><script type="text/javascript" src="js/highlight.min.js"></script><script type="text/javascript" src="js/jquery.min.js"></script><script type="text/javascript" src="js/page_effects.js"></script><script>hljs.initHighlightingOnLoad();</script></head><body><div id="header"><h2>Generated by <a href="https://github.com/weavejester/codox">Codox</a></h2><h1><a href="index.html"><span class="project-title"><span class="project-name">coffi</span> <span class="project-version">v1.0.486</span></span></a></h1></div><div class="sidebar primary"><h3 class="no-link"><span class="inner">Project</span></h3><ul class="index-link"><li class="depth-1 "><a href="index.html"><div class="inner">Index</div></a></li></ul><h3 class="no-link"><span class="inner">Topics</span></h3><ul><li class="depth-1 "><a href="01-Getting-Started.html"><div class="inner"><span>Getting Started</span></div></a></li><li class="depth-1 "><a href="02-Memory-Management.html"><div class="inner"><span>Memory Management</span></div></a></li><li class="depth-1 "><a href="03-Builtin-Types.html"><div class="inner"><span>Built-in Types **WIP**</span></div></a></li><li class="depth-1 "><a href="04-Custom-Types.html"><div class="inner"><span>Custom Types</span></div></a></li><li class="depth-1 "><a href="05-Low-Level-Wrappers.html"><div class="inner"><span>Low-Level Wrappers</span></div></a></li><li class="depth-1 "><a href="50-Data-Model.html"><div class="inner"><span>Data Model</span></div></a></li><li class="depth-1 "><a href="99-Benchmarks.html"><div class="inner"><span>Benchmarks **OUTDATED**</span></div></a></li></ul><h3 class="no-link"><span class="inner">Namespaces</span></h3><ul><li class="depth-1"><div class="no-link"><div class="inner"><span class="tree"><span class="top"></span><span class="bottom"></span></span><span>coffi</span></div></div></li><li class="depth-2 branch"><a href="coffi.ffi.html"><div class="inner"><span class="tree"><span class="top"></span><span class="bottom"></span></span><span>ffi</span></div></a></li><li class="depth-2 branch current"><a href="coffi.layout.html"><div class="inner"><span class="tree"><span class="top"></span><span class="bottom"></span></span><span>layout</span></div></a></li><li class="depth-2"><a href="coffi.mem.html"><div class="inner"><span class="tree"><span class="top"></span><span class="bottom"></span></span><span>mem</span></div></a></li></ul></div><div class="sidebar secondary"><h3><a href="#top"><span class="inner">Public Vars</span></a></h3><ul><li class="depth-1"><a href="coffi.layout.html#var-with-c-layout"><div class="inner"><span>with-c-layout</span></div></a></li></ul></div><div class="namespace-docs" id="content"><h1 class="anchor" id="top">coffi.layout</h1><div class="doc"><div class="markdown"><p>Functions for adjusting the layout of structs.</p>
</div></div><div class="public anchor" id="var-with-c-layout"><h3>with-c-layout</h3><div class="usage"><code>(with-c-layout struct-spec)</code></div><div class="doc"><div class="markdown"><p>Forces a struct specification to C layout rules.</p>
<p>This will add padding fields between fields to match C alignment requirements.</p>
</div></div><div class="src-link"><a href="https://github.com/IGJoshua/coffi/blob/18fd49136364806c597d0420d20c2fe144a5cd45/src/clj/coffi/layout.clj#L6">view source</a></div></div></div></body></html>
</div></div><div class="src-link"><a href="https://github.com/IGJoshua/coffi/blob/58eaffdf543a3aa00436dafef2c65b247ad3f916/src/clj/coffi/layout.clj#L6">view source</a></div></div></div></body></html>

View file

@ -5,117 +5,117 @@
<p>If the native representation of the type is a primitive (whether or not other data beyond the primitive is associated with it, as e.g. a pointer), then <a href="coffi.mem.html#var-primitive-type">primitive-type</a> must be overriden to return which primitive type it is serialized as, then <a href="coffi.mem.html#var-serialize*">serialize*</a> and <a href="coffi.mem.html#var-deserialize*">deserialize*</a> should be overriden.</p>
<p>If the native representation of the type is a composite type, like a union, struct, or array, then <a href="coffi.mem.html#var-c-layout">c-layout</a> must be overriden to return the native layout of the type, and <a href="coffi.mem.html#var-serialize-into">serialize-into</a> and <a href="coffi.mem.html#var-deserialize-from">deserialize-from</a> should be overriden to allow marshaling values of the type into and out of memory segments.</p>
</div></div><div class="public anchor" id="var-address-of"><h3>address-of</h3><div class="usage"><code>(address-of addressable)</code></div><div class="doc"><div class="markdown"><p>Gets the address of a given segment as a number.</p>
</div></div><div class="src-link"><a href="https://github.com/IGJoshua/coffi/blob/18fd49136364806c597d0420d20c2fe144a5cd45/src/clj/coffi/mem.clj#L108">view source</a></div></div><div class="public anchor" id="var-address.3F"><h3>address?</h3><div class="usage"><code>(address? addr)</code></div><div class="doc"><div class="markdown"><p>Checks if an object is a memory address.</p>
</div></div><div class="src-link"><a href="https://github.com/IGJoshua/coffi/blob/58eaffdf543a3aa00436dafef2c65b247ad3f916/src/clj/coffi/mem.clj#L106">view source</a></div></div><div class="public anchor" id="var-address.3F"><h3>address?</h3><div class="usage"><code>(address? addr)</code></div><div class="doc"><div class="markdown"><p>Checks if an object is a memory address.</p>
<p><code>nil</code> is considered an address.</p>
</div></div><div class="src-link"><a href="https://github.com/IGJoshua/coffi/blob/18fd49136364806c597d0420d20c2fe144a5cd45/src/clj/coffi/mem.clj#L126">view source</a></div></div><div class="public anchor" id="var-align-of"><h3>align-of</h3><div class="usage"><code>(align-of type)</code></div><div class="doc"><div class="markdown"><p>The alignment in bytes of the given <code>type</code>.</p>
</div></div><div class="src-link"><a href="https://github.com/IGJoshua/coffi/blob/18fd49136364806c597d0420d20c2fe144a5cd45/src/clj/coffi/mem.clj#L813">view source</a></div></div><div class="public anchor" id="var-alloc"><h3>alloc</h3><div class="usage"><code>(alloc size)</code><code>(alloc size arena)</code><code>(alloc size alignment arena)</code></div><div class="doc"><div class="markdown"><p>Allocates <code>size</code> bytes.</p>
</div></div><div class="src-link"><a href="https://github.com/IGJoshua/coffi/blob/58eaffdf543a3aa00436dafef2c65b247ad3f916/src/clj/coffi/mem.clj#L124">view source</a></div></div><div class="public anchor" id="var-align-of"><h3>align-of</h3><div class="usage"><code>(align-of type)</code></div><div class="doc"><div class="markdown"><p>The alignment in bytes of the given <code>type</code>.</p>
</div></div><div class="src-link"><a href="https://github.com/IGJoshua/coffi/blob/58eaffdf543a3aa00436dafef2c65b247ad3f916/src/clj/coffi/mem.clj#L811">view source</a></div></div><div class="public anchor" id="var-alloc"><h3>alloc</h3><div class="usage"><code>(alloc size)</code><code>(alloc size arena)</code><code>(alloc size alignment arena)</code></div><div class="doc"><div class="markdown"><p>Allocates <code>size</code> bytes.</p>
<p>If an <code>arena</code> is provided, the allocation will be reclaimed when it is closed.</p>
</div></div><div class="src-link"><a href="https://github.com/IGJoshua/coffi/blob/18fd49136364806c597d0420d20c2fe144a5cd45/src/clj/coffi/mem.clj#L93">view source</a></div></div><div class="public anchor" id="var-alloc-instance"><h3>alloc-instance</h3><div class="usage"><code>(alloc-instance type)</code><code>(alloc-instance type arena)</code></div><div class="doc"><div class="markdown"><p>Allocates a memory segment for the given <code>type</code>.</p>
</div></div><div class="src-link"><a href="https://github.com/IGJoshua/coffi/blob/18fd49136364806c597d0420d20c2fe144a5cd45/src/clj/coffi/mem.clj#L820">view source</a></div></div><div class="public anchor" id="var-alloc-with"><h3>alloc-with</h3><div class="usage"><code>(alloc-with allocator size)</code><code>(alloc-with allocator size alignment)</code></div><div class="doc"><div class="markdown"><p>Allocates <code>size</code> bytes using the <code>allocator</code>.</p>
</div></div><div class="src-link"><a href="https://github.com/IGJoshua/coffi/blob/18fd49136364806c597d0420d20c2fe144a5cd45/src/clj/coffi/mem.clj#L101">view source</a></div></div><div class="public anchor" id="var-arena-allocator"><h3>arena-allocator</h3><div class="usage"><code>(arena-allocator arena)</code></div><div class="doc"><div class="markdown"><p>Constructs a <a href="null">SegmentAllocator</a> from the given <a href="null">Arena</a>.</p>
</div></div><div class="src-link"><a href="https://github.com/IGJoshua/coffi/blob/58eaffdf543a3aa00436dafef2c65b247ad3f916/src/clj/coffi/mem.clj#L91">view source</a></div></div><div class="public anchor" id="var-alloc-instance"><h3>alloc-instance</h3><div class="usage"><code>(alloc-instance type)</code><code>(alloc-instance type arena)</code></div><div class="doc"><div class="markdown"><p>Allocates a memory segment for the given <code>type</code>.</p>
</div></div><div class="src-link"><a href="https://github.com/IGJoshua/coffi/blob/58eaffdf543a3aa00436dafef2c65b247ad3f916/src/clj/coffi/mem.clj#L818">view source</a></div></div><div class="public anchor" id="var-alloc-with"><h3>alloc-with</h3><div class="usage"><code>(alloc-with allocator size)</code><code>(alloc-with allocator size alignment)</code></div><div class="doc"><div class="markdown"><p>Allocates <code>size</code> bytes using the <code>allocator</code>.</p>
</div></div><div class="src-link"><a href="https://github.com/IGJoshua/coffi/blob/58eaffdf543a3aa00436dafef2c65b247ad3f916/src/clj/coffi/mem.clj#L99">view source</a></div></div><div class="public anchor" id="var-arena-allocator"><h3>arena-allocator</h3><div class="usage"><code>(arena-allocator arena)</code></div><div class="doc"><div class="markdown"><p>Constructs a <a href="null">SegmentAllocator</a> from the given <a href="null">Arena</a>.</p>
<p>This is primarily used when working with unwrapped downcall functions. When a downcall function returns a non-primitive type, it must be provided with an allocator.</p>
</div></div><div class="src-link"><a href="https://github.com/IGJoshua/coffi/blob/18fd49136364806c597d0420d20c2fe144a5cd45/src/clj/coffi/mem.clj#L82">view source</a></div></div><div class="public anchor" id="var-as-segment"><h3>as-segment</h3><div class="usage"><code>(as-segment address)</code><code>(as-segment address size)</code><code>(as-segment address size arena)</code><code>(as-segment address size arena cleanup)</code></div><div class="doc"><div class="markdown"><p>Dereferences an <code>address</code> into a memory segment associated with the <code>arena</code> (default global).</p>
</div></div><div class="src-link"><a href="https://github.com/IGJoshua/coffi/blob/18fd49136364806c597d0420d20c2fe144a5cd45/src/clj/coffi/mem.clj#L158">view source</a></div></div><div class="public anchor" id="var-auto-arena"><h3>auto-arena</h3><div class="usage"><code>(auto-arena)</code></div><div class="doc"><div class="markdown"><p>Constructs a new memory arena that is managed by the garbage collector.</p>
</div></div><div class="src-link"><a href="https://github.com/IGJoshua/coffi/blob/58eaffdf543a3aa00436dafef2c65b247ad3f916/src/clj/coffi/mem.clj#L80">view source</a></div></div><div class="public anchor" id="var-as-segment"><h3>as-segment</h3><div class="usage"><code>(as-segment address)</code><code>(as-segment address size)</code><code>(as-segment address size arena)</code><code>(as-segment address size arena cleanup)</code></div><div class="doc"><div class="markdown"><p>Dereferences an <code>address</code> into a memory segment associated with the <code>arena</code> (default global).</p>
</div></div><div class="src-link"><a href="https://github.com/IGJoshua/coffi/blob/58eaffdf543a3aa00436dafef2c65b247ad3f916/src/clj/coffi/mem.clj#L156">view source</a></div></div><div class="public anchor" id="var-auto-arena"><h3>auto-arena</h3><div class="usage"><code>(auto-arena)</code></div><div class="doc"><div class="markdown"><p>Constructs a new memory arena that is managed by the garbage collector.</p>
<p>The arena may be shared across threads, and all resources created with it will be cleaned up at the same time, when all references have been collected.</p>
<p>This type of arena cannot be closed, and therefore should not be created in a <a href="null">with-open</a> clause.</p>
</div></div><div class="src-link"><a href="https://github.com/IGJoshua/coffi/blob/18fd49136364806c597d0420d20c2fe144a5cd45/src/clj/coffi/mem.clj#L61">view source</a></div></div><div class="public anchor" id="var-big-endian"><h3>big-endian</h3><div class="usage"></div><div class="doc"><div class="markdown"><p>The big-endian <a href="null">ByteOrder</a>.</p>
</div></div><div class="src-link"><a href="https://github.com/IGJoshua/coffi/blob/58eaffdf543a3aa00436dafef2c65b247ad3f916/src/clj/coffi/mem.clj#L59">view source</a></div></div><div class="public anchor" id="var-big-endian"><h3>big-endian</h3><div class="usage"></div><div class="doc"><div class="markdown"><p>The big-endian <a href="null">ByteOrder</a>.</p>
<p>See <a href="coffi.mem.html#var-little-endian">little-endian</a>, <a href="coffi.mem.html#var-native-endian">native-endian</a>.</p>
</div></div><div class="src-link"><a href="https://github.com/IGJoshua/coffi/blob/18fd49136364806c597d0420d20c2fe144a5cd45/src/clj/coffi/mem.clj#L189">view source</a></div></div><div class="public anchor" id="var-byte-layout"><h3>byte-layout</h3><div class="usage"></div><div class="doc"><div class="markdown"><p>The <a href="null">MemoryLayout</a> for a byte in <a href="coffi.mem.html#var-native-endian">native-endian</a> <a href="null">ByteOrder</a>.</p>
</div></div><div class="src-link"><a href="https://github.com/IGJoshua/coffi/blob/18fd49136364806c597d0420d20c2fe144a5cd45/src/clj/coffi/mem.clj#L207">view source</a></div></div><div class="public anchor" id="var-c-layout"><h3>c-layout</h3><h4 class="type">multimethod</h4><div class="usage"></div><div class="doc"><div class="markdown"><p>Gets the layout object for a given <code>type</code>.</p>
</div></div><div class="src-link"><a href="https://github.com/IGJoshua/coffi/blob/58eaffdf543a3aa00436dafef2c65b247ad3f916/src/clj/coffi/mem.clj#L187">view source</a></div></div><div class="public anchor" id="var-byte-layout"><h3>byte-layout</h3><div class="usage"></div><div class="doc"><div class="markdown"><p>The <a href="null">MemoryLayout</a> for a byte in <a href="coffi.mem.html#var-native-endian">native-endian</a> <a href="null">ByteOrder</a>.</p>
</div></div><div class="src-link"><a href="https://github.com/IGJoshua/coffi/blob/58eaffdf543a3aa00436dafef2c65b247ad3f916/src/clj/coffi/mem.clj#L205">view source</a></div></div><div class="public anchor" id="var-c-layout"><h3>c-layout</h3><h4 class="type">multimethod</h4><div class="usage"></div><div class="doc"><div class="markdown"><p>Gets the layout object for a given <code>type</code>.</p>
<p>If a type is primitive it will return the appropriate primitive layout (see <a href="null">c-prim-layout</a>).</p>
<p>Otherwise, it should return a <a href="null">GroupLayout</a> for the given type.</p>
</div></div><div class="src-link"><a href="https://github.com/IGJoshua/coffi/blob/18fd49136364806c597d0420d20c2fe144a5cd45/src/clj/coffi/mem.clj#L731">view source</a></div></div><div class="public anchor" id="var-char-layout"><h3>char-layout</h3><div class="usage"></div><div class="doc"><div class="markdown"><p>The <a href="null">MemoryLayout</a> for a c-sized char in <a href="coffi.mem.html#var-native-endian">native-endian</a> <a href="null">ByteOrder</a>.</p>
</div></div><div class="src-link"><a href="https://github.com/IGJoshua/coffi/blob/18fd49136364806c597d0420d20c2fe144a5cd45/src/clj/coffi/mem.clj#L223">view source</a></div></div><div class="public anchor" id="var-clone-segment"><h3>clone-segment</h3><div class="usage"><code>(clone-segment segment)</code><code>(clone-segment segment arena)</code></div><div class="doc"><div class="markdown"><p>Clones the content of <code>segment</code> into a new segment of the same size.</p>
</div></div><div class="src-link"><a href="https://github.com/IGJoshua/coffi/blob/18fd49136364806c597d0420d20c2fe144a5cd45/src/clj/coffi/mem.clj#L176">view source</a></div></div><div class="public anchor" id="var-confined-arena"><h3>confined-arena</h3><div class="usage"><code>(confined-arena)</code></div><div class="doc"><div class="markdown"><p>Constructs a new arena for use only in this thread.</p>
</div></div><div class="src-link"><a href="https://github.com/IGJoshua/coffi/blob/58eaffdf543a3aa00436dafef2c65b247ad3f916/src/clj/coffi/mem.clj#L729">view source</a></div></div><div class="public anchor" id="var-char-layout"><h3>char-layout</h3><div class="usage"></div><div class="doc"><div class="markdown"><p>The <a href="null">MemoryLayout</a> for a c-sized char in <a href="coffi.mem.html#var-native-endian">native-endian</a> <a href="null">ByteOrder</a>.</p>
</div></div><div class="src-link"><a href="https://github.com/IGJoshua/coffi/blob/58eaffdf543a3aa00436dafef2c65b247ad3f916/src/clj/coffi/mem.clj#L221">view source</a></div></div><div class="public anchor" id="var-clone-segment"><h3>clone-segment</h3><div class="usage"><code>(clone-segment segment)</code><code>(clone-segment segment arena)</code></div><div class="doc"><div class="markdown"><p>Clones the content of <code>segment</code> into a new segment of the same size.</p>
</div></div><div class="src-link"><a href="https://github.com/IGJoshua/coffi/blob/58eaffdf543a3aa00436dafef2c65b247ad3f916/src/clj/coffi/mem.clj#L174">view source</a></div></div><div class="public anchor" id="var-confined-arena"><h3>confined-arena</h3><div class="usage"><code>(confined-arena)</code></div><div class="doc"><div class="markdown"><p>Constructs a new arena for use only in this thread.</p>
<p>The memory allocated within this arena is cheap to allocate, like a native stack.</p>
<p>The memory allocated within this arena will be cleared once it is closed, so it is usually a good idea to create it in a <a href="null">with-open</a> clause.</p>
</div></div><div class="src-link"><a href="https://github.com/IGJoshua/coffi/blob/18fd49136364806c597d0420d20c2fe144a5cd45/src/clj/coffi/mem.clj#L42">view source</a></div></div><div class="public anchor" id="var-copy-segment"><h3>copy-segment</h3><div class="usage"><code>(copy-segment dest src)</code></div><div class="doc"><div class="markdown"><p>Copies the content to <code>dest</code> from <code>src</code>.</p>
</div></div><div class="src-link"><a href="https://github.com/IGJoshua/coffi/blob/58eaffdf543a3aa00436dafef2c65b247ad3f916/src/clj/coffi/mem.clj#L40">view source</a></div></div><div class="public anchor" id="var-copy-segment"><h3>copy-segment</h3><div class="usage"><code>(copy-segment dest src)</code></div><div class="doc"><div class="markdown"><p>Copies the content to <code>dest</code> from <code>src</code>.</p>
<p>Returns <code>dest</code>.</p>
</div></div><div class="src-link"><a href="https://github.com/IGJoshua/coffi/blob/18fd49136364806c597d0420d20c2fe144a5cd45/src/clj/coffi/mem.clj#L169">view source</a></div></div><div class="public anchor" id="var-defalias"><h3>defalias</h3><h4 class="type">macro</h4><div class="usage"><code>(defalias new-type aliased-type)</code></div><div class="doc"><div class="markdown"><p>Defines a type alias from <code>new-type</code> to <code>aliased-type</code>.</p>
</div></div><div class="src-link"><a href="https://github.com/IGJoshua/coffi/blob/58eaffdf543a3aa00436dafef2c65b247ad3f916/src/clj/coffi/mem.clj#L167">view source</a></div></div><div class="public anchor" id="var-defalias"><h3>defalias</h3><h4 class="type">macro</h4><div class="usage"><code>(defalias new-type aliased-type)</code></div><div class="doc"><div class="markdown"><p>Defines a type alias from <code>new-type</code> to <code>aliased-type</code>.</p>
<p>This creates needed serialization and deserialization implementations for the aliased type.</p>
</div></div><div class="src-link"><a href="https://github.com/IGJoshua/coffi/blob/18fd49136364806c597d0420d20c2fe144a5cd45/src/clj/coffi/mem.clj#L1326">view source</a></div></div><div class="public anchor" id="var-deserialize"><h3>deserialize</h3><div class="usage"><code>(deserialize obj type)</code></div><div class="doc"><div class="markdown"><p>Deserializes an arbitrary type.</p>
</div></div><div class="src-link"><a href="https://github.com/IGJoshua/coffi/blob/58eaffdf543a3aa00436dafef2c65b247ad3f916/src/clj/coffi/mem.clj#L1319">view source</a></div></div><div class="public anchor" id="var-deserialize"><h3>deserialize</h3><div class="usage"><code>(deserialize obj type)</code></div><div class="doc"><div class="markdown"><p>Deserializes an arbitrary type.</p>
<p>For types which have a primitive representation, this deserializes the primitive representation. For types which do not, this deserializes out of a segment.</p>
</div></div><div class="src-link"><a href="https://github.com/IGJoshua/coffi/blob/18fd49136364806c597d0420d20c2fe144a5cd45/src/clj/coffi/mem.clj#L1094">view source</a></div></div><div class="public anchor" id="var-deserialize*"><h3>deserialize*</h3><h4 class="type">multimethod</h4><div class="usage"></div><div class="doc"><div class="markdown"><p>Deserializes a primitive object into a Clojure data structure.</p>
</div></div><div class="src-link"><a href="https://github.com/IGJoshua/coffi/blob/58eaffdf543a3aa00436dafef2c65b247ad3f916/src/clj/coffi/mem.clj#L1092">view source</a></div></div><div class="public anchor" id="var-deserialize*"><h3>deserialize*</h3><h4 class="type">multimethod</h4><div class="usage"></div><div class="doc"><div class="markdown"><p>Deserializes a primitive object into a Clojure data structure.</p>
<p>This is intended for use with types that are returned as a primitive but which need additional processing before they can be returned.</p>
</div></div><div class="src-link"><a href="https://github.com/IGJoshua/coffi/blob/18fd49136364806c597d0420d20c2fe144a5cd45/src/clj/coffi/mem.clj#L1035">view source</a></div></div><div class="public anchor" id="var-deserialize-from"><h3>deserialize-from</h3><h4 class="type">multimethod</h4><div class="usage"></div><div class="doc"><div class="markdown"><p>Deserializes the given segment into a Clojure data structure.</p>
</div></div><div class="src-link"><a href="https://github.com/IGJoshua/coffi/blob/58eaffdf543a3aa00436dafef2c65b247ad3f916/src/clj/coffi/mem.clj#L1033">view source</a></div></div><div class="public anchor" id="var-deserialize-from"><h3>deserialize-from</h3><h4 class="type">multimethod</h4><div class="usage"></div><div class="doc"><div class="markdown"><p>Deserializes the given segment into a Clojure data structure.</p>
<p>For types that serialize to primitives, a default implementation will deserialize the primitive before calling <a href="coffi.mem.html#var-deserialize*">deserialize*</a>.</p>
</div></div><div class="src-link"><a href="https://github.com/IGJoshua/coffi/blob/18fd49136364806c597d0420d20c2fe144a5cd45/src/clj/coffi/mem.clj#L972">view source</a></div></div><div class="public anchor" id="var-double-alignment"><h3>double-alignment</h3><div class="usage"></div><div class="doc"><div class="markdown"><p>The alignment in bytes of a c-sized double.</p>
</div></div><div class="src-link"><a href="https://github.com/IGJoshua/coffi/blob/18fd49136364806c597d0420d20c2fe144a5cd45/src/clj/coffi/mem.clj#L279">view source</a></div></div><div class="public anchor" id="var-double-layout"><h3>double-layout</h3><div class="usage"></div><div class="doc"><div class="markdown"><p>The <a href="null">MemoryLayout</a> for a c-sized double in <a href="coffi.mem.html#var-native-endian">native-endian</a> <a href="null">ByteOrder</a>.</p>
</div></div><div class="src-link"><a href="https://github.com/IGJoshua/coffi/blob/18fd49136364806c597d0420d20c2fe144a5cd45/src/clj/coffi/mem.clj#L231">view source</a></div></div><div class="public anchor" id="var-double-size"><h3>double-size</h3><div class="usage"></div><div class="doc"><div class="markdown"><p>The size in bytes of a c-sized double.</p>
</div></div><div class="src-link"><a href="https://github.com/IGJoshua/coffi/blob/18fd49136364806c597d0420d20c2fe144a5cd45/src/clj/coffi/mem.clj#L255">view source</a></div></div><div class="public anchor" id="var-float-alignment"><h3>float-alignment</h3><div class="usage"></div><div class="doc"><div class="markdown"><p>The alignment in bytes of a c-sized float.</p>
</div></div><div class="src-link"><a href="https://github.com/IGJoshua/coffi/blob/18fd49136364806c597d0420d20c2fe144a5cd45/src/clj/coffi/mem.clj#L275">view source</a></div></div><div class="public anchor" id="var-float-layout"><h3>float-layout</h3><div class="usage"></div><div class="doc"><div class="markdown"><p>The <a href="null">MemoryLayout</a> for a c-sized float in <a href="coffi.mem.html#var-native-endian">native-endian</a> <a href="null">ByteOrder</a>.</p>
</div></div><div class="src-link"><a href="https://github.com/IGJoshua/coffi/blob/18fd49136364806c597d0420d20c2fe144a5cd45/src/clj/coffi/mem.clj#L227">view source</a></div></div><div class="public anchor" id="var-float-size"><h3>float-size</h3><div class="usage"></div><div class="doc"><div class="markdown"><p>The size in bytes of a c-sized float.</p>
</div></div><div class="src-link"><a href="https://github.com/IGJoshua/coffi/blob/18fd49136364806c597d0420d20c2fe144a5cd45/src/clj/coffi/mem.clj#L251">view source</a></div></div><div class="public anchor" id="var-global-arena"><h3>global-arena</h3><div class="usage"><code>(global-arena)</code></div><div class="doc"><div class="markdown"><p>Constructs the global arena, which will never reclaim its resources.</p>
</div></div><div class="src-link"><a href="https://github.com/IGJoshua/coffi/blob/58eaffdf543a3aa00436dafef2c65b247ad3f916/src/clj/coffi/mem.clj#L970">view source</a></div></div><div class="public anchor" id="var-double-alignment"><h3>double-alignment</h3><div class="usage"></div><div class="doc"><div class="markdown"><p>The alignment in bytes of a c-sized double.</p>
</div></div><div class="src-link"><a href="https://github.com/IGJoshua/coffi/blob/58eaffdf543a3aa00436dafef2c65b247ad3f916/src/clj/coffi/mem.clj#L277">view source</a></div></div><div class="public anchor" id="var-double-layout"><h3>double-layout</h3><div class="usage"></div><div class="doc"><div class="markdown"><p>The <a href="null">MemoryLayout</a> for a c-sized double in <a href="coffi.mem.html#var-native-endian">native-endian</a> <a href="null">ByteOrder</a>.</p>
</div></div><div class="src-link"><a href="https://github.com/IGJoshua/coffi/blob/58eaffdf543a3aa00436dafef2c65b247ad3f916/src/clj/coffi/mem.clj#L229">view source</a></div></div><div class="public anchor" id="var-double-size"><h3>double-size</h3><div class="usage"></div><div class="doc"><div class="markdown"><p>The size in bytes of a c-sized double.</p>
</div></div><div class="src-link"><a href="https://github.com/IGJoshua/coffi/blob/58eaffdf543a3aa00436dafef2c65b247ad3f916/src/clj/coffi/mem.clj#L253">view source</a></div></div><div class="public anchor" id="var-float-alignment"><h3>float-alignment</h3><div class="usage"></div><div class="doc"><div class="markdown"><p>The alignment in bytes of a c-sized float.</p>
</div></div><div class="src-link"><a href="https://github.com/IGJoshua/coffi/blob/58eaffdf543a3aa00436dafef2c65b247ad3f916/src/clj/coffi/mem.clj#L273">view source</a></div></div><div class="public anchor" id="var-float-layout"><h3>float-layout</h3><div class="usage"></div><div class="doc"><div class="markdown"><p>The <a href="null">MemoryLayout</a> for a c-sized float in <a href="coffi.mem.html#var-native-endian">native-endian</a> <a href="null">ByteOrder</a>.</p>
</div></div><div class="src-link"><a href="https://github.com/IGJoshua/coffi/blob/58eaffdf543a3aa00436dafef2c65b247ad3f916/src/clj/coffi/mem.clj#L225">view source</a></div></div><div class="public anchor" id="var-float-size"><h3>float-size</h3><div class="usage"></div><div class="doc"><div class="markdown"><p>The size in bytes of a c-sized float.</p>
</div></div><div class="src-link"><a href="https://github.com/IGJoshua/coffi/blob/58eaffdf543a3aa00436dafef2c65b247ad3f916/src/clj/coffi/mem.clj#L249">view source</a></div></div><div class="public anchor" id="var-global-arena"><h3>global-arena</h3><div class="usage"><code>(global-arena)</code></div><div class="doc"><div class="markdown"><p>Constructs the global arena, which will never reclaim its resources.</p>
<p>This arena may be shared across threads, but is intended mainly in cases where memory is allocated with <a href="coffi.mem.html#var-alloc">alloc</a> but is either never freed or whose management is relinquished to a native library, such as when returned from a callback.</p>
</div></div><div class="src-link"><a href="https://github.com/IGJoshua/coffi/blob/18fd49136364806c597d0420d20c2fe144a5cd45/src/clj/coffi/mem.clj#L72">view source</a></div></div><div class="public anchor" id="var-int-alignment"><h3>int-alignment</h3><div class="usage"></div><div class="doc"><div class="markdown"><p>The alignment in bytes of a c-sized int.</p>
</div></div><div class="src-link"><a href="https://github.com/IGJoshua/coffi/blob/18fd49136364806c597d0420d20c2fe144a5cd45/src/clj/coffi/mem.clj#L267">view source</a></div></div><div class="public anchor" id="var-int-layout"><h3>int-layout</h3><div class="usage"></div><div class="doc"><div class="markdown"><p>The <a href="null">MemoryLayout</a> for a c-sized int in <a href="coffi.mem.html#var-native-endian">native-endian</a> <a href="null">ByteOrder</a>.</p>
</div></div><div class="src-link"><a href="https://github.com/IGJoshua/coffi/blob/18fd49136364806c597d0420d20c2fe144a5cd45/src/clj/coffi/mem.clj#L215">view source</a></div></div><div class="public anchor" id="var-int-size"><h3>int-size</h3><div class="usage"></div><div class="doc"><div class="markdown"><p>The size in bytes of a c-sized int.</p>
</div></div><div class="src-link"><a href="https://github.com/IGJoshua/coffi/blob/18fd49136364806c597d0420d20c2fe144a5cd45/src/clj/coffi/mem.clj#L243">view source</a></div></div><div class="public anchor" id="var-java-layout"><h3>java-layout</h3><div class="usage"><code>(java-layout type)</code></div><div class="doc"><div class="markdown"><p>Gets the Java class to an argument of this type for a method handle.</p>
</div></div><div class="src-link"><a href="https://github.com/IGJoshua/coffi/blob/58eaffdf543a3aa00436dafef2c65b247ad3f916/src/clj/coffi/mem.clj#L70">view source</a></div></div><div class="public anchor" id="var-int-alignment"><h3>int-alignment</h3><div class="usage"></div><div class="doc"><div class="markdown"><p>The alignment in bytes of a c-sized int.</p>
</div></div><div class="src-link"><a href="https://github.com/IGJoshua/coffi/blob/58eaffdf543a3aa00436dafef2c65b247ad3f916/src/clj/coffi/mem.clj#L265">view source</a></div></div><div class="public anchor" id="var-int-layout"><h3>int-layout</h3><div class="usage"></div><div class="doc"><div class="markdown"><p>The <a href="null">MemoryLayout</a> for a c-sized int in <a href="coffi.mem.html#var-native-endian">native-endian</a> <a href="null">ByteOrder</a>.</p>
</div></div><div class="src-link"><a href="https://github.com/IGJoshua/coffi/blob/58eaffdf543a3aa00436dafef2c65b247ad3f916/src/clj/coffi/mem.clj#L213">view source</a></div></div><div class="public anchor" id="var-int-size"><h3>int-size</h3><div class="usage"></div><div class="doc"><div class="markdown"><p>The size in bytes of a c-sized int.</p>
</div></div><div class="src-link"><a href="https://github.com/IGJoshua/coffi/blob/58eaffdf543a3aa00436dafef2c65b247ad3f916/src/clj/coffi/mem.clj#L241">view source</a></div></div><div class="public anchor" id="var-java-layout"><h3>java-layout</h3><div class="usage"><code>(java-layout type)</code></div><div class="doc"><div class="markdown"><p>Gets the Java class to an argument of this type for a method handle.</p>
<p>If a type serializes to a primitive it returns return a Java primitive type. Otherwise, it returns <a href="null">MemorySegment</a>.</p>
</div></div><div class="src-link"><a href="https://github.com/IGJoshua/coffi/blob/18fd49136364806c597d0420d20c2fe144a5cd45/src/clj/coffi/mem.clj#L798">view source</a></div></div><div class="public anchor" id="var-java-prim-layout"><h3>java-prim-layout</h3><div class="usage"></div><div class="doc"><div class="markdown"><p>Map of primitive type names to the Java types for a method handle.</p>
</div></div><div class="src-link"><a href="https://github.com/IGJoshua/coffi/blob/18fd49136364806c597d0420d20c2fe144a5cd45/src/clj/coffi/mem.clj#L786">view source</a></div></div><div class="public anchor" id="var-little-endian"><h3>little-endian</h3><div class="usage"></div><div class="doc"><div class="markdown"><p>The little-endian <a href="null">ByteOrder</a>.</p>
</div></div><div class="src-link"><a href="https://github.com/IGJoshua/coffi/blob/58eaffdf543a3aa00436dafef2c65b247ad3f916/src/clj/coffi/mem.clj#L796">view source</a></div></div><div class="public anchor" id="var-java-prim-layout"><h3>java-prim-layout</h3><div class="usage"></div><div class="doc"><div class="markdown"><p>Map of primitive type names to the Java types for a method handle.</p>
</div></div><div class="src-link"><a href="https://github.com/IGJoshua/coffi/blob/58eaffdf543a3aa00436dafef2c65b247ad3f916/src/clj/coffi/mem.clj#L784">view source</a></div></div><div class="public anchor" id="var-little-endian"><h3>little-endian</h3><div class="usage"></div><div class="doc"><div class="markdown"><p>The little-endian <a href="null">ByteOrder</a>.</p>
<p>See <a href="coffi.mem.html#var-big-endian">big-endian</a>, <a href="coffi.mem.html#var-native-endian">native-endian</a></p>
</div></div><div class="src-link"><a href="https://github.com/IGJoshua/coffi/blob/18fd49136364806c597d0420d20c2fe144a5cd45/src/clj/coffi/mem.clj#L195">view source</a></div></div><div class="public anchor" id="var-long-alignment"><h3>long-alignment</h3><div class="usage"></div><div class="doc"><div class="markdown"><p>The alignment in bytes of a c-sized long.</p>
</div></div><div class="src-link"><a href="https://github.com/IGJoshua/coffi/blob/18fd49136364806c597d0420d20c2fe144a5cd45/src/clj/coffi/mem.clj#L271">view source</a></div></div><div class="public anchor" id="var-long-layout"><h3>long-layout</h3><div class="usage"></div><div class="doc"><div class="markdown"><p>The <a href="null">MemoryLayout</a> for a c-sized long in <a href="coffi.mem.html#var-native-endian">native-endian</a> <a href="null">ByteOrder</a>.</p>
</div></div><div class="src-link"><a href="https://github.com/IGJoshua/coffi/blob/18fd49136364806c597d0420d20c2fe144a5cd45/src/clj/coffi/mem.clj#L219">view source</a></div></div><div class="public anchor" id="var-long-size"><h3>long-size</h3><div class="usage"></div><div class="doc"><div class="markdown"><p>The size in bytes of a c-sized long.</p>
</div></div><div class="src-link"><a href="https://github.com/IGJoshua/coffi/blob/18fd49136364806c597d0420d20c2fe144a5cd45/src/clj/coffi/mem.clj#L247">view source</a></div></div><div class="public anchor" id="var-native-endian"><h3>native-endian</h3><div class="usage"></div><div class="doc"><div class="markdown"><p>The <a href="null">ByteOrder</a> for the native endianness of the current hardware.</p>
</div></div><div class="src-link"><a href="https://github.com/IGJoshua/coffi/blob/58eaffdf543a3aa00436dafef2c65b247ad3f916/src/clj/coffi/mem.clj#L193">view source</a></div></div><div class="public anchor" id="var-long-alignment"><h3>long-alignment</h3><div class="usage"></div><div class="doc"><div class="markdown"><p>The alignment in bytes of a c-sized long.</p>
</div></div><div class="src-link"><a href="https://github.com/IGJoshua/coffi/blob/58eaffdf543a3aa00436dafef2c65b247ad3f916/src/clj/coffi/mem.clj#L269">view source</a></div></div><div class="public anchor" id="var-long-layout"><h3>long-layout</h3><div class="usage"></div><div class="doc"><div class="markdown"><p>The <a href="null">MemoryLayout</a> for a c-sized long in <a href="coffi.mem.html#var-native-endian">native-endian</a> <a href="null">ByteOrder</a>.</p>
</div></div><div class="src-link"><a href="https://github.com/IGJoshua/coffi/blob/58eaffdf543a3aa00436dafef2c65b247ad3f916/src/clj/coffi/mem.clj#L217">view source</a></div></div><div class="public anchor" id="var-long-size"><h3>long-size</h3><div class="usage"></div><div class="doc"><div class="markdown"><p>The size in bytes of a c-sized long.</p>
</div></div><div class="src-link"><a href="https://github.com/IGJoshua/coffi/blob/58eaffdf543a3aa00436dafef2c65b247ad3f916/src/clj/coffi/mem.clj#L245">view source</a></div></div><div class="public anchor" id="var-native-endian"><h3>native-endian</h3><div class="usage"></div><div class="doc"><div class="markdown"><p>The <a href="null">ByteOrder</a> for the native endianness of the current hardware.</p>
<p>See <a href="coffi.mem.html#var-big-endian">big-endian</a>, <a href="coffi.mem.html#var-little-endian">little-endian</a>.</p>
</div></div><div class="src-link"><a href="https://github.com/IGJoshua/coffi/blob/18fd49136364806c597d0420d20c2fe144a5cd45/src/clj/coffi/mem.clj#L201">view source</a></div></div><div class="public anchor" id="var-null"><h3>null</h3><div class="usage"></div><div class="doc"><div class="markdown"><p>The NULL pointer object.</p>
</div></div><div class="src-link"><a href="https://github.com/IGJoshua/coffi/blob/58eaffdf543a3aa00436dafef2c65b247ad3f916/src/clj/coffi/mem.clj#L199">view source</a></div></div><div class="public anchor" id="var-null"><h3>null</h3><div class="usage"></div><div class="doc"><div class="markdown"><p>The NULL pointer object.</p>
<p>While this object is safe to pass to functions which serialize to a pointer, its generally encouraged to simply pass <code>nil</code>. This value primarily exists to make it easier to write custom types with a primitive pointer representation.</p>
</div></div><div class="src-link"><a href="https://github.com/IGJoshua/coffi/blob/18fd49136364806c597d0420d20c2fe144a5cd45/src/clj/coffi/mem.clj#L113">view source</a></div></div><div class="public anchor" id="var-null.3F"><h3>null?</h3><div class="usage"><code>(null? addr)</code></div><div class="doc"><div class="markdown"><p>Checks if a memory address is null.</p>
</div></div><div class="src-link"><a href="https://github.com/IGJoshua/coffi/blob/18fd49136364806c597d0420d20c2fe144a5cd45/src/clj/coffi/mem.clj#L121">view source</a></div></div><div class="public anchor" id="var-pointer-alignment"><h3>pointer-alignment</h3><div class="usage"></div><div class="doc"><div class="markdown"><p>The alignment in bytes of a c-sized pointer.</p>
</div></div><div class="src-link"><a href="https://github.com/IGJoshua/coffi/blob/18fd49136364806c597d0420d20c2fe144a5cd45/src/clj/coffi/mem.clj#L283">view source</a></div></div><div class="public anchor" id="var-pointer-layout"><h3>pointer-layout</h3><div class="usage"></div><div class="doc"><div class="markdown"><p>The <a href="null">MemoryLayout</a> for a native pointer in <a href="coffi.mem.html#var-native-endian">native-endian</a> <a href="null">ByteOrder</a>.</p>
</div></div><div class="src-link"><a href="https://github.com/IGJoshua/coffi/blob/18fd49136364806c597d0420d20c2fe144a5cd45/src/clj/coffi/mem.clj#L235">view source</a></div></div><div class="public anchor" id="var-pointer-size"><h3>pointer-size</h3><div class="usage"></div><div class="doc"><div class="markdown"><p>The size in bytes of a c-sized pointer.</p>
</div></div><div class="src-link"><a href="https://github.com/IGJoshua/coffi/blob/18fd49136364806c597d0420d20c2fe144a5cd45/src/clj/coffi/mem.clj#L259">view source</a></div></div><div class="public anchor" id="var-primitive-type"><h3>primitive-type</h3><h4 class="type">multimethod</h4><div class="usage"></div><div class="doc"><div class="markdown"><p>Gets the primitive type that is used to pass as an argument for the <code>type</code>.</p>
</div></div><div class="src-link"><a href="https://github.com/IGJoshua/coffi/blob/58eaffdf543a3aa00436dafef2c65b247ad3f916/src/clj/coffi/mem.clj#L111">view source</a></div></div><div class="public anchor" id="var-null.3F"><h3>null?</h3><div class="usage"><code>(null? addr)</code></div><div class="doc"><div class="markdown"><p>Checks if a memory address is null.</p>
</div></div><div class="src-link"><a href="https://github.com/IGJoshua/coffi/blob/58eaffdf543a3aa00436dafef2c65b247ad3f916/src/clj/coffi/mem.clj#L119">view source</a></div></div><div class="public anchor" id="var-pointer-alignment"><h3>pointer-alignment</h3><div class="usage"></div><div class="doc"><div class="markdown"><p>The alignment in bytes of a c-sized pointer.</p>
</div></div><div class="src-link"><a href="https://github.com/IGJoshua/coffi/blob/58eaffdf543a3aa00436dafef2c65b247ad3f916/src/clj/coffi/mem.clj#L281">view source</a></div></div><div class="public anchor" id="var-pointer-layout"><h3>pointer-layout</h3><div class="usage"></div><div class="doc"><div class="markdown"><p>The <a href="null">MemoryLayout</a> for a native pointer in <a href="coffi.mem.html#var-native-endian">native-endian</a> <a href="null">ByteOrder</a>.</p>
</div></div><div class="src-link"><a href="https://github.com/IGJoshua/coffi/blob/58eaffdf543a3aa00436dafef2c65b247ad3f916/src/clj/coffi/mem.clj#L233">view source</a></div></div><div class="public anchor" id="var-pointer-size"><h3>pointer-size</h3><div class="usage"></div><div class="doc"><div class="markdown"><p>The size in bytes of a c-sized pointer.</p>
</div></div><div class="src-link"><a href="https://github.com/IGJoshua/coffi/blob/58eaffdf543a3aa00436dafef2c65b247ad3f916/src/clj/coffi/mem.clj#L257">view source</a></div></div><div class="public anchor" id="var-primitive-type"><h3>primitive-type</h3><h4 class="type">multimethod</h4><div class="usage"></div><div class="doc"><div class="markdown"><p>Gets the primitive type that is used to pass as an argument for the <code>type</code>.</p>
<p>This is for objects which are passed to native functions as primitive types, but which need additional logic to be performed during serialization and deserialization.</p>
<p>Implementations of this method should take into account that type arguments may not always be evaluated before passing to this function.</p>
<p>Returns nil for any type which does not have a primitive representation.</p>
</div></div><div class="src-link"><a href="https://github.com/IGJoshua/coffi/blob/18fd49136364806c597d0420d20c2fe144a5cd45/src/clj/coffi/mem.clj#L678">view source</a></div></div><div class="public anchor" id="var-primitive-types"><h3>primitive-types</h3><div class="usage"></div><div class="doc"><div class="markdown"><p>A set of all primitive types.</p>
</div></div><div class="src-link"><a href="https://github.com/IGJoshua/coffi/blob/18fd49136364806c597d0420d20c2fe144a5cd45/src/clj/coffi/mem.clj#L668">view source</a></div></div><div class="public anchor" id="var-primitive.3F"><h3>primitive?</h3><div class="usage"><code>(primitive? type)</code></div><div class="doc"><div class="markdown"><p>A predicate to determine if a given type is primitive.</p>
</div></div><div class="src-link"><a href="https://github.com/IGJoshua/coffi/blob/18fd49136364806c597d0420d20c2fe144a5cd45/src/clj/coffi/mem.clj#L673">view source</a></div></div><div class="public anchor" id="var-read-address"><h3>read-address</h3><div class="usage"><code>(read-address segment)</code><code>(read-address segment offset)</code></div><div class="doc"><div class="markdown"><p>Reads an address from the <code>segment</code>, at an optional <code>offset</code>, wrapped in a <a href="null">MemorySegment</a>.</p>
</div></div><div class="src-link"><a href="https://github.com/IGJoshua/coffi/blob/18fd49136364806c597d0420d20c2fe144a5cd45/src/clj/coffi/mem.clj#L444">view source</a></div></div><div class="public anchor" id="var-read-byte"><h3>read-byte</h3><div class="usage"><code>(read-byte segment)</code><code>(read-byte segment offset)</code></div><div class="doc"><div class="markdown"><p>Reads a <a href="null">byte</a> from the <code>segment</code>, at an optional <code>offset</code>.</p>
</div></div><div class="src-link"><a href="https://github.com/IGJoshua/coffi/blob/18fd49136364806c597d0420d20c2fe144a5cd45/src/clj/coffi/mem.clj#L287">view source</a></div></div><div class="public anchor" id="var-read-char"><h3>read-char</h3><div class="usage"><code>(read-char segment)</code><code>(read-char segment offset)</code></div><div class="doc"><div class="markdown"><p>Reads a <a href="null">char</a> from the <code>segment</code>, at an optional <code>offset</code>.</p>
</div></div><div class="src-link"><a href="https://github.com/IGJoshua/coffi/blob/18fd49136364806c597d0420d20c2fe144a5cd45/src/clj/coffi/mem.clj#L378">view source</a></div></div><div class="public anchor" id="var-read-double"><h3>read-double</h3><div class="usage"><code>(read-double segment)</code><code>(read-double segment offset)</code><code>(read-double segment offset byte-order)</code></div><div class="doc"><div class="markdown"><p>Reads a <a href="null">double</a> from the <code>segment</code>, at an optional <code>offset</code>.</p>
</div></div><div class="src-link"><a href="https://github.com/IGJoshua/coffi/blob/58eaffdf543a3aa00436dafef2c65b247ad3f916/src/clj/coffi/mem.clj#L676">view source</a></div></div><div class="public anchor" id="var-primitive-types"><h3>primitive-types</h3><div class="usage"></div><div class="doc"><div class="markdown"><p>A set of all primitive types.</p>
</div></div><div class="src-link"><a href="https://github.com/IGJoshua/coffi/blob/58eaffdf543a3aa00436dafef2c65b247ad3f916/src/clj/coffi/mem.clj#L666">view source</a></div></div><div class="public anchor" id="var-primitive.3F"><h3>primitive?</h3><div class="usage"><code>(primitive? type)</code></div><div class="doc"><div class="markdown"><p>A predicate to determine if a given type is primitive.</p>
</div></div><div class="src-link"><a href="https://github.com/IGJoshua/coffi/blob/58eaffdf543a3aa00436dafef2c65b247ad3f916/src/clj/coffi/mem.clj#L671">view source</a></div></div><div class="public anchor" id="var-read-address"><h3>read-address</h3><div class="usage"><code>(read-address segment)</code><code>(read-address segment offset)</code></div><div class="doc"><div class="markdown"><p>Reads an address from the <code>segment</code>, at an optional <code>offset</code>, wrapped in a <a href="null">MemorySegment</a>.</p>
</div></div><div class="src-link"><a href="https://github.com/IGJoshua/coffi/blob/58eaffdf543a3aa00436dafef2c65b247ad3f916/src/clj/coffi/mem.clj#L442">view source</a></div></div><div class="public anchor" id="var-read-byte"><h3>read-byte</h3><div class="usage"><code>(read-byte segment)</code><code>(read-byte segment offset)</code></div><div class="doc"><div class="markdown"><p>Reads a <a href="null">byte</a> from the <code>segment</code>, at an optional <code>offset</code>.</p>
</div></div><div class="src-link"><a href="https://github.com/IGJoshua/coffi/blob/58eaffdf543a3aa00436dafef2c65b247ad3f916/src/clj/coffi/mem.clj#L285">view source</a></div></div><div class="public anchor" id="var-read-char"><h3>read-char</h3><div class="usage"><code>(read-char segment)</code><code>(read-char segment offset)</code></div><div class="doc"><div class="markdown"><p>Reads a <a href="null">char</a> from the <code>segment</code>, at an optional <code>offset</code>.</p>
</div></div><div class="src-link"><a href="https://github.com/IGJoshua/coffi/blob/58eaffdf543a3aa00436dafef2c65b247ad3f916/src/clj/coffi/mem.clj#L376">view source</a></div></div><div class="public anchor" id="var-read-double"><h3>read-double</h3><div class="usage"><code>(read-double segment)</code><code>(read-double segment offset)</code><code>(read-double segment offset byte-order)</code></div><div class="doc"><div class="markdown"><p>Reads a <a href="null">double</a> from the <code>segment</code>, at an optional <code>offset</code>.</p>
<p>If <code>byte-order</code> is not provided, it defaults to <a href="coffi.mem.html#var-native-endian">native-endian</a>.</p>
</div></div><div class="src-link"><a href="https://github.com/IGJoshua/coffi/blob/18fd49136364806c597d0420d20c2fe144a5cd45/src/clj/coffi/mem.clj#L419">view source</a></div></div><div class="public anchor" id="var-read-float"><h3>read-float</h3><div class="usage"><code>(read-float segment)</code><code>(read-float segment offset)</code><code>(read-float segment offset byte-order)</code></div><div class="doc"><div class="markdown"><p>Reads a <a href="null">float</a> from the <code>segment</code>, at an optional <code>offset</code>.</p>
</div></div><div class="src-link"><a href="https://github.com/IGJoshua/coffi/blob/58eaffdf543a3aa00436dafef2c65b247ad3f916/src/clj/coffi/mem.clj#L417">view source</a></div></div><div class="public anchor" id="var-read-float"><h3>read-float</h3><div class="usage"><code>(read-float segment)</code><code>(read-float segment offset)</code><code>(read-float segment offset byte-order)</code></div><div class="doc"><div class="markdown"><p>Reads a <a href="null">float</a> from the <code>segment</code>, at an optional <code>offset</code>.</p>
<p>If <code>byte-order</code> is not provided, it defaults to <a href="coffi.mem.html#var-native-endian">native-endian</a>.</p>
</div></div><div class="src-link"><a href="https://github.com/IGJoshua/coffi/blob/18fd49136364806c597d0420d20c2fe144a5cd45/src/clj/coffi/mem.clj#L394">view source</a></div></div><div class="public anchor" id="var-read-int"><h3>read-int</h3><div class="usage"><code>(read-int segment)</code><code>(read-int segment offset)</code><code>(read-int segment offset byte-order)</code></div><div class="doc"><div class="markdown"><p>Reads a <a href="null">int</a> from the <code>segment</code>, at an optional <code>offset</code>.</p>
</div></div><div class="src-link"><a href="https://github.com/IGJoshua/coffi/blob/58eaffdf543a3aa00436dafef2c65b247ad3f916/src/clj/coffi/mem.clj#L392">view source</a></div></div><div class="public anchor" id="var-read-int"><h3>read-int</h3><div class="usage"><code>(read-int segment)</code><code>(read-int segment offset)</code><code>(read-int segment offset byte-order)</code></div><div class="doc"><div class="markdown"><p>Reads a <a href="null">int</a> from the <code>segment</code>, at an optional <code>offset</code>.</p>
<p>If <code>byte-order</code> is not provided, it defaults to <a href="coffi.mem.html#var-native-endian">native-endian</a>.</p>
</div></div><div class="src-link"><a href="https://github.com/IGJoshua/coffi/blob/18fd49136364806c597d0420d20c2fe144a5cd45/src/clj/coffi/mem.clj#L328">view source</a></div></div><div class="public anchor" id="var-read-long"><h3>read-long</h3><div class="usage"><code>(read-long segment)</code><code>(read-long segment offset)</code><code>(read-long segment offset byte-order)</code></div><div class="doc"><div class="markdown"><p>Reads a <a href="null">long</a> from the <code>segment</code>, at an optional <code>offset</code>.</p>
</div></div><div class="src-link"><a href="https://github.com/IGJoshua/coffi/blob/58eaffdf543a3aa00436dafef2c65b247ad3f916/src/clj/coffi/mem.clj#L326">view source</a></div></div><div class="public anchor" id="var-read-long"><h3>read-long</h3><div class="usage"><code>(read-long segment)</code><code>(read-long segment offset)</code><code>(read-long segment offset byte-order)</code></div><div class="doc"><div class="markdown"><p>Reads a <a href="null">long</a> from the <code>segment</code>, at an optional <code>offset</code>.</p>
<p>If <code>byte-order</code> is not provided, it defaults to <a href="coffi.mem.html#var-native-endian">native-endian</a>.</p>
</div></div><div class="src-link"><a href="https://github.com/IGJoshua/coffi/blob/18fd49136364806c597d0420d20c2fe144a5cd45/src/clj/coffi/mem.clj#L353">view source</a></div></div><div class="public anchor" id="var-read-short"><h3>read-short</h3><div class="usage"><code>(read-short segment)</code><code>(read-short segment offset)</code><code>(read-short segment offset byte-order)</code></div><div class="doc"><div class="markdown"><p>Reads a <a href="null">short</a> from the <code>segment</code>, at an optional <code>offset</code>.</p>
</div></div><div class="src-link"><a href="https://github.com/IGJoshua/coffi/blob/58eaffdf543a3aa00436dafef2c65b247ad3f916/src/clj/coffi/mem.clj#L351">view source</a></div></div><div class="public anchor" id="var-read-short"><h3>read-short</h3><div class="usage"><code>(read-short segment)</code><code>(read-short segment offset)</code><code>(read-short segment offset byte-order)</code></div><div class="doc"><div class="markdown"><p>Reads a <a href="null">short</a> from the <code>segment</code>, at an optional <code>offset</code>.</p>
<p>If <code>byte-order</code> is not provided, it defaults to <a href="coffi.mem.html#var-native-endian">native-endian</a>.</p>
</div></div><div class="src-link"><a href="https://github.com/IGJoshua/coffi/blob/18fd49136364806c597d0420d20c2fe144a5cd45/src/clj/coffi/mem.clj#L303">view source</a></div></div><div class="public anchor" id="var-reinterpret"><h3>reinterpret</h3><div class="usage"><code>(reinterpret segment size)</code><code>(reinterpret segment size arena)</code><code>(reinterpret segment size arena cleanup)</code></div><div class="doc"><div class="markdown"><p>Reinterprets the <code>segment</code> as having the passed <code>size</code>.</p>
</div></div><div class="src-link"><a href="https://github.com/IGJoshua/coffi/blob/58eaffdf543a3aa00436dafef2c65b247ad3f916/src/clj/coffi/mem.clj#L301">view source</a></div></div><div class="public anchor" id="var-reinterpret"><h3>reinterpret</h3><div class="usage"><code>(reinterpret segment size)</code><code>(reinterpret segment size arena)</code><code>(reinterpret segment size arena cleanup)</code></div><div class="doc"><div class="markdown"><p>Reinterprets the <code>segment</code> as having the passed <code>size</code>.</p>
<p>If <code>arena</code> is passed, the scope of the <code>segment</code> is associated with the arena, as well as its access constraints. If <code>cleanup</code> is passed, it will be a 1-argument function of a fresh memory segment backed by the same memory as the returned segment which should perform any required cleanup operations. It will be called when the <code>arena</code> is closed.</p>
</div></div><div class="src-link"><a href="https://github.com/IGJoshua/coffi/blob/18fd49136364806c597d0420d20c2fe144a5cd45/src/clj/coffi/mem.clj#L140">view source</a></div></div><div class="public anchor" id="var-seq-of"><h3>seq-of</h3><div class="usage"><code>(seq-of type segment)</code></div><div class="doc"><div class="markdown"><p>Constructs a lazy sequence of <code>type</code> elements deserialized from <code>segment</code>.</p>
</div></div><div class="src-link"><a href="https://github.com/IGJoshua/coffi/blob/18fd49136364806c597d0420d20c2fe144a5cd45/src/clj/coffi/mem.clj#L1106">view source</a></div></div><div class="public anchor" id="var-serialize"><h3>serialize</h3><div class="usage"><code>(serialize obj type)</code><code>(serialize obj type arena)</code></div><div class="doc"><div class="markdown"><p>Serializes an arbitrary type.</p>
</div></div><div class="src-link"><a href="https://github.com/IGJoshua/coffi/blob/58eaffdf543a3aa00436dafef2c65b247ad3f916/src/clj/coffi/mem.clj#L138">view source</a></div></div><div class="public anchor" id="var-seq-of"><h3>seq-of</h3><div class="usage"><code>(seq-of type segment)</code></div><div class="doc"><div class="markdown"><p>Constructs a lazy sequence of <code>type</code> elements deserialized from <code>segment</code>.</p>
</div></div><div class="src-link"><a href="https://github.com/IGJoshua/coffi/blob/58eaffdf543a3aa00436dafef2c65b247ad3f916/src/clj/coffi/mem.clj#L1104">view source</a></div></div><div class="public anchor" id="var-serialize"><h3>serialize</h3><div class="usage"><code>(serialize obj type)</code><code>(serialize obj type arena)</code></div><div class="doc"><div class="markdown"><p>Serializes an arbitrary type.</p>
<p>For types which have a primitive representation, this serializes into that representation. For types which do not, it allocates a new segment and serializes into that.</p>
</div></div><div class="src-link"><a href="https://github.com/IGJoshua/coffi/blob/18fd49136364806c597d0420d20c2fe144a5cd45/src/clj/coffi/mem.clj#L956">view source</a></div></div><div class="public anchor" id="var-serialize*"><h3>serialize*</h3><h4 class="type">multimethod</h4><div class="usage"></div><div class="doc"><div class="markdown"><p>Constructs a serialized version of the <code>obj</code> and returns it.</p>
</div></div><div class="src-link"><a href="https://github.com/IGJoshua/coffi/blob/58eaffdf543a3aa00436dafef2c65b247ad3f916/src/clj/coffi/mem.clj#L954">view source</a></div></div><div class="public anchor" id="var-serialize*"><h3>serialize*</h3><h4 class="type">multimethod</h4><div class="usage"></div><div class="doc"><div class="markdown"><p>Constructs a serialized version of the <code>obj</code> and returns it.</p>
<p>Any new allocations made during the serialization should be tied to the given <code>arena</code>, except in extenuating circumstances.</p>
<p>This method should only be implemented for types that serialize to primitives.</p>
</div></div><div class="src-link"><a href="https://github.com/IGJoshua/coffi/blob/18fd49136364806c597d0420d20c2fe144a5cd45/src/clj/coffi/mem.clj#L827">view source</a></div></div><div class="public anchor" id="var-serialize-into"><h3>serialize-into</h3><h4 class="type">multimethod</h4><div class="usage"></div><div class="doc"><div class="markdown"><p>Writes a serialized version of the <code>obj</code> to the given <code>segment</code>.</p>
</div></div><div class="src-link"><a href="https://github.com/IGJoshua/coffi/blob/58eaffdf543a3aa00436dafef2c65b247ad3f916/src/clj/coffi/mem.clj#L825">view source</a></div></div><div class="public anchor" id="var-serialize-into"><h3>serialize-into</h3><h4 class="type">multimethod</h4><div class="usage"></div><div class="doc"><div class="markdown"><p>Writes a serialized version of the <code>obj</code> to the given <code>segment</code>.</p>
<p>Any new allocations made during the serialization should be tied to the given <code>arena</code>, except in extenuating circumstances.</p>
<p>This method should be implemented for any type which does not override <a href="coffi.mem.html#var-c-layout">c-layout</a>.</p>
<p>For any other type, this will serialize it as <a href="coffi.mem.html#var-serialize*">serialize*</a> before writing the result value into the <code>segment</code>.</p>
</div></div><div class="src-link"><a href="https://github.com/IGJoshua/coffi/blob/18fd49136364806c597d0420d20c2fe144a5cd45/src/clj/coffi/mem.clj#L887">view source</a></div></div><div class="public anchor" id="var-shared-arena"><h3>shared-arena</h3><div class="usage"><code>(shared-arena)</code></div><div class="doc"><div class="markdown"><p>Constructs a new shared memory arena.</p>
</div></div><div class="src-link"><a href="https://github.com/IGJoshua/coffi/blob/58eaffdf543a3aa00436dafef2c65b247ad3f916/src/clj/coffi/mem.clj#L885">view source</a></div></div><div class="public anchor" id="var-shared-arena"><h3>shared-arena</h3><div class="usage"><code>(shared-arena)</code></div><div class="doc"><div class="markdown"><p>Constructs a new shared memory arena.</p>
<p>This arena can be shared across threads and memory allocated in it will only be cleaned up once any thread accessing the arena closes it.</p>
</div></div><div class="src-link"><a href="https://github.com/IGJoshua/coffi/blob/18fd49136364806c597d0420d20c2fe144a5cd45/src/clj/coffi/mem.clj#L53">view source</a></div></div><div class="public anchor" id="var-short-alignment"><h3>short-alignment</h3><div class="usage"></div><div class="doc"><div class="markdown"><p>The alignment in bytes of a c-sized short.</p>
</div></div><div class="src-link"><a href="https://github.com/IGJoshua/coffi/blob/18fd49136364806c597d0420d20c2fe144a5cd45/src/clj/coffi/mem.clj#L263">view source</a></div></div><div class="public anchor" id="var-short-layout"><h3>short-layout</h3><div class="usage"></div><div class="doc"><div class="markdown"><p>The <a href="null">MemoryLayout</a> for a c-sized short in <a href="coffi.mem.html#var-native-endian">native-endian</a> <a href="null">ByteOrder</a>.</p>
</div></div><div class="src-link"><a href="https://github.com/IGJoshua/coffi/blob/18fd49136364806c597d0420d20c2fe144a5cd45/src/clj/coffi/mem.clj#L211">view source</a></div></div><div class="public anchor" id="var-short-size"><h3>short-size</h3><div class="usage"></div><div class="doc"><div class="markdown"><p>The size in bytes of a c-sized short.</p>
</div></div><div class="src-link"><a href="https://github.com/IGJoshua/coffi/blob/18fd49136364806c597d0420d20c2fe144a5cd45/src/clj/coffi/mem.clj#L239">view source</a></div></div><div class="public anchor" id="var-size-of"><h3>size-of</h3><div class="usage"><code>(size-of type)</code></div><div class="doc"><div class="markdown"><p>The size in bytes of the given <code>type</code>.</p>
</div></div><div class="src-link"><a href="https://github.com/IGJoshua/coffi/blob/18fd49136364806c597d0420d20c2fe144a5cd45/src/clj/coffi/mem.clj#L806">view source</a></div></div><div class="public anchor" id="var-slice"><h3>slice</h3><div class="usage"><code>(slice segment offset)</code><code>(slice segment offset size)</code></div><div class="doc"><div class="markdown"><p>Get a slice over the <code>segment</code> with the given <code>offset</code>.</p>
</div></div><div class="src-link"><a href="https://github.com/IGJoshua/coffi/blob/18fd49136364806c597d0420d20c2fe144a5cd45/src/clj/coffi/mem.clj#L133">view source</a></div></div><div class="public anchor" id="var-slice-segments"><h3>slice-segments</h3><div class="usage"><code>(slice-segments segment size)</code></div><div class="doc"><div class="markdown"><p>Constructs a lazy seq of <code>size</code>-length memory segments, sliced from <code>segment</code>.</p>
</div></div><div class="src-link"><a href="https://github.com/IGJoshua/coffi/blob/18fd49136364806c597d0420d20c2fe144a5cd45/src/clj/coffi/mem.clj#L182">view source</a></div></div><div class="public anchor" id="var-write-address"><h3>write-address</h3><div class="usage"><code>(write-address segment value)</code><code>(write-address segment offset value)</code></div><div class="doc"><div class="markdown"><p>Writes the address of the <a href="null">MemorySegment</a> <code>value</code> to the <code>segment</code>, at an optional <code>offset</code>.</p>
</div></div><div class="src-link"><a href="https://github.com/IGJoshua/coffi/blob/18fd49136364806c597d0420d20c2fe144a5cd45/src/clj/coffi/mem.clj#L642">view source</a></div></div><div class="public anchor" id="var-write-byte"><h3>write-byte</h3><div class="usage"><code>(write-byte segment value)</code><code>(write-byte segment offset value)</code></div><div class="doc"><div class="markdown"><p>Writes a <a href="null">byte</a> to the <code>segment</code>, at an optional <code>offset</code>.</p>
</div></div><div class="src-link"><a href="https://github.com/IGJoshua/coffi/blob/18fd49136364806c597d0420d20c2fe144a5cd45/src/clj/coffi/mem.clj#L460">view source</a></div></div><div class="public anchor" id="var-write-char"><h3>write-char</h3><div class="usage"><code>(write-char segment value)</code><code>(write-char segment offset value)</code></div><div class="doc"><div class="markdown"><p>Writes a <a href="null">char</a> to the <code>segment</code>, at an optional <code>offset</code>.</p>
</div></div><div class="src-link"><a href="https://github.com/IGJoshua/coffi/blob/18fd49136364806c597d0420d20c2fe144a5cd45/src/clj/coffi/mem.clj#L562">view source</a></div></div><div class="public anchor" id="var-write-double"><h3>write-double</h3><div class="usage"><code>(write-double segment value)</code><code>(write-double segment offset value)</code><code>(write-double segment offset byte-order value)</code></div><div class="doc"><div class="markdown"><p>Writes a <a href="null">double</a> to the <code>segment</code>, at an optional <code>offset</code>.</p>
</div></div><div class="src-link"><a href="https://github.com/IGJoshua/coffi/blob/58eaffdf543a3aa00436dafef2c65b247ad3f916/src/clj/coffi/mem.clj#L51">view source</a></div></div><div class="public anchor" id="var-short-alignment"><h3>short-alignment</h3><div class="usage"></div><div class="doc"><div class="markdown"><p>The alignment in bytes of a c-sized short.</p>
</div></div><div class="src-link"><a href="https://github.com/IGJoshua/coffi/blob/58eaffdf543a3aa00436dafef2c65b247ad3f916/src/clj/coffi/mem.clj#L261">view source</a></div></div><div class="public anchor" id="var-short-layout"><h3>short-layout</h3><div class="usage"></div><div class="doc"><div class="markdown"><p>The <a href="null">MemoryLayout</a> for a c-sized short in <a href="coffi.mem.html#var-native-endian">native-endian</a> <a href="null">ByteOrder</a>.</p>
</div></div><div class="src-link"><a href="https://github.com/IGJoshua/coffi/blob/58eaffdf543a3aa00436dafef2c65b247ad3f916/src/clj/coffi/mem.clj#L209">view source</a></div></div><div class="public anchor" id="var-short-size"><h3>short-size</h3><div class="usage"></div><div class="doc"><div class="markdown"><p>The size in bytes of a c-sized short.</p>
</div></div><div class="src-link"><a href="https://github.com/IGJoshua/coffi/blob/58eaffdf543a3aa00436dafef2c65b247ad3f916/src/clj/coffi/mem.clj#L237">view source</a></div></div><div class="public anchor" id="var-size-of"><h3>size-of</h3><div class="usage"><code>(size-of type)</code></div><div class="doc"><div class="markdown"><p>The size in bytes of the given <code>type</code>.</p>
</div></div><div class="src-link"><a href="https://github.com/IGJoshua/coffi/blob/58eaffdf543a3aa00436dafef2c65b247ad3f916/src/clj/coffi/mem.clj#L804">view source</a></div></div><div class="public anchor" id="var-slice"><h3>slice</h3><div class="usage"><code>(slice segment offset)</code><code>(slice segment offset size)</code></div><div class="doc"><div class="markdown"><p>Get a slice over the <code>segment</code> with the given <code>offset</code>.</p>
</div></div><div class="src-link"><a href="https://github.com/IGJoshua/coffi/blob/58eaffdf543a3aa00436dafef2c65b247ad3f916/src/clj/coffi/mem.clj#L131">view source</a></div></div><div class="public anchor" id="var-slice-segments"><h3>slice-segments</h3><div class="usage"><code>(slice-segments segment size)</code></div><div class="doc"><div class="markdown"><p>Constructs a lazy seq of <code>size</code>-length memory segments, sliced from <code>segment</code>.</p>
</div></div><div class="src-link"><a href="https://github.com/IGJoshua/coffi/blob/58eaffdf543a3aa00436dafef2c65b247ad3f916/src/clj/coffi/mem.clj#L180">view source</a></div></div><div class="public anchor" id="var-write-address"><h3>write-address</h3><div class="usage"><code>(write-address segment value)</code><code>(write-address segment offset value)</code></div><div class="doc"><div class="markdown"><p>Writes the address of the <a href="null">MemorySegment</a> <code>value</code> to the <code>segment</code>, at an optional <code>offset</code>.</p>
</div></div><div class="src-link"><a href="https://github.com/IGJoshua/coffi/blob/58eaffdf543a3aa00436dafef2c65b247ad3f916/src/clj/coffi/mem.clj#L640">view source</a></div></div><div class="public anchor" id="var-write-byte"><h3>write-byte</h3><div class="usage"><code>(write-byte segment value)</code><code>(write-byte segment offset value)</code></div><div class="doc"><div class="markdown"><p>Writes a <a href="null">byte</a> to the <code>segment</code>, at an optional <code>offset</code>.</p>
</div></div><div class="src-link"><a href="https://github.com/IGJoshua/coffi/blob/58eaffdf543a3aa00436dafef2c65b247ad3f916/src/clj/coffi/mem.clj#L458">view source</a></div></div><div class="public anchor" id="var-write-char"><h3>write-char</h3><div class="usage"><code>(write-char segment value)</code><code>(write-char segment offset value)</code></div><div class="doc"><div class="markdown"><p>Writes a <a href="null">char</a> to the <code>segment</code>, at an optional <code>offset</code>.</p>
</div></div><div class="src-link"><a href="https://github.com/IGJoshua/coffi/blob/58eaffdf543a3aa00436dafef2c65b247ad3f916/src/clj/coffi/mem.clj#L560">view source</a></div></div><div class="public anchor" id="var-write-double"><h3>write-double</h3><div class="usage"><code>(write-double segment value)</code><code>(write-double segment offset value)</code><code>(write-double segment offset byte-order value)</code></div><div class="doc"><div class="markdown"><p>Writes a <a href="null">double</a> to the <code>segment</code>, at an optional <code>offset</code>.</p>
<p>If <code>byte-order</code> is not provided, it defaults to <a href="coffi.mem.html#var-native-endian">native-endian</a>.</p>
</div></div><div class="src-link"><a href="https://github.com/IGJoshua/coffi/blob/18fd49136364806c597d0420d20c2fe144a5cd45/src/clj/coffi/mem.clj#L614">view source</a></div></div><div class="public anchor" id="var-write-float"><h3>write-float</h3><div class="usage"><code>(write-float segment value)</code><code>(write-float segment offset value)</code><code>(write-float segment offset byte-order value)</code></div><div class="doc"><div class="markdown"><p>Writes a <a href="null">float</a> to the <code>segment</code>, at an optional <code>offset</code>.</p>
</div></div><div class="src-link"><a href="https://github.com/IGJoshua/coffi/blob/58eaffdf543a3aa00436dafef2c65b247ad3f916/src/clj/coffi/mem.clj#L612">view source</a></div></div><div class="public anchor" id="var-write-float"><h3>write-float</h3><div class="usage"><code>(write-float segment value)</code><code>(write-float segment offset value)</code><code>(write-float segment offset byte-order value)</code></div><div class="doc"><div class="markdown"><p>Writes a <a href="null">float</a> to the <code>segment</code>, at an optional <code>offset</code>.</p>
<p>If <code>byte-order</code> is not provided, it defaults to <a href="coffi.mem.html#var-native-endian">native-endian</a>.</p>
</div></div><div class="src-link"><a href="https://github.com/IGJoshua/coffi/blob/18fd49136364806c597d0420d20c2fe144a5cd45/src/clj/coffi/mem.clj#L586">view source</a></div></div><div class="public anchor" id="var-write-int"><h3>write-int</h3><div class="usage"><code>(write-int segment value)</code><code>(write-int segment offset value)</code><code>(write-int segment offset byte-order value)</code></div><div class="doc"><div class="markdown"><p>Writes a <a href="null">int</a> to the <code>segment</code>, at an optional <code>offset</code>.</p>
</div></div><div class="src-link"><a href="https://github.com/IGJoshua/coffi/blob/58eaffdf543a3aa00436dafef2c65b247ad3f916/src/clj/coffi/mem.clj#L584">view source</a></div></div><div class="public anchor" id="var-write-int"><h3>write-int</h3><div class="usage"><code>(write-int segment value)</code><code>(write-int segment offset value)</code><code>(write-int segment offset byte-order value)</code></div><div class="doc"><div class="markdown"><p>Writes a <a href="null">int</a> to the <code>segment</code>, at an optional <code>offset</code>.</p>
<p>If <code>byte-order</code> is not provided, it defaults to <a href="coffi.mem.html#var-native-endian">native-endian</a>.</p>
</div></div><div class="src-link"><a href="https://github.com/IGJoshua/coffi/blob/18fd49136364806c597d0420d20c2fe144a5cd45/src/clj/coffi/mem.clj#L506">view source</a></div></div><div class="public anchor" id="var-write-long"><h3>write-long</h3><div class="usage"><code>(write-long segment value)</code><code>(write-long segment offset value)</code><code>(write-long segment offset byte-order value)</code></div><div class="doc"><div class="markdown"><p>Writes a <a href="null">long</a> to the <code>segment</code>, at an optional <code>offset</code>.</p>
</div></div><div class="src-link"><a href="https://github.com/IGJoshua/coffi/blob/58eaffdf543a3aa00436dafef2c65b247ad3f916/src/clj/coffi/mem.clj#L504">view source</a></div></div><div class="public anchor" id="var-write-long"><h3>write-long</h3><div class="usage"><code>(write-long segment value)</code><code>(write-long segment offset value)</code><code>(write-long segment offset byte-order value)</code></div><div class="doc"><div class="markdown"><p>Writes a <a href="null">long</a> to the <code>segment</code>, at an optional <code>offset</code>.</p>
<p>If <code>byte-order</code> is not provided, it defaults to <a href="coffi.mem.html#var-native-endian">native-endian</a>.</p>
</div></div><div class="src-link"><a href="https://github.com/IGJoshua/coffi/blob/18fd49136364806c597d0420d20c2fe144a5cd45/src/clj/coffi/mem.clj#L534">view source</a></div></div><div class="public anchor" id="var-write-short"><h3>write-short</h3><div class="usage"><code>(write-short segment value)</code><code>(write-short segment offset value)</code><code>(write-short segment offset byte-order value)</code></div><div class="doc"><div class="markdown"><p>Writes a <a href="null">short</a> to the <code>segment</code>, at an optional <code>offset</code>.</p>
</div></div><div class="src-link"><a href="https://github.com/IGJoshua/coffi/blob/58eaffdf543a3aa00436dafef2c65b247ad3f916/src/clj/coffi/mem.clj#L532">view source</a></div></div><div class="public anchor" id="var-write-short"><h3>write-short</h3><div class="usage"><code>(write-short segment value)</code><code>(write-short segment offset value)</code><code>(write-short segment offset byte-order value)</code></div><div class="doc"><div class="markdown"><p>Writes a <a href="null">short</a> to the <code>segment</code>, at an optional <code>offset</code>.</p>
<p>If <code>byte-order</code> is not provided, it defaults to <a href="coffi.mem.html#var-native-endian">native-endian</a>.</p>
</div></div><div class="src-link"><a href="https://github.com/IGJoshua/coffi/blob/18fd49136364806c597d0420d20c2fe144a5cd45/src/clj/coffi/mem.clj#L478">view source</a></div></div></div></body></html>
</div></div><div class="src-link"><a href="https://github.com/IGJoshua/coffi/blob/58eaffdf543a3aa00436dafef2c65b247ad3f916/src/clj/coffi/mem.clj#L476">view source</a></div></div></div></body></html>