1
0
mirror of synced 2026-01-19 01:47:07 +00:00
Interlisp.medley/docs/internal/CALL-C-SPEC.TEDIT

5 lines
5.0 KiB
Plaintext
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

The Call-C-Function MISCN opcode
This opcode calls the specified C function, performaing conversion of arguments and result as needed, and returning an indication of any errors it encounters.
(MISCN CALL-C Function Conversion-spec Return-Code &REST Args-To-C-Fn)
Function is a Lisp integer (FIXP or SMALLP) containing the address of the function to be called. CALL-C checks for some special values, 0 (meaning the function was never loaded) and -1 (meaning the function was loaded once, and subsequently unloaded at user request), and -2 (meaning that the function has been loaded, but there are unresolved externals).
Conversion-spec specifies how the arguments and function-result are to be converted.
This is a Lisp pointer to a block of 16-bit entries:
+------------------------+
+ Result Conversion Spec |
+------------------------+
| Arg 0 Conversion |
+------------------------+
| Arg 1 Conversion |
+------------------------+
| etc. |
+------------------------+
| -0- |
+------------------------+
Possible values for the conversion fields:
0 VOID (return only, return NIL)
1 int (Lisp SMALLP/FIXP <=> 32-bit integer)
2 char (Lisp SMALLP/CHARACTER <=> char)
3 float
4 long
5 short
6 lisp
7 cpointer
Return-Code is a FIXP cell into which CALL-C places a return value. Possible values are:
0 Successful call and return
+n conversion error on argument n
-1 conversion error on result
-2 signal encountered while running C??
DEFFOREIGNÿÿï%Define a foreign function for lisp.ÿ
This macro tells Medley about a foreign functionÿÿï%its arguments, what type of result it returns, etc. It also creates a Medley function you can call to invoke the foreign functionÿ.
(DEFFOREIGN Function Result-Type ArgList &KEY :function-name)
Function is a symbol, the Lisp name for the function. Function is given a definition that results in the foreign function being called. Function returns what the foreign function returns, after conversion to a Lisp datatype.
Result-Type is a symbol specifying what type of data the foreign function returns, and how it is to be converted to a Lisp type. Possible values are:
:void The function returns no interesting value. Function will always return NIL.
:long
:short
:int The function returns an integer. It is converted to a FIXP or a SMALLP.
:char The function returns a character. It is converted to a SMALLP.
:float The function returns a floating-point number. It is converted to a Lisp FLOATP.
:lisp The function returns a lisp-pointer, which isn't converted, but DOES get reference counted.
:byte ?? same as character, but converted to what??
:cpointer The function returns a pointer to a block of storage not in the Lisp virtual memory image. This may be a pointer to a C structure, or whatever. It is intended for use with CBLOCKRECORD and DEFCSTRUCT
<c type> Where <C type> is a type defined using DEFCSTRUCT. The result is a pointer to a block of storage no in the Lisp virtual memory image....
ArgList is a list of symbols, each specifying what kind of data the foreign function expects for a given argument. The possible values are as above.
Function-name is a symbol or string containing the true name (as far as the foreign language is concerned) of the function you want to call when the Lisp Function is called.5HÔBH, -Ô T,Ô ,TITAN GACHA CLASSIC CLASSIC MODERNVH(DEFAULTFONT 1 (GACHA 10) (GACHA 8) (TERMINAL 8) (POSTSCRIPT (GACHA 8)))
!Ÿ$ ]F5+!,(  O"(
K0  /KQ ŒNJAR]/
¯ 
<00>
<00> 
¬‡zº