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