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