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