Library part of type nativeLibrary

A library of type nativeLibrary enables your EGL-generated Java™ code to invoke a single, locally running DLL. The code for that DLL is not written in the EGL language. For information on developing a basic library, which contains shared functions and values that are written in the EGL language, see Library part of type basicLibrary.

In a library of type nativeLibrary, the purpose of each function is to provide an interface to a DLL function. You cannot define statements in the EGL function, and you cannot declare variables or constants anywhere in the library.

The EGL runtime accesses a DLL-based function by using the setting of the EGL function property alias, which defaults to the EGL function name. Set that property explicitly if the name of the DLL-based function does not conform to the conventions described in Naming conventions.

The library property callingConvention specifies how the EGL runtime passes data between the two kinds of code:
The only value now available for callingConvention is I4GL:

The library property dllName specifies the DLL name, which is final; it cannot be overridden at deployment time. If you do not specify a value for the library property dllName, you must specify the DLL name in the Java runtime property vgj.defaultI4GLNativeLibrary. Only one such Java runtime property is available for a run unit, so only one DLL can be specified, aside from DLLs that are identified in the EGL libraries.

Whether you specify the DLL name at development time (in dllName) or at deployment time (in vgj.defaultI4GLNativeLibrary), the DLL must reside in the directory path identified in a runtime variable; that variable is either PATH (on Windows® 2000/NT/XP) or LIBPATH (on UNIX® platforms).

Library functions are automatically declared as public to ensure that they are available outside the library. In your other EGL code, you can reference a function by its function-alias name alone, without specifying the library name, but only if you include the library in a program-specific Use declaration.

The EGL library is generated as a Java class that is separate from the code that accesses the library and from the DLL. The EGL runtime accesses that class by using the setting of the library property alias, which defaults to the EGL library name. Set that property explicitly if the name of the library part does not conform to Java conventions.

At run time, a DLL is loaded when first used and is unloaded when the accessing program or PageHandler leaves memory, as occurs when the run unit ends.

A PageHandler gets a new copy of the DLL whenever the PageHandler is loaded. Also, a DLL that is invoked by an EGL library of type basicLibrary remains in memory as long as the invoking library does.

The following native library provides access to a DLL written in C:
  Library myLibrary type nativeLibrary
  {callingConvention=”I4GL”, dllname=”mydll”}
	
    Function entryPoint1( p1 int nullable in, 
                          p2 date in, p3 time in, 
                          p4 interval in, p5 any out) 
    	end

    	Function entryPoint2( p1 float in, 
                          p2 String in, 
                          p3 smallint out)
    	end

    	Function entryPoint3( p1 any in, 
                          p2 any in, 
                          p3 any out, 
                          p4 CLOB inout)
    	end
  end

Related concepts
Java runtime properties
Library part of type basicLibrary

Related reference
Function part in EGL source format
Java runtime properties (details)
Library part in EGL source format
Naming conventions
Run unit
Use declaration

Feedback
(C) Copyright IBM Corporation 2000, 2005. All Rights Reserved.