diff options
author | Sven Gothel <[email protected]> | 2023-06-16 02:16:20 +0200 |
---|---|---|
committer | Sven Gothel <[email protected]> | 2023-06-16 02:16:20 +0200 |
commit | 8b127c4c1dd26fcb1756805ddb83729203161f78 (patch) | |
tree | f8563a0e39d293bc070ef01e457cfe08ee44096d /doc | |
parent | aeadfab9572e4b441b1bc1f0708cf4c72dfe181e (diff) |
GlueGen Struct [5]: Revised Struct Mapping + Documentation
GlueGen Revised Struct Mapping (esp pointer to array or single element), Struct String Charset, .. and Documentation
- Documentation:
- Added README.md
Let's have a proper face for the git repo
- Added doc/GlueGen_Mapping.md (and its html conversion doc/GlueGen_Mapping.html)
Created a new document covering application and implementation details suitable for users/devs.
- Added doc/JogAmpMacOSVersions.md conversion to doc/JogAmpMacOSVersions.html
- Updated www/index.html
- Use *CodeUnit instead of PrintWriter, representing a Java or C code unit covering a set of functions and structs.
The CCodeUnit also handles common code shared by its unit across functions etc.
- Dropping 'static initializer', as its no more required
due to simplified `JVMUtil_NewDirectByteBufferCopy()` variant.
- Revised Struct Mapping:
- Pure Java implementation to map primitive and struct fields within a struct
by utilizing ElementBuffer.
Only 'Function Pointer' fields within a struct require native code.
Exposes `static boolean usesNativeCode()` to query whether native code is used/required.
- Transparent native memory address API
Expose `long getDirectBufferAddress()` and `static TK_Struct derefPointer(long addr)`,
allowing to
- pass the native struct-pointer with native code
- reconstruct the struct from a native struct-pointer
- have a fully functional `TK_Struct.derefPointer(struct.getDirectBufferAddress())` cycle.
- Add 'boolean is<Val>Null() to query whether a pointer (array) is NULL
- *Changed* array get/set method for more flexibility alike `System.arraycopy(src, srcPos, dest, destPos, len)`,
where 'src' is being dropped for the getter and 'dest' is being dropped for the setter
as both objects are reflected by the struct instance.
- *Changed* `get<Val>ArrayLength()` -> `get<Val>ElemCount()` for clarity
- Considering all ConstElemCount values with config 'ReturnedArrayLength <int>'
to be owned by native code -> NativeOwnership -> Not changing the underlying memory region!
JavaOwnership is considered for all pointer-arrays not of NativeOwnership.
Hence any setter on a NativeOwnership pointer-array will fail with non-matching elem-count.
- Add 'release<Val>()' for JavaOwnership pointer-arrays,
allowing to release the Java owned native memory incl. null-ing pointer and set<Val>ElemCount(0).
- Support setter for 'const <type>*' w/ JavaOwnership, i.e. pointer to const value of a primitive or struct,
setter and getter using pointer to array or single element in general.
- Added Config `ImmutableAccess symbol` to disable all setter for whole struct or a field
- Added Config `MaxOneElement symbol` to restrict a pointer to maximum one element and unset
initial value (zero elements)
- Added Config `ReturnsStringOnly symbol` to restrict mapping only to a Java String,
dropping the ByteBuffer variant for 'char'
- String mapping default is UTF-8 and can be read and set via [get|set]Charset(..) per class.
- Dynamic string length retrieval in case no `ReturnedArrayLength` has been configured
has changed from `strlen()` to `strnlen(aptr, max_len)` to be on the safe site.
The maximum length default is 8192 bytes and can be read and set via [get|set]MaxStrnlen(..) per class.
FIXME: strnlen(..) using EOS byte non-functional for non 8-bit codecs like UTF-8, US-ASCII.
This is due to e.g. UTF-16 doesn't use an EOS byte, but interprets it as part of a code point.
- TODO: Perhaps a few more unit tests
- TODO: Allow plain 'int' to be mapped in structs IFF their size is same for all MachineDescriptions used.
Currently this is the case -> 4 bytes like int32_t.
Diffstat (limited to 'doc')
-rw-r--r-- | doc/GlueGen_Mapping.html | 1372 | ||||
-rw-r--r-- | doc/GlueGen_Mapping.md | 402 | ||||
-rw-r--r-- | doc/JogAmpMacOSVersions.html | 568 | ||||
-rw-r--r-- | doc/JogAmpMacOSVersions.md | 8 |
4 files changed, 2349 insertions, 1 deletions
diff --git a/doc/GlueGen_Mapping.html b/doc/GlueGen_Mapping.html new file mode 100644 index 0000000..537ce89 --- /dev/null +++ b/doc/GlueGen_Mapping.html @@ -0,0 +1,1372 @@ +<style> +div#header, header + { + + border-bottom: 1px solid #aaa; + margin-bottom: 0.5em; + } + +.title + { + text-align: center; + } + +.author, .date + { + text-align: center; + } + +div#TOC, nav#TOC + { + + border-bottom: 1px solid #aaa; + margin-bottom: 0.5em; + } + +nav#TOC { + margin-bottom: var(--line-height); + + padding-bottom: 0.5rem; +} + +nav#TOC input { + display: none; +} + +nav#TOC label { + color: var(--color-link); + cursor: pointer; +} + +nav#TOC > ul { + display: none; +} + +nav#TOC > input:checked + ul { + display: block; +} + +@media print + { + div#TOC, nav#TOC + { + + display: none; + } + } + +div.content + { + color: #111111; + font-size: 14px; + line-height: 1.6; + } + +div#cgit a + { + color: #1212a0; + } + +div#cgit a.sourceLine + { + color: #111111; + } + +h1, h2, h3, h4, h5, h6 +{ + font-family: "Helvetica Neue", Helvetica, "Liberation Sans", Calibri, Arial, sans-serif; + + page-break-after: avoid; + + margin: 20px 0 10px; + padding: 0; +} + +h2 { + border-bottom: 1px solid #ccc; +} + +div div + { + + } + +section section + { + margin-left: 2em; + } + +p {} + +blockquote + { + font-style: italic; + } + +li + { + } + +li > p + { + margin-top: 1em; + } + +ul + { + } + +ul li + { + } + +ol + { + } + +ol li + { + } + +hr {} + +sub + { + } + +sup + { + } + +em + { + } + +em > em + { + font-style: normal; + } + +strong + { + } + +a + { + + text-decoration: none; + } + +@media screen + { + a:hover + { + + text-decoration: underline; + } + } + +@media print + { + a { + + color: black; + background: transparent; + } + + a[href^="http://"]:after, a[href^="https://"]:after + { + + content: " (" attr(href) ") "; + font-size: 90%; + } + } + +img + { + + vertical-align: middle; + } + +div.figure + { + + margin-left: auto; + margin-right: auto; + text-align: center; + font-style: italic; + } + +p.caption + { + + } + +pre, code + { + background-color: #f8f8f8; + + white-space: pre-wrap; + white-space: -moz-pre-wrap !important; + white-space: -pre-wrap; + white-space: -o-pre-wrap; + word-wrap: break-word; + + } + +pre + { + + padding: 0.5em; + border-radius: 5px; + + background-color: #f8f8f8; + border: 1px solid #ccc; + font-size: 13px; + line-height: 19px; + overflow: auto; + padding: 6px 10px; + + margin-left: 0.5em; + margin-right: 0.5em; + } + +@media screen + { + pre + { + + white-space: pre; + overflow: auto; + + border: 1px dotted #777; + } + } + +code + { + } + +p > code, li > code + { + + padding-left: 2px; + padding-right: 2px; + } + +li > p code + { + + padding: 2px; + } + +span.math + { + + } + +div.math + { + } + +span.LaTeX + { + } + +eq + { + } + +table + { + border-collapse: collapse; + border-spacing: 0; + + margin-left: auto; + margin-right: auto; + } + +thead + { + border-bottom: 1pt solid #000; + background-color: #eee; + } + +tr.header + { + } + +tbody + { + } + +tr { + } +tr.odd:hover, tr.even:hover + { + background-color: #eee; + } + +tr.odd {} +tr.even {} + +td, th + { + vertical-align: top; + vertical-align: baseline; + padding-left: 0.5em; + padding-right: 0.5em; + padding-top: 0.2em; + padding-bottom: 0.2em; + } +th + { + font-weight: bold; + } + +tfoot + { + } + +caption + { + caption-side: top; + border: none; + font-size: 0.9em; + font-style: italic; + text-align: center; + margin-bottom: 0.3em; + padding-bottom: 0.2em; + } + +dl + { + border-top: 2pt solid black; + padding-top: 0.5em; + border-bottom: 2pt solid black; + } + +dt + { + font-weight: bold; + } + +dd+dt + { + border-top: 1pt solid black; + padding-top: 0.5em; + } + +dd + { + margin-bottom: 0.5em; + } + +dd+dd + { + border-top: 1px solid black; + } + +a.footnote, a.footnoteRef { + font-size: small; + vertical-align: text-top; +} + +a[href^="#fnref"], a.reversefootnote + { + } + +@media print + { + a[href^="#fnref"], a.reversefootnote + { + + display: none; + } + } + +div.footnotes + { + } + +div.footnotes li[id^="fn"] + { + } + +@media print + { + .noprint + { + display:none; + } + } +</style> + +<nav id="TOC" role="doc-toc"> + <strong>Contents</strong><label for="contents">⊕</label> + <input type="checkbox" id="contents"> + <ul> + <li><a href="#gluegen-native-data--function-mapping-for-java">GlueGen + Native Data & Function Mapping for Java™</a> + <ul> + <li><a href="#references">References</a></li> + <li><a href="#overview">Overview</a></li> + <li><a href="#primitive-mapping">Primitive Mapping</a> + <ul> + <li><a href="#string-mapping">String Mapping</a></li> + <li><a href="#alignment-for-compound-data">Alignment for Compound + Data</a></li> + </ul></li> + <li><a href="#struct-mapping">Struct Mapping</a> + <ul> + <li><a href="#gluegen-struct-settings">GlueGen Struct + Settings</a></li> + <li><a href="#struct-mapping-notes">Struct Mapping Notes</a></li> + <li><a href="#struct-java-signature-table">Struct Java Signature + Table</a></li> + <li><a href="#struct-setter-pseudo-code">Struct Setter + Pseudo-Code</a></li> + </ul></li> + <li><a href="#platform-header-files">Platform Header Files</a></li> + <li><a href="#pre-defined-macros">Pre-Defined Macros</a></li> + </ul></li> + </ul> +</nav> + +<style> +table, th, td { + border: 1px solid black; +} +</style> + +<h1 id="gluegen-native-data--function-mapping-for-java">GlueGen Native +Data & Function Mapping for Java™</h1> +<h2 id="references">References</h2> +<ul> +<li><a href="https://jogamp.org/cgit/gluegen.git/about/">GlueGen Git +Repo</a></li> +<li><a +href="https://jogamp.org/deployment/jogamp-next/javadoc/gluegen/javadoc/">GlueGen +Java™ API-Doc</a></li> +<li><a href="https://jogamp.org/gluegen/doc/manual/">GlueGen +Manual</a></li> +<li><a href="https://jogamp.org/gluegen/www/">GlueGen Project +Page</a></li> +<li><a href="https://jogamp.org/gluegen/doc/HowToBuild.html">How To +Build</a></li> +</ul> +<h2 id="overview">Overview</h2> +<p><a href="https://jogamp.org/gluegen/www/">GlueGen</a> is a compiler +for function and data-structure declarations, generating Java and JNI C +code offline at compile time and allows using native libraries within +your Java application.</p> +<p>It reads ANSI C header files and separate configuration files which +provide control over many aspects of the glue code generation. GlueGen +uses a complete ANSI C parser and an internal representation (IR) +capable of representing all C types to represent the APIs for which it +generates interfaces. It has the ability to perform significant +transformations on the IR before glue code emission.</p> +<p>GlueGen can produce native foreign function bindings to Java as well +as map native data structures to be fully accessible from Java including +potential calls to embedded function pointer.</p> +<p>GlueGen is also capable to bind even low-level APIs such as the Java +Native Interface (JNI) and the AWT Native Interface (JAWT) back up to +the Java programming language.</p> +<p>GlueGen utilizes <a +href="https://jogamp.org/cgit/jcpp.git/about/">JCPP</a>, migrated C +preprocessor written in Java.</p> +<p>GlueGen is used for the <a href="https://jogamp.org">JogAmp</a> +projects <a href="https://jogamp.org/cgit/joal.git/about/">JOAL</a>, <a +href="https://jogamp.org/cgit/jogl.git/about/">JOGL</a> and <a +href="https://jogamp.org/cgit/jocl.git/">JOCL</a>.</p> +<p>GlueGen is part of <a href="https://jogamp.org">the JogAmp +project</a>.</p> +<h2 id="primitive-mapping">Primitive Mapping</h2> +<p>Gluegen has build-in types (terminal symbols) for:</p> +<table> +<thead> +<tr class="header"> +<th style="text-align: left;">type</th> +<th style="text-align: left;">java-bits</th> +<th style="text-align: left;">native-bits <br> x32</th> +<th style="text-align: left;">native bits <br> x64</th> +<th style="text-align: left;">type</th> +<th style="text-align: left;">signed</th> +<th style="text-align: left;">origin</th> +</tr> +</thead> +<tbody> +<tr class="odd"> +<td style="text-align: left;">void</td> +<td style="text-align: left;">0</td> +<td style="text-align: left;">0</td> +<td style="text-align: left;">0</td> +<td style="text-align: left;">void</td> +<td style="text-align: left;">void</td> +<td style="text-align: left;">ANSI-C</td> +</tr> +<tr class="even"> +<td style="text-align: left;">char</td> +<td style="text-align: left;">8</td> +<td style="text-align: left;">8</td> +<td style="text-align: left;">8</td> +<td style="text-align: left;">integer</td> +<td style="text-align: left;">any</td> +<td style="text-align: left;">ANSI-C</td> +</tr> +<tr class="odd"> +<td style="text-align: left;">short</td> +<td style="text-align: left;">16</td> +<td style="text-align: left;">16</td> +<td style="text-align: left;">16</td> +<td style="text-align: left;">integer</td> +<td style="text-align: left;">any</td> +<td style="text-align: left;">ANSI-C</td> +</tr> +<tr class="even"> +<td style="text-align: left;">int</td> +<td style="text-align: left;">32</td> +<td style="text-align: left;">32</td> +<td style="text-align: left;">32</td> +<td style="text-align: left;">integer</td> +<td style="text-align: left;">any</td> +<td style="text-align: left;">ANSI-C</td> +</tr> +<tr class="odd"> +<td style="text-align: left;">long</td> +<td style="text-align: left;">64</td> +<td style="text-align: left;">32</td> +<td style="text-align: left;"><strong>32</strong>†</td> +<td style="text-align: left;">integer</td> +<td style="text-align: left;">any</td> +<td style="text-align: left;">ANSI-C - Windows</td> +</tr> +<tr class="even"> +<td style="text-align: left;">long</td> +<td style="text-align: left;">64</td> +<td style="text-align: left;">32</td> +<td style="text-align: left;"><strong>64</strong></td> +<td style="text-align: left;">integer</td> +<td style="text-align: left;">any</td> +<td style="text-align: left;">ANSI-C - Unix</td> +</tr> +<tr class="odd"> +<td style="text-align: left;">float</td> +<td style="text-align: left;">32</td> +<td style="text-align: left;">32</td> +<td style="text-align: left;">32</td> +<td style="text-align: left;">float</td> +<td style="text-align: left;">signed</td> +<td style="text-align: left;">ANSI-C</td> +</tr> +<tr class="even"> +<td style="text-align: left;">double</td> +<td style="text-align: left;">64</td> +<td style="text-align: left;">64</td> +<td style="text-align: left;">64</td> +<td style="text-align: left;">double</td> +<td style="text-align: left;">signed</td> +<td style="text-align: left;">ANSI-C</td> +</tr> +<tr class="odd"> +<td style="text-align: left;">__int32</td> +<td style="text-align: left;">32</td> +<td style="text-align: left;">32</td> +<td style="text-align: left;">32</td> +<td style="text-align: left;">integer</td> +<td style="text-align: left;">any</td> +<td style="text-align: left;">windows</td> +</tr> +<tr class="even"> +<td style="text-align: left;">__int64</td> +<td style="text-align: left;">64</td> +<td style="text-align: left;">64</td> +<td style="text-align: left;">64</td> +<td style="text-align: left;">integer</td> +<td style="text-align: left;">any</td> +<td style="text-align: left;">windows</td> +</tr> +<tr class="odd"> +<td style="text-align: left;">int8_t</td> +<td style="text-align: left;">8</td> +<td style="text-align: left;">8</td> +<td style="text-align: left;">8</td> +<td style="text-align: left;">integer</td> +<td style="text-align: left;">signed</td> +<td style="text-align: left;">stdint.h</td> +</tr> +<tr class="even"> +<td style="text-align: left;">uint8_t</td> +<td style="text-align: left;">8</td> +<td style="text-align: left;">8</td> +<td style="text-align: left;">8</td> +<td style="text-align: left;">integer</td> +<td style="text-align: left;">unsigned</td> +<td style="text-align: left;">stdint.h</td> +</tr> +<tr class="odd"> +<td style="text-align: left;">int16_t</td> +<td style="text-align: left;">16</td> +<td style="text-align: left;">16</td> +<td style="text-align: left;">16</td> +<td style="text-align: left;">integer</td> +<td style="text-align: left;">signed</td> +<td style="text-align: left;">stdint.h</td> +</tr> +<tr class="even"> +<td style="text-align: left;">uint16_t</td> +<td style="text-align: left;">16</td> +<td style="text-align: left;">16</td> +<td style="text-align: left;">16</td> +<td style="text-align: left;">integer</td> +<td style="text-align: left;">unsigned</td> +<td style="text-align: left;">stdint.h</td> +</tr> +<tr class="odd"> +<td style="text-align: left;">int32_t</td> +<td style="text-align: left;">32</td> +<td style="text-align: left;">32</td> +<td style="text-align: left;">32</td> +<td style="text-align: left;">integer</td> +<td style="text-align: left;">signed</td> +<td style="text-align: left;">stdint.h</td> +</tr> +<tr class="even"> +<td style="text-align: left;">uint32_t</td> +<td style="text-align: left;">32</td> +<td style="text-align: left;">32</td> +<td style="text-align: left;">32</td> +<td style="text-align: left;">integer</td> +<td style="text-align: left;">unsigned</td> +<td style="text-align: left;">stdint.h</td> +</tr> +<tr class="odd"> +<td style="text-align: left;">int64_t</td> +<td style="text-align: left;">64</td> +<td style="text-align: left;">64</td> +<td style="text-align: left;">64</td> +<td style="text-align: left;">integer</td> +<td style="text-align: left;">signed</td> +<td style="text-align: left;">stdint.h</td> +</tr> +<tr class="even"> +<td style="text-align: left;">uint64_t</td> +<td style="text-align: left;">64</td> +<td style="text-align: left;">64</td> +<td style="text-align: left;">64</td> +<td style="text-align: left;">integer</td> +<td style="text-align: left;">unsigned</td> +<td style="text-align: left;">stdint.h</td> +</tr> +<tr class="odd"> +<td style="text-align: left;">intptr_t</td> +<td style="text-align: left;">64</td> +<td style="text-align: left;">32</td> +<td style="text-align: left;">64</td> +<td style="text-align: left;">integer</td> +<td style="text-align: left;">signed</td> +<td style="text-align: left;">stdint.h</td> +</tr> +<tr class="even"> +<td style="text-align: left;">uintptr_t</td> +<td style="text-align: left;">64</td> +<td style="text-align: left;">32</td> +<td style="text-align: left;">64</td> +<td style="text-align: left;">integer</td> +<td style="text-align: left;">unsigned</td> +<td style="text-align: left;">stdint.h</td> +</tr> +<tr class="odd"> +<td style="text-align: left;">ptrdiff_t</td> +<td style="text-align: left;">64</td> +<td style="text-align: left;">32</td> +<td style="text-align: left;">64</td> +<td style="text-align: left;">integer</td> +<td style="text-align: left;">signed</td> +<td style="text-align: left;">stddef.h</td> +</tr> +<tr class="even"> +<td style="text-align: left;">size_t</td> +<td style="text-align: left;">64</td> +<td style="text-align: left;">32</td> +<td style="text-align: left;">64</td> +<td style="text-align: left;">integer</td> +<td style="text-align: left;">unsigned</td> +<td style="text-align: left;">stddef.h</td> +</tr> +<tr class="odd"> +<td style="text-align: left;">wchar_t</td> +<td style="text-align: left;">32</td> +<td style="text-align: left;">32</td> +<td style="text-align: left;">32</td> +<td style="text-align: left;">integer</td> +<td style="text-align: left;">signed</td> +<td style="text-align: left;">stddef.h</td> +</tr> +</tbody> +</table> +<p><strong>Warning:</strong> Try to avoid unspecified bit sized types, +especially <strong>long</strong>, since it differs on Unix and +Windows!<br /> +<strong>Notes:</strong></p> +<ul> +<li>† Type <strong>long</strong> will result in broken code on Windows, +since we don't differentiate the OS and it's bit size is ambiguous.</li> +<li>Anonymous void-pointer <em>void*</em> are mapped to NIO +<em>Buffer</em>.</li> +<li>Pointers to pointer-size types like <em>intptr_t*</em>, +<em>uintptr_t*</em>, <em>ptrdiff_t*</em> and <em>size_t*</em> are mapped +to <em>PointerBuffer</em>, to reflect the architecture depending storage +size.</li> +</ul> +<h3 id="string-mapping">String Mapping</h3> +<h4 id="function-return-string-values">Function return String +values</h4> +<p>Function return values are currently mapped from <code>char*</code> +to Java String using <em>UTF-8</em> via JNI function</p> +<blockquote> +<p><code>jstring NewStringUTF(JNIEnv *env, const char *bytes)</code></p> +</blockquote> +<p><em>FIXME</em>: This might need more flexibility in case UTF-8 is not +suitable for 8-bit wide <code>char</code> mappings or wide characters, +e.g. for UTF-16 needs to be supported.</p> +<h4 id="function-argument-string-values">Function argument String +values</h4> +<p>Function argument values are either mapped from <code>char*</code> to +Java String using <em>UTF-8</em> via JNI function</p> +<blockquote> +<p><code>const char * GetStringUTFChars(JNIEnv *env, jstring string, jboolean *isCopy)</code>.</p> +</blockquote> +<p>Alternatively, if a 16-bit wide <em>character</em> type has been +detected, i.e. <em>short</em>, the native <em>character</em> are mapped +to Java using <em>UTF-16</em> via JNI function</p> +<blockquote> +<p><code>void GetStringRegion(JNIEnv *env, jstring str, jsize start, jsize len, jchar *buf)</code>.</p> +</blockquote> +<h4 id="struct-string-mapping">Struct String mapping</h4> +<p>String value mapping for <code>Struct</code> fields is performed +solely from the Java side using <em>Charset</em> and is hence most +flexible.</p> +<p>By default, <em>UTF-8</em> is being used for getter and setter of +String values.<br /> +The <em>Struct</em> class provides two methods to get and set the used +<em>Charset</em> for conversion</p> +<pre><code> /** Returns the Charset for this class's String mapping, default is StandardCharsets.UTF_8. */ + public static Charset getCharset() { return _charset; }; + + /** Sets the Charset for this class's String mapping, default is StandardCharsets.UTF_8. */ + public static void setCharset(Charset cs) { _charset = cs; } +</code></pre> +<p>In case the String length has not been configured via +<code>ReturnedArrayLength</code>, it will be dynamically calculated via +<code>strnlen(aptr, max_len)</code>.<br /> +The maximum length default for the <code>strnlen(..)</code> operation is +8192 bytes and can be get and set using:</p> +<pre><code> /** Returns the maximum number of bytes to read to determine native string length using `strnlen(..)`, default is 8192. */ + public static int getMaxStrnlen() { return _max_strnlen; }; + + /** Sets the maximum number of bytes to read to determine native string length using `strnlen(..)`, default is 8192. */ + public static void setMaxStrnlen(int v) { _max_strnlen = v; }</code></pre> +<p><em>FIXME</em>: This only works reliable using an 8-bit Charset +encoding, e.g. the default <em>UTF-8</em>.</p> +<h3 id="alignment-for-compound-data">Alignment for Compound Data</h3> +<p>In general, depending on CPU and it's configuration (OS), alignment +is set up for each type (char, short, int, long, ..).</p> +<p>Compounds (structures) are aligned naturally, i.e. their inner +components are aligned<br /> +and are itself aligned to it's largest element.</p> +<p>See:</p> +<ul> +<li><a +href="http://en.wikipedia.org/wiki/Data_structure_alignment">Wikipedia +Data Structure Alignment</a></li> +<li><a +href="http://en.wikipedia.org/wiki/Data_structure_alignment#Data_structure_padding">Wikipedia +Data Structure Alignment - Padding</a></li> +<li><a href="http://www.viva64.com/en/l/0021/">Viva64 Data +Alignment</a></li> +<li><a +href="http://developer.apple.com/library/mac/#documentation/Darwin/Conceptual/64bitPorting/transition/transition.html#//apple_ref/doc/uid/TP40001064-CH207-SW1">Apple: +Darwin 64bit Porting - Data Type Size & Alignment</a></li> +</ul> +<h4 id="simple-alignment-arithmetic">Simple alignment arithmetic</h4> +<p>Modulo operation, where the 2nd handles the case offset == +alignment:</p> +<blockquote> +<p>padding = ( alignment - ( offset % alignment ) ) % alignment ;<br /> +aligned_offset = offset + padding ;</p> +</blockquote> +<p>Optimization utilizing alignment as a multiple of 2 +<code>-> x % 2n == x & ( 2n - 1 )</code></p> +<blockquote> +<p>remainder = offset & ( alignment - 1 ) ;<br /> +padding = ( remainder > 0 ) ? alignment - remainder : 0 ;<br /> +aligned_offset = offset + padding ;</p> +</blockquote> +<p>Without branching, using the 2nd modulo operation for the case offset +== alignment:</p> +<blockquote> +<p>padding = ( alignment - ( offset & ( alignment - 1 ) ) ) & ( +alignment - 1 ) ;<br /> +aligned_offset = offset + padding ;</p> +</blockquote> +<p>See +<code>com.jogamp.gluegen.cgram.types.SizeThunk.align(..)</code>.</p> +<h4 +id="type-size--alignment-for-x86-x86_64-armv6l-32bit-eabi-and-windowmingwmingw64">Type +Size & Alignment for x86, x86_64, armv6l-32bit-eabi and +Window(mingw/mingw64)</h4> +<p>Runtime query is implemented as follows:</p> +<pre><code> typedef struct { + char fill; // nibble one byte + // padding to align s1: padding_0 + type_t s1; // + } test_struct_type_t; + + padding_0 = sizeof(test_struct_type_t) - sizeof(type_t) - sizeof(char) ; + alignmentOf(type_t) = sizeof(test_struct_type_t) - sizeof(type_t) ;</code></pre> +<table> +<thead> +<tr class="header"> +<th style="text-align: left;">type</th> +<th style="text-align: left;">size <br> <em>32 bit</em></th> +<th style="text-align: left;">alignment <br> <em>32 bit</em></th> +<th style="text-align: left;">size <br> <em>64 bit</em></th> +<th style="text-align: left;">alignment <br> <em>64 bit</em></th> +</tr> +</thead> +<tbody> +<tr class="odd"> +<td style="text-align: left;">char</td> +<td style="text-align: left;">1</td> +<td style="text-align: left;">1</td> +<td style="text-align: left;">1</td> +<td style="text-align: left;">1</td> +</tr> +<tr class="even"> +<td style="text-align: left;">short</td> +<td style="text-align: left;">2</td> +<td style="text-align: left;">2</td> +<td style="text-align: left;">2</td> +<td style="text-align: left;">2</td> +</tr> +<tr class="odd"> +<td style="text-align: left;">int</td> +<td style="text-align: left;">4</td> +<td style="text-align: left;">4</td> +<td style="text-align: left;">4</td> +<td style="text-align: left;">4</td> +</tr> +<tr class="even"> +<td style="text-align: left;">float</td> +<td style="text-align: left;">4</td> +<td style="text-align: left;">4</td> +<td style="text-align: left;">4</td> +<td style="text-align: left;">4</td> +</tr> +<tr class="odd"> +<td style="text-align: left;">long</td> +<td style="text-align: left;">4</td> +<td style="text-align: left;">4</td> +<td style="text-align: left;">8†,4∗</td> +<td style="text-align: left;">8†,4∗</td> +</tr> +<tr class="even"> +<td style="text-align: left;">pointer</td> +<td style="text-align: left;">4</td> +<td style="text-align: left;">4</td> +<td style="text-align: left;">8</td> +<td style="text-align: left;">8</td> +</tr> +<tr class="odd"> +<td style="text-align: left;">long long</td> +<td style="text-align: left;">8</td> +<td style="text-align: left;">4†,8∗+</td> +<td style="text-align: left;">8</td> +<td style="text-align: left;">8</td> +</tr> +<tr class="even"> +<td style="text-align: left;">double</td> +<td style="text-align: left;">8</td> +<td style="text-align: left;">4†,8∗+</td> +<td style="text-align: left;">8</td> +<td style="text-align: left;">8</td> +</tr> +<tr class="odd"> +<td style="text-align: left;">long double</td> +<td style="text-align: left;">12†∗,8+,16-</td> +<td style="text-align: left;">4†∗,8+,16-</td> +<td style="text-align: left;">16</td> +<td style="text-align: left;">16</td> +</tr> +</tbody> +</table> +<p>† Linux, Darwin<br /> ++armv7l-eabi<br /> +- MacOsX-32bit-gcc4<br /> +∗ Windows</p> +<h2 id="struct-mapping">Struct Mapping</h2> +<p>A <em>Struct</em> is a C compound type declaration, which can be +mapped to a Java class.</p> +<p>A <em>Struct</em> may utilize the following data types for its +fields</p> +<ul> +<li><em>Primitive</em>, i.e. <em>char</em>, <em>int32_t</em>, ... +<ul> +<li>See <a href="#primitive-mapping"><em>Primitive Mapping</em></a> +above.</li> +<li>See <a href="#string-mapping"><em>String Mapping</em></a> +above.</li> +</ul></li> +<li><em>Struct</em>, i.e. another compound variable</li> +<li><em>Function Pointer</em>, a <em>typedef</em>'ed and set callable +function pointer</li> +</ul> +<p>A field may be a direct aggregation, i.e. instance, within the struct +including an array or a reference to a single element or array via a +pointer.</p> +<p>Both, <em>primitive</em> and <em>struct</em> field type mappings only +produce pure Java code, utilizing the <em>GlueGen Runtime</em>. Hence no +additional native code must be compiled nor a resulting additional +library loaded to use the mapping.</p> +<p>Only when mapping <em>function-pointer</em> within <em>structs</em>, +additional native glue-code is produced to call the underlying native +function which has to be compiled and its library loaded.</p> +<p>The generated method +<code>public static boolean usesNativeCode()</code> can be used to +validate whether the produced Java class requires a corresponding +library for additional native code.</p> +<h3 id="gluegen-struct-settings">GlueGen Struct Settings</h3> +<h4 id="immutableaccess-symbol"><strong>ImmutableAccess</strong> +<em>symbol</em></h4> +<p>Immutable access can be set for a whole struct or a single field of a +struct.</p> +<p>Immutable access will simply suppress generating setters in the Java +code and hence also reduces the footprint of the generated Java class +for such struct.</p> +<ul> +<li><p><code>ImmutableAccess TK_Struct</code></p> +<p>Immutable access for the whole struct `TK_Struct</p> +<p>Sets pseudo-code flag <em>ImmutableAccess</em>, see below.</p></li> +<li><p><code>ImmutableAccess TK_Struct.val</code></p> +<p>Immutable access for the single field <code>val</code> within struct +<code>TK_Struct</code></p> +<p>Sets pseudo-code flag <em>ImmutableAccess</em>, see below.</p></li> +</ul> +<h4 id="maxoneelement-symbol"><strong>MaxOneElement</strong> +<em>symbol</em></h4> +<ul> +<li><p><code>MaxOneElement TK_Struct.val</code></p> +<p>Sets field pointer <code>val</code> to point to a array with a +maximum of one element and unset initial value (zero elements).</p> +<p>Sets pseudo-code flag <em>MaxOneElement</em>, see below.</p></li> +</ul> +<h4 +id="returnedarraylength-symbol-expression"><strong>ReturnedArrayLength</strong> +<em>symbol</em> <em>expression</em></h4> +<ul> +<li><p><code>ReturnedArrayLength TK_Struct.val 3</code></p> +<p>Sets field pointer <code>val</code> to point to a array with three +elements.</p> +<p>Sets pseudo-code flag <em>ConstElemCount</em>, see below.</p> +<p>Having set <em>ConstElemCount</em> also implies <em>native +ownership</em> for a <em>Pointer</em> referenced <em>native</em> +memory.</p></li> +<li><p><code>ReturnedArrayLength TK_Struct.val 1</code></p> +<p>Sets field pointer <code>val</code> to point to a array with one +element.</p> +<p>Sets pseudo-code flags <em>ConstElemCount</em> and +<em>MaxOneElement</em>, see below.</p> +<p>Having set <em>ConstElemCount</em> also implies <em>native +ownership</em> for a <em>Pointer</em> referenced <em>native</em> +memory.</p></li> +<li><p><code>ReturnedArrayLength TK_Struct.val getValElements()</code></p> +<p>Sets field pointer <code>val</code> to point to a array with a +variable length as described by the field <code>valElements</code> +retrievable via its getter <code>getValElements()</code>.</p> +<p>Sets pseudo-code flag <em>VariaElemCount</em>, see below.</p></li> +</ul> +<h4 id="returnsstring-symbol"><strong>ReturnsString</strong> +<em>symbol</em></h4> +<p>A direct C code <code>char</code> array or indirect array via pointer +can be interpreted as a Java <code>String</code>.</p> +<ul> +<li><p><code>ReturnsString TK_Struct.name</code></p> +<p>Sets field char-array or char-pointer <code>name</code> to be +additionally interpreted as a Java <code>String</code>. Besides the +<code>byte[]</code> and <code>ByteBuffer</code> getter and setter +variants, a <code>String</code> variant will be added.</p> +<p>Sets pseudo-code flags <em>String</em>, see below.</p> +<p>See <a href="#string-mapping"><em>String Mapping</em></a> +above.</p></li> +</ul> +<h4 id="returnsstringonly-symbol"><strong>ReturnsStringOnly</strong> +<em>symbol</em></h4> +<ul> +<li><p><code>ReturnsStringOnly TK_Struct.name</code></p> +<p>Sets field char-array or char-pointer <code>name</code> to be +exclusively interpreted as a Java <code>String</code>. Instead of the +<code>byte[]</code> and <code>ByteBuffer</code> getter and setter +variants, a <code>String</code> variant will be produced.</p> +<p>Sets pseudo-code flags <em>StringOnly</em>, see below.</p> +<p>See <a href="#string-mapping"><em>String Mapping</em></a> +above.</p></li> +</ul> +<h3 id="struct-mapping-notes">Struct Mapping Notes</h3> +<ul> +<li><p><em>ConstElemCount</em> via <strong>ReturnedArrayLength +<int></strong> implies <em>native ownership</em> for a +<em>Pointer</em> referenced <em>native</em> memory if the expression is +constant. Otherwise the <em>native</em> memory has <em>java +ownership</em>. See <a +href="#returnedarraylength-symbol-expression">ReturnedArrayLength +Setting</a> above.</p></li> +<li><p>To release native memory with <em>java ownership</em>, i.e. a +native ByteBuffer, <code>releaseVal()</code> can be used.</p></li> +<li><p>To shrink a <em>Pointer</em> & <em>VariaElemCount</em> +pointer-array elemCount size with <em>java ownership</em> , the memory +must be cleared with <code>releaseVal()</code> first. This is due to +<code>setVal(src, srcPos, destPos, len)</code> reusing the existing +memory in case <code>destPos + len < elemCount</code>.</p></li> +</ul> +<h3 id="struct-java-signature-table">Struct Java Signature Table</h3> +<p>Please find below signature table as generated by the <em>C +Declaration</em> including its <em>C Modifier</em>, e.g. +<code>const</code> for constant, <code>[const]</code> for const and +non-const and <code>empty</code> for non-const (variable).</p> +<p>Further, the <em>GlueGen Setting</em> (see above) impacts the code +generation as well.</p> +<p>Below table demonstrates <em>primitive</em> types being mapped within +a <code>struct</code> named <code>TK_Struct</code>. A similar mapping is +produced for <code>struct</code> types, i.e. <em>compounds</em>.</p> +<table> +<thead> +<tr class="header"> +<th style="text-align: left;">C Mod</th> +<th style="text-align: left;">C Declaration</th> +<th style="text-align: left;">Java Setter</th> +<th style="text-align: left;">Java Getter</th> +<th style="text-align: left;">GlueGen Setting</th> +<th style="text-align: left;">Ownership</th> +<th style="text-align: left;">Remarks</th> +</tr> +</thead> +<tbody> +<tr class="odd"> +<td style="text-align: left;"></td> +<td style="text-align: left;"></td> +<td style="text-align: left;"></td> +<td style="text-align: left;">static boolean usesNativeCode()</td> +<td style="text-align: left;"></td> +<td style="text-align: left;"></td> +<td style="text-align: left;">Java, static, <br> <em>true</em> if using +native code</td> +</tr> +<tr class="even"> +<td style="text-align: left;"></td> +<td style="text-align: left;"></td> +<td style="text-align: left;"></td> +<td style="text-align: left;">static int size()</td> +<td style="text-align: left;"></td> +<td style="text-align: left;"></td> +<td style="text-align: left;">Java, static, <br> native size in +bytes</td> +</tr> +<tr class="odd"> +<td style="text-align: left;"></td> +<td style="text-align: left;"></td> +<td style="text-align: left;"></td> +<td style="text-align: left;">static TK_Struct create()</td> +<td style="text-align: left;"></td> +<td style="text-align: left;"></td> +<td style="text-align: left;">Java, static ctor</td> +</tr> +<tr class="even"> +<td style="text-align: left;"></td> +<td style="text-align: left;"></td> +<td style="text-align: left;"></td> +<td style="text-align: left;">static TK_Struct create(ByteBuffer)</td> +<td style="text-align: left;"></td> +<td style="text-align: left;"></td> +<td style="text-align: left;">Java, static ctor <br> w/ existing +ByteBuffer</td> +</tr> +<tr class="odd"> +<td style="text-align: left;"></td> +<td style="text-align: left;"></td> +<td style="text-align: left;"></td> +<td style="text-align: left;">static TK_Struct derefPointer(long +addr)</td> +<td style="text-align: left;"></td> +<td style="text-align: left;"></td> +<td style="text-align: left;">Java, static ctor <br> dereferencing +ByteBuffer <br> at native address of size()</td> +</tr> +<tr class="even"> +<td style="text-align: left;"></td> +<td style="text-align: left;"></td> +<td style="text-align: left;"></td> +<td style="text-align: left;">ByteBuffer getBuffer()</td> +<td style="text-align: left;"></td> +<td style="text-align: left;"></td> +<td style="text-align: left;">Java, <br> underlying ByteBuffer</td> +</tr> +<tr class="odd"> +<td style="text-align: left;"></td> +<td style="text-align: left;"></td> +<td style="text-align: left;"></td> +<td style="text-align: left;">long getDirectBufferAddress()</td> +<td style="text-align: left;"></td> +<td style="text-align: left;"></td> +<td style="text-align: left;">Java, native address <br> of underlying +getBuffer()</td> +</tr> +<tr class="even"> +<td style="text-align: left;"></td> +<td style="text-align: left;">int32_t val</td> +<td style="text-align: left;">setVal(int v)</td> +<td style="text-align: left;">int getVal()</td> +<td style="text-align: left;"></td> +<td style="text-align: left;">Static</td> +<td style="text-align: left;"></td> +</tr> +<tr class="odd"> +<td style="text-align: left;">const</td> +<td style="text-align: left;">int32_t val</td> +<td style="text-align: left;"><em>none</em></td> +<td style="text-align: left;">int getVal()</td> +<td style="text-align: left;"></td> +<td style="text-align: left;">Static</td> +<td style="text-align: left;">Read only</td> +</tr> +<tr class="even"> +<td style="text-align: left;"></td> +<td style="text-align: left;">int32_t val</td> +<td style="text-align: left;"><em>none</em></td> +<td style="text-align: left;">int getVal()</td> +<td style="text-align: left;"><strong>ImmutableAccess</strong></td> +<td style="text-align: left;">Static</td> +<td style="text-align: left;">Read only</td> +</tr> +<tr class="odd"> +<td style="text-align: left;">[const]</td> +<td style="text-align: left;">int32_t* val</td> +<td style="text-align: left;">setVal(int v) <br> releaseVal()</td> +<td style="text-align: left;">int getVal() <br> boolean isValNull() <br> +int getValElemCount()</td> +<td style="text-align: left;"><strong>MaxOneElement</strong></td> +<td style="text-align: left;">Java</td> +<td style="text-align: left;">Starts w/ null elements,<br>max 1 +element</td> +</tr> +<tr class="even"> +<td style="text-align: left;">const</td> +<td style="text-align: left;">int32_t* val</td> +<td style="text-align: left;"><em>none</em></td> +<td style="text-align: left;">int getVal() <br> boolean isValNull() <br> +static int getValElemCount()</td> +<td style="text-align: left;"><strong>ReturnedArrayLength +1</strong></td> +<td style="text-align: left;">Native</td> +<td style="text-align: left;">Const element count 1</td> +</tr> +<tr class="odd"> +<td style="text-align: left;"></td> +<td style="text-align: left;">int32_t* val</td> +<td style="text-align: left;">setVal(int v)</td> +<td style="text-align: left;">int getVal() <br> boolean isValNull() <br> +static int getValElemCount()</td> +<td style="text-align: left;"><strong>ReturnedArrayLength +1</strong></td> +<td style="text-align: left;">Native</td> +<td style="text-align: left;">Const element count 1</td> +</tr> +<tr class="even"> +<td style="text-align: left;"></td> +<td style="text-align: left;">int32_t val[3]</td> +<td style="text-align: left;">setVal(int[] src, int srcPos, int destPos, +int len)</td> +<td style="text-align: left;">IntBuffer getVal() <br> int[] getVal(int +srcPos, int[] dest, int destPos, int len)</td> +<td style="text-align: left;"></td> +<td style="text-align: left;">Static</td> +<td style="text-align: left;"></td> +</tr> +<tr class="odd"> +<td style="text-align: left;">const</td> +<td style="text-align: left;">int32_t val[3]</td> +<td style="text-align: left;"><em>none</em></td> +<td style="text-align: left;">IntBuffer getVal() <br> int[] getVal(int +srcPos, int[] dest, int destPos, int len)</td> +<td style="text-align: left;"></td> +<td style="text-align: left;">Static</td> +<td style="text-align: left;">Read only</td> +</tr> +<tr class="even"> +<td style="text-align: left;">const</td> +<td style="text-align: left;">int32_t* val</td> +<td style="text-align: left;"><em>none</em></td> +<td style="text-align: left;">IntBuffer getVal() <br> int[] getVal(int +srcPos, int[] dest, int destPos, int len) <br> boolean isValNull() <br> +static int getValElemCount()</td> +<td style="text-align: left;"><strong>ReturnedArrayLength +3</strong></td> +<td style="text-align: left;">Native</td> +<td style="text-align: left;">Read only <br> Const element count 3</td> +</tr> +<tr class="odd"> +<td style="text-align: left;"></td> +<td style="text-align: left;">int32_t* val</td> +<td style="text-align: left;">setVal(int[] src, int srcPos, int destPos, +int len)</td> +<td style="text-align: left;">IntBuffer getVal() <br> int[] getVal(int +srcPos, int[] dest, int destPos, int len) <br> boolean isValNull() <br> +static int getValElemCount()</td> +<td style="text-align: left;"><strong>ReturnedArrayLength +3</strong></td> +<td style="text-align: left;">Native</td> +<td style="text-align: left;">Const element count 3</td> +</tr> +<tr class="even"> +<td style="text-align: left;">[const]</td> +<td style="text-align: left;">int32_t* val</td> +<td style="text-align: left;">setVal(int[] src, int srcPos, int destPos, +int len) <br> releaseVal()</td> +<td style="text-align: left;">IntBuffer getVal() <br> int[] getVal(int +srcPos, int[] dest, int destPos, int len) <br> boolean isValNull() <br> +int getValElemCount()</td> +<td style="text-align: left;"></td> +<td style="text-align: left;">Java</td> +<td style="text-align: left;">Starts w/ null elements</td> +</tr> +<tr class="odd"> +<td style="text-align: left;">[const]</td> +<td style="text-align: left;">int32_t* val</td> +<td style="text-align: left;">setVal(int[] src, int srcPos, int destPos, +int len) <br> releaseVal()</td> +<td style="text-align: left;">IntBuffer getVal() <br> int[] getVal(int +srcPos, int[] dest, int destPos, int len) <br> boolean isValNull()</td> +<td style="text-align: left;"><strong>ReturnedArrayLength +getValCount()</strong></td> +<td style="text-align: left;"><em>Ambiguous</em></td> +<td style="text-align: left;">Variable element count<br>using field +<em>valCount</em>,<br>which has getter and setter</td> +</tr> +<tr class="even"> +<td style="text-align: left;">[const]</td> +<td style="text-align: left;">char* name</td> +<td style="text-align: left;">setName(String srcVal) <br> +releaseVal()</td> +<td style="text-align: left;">String getName() <br> boolean isNameNull() +<br> int getNameElemCount()</td> +<td style="text-align: left;"><strong>ReturnsStringOnly</strong></td> +<td style="text-align: left;">Java</td> +<td style="text-align: left;">String only, w/ EOS</td> +</tr> +<tr class="odd"> +<td style="text-align: left;">[const]</td> +<td style="text-align: left;">char* name</td> +<td style="text-align: left;">setName(String srcVal) <br> setName(byte[] +src, int srcPos, int destPos, int len) <br> releaseVal()</td> +<td style="text-align: left;">String getNameAsString() <br> ByteBuffer +getName() <br> boolean isNameNull() <br> int getNameElemCount()</td> +<td style="text-align: left;"><strong>ReturnsString</strong></td> +<td style="text-align: left;">Java</td> +<td style="text-align: left;">String and byte access, w/ EOS</td> +</tr> +</tbody> +</table> +<h3 id="struct-setter-pseudo-code">Struct Setter Pseudo-Code</h3> +<ul> +<li><em>ImmutableAccess</em>: Drops setter, immutable</li> +<li><em>Pointer</em> & <em>ConstValue</em> & +<em>ConstElemCount</em>: Drops setter, native ownership on +const-value</li> +<li><em>Array</em> & <em>ConstValue</em> : Drops setter, const-value +array</li> +<li><em>Primitive</em> +<ul> +<li>Single aggregated instance +<ul> +<li>Store value within <em>native</em> memory</li> +</ul></li> +<li><em>Array</em> | <em>Pointer</em> +<ul> +<li><em>MaxOneElement</em> +<ul> +<li><em>Pointer</em> +<ul> +<li><em>ConstValue</em>: Allocate new memory and store value</li> +<li><em>VariaValue</em>: +<ul> +<li><em>ConstElemCount</em>: Reuse <em>native</em> memory and store +value with matching <em>elemCount 1</em>, otherwise Exception</li> +<li><em>VariaElemCount</em>: Reuse <em>native</em> memory and store +value with matching <em>elemCount 1</em>, otherwise allocates new memory +(had <em>elemCount 0</em>)</li> +</ul></li> +</ul></li> +<li><em>Array</em> & <em>VariaValue</em>: Reuse <em>native</em> +memory and store value (has const <em>elemCount 1</em>)</li> +<li><em>else</em>: <em>SKIP</em> setter for const single-primitive +array</li> +</ul></li> +<li><em>AnyElementCount</em> +<ul> +<li><em>String</em> & <em>isByteBuffer</em> & <em>Pointer</em> +<ul> +<li><em>ConstElemCount</em>: Reuse <em>native</em> memory and store +UTF-8 bytes with EOS with matching <em>elemCount</em>, otherwise +Exception +<ul> +<li><em>StringOnly</em>: End, no more setter for this field, otherwise +continue</li> +</ul></li> +<li><em>VariaElemCount</em>: Allocate new <em>native</em> memory and +store UTF-8 bytes with EOS +<ul> +<li><em>StringOnly</em>: End, no more setter for this field, otherwise +continue</li> +</ul></li> +</ul></li> +<li><em>ConstValue</em> +<ul> +<li><em>Pointer</em> +<ul> +<li><em>VariaElemCount</em>: Allocates new <em>native</em> memory and +store value</li> +</ul></li> +<li><em>else</em>: <em>SKIP</em> setter for const primitive array</li> +</ul></li> +<li><em>Array</em> | <em>ConstElemCount</em>: Reuse <em>native</em> +memory and store value with <= <em>elemCount</em>, otherwise +Exception</li> +<li><em>Pointer</em> & <em>VariaElemCount</em>: Reuse +<em>native</em> memory and store value with <= <em>elemCount</em>, +otherwise allocate new <em>native</em> memory</li> +</ul></li> +</ul></li> +</ul></li> +<li><em>Struct</em> ...</li> +</ul> +<h2 id="platform-header-files">Platform Header Files</h2> +<p>GlueGen provides convenient platform headers,<br /> +which can be included in your C header files for native compilation and +GlueGen code generation.</p> +<p>Example:</p> +<pre><code> #include <gluegen_stdint.h> + #include <gluegen_stddef.h> + + uint64_t test64; + size_t size1; + ptrdiff_t ptr1;</code></pre> +<p>To compile this file you have to include the following folder to your +compilers system includes, ie <code>-I</code>:</p> +<pre><code> gluegen/make/stub_includes/platform</code></pre> +<p>To generate code for this file you have to include the following +folder to your GlueGen <code>includeRefid</code> element:</p> +<pre><code> gluegen/make/stub_includes/gluegen</code></pre> +<h2 id="pre-defined-macros">Pre-Defined Macros</h2> +<p>To identity a GlueGen code generation run, GlueGen defines the +following macros:</p> +<pre><code> #define __GLUEGEN__ 2</code></pre> diff --git a/doc/GlueGen_Mapping.md b/doc/GlueGen_Mapping.md new file mode 100644 index 0000000..dcdb51a --- /dev/null +++ b/doc/GlueGen_Mapping.md @@ -0,0 +1,402 @@ +<style> +table, th, td { + border: 1px solid black; +} +</style> + +# GlueGen Native Data & Function Mapping for Java™ + +## References + +- [GlueGen Git Repo](https://jogamp.org/cgit/gluegen.git/about/) +- [GlueGen Java™ API-Doc](https://jogamp.org/deployment/jogamp-next/javadoc/gluegen/javadoc/) +- [GlueGen Manual](https://jogamp.org/gluegen/doc/manual/) +- [GlueGen Project Page](https://jogamp.org/gluegen/www/) +- [How To Build](https://jogamp.org/gluegen/doc/HowToBuild.html) + +## Overview +[GlueGen](https://jogamp.org/gluegen/www/) is a compiler for function and data-structure declarations, +generating Java and JNI C code offline at compile time +and allows using native libraries within your Java application. + +It reads ANSI C header files +and separate configuration files which provide control over many +aspects of the glue code generation. GlueGen uses a complete ANSI C +parser and an internal representation (IR) capable of representing all +C types to represent the APIs for which it generates interfaces. It +has the ability to perform significant transformations on the IR +before glue code emission. + +GlueGen can produce native foreign function bindings to Java as well as +map native data structures to be fully accessible from Java including +potential calls to embedded function pointer. + +GlueGen is also capable to bind even low-level APIs such as the Java Native Interface (JNI) and +the AWT Native Interface (JAWT) back up to the Java programming language. + +GlueGen utilizes [JCPP](https://jogamp.org/cgit/jcpp.git/about/), migrated C preprocessor written in Java. + +GlueGen is used for the [JogAmp](https://jogamp.org) projects +[JOAL](https://jogamp.org/cgit/joal.git/about/), +[JOGL](https://jogamp.org/cgit/jogl.git/about/) and +[JOCL](https://jogamp.org/cgit/jocl.git/). + +GlueGen is part of [the JogAmp project](https://jogamp.org). + +## Primitive Mapping + +Gluegen has build-in types (terminal symbols) for: + +| type | java-bits | native-bits <br> x32 | native bits <br> x64 | type | signed | origin | +|:-----|:----------|:-----------------------|:---------------------|:--------|:-------|:-------| +| void | 0 | 0 | 0 | void | void | ANSI-C | +| char | 8 | 8 | 8 | integer | any | ANSI-C | +| short | 16 | 16 | 16 | integer | any | ANSI-C | +| int | 32 | 32 | 32 | integer | any | ANSI-C | +| long | 64 | 32 | **32**† | integer | any | ANSI-C - Windows | +| long | 64 | 32 | **64** | integer | any | ANSI-C - Unix | +| float | 32 | 32 | 32 | float | signed | ANSI-C | +| double | 64 | 64 | 64 | double | signed | ANSI-C | +| \_\_int32 | 32 | 32 | 32 | integer | any | windows | +| \_\_int64 | 64 | 64 | 64 | integer | any | windows | +| int8\_t | 8 | 8 | 8 | integer | signed | stdint.h | +| uint8\_t | 8 | 8 | 8 | integer | unsigned | stdint.h | +| int16\_t | 16 | 16 | 16 | integer | signed | stdint.h | +| uint16\_t | 16 | 16 | 16 | integer | unsigned | stdint.h | +| int32\_t | 32 | 32 | 32 | integer | signed | stdint.h | +| uint32\_t | 32 | 32 | 32 | integer | unsigned | stdint.h | +| int64\_t | 64 | 64 | 64 | integer | signed | stdint.h | +| uint64\_t | 64 | 64 | 64 | integer | unsigned | stdint.h | +| intptr\_t | 64 | 32 | 64 | integer | signed | stdint.h | +| uintptr\_t | 64 | 32 | 64 | integer | unsigned | stdint.h | +| ptrdiff\_t | 64 | 32 | 64 | integer | signed | stddef.h | +| size\_t | 64 | 32 | 64 | integer | unsigned | stddef.h | +| wchar\_t | 32 | 32 | 32 | integer | signed | stddef.h | + +**Warning:** Try to avoid unspecified bit sized types, especially **long**, since it differs on Unix and Windows! +**Notes:** + +* † Type **long** will result in broken code on Windows, since we don't differentiate the OS and it's bit size is ambiguous. +* Anonymous void-pointer _void\*_ are mapped to NIO _Buffer_. +* Pointers to pointer-size types like _intptr\_t\*_, _uintptr\_t\*_, _ptrdiff\_t\*_ and _size\_t\*_ are mapped to _PointerBuffer_, to reflect the architecture depending storage size. + +### String Mapping + +#### Function return String values +Function return values are currently mapped from `char*` to Java String using *UTF-8* +via JNI function +> `jstring NewStringUTF(JNIEnv *env, const char *bytes)` + +*FIXME*: This might need more flexibility in case UTF-8 is not suitable for 8-bit wide `char` mappings +or wide characters, e.g. for UTF-16 needs to be supported. + +#### Function argument String values +Function argument values are either mapped from `char*` to Java String using *UTF-8* +via JNI function +> `const char * GetStringUTFChars(JNIEnv *env, jstring string, jboolean *isCopy)`. + +Alternatively, if a 16-bit wide *character* type has been detected, i.e. *short*, +the native *character* are mapped to Java using *UTF-16* +via JNI function +> `void GetStringRegion(JNIEnv *env, jstring str, jsize start, jsize len, jchar *buf)`. + + +#### Struct String mapping + +String value mapping for `Struct` fields is performed solely from the Java side using *Charset* and is hence most flexible. + +By default, *UTF-8* is being used for getter and setter of String values. +The *Struct* class provides two methods to get and set the used *Charset* for conversion +``` + /** Returns the Charset for this class's String mapping, default is StandardCharsets.UTF_8. */ + public static Charset getCharset() { return _charset; }; + + /** Sets the Charset for this class's String mapping, default is StandardCharsets.UTF_8. */ + public static void setCharset(Charset cs) { _charset = cs; } + +``` + +In case the String length has not been configured via `ReturnedArrayLength`, +it will be dynamically calculated via `strnlen(aptr, max_len)`. +The maximum length default for the `strnlen(..)` operation is 8192 bytes and can be get and set using: +``` + /** Returns the maximum number of bytes to read to determine native string length using `strnlen(..)`, default is 8192. */ + public static int getMaxStrnlen() { return _max_strnlen; }; + + /** Sets the maximum number of bytes to read to determine native string length using `strnlen(..)`, default is 8192. */ + public static void setMaxStrnlen(int v) { _max_strnlen = v; } +``` +*FIXME*: This only works reliable using an 8-bit Charset encoding, e.g. the default *UTF-8*. + +### Alignment for Compound Data + +In general, depending on CPU and it's configuration (OS), alignment is set up for each type (char, short, int, long, ..). + +Compounds (structures) are aligned naturally, i.e. their inner components are aligned +and are itself aligned to it's largest element. + +See: + +* [Wikipedia Data Structure Alignment](http://en.wikipedia.org/wiki/Data_structure_alignment) +* [Wikipedia Data Structure Alignment - Padding](http://en.wikipedia.org/wiki/Data_structure_alignment#Data_structure_padding) +* [Viva64 Data Alignment](http://www.viva64.com/en/l/0021/) +* [Apple: Darwin 64bit Porting - Data Type Size & Alignment](http://developer.apple.com/library/mac/#documentation/Darwin/Conceptual/64bitPorting/transition/transition.html#//apple_ref/doc/uid/TP40001064-CH207-SW1) + +#### Simple alignment arithmetic + +Modulo operation, where the 2nd handles the case offset == alignment: + +> padding = ( alignment - ( offset % alignment ) ) % alignment ; +> aligned\_offset = offset + padding ; + +Optimization utilizing alignment as a multiple of 2 `-> x % 2n == x & ( 2n - 1 )` + +> remainder = offset & ( alignment - 1 ) ; +> padding = ( remainder > 0 ) ? alignment - remainder : 0 ; +> aligned\_offset = offset + padding ; + +Without branching, using the 2nd modulo operation for the case offset == alignment: + +> padding = ( alignment - ( offset & ( alignment - 1 ) ) ) & ( alignment - 1 ) ; +> aligned\_offset = offset + padding ; + +See `com.jogamp.gluegen.cgram.types.SizeThunk.align(..)`. + +#### Type Size & Alignment for x86, x86\_64, armv6l-32bit-eabi and Window(mingw/mingw64) + +Runtime query is implemented as follows: +``` + typedef struct { + char fill; // nibble one byte + // padding to align s1: padding_0 + type_t s1; // + } test_struct_type_t; + + padding_0 = sizeof(test_struct_type_t) - sizeof(type_t) - sizeof(char) ; + alignmentOf(type_t) = sizeof(test_struct_type_t) - sizeof(type_t) ; +``` + +| type | size <br> *32 bit* | alignment <br> *32 bit* | size <br> *64 bit* | alignment <br> *64 bit* | +|:------------|:-------------------|:------------------------|:-------------------|:------------------------| +| char | 1 | 1 | 1 | 1 | +| short | 2 | 2 | 2 | 2 | +| int | 4 | 4 | 4 | 4 | +| float | 4 | 4 | 4 | 4 | +| long | 4 | 4 | 8†,4∗ | 8†,4∗ | +| pointer | 4 | 4 | 8 | 8 | +| long long | 8 | 4†,8∗+ | 8 | 8 | +| double | 8 | 4†,8∗+ | 8 | 8 | +| long double | 12†∗,8+,16\- | 4†∗,8+,16\- | 16 | 16 | + +† Linux, Darwin ++armv7l-eabi +\- MacOsX-32bit-gcc4 +∗ Windows + +## Struct Mapping +A *Struct* is a C compound type declaration, which can be mapped to a Java class. + +A *Struct* may utilize the following data types for its fields +* *Primitive*, i.e. *char*, *int32_t*, ... + * See [*Primitive Mapping*](#primitive-mapping) above. + * See [*String Mapping*](#string-mapping) above. +* *Struct*, i.e. another compound variable +* *Function Pointer*, a *typedef*'ed and set callable function pointer + +A field may be a direct aggregation, i.e. instance, within the struct including an array +or a reference to a single element or array via a pointer. + +Both, *primitive* and *struct* field type mappings only produce pure Java code, utilizing the *GlueGen Runtime*. +Hence no additional native code must be compiled nor a resulting additional library loaded to use the mapping. + +Only when mapping *function-pointer* within *structs*, additional native glue-code is produced to +call the underlying native function which has to be compiled and its library loaded. + +The generated method `public static boolean usesNativeCode()` can be used to validate +whether the produced Java class requires a corresponding library for additional native code. + +### GlueGen Struct Settings + +#### **ImmutableAccess** *symbol* +Immutable access can be set for a whole struct or a single field of a struct. + +Immutable access will simply suppress generating setters in the Java code +and hence also reduces the footprint of the generated Java class for such struct. + +* `ImmutableAccess TK_Struct` + + Immutable access for the whole struct `TK_Struct + + Sets pseudo-code flag *ImmutableAccess*, see below. + +* `ImmutableAccess TK_Struct.val` + + Immutable access for the single field `val` within struct `TK_Struct` + + Sets pseudo-code flag *ImmutableAccess*, see below. + +#### **MaxOneElement** *symbol* +* `MaxOneElement TK_Struct.val` + + Sets field pointer `val` + to point to a array with a maximum of one element and unset initial value (zero elements). + + Sets pseudo-code flag *MaxOneElement*, see below. + +#### **ReturnedArrayLength** *symbol* *expression* +* `ReturnedArrayLength TK_Struct.val 3` + + Sets field pointer `val` to point to a array with three elements. + + Sets pseudo-code flag *ConstElemCount*, see below. + + Having set *ConstElemCount* also implies *native ownership* for a *Pointer* referenced *native* memory. + +* `ReturnedArrayLength TK_Struct.val 1` + + Sets field pointer `val` to point to a array with one element. + + Sets pseudo-code flags *ConstElemCount* and *MaxOneElement*, see below. + + Having set *ConstElemCount* also implies *native ownership* for a *Pointer* referenced *native* memory. + +* `ReturnedArrayLength TK_Struct.val getValElements()` + + Sets field pointer `val` to point to a array with a variable length as described by the + field `valElements` retrievable via its getter `getValElements()`. + + Sets pseudo-code flag *VariaElemCount*, see below. + +#### **ReturnsString** *symbol* +A direct C code `char` array or indirect array via pointer can be interpreted as a Java `String`. + +* `ReturnsString TK_Struct.name` + + Sets field char-array or char-pointer `name` to be additionally interpreted as a Java `String`. + Besides the `byte[]` and `ByteBuffer` getter and setter variants, a `String` variant will be added. + + Sets pseudo-code flags *String*, see below. + + See [*String Mapping*](#string-mapping) above. + +#### **ReturnsStringOnly** *symbol* + +* `ReturnsStringOnly TK_Struct.name` + + Sets field char-array or char-pointer `name` to be exclusively interpreted as a Java `String`. + Instead of the `byte[]` and `ByteBuffer` getter and setter variants, a `String` variant will be produced. + + Sets pseudo-code flags *StringOnly*, see below. + + See [*String Mapping*](#string-mapping) above. + +### Struct Mapping Notes + +* *ConstElemCount* via **ReturnedArrayLength \<int\>** implies *native ownership* for a *Pointer* referenced *native* memory + if the expression is constant. Otherwise the *native* memory has *java ownership*. + See [ReturnedArrayLength Setting](#returnedarraylength-symbol-expression) above. + +* To release native memory with *java ownership*, i.e. a native ByteBuffer, `releaseVal()` can be used. + +* To shrink a *Pointer* & *VariaElemCount* pointer-array elemCount size with *java ownership* , + the memory must be cleared with `releaseVal()` first. This is due to `setVal(src, srcPos, destPos, len)` + reusing the existing memory in case `destPos + len < elemCount`. + +### Struct Java Signature Table + +Please find below signature table as generated by the *C Declaration* including its *C Modifier*, +e.g. `const` for constant, `[const]` for const and non-const and `empty` for non-const (variable). + +Further, the *GlueGen Setting* (see above) impacts the code generation as well. + +Below table demonstrates *primitive* types being mapped within a `struct` named `TK_Struct`. +A similar mapping is produced for `struct` types, i.e. *compounds*. + + +| C Mod | C Declaration | Java Setter | Java Getter | GlueGen Setting | Ownership | Remarks | +|:--------|:--------------|:-----------------------------------------------------------------|:--------------------------------------|:-----------------------------------------------|:----------|:----------| +| | | | static boolean usesNativeCode() | | | Java, static, <br> *true* if using native code | +| | | | static int size() | | | Java, static, <br> native size in bytes | +| | | | static TK_Struct create() | | | Java, static ctor | +| | | | static TK_Struct create(ByteBuffer) | | | Java, static ctor <br> w/ existing ByteBuffer | +| | | | static TK_Struct derefPointer(long addr) | | | Java, static ctor <br> dereferencing ByteBuffer <br> at native address of size() | +| | | | ByteBuffer getBuffer() | | | Java, <br> underlying ByteBuffer | +| | | | long getDirectBufferAddress() | | | Java, native address <br> of underlying getBuffer() | +| | int32_t val | setVal(int v) | int getVal() | | Static | | +| const | int32_t val | *none* | int getVal() | | Static | Read only | +| | int32_t val | *none* | int getVal() | **ImmutableAccess** | Static | Read only | +| [const] | int32_t* val | setVal(int v) <br> releaseVal() | int getVal() <br> boolean isValNull() <br> int getValElemCount() | **MaxOneElement** | Java | Starts w/ null elements,<br>max 1 element | +| const | int32_t* val | *none* | int getVal() <br> boolean isValNull() <br> static int getValElemCount() | **ReturnedArrayLength 1** | Native | Const element count 1 | +| | int32_t* val | setVal(int v) | int getVal() <br> boolean isValNull() <br> static int getValElemCount() | **ReturnedArrayLength 1** | Native | Const element count 1 | | +| | int32_t val[3]| setVal(int[] src, int srcPos, int destPos, int len) | IntBuffer getVal() <br> int[] getVal(int srcPos, int[] dest, int destPos, int len) | | Static | | +| const | int32_t val[3]| *none* | IntBuffer getVal() <br> int[] getVal(int srcPos, int[] dest, int destPos, int len) | | Static | Read only | +| const | int32_t* val | *none* | IntBuffer getVal() <br> int[] getVal(int srcPos, int[] dest, int destPos, int len) <br> boolean isValNull() <br> static int getValElemCount() | **ReturnedArrayLength 3** | Native | Read only <br> Const element count 3 | +| | int32_t* val | setVal(int[] src, int srcPos, int destPos, int len) | IntBuffer getVal() <br> int[] getVal(int srcPos, int[] dest, int destPos, int len) <br> boolean isValNull() <br> static int getValElemCount() | **ReturnedArrayLength 3** | Native | Const element count 3 | +| [const] | int32_t* val | setVal(int[] src, int srcPos, int destPos, int len) <br> releaseVal() | IntBuffer getVal() <br> int[] getVal(int srcPos, int[] dest, int destPos, int len) <br> boolean isValNull() <br> int getValElemCount() | | Java | Starts w/ null elements | +| [const] | int32_t* val | setVal(int[] src, int srcPos, int destPos, int len) <br> releaseVal() | IntBuffer getVal() <br> int[] getVal(int srcPos, int[] dest, int destPos, int len) <br> boolean isValNull() | **ReturnedArrayLength getValCount()** | *Ambiguous* | Variable element count<br>using field *valCount*,<br>which has getter and setter | +| [const] | char* name | setName(String srcVal) <br> releaseVal() | String getName() <br> boolean isNameNull() <br> int getNameElemCount() | **ReturnsStringOnly** | Java | String only, w/ EOS | +| [const] | char* name | setName(String srcVal) <br> setName(byte[] src, int srcPos, int destPos, int len) <br> releaseVal() | String getNameAsString() <br> ByteBuffer getName() <br> boolean isNameNull() <br> int getNameElemCount() | **ReturnsString** | Java | String and byte access, w/ EOS| + +### Struct Setter Pseudo-Code + +* *ImmutableAccess*: Drops setter, immutable +* *Pointer* & *ConstValue* & *ConstElemCount*: Drops setter, native ownership on const-value +* *Array* & *ConstValue* : Drops setter, const-value array +* *Primitive* + * Single aggregated instance + * Store value within *native* memory + * *Array* | *Pointer* + * *MaxOneElement* + * *Pointer* + * *ConstValue*: Allocate new memory and store value + * *VariaValue*: + * *ConstElemCount*: Reuse *native* memory and store value with matching *elemCount 1*, otherwise Exception + * *VariaElemCount*: Reuse *native* memory and store value with matching *elemCount 1*, otherwise allocates new memory (had *elemCount 0*) + * *Array* & *VariaValue*: Reuse *native* memory and store value (has const *elemCount 1*) + * *else*: *SKIP* setter for const single-primitive array + * *AnyElementCount* + * *String* & *isByteBuffer* & *Pointer* + * *ConstElemCount*: Reuse *native* memory and store UTF-8 bytes with EOS with matching *elemCount*, otherwise Exception + * *StringOnly*: End, no more setter for this field, otherwise continue + * *VariaElemCount*: Allocate new *native* memory and store UTF-8 bytes with EOS + * *StringOnly*: End, no more setter for this field, otherwise continue + * *ConstValue* + * *Pointer* + * *VariaElemCount*: Allocates new *native* memory and store value + * *else*: *SKIP* setter for const primitive array + * *Array* | *ConstElemCount*: Reuse *native* memory and store value with <= *elemCount*, otherwise Exception + * *Pointer* & *VariaElemCount*: Reuse *native* memory and store value with <= *elemCount*, otherwise allocate new *native* memory +* *Struct* ... + + +## Platform Header Files + +GlueGen provides convenient platform headers, +which can be included in your C header files for native compilation and GlueGen code generation. + +Example: +``` + #include <gluegen_stdint.h> + #include <gluegen_stddef.h> + + uint64_t test64; + size_t size1; + ptrdiff_t ptr1; +``` + +To compile this file you have to include the following folder to your compilers system includes, ie `-I`: +``` + gluegen/make/stub_includes/platform +``` + +To generate code for this file you have to include the following folder to your GlueGen `includeRefid` element: +``` + gluegen/make/stub_includes/gluegen +``` + +## Pre-Defined Macros + +To identity a GlueGen code generation run, GlueGen defines the following macros: +``` + #define __GLUEGEN__ 2 +``` diff --git a/doc/JogAmpMacOSVersions.html b/doc/JogAmpMacOSVersions.html new file mode 100644 index 0000000..22c2351 --- /dev/null +++ b/doc/JogAmpMacOSVersions.html @@ -0,0 +1,568 @@ +<style> +div#header, header + { + + border-bottom: 1px solid #aaa; + margin-bottom: 0.5em; + } + +.title + { + text-align: center; + } + +.author, .date + { + text-align: center; + } + +div#TOC, nav#TOC + { + + border-bottom: 1px solid #aaa; + margin-bottom: 0.5em; + } + +nav#TOC { + margin-bottom: var(--line-height); + + padding-bottom: 0.5rem; +} + +nav#TOC input { + display: none; +} + +nav#TOC label { + color: var(--color-link); + cursor: pointer; +} + +nav#TOC > ul { + display: none; +} + +nav#TOC > input:checked + ul { + display: block; +} + +@media print + { + div#TOC, nav#TOC + { + + display: none; + } + } + +div.content + { + color: #111111; + font-size: 14px; + line-height: 1.6; + } + +div#cgit a + { + color: #1212a0; + } + +div#cgit a.sourceLine + { + color: #111111; + } + +h1, h2, h3, h4, h5, h6 +{ + font-family: "Helvetica Neue", Helvetica, "Liberation Sans", Calibri, Arial, sans-serif; + + page-break-after: avoid; + + margin: 20px 0 10px; + padding: 0; +} + +h2 { + border-bottom: 1px solid #ccc; +} + +div div + { + + } + +section section + { + margin-left: 2em; + } + +p {} + +blockquote + { + font-style: italic; + } + +li + { + } + +li > p + { + margin-top: 1em; + } + +ul + { + } + +ul li + { + } + +ol + { + } + +ol li + { + } + +hr {} + +sub + { + } + +sup + { + } + +em + { + } + +em > em + { + font-style: normal; + } + +strong + { + } + +a + { + + text-decoration: none; + } + +@media screen + { + a:hover + { + + text-decoration: underline; + } + } + +@media print + { + a { + + color: black; + background: transparent; + } + + a[href^="http://"]:after, a[href^="https://"]:after + { + + content: " (" attr(href) ") "; + font-size: 90%; + } + } + +img + { + + vertical-align: middle; + } + +div.figure + { + + margin-left: auto; + margin-right: auto; + text-align: center; + font-style: italic; + } + +p.caption + { + + } + +pre, code + { + background-color: #f8f8f8; + + white-space: pre-wrap; + white-space: -moz-pre-wrap !important; + white-space: -pre-wrap; + white-space: -o-pre-wrap; + word-wrap: break-word; + + } + +pre + { + + padding: 0.5em; + border-radius: 5px; + + background-color: #f8f8f8; + border: 1px solid #ccc; + font-size: 13px; + line-height: 19px; + overflow: auto; + padding: 6px 10px; + + margin-left: 0.5em; + margin-right: 0.5em; + } + +@media screen + { + pre + { + + white-space: pre; + overflow: auto; + + border: 1px dotted #777; + } + } + +code + { + } + +p > code, li > code + { + + padding-left: 2px; + padding-right: 2px; + } + +li > p code + { + + padding: 2px; + } + +span.math + { + + } + +div.math + { + } + +span.LaTeX + { + } + +eq + { + } + +table + { + border-collapse: collapse; + border-spacing: 0; + + margin-left: auto; + margin-right: auto; + } + +thead + { + border-bottom: 1pt solid #000; + background-color: #eee; + } + +tr.header + { + } + +tbody + { + } + +tr { + } +tr.odd:hover, tr.even:hover + { + background-color: #eee; + } + +tr.odd {} +tr.even {} + +td, th + { + vertical-align: top; + vertical-align: baseline; + padding-left: 0.5em; + padding-right: 0.5em; + padding-top: 0.2em; + padding-bottom: 0.2em; + } +th + { + font-weight: bold; + } + +tfoot + { + } + +caption + { + caption-side: top; + border: none; + font-size: 0.9em; + font-style: italic; + text-align: center; + margin-bottom: 0.3em; + padding-bottom: 0.2em; + } + +dl + { + border-top: 2pt solid black; + padding-top: 0.5em; + border-bottom: 2pt solid black; + } + +dt + { + font-weight: bold; + } + +dd+dt + { + border-top: 1pt solid black; + padding-top: 0.5em; + } + +dd + { + margin-bottom: 0.5em; + } + +dd+dd + { + border-top: 1px solid black; + } + +a.footnote, a.footnoteRef { + font-size: small; + vertical-align: text-top; +} + +a[href^="#fnref"], a.reversefootnote + { + } + +@media print + { + a[href^="#fnref"], a.reversefootnote + { + + display: none; + } + } + +div.footnotes + { + } + +div.footnotes li[id^="fn"] + { + } + +@media print + { + .noprint + { + display:none; + } + } +</style> + +<nav id="TOC" role="doc-toc"> + <strong>Contents</strong><label for="contents">⊕</label> + <input type="checkbox" id="contents"> + <ul> + <li><a href="#jogamps-macos-version-support">JogAmp's MacOS Version + Support</a> + <ul> + <li><a href="#overview">Overview</a></li> + <li><a href="#openjdk">OpenJDK</a></li> + <li><a href="#jogamp-build-and-test-setup">JogAmp Build and Test + Setup</a> + <ul> + <li><a href="#macos-1265-monterey-darwin-21-x86_64">MacOS 12.6.5 + (Monterey), Darwin 21, <code>x86_64</code></a></li> + <li><a href="#macos-10136-high-sierra-darwin-17-x86_64">MacOS 10.13.6 + (High Sierra), Darwin 17, <code>x86_64</code></a></li> + <li><a href="#macos-131-ventura-darwin-22-arm64">MacOS 13.1 (Ventura), + Darwin 22, <code>arm64</code></a></li> + </ul></li> + <li><a href="#change-history">Change History</a></li> + </ul></li> + </ul> +</nav> + +<style> +table, th, td { + border: 1px solid black; +} +</style> + +<h1 id="jogamps-macos-version-support">JogAmp's MacOS Version +Support</h1> +<p>References</p> +<ul> +<li><a href="https://en.wikipedia.org/wiki/MacOS_version_history">Mac OS +Version History (wiki)</a>.</li> +<li><a +href="https://en.wikipedia.org/wiki/Xcode#Version_comparison_table">Xcode +Version Comparison Table (wiki)</a></li> +</ul> +<h2 id="overview">Overview</h2> +<table> +<thead> +<tr class="header"> +<th style="text-align: left;">MacOS Version</th> +<th style="text-align: left;">Release Name</th> +<th style="text-align: left;">Darwin Version</th> +<th style="text-align: left;">JogAmp Relation</th> +</tr> +</thead> +<tbody> +<tr class="odd"> +<td style="text-align: left;">10.7</td> +<td style="text-align: left;">Lion</td> +<td style="text-align: left;">11</td> +<td style="text-align: left;">Min deployment target</td> +</tr> +<tr class="even"> +<td style="text-align: left;"></td> +<td style="text-align: left;"></td> +<td style="text-align: left;"></td> +<td style="text-align: left;"></td> +</tr> +<tr class="odd"> +<td style="text-align: left;">10.13</td> +<td style="text-align: left;">High Sierra</td> +<td style="text-align: left;">17</td> +<td style="text-align: left;">Test node 10.13.6, +<code>x86_64</code></td> +</tr> +<tr class="even"> +<td style="text-align: left;">10.14</td> +<td style="text-align: left;">Mojave</td> +<td style="text-align: left;">18</td> +<td style="text-align: left;"></td> +</tr> +<tr class="odd"> +<td style="text-align: left;">10.15</td> +<td style="text-align: left;">Catalina</td> +<td style="text-align: left;">19</td> +<td style="text-align: left;"></td> +</tr> +<tr class="even"> +<td style="text-align: left;"></td> +<td style="text-align: left;"></td> +<td style="text-align: left;"></td> +<td style="text-align: left;"></td> +</tr> +<tr class="odd"> +<td style="text-align: left;">11</td> +<td style="text-align: left;">Big Sur</td> +<td style="text-align: left;">20</td> +<td style="text-align: left;"></td> +</tr> +<tr class="even"> +<td style="text-align: left;">12</td> +<td style="text-align: left;">Monterey</td> +<td style="text-align: left;">21</td> +<td style="text-align: left;">Build node 12.6.5, w/ Xcode 14.2, +<code>x86_64</code></td> +</tr> +<tr class="odd"> +<td style="text-align: left;">13</td> +<td style="text-align: left;">Ventura</td> +<td style="text-align: left;">22</td> +<td style="text-align: left;">Test node 13.1, <code>arm64</code></td> +</tr> +</tbody> +</table> +<h2 id="openjdk">OpenJDK</h2> +<p>Available Java(tm) VMs</p> +<ul> +<li><a href="http://openjdk.java.net/">OpenJDK</a> build @ <a +href="https://adoptium.net/temurin/releases/">Adoptium</a> +<ul> +<li><a href="https://adoptium.net/supported-platforms/">Adoptium +Supported MacOS Versions</a> +<ul> +<li>MacOS 10.15, 11, 12, 13 for <code>x86_64</code> and +<code>arm64</code></li> +</ul></li> +</ul></li> +</ul> +<h2 id="jogamp-build-and-test-setup">JogAmp Build and Test Setup</h2> +<h3 id="macos-1265-monterey-darwin-21-x86_64">MacOS 12.6.5 (Monterey), +Darwin 21, <code>x86_64</code></h3> +<ul> +<li>Build and main test machine</li> +<li>XCode 14.2 w/ SDK 11.3 +<ul> +<li><code>export SDKROOT=macosx11.3</code> (<em>MacOS SDK</em>)</li> +<li><code>-mmacosx-version-min=10.7</code> (<em>Miniumum deployment +target</em>)</li> +</ul></li> +<li>OpenJDK Temurin 17.0.5+8</li> +</ul> +<h3 id="macos-10136-high-sierra-darwin-17-x86_64">MacOS 10.13.6 (High +Sierra), Darwin 17, <code>x86_64</code></h3> +<ul> +<li>Test machine</li> +<li>OpenJDK Temurin 17.0.5+8</li> +</ul> +<h3 id="macos-131-ventura-darwin-22-arm64">MacOS 13.1 (Ventura), Darwin +22, <code>arm64</code></h3> +<ul> +<li>Test machine</li> +<li>OpenJDK Temurin 17.0.5+8</li> +</ul> +<h2 id="change-history">Change History</h2> +<table> +<thead> +<tr class="header"> +<th style="text-align: left;">Date</th> +<th style="text-align: left;">Note</th> +</tr> +</thead> +<tbody> +<tr class="odd"> +<td style="text-align: left;">2023-05-06</td> +<td style="text-align: left;">Initial Version for JogAmp Release +2.5.0</td> +</tr> +</tbody> +</table> diff --git a/doc/JogAmpMacOSVersions.md b/doc/JogAmpMacOSVersions.md index 924c53f..58eb199 100644 --- a/doc/JogAmpMacOSVersions.md +++ b/doc/JogAmpMacOSVersions.md @@ -1,4 +1,10 @@ -# MacOS Versions Related to JogAmp +<style> +table, th, td { + border: 1px solid black; +} +</style> + +# JogAmp's MacOS Version Support References |