Class CCodeUnit


  • public class CCodeUnit
    extends CodeUnit
    C code unit (a generated C source file), covering multiple FunctionEmitter allowing to unify output, decoration and dynamic helper code injection per unit.
    • Field Detail

      • cUnitName

        public final String cUnitName
        base c-unit name with suffix.
    • Constructor Detail

      • CCodeUnit

        public CCodeUnit​(String filename,
                         String cUnitName,
                         Object generator)
                  throws IOException
        Parameters:
        filename - the class's full filename to open w/ write access
        cUnitName - the base c-unit name, i.e. c-file basename with suffix
        generator - informal optional object that is creating this unit, used to be mentioned in a warning message if not null.
        Throws:
        IOException
    • Method Detail

      • getJNIOnLoadJNIEnvCode

        public static final String getJNIOnLoadJNIEnvCode​(String libraryBasename)
        Returns native JNI code `JNI_OnLoad(..)` used for dynamic libraries, `JNI_OnLoad_{libraryBasename}(..)` used for static libraries, `JVMUtil_GetJNIEnv(..)` etc.

        The `JNI_OnLoad*(..)` methods set a `static JavaVM* {libraryBasename}_jvmHandle`, which in turn is utilized by `JVMUtil_GetJNIEnv(..)` to attach a new thread to the `JavaVM*` generating a new `JNIEnv*`- or just to retrieve the thread's `JNIEnv*`, if already attached to the `JavaVM*`.

        Parameters:
        libraryBasename - library basename to generate the `JNI_OnLoad_{libraryBasename}(..)` variant for statically linked libraries.
        Returns:
        the code
        See Also:
        #getJNIOnLoadJNIEnvDecl(String)