TP_API
This function modifier directs the C/C++ compiler to generate function calls
using the standard calling convention. Functions must pass the correct number and type of
arguments. Such functions comply with the standard WIN32 argument-passing convention. In
Delphi the directive stdcall must be used.
TPINT32
A signed 32 bit integer type, the size of this integer type is guaranteed across
different platforms.
TPBOOL
A boolean type, the values TRUE or FALSE must be used. The size of this type may
change across different platforms.
TPCHAR
A single character. The size of this type may change across different platforms.
TPINT
A signed integer. The size of this type may change across different platforms.
TP_EXTERNAL_VERSION
This constant defines the major version of the implemented external interface.
Differences in the major version number mean that existing extension libraries cannot work
with a version of Trinc-Prolog.
TP_EXTERNAL_VERSION_MINOR
This constant defines the minor version of the implemented external interface.
Changes in the minor version do not break existing extension libraries, they only indicate
that the interface definition has been extended.
TPEXTEVENT_SIZE_GOAL
The size of the character array to which an external event can be copied. See
also TPEXTEVENT.
TP_VALUE_FUNCTOR
Functor name for predicate used to transport values to Trinc-Prolog. See also TPARGUMENT.
These constants are used for the attribute _Type of TPARGUMENT.
| T_ARG_VAR_EMPTY | an empty variable |
| T_ARG_ATOM | atom |
| T_ARG_INTEGER | an integer number |
| T_ARG_FLOAT | a floating point number |
| T_ARG_LIST | a list |
| T_ARG_EMPTY_LIST | an empty list |
| T_ARG_OP | an operator |
| T_ARG_SINGLE_QUOTED | an atom enclosed by single quotes |
| T_ARG_VARIOUS | all remaining possible types |
A function that implements a Prolog clause or a class method of a prolog class can return any of the following values. These values determine how Trinc-Prolog continues proving.
| TP_ERROR | critical error, the prolog program must stop |
| TP_HALT | the prolog program must stop |
| TP_EXIT | Prolog engine must continue with exiting |
| TP_FAIL | the predicate has failed, start failing |
| TP_EXCEPTION | an exception must be thrown |
| TP_UNKNOWN | a call was made to a predicate that was not implemented, see also the 'unknown' flag of current_prolog_flag/2. |
If a value is assigned to a variable by an external library then the type of the returned value must be specified. The possible values are:
| T_VARVALUE_CLAUSE | a Prolog clause that must be compiled |
| T_VARVALUE_INTEGER | an integer |
| T_VARVALUE_FLOAT | a floating point value |
| T_VARVALUE_ATOM | an atom |
| T_VARVALUE_ATOM_QUOTED | an atom enclosed by single quotes |
The TPINIT structure contains information for initializing the extension. The structure has one attribute, this attribute is the handle of the window to use when an event must be send.
TPINIT {
HWND _DestWin
}
HWND _DestWin
Window to which an external asynchronous event must be send.
The TPCALL structure is a parameter if an external clause or a class method is called by Trinc-Prolog. It contains information about the context of the function call.
TPCALL {
TPINT32 _EngineId
TPINT32 _Arity
TPINT _TPId
TPINT _ExtId
}
TPINT32 _EngineId
This is the Trinc-Prolog engine identifier, each instance of the Trinc-Prolog inference
engine is assigned a unique value.
TPINT32 _Arity
Arity of the prolog goal being proven, i.e. number of arguments. This number need not be
equal to the number TPARGUMENT structures.
TPINT _TPId
Trinc-Prolog identifier value for a class instance, if a method of a class instance is
being called, for a normal clause this attribute is set to 0.
TPINT _ExtId
Identifier for an instance as assigned by the extension library. If a normal clause is
being called this attribute is 0.
For each argument passed to a clause or a class method there is a single TPARGUMENT. A structure of this type contains the type and value of the argument, the next argument of the list of argument and the first of its (possible) subexpression of arguments.
TPARGUMENT {
TPCHAR *_Lexeme
TPINT32 _Type
TPARGUMENT *_Next
TPARGUMENT *_Child
TPCHAR *_VarValue
TPCHAR _VarValueType
void *_Reserved
}
TPCHAR *_Lexeme
Name of the argument, this parameter may never be changed by an external library!
TPINT32 _Type
Type of argument, see also argument types.
TPARGUMENT *_Next
Next argument in the argument list.
TPARGUMENT *_Child
First child of the subexpression of the argument. If for instance a structure or a list is
a parameter.
TPCHAR *_VarValue
A value can assigned to this attribute if the type of the argument is T_ARG_VAR_EMPTY.
Memory can be allocated with the function TP_MEMALLOC.
TPCHAR _VarValueType
If a value was assigned to a variable then this attribute must be used to indicate the
type of the variable. see also variable value types.
void *_Reserved
Reserved for use by Trinc-Prolog.
If an external clause or class method wants to throw an exception then this structure must be filled with a string (a prolog query to prove).
TPEXCEPTION {
TPCHAR *_Str
}
TPCHAR *_Str
The Prolog exception goal that must be proven must be assigned to this string pointer.
Memory can be allocated with the function TP_MEMALLOC.
This structure must be filled if an external asynchronous event was detected by an extension library and must be proven by Trinc-Prolog.
TPEXTEVENT {
TPINT32 _EngineId
TPINT _TPId
TPCHAR _Goal[TPEXTEVENT_SIZE_GOAL+1]
}
TPINT32 _EngineId
A Trinc-Prolog engine identifier, each instance of the Trinc-Prolog engine is assigned an
unique value.
TPINT _TPId
The Trinc-Prolog instance identifier if the event must be send to an instance of a class.
0 must be assigned if the event is not send to an instance.
TPCHAR _Goal
The Prolog goal to be proven by Trinc-Prolog can be copied to this character array.
This structure must be filled if an external asynchronous event was detected by an extension library and must be proven by Trinc-Prolog. This structure was introduced with Trinc-Prolog R3B, which included version 2.1 of the extension interface. This structure can only be used if the extension library and Trinc-Prolog are in the same operating system process.
TPEXTEVENT2 {
TPINT32 _EngineId
TPINT _TPId
TPCHAR _GoalPtr
}
TPINT32 _EngineId
A Trinc-Prolog engine identifier, each instance of the Trinc-Prolog engine is assigned an
unique value.
TPINT _TPId
The Trinc-Prolog instance identifier if the event must be send to an instance of a class.
0 must be assigned if the event is not send to an instance.
TPCHAR _GoalPtr
Pointer to a memory buffer that contains the Prolog goal to be proven by Trinc-Prolog. The
memory buffer must be allocated and managed by the extension library.
TPCHAR *TP_MEMALLOC( unsigned int NumBytes )
Function to allocate memory for a value if a value must be assigned to an argument, variable or some other attribute.
void TP_MEMFREE( TPCHAR *Value )
Function to free the memory allocated by TP_MEMALLOC.
This macro returns the window handle of a window inside Trinc-Prolog to which events can be send if an extension library detects an event. This function also works if it is called from inside another process.
TPBOOL TP_API TPExtensionStart( TPINT32 EngineId ,
TPINIT *Init, TPEXCEPTION *Exc )
This functions is called after an extension library was loaded, the first argument is a
Trinc-Prolog engine identifier. The second argument is an initialization
structure. The third argument is an exception structure. If
FALSE was returned, then the exception structure must be filled with an exception goal to
prove. For instance: 'instantiation_error.'
TPBOOL TP_API TPExtensionStop ( TPINT32 Engine )
Called when extension library is unloaded, argument is a Trinc-Prolog engine identifier.
TPINT TP_API <myClause>( TPINT32 Version, TPCALL *Call, TPARGUMENT
*First, TPEXCEPTION *Exc )
Type of function that implements a prolog clause or a class method. The first argument is
a version number, the second a TPCALL structure with the prolog
engine identifier and the number of arguments. The third parameter is the first argument of a linked list of arguments. The fourth parameter must
be used when an exception must be thrown by Trinc-Prolog. The result code of the function determines how Trinc-Prolog must
continue proving the current goal.
TPINT TP_API new_<myClass>( TPINT32 Version, TPINT32 EngineId, TPINT TrincPrologId, TPEXCEPTION *Exc )
Function that is called to create a new instance of a class, the first parameter is the
version parameter, the second parameter is an identifier of the current Trinc-Prolog
engine, the third parameter is the instance identifier that Trinc-Prolog has assigned to
the new instance and the last parameter is an exception
parameter so that exceptions can be thrown. The result of the function is an instance
identifier for the instance created by the extension library, if no instance could be
created then must 0 be returned.
The name of the function must be: "new_<classname>", for instance: if the
class is "myClass" then the function must be called "new_myClass".
void TP_API delete_<myClass>( TPINT32 Version, TPINT32 EngineId, TPINT TrincPrologId, TPINT myId )
Function to delete an instance of a class, the first parameter is the version identifier, the second parameter is the Trinc-Prolog engine identifier, the third parameter is a Trinc-Prolog instance identifier and the fourth parameter is the instance identifier of the extension library.