*** empty log message ***
authorClaus Gittinger <cg@exept.de>
Tue, 25 Apr 2006 14:42:31 +0200
changeset 9323 71e2a9e2aa57
parent 9322 41c391bfbf03
child 9324 96279896d95f
*** empty log message ***
ExternalFunction.st
--- a/ExternalFunction.st	Tue Apr 25 12:33:27 2006 +0200
+++ b/ExternalFunction.st	Tue Apr 25 14:42:31 2006 +0200
@@ -134,16 +134,18 @@
 "
     Instances of this class represent external (non-Smalltalk) functions.
 
-    Also, the class provides access to custom functions
+    (Obsolete) Custom Functions:
+    This class also provides access to custom functions.
     These custom functions enable you to call c functions
-    even if no stc compiler is available
-    (they are kind of what user-primitives are in ST-80).
-    You can register your own custom C-functions in a private main.c
-    and relink ST/X from the binaries.
+    even if no stc compiler is available (they are kind of what user-primitives are in ST-80).
+    You can register your own custom C-functions in a private main.c and relink ST/X from the binaries.
     (see the demo functions provided in main.c).
+    Notice, that custom functions are ugly and inflexible.
+    They are to be considered obsolete and support for them will vanish.
 
-    If you have the stc compiler, we recommend using inline primitive
-    code: its much easier to enter, compile, debug and maintain.
+    If you have the stc compiler, we recommend using either inline primitive
+    code or the new external function call interface which is based upon libffi.
+    Both are easier to enter, compile, debug and maintain.
     (especially, to maintain, since the primitive code is contained
      in the classes source/object file - while custom functions are
      external to the classLibraries).
@@ -183,8 +185,7 @@
 
 
     - This is still in construction and NOT yet published for
-      general use. For now, either use inline C-code, or use the customFunction call
-      mechanism.
+      general use. For now, use inline C-code.
 
     [author:]
 	Claus Gittinger
@@ -460,9 +461,9 @@
 
     func = (LINTFUNC) __INST(code_);
     if (func) {
-        cArg = convertST_to_C(arg);
-        retVal = (*func)(&cArg);
-        RETURN (__MKINT(retVal));
+	cArg = convertST_to_C(arg);
+	retVal = (*func)(&cArg);
+	RETURN (__MKINT(retVal));
     }
 %}.
     self primitiveFailed
@@ -488,10 +489,10 @@
 
     func = (LINTFUNC) __INST(code_);
     if (func) {
-        cArg = convertST_to_C(arg);
-        cArg2 = convertST_to_C(arg2);
-        retVal = (*func)(&cArg, &cArg2);
-        RETURN (__MKINT(retVal));
+	cArg = convertST_to_C(arg);
+	cArg2 = convertST_to_C(arg2);
+	retVal = (*func)(&cArg, &cArg2);
+	RETURN (__MKINT(retVal));
     }
 %}.
     self primitiveFailed
@@ -517,11 +518,11 @@
 
     func = (LINTFUNC) __INST(code_);
     if (func) {
-        cArg = convertST_to_C(arg);
-        cArg2 = convertST_to_C(arg2);
-        cArg3 = convertST_to_C(arg3);
-        retVal = (*func)(&cArg, &cArg2, &cArg3);
-        RETURN (__MKINT(retVal));
+	cArg = convertST_to_C(arg);
+	cArg2 = convertST_to_C(arg2);
+	cArg3 = convertST_to_C(arg3);
+	retVal = (*func)(&cArg, &cArg2, &cArg3);
+	RETURN (__MKINT(retVal));
     }
 %}.
     self primitiveFailed
@@ -548,61 +549,61 @@
 
     func = (LINTFUNC) __INST(code_);
     if (func && __isArray(argArray)) {
-        int n = __arraySize(argArray);
-        int i;
+	int n = __arraySize(argArray);
+	int i;
 
-        if (n <= 10) {
-            ap = __ArrayInstPtr(argArray)->a_element;
-            for (i=0; i<NUMARGS; i++) {
-                args[i] = convertST_to_C(*ap++);
-            }
-        }
-        switch (n) {
-            case 0:
-                retVal = (*func)();
-                break;
-            case 1:
-                retVal = (*func)(&args[0]);
-                break;
-            case 2:
-                retVal = (*func)(&args[0], &args[1]);
-                break;
-            case 3:
-                retVal = (*func)(&args[0], &args[1], &args[2]);
-                break;
-            case 4:
-                retVal = (*func)(&args[0], &args[1], &args[2], &args[3]);
-                break;
-            case 5:
-                retVal = (*func)(&args[0], &args[1], &args[2], &args[3],
-                                 &args[4]);
-                break;
-            case 6:
-                retVal = (*func)(&args[0], &args[1], &args[2], &args[3],
-                                 &args[4], &args[5]);
-                break;
-            case 7:
-                retVal = (*func)(&args[0], &args[1],& args[2], &args[3],
-                                 &args[4], &args[5], &args[6]);
-                break;
-            case 8:
-                retVal = (*func)(&args[0], &args[1], &args[2], &args[3],
-                                 &args[4], &args[5], &args[6], &args[7]);
-                break;
-            case 9:
-                retVal = (*func)(&args[0], &args[1], &args[2], &args[3],
-                                 &args[4], &args[5], &args[6], &args[7],
-                                 &args[8]);
-                break;
-            case 10:
-                retVal = (*func)(&args[0], &args[1], &args[2], &args[3],
-                                 &args[4], &args[5], &args[6], &args[7],
-                                 &args[8], &args[9]);
-                break;
-            default:
-                goto err;
-        }
-        RETURN (__MKINT(retVal));
+	if (n <= 10) {
+	    ap = __ArrayInstPtr(argArray)->a_element;
+	    for (i=0; i<NUMARGS; i++) {
+		args[i] = convertST_to_C(*ap++);
+	    }
+	}
+	switch (n) {
+	    case 0:
+		retVal = (*func)();
+		break;
+	    case 1:
+		retVal = (*func)(&args[0]);
+		break;
+	    case 2:
+		retVal = (*func)(&args[0], &args[1]);
+		break;
+	    case 3:
+		retVal = (*func)(&args[0], &args[1], &args[2]);
+		break;
+	    case 4:
+		retVal = (*func)(&args[0], &args[1], &args[2], &args[3]);
+		break;
+	    case 5:
+		retVal = (*func)(&args[0], &args[1], &args[2], &args[3],
+				 &args[4]);
+		break;
+	    case 6:
+		retVal = (*func)(&args[0], &args[1], &args[2], &args[3],
+				 &args[4], &args[5]);
+		break;
+	    case 7:
+		retVal = (*func)(&args[0], &args[1],& args[2], &args[3],
+				 &args[4], &args[5], &args[6]);
+		break;
+	    case 8:
+		retVal = (*func)(&args[0], &args[1], &args[2], &args[3],
+				 &args[4], &args[5], &args[6], &args[7]);
+		break;
+	    case 9:
+		retVal = (*func)(&args[0], &args[1], &args[2], &args[3],
+				 &args[4], &args[5], &args[6], &args[7],
+				 &args[8]);
+		break;
+	    case 10:
+		retVal = (*func)(&args[0], &args[1], &args[2], &args[3],
+				 &args[4], &args[5], &args[6], &args[7],
+				 &args[8], &args[9]);
+		break;
+	    default:
+		goto err;
+	}
+	RETURN (__MKINT(retVal));
     }
   err: ;
 %}.
@@ -960,7 +961,7 @@
 !ExternalFunction class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libbasic/ExternalFunction.st,v 1.23 2005-07-08 17:15:01 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libbasic/ExternalFunction.st,v 1.24 2006-04-25 12:42:31 cg Exp $'
 ! !
 
 ExternalFunction initialize!