ExternalFunction.st
author Claus Gittinger <cg@exept.de>
Tue, 09 Jul 2019 20:55:17 +0200
changeset 24417 03b083548da2
parent 21623 0fd2de531f9a
permissions -rw-r--r--
#REFACTORING by exept class: Smalltalk class changed: #recursiveInstallAutoloadedClassesFrom:rememberIn:maxLevels:noAutoload:packageTop:showSplashInLevels: Transcript showCR:(... bindWith:...) -> Transcript showCR:... with:...
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
20510
3c745c287254 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 19480
diff changeset
     1
"{ Encoding: utf8 }"
3c745c287254 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 19480
diff changeset
     2
848
76a83f34c26a moved ExtBytes & ExtFunc from libbasic2
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     3
"
76a83f34c26a moved ExtBytes & ExtFunc from libbasic2
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     4
 COPYRIGHT (c) 1994 by Claus Gittinger
76a83f34c26a moved ExtBytes & ExtFunc from libbasic2
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     5
	      All Rights Reserved
76a83f34c26a moved ExtBytes & ExtFunc from libbasic2
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     6
76a83f34c26a moved ExtBytes & ExtFunc from libbasic2
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     7
 This software is furnished under a license and may be used
76a83f34c26a moved ExtBytes & ExtFunc from libbasic2
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     8
 only in accordance with the terms of that license and with the
76a83f34c26a moved ExtBytes & ExtFunc from libbasic2
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     9
 inclusion of the above copyright notice.   This software may not
76a83f34c26a moved ExtBytes & ExtFunc from libbasic2
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    10
 be provided or otherwise made available to, or used by, any
76a83f34c26a moved ExtBytes & ExtFunc from libbasic2
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    11
 other person.  No title to or ownership of the software is
76a83f34c26a moved ExtBytes & ExtFunc from libbasic2
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    12
 hereby transferred.
76a83f34c26a moved ExtBytes & ExtFunc from libbasic2
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    13
"
7257
b9f0fb923c72 method category rename
Claus Gittinger <cg@exept.de>
parents: 5164
diff changeset
    14
"{ Package: 'stx:libbasic' }"
b9f0fb923c72 method category rename
Claus Gittinger <cg@exept.de>
parents: 5164
diff changeset
    15
20510
3c745c287254 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 19480
diff changeset
    16
"{ NameSpace: Smalltalk }"
3c745c287254 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 19480
diff changeset
    17
848
76a83f34c26a moved ExtBytes & ExtFunc from libbasic2
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    18
ExecutableFunction subclass:#ExternalFunction
1542
cdcf4ad7556f need name & moduleHandle for the ObjectFileLoader to be able to recreate
Claus Gittinger <cg@exept.de>
parents: 1317
diff changeset
    19
	instanceVariableNames:'name moduleHandle'
1184
e15a6702c812 subclasses of fixed classes are still possible
Claus Gittinger <cg@exept.de>
parents: 1133
diff changeset
    20
	classVariableNames:'InvalidCustomFunctionSignal'
e15a6702c812 subclasses of fixed classes are still possible
Claus Gittinger <cg@exept.de>
parents: 1133
diff changeset
    21
	poolDictionaries:''
e15a6702c812 subclasses of fixed classes are still possible
Claus Gittinger <cg@exept.de>
parents: 1133
diff changeset
    22
	category:'System-Support'
848
76a83f34c26a moved ExtBytes & ExtFunc from libbasic2
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    23
!
3612
5d6fc1e8e578 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2880
diff changeset
    24
2880
87d9ea943024 alpha stuff
Claus Gittinger <cg@exept.de>
parents: 2769
diff changeset
    25
!ExternalFunction primitiveDefinitions!
87d9ea943024 alpha stuff
Claus Gittinger <cg@exept.de>
parents: 2769
diff changeset
    26
%{
87d9ea943024 alpha stuff
Claus Gittinger <cg@exept.de>
parents: 2769
diff changeset
    27
typedef INT  (*LINTFUNC)();
87d9ea943024 alpha stuff
Claus Gittinger <cg@exept.de>
parents: 2769
diff changeset
    28
%}
87d9ea943024 alpha stuff
Claus Gittinger <cg@exept.de>
parents: 2769
diff changeset
    29
! !
848
76a83f34c26a moved ExtBytes & ExtFunc from libbasic2
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    30
76a83f34c26a moved ExtBytes & ExtFunc from libbasic2
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    31
!ExternalFunction primitiveFunctions!
76a83f34c26a moved ExtBytes & ExtFunc from libbasic2
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    32
%{
76a83f34c26a moved ExtBytes & ExtFunc from libbasic2
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    33
76a83f34c26a moved ExtBytes & ExtFunc from libbasic2
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    34
/*
76a83f34c26a moved ExtBytes & ExtFunc from libbasic2
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    35
 * given an ST-object, make something useful for C
76a83f34c26a moved ExtBytes & ExtFunc from libbasic2
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    36
 * cast it to an int
76a83f34c26a moved ExtBytes & ExtFunc from libbasic2
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    37
 *
76a83f34c26a moved ExtBytes & ExtFunc from libbasic2
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    38
 * CAVEAT: floats are not allowed.
76a83f34c26a moved ExtBytes & ExtFunc from libbasic2
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    39
 */
2769
2fd416e4b589 alpha64 changes
Claus Gittinger <cg@exept.de>
parents: 1547
diff changeset
    40
INT
8534
dcb1cbd43198 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7665
diff changeset
    41
convertST_to_C(stObj)
848
76a83f34c26a moved ExtBytes & ExtFunc from libbasic2
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    42
    OBJ stObj;
76a83f34c26a moved ExtBytes & ExtFunc from libbasic2
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    43
{
7665
18f5805b3920 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7602
diff changeset
    44
	INT flags, nInst;
18f5805b3920 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7602
diff changeset
    45
	OBJ *oP;
1545
01e11b46ca65 more possible argument types
Claus Gittinger <cg@exept.de>
parents: 1543
diff changeset
    46
7665
18f5805b3920 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7602
diff changeset
    47
	if (__isString(stObj) || __isSymbol(stObj)) {
18f5805b3920 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7602
diff changeset
    48
	    return (INT)(__stringVal(stObj));
18f5805b3920 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7602
diff changeset
    49
	}
18f5805b3920 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7602
diff changeset
    50
	if (__isByteArray(stObj)) {
18f5805b3920 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7602
diff changeset
    51
	    return (INT)(__ByteArrayInstPtr(stObj)->ba_element);
18f5805b3920 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7602
diff changeset
    52
	}
18f5805b3920 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7602
diff changeset
    53
	if (__isExternalBytes(stObj)) {
18f5805b3920 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7602
diff changeset
    54
	    return (INT)(__externalBytesAddress(stObj));
18f5805b3920 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7602
diff changeset
    55
	}
18f5805b3920 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7602
diff changeset
    56
	if (__isExternalAddress(stObj)) {
18f5805b3920 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7602
diff changeset
    57
	    return (INT)(__externalAddressVal(stObj));
18f5805b3920 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7602
diff changeset
    58
	}
18f5805b3920 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7602
diff changeset
    59
	if (__isExternalFunction(stObj)) {
18f5805b3920 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7602
diff changeset
    60
	    return (INT)(__externalFunctionVal(stObj));
18f5805b3920 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7602
diff changeset
    61
	}
18f5805b3920 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7602
diff changeset
    62
	if (__isSmallInteger(stObj)) {
18f5805b3920 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7602
diff changeset
    63
	    return (INT)(__intVal(stObj));
18f5805b3920 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7602
diff changeset
    64
	}
18f5805b3920 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7602
diff changeset
    65
	if (__isLargeInteger(stObj)) {
18f5805b3920 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7602
diff changeset
    66
	    return (INT)(__signedLongIntVal(stObj));
18f5805b3920 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7602
diff changeset
    67
	}
18f5805b3920 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7602
diff changeset
    68
	if (__isCharacter(stObj)) {
18f5805b3920 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7602
diff changeset
    69
	    return (INT)(__intVal(__characterVal(stObj)));
18f5805b3920 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7602
diff changeset
    70
	}
18f5805b3920 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7602
diff changeset
    71
	if (stObj == nil) {
18f5805b3920 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7602
diff changeset
    72
	    return 0;
18f5805b3920 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7602
diff changeset
    73
	}
1545
01e11b46ca65 more possible argument types
Claus Gittinger <cg@exept.de>
parents: 1543
diff changeset
    74
7665
18f5805b3920 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7602
diff changeset
    75
	if (__qClass(stObj) == @global(ShortFloat)) {
18f5805b3920 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7602
diff changeset
    76
	    return (INT)(__shortFloatVal(stObj));
18f5805b3920 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7602
diff changeset
    77
	}
1545
01e11b46ca65 more possible argument types
Claus Gittinger <cg@exept.de>
parents: 1543
diff changeset
    78
7665
18f5805b3920 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7602
diff changeset
    79
	flags = __intVal(__ClassInstPtr(__qClass(stObj))->c_flags) & ARRAYMASK;
18f5805b3920 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7602
diff changeset
    80
	nInst = __intVal(__ClassInstPtr(__qClass(stObj))->c_ninstvars);
18f5805b3920 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7602
diff changeset
    81
	oP = (OBJ *)__InstPtr(stObj)->i_instvars[nInst];
1545
01e11b46ca65 more possible argument types
Claus Gittinger <cg@exept.de>
parents: 1543
diff changeset
    82
7665
18f5805b3920 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7602
diff changeset
    83
	if (flags & FLOATARRAY) {
18f5805b3920 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7602
diff changeset
    84
	    return (INT)(oP);
18f5805b3920 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7602
diff changeset
    85
	}
18f5805b3920 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7602
diff changeset
    86
	if (flags & DOUBLEARRAY) {
18f5805b3920 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7602
diff changeset
    87
	    return (INT)(oP);
18f5805b3920 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7602
diff changeset
    88
	}
18f5805b3920 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7602
diff changeset
    89
	if (flags & DOUBLEARRAY) {
18f5805b3920 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7602
diff changeset
    90
	    return (INT)(oP);
18f5805b3920 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7602
diff changeset
    91
	}
18f5805b3920 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7602
diff changeset
    92
	if (flags & BYTEARRAY) {
18f5805b3920 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7602
diff changeset
    93
	    return (INT)(oP);
18f5805b3920 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7602
diff changeset
    94
	}
18f5805b3920 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7602
diff changeset
    95
	if (flags & WORDARRAY) {
18f5805b3920 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7602
diff changeset
    96
	    return (INT)(oP);
18f5805b3920 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7602
diff changeset
    97
	}
18f5805b3920 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7602
diff changeset
    98
	if (flags & LONGARRAY) {
18f5805b3920 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7602
diff changeset
    99
	    return (INT)(oP);
18f5805b3920 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7602
diff changeset
   100
	}
18f5805b3920 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7602
diff changeset
   101
	if (flags & SWORDARRAY) {
18f5805b3920 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7602
diff changeset
   102
	    return (INT)(oP);
18f5805b3920 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7602
diff changeset
   103
	}
18f5805b3920 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7602
diff changeset
   104
	if (flags & SLONGARRAY) {
18f5805b3920 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7602
diff changeset
   105
	    return (INT)(oP);
18f5805b3920 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7602
diff changeset
   106
	}
1545
01e11b46ca65 more possible argument types
Claus Gittinger <cg@exept.de>
parents: 1543
diff changeset
   107
7665
18f5805b3920 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7602
diff changeset
   108
	if (stObj == true) {
18f5805b3920 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7602
diff changeset
   109
	    return 1;
18f5805b3920 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7602
diff changeset
   110
	}
18f5805b3920 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7602
diff changeset
   111
	if (stObj == false) {
18f5805b3920 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7602
diff changeset
   112
	    return 0;
18f5805b3920 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7602
diff changeset
   113
	}
18f5805b3920 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7602
diff changeset
   114
	return 0;
848
76a83f34c26a moved ExtBytes & ExtFunc from libbasic2
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   115
}
76a83f34c26a moved ExtBytes & ExtFunc from libbasic2
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   116
8534
dcb1cbd43198 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7665
diff changeset
   117
%}
848
76a83f34c26a moved ExtBytes & ExtFunc from libbasic2
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   118
! !
76a83f34c26a moved ExtBytes & ExtFunc from libbasic2
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   119
3612
5d6fc1e8e578 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2880
diff changeset
   120
!ExternalFunction class methodsFor:'documentation'!
848
76a83f34c26a moved ExtBytes & ExtFunc from libbasic2
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   121
76a83f34c26a moved ExtBytes & ExtFunc from libbasic2
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   122
copyright
76a83f34c26a moved ExtBytes & ExtFunc from libbasic2
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   123
"
76a83f34c26a moved ExtBytes & ExtFunc from libbasic2
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   124
 COPYRIGHT (c) 1994 by Claus Gittinger
76a83f34c26a moved ExtBytes & ExtFunc from libbasic2
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   125
	      All Rights Reserved
76a83f34c26a moved ExtBytes & ExtFunc from libbasic2
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   126
76a83f34c26a moved ExtBytes & ExtFunc from libbasic2
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   127
 This software is furnished under a license and may be used
76a83f34c26a moved ExtBytes & ExtFunc from libbasic2
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   128
 only in accordance with the terms of that license and with the
76a83f34c26a moved ExtBytes & ExtFunc from libbasic2
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   129
 inclusion of the above copyright notice.   This software may not
76a83f34c26a moved ExtBytes & ExtFunc from libbasic2
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   130
 be provided or otherwise made available to, or used by, any
76a83f34c26a moved ExtBytes & ExtFunc from libbasic2
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   131
 other person.  No title to or ownership of the software is
76a83f34c26a moved ExtBytes & ExtFunc from libbasic2
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   132
 hereby transferred.
76a83f34c26a moved ExtBytes & ExtFunc from libbasic2
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   133
"
76a83f34c26a moved ExtBytes & ExtFunc from libbasic2
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   134
!
76a83f34c26a moved ExtBytes & ExtFunc from libbasic2
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   135
76a83f34c26a moved ExtBytes & ExtFunc from libbasic2
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   136
documentation
76a83f34c26a moved ExtBytes & ExtFunc from libbasic2
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   137
"
76a83f34c26a moved ExtBytes & ExtFunc from libbasic2
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   138
    Instances of this class represent external (non-Smalltalk) functions.
76a83f34c26a moved ExtBytes & ExtFunc from libbasic2
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   139
9323
71e2a9e2aa57 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8913
diff changeset
   140
    (Obsolete) Custom Functions:
21623
0fd2de531f9a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 20957
diff changeset
   141
	This class also provides access to custom functions.
0fd2de531f9a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 20957
diff changeset
   142
	These custom functions enable you to call c functions
0fd2de531f9a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 20957
diff changeset
   143
	even if no stc compiler is available (they are kind of what user-primitives are in ST-80).
0fd2de531f9a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 20957
diff changeset
   144
	You can register your own custom C-functions in a private main.c and relink ST/X from the binaries.
0fd2de531f9a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 20957
diff changeset
   145
	(see the demo functions provided in main.c).
0fd2de531f9a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 20957
diff changeset
   146
	Notice, that custom functions are ugly and inflexible.
0fd2de531f9a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 20957
diff changeset
   147
	They are to be considered obsolete and support for them will vanish.
848
76a83f34c26a moved ExtBytes & ExtFunc from libbasic2
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   148
9323
71e2a9e2aa57 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8913
diff changeset
   149
    If you have the stc compiler, we recommend using either inline primitive
71e2a9e2aa57 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8913
diff changeset
   150
    code or the new external function call interface which is based upon libffi.
71e2a9e2aa57 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8913
diff changeset
   151
    Both are easier to enter, compile, debug and maintain.
1257
f98014b76dd1 commentary
Claus Gittinger <cg@exept.de>
parents: 1184
diff changeset
   152
    (especially, to maintain, since the primitive code is contained
8534
dcb1cbd43198 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7665
diff changeset
   153
     in the classes source/object file - while custom functions are
1257
f98014b76dd1 commentary
Claus Gittinger <cg@exept.de>
parents: 1184
diff changeset
   154
     external to the classLibraries).
848
76a83f34c26a moved ExtBytes & ExtFunc from libbasic2
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   155
8534
dcb1cbd43198 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7665
diff changeset
   156
    Non custom externalFunctions are created, when a non-ST shared library is loaded,
1545
01e11b46ca65 more possible argument types
Claus Gittinger <cg@exept.de>
parents: 1543
diff changeset
   157
    and returned by the ObjectFileHandles>>getFunction: method.
01e11b46ca65 more possible argument types
Claus Gittinger <cg@exept.de>
parents: 1543
diff changeset
   158
01e11b46ca65 more possible argument types
Claus Gittinger <cg@exept.de>
parents: 1543
diff changeset
   159
    The C functions contained in that lib are callable (instances of myself)
01e11b46ca65 more possible argument types
Claus Gittinger <cg@exept.de>
parents: 1543
diff changeset
   160
    with the call / callWith: methods.
01e11b46ca65 more possible argument types
Claus Gittinger <cg@exept.de>
parents: 1543
diff changeset
   161
01e11b46ca65 more possible argument types
Claus Gittinger <cg@exept.de>
parents: 1543
diff changeset
   162
    ST-arguments are converted to C as follows:
21623
0fd2de531f9a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 20957
diff changeset
   163
	ST class            C argument
0fd2de531f9a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 20957
diff changeset
   164
	------------------------------
0fd2de531f9a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 20957
diff changeset
   165
	SmallInteger        int
0fd2de531f9a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 20957
diff changeset
   166
	LargeInteger        int (must be 4-byte unsigned largeInteger)
0fd2de531f9a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 20957
diff changeset
   167
	String              char *
0fd2de531f9a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 20957
diff changeset
   168
	Symbol              char *
0fd2de531f9a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 20957
diff changeset
   169
	Character           int
0fd2de531f9a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 20957
diff changeset
   170
	ExternalBytes       char *
0fd2de531f9a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 20957
diff changeset
   171
	ExternalAddress     char *
0fd2de531f9a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 20957
diff changeset
   172
	ExternalFunction    char *
0fd2de531f9a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 20957
diff changeset
   173
	FloatArray          float *
0fd2de531f9a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 20957
diff changeset
   174
	DoubleArray         double *
0fd2de531f9a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 20957
diff changeset
   175
	ByteArray           char *
0fd2de531f9a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 20957
diff changeset
   176
	ShortFloat          float
0fd2de531f9a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 20957
diff changeset
   177
	true                1
0fd2de531f9a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 20957
diff changeset
   178
	false               0
1545
01e11b46ca65 more possible argument types
Claus Gittinger <cg@exept.de>
parents: 1543
diff changeset
   179
01e11b46ca65 more possible argument types
Claus Gittinger <cg@exept.de>
parents: 1543
diff changeset
   180
    The returned value is converted to an unsigned integer (smallInteger or largeInteger).
01e11b46ca65 more possible argument types
Claus Gittinger <cg@exept.de>
parents: 1543
diff changeset
   181
01e11b46ca65 more possible argument types
Claus Gittinger <cg@exept.de>
parents: 1543
diff changeset
   182
    Notice, that no doubles can be passed; the reason is that the calling
01e11b46ca65 more possible argument types
Claus Gittinger <cg@exept.de>
parents: 1543
diff changeset
   183
    conventions (on stack, in registers, in FPU registers etc.) are so different among
8534
dcb1cbd43198 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7665
diff changeset
   184
    machines (and even compilers), that a general solution is not possible (difficult)
1545
01e11b46ca65 more possible argument types
Claus Gittinger <cg@exept.de>
parents: 1543
diff changeset
   185
    to program here. To pass doubles, either use shortFloats, or pack them into a DoubleArray.
01e11b46ca65 more possible argument types
Claus Gittinger <cg@exept.de>
parents: 1543
diff changeset
   186
    For functions with up to 2 double arguments, specialized call methods are provided.
01e11b46ca65 more possible argument types
Claus Gittinger <cg@exept.de>
parents: 1543
diff changeset
   187
    Sorry for that inconvenience.
8534
dcb1cbd43198 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7665
diff changeset
   188
1545
01e11b46ca65 more possible argument types
Claus Gittinger <cg@exept.de>
parents: 1543
diff changeset
   189
8534
dcb1cbd43198 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7665
diff changeset
   190
    - This is still in construction and NOT yet published for
9323
71e2a9e2aa57 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8913
diff changeset
   191
      general use. For now, use inline C-code.
1286
4270a0b4917d documentation
Claus Gittinger <cg@exept.de>
parents: 1267
diff changeset
   192
4270a0b4917d documentation
Claus Gittinger <cg@exept.de>
parents: 1267
diff changeset
   193
    [author:]
21623
0fd2de531f9a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 20957
diff changeset
   194
	Claus Gittinger
1317
cc737e0fdf48 examples
Claus Gittinger <cg@exept.de>
parents: 1286
diff changeset
   195
cc737e0fdf48 examples
Claus Gittinger <cg@exept.de>
parents: 1286
diff changeset
   196
    [see also:]
21623
0fd2de531f9a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 20957
diff changeset
   197
	ExternalAddress ExternalBytes
0fd2de531f9a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 20957
diff changeset
   198
	( how to write primitive code :html: programming/primitive.html )
848
76a83f34c26a moved ExtBytes & ExtFunc from libbasic2
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   199
"
1545
01e11b46ca65 more possible argument types
Claus Gittinger <cg@exept.de>
parents: 1543
diff changeset
   200
!
01e11b46ca65 more possible argument types
Claus Gittinger <cg@exept.de>
parents: 1543
diff changeset
   201
01e11b46ca65 more possible argument types
Claus Gittinger <cg@exept.de>
parents: 1543
diff changeset
   202
examples
01e11b46ca65 more possible argument types
Claus Gittinger <cg@exept.de>
parents: 1543
diff changeset
   203
"
01e11b46ca65 more possible argument types
Claus Gittinger <cg@exept.de>
parents: 1543
diff changeset
   204
    see a sample demo c file in doc/coding/cModules;
01e11b46ca65 more possible argument types
Claus Gittinger <cg@exept.de>
parents: 1543
diff changeset
   205
    compile and link (shared) it to an object module.
01e11b46ca65 more possible argument types
Claus Gittinger <cg@exept.de>
parents: 1543
diff changeset
   206
    Load it into the system:
01e11b46ca65 more possible argument types
Claus Gittinger <cg@exept.de>
parents: 1543
diff changeset
   207
01e11b46ca65 more possible argument types
Claus Gittinger <cg@exept.de>
parents: 1543
diff changeset
   208
	handle := ObjectFileLoader loadDynamicObject:'demo1.o'.
01e11b46ca65 more possible argument types
Claus Gittinger <cg@exept.de>
parents: 1543
diff changeset
   209
01e11b46ca65 more possible argument types
Claus Gittinger <cg@exept.de>
parents: 1543
diff changeset
   210
    get a C-function (an instance of ExternalFunction):
01e11b46ca65 more possible argument types
Claus Gittinger <cg@exept.de>
parents: 1543
diff changeset
   211
01e11b46ca65 more possible argument types
Claus Gittinger <cg@exept.de>
parents: 1543
diff changeset
   212
	f := handle getFunction:'function1'.
01e11b46ca65 more possible argument types
Claus Gittinger <cg@exept.de>
parents: 1543
diff changeset
   213
01e11b46ca65 more possible argument types
Claus Gittinger <cg@exept.de>
parents: 1543
diff changeset
   214
    call it:
8534
dcb1cbd43198 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7665
diff changeset
   215
1545
01e11b46ca65 more possible argument types
Claus Gittinger <cg@exept.de>
parents: 1543
diff changeset
   216
	f callWith:999
01e11b46ca65 more possible argument types
Claus Gittinger <cg@exept.de>
parents: 1543
diff changeset
   217
"
848
76a83f34c26a moved ExtBytes & ExtFunc from libbasic2
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   218
! !
76a83f34c26a moved ExtBytes & ExtFunc from libbasic2
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   219
3612
5d6fc1e8e578 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2880
diff changeset
   220
!ExternalFunction class methodsFor:'initialization'!
848
76a83f34c26a moved ExtBytes & ExtFunc from libbasic2
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   221
76a83f34c26a moved ExtBytes & ExtFunc from libbasic2
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   222
initialize
1257
f98014b76dd1 commentary
Claus Gittinger <cg@exept.de>
parents: 1184
diff changeset
   223
    "create signals"
f98014b76dd1 commentary
Claus Gittinger <cg@exept.de>
parents: 1184
diff changeset
   224
848
76a83f34c26a moved ExtBytes & ExtFunc from libbasic2
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   225
    InvalidCustomFunctionSignal isNil ifTrue:[
7665
18f5805b3920 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7602
diff changeset
   226
	InvalidCustomFunctionSignal := ExecutionError newSignalMayProceed:true.
18f5805b3920 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7602
diff changeset
   227
	InvalidCustomFunctionSignal nameClass:self message:#invalidCustomFunctionSignal.
18f5805b3920 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7602
diff changeset
   228
	InvalidCustomFunctionSignal notifierString:'attempt to execute unknown custom function'.
848
76a83f34c26a moved ExtBytes & ExtFunc from libbasic2
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   229
    ]
1257
f98014b76dd1 commentary
Claus Gittinger <cg@exept.de>
parents: 1184
diff changeset
   230
f98014b76dd1 commentary
Claus Gittinger <cg@exept.de>
parents: 1184
diff changeset
   231
    "Modified: 22.4.1996 / 18:08:55 / cg"
848
76a83f34c26a moved ExtBytes & ExtFunc from libbasic2
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   232
! !
76a83f34c26a moved ExtBytes & ExtFunc from libbasic2
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   233
3612
5d6fc1e8e578 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2880
diff changeset
   234
!ExternalFunction class methodsFor:'Signal constants'!
848
76a83f34c26a moved ExtBytes & ExtFunc from libbasic2
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   235
76a83f34c26a moved ExtBytes & ExtFunc from libbasic2
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   236
invalidCustomFunctionSignal
76a83f34c26a moved ExtBytes & ExtFunc from libbasic2
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   237
    "return the signal raised when a non existent custom function is
76a83f34c26a moved ExtBytes & ExtFunc from libbasic2
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   238
     called for."
76a83f34c26a moved ExtBytes & ExtFunc from libbasic2
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   239
76a83f34c26a moved ExtBytes & ExtFunc from libbasic2
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   240
    ^ InvalidCustomFunctionSignal
76a83f34c26a moved ExtBytes & ExtFunc from libbasic2
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   241
! !
76a83f34c26a moved ExtBytes & ExtFunc from libbasic2
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   242
3612
5d6fc1e8e578 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2880
diff changeset
   243
!ExternalFunction class methodsFor:'calling custom functions'!
848
76a83f34c26a moved ExtBytes & ExtFunc from libbasic2
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   244
76a83f34c26a moved ExtBytes & ExtFunc from libbasic2
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   245
callCustomFunction:nr
19480
dedfb6c4bc16 custom functions
Claus Gittinger <cg@exept.de>
parents: 12484
diff changeset
   246
    "call the custom function #nr without arguments.
dedfb6c4bc16 custom functions
Claus Gittinger <cg@exept.de>
parents: 12484
diff changeset
   247
     See main.c for examples."
1257
f98014b76dd1 commentary
Claus Gittinger <cg@exept.de>
parents: 1184
diff changeset
   248
848
76a83f34c26a moved ExtBytes & ExtFunc from libbasic2
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   249
    ^ self callCustomFunction:nr withArguments:#()
76a83f34c26a moved ExtBytes & ExtFunc from libbasic2
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   250
76a83f34c26a moved ExtBytes & ExtFunc from libbasic2
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   251
    "
76a83f34c26a moved ExtBytes & ExtFunc from libbasic2
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   252
     ExternalFunction callCustomFunction:0
8534
dcb1cbd43198 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7665
diff changeset
   253
     ExternalFunction callCustomFunction:999
848
76a83f34c26a moved ExtBytes & ExtFunc from libbasic2
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   254
    "
1257
f98014b76dd1 commentary
Claus Gittinger <cg@exept.de>
parents: 1184
diff changeset
   255
f98014b76dd1 commentary
Claus Gittinger <cg@exept.de>
parents: 1184
diff changeset
   256
    "Modified: 22.4.1996 / 18:06:52 / cg"
848
76a83f34c26a moved ExtBytes & ExtFunc from libbasic2
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   257
!
76a83f34c26a moved ExtBytes & ExtFunc from libbasic2
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   258
76a83f34c26a moved ExtBytes & ExtFunc from libbasic2
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   259
callCustomFunction:nr with:arg
19480
dedfb6c4bc16 custom functions
Claus Gittinger <cg@exept.de>
parents: 12484
diff changeset
   260
    "call the custom function #nr with a single argument.
dedfb6c4bc16 custom functions
Claus Gittinger <cg@exept.de>
parents: 12484
diff changeset
   261
     See main.c for examples."
1257
f98014b76dd1 commentary
Claus Gittinger <cg@exept.de>
parents: 1184
diff changeset
   262
848
76a83f34c26a moved ExtBytes & ExtFunc from libbasic2
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   263
    ^ self callCustomFunction:nr withArguments:(Array with:arg)
76a83f34c26a moved ExtBytes & ExtFunc from libbasic2
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   264
76a83f34c26a moved ExtBytes & ExtFunc from libbasic2
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   265
    "
76a83f34c26a moved ExtBytes & ExtFunc from libbasic2
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   266
     ExternalFunction callCustomFunction:1 with:'hello world'
76a83f34c26a moved ExtBytes & ExtFunc from libbasic2
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   267
    "
1257
f98014b76dd1 commentary
Claus Gittinger <cg@exept.de>
parents: 1184
diff changeset
   268
f98014b76dd1 commentary
Claus Gittinger <cg@exept.de>
parents: 1184
diff changeset
   269
    "Modified: 22.4.1996 / 18:07:03 / cg"
848
76a83f34c26a moved ExtBytes & ExtFunc from libbasic2
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   270
!
76a83f34c26a moved ExtBytes & ExtFunc from libbasic2
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   271
76a83f34c26a moved ExtBytes & ExtFunc from libbasic2
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   272
callCustomFunction:nr with:arg1 with:arg2
19480
dedfb6c4bc16 custom functions
Claus Gittinger <cg@exept.de>
parents: 12484
diff changeset
   273
    "call the custom function #nr with two arguments.
dedfb6c4bc16 custom functions
Claus Gittinger <cg@exept.de>
parents: 12484
diff changeset
   274
     See main.c for examples."
1257
f98014b76dd1 commentary
Claus Gittinger <cg@exept.de>
parents: 1184
diff changeset
   275
848
76a83f34c26a moved ExtBytes & ExtFunc from libbasic2
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   276
    ^ self callCustomFunction:nr withArguments:(Array with:arg1 with:arg2)
76a83f34c26a moved ExtBytes & ExtFunc from libbasic2
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   277
76a83f34c26a moved ExtBytes & ExtFunc from libbasic2
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   278
    "
76a83f34c26a moved ExtBytes & ExtFunc from libbasic2
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   279
     ExternalFunction callCustomFunction:2 with:(Float pi) with:1.0
76a83f34c26a moved ExtBytes & ExtFunc from libbasic2
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   280
    "
1257
f98014b76dd1 commentary
Claus Gittinger <cg@exept.de>
parents: 1184
diff changeset
   281
f98014b76dd1 commentary
Claus Gittinger <cg@exept.de>
parents: 1184
diff changeset
   282
    "Modified: 22.4.1996 / 18:07:11 / cg"
848
76a83f34c26a moved ExtBytes & ExtFunc from libbasic2
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   283
!
76a83f34c26a moved ExtBytes & ExtFunc from libbasic2
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   284
76a83f34c26a moved ExtBytes & ExtFunc from libbasic2
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   285
callCustomFunction:nr with:arg1 with:arg2 with:arg3
19480
dedfb6c4bc16 custom functions
Claus Gittinger <cg@exept.de>
parents: 12484
diff changeset
   286
    "call the custom function #nr with three arguments.
dedfb6c4bc16 custom functions
Claus Gittinger <cg@exept.de>
parents: 12484
diff changeset
   287
     See main.c for examples."
1257
f98014b76dd1 commentary
Claus Gittinger <cg@exept.de>
parents: 1184
diff changeset
   288
8534
dcb1cbd43198 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7665
diff changeset
   289
    ^ self callCustomFunction:nr
7665
18f5805b3920 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7602
diff changeset
   290
		withArguments:(Array with:arg1 with:arg2 with:arg3)
1257
f98014b76dd1 commentary
Claus Gittinger <cg@exept.de>
parents: 1184
diff changeset
   291
f98014b76dd1 commentary
Claus Gittinger <cg@exept.de>
parents: 1184
diff changeset
   292
    "Modified: 22.4.1996 / 18:07:18 / cg"
848
76a83f34c26a moved ExtBytes & ExtFunc from libbasic2
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   293
!
76a83f34c26a moved ExtBytes & ExtFunc from libbasic2
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   294
76a83f34c26a moved ExtBytes & ExtFunc from libbasic2
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   295
callCustomFunction:nr withArguments:argArray
19480
dedfb6c4bc16 custom functions
Claus Gittinger <cg@exept.de>
parents: 12484
diff changeset
   296
    "call the custom function #nr with arguments from argArray.
dedfb6c4bc16 custom functions
Claus Gittinger <cg@exept.de>
parents: 12484
diff changeset
   297
     See main.c for examples."
1257
f98014b76dd1 commentary
Claus Gittinger <cg@exept.de>
parents: 1184
diff changeset
   298
19480
dedfb6c4bc16 custom functions
Claus Gittinger <cg@exept.de>
parents: 12484
diff changeset
   299
    |retVal called errCode|
848
76a83f34c26a moved ExtBytes & ExtFunc from libbasic2
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   300
76a83f34c26a moved ExtBytes & ExtFunc from libbasic2
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   301
%{
917
57dd3973f35f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 856
diff changeset
   302
#ifndef __stxNCustomFunctions__
856
d2c9f9ecedcf renamed customFunction-globals
Claus Gittinger <cg@exept.de>
parents: 848
diff changeset
   303
    extern int __stxNCustomFunctions__;
d2c9f9ecedcf renamed customFunction-globals
Claus Gittinger <cg@exept.de>
parents: 848
diff changeset
   304
    extern CUSTOMFUNCTION __stxCustomFunctions__[];
917
57dd3973f35f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 856
diff changeset
   305
#endif
848
76a83f34c26a moved ExtBytes & ExtFunc from libbasic2
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   306
    int (* func)();
76a83f34c26a moved ExtBytes & ExtFunc from libbasic2
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   307
76a83f34c26a moved ExtBytes & ExtFunc from libbasic2
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   308
    called = false;
21623
0fd2de531f9a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 20957
diff changeset
   309
    if (__isSmallInteger(nr) && __isArrayLike(argArray)) {
7665
18f5805b3920 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7602
diff changeset
   310
	int nargs = __arraySize(argArray);
18f5805b3920 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7602
diff changeset
   311
	int functionNr;
848
76a83f34c26a moved ExtBytes & ExtFunc from libbasic2
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   312
7665
18f5805b3920 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7602
diff changeset
   313
	functionNr = __intVal(nr);
18f5805b3920 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7602
diff changeset
   314
	if ((functionNr >= 0) && (functionNr < __stxNCustomFunctions__)) {
18f5805b3920 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7602
diff changeset
   315
	    /*
18f5805b3920 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7602
diff changeset
   316
	     * now, call the function; passing nargs and arg-vector
18f5805b3920 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7602
diff changeset
   317
	     */
18f5805b3920 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7602
diff changeset
   318
	    func = __stxCustomFunctions__[functionNr].func;
18f5805b3920 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7602
diff changeset
   319
	    if (func) {
18f5805b3920 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7602
diff changeset
   320
		int ok;
848
76a83f34c26a moved ExtBytes & ExtFunc from libbasic2
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   321
7665
18f5805b3920 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7602
diff changeset
   322
		retVal = self;
18f5805b3920 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7602
diff changeset
   323
		ok = (*func)(nargs, &retVal, __ArrayInstPtr(argArray)->a_element);
19480
dedfb6c4bc16 custom functions
Claus Gittinger <cg@exept.de>
parents: 12484
diff changeset
   324
		if (ok == 0) {
7665
18f5805b3920 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7602
diff changeset
   325
		    RETURN (retVal);
18f5805b3920 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7602
diff changeset
   326
		}
19480
dedfb6c4bc16 custom functions
Claus Gittinger <cg@exept.de>
parents: 12484
diff changeset
   327
		errCode = __mkSmallInteger(ok);
7665
18f5805b3920 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7602
diff changeset
   328
		called = true;
18f5805b3920 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7602
diff changeset
   329
	    }
18f5805b3920 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7602
diff changeset
   330
	}
848
76a83f34c26a moved ExtBytes & ExtFunc from libbasic2
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   331
    }
76a83f34c26a moved ExtBytes & ExtFunc from libbasic2
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   332
%}.
76a83f34c26a moved ExtBytes & ExtFunc from libbasic2
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   333
    called ifTrue:[
7665
18f5805b3920 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7602
diff changeset
   334
	"
19480
dedfb6c4bc16 custom functions
Claus Gittinger <cg@exept.de>
parents: 12484
diff changeset
   335
	 the customFunction returned non-0 (failure)
dedfb6c4bc16 custom functions
Claus Gittinger <cg@exept.de>
parents: 12484
diff changeset
   336
	    PRIM_OK         0
dedfb6c4bc16 custom functions
Claus Gittinger <cg@exept.de>
parents: 12484
diff changeset
   337
	    PRIM_FAIL       -1
dedfb6c4bc16 custom functions
Claus Gittinger <cg@exept.de>
parents: 12484
diff changeset
   338
	    PRIM_ARGCOUNT   -2
dedfb6c4bc16 custom functions
Claus Gittinger <cg@exept.de>
parents: 12484
diff changeset
   339
	    PRIM_ARGTYPE    -3
7665
18f5805b3920 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7602
diff changeset
   340
	"
19480
dedfb6c4bc16 custom functions
Claus Gittinger <cg@exept.de>
parents: 12484
diff changeset
   341
	errCode == -2 ifTrue:[
dedfb6c4bc16 custom functions
Claus Gittinger <cg@exept.de>
parents: 12484
diff changeset
   342
	    ^ self primitiveFailed:'argument count'
dedfb6c4bc16 custom functions
Claus Gittinger <cg@exept.de>
parents: 12484
diff changeset
   343
	].
dedfb6c4bc16 custom functions
Claus Gittinger <cg@exept.de>
parents: 12484
diff changeset
   344
	errCode == -3 ifTrue:[
dedfb6c4bc16 custom functions
Claus Gittinger <cg@exept.de>
parents: 12484
diff changeset
   345
	    ^ self primitiveFailed:'argument type'
dedfb6c4bc16 custom functions
Claus Gittinger <cg@exept.de>
parents: 12484
diff changeset
   346
	].
7665
18f5805b3920 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7602
diff changeset
   347
	^ self primitiveFailed
848
76a83f34c26a moved ExtBytes & ExtFunc from libbasic2
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   348
    ].
76a83f34c26a moved ExtBytes & ExtFunc from libbasic2
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   349
76a83f34c26a moved ExtBytes & ExtFunc from libbasic2
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   350
    "
76a83f34c26a moved ExtBytes & ExtFunc from libbasic2
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   351
     an invalid customFunction-nr was given,
76a83f34c26a moved ExtBytes & ExtFunc from libbasic2
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   352
    "
76a83f34c26a moved ExtBytes & ExtFunc from libbasic2
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   353
    InvalidCustomFunctionSignal raise
76a83f34c26a moved ExtBytes & ExtFunc from libbasic2
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   354
76a83f34c26a moved ExtBytes & ExtFunc from libbasic2
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   355
    "
76a83f34c26a moved ExtBytes & ExtFunc from libbasic2
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   356
     ExternalFunction callCustomFunction:2 withArguments:#(1.0 1.0)
76a83f34c26a moved ExtBytes & ExtFunc from libbasic2
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   357
     ExternalFunction callCustomFunction:999 withArguments:#(1.0 1.0)
76a83f34c26a moved ExtBytes & ExtFunc from libbasic2
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   358
    "
76a83f34c26a moved ExtBytes & ExtFunc from libbasic2
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   359
!
76a83f34c26a moved ExtBytes & ExtFunc from libbasic2
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   360
76a83f34c26a moved ExtBytes & ExtFunc from libbasic2
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   361
callCustomFunctionNamed:name withArguments:argArray
1257
f98014b76dd1 commentary
Claus Gittinger <cg@exept.de>
parents: 1184
diff changeset
   362
    "call a custom function by name with arguments from argArray"
f98014b76dd1 commentary
Claus Gittinger <cg@exept.de>
parents: 1184
diff changeset
   363
848
76a83f34c26a moved ExtBytes & ExtFunc from libbasic2
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   364
    |index|
76a83f34c26a moved ExtBytes & ExtFunc from libbasic2
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   365
76a83f34c26a moved ExtBytes & ExtFunc from libbasic2
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   366
    index := self indexOfCustomFunctionNamed:name.
76a83f34c26a moved ExtBytes & ExtFunc from libbasic2
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   367
    index notNil ifTrue:[
7665
18f5805b3920 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7602
diff changeset
   368
	^ self callCustomFunction:index withArguments:argArray
848
76a83f34c26a moved ExtBytes & ExtFunc from libbasic2
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   369
    ].
76a83f34c26a moved ExtBytes & ExtFunc from libbasic2
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   370
    "
76a83f34c26a moved ExtBytes & ExtFunc from libbasic2
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   371
     no such function exists
76a83f34c26a moved ExtBytes & ExtFunc from libbasic2
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   372
    "
76a83f34c26a moved ExtBytes & ExtFunc from libbasic2
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   373
    InvalidCustomFunctionSignal raise
76a83f34c26a moved ExtBytes & ExtFunc from libbasic2
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   374
76a83f34c26a moved ExtBytes & ExtFunc from libbasic2
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   375
    "
76a83f34c26a moved ExtBytes & ExtFunc from libbasic2
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   376
     ExternalFunction callCustomFunctionNamed:'demoFunction0'
7665
18f5805b3920 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7602
diff changeset
   377
				withArguments:#()
848
76a83f34c26a moved ExtBytes & ExtFunc from libbasic2
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   378
    "
1257
f98014b76dd1 commentary
Claus Gittinger <cg@exept.de>
parents: 1184
diff changeset
   379
f98014b76dd1 commentary
Claus Gittinger <cg@exept.de>
parents: 1184
diff changeset
   380
    "Modified: 22.4.1996 / 18:08:09 / cg"
848
76a83f34c26a moved ExtBytes & ExtFunc from libbasic2
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   381
!
76a83f34c26a moved ExtBytes & ExtFunc from libbasic2
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   382
76a83f34c26a moved ExtBytes & ExtFunc from libbasic2
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   383
indexOfCustomFunctionNamed:functionName
1257
f98014b76dd1 commentary
Claus Gittinger <cg@exept.de>
parents: 1184
diff changeset
   384
    "return the index of a named custom function"
848
76a83f34c26a moved ExtBytes & ExtFunc from libbasic2
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   385
76a83f34c26a moved ExtBytes & ExtFunc from libbasic2
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   386
%{  /* NOCONTEXT */
917
57dd3973f35f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 856
diff changeset
   387
#ifndef __stxNCustomFunctions__
856
d2c9f9ecedcf renamed customFunction-globals
Claus Gittinger <cg@exept.de>
parents: 848
diff changeset
   388
    extern int __stxNCustomFunctions__;
d2c9f9ecedcf renamed customFunction-globals
Claus Gittinger <cg@exept.de>
parents: 848
diff changeset
   389
    extern CUSTOMFUNCTION __stxCustomFunctions__[];
917
57dd3973f35f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 856
diff changeset
   390
#endif
848
76a83f34c26a moved ExtBytes & ExtFunc from libbasic2
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   391
12484
7f0cc6e86a66 change __isString() to __isStringLike() in primitive code
Stefan Vogel <sv@exept.de>
parents: 9397
diff changeset
   392
    if (__isStringLike(functionName)) {
19480
dedfb6c4bc16 custom functions
Claus Gittinger <cg@exept.de>
parents: 12484
diff changeset
   393
	char *nm;
dedfb6c4bc16 custom functions
Claus Gittinger <cg@exept.de>
parents: 12484
diff changeset
   394
	int i;
848
76a83f34c26a moved ExtBytes & ExtFunc from libbasic2
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   395
19480
dedfb6c4bc16 custom functions
Claus Gittinger <cg@exept.de>
parents: 12484
diff changeset
   396
	nm = (char *)__stringVal(functionName);
dedfb6c4bc16 custom functions
Claus Gittinger <cg@exept.de>
parents: 12484
diff changeset
   397
	for (i=0; i < __stxNCustomFunctions__; i++) {
dedfb6c4bc16 custom functions
Claus Gittinger <cg@exept.de>
parents: 12484
diff changeset
   398
	   if (strcmp(__stxCustomFunctions__[i].name, nm) == 0) {
dedfb6c4bc16 custom functions
Claus Gittinger <cg@exept.de>
parents: 12484
diff changeset
   399
		RETURN (__mkSmallInteger(i));
dedfb6c4bc16 custom functions
Claus Gittinger <cg@exept.de>
parents: 12484
diff changeset
   400
	   }
dedfb6c4bc16 custom functions
Claus Gittinger <cg@exept.de>
parents: 12484
diff changeset
   401
	}
848
76a83f34c26a moved ExtBytes & ExtFunc from libbasic2
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   402
    }
76a83f34c26a moved ExtBytes & ExtFunc from libbasic2
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   403
%}.
76a83f34c26a moved ExtBytes & ExtFunc from libbasic2
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   404
    ^ nil
76a83f34c26a moved ExtBytes & ExtFunc from libbasic2
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   405
76a83f34c26a moved ExtBytes & ExtFunc from libbasic2
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   406
    "
8534
dcb1cbd43198 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7665
diff changeset
   407
     ExternalFunction indexOfCustomFunctionNamed:'demoFunction0'
dcb1cbd43198 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7665
diff changeset
   408
     ExternalFunction indexOfCustomFunctionNamed:'fooBar'
848
76a83f34c26a moved ExtBytes & ExtFunc from libbasic2
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   409
    "
76a83f34c26a moved ExtBytes & ExtFunc from libbasic2
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   410
! !
76a83f34c26a moved ExtBytes & ExtFunc from libbasic2
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   411
3612
5d6fc1e8e578 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2880
diff changeset
   412
!ExternalFunction class methodsFor:'queries'!
1184
e15a6702c812 subclasses of fixed classes are still possible
Claus Gittinger <cg@exept.de>
parents: 1133
diff changeset
   413
e15a6702c812 subclasses of fixed classes are still possible
Claus Gittinger <cg@exept.de>
parents: 1133
diff changeset
   414
isBuiltInClass
1267
e285a3a94d9e commentary
Claus Gittinger <cg@exept.de>
parents: 1257
diff changeset
   415
    "return true if this class is known by the run-time-system.
e285a3a94d9e commentary
Claus Gittinger <cg@exept.de>
parents: 1257
diff changeset
   416
     Here, true is returned for myself, false for subclasses."
1184
e15a6702c812 subclasses of fixed classes are still possible
Claus Gittinger <cg@exept.de>
parents: 1133
diff changeset
   417
e15a6702c812 subclasses of fixed classes are still possible
Claus Gittinger <cg@exept.de>
parents: 1133
diff changeset
   418
    ^ self == ExternalFunction
e15a6702c812 subclasses of fixed classes are still possible
Claus Gittinger <cg@exept.de>
parents: 1133
diff changeset
   419
e15a6702c812 subclasses of fixed classes are still possible
Claus Gittinger <cg@exept.de>
parents: 1133
diff changeset
   420
    "Created: 16.4.1996 / 11:24:50 / cg"
1267
e285a3a94d9e commentary
Claus Gittinger <cg@exept.de>
parents: 1257
diff changeset
   421
    "Modified: 23.4.1996 / 15:58:55 / cg"
1184
e15a6702c812 subclasses of fixed classes are still possible
Claus Gittinger <cg@exept.de>
parents: 1133
diff changeset
   422
! !
e15a6702c812 subclasses of fixed classes are still possible
Claus Gittinger <cg@exept.de>
parents: 1133
diff changeset
   423
1542
cdcf4ad7556f need name & moduleHandle for the ObjectFileLoader to be able to recreate
Claus Gittinger <cg@exept.de>
parents: 1317
diff changeset
   424
!ExternalFunction methodsFor:'accessing'!
cdcf4ad7556f need name & moduleHandle for the ObjectFileLoader to be able to recreate
Claus Gittinger <cg@exept.de>
parents: 1317
diff changeset
   425
cdcf4ad7556f need name & moduleHandle for the ObjectFileLoader to be able to recreate
Claus Gittinger <cg@exept.de>
parents: 1317
diff changeset
   426
moduleHandle
21623
0fd2de531f9a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 20957
diff changeset
   427
    "return the function's moduleHandle
20510
3c745c287254 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 19480
diff changeset
   428
     (nil if not loaded dynamically)"
1542
cdcf4ad7556f need name & moduleHandle for the ObjectFileLoader to be able to recreate
Claus Gittinger <cg@exept.de>
parents: 1317
diff changeset
   429
cdcf4ad7556f need name & moduleHandle for the ObjectFileLoader to be able to recreate
Claus Gittinger <cg@exept.de>
parents: 1317
diff changeset
   430
    ^ moduleHandle
cdcf4ad7556f need name & moduleHandle for the ObjectFileLoader to be able to recreate
Claus Gittinger <cg@exept.de>
parents: 1317
diff changeset
   431
!
cdcf4ad7556f need name & moduleHandle for the ObjectFileLoader to be able to recreate
Claus Gittinger <cg@exept.de>
parents: 1317
diff changeset
   432
cdcf4ad7556f need name & moduleHandle for the ObjectFileLoader to be able to recreate
Claus Gittinger <cg@exept.de>
parents: 1317
diff changeset
   433
name
20510
3c745c287254 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 19480
diff changeset
   434
    "return the function's name"
1542
cdcf4ad7556f need name & moduleHandle for the ObjectFileLoader to be able to recreate
Claus Gittinger <cg@exept.de>
parents: 1317
diff changeset
   435
cdcf4ad7556f need name & moduleHandle for the ObjectFileLoader to be able to recreate
Claus Gittinger <cg@exept.de>
parents: 1317
diff changeset
   436
    ^ name
cdcf4ad7556f need name & moduleHandle for the ObjectFileLoader to be able to recreate
Claus Gittinger <cg@exept.de>
parents: 1317
diff changeset
   437
! !
cdcf4ad7556f need name & moduleHandle for the ObjectFileLoader to be able to recreate
Claus Gittinger <cg@exept.de>
parents: 1317
diff changeset
   438
848
76a83f34c26a moved ExtBytes & ExtFunc from libbasic2
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   439
!ExternalFunction methodsFor:'function calling'!
76a83f34c26a moved ExtBytes & ExtFunc from libbasic2
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   440
76a83f34c26a moved ExtBytes & ExtFunc from libbasic2
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   441
call
76a83f34c26a moved ExtBytes & ExtFunc from libbasic2
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   442
    "call the underlying C function, passing no argument.
8534
dcb1cbd43198 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7665
diff changeset
   443
     The return value is interpreted as an integer
848
76a83f34c26a moved ExtBytes & ExtFunc from libbasic2
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   444
     (and must be converted to an externalBytes object,
76a83f34c26a moved ExtBytes & ExtFunc from libbasic2
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   445
      if it is a pointer to something).
76a83f34c26a moved ExtBytes & ExtFunc from libbasic2
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   446
76a83f34c26a moved ExtBytes & ExtFunc from libbasic2
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   447
     DANGER alert: This is an unprotected low-level entry.
76a83f34c26a moved ExtBytes & ExtFunc from libbasic2
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   448
     Not for normal application usage.
76a83f34c26a moved ExtBytes & ExtFunc from libbasic2
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   449
    "
76a83f34c26a moved ExtBytes & ExtFunc from libbasic2
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   450
%{
2880
87d9ea943024 alpha stuff
Claus Gittinger <cg@exept.de>
parents: 2769
diff changeset
   451
    LINTFUNC func;
2769
2fd416e4b589 alpha64 changes
Claus Gittinger <cg@exept.de>
parents: 1547
diff changeset
   452
    INT retVal;
848
76a83f34c26a moved ExtBytes & ExtFunc from libbasic2
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   453
2880
87d9ea943024 alpha stuff
Claus Gittinger <cg@exept.de>
parents: 2769
diff changeset
   454
    func = (LINTFUNC) __INST(code_);
1545
01e11b46ca65 more possible argument types
Claus Gittinger <cg@exept.de>
parents: 1543
diff changeset
   455
    if (func) {
7665
18f5805b3920 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7602
diff changeset
   456
	retVal = (*func)();
18f5805b3920 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7602
diff changeset
   457
	RETURN (__MKINT(retVal));
1545
01e11b46ca65 more possible argument types
Claus Gittinger <cg@exept.de>
parents: 1543
diff changeset
   458
    }
01e11b46ca65 more possible argument types
Claus Gittinger <cg@exept.de>
parents: 1543
diff changeset
   459
%}.
01e11b46ca65 more possible argument types
Claus Gittinger <cg@exept.de>
parents: 1543
diff changeset
   460
    self primitiveFailed
848
76a83f34c26a moved ExtBytes & ExtFunc from libbasic2
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   461
!
76a83f34c26a moved ExtBytes & ExtFunc from libbasic2
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   462
8594
272976291af7 New: #calByRef* methods
Stefan Vogel <sv@exept.de>
parents: 8534
diff changeset
   463
callByRefWith:arg
272976291af7 New: #calByRef* methods
Stefan Vogel <sv@exept.de>
parents: 8534
diff changeset
   464
    "call the underlying C function, passing a single argument by reference.
272976291af7 New: #calByRef* methods
Stefan Vogel <sv@exept.de>
parents: 8534
diff changeset
   465
     The pointer of the argument is passed. Use this if you want to call a
272976291af7 New: #calByRef* methods
Stefan Vogel <sv@exept.de>
parents: 8534
diff changeset
   466
     function with call-by-refernece semantics, like in fortran.
272976291af7 New: #calByRef* methods
Stefan Vogel <sv@exept.de>
parents: 8534
diff changeset
   467
     The argument arg is converted to a corresponding C data type,
272976291af7 New: #calByRef* methods
Stefan Vogel <sv@exept.de>
parents: 8534
diff changeset
   468
     as defined in the convertST_to_C() function.
272976291af7 New: #calByRef* methods
Stefan Vogel <sv@exept.de>
parents: 8534
diff changeset
   469
     The return value is interpreted as an integer
272976291af7 New: #calByRef* methods
Stefan Vogel <sv@exept.de>
parents: 8534
diff changeset
   470
     (and must be converted to an externalBytes object,
272976291af7 New: #calByRef* methods
Stefan Vogel <sv@exept.de>
parents: 8534
diff changeset
   471
      if it is a pointer to something).
272976291af7 New: #calByRef* methods
Stefan Vogel <sv@exept.de>
parents: 8534
diff changeset
   472
272976291af7 New: #calByRef* methods
Stefan Vogel <sv@exept.de>
parents: 8534
diff changeset
   473
     DANGER alert: This is an unprotected low-level entry.
272976291af7 New: #calByRef* methods
Stefan Vogel <sv@exept.de>
parents: 8534
diff changeset
   474
     Not for normal application usage.
272976291af7 New: #calByRef* methods
Stefan Vogel <sv@exept.de>
parents: 8534
diff changeset
   475
    "
272976291af7 New: #calByRef* methods
Stefan Vogel <sv@exept.de>
parents: 8534
diff changeset
   476
%{
272976291af7 New: #calByRef* methods
Stefan Vogel <sv@exept.de>
parents: 8534
diff changeset
   477
    LINTFUNC func;
272976291af7 New: #calByRef* methods
Stefan Vogel <sv@exept.de>
parents: 8534
diff changeset
   478
    INT retVal;
272976291af7 New: #calByRef* methods
Stefan Vogel <sv@exept.de>
parents: 8534
diff changeset
   479
    INT cArg;
272976291af7 New: #calByRef* methods
Stefan Vogel <sv@exept.de>
parents: 8534
diff changeset
   480
272976291af7 New: #calByRef* methods
Stefan Vogel <sv@exept.de>
parents: 8534
diff changeset
   481
    func = (LINTFUNC) __INST(code_);
272976291af7 New: #calByRef* methods
Stefan Vogel <sv@exept.de>
parents: 8534
diff changeset
   482
    if (func) {
9323
71e2a9e2aa57 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8913
diff changeset
   483
	cArg = convertST_to_C(arg);
71e2a9e2aa57 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8913
diff changeset
   484
	retVal = (*func)(&cArg);
71e2a9e2aa57 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8913
diff changeset
   485
	RETURN (__MKINT(retVal));
8594
272976291af7 New: #calByRef* methods
Stefan Vogel <sv@exept.de>
parents: 8534
diff changeset
   486
    }
272976291af7 New: #calByRef* methods
Stefan Vogel <sv@exept.de>
parents: 8534
diff changeset
   487
%}.
272976291af7 New: #calByRef* methods
Stefan Vogel <sv@exept.de>
parents: 8534
diff changeset
   488
    self primitiveFailed
272976291af7 New: #calByRef* methods
Stefan Vogel <sv@exept.de>
parents: 8534
diff changeset
   489
!
272976291af7 New: #calByRef* methods
Stefan Vogel <sv@exept.de>
parents: 8534
diff changeset
   490
272976291af7 New: #calByRef* methods
Stefan Vogel <sv@exept.de>
parents: 8534
diff changeset
   491
callByRefWith:arg with:arg2
272976291af7 New: #calByRef* methods
Stefan Vogel <sv@exept.de>
parents: 8534
diff changeset
   492
    "call the underlying C function, passing two args.
272976291af7 New: #calByRef* methods
Stefan Vogel <sv@exept.de>
parents: 8534
diff changeset
   493
     The pointer of the arguments are passed. Use this if you want to call a
272976291af7 New: #calByRef* methods
Stefan Vogel <sv@exept.de>
parents: 8534
diff changeset
   494
     function with call-by-refernece semantics, like in fortran.
272976291af7 New: #calByRef* methods
Stefan Vogel <sv@exept.de>
parents: 8534
diff changeset
   495
     The arguments are converted to a corresponding C data type,
272976291af7 New: #calByRef* methods
Stefan Vogel <sv@exept.de>
parents: 8534
diff changeset
   496
     as defined in the convertST_to_C() function.
272976291af7 New: #calByRef* methods
Stefan Vogel <sv@exept.de>
parents: 8534
diff changeset
   497
     The return value is interpreted as an integer
272976291af7 New: #calByRef* methods
Stefan Vogel <sv@exept.de>
parents: 8534
diff changeset
   498
     (and must be converted to an externalBytes object,
272976291af7 New: #calByRef* methods
Stefan Vogel <sv@exept.de>
parents: 8534
diff changeset
   499
      if it is a pointer to something).
272976291af7 New: #calByRef* methods
Stefan Vogel <sv@exept.de>
parents: 8534
diff changeset
   500
272976291af7 New: #calByRef* methods
Stefan Vogel <sv@exept.de>
parents: 8534
diff changeset
   501
     DANGER alert: This is an unprotected low-level entry.
272976291af7 New: #calByRef* methods
Stefan Vogel <sv@exept.de>
parents: 8534
diff changeset
   502
     Not for normal application usage.
272976291af7 New: #calByRef* methods
Stefan Vogel <sv@exept.de>
parents: 8534
diff changeset
   503
    "
272976291af7 New: #calByRef* methods
Stefan Vogel <sv@exept.de>
parents: 8534
diff changeset
   504
%{
272976291af7 New: #calByRef* methods
Stefan Vogel <sv@exept.de>
parents: 8534
diff changeset
   505
    LINTFUNC func;
272976291af7 New: #calByRef* methods
Stefan Vogel <sv@exept.de>
parents: 8534
diff changeset
   506
    INT retVal;
272976291af7 New: #calByRef* methods
Stefan Vogel <sv@exept.de>
parents: 8534
diff changeset
   507
    INT cArg, cArg2;
272976291af7 New: #calByRef* methods
Stefan Vogel <sv@exept.de>
parents: 8534
diff changeset
   508
272976291af7 New: #calByRef* methods
Stefan Vogel <sv@exept.de>
parents: 8534
diff changeset
   509
    func = (LINTFUNC) __INST(code_);
272976291af7 New: #calByRef* methods
Stefan Vogel <sv@exept.de>
parents: 8534
diff changeset
   510
    if (func) {
9323
71e2a9e2aa57 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8913
diff changeset
   511
	cArg = convertST_to_C(arg);
71e2a9e2aa57 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8913
diff changeset
   512
	cArg2 = convertST_to_C(arg2);
71e2a9e2aa57 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8913
diff changeset
   513
	retVal = (*func)(&cArg, &cArg2);
71e2a9e2aa57 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8913
diff changeset
   514
	RETURN (__MKINT(retVal));
8594
272976291af7 New: #calByRef* methods
Stefan Vogel <sv@exept.de>
parents: 8534
diff changeset
   515
    }
272976291af7 New: #calByRef* methods
Stefan Vogel <sv@exept.de>
parents: 8534
diff changeset
   516
%}.
272976291af7 New: #calByRef* methods
Stefan Vogel <sv@exept.de>
parents: 8534
diff changeset
   517
    self primitiveFailed
272976291af7 New: #calByRef* methods
Stefan Vogel <sv@exept.de>
parents: 8534
diff changeset
   518
!
272976291af7 New: #calByRef* methods
Stefan Vogel <sv@exept.de>
parents: 8534
diff changeset
   519
272976291af7 New: #calByRef* methods
Stefan Vogel <sv@exept.de>
parents: 8534
diff changeset
   520
callByRefWith:arg with:arg2 with:arg3
272976291af7 New: #calByRef* methods
Stefan Vogel <sv@exept.de>
parents: 8534
diff changeset
   521
    "call the underlying C function, passing three args.
272976291af7 New: #calByRef* methods
Stefan Vogel <sv@exept.de>
parents: 8534
diff changeset
   522
     The pointer of the arguments are passed. Use this if you want to call a
272976291af7 New: #calByRef* methods
Stefan Vogel <sv@exept.de>
parents: 8534
diff changeset
   523
     function with call-by-refernece semantics, like in fortran.
272976291af7 New: #calByRef* methods
Stefan Vogel <sv@exept.de>
parents: 8534
diff changeset
   524
     The arguments are converted to a corresponding C data type,
272976291af7 New: #calByRef* methods
Stefan Vogel <sv@exept.de>
parents: 8534
diff changeset
   525
     as defined in the convertST_to_C() function.
272976291af7 New: #calByRef* methods
Stefan Vogel <sv@exept.de>
parents: 8534
diff changeset
   526
     The return value is interpreted as an integer
272976291af7 New: #calByRef* methods
Stefan Vogel <sv@exept.de>
parents: 8534
diff changeset
   527
     (and must be converted to an externalBytes object,
272976291af7 New: #calByRef* methods
Stefan Vogel <sv@exept.de>
parents: 8534
diff changeset
   528
      if it is a pointer to something).
272976291af7 New: #calByRef* methods
Stefan Vogel <sv@exept.de>
parents: 8534
diff changeset
   529
272976291af7 New: #calByRef* methods
Stefan Vogel <sv@exept.de>
parents: 8534
diff changeset
   530
     DANGER alert: This is an unprotected low-level entry.
272976291af7 New: #calByRef* methods
Stefan Vogel <sv@exept.de>
parents: 8534
diff changeset
   531
     Not for normal application usage.
272976291af7 New: #calByRef* methods
Stefan Vogel <sv@exept.de>
parents: 8534
diff changeset
   532
    "
272976291af7 New: #calByRef* methods
Stefan Vogel <sv@exept.de>
parents: 8534
diff changeset
   533
%{
272976291af7 New: #calByRef* methods
Stefan Vogel <sv@exept.de>
parents: 8534
diff changeset
   534
    LINTFUNC func;
272976291af7 New: #calByRef* methods
Stefan Vogel <sv@exept.de>
parents: 8534
diff changeset
   535
    INT retVal;
272976291af7 New: #calByRef* methods
Stefan Vogel <sv@exept.de>
parents: 8534
diff changeset
   536
    INT cArg, cArg2, cArg3;
272976291af7 New: #calByRef* methods
Stefan Vogel <sv@exept.de>
parents: 8534
diff changeset
   537
272976291af7 New: #calByRef* methods
Stefan Vogel <sv@exept.de>
parents: 8534
diff changeset
   538
    func = (LINTFUNC) __INST(code_);
272976291af7 New: #calByRef* methods
Stefan Vogel <sv@exept.de>
parents: 8534
diff changeset
   539
    if (func) {
9323
71e2a9e2aa57 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8913
diff changeset
   540
	cArg = convertST_to_C(arg);
71e2a9e2aa57 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8913
diff changeset
   541
	cArg2 = convertST_to_C(arg2);
71e2a9e2aa57 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8913
diff changeset
   542
	cArg3 = convertST_to_C(arg3);
71e2a9e2aa57 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8913
diff changeset
   543
	retVal = (*func)(&cArg, &cArg2, &cArg3);
71e2a9e2aa57 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8913
diff changeset
   544
	RETURN (__MKINT(retVal));
8594
272976291af7 New: #calByRef* methods
Stefan Vogel <sv@exept.de>
parents: 8534
diff changeset
   545
    }
272976291af7 New: #calByRef* methods
Stefan Vogel <sv@exept.de>
parents: 8534
diff changeset
   546
%}.
272976291af7 New: #calByRef* methods
Stefan Vogel <sv@exept.de>
parents: 8534
diff changeset
   547
    self primitiveFailed
272976291af7 New: #calByRef* methods
Stefan Vogel <sv@exept.de>
parents: 8534
diff changeset
   548
!
272976291af7 New: #calByRef* methods
Stefan Vogel <sv@exept.de>
parents: 8534
diff changeset
   549
272976291af7 New: #calByRef* methods
Stefan Vogel <sv@exept.de>
parents: 8534
diff changeset
   550
callByRefWithArguments:argArray
272976291af7 New: #calByRef* methods
Stefan Vogel <sv@exept.de>
parents: 8534
diff changeset
   551
    "call the underlying C function, passing up to 10 arguments by reference.
272976291af7 New: #calByRef* methods
Stefan Vogel <sv@exept.de>
parents: 8534
diff changeset
   552
     The arguments are converted to a corresponding C data type,
272976291af7 New: #calByRef* methods
Stefan Vogel <sv@exept.de>
parents: 8534
diff changeset
   553
     as defined in the convertST_to_C() function.
272976291af7 New: #calByRef* methods
Stefan Vogel <sv@exept.de>
parents: 8534
diff changeset
   554
     The return value is interpreted as an integer
272976291af7 New: #calByRef* methods
Stefan Vogel <sv@exept.de>
parents: 8534
diff changeset
   555
     (and must be converted to an externalBytes object,
272976291af7 New: #calByRef* methods
Stefan Vogel <sv@exept.de>
parents: 8534
diff changeset
   556
      if it is a pointer to something).
272976291af7 New: #calByRef* methods
Stefan Vogel <sv@exept.de>
parents: 8534
diff changeset
   557
272976291af7 New: #calByRef* methods
Stefan Vogel <sv@exept.de>
parents: 8534
diff changeset
   558
     DANGER alert: This is an unprotected low-level entry.
272976291af7 New: #calByRef* methods
Stefan Vogel <sv@exept.de>
parents: 8534
diff changeset
   559
     Not for normal application usage.
272976291af7 New: #calByRef* methods
Stefan Vogel <sv@exept.de>
parents: 8534
diff changeset
   560
    "
272976291af7 New: #calByRef* methods
Stefan Vogel <sv@exept.de>
parents: 8534
diff changeset
   561
%{
272976291af7 New: #calByRef* methods
Stefan Vogel <sv@exept.de>
parents: 8534
diff changeset
   562
    LINTFUNC func;
272976291af7 New: #calByRef* methods
Stefan Vogel <sv@exept.de>
parents: 8534
diff changeset
   563
#   define NUMARGS 10
272976291af7 New: #calByRef* methods
Stefan Vogel <sv@exept.de>
parents: 8534
diff changeset
   564
    INT args[NUMARGS];
272976291af7 New: #calByRef* methods
Stefan Vogel <sv@exept.de>
parents: 8534
diff changeset
   565
    INT retVal;
272976291af7 New: #calByRef* methods
Stefan Vogel <sv@exept.de>
parents: 8534
diff changeset
   566
    OBJ *ap;
272976291af7 New: #calByRef* methods
Stefan Vogel <sv@exept.de>
parents: 8534
diff changeset
   567
    INT convertST_to_C();
272976291af7 New: #calByRef* methods
Stefan Vogel <sv@exept.de>
parents: 8534
diff changeset
   568
272976291af7 New: #calByRef* methods
Stefan Vogel <sv@exept.de>
parents: 8534
diff changeset
   569
    func = (LINTFUNC) __INST(code_);
21623
0fd2de531f9a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 20957
diff changeset
   570
    if (func && __isArrayLike(argArray)) {
9323
71e2a9e2aa57 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8913
diff changeset
   571
	int n = __arraySize(argArray);
71e2a9e2aa57 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8913
diff changeset
   572
	int i;
8594
272976291af7 New: #calByRef* methods
Stefan Vogel <sv@exept.de>
parents: 8534
diff changeset
   573
9323
71e2a9e2aa57 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8913
diff changeset
   574
	if (n <= 10) {
71e2a9e2aa57 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8913
diff changeset
   575
	    ap = __ArrayInstPtr(argArray)->a_element;
71e2a9e2aa57 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8913
diff changeset
   576
	    for (i=0; i<NUMARGS; i++) {
71e2a9e2aa57 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8913
diff changeset
   577
		args[i] = convertST_to_C(*ap++);
71e2a9e2aa57 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8913
diff changeset
   578
	    }
71e2a9e2aa57 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8913
diff changeset
   579
	}
71e2a9e2aa57 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8913
diff changeset
   580
	switch (n) {
71e2a9e2aa57 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8913
diff changeset
   581
	    case 0:
71e2a9e2aa57 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8913
diff changeset
   582
		retVal = (*func)();
71e2a9e2aa57 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8913
diff changeset
   583
		break;
71e2a9e2aa57 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8913
diff changeset
   584
	    case 1:
71e2a9e2aa57 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8913
diff changeset
   585
		retVal = (*func)(&args[0]);
71e2a9e2aa57 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8913
diff changeset
   586
		break;
71e2a9e2aa57 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8913
diff changeset
   587
	    case 2:
71e2a9e2aa57 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8913
diff changeset
   588
		retVal = (*func)(&args[0], &args[1]);
71e2a9e2aa57 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8913
diff changeset
   589
		break;
71e2a9e2aa57 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8913
diff changeset
   590
	    case 3:
71e2a9e2aa57 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8913
diff changeset
   591
		retVal = (*func)(&args[0], &args[1], &args[2]);
71e2a9e2aa57 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8913
diff changeset
   592
		break;
71e2a9e2aa57 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8913
diff changeset
   593
	    case 4:
71e2a9e2aa57 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8913
diff changeset
   594
		retVal = (*func)(&args[0], &args[1], &args[2], &args[3]);
71e2a9e2aa57 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8913
diff changeset
   595
		break;
71e2a9e2aa57 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8913
diff changeset
   596
	    case 5:
71e2a9e2aa57 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8913
diff changeset
   597
		retVal = (*func)(&args[0], &args[1], &args[2], &args[3],
71e2a9e2aa57 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8913
diff changeset
   598
				 &args[4]);
71e2a9e2aa57 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8913
diff changeset
   599
		break;
71e2a9e2aa57 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8913
diff changeset
   600
	    case 6:
71e2a9e2aa57 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8913
diff changeset
   601
		retVal = (*func)(&args[0], &args[1], &args[2], &args[3],
71e2a9e2aa57 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8913
diff changeset
   602
				 &args[4], &args[5]);
71e2a9e2aa57 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8913
diff changeset
   603
		break;
71e2a9e2aa57 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8913
diff changeset
   604
	    case 7:
71e2a9e2aa57 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8913
diff changeset
   605
		retVal = (*func)(&args[0], &args[1],& args[2], &args[3],
71e2a9e2aa57 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8913
diff changeset
   606
				 &args[4], &args[5], &args[6]);
71e2a9e2aa57 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8913
diff changeset
   607
		break;
71e2a9e2aa57 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8913
diff changeset
   608
	    case 8:
71e2a9e2aa57 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8913
diff changeset
   609
		retVal = (*func)(&args[0], &args[1], &args[2], &args[3],
71e2a9e2aa57 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8913
diff changeset
   610
				 &args[4], &args[5], &args[6], &args[7]);
71e2a9e2aa57 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8913
diff changeset
   611
		break;
71e2a9e2aa57 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8913
diff changeset
   612
	    case 9:
71e2a9e2aa57 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8913
diff changeset
   613
		retVal = (*func)(&args[0], &args[1], &args[2], &args[3],
71e2a9e2aa57 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8913
diff changeset
   614
				 &args[4], &args[5], &args[6], &args[7],
71e2a9e2aa57 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8913
diff changeset
   615
				 &args[8]);
71e2a9e2aa57 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8913
diff changeset
   616
		break;
71e2a9e2aa57 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8913
diff changeset
   617
	    case 10:
71e2a9e2aa57 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8913
diff changeset
   618
		retVal = (*func)(&args[0], &args[1], &args[2], &args[3],
71e2a9e2aa57 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8913
diff changeset
   619
				 &args[4], &args[5], &args[6], &args[7],
71e2a9e2aa57 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8913
diff changeset
   620
				 &args[8], &args[9]);
71e2a9e2aa57 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8913
diff changeset
   621
		break;
71e2a9e2aa57 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8913
diff changeset
   622
	    default:
71e2a9e2aa57 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8913
diff changeset
   623
		goto err;
71e2a9e2aa57 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8913
diff changeset
   624
	}
71e2a9e2aa57 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8913
diff changeset
   625
	RETURN (__MKINT(retVal));
8594
272976291af7 New: #calByRef* methods
Stefan Vogel <sv@exept.de>
parents: 8534
diff changeset
   626
    }
272976291af7 New: #calByRef* methods
Stefan Vogel <sv@exept.de>
parents: 8534
diff changeset
   627
  err: ;
272976291af7 New: #calByRef* methods
Stefan Vogel <sv@exept.de>
parents: 8534
diff changeset
   628
%}.
272976291af7 New: #calByRef* methods
Stefan Vogel <sv@exept.de>
parents: 8534
diff changeset
   629
    self primitiveFailed
272976291af7 New: #calByRef* methods
Stefan Vogel <sv@exept.de>
parents: 8534
diff changeset
   630
!
272976291af7 New: #calByRef* methods
Stefan Vogel <sv@exept.de>
parents: 8534
diff changeset
   631
5164
005ca26bf53a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3612
diff changeset
   632
callO
005ca26bf53a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3612
diff changeset
   633
    "call the underlying C function, passing no argument.
005ca26bf53a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3612
diff changeset
   634
     The return value must be a valid object.
005ca26bf53a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3612
diff changeset
   635
005ca26bf53a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3612
diff changeset
   636
     DANGER alert: This is an unprotected low-level entry.
005ca26bf53a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3612
diff changeset
   637
     Not for normal application usage.
005ca26bf53a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3612
diff changeset
   638
    "
005ca26bf53a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3612
diff changeset
   639
%{
005ca26bf53a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3612
diff changeset
   640
    OBJFUNC func;
005ca26bf53a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3612
diff changeset
   641
    OBJ retVal;
005ca26bf53a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3612
diff changeset
   642
005ca26bf53a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3612
diff changeset
   643
    func = (OBJFUNC) __INST(code_);
005ca26bf53a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3612
diff changeset
   644
    if (func) {
7665
18f5805b3920 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7602
diff changeset
   645
	retVal = (*func)();
18f5805b3920 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7602
diff changeset
   646
	RETURN (retVal);
5164
005ca26bf53a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3612
diff changeset
   647
    }
005ca26bf53a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3612
diff changeset
   648
%}.
005ca26bf53a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3612
diff changeset
   649
    self primitiveFailed
005ca26bf53a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3612
diff changeset
   650
!
005ca26bf53a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3612
diff changeset
   651
005ca26bf53a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3612
diff changeset
   652
callOWith:arg
005ca26bf53a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3612
diff changeset
   653
    "call the underlying C function, passing a single object argument.
8534
dcb1cbd43198 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7665
diff changeset
   654
     The return value must be a valid object.
5164
005ca26bf53a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3612
diff changeset
   655
005ca26bf53a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3612
diff changeset
   656
     DANGER alert: This is an unprotected low-level entry.
005ca26bf53a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3612
diff changeset
   657
     Not for normal application usage.
005ca26bf53a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3612
diff changeset
   658
    "
005ca26bf53a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3612
diff changeset
   659
%{
005ca26bf53a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3612
diff changeset
   660
    OBJFUNC func;
005ca26bf53a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3612
diff changeset
   661
    OBJ retVal;
005ca26bf53a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3612
diff changeset
   662
005ca26bf53a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3612
diff changeset
   663
    func = (OBJFUNC) __INST(code_);
005ca26bf53a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3612
diff changeset
   664
    if (func) {
7665
18f5805b3920 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7602
diff changeset
   665
	retVal = (*func)(arg);
18f5805b3920 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7602
diff changeset
   666
	RETURN (retVal);
5164
005ca26bf53a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3612
diff changeset
   667
    }
005ca26bf53a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3612
diff changeset
   668
%}.
005ca26bf53a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3612
diff changeset
   669
    self primitiveFailed
005ca26bf53a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3612
diff changeset
   670
!
005ca26bf53a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3612
diff changeset
   671
005ca26bf53a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3612
diff changeset
   672
callOWith:arg1 with:arg2
005ca26bf53a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3612
diff changeset
   673
    "call the underlying C function, passing two args.
8534
dcb1cbd43198 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7665
diff changeset
   674
     The return value must be a valid object.
5164
005ca26bf53a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3612
diff changeset
   675
005ca26bf53a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3612
diff changeset
   676
     DANGER alert: This is an unprotected low-level entry.
005ca26bf53a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3612
diff changeset
   677
     Not for normal application usage.
005ca26bf53a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3612
diff changeset
   678
    "
005ca26bf53a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3612
diff changeset
   679
%{
005ca26bf53a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3612
diff changeset
   680
    OBJFUNC func;
005ca26bf53a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3612
diff changeset
   681
    OBJ retVal;
005ca26bf53a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3612
diff changeset
   682
005ca26bf53a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3612
diff changeset
   683
    func = (OBJFUNC) __INST(code_);
005ca26bf53a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3612
diff changeset
   684
    if (func) {
7665
18f5805b3920 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7602
diff changeset
   685
	retVal = (*func)(arg1, arg2);
18f5805b3920 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7602
diff changeset
   686
	RETURN (retVal);
5164
005ca26bf53a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3612
diff changeset
   687
    }
005ca26bf53a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3612
diff changeset
   688
%}.
005ca26bf53a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3612
diff changeset
   689
    self primitiveFailed
005ca26bf53a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3612
diff changeset
   690
!
005ca26bf53a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3612
diff changeset
   691
005ca26bf53a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3612
diff changeset
   692
callOWith:arg1 with:arg2 with:arg3
005ca26bf53a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3612
diff changeset
   693
    "call the underlying C function, passing three args.
8534
dcb1cbd43198 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7665
diff changeset
   694
     The return value must be a valid object.
5164
005ca26bf53a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3612
diff changeset
   695
005ca26bf53a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3612
diff changeset
   696
     DANGER alert: This is an unprotected low-level entry.
005ca26bf53a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3612
diff changeset
   697
     Not for normal application usage.
005ca26bf53a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3612
diff changeset
   698
    "
005ca26bf53a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3612
diff changeset
   699
%{
005ca26bf53a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3612
diff changeset
   700
    OBJFUNC func;
7665
18f5805b3920 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7602
diff changeset
   701
    OBJ retVal;
5164
005ca26bf53a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3612
diff changeset
   702
005ca26bf53a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3612
diff changeset
   703
    func = (OBJFUNC) __INST(code_);
005ca26bf53a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3612
diff changeset
   704
    if (func) {
7665
18f5805b3920 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7602
diff changeset
   705
	retVal = (*func)(arg1, arg2, arg3);
18f5805b3920 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7602
diff changeset
   706
	RETURN (retVal);
5164
005ca26bf53a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3612
diff changeset
   707
    }
005ca26bf53a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3612
diff changeset
   708
%}.
005ca26bf53a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3612
diff changeset
   709
    self primitiveFailed
005ca26bf53a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3612
diff changeset
   710
!
005ca26bf53a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3612
diff changeset
   711
848
76a83f34c26a moved ExtBytes & ExtFunc from libbasic2
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   712
callWith:arg
76a83f34c26a moved ExtBytes & ExtFunc from libbasic2
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   713
    "call the underlying C function, passing a single argument.
76a83f34c26a moved ExtBytes & ExtFunc from libbasic2
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   714
     The argument arg is converted to a corresponding C data type,
76a83f34c26a moved ExtBytes & ExtFunc from libbasic2
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   715
     as defined in the convertST_to_C() function.
8534
dcb1cbd43198 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7665
diff changeset
   716
     The return value is interpreted as an integer
848
76a83f34c26a moved ExtBytes & ExtFunc from libbasic2
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   717
     (and must be converted to an externalBytes object,
76a83f34c26a moved ExtBytes & ExtFunc from libbasic2
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   718
      if it is a pointer to something).
76a83f34c26a moved ExtBytes & ExtFunc from libbasic2
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   719
76a83f34c26a moved ExtBytes & ExtFunc from libbasic2
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   720
     DANGER alert: This is an unprotected low-level entry.
76a83f34c26a moved ExtBytes & ExtFunc from libbasic2
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   721
     Not for normal application usage.
76a83f34c26a moved ExtBytes & ExtFunc from libbasic2
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   722
    "
76a83f34c26a moved ExtBytes & ExtFunc from libbasic2
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   723
%{
2880
87d9ea943024 alpha stuff
Claus Gittinger <cg@exept.de>
parents: 2769
diff changeset
   724
    LINTFUNC func;
2769
2fd416e4b589 alpha64 changes
Claus Gittinger <cg@exept.de>
parents: 1547
diff changeset
   725
    INT retVal;
848
76a83f34c26a moved ExtBytes & ExtFunc from libbasic2
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   726
2880
87d9ea943024 alpha stuff
Claus Gittinger <cg@exept.de>
parents: 2769
diff changeset
   727
    func = (LINTFUNC) __INST(code_);
1545
01e11b46ca65 more possible argument types
Claus Gittinger <cg@exept.de>
parents: 1543
diff changeset
   728
    if (func) {
7665
18f5805b3920 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7602
diff changeset
   729
	retVal = (*func)(convertST_to_C(arg));
18f5805b3920 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7602
diff changeset
   730
	RETURN (__MKINT(retVal));
1545
01e11b46ca65 more possible argument types
Claus Gittinger <cg@exept.de>
parents: 1543
diff changeset
   731
    }
01e11b46ca65 more possible argument types
Claus Gittinger <cg@exept.de>
parents: 1543
diff changeset
   732
%}.
01e11b46ca65 more possible argument types
Claus Gittinger <cg@exept.de>
parents: 1543
diff changeset
   733
    self primitiveFailed
848
76a83f34c26a moved ExtBytes & ExtFunc from libbasic2
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   734
!
76a83f34c26a moved ExtBytes & ExtFunc from libbasic2
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   735
3612
5d6fc1e8e578 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2880
diff changeset
   736
callWith:arg1 with:arg2
5d6fc1e8e578 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2880
diff changeset
   737
    "call the underlying C function, passing two args.
5d6fc1e8e578 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2880
diff changeset
   738
     The arguments are converted to a corresponding C data type,
5d6fc1e8e578 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2880
diff changeset
   739
     as defined in the convertST_to_C() function.
8534
dcb1cbd43198 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7665
diff changeset
   740
     The return value is interpreted as an integer
3612
5d6fc1e8e578 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2880
diff changeset
   741
     (and must be converted to an externalBytes object,
5d6fc1e8e578 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2880
diff changeset
   742
      if it is a pointer to something).
5d6fc1e8e578 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2880
diff changeset
   743
5d6fc1e8e578 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2880
diff changeset
   744
     DANGER alert: This is an unprotected low-level entry.
5d6fc1e8e578 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2880
diff changeset
   745
     Not for normal application usage.
5d6fc1e8e578 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2880
diff changeset
   746
    "
5d6fc1e8e578 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2880
diff changeset
   747
%{
5d6fc1e8e578 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2880
diff changeset
   748
    LINTFUNC func;
5d6fc1e8e578 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2880
diff changeset
   749
    INT retVal;
5d6fc1e8e578 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2880
diff changeset
   750
5d6fc1e8e578 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2880
diff changeset
   751
    func = (LINTFUNC) __INST(code_);
5d6fc1e8e578 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2880
diff changeset
   752
    if (func) {
7665
18f5805b3920 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7602
diff changeset
   753
	retVal = (*func)(convertST_to_C(arg1), convertST_to_C(arg2));
18f5805b3920 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7602
diff changeset
   754
	RETURN (__MKINT(retVal));
3612
5d6fc1e8e578 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2880
diff changeset
   755
    }
5d6fc1e8e578 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2880
diff changeset
   756
%}.
5d6fc1e8e578 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2880
diff changeset
   757
    self primitiveFailed
5d6fc1e8e578 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2880
diff changeset
   758
!
5d6fc1e8e578 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2880
diff changeset
   759
5d6fc1e8e578 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2880
diff changeset
   760
callWith:arg1 with:arg2 with:arg3
5d6fc1e8e578 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2880
diff changeset
   761
    "call the underlying C function, passing three args.
5d6fc1e8e578 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2880
diff changeset
   762
     The arguments are converted to a corresponding C data type,
5d6fc1e8e578 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2880
diff changeset
   763
     as defined in the convertST_to_C() function.
8534
dcb1cbd43198 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7665
diff changeset
   764
     The return value is interpreted as an integer
3612
5d6fc1e8e578 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2880
diff changeset
   765
     (and must be converted to an externalBytes object,
5d6fc1e8e578 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2880
diff changeset
   766
      if it is a pointer to something).
5d6fc1e8e578 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2880
diff changeset
   767
5d6fc1e8e578 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2880
diff changeset
   768
     DANGER alert: This is an unprotected low-level entry.
5d6fc1e8e578 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2880
diff changeset
   769
     Not for normal application usage.
5d6fc1e8e578 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2880
diff changeset
   770
    "
5d6fc1e8e578 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2880
diff changeset
   771
%{
5d6fc1e8e578 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2880
diff changeset
   772
    LINTFUNC func;
5d6fc1e8e578 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2880
diff changeset
   773
    INT retVal;
5d6fc1e8e578 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2880
diff changeset
   774
5d6fc1e8e578 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2880
diff changeset
   775
    func = (LINTFUNC) __INST(code_);
5d6fc1e8e578 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2880
diff changeset
   776
    if (func) {
7665
18f5805b3920 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7602
diff changeset
   777
	retVal = (*func)(convertST_to_C(arg1), convertST_to_C(arg2), convertST_to_C(arg3));
18f5805b3920 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7602
diff changeset
   778
	RETURN (__MKINT(retVal));
3612
5d6fc1e8e578 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2880
diff changeset
   779
    }
5d6fc1e8e578 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2880
diff changeset
   780
%}.
5d6fc1e8e578 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2880
diff changeset
   781
    self primitiveFailed
5d6fc1e8e578 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2880
diff changeset
   782
!
5d6fc1e8e578 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2880
diff changeset
   783
848
76a83f34c26a moved ExtBytes & ExtFunc from libbasic2
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   784
callWithArguments:argArray
76a83f34c26a moved ExtBytes & ExtFunc from libbasic2
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   785
    "call the underlying C function, passing up to 10 arguments.
76a83f34c26a moved ExtBytes & ExtFunc from libbasic2
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   786
     The arguments are converted to a corresponding C data type,
76a83f34c26a moved ExtBytes & ExtFunc from libbasic2
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   787
     as defined in the convertST_to_C() function.
8534
dcb1cbd43198 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7665
diff changeset
   788
     The return value is interpreted as an integer
848
76a83f34c26a moved ExtBytes & ExtFunc from libbasic2
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   789
     (and must be converted to an externalBytes object,
76a83f34c26a moved ExtBytes & ExtFunc from libbasic2
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   790
      if it is a pointer to something).
76a83f34c26a moved ExtBytes & ExtFunc from libbasic2
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   791
76a83f34c26a moved ExtBytes & ExtFunc from libbasic2
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   792
     DANGER alert: This is an unprotected low-level entry.
76a83f34c26a moved ExtBytes & ExtFunc from libbasic2
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   793
     Not for normal application usage.
76a83f34c26a moved ExtBytes & ExtFunc from libbasic2
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   794
    "
76a83f34c26a moved ExtBytes & ExtFunc from libbasic2
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   795
%{
2880
87d9ea943024 alpha stuff
Claus Gittinger <cg@exept.de>
parents: 2769
diff changeset
   796
    LINTFUNC func;
848
76a83f34c26a moved ExtBytes & ExtFunc from libbasic2
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   797
#   define NUMARGS 10
2880
87d9ea943024 alpha stuff
Claus Gittinger <cg@exept.de>
parents: 2769
diff changeset
   798
    INT args[NUMARGS];
87d9ea943024 alpha stuff
Claus Gittinger <cg@exept.de>
parents: 2769
diff changeset
   799
    INT retVal;
848
76a83f34c26a moved ExtBytes & ExtFunc from libbasic2
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   800
    OBJ *ap;
2880
87d9ea943024 alpha stuff
Claus Gittinger <cg@exept.de>
parents: 2769
diff changeset
   801
    INT convertST_to_C();
848
76a83f34c26a moved ExtBytes & ExtFunc from libbasic2
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   802
2880
87d9ea943024 alpha stuff
Claus Gittinger <cg@exept.de>
parents: 2769
diff changeset
   803
    func = (LINTFUNC) __INST(code_);
21623
0fd2de531f9a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 20957
diff changeset
   804
    if (func && __isArrayLike(argArray)) {
1133
961f2b095c22 underline cleanup
Claus Gittinger <cg@exept.de>
parents: 917
diff changeset
   805
	int n = __arraySize(argArray);
848
76a83f34c26a moved ExtBytes & ExtFunc from libbasic2
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   806
	int i;
76a83f34c26a moved ExtBytes & ExtFunc from libbasic2
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   807
76a83f34c26a moved ExtBytes & ExtFunc from libbasic2
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   808
	if (n <= 10) {
1133
961f2b095c22 underline cleanup
Claus Gittinger <cg@exept.de>
parents: 917
diff changeset
   809
	    ap = __ArrayInstPtr(argArray)->a_element;
848
76a83f34c26a moved ExtBytes & ExtFunc from libbasic2
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   810
	    for (i=0; i<NUMARGS; i++) {
76a83f34c26a moved ExtBytes & ExtFunc from libbasic2
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   811
		args[i] = convertST_to_C(*ap++);
76a83f34c26a moved ExtBytes & ExtFunc from libbasic2
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   812
	    }
76a83f34c26a moved ExtBytes & ExtFunc from libbasic2
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   813
	}
76a83f34c26a moved ExtBytes & ExtFunc from libbasic2
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   814
	switch (n) {
76a83f34c26a moved ExtBytes & ExtFunc from libbasic2
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   815
	    case 0:
76a83f34c26a moved ExtBytes & ExtFunc from libbasic2
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   816
		retVal = (*func)();
76a83f34c26a moved ExtBytes & ExtFunc from libbasic2
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   817
		break;
76a83f34c26a moved ExtBytes & ExtFunc from libbasic2
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   818
	    case 1:
76a83f34c26a moved ExtBytes & ExtFunc from libbasic2
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   819
		retVal = (*func)(args[0]);
76a83f34c26a moved ExtBytes & ExtFunc from libbasic2
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   820
		break;
76a83f34c26a moved ExtBytes & ExtFunc from libbasic2
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   821
	    case 2:
76a83f34c26a moved ExtBytes & ExtFunc from libbasic2
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   822
		retVal = (*func)(args[0], args[1]);
76a83f34c26a moved ExtBytes & ExtFunc from libbasic2
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   823
		break;
76a83f34c26a moved ExtBytes & ExtFunc from libbasic2
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   824
	    case 3:
76a83f34c26a moved ExtBytes & ExtFunc from libbasic2
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   825
		retVal = (*func)(args[0], args[1], args[2]);
76a83f34c26a moved ExtBytes & ExtFunc from libbasic2
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   826
		break;
76a83f34c26a moved ExtBytes & ExtFunc from libbasic2
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   827
	    case 4:
76a83f34c26a moved ExtBytes & ExtFunc from libbasic2
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   828
		retVal = (*func)(args[0], args[1], args[2], args[3]);
76a83f34c26a moved ExtBytes & ExtFunc from libbasic2
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   829
		break;
76a83f34c26a moved ExtBytes & ExtFunc from libbasic2
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   830
	    case 5:
76a83f34c26a moved ExtBytes & ExtFunc from libbasic2
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   831
		retVal = (*func)(args[0], args[1], args[2], args[3],
76a83f34c26a moved ExtBytes & ExtFunc from libbasic2
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   832
				 args[4]);
76a83f34c26a moved ExtBytes & ExtFunc from libbasic2
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   833
		break;
76a83f34c26a moved ExtBytes & ExtFunc from libbasic2
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   834
	    case 6:
76a83f34c26a moved ExtBytes & ExtFunc from libbasic2
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   835
		retVal = (*func)(args[0], args[1], args[2], args[3],
76a83f34c26a moved ExtBytes & ExtFunc from libbasic2
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   836
				 args[4], args[5]);
76a83f34c26a moved ExtBytes & ExtFunc from libbasic2
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   837
		break;
76a83f34c26a moved ExtBytes & ExtFunc from libbasic2
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   838
	    case 7:
76a83f34c26a moved ExtBytes & ExtFunc from libbasic2
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   839
		retVal = (*func)(args[0], args[1], args[2], args[3],
76a83f34c26a moved ExtBytes & ExtFunc from libbasic2
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   840
				 args[4], args[5], args[6]);
76a83f34c26a moved ExtBytes & ExtFunc from libbasic2
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   841
		break;
76a83f34c26a moved ExtBytes & ExtFunc from libbasic2
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   842
	    case 8:
76a83f34c26a moved ExtBytes & ExtFunc from libbasic2
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   843
		retVal = (*func)(args[0], args[1], args[2], args[3],
76a83f34c26a moved ExtBytes & ExtFunc from libbasic2
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   844
				 args[4], args[5], args[6], args[7]);
76a83f34c26a moved ExtBytes & ExtFunc from libbasic2
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   845
		break;
76a83f34c26a moved ExtBytes & ExtFunc from libbasic2
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   846
	    case 9:
76a83f34c26a moved ExtBytes & ExtFunc from libbasic2
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   847
		retVal = (*func)(args[0], args[1], args[2], args[3],
76a83f34c26a moved ExtBytes & ExtFunc from libbasic2
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   848
				 args[4], args[5], args[6], args[7],
76a83f34c26a moved ExtBytes & ExtFunc from libbasic2
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   849
				 args[8]);
76a83f34c26a moved ExtBytes & ExtFunc from libbasic2
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   850
		break;
76a83f34c26a moved ExtBytes & ExtFunc from libbasic2
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   851
	    case 10:
76a83f34c26a moved ExtBytes & ExtFunc from libbasic2
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   852
		retVal = (*func)(args[0], args[1], args[2], args[3],
76a83f34c26a moved ExtBytes & ExtFunc from libbasic2
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   853
				 args[4], args[5], args[6], args[7],
76a83f34c26a moved ExtBytes & ExtFunc from libbasic2
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   854
				 args[8], args[9]);
76a83f34c26a moved ExtBytes & ExtFunc from libbasic2
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   855
		break;
76a83f34c26a moved ExtBytes & ExtFunc from libbasic2
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   856
	    default:
76a83f34c26a moved ExtBytes & ExtFunc from libbasic2
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   857
		goto err;
76a83f34c26a moved ExtBytes & ExtFunc from libbasic2
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   858
	}
76a83f34c26a moved ExtBytes & ExtFunc from libbasic2
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   859
	RETURN (__MKINT(retVal));
76a83f34c26a moved ExtBytes & ExtFunc from libbasic2
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   860
    }
76a83f34c26a moved ExtBytes & ExtFunc from libbasic2
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   861
  err: ;
76a83f34c26a moved ExtBytes & ExtFunc from libbasic2
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   862
%}.
76a83f34c26a moved ExtBytes & ExtFunc from libbasic2
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   863
    self primitiveFailed
1545
01e11b46ca65 more possible argument types
Claus Gittinger <cg@exept.de>
parents: 1543
diff changeset
   864
!
01e11b46ca65 more possible argument types
Claus Gittinger <cg@exept.de>
parents: 1543
diff changeset
   865
01e11b46ca65 more possible argument types
Claus Gittinger <cg@exept.de>
parents: 1543
diff changeset
   866
callWithDouble:aFloatArg returnsDouble:doubleFlag
01e11b46ca65 more possible argument types
Claus Gittinger <cg@exept.de>
parents: 1543
diff changeset
   867
    "call the underlying C function, passing a single double argument.
01e11b46ca65 more possible argument types
Claus Gittinger <cg@exept.de>
parents: 1543
diff changeset
   868
     The returnsDouble flag specifies if the returnValue is a double; if false,
01e11b46ca65 more possible argument types
Claus Gittinger <cg@exept.de>
parents: 1543
diff changeset
   869
     an integer returnValue is assumed."
01e11b46ca65 more possible argument types
Claus Gittinger <cg@exept.de>
parents: 1543
diff changeset
   870
%{
01e11b46ca65 more possible argument types
Claus Gittinger <cg@exept.de>
parents: 1543
diff changeset
   871
    typedef double  (*DOUBLEFUNC)();
2880
87d9ea943024 alpha stuff
Claus Gittinger <cg@exept.de>
parents: 2769
diff changeset
   872
    LINTFUNC func;
1545
01e11b46ca65 more possible argument types
Claus Gittinger <cg@exept.de>
parents: 1543
diff changeset
   873
    DOUBLEFUNC dfunc;
01e11b46ca65 more possible argument types
Claus Gittinger <cg@exept.de>
parents: 1543
diff changeset
   874
    double arg, dretVal;
2880
87d9ea943024 alpha stuff
Claus Gittinger <cg@exept.de>
parents: 2769
diff changeset
   875
    INT retVal;
1545
01e11b46ca65 more possible argument types
Claus Gittinger <cg@exept.de>
parents: 1543
diff changeset
   876
2880
87d9ea943024 alpha stuff
Claus Gittinger <cg@exept.de>
parents: 2769
diff changeset
   877
    func = (LINTFUNC) __INST(code_);
1545
01e11b46ca65 more possible argument types
Claus Gittinger <cg@exept.de>
parents: 1543
diff changeset
   878
    if (func) {
7665
18f5805b3920 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7602
diff changeset
   879
	if (__isFloat(aFloatArg)) {
1545
01e11b46ca65 more possible argument types
Claus Gittinger <cg@exept.de>
parents: 1543
diff changeset
   880
	    arg = __floatVal(aFloatArg);
01e11b46ca65 more possible argument types
Claus Gittinger <cg@exept.de>
parents: 1543
diff changeset
   881
	} else if (__isShortFloat(aFloatArg)) {
01e11b46ca65 more possible argument types
Claus Gittinger <cg@exept.de>
parents: 1543
diff changeset
   882
	    arg = (double)(__shortFloatVal(aFloatArg));
01e11b46ca65 more possible argument types
Claus Gittinger <cg@exept.de>
parents: 1543
diff changeset
   883
	} else {
01e11b46ca65 more possible argument types
Claus Gittinger <cg@exept.de>
parents: 1543
diff changeset
   884
	    arg = (double)(__signedLongIntVal(aFloatArg));
01e11b46ca65 more possible argument types
Claus Gittinger <cg@exept.de>
parents: 1543
diff changeset
   885
	}
01e11b46ca65 more possible argument types
Claus Gittinger <cg@exept.de>
parents: 1543
diff changeset
   886
	if (doubleFlag == true) {
01e11b46ca65 more possible argument types
Claus Gittinger <cg@exept.de>
parents: 1543
diff changeset
   887
	    dfunc = (DOUBLEFUNC)func;
01e11b46ca65 more possible argument types
Claus Gittinger <cg@exept.de>
parents: 1543
diff changeset
   888
	    dretVal = (*dfunc)(arg);
01e11b46ca65 more possible argument types
Claus Gittinger <cg@exept.de>
parents: 1543
diff changeset
   889
	    RETURN (__MKFLOAT(dretVal));
01e11b46ca65 more possible argument types
Claus Gittinger <cg@exept.de>
parents: 1543
diff changeset
   890
	} else {
01e11b46ca65 more possible argument types
Claus Gittinger <cg@exept.de>
parents: 1543
diff changeset
   891
	    retVal = (*func)(arg);
01e11b46ca65 more possible argument types
Claus Gittinger <cg@exept.de>
parents: 1543
diff changeset
   892
	    RETURN (__MKINT(retVal));
01e11b46ca65 more possible argument types
Claus Gittinger <cg@exept.de>
parents: 1543
diff changeset
   893
	}
01e11b46ca65 more possible argument types
Claus Gittinger <cg@exept.de>
parents: 1543
diff changeset
   894
    }
01e11b46ca65 more possible argument types
Claus Gittinger <cg@exept.de>
parents: 1543
diff changeset
   895
%}.
01e11b46ca65 more possible argument types
Claus Gittinger <cg@exept.de>
parents: 1543
diff changeset
   896
    self primitiveFailed
01e11b46ca65 more possible argument types
Claus Gittinger <cg@exept.de>
parents: 1543
diff changeset
   897
!
01e11b46ca65 more possible argument types
Claus Gittinger <cg@exept.de>
parents: 1543
diff changeset
   898
01e11b46ca65 more possible argument types
Claus Gittinger <cg@exept.de>
parents: 1543
diff changeset
   899
callWithDouble:aFloatArg1 withDouble:aFloatArg2 returnsDouble:doubleFlag
01e11b46ca65 more possible argument types
Claus Gittinger <cg@exept.de>
parents: 1543
diff changeset
   900
    "call the underlying C function, passing two double arguments.
01e11b46ca65 more possible argument types
Claus Gittinger <cg@exept.de>
parents: 1543
diff changeset
   901
     The returnsDouble flag specifies if the returnValue is a double; if false,
01e11b46ca65 more possible argument types
Claus Gittinger <cg@exept.de>
parents: 1543
diff changeset
   902
     an integer returnValue is assumed."
01e11b46ca65 more possible argument types
Claus Gittinger <cg@exept.de>
parents: 1543
diff changeset
   903
%{
01e11b46ca65 more possible argument types
Claus Gittinger <cg@exept.de>
parents: 1543
diff changeset
   904
    typedef double  (*DOUBLEFUNC)();
2880
87d9ea943024 alpha stuff
Claus Gittinger <cg@exept.de>
parents: 2769
diff changeset
   905
    LINTFUNC func;
1545
01e11b46ca65 more possible argument types
Claus Gittinger <cg@exept.de>
parents: 1543
diff changeset
   906
    DOUBLEFUNC dfunc;
01e11b46ca65 more possible argument types
Claus Gittinger <cg@exept.de>
parents: 1543
diff changeset
   907
    double arg1, arg2, dretVal;
01e11b46ca65 more possible argument types
Claus Gittinger <cg@exept.de>
parents: 1543
diff changeset
   908
    int retVal;
01e11b46ca65 more possible argument types
Claus Gittinger <cg@exept.de>
parents: 1543
diff changeset
   909
2880
87d9ea943024 alpha stuff
Claus Gittinger <cg@exept.de>
parents: 2769
diff changeset
   910
    func = (LINTFUNC) __INST(code_);
1545
01e11b46ca65 more possible argument types
Claus Gittinger <cg@exept.de>
parents: 1543
diff changeset
   911
    if (func) {
7665
18f5805b3920 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7602
diff changeset
   912
	if (__isFloat(aFloatArg1)) {
18f5805b3920 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7602
diff changeset
   913
	    arg1 = __floatVal(aFloatArg1);
18f5805b3920 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7602
diff changeset
   914
	} else if (__isShortFloat(aFloatArg1)) {
18f5805b3920 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7602
diff changeset
   915
	    arg1 = (double)(__shortFloatVal(aFloatArg1));
18f5805b3920 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7602
diff changeset
   916
	} else {
18f5805b3920 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7602
diff changeset
   917
	    arg1 = (double)(__signedLongIntVal(aFloatArg1));
18f5805b3920 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7602
diff changeset
   918
	}
18f5805b3920 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7602
diff changeset
   919
	if (__isFloat(aFloatArg2)) {
18f5805b3920 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7602
diff changeset
   920
	    arg2 = __floatVal(aFloatArg2);
18f5805b3920 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7602
diff changeset
   921
	} else if (__isShortFloat(aFloatArg2)) {
18f5805b3920 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7602
diff changeset
   922
	    arg2 = (double)(__shortFloatVal(aFloatArg2));
18f5805b3920 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7602
diff changeset
   923
	} else {
18f5805b3920 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7602
diff changeset
   924
	    arg2 = (double)(__signedLongIntVal(aFloatArg2));
18f5805b3920 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7602
diff changeset
   925
	}
18f5805b3920 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7602
diff changeset
   926
	if (doubleFlag == true) {
18f5805b3920 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7602
diff changeset
   927
	    dfunc = (DOUBLEFUNC)func;
18f5805b3920 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7602
diff changeset
   928
	    dretVal = (*dfunc)(arg1, arg2);
18f5805b3920 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7602
diff changeset
   929
	    RETURN (__MKFLOAT(dretVal));
18f5805b3920 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7602
diff changeset
   930
	} else {
18f5805b3920 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7602
diff changeset
   931
	    retVal = (*func)(arg1, arg2);
18f5805b3920 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7602
diff changeset
   932
	    RETURN (__MKINT(retVal));
18f5805b3920 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7602
diff changeset
   933
	}
1545
01e11b46ca65 more possible argument types
Claus Gittinger <cg@exept.de>
parents: 1543
diff changeset
   934
    }
01e11b46ca65 more possible argument types
Claus Gittinger <cg@exept.de>
parents: 1543
diff changeset
   935
%}.
01e11b46ca65 more possible argument types
Claus Gittinger <cg@exept.de>
parents: 1543
diff changeset
   936
    self primitiveFailed
848
76a83f34c26a moved ExtBytes & ExtFunc from libbasic2
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   937
! !
76a83f34c26a moved ExtBytes & ExtFunc from libbasic2
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   938
1547
fa7cc4070fc0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1545
diff changeset
   939
!ExternalFunction methodsFor:'printing & storing'!
fa7cc4070fc0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1545
diff changeset
   940
fa7cc4070fc0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1545
diff changeset
   941
printOn:aStream
fa7cc4070fc0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1545
diff changeset
   942
    "append a printed representation of the receiver to aStream"
fa7cc4070fc0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1545
diff changeset
   943
fa7cc4070fc0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1545
diff changeset
   944
    |addr|
fa7cc4070fc0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1545
diff changeset
   945
fa7cc4070fc0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1545
diff changeset
   946
    name isNil ifTrue:[^ super printOn:aStream].
fa7cc4070fc0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1545
diff changeset
   947
fa7cc4070fc0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1545
diff changeset
   948
    aStream nextPutAll:self class name; nextPutAll:'(name: ''';
7665
18f5805b3920 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7602
diff changeset
   949
	    nextPutAll:name; nextPutAll:''' address: '.
1547
fa7cc4070fc0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1545
diff changeset
   950
21623
0fd2de531f9a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 20957
diff changeset
   951
    addr := self getCode.
1547
fa7cc4070fc0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1545
diff changeset
   952
    addr isNil ifTrue:[
7665
18f5805b3920 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7602
diff changeset
   953
	aStream nextPutAll:'** unloaded **'
1547
fa7cc4070fc0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1545
diff changeset
   954
    ] ifFalse:[
7665
18f5805b3920 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7602
diff changeset
   955
	aStream nextPutAll:'0x';
18f5805b3920 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7602
diff changeset
   956
		nextPutAll:(addr hexPrintString)
1547
fa7cc4070fc0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1545
diff changeset
   957
    ].
fa7cc4070fc0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1545
diff changeset
   958
fa7cc4070fc0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1545
diff changeset
   959
    moduleHandle notNil ifTrue:[
8534
dcb1cbd43198 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7665
diff changeset
   960
	aStream nextPutAll:' from: ''';
7665
18f5805b3920 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7602
diff changeset
   961
		nextPutAll:(moduleHandle pathName asFilename baseName);
18f5805b3920 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7602
diff changeset
   962
		nextPutAll:''''.
1547
fa7cc4070fc0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1545
diff changeset
   963
    ].
fa7cc4070fc0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1545
diff changeset
   964
fa7cc4070fc0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1545
diff changeset
   965
    aStream nextPutAll:')'
fa7cc4070fc0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1545
diff changeset
   966
fa7cc4070fc0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1545
diff changeset
   967
    "Modified: 12.7.1996 / 23:31:49 / cg"
fa7cc4070fc0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1545
diff changeset
   968
! !
fa7cc4070fc0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1545
diff changeset
   969
7257
b9f0fb923c72 method category rename
Claus Gittinger <cg@exept.de>
parents: 5164
diff changeset
   970
!ExternalFunction methodsFor:'private-loader access'!
1547
fa7cc4070fc0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1545
diff changeset
   971
9395
f02332e03370 also flush the moduleHandle (to force reloading of the library)
ca
parents: 9323
diff changeset
   972
invalidate
f02332e03370 also flush the moduleHandle (to force reloading of the library)
ca
parents: 9323
diff changeset
   973
    super invalidate.
f02332e03370 also flush the moduleHandle (to force reloading of the library)
ca
parents: 9323
diff changeset
   974
    moduleHandle := nil.
f02332e03370 also flush the moduleHandle (to force reloading of the library)
ca
parents: 9323
diff changeset
   975
!
f02332e03370 also flush the moduleHandle (to force reloading of the library)
ca
parents: 9323
diff changeset
   976
9397
cbe664f0fc8c function registration handling
ca
parents: 9395
diff changeset
   977
setModuleHandle:aHandle
cbe664f0fc8c function registration handling
ca
parents: 9395
diff changeset
   978
    "set the moduleHandle.
cbe664f0fc8c function registration handling
ca
parents: 9395
diff changeset
   979
     This is a private interface for the objectFileLoader; not for public use."
cbe664f0fc8c function registration handling
ca
parents: 9395
diff changeset
   980
cbe664f0fc8c function registration handling
ca
parents: 9395
diff changeset
   981
    moduleHandle := aHandle
cbe664f0fc8c function registration handling
ca
parents: 9395
diff changeset
   982
!
cbe664f0fc8c function registration handling
ca
parents: 9395
diff changeset
   983
1547
fa7cc4070fc0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1545
diff changeset
   984
setName:aString moduleHandle:aHandle
fa7cc4070fc0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1545
diff changeset
   985
    "set the name & moduleHandle.
fa7cc4070fc0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1545
diff changeset
   986
     This is a private interface for the objectFileLoader; not for public use."
fa7cc4070fc0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1545
diff changeset
   987
fa7cc4070fc0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1545
diff changeset
   988
    name := aString.
fa7cc4070fc0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1545
diff changeset
   989
    moduleHandle := aHandle
fa7cc4070fc0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1545
diff changeset
   990
! !
fa7cc4070fc0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1545
diff changeset
   991
3612
5d6fc1e8e578 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2880
diff changeset
   992
!ExternalFunction class methodsFor:'documentation'!
848
76a83f34c26a moved ExtBytes & ExtFunc from libbasic2
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   993
76a83f34c26a moved ExtBytes & ExtFunc from libbasic2
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   994
version
19480
dedfb6c4bc16 custom functions
Claus Gittinger <cg@exept.de>
parents: 12484
diff changeset
   995
    ^ '$Header$'
12484
7f0cc6e86a66 change __isString() to __isStringLike() in primitive code
Stefan Vogel <sv@exept.de>
parents: 9397
diff changeset
   996
!
7f0cc6e86a66 change __isString() to __isStringLike() in primitive code
Stefan Vogel <sv@exept.de>
parents: 9397
diff changeset
   997
7f0cc6e86a66 change __isString() to __isStringLike() in primitive code
Stefan Vogel <sv@exept.de>
parents: 9397
diff changeset
   998
version_CVS
19480
dedfb6c4bc16 custom functions
Claus Gittinger <cg@exept.de>
parents: 12484
diff changeset
   999
    ^ '$Header$'
848
76a83f34c26a moved ExtBytes & ExtFunc from libbasic2
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1000
! !
7257
b9f0fb923c72 method category rename
Claus Gittinger <cg@exept.de>
parents: 5164
diff changeset
  1001
20510
3c745c287254 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 19480
diff changeset
  1002
848
76a83f34c26a moved ExtBytes & ExtFunc from libbasic2
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1003
ExternalFunction initialize!