WinAPIFunction.st
author Claus Gittinger <cg@exept.de>
Thu, 09 Jun 2016 13:02:17 +0200
changeset 3909 10e26efa4fb4
parent 3908 6b71bf0b6d16
child 3912 bc757e3447e6
permissions -rw-r--r--
*** empty log message ***
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
659
c48a5b89ca8e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     1
"
c48a5b89ca8e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     2
 COPYRIGHT (c) 1998 by eXept Software AG
3907
3916d3edc89c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1566
diff changeset
     3
	      All Rights Reserved
659
c48a5b89ca8e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     4
c48a5b89ca8e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     5
 This software is furnished under a license and may be used
c48a5b89ca8e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     6
 only in accordance with the terms of that license and with the
c48a5b89ca8e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     7
 inclusion of the above copyright notice.   This software may not
c48a5b89ca8e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     8
 be provided or otherwise made available to, or used by, any
c48a5b89ca8e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     9
 other person.  No title to or ownership of the software is
c48a5b89ca8e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    10
 hereby transferred.
c48a5b89ca8e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    11
"
c48a5b89ca8e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    12
c48a5b89ca8e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    13
c48a5b89ca8e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    14
ExternalFunction subclass:#WinAPIFunction
c48a5b89ca8e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    15
	instanceVariableNames:''
c48a5b89ca8e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    16
	classVariableNames:''
c48a5b89ca8e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    17
	poolDictionaries:''
c48a5b89ca8e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    18
	category:'OS-Windows'
c48a5b89ca8e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    19
!
c48a5b89ca8e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    20
c48a5b89ca8e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    21
!WinAPIFunction primitiveDefinitions!
c48a5b89ca8e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    22
%{
3908
6b71bf0b6d16 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3907
diff changeset
    23
#ifdef __x86_64__
6b71bf0b6d16 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3907
diff changeset
    24
 // finally, Microsoft got rid of this garbage
6b71bf0b6d16 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3907
diff changeset
    25
 typedef int  (*WINAPI_intFUNC)();
6b71bf0b6d16 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3907
diff changeset
    26
#else
6b71bf0b6d16 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3907
diff changeset
    27
 typedef WINAPI int  (*WINAPI_intFUNC)();
6b71bf0b6d16 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3907
diff changeset
    28
#endif
659
c48a5b89ca8e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    29
%}
c48a5b89ca8e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    30
c48a5b89ca8e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    31
! !
c48a5b89ca8e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    32
c48a5b89ca8e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    33
!WinAPIFunction class methodsFor:'documentation'!
c48a5b89ca8e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    34
c48a5b89ca8e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    35
copyright
c48a5b89ca8e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    36
"
c48a5b89ca8e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    37
 COPYRIGHT (c) 1998 by eXept Software AG
3907
3916d3edc89c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1566
diff changeset
    38
	      All Rights Reserved
659
c48a5b89ca8e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    39
c48a5b89ca8e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    40
 This software is furnished under a license and may be used
c48a5b89ca8e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    41
 only in accordance with the terms of that license and with the
c48a5b89ca8e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    42
 inclusion of the above copyright notice.   This software may not
c48a5b89ca8e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    43
 be provided or otherwise made available to, or used by, any
c48a5b89ca8e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    44
 other person.  No title to or ownership of the software is
c48a5b89ca8e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    45
 hereby transferred.
c48a5b89ca8e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    46
"
c48a5b89ca8e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    47
c48a5b89ca8e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    48
!
c48a5b89ca8e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    49
c48a5b89ca8e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    50
documentation
c48a5b89ca8e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    51
"
c48a5b89ca8e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    52
    WIN32 only:
c48a5b89ca8e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    53
c48a5b89ca8e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    54
    Experimental class representing external (non-Smalltalk) WINAPI functions.
c48a5b89ca8e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    55
    These will provide the same functionality and protocol as
c48a5b89ca8e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    56
    regular externalFunctions, but use a different calling convention.
c48a5b89ca8e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    57
c48a5b89ca8e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    58
    Warning: under construction.
c48a5b89ca8e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    59
c48a5b89ca8e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    60
    [author:]
3907
3916d3edc89c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1566
diff changeset
    61
	Claus Gittinger
659
c48a5b89ca8e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    62
c48a5b89ca8e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    63
    [see also:]
3907
3916d3edc89c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1566
diff changeset
    64
	ExternalAddress ExternalBytes
659
c48a5b89ca8e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    65
"
c48a5b89ca8e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    66
c48a5b89ca8e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    67
c48a5b89ca8e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    68
! !
c48a5b89ca8e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    69
c48a5b89ca8e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    70
!WinAPIFunction methodsFor:'function calling'!
c48a5b89ca8e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    71
c48a5b89ca8e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    72
call
c48a5b89ca8e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    73
    "call the underlying C function, passing no argument.
3907
3916d3edc89c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1566
diff changeset
    74
     The return value is interpreted as an integer
659
c48a5b89ca8e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    75
     (and must be converted to an externalBytes object,
c48a5b89ca8e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    76
      if it is a pointer to something).
c48a5b89ca8e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    77
c48a5b89ca8e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    78
     DANGER alert: This is an unprotected low-level entry.
c48a5b89ca8e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    79
     Not for normal application usage.
c48a5b89ca8e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    80
    "
c48a5b89ca8e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    81
%{
3907
3916d3edc89c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1566
diff changeset
    82
    WINAPI_intFUNC func;
659
c48a5b89ca8e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    83
    INT retVal;
c48a5b89ca8e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    84
3907
3916d3edc89c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1566
diff changeset
    85
    func = (WINAPI_intFUNC) __INST(code_);
659
c48a5b89ca8e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    86
    if (func) {
3907
3916d3edc89c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1566
diff changeset
    87
	retVal = (*func)();
3916d3edc89c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1566
diff changeset
    88
	RETURN (__MKINT(retVal));
659
c48a5b89ca8e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    89
    }
c48a5b89ca8e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    90
%}.
c48a5b89ca8e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    91
    self primitiveFailed
c48a5b89ca8e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    92
c48a5b89ca8e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    93
    "Created: / 18.6.1998 / 18:01:28 / cg"
660
738f8b4edcac checkin from browser
Claus Gittinger <cg@exept.de>
parents: 659
diff changeset
    94
    "Modified: / 18.6.1998 / 18:04:48 / cg"
738f8b4edcac checkin from browser
Claus Gittinger <cg@exept.de>
parents: 659
diff changeset
    95
!
738f8b4edcac checkin from browser
Claus Gittinger <cg@exept.de>
parents: 659
diff changeset
    96
738f8b4edcac checkin from browser
Claus Gittinger <cg@exept.de>
parents: 659
diff changeset
    97
callWith:arg
738f8b4edcac checkin from browser
Claus Gittinger <cg@exept.de>
parents: 659
diff changeset
    98
    "call the underlying C function, passing a single argument.
738f8b4edcac checkin from browser
Claus Gittinger <cg@exept.de>
parents: 659
diff changeset
    99
     The argument arg is converted to a corresponding C data type,
738f8b4edcac checkin from browser
Claus Gittinger <cg@exept.de>
parents: 659
diff changeset
   100
     as defined in the convertST_to_C() function.
3907
3916d3edc89c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1566
diff changeset
   101
     The return value is interpreted as an integer
660
738f8b4edcac checkin from browser
Claus Gittinger <cg@exept.de>
parents: 659
diff changeset
   102
     (and must be converted to an externalBytes object,
738f8b4edcac checkin from browser
Claus Gittinger <cg@exept.de>
parents: 659
diff changeset
   103
      if it is a pointer to something).
738f8b4edcac checkin from browser
Claus Gittinger <cg@exept.de>
parents: 659
diff changeset
   104
738f8b4edcac checkin from browser
Claus Gittinger <cg@exept.de>
parents: 659
diff changeset
   105
     DANGER alert: This is an unprotected low-level entry.
738f8b4edcac checkin from browser
Claus Gittinger <cg@exept.de>
parents: 659
diff changeset
   106
     Not for normal application usage.
738f8b4edcac checkin from browser
Claus Gittinger <cg@exept.de>
parents: 659
diff changeset
   107
    "
738f8b4edcac checkin from browser
Claus Gittinger <cg@exept.de>
parents: 659
diff changeset
   108
%{
3909
10e26efa4fb4 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3908
diff changeset
   109
    INT convertST_to_C();
3907
3916d3edc89c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1566
diff changeset
   110
    WINAPI_intFUNC func;
660
738f8b4edcac checkin from browser
Claus Gittinger <cg@exept.de>
parents: 659
diff changeset
   111
    INT retVal;
738f8b4edcac checkin from browser
Claus Gittinger <cg@exept.de>
parents: 659
diff changeset
   112
3907
3916d3edc89c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1566
diff changeset
   113
    func = (WINAPI_intFUNC) __INST(code_);
660
738f8b4edcac checkin from browser
Claus Gittinger <cg@exept.de>
parents: 659
diff changeset
   114
    if (func) {
3907
3916d3edc89c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1566
diff changeset
   115
	retVal = (*func)(convertST_to_C(arg));
3916d3edc89c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1566
diff changeset
   116
	RETURN (__MKINT(retVal));
660
738f8b4edcac checkin from browser
Claus Gittinger <cg@exept.de>
parents: 659
diff changeset
   117
    }
738f8b4edcac checkin from browser
Claus Gittinger <cg@exept.de>
parents: 659
diff changeset
   118
%}.
738f8b4edcac checkin from browser
Claus Gittinger <cg@exept.de>
parents: 659
diff changeset
   119
    self primitiveFailed
738f8b4edcac checkin from browser
Claus Gittinger <cg@exept.de>
parents: 659
diff changeset
   120
738f8b4edcac checkin from browser
Claus Gittinger <cg@exept.de>
parents: 659
diff changeset
   121
    "Created: / 18.6.1998 / 18:04:30 / cg"
738f8b4edcac checkin from browser
Claus Gittinger <cg@exept.de>
parents: 659
diff changeset
   122
    "Modified: / 18.6.1998 / 18:04:53 / cg"
738f8b4edcac checkin from browser
Claus Gittinger <cg@exept.de>
parents: 659
diff changeset
   123
!
738f8b4edcac checkin from browser
Claus Gittinger <cg@exept.de>
parents: 659
diff changeset
   124
738f8b4edcac checkin from browser
Claus Gittinger <cg@exept.de>
parents: 659
diff changeset
   125
callWith:arg1 with:arg2
738f8b4edcac checkin from browser
Claus Gittinger <cg@exept.de>
parents: 659
diff changeset
   126
    "call the underlying C function, passing two args.
738f8b4edcac checkin from browser
Claus Gittinger <cg@exept.de>
parents: 659
diff changeset
   127
     The arguments are converted to a corresponding C data type,
738f8b4edcac checkin from browser
Claus Gittinger <cg@exept.de>
parents: 659
diff changeset
   128
     as defined in the convertST_to_C() function.
3907
3916d3edc89c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1566
diff changeset
   129
     The return value is interpreted as an integer
660
738f8b4edcac checkin from browser
Claus Gittinger <cg@exept.de>
parents: 659
diff changeset
   130
     (and must be converted to an externalBytes object,
738f8b4edcac checkin from browser
Claus Gittinger <cg@exept.de>
parents: 659
diff changeset
   131
      if it is a pointer to something).
738f8b4edcac checkin from browser
Claus Gittinger <cg@exept.de>
parents: 659
diff changeset
   132
738f8b4edcac checkin from browser
Claus Gittinger <cg@exept.de>
parents: 659
diff changeset
   133
     DANGER alert: This is an unprotected low-level entry.
738f8b4edcac checkin from browser
Claus Gittinger <cg@exept.de>
parents: 659
diff changeset
   134
     Not for normal application usage.
738f8b4edcac checkin from browser
Claus Gittinger <cg@exept.de>
parents: 659
diff changeset
   135
    "
738f8b4edcac checkin from browser
Claus Gittinger <cg@exept.de>
parents: 659
diff changeset
   136
%{
3909
10e26efa4fb4 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3908
diff changeset
   137
    INT convertST_to_C();
3907
3916d3edc89c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1566
diff changeset
   138
    WINAPI_intFUNC func;
660
738f8b4edcac checkin from browser
Claus Gittinger <cg@exept.de>
parents: 659
diff changeset
   139
    INT retVal;
738f8b4edcac checkin from browser
Claus Gittinger <cg@exept.de>
parents: 659
diff changeset
   140
3907
3916d3edc89c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1566
diff changeset
   141
    func = (WINAPI_intFUNC) __INST(code_);
660
738f8b4edcac checkin from browser
Claus Gittinger <cg@exept.de>
parents: 659
diff changeset
   142
    if (func) {
3907
3916d3edc89c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1566
diff changeset
   143
	retVal = (*func)(convertST_to_C(arg1), convertST_to_C(arg2));
3916d3edc89c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1566
diff changeset
   144
	RETURN (__MKINT(retVal));
660
738f8b4edcac checkin from browser
Claus Gittinger <cg@exept.de>
parents: 659
diff changeset
   145
    }
738f8b4edcac checkin from browser
Claus Gittinger <cg@exept.de>
parents: 659
diff changeset
   146
%}.
738f8b4edcac checkin from browser
Claus Gittinger <cg@exept.de>
parents: 659
diff changeset
   147
    self primitiveFailed
738f8b4edcac checkin from browser
Claus Gittinger <cg@exept.de>
parents: 659
diff changeset
   148
738f8b4edcac checkin from browser
Claus Gittinger <cg@exept.de>
parents: 659
diff changeset
   149
    "Created: / 18.6.1998 / 18:05:07 / cg"
738f8b4edcac checkin from browser
Claus Gittinger <cg@exept.de>
parents: 659
diff changeset
   150
!
738f8b4edcac checkin from browser
Claus Gittinger <cg@exept.de>
parents: 659
diff changeset
   151
738f8b4edcac checkin from browser
Claus Gittinger <cg@exept.de>
parents: 659
diff changeset
   152
callWith:arg1 with:arg2 with:arg3
738f8b4edcac checkin from browser
Claus Gittinger <cg@exept.de>
parents: 659
diff changeset
   153
    "call the underlying C function, passing three args.
738f8b4edcac checkin from browser
Claus Gittinger <cg@exept.de>
parents: 659
diff changeset
   154
     The arguments are converted to a corresponding C data type,
738f8b4edcac checkin from browser
Claus Gittinger <cg@exept.de>
parents: 659
diff changeset
   155
     as defined in the convertST_to_C() function.
3907
3916d3edc89c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1566
diff changeset
   156
     The return value is interpreted as an integer
660
738f8b4edcac checkin from browser
Claus Gittinger <cg@exept.de>
parents: 659
diff changeset
   157
     (and must be converted to an externalBytes object,
738f8b4edcac checkin from browser
Claus Gittinger <cg@exept.de>
parents: 659
diff changeset
   158
      if it is a pointer to something).
738f8b4edcac checkin from browser
Claus Gittinger <cg@exept.de>
parents: 659
diff changeset
   159
738f8b4edcac checkin from browser
Claus Gittinger <cg@exept.de>
parents: 659
diff changeset
   160
     DANGER alert: This is an unprotected low-level entry.
738f8b4edcac checkin from browser
Claus Gittinger <cg@exept.de>
parents: 659
diff changeset
   161
     Not for normal application usage.
738f8b4edcac checkin from browser
Claus Gittinger <cg@exept.de>
parents: 659
diff changeset
   162
    "
738f8b4edcac checkin from browser
Claus Gittinger <cg@exept.de>
parents: 659
diff changeset
   163
%{
3909
10e26efa4fb4 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3908
diff changeset
   164
    INT convertST_to_C();
3907
3916d3edc89c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1566
diff changeset
   165
    WINAPI_intFUNC func;
660
738f8b4edcac checkin from browser
Claus Gittinger <cg@exept.de>
parents: 659
diff changeset
   166
    INT retVal;
738f8b4edcac checkin from browser
Claus Gittinger <cg@exept.de>
parents: 659
diff changeset
   167
3907
3916d3edc89c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1566
diff changeset
   168
    func = (WINAPI_intFUNC) __INST(code_);
660
738f8b4edcac checkin from browser
Claus Gittinger <cg@exept.de>
parents: 659
diff changeset
   169
    if (func) {
3907
3916d3edc89c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1566
diff changeset
   170
	retVal = (*func)(convertST_to_C(arg1), convertST_to_C(arg2), convertST_to_C(arg3));
3916d3edc89c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1566
diff changeset
   171
	RETURN (__MKINT(retVal));
660
738f8b4edcac checkin from browser
Claus Gittinger <cg@exept.de>
parents: 659
diff changeset
   172
    }
738f8b4edcac checkin from browser
Claus Gittinger <cg@exept.de>
parents: 659
diff changeset
   173
%}.
738f8b4edcac checkin from browser
Claus Gittinger <cg@exept.de>
parents: 659
diff changeset
   174
    self primitiveFailed
738f8b4edcac checkin from browser
Claus Gittinger <cg@exept.de>
parents: 659
diff changeset
   175
738f8b4edcac checkin from browser
Claus Gittinger <cg@exept.de>
parents: 659
diff changeset
   176
    "Created: / 18.6.1998 / 18:05:18 / cg"
738f8b4edcac checkin from browser
Claus Gittinger <cg@exept.de>
parents: 659
diff changeset
   177
!
738f8b4edcac checkin from browser
Claus Gittinger <cg@exept.de>
parents: 659
diff changeset
   178
738f8b4edcac checkin from browser
Claus Gittinger <cg@exept.de>
parents: 659
diff changeset
   179
callWithArguments:argArray
738f8b4edcac checkin from browser
Claus Gittinger <cg@exept.de>
parents: 659
diff changeset
   180
    "call the underlying C function, passing up to 10 arguments.
738f8b4edcac checkin from browser
Claus Gittinger <cg@exept.de>
parents: 659
diff changeset
   181
     The arguments are converted to a corresponding C data type,
738f8b4edcac checkin from browser
Claus Gittinger <cg@exept.de>
parents: 659
diff changeset
   182
     as defined in the convertST_to_C() function.
3907
3916d3edc89c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1566
diff changeset
   183
     The return value is interpreted as an integer
660
738f8b4edcac checkin from browser
Claus Gittinger <cg@exept.de>
parents: 659
diff changeset
   184
     (and must be converted to an externalBytes object,
738f8b4edcac checkin from browser
Claus Gittinger <cg@exept.de>
parents: 659
diff changeset
   185
      if it is a pointer to something).
738f8b4edcac checkin from browser
Claus Gittinger <cg@exept.de>
parents: 659
diff changeset
   186
738f8b4edcac checkin from browser
Claus Gittinger <cg@exept.de>
parents: 659
diff changeset
   187
     DANGER alert: This is an unprotected low-level entry.
738f8b4edcac checkin from browser
Claus Gittinger <cg@exept.de>
parents: 659
diff changeset
   188
     Not for normal application usage.
738f8b4edcac checkin from browser
Claus Gittinger <cg@exept.de>
parents: 659
diff changeset
   189
    "
738f8b4edcac checkin from browser
Claus Gittinger <cg@exept.de>
parents: 659
diff changeset
   190
%{
3909
10e26efa4fb4 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3908
diff changeset
   191
    INT convertST_to_C();
3907
3916d3edc89c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1566
diff changeset
   192
    WINAPI_intFUNC func;
660
738f8b4edcac checkin from browser
Claus Gittinger <cg@exept.de>
parents: 659
diff changeset
   193
#   define NUMARGS 10
738f8b4edcac checkin from browser
Claus Gittinger <cg@exept.de>
parents: 659
diff changeset
   194
    INT args[NUMARGS];
738f8b4edcac checkin from browser
Claus Gittinger <cg@exept.de>
parents: 659
diff changeset
   195
    INT retVal;
738f8b4edcac checkin from browser
Claus Gittinger <cg@exept.de>
parents: 659
diff changeset
   196
    OBJ *ap;
738f8b4edcac checkin from browser
Claus Gittinger <cg@exept.de>
parents: 659
diff changeset
   197
3907
3916d3edc89c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1566
diff changeset
   198
    func = (WINAPI_intFUNC) __INST(code_);
1566
465a4de0e714 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 660
diff changeset
   199
    if (func && __isArrayLike(argArray)) {
3907
3916d3edc89c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1566
diff changeset
   200
	int n = __arraySize(argArray);
3916d3edc89c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1566
diff changeset
   201
	int i;
660
738f8b4edcac checkin from browser
Claus Gittinger <cg@exept.de>
parents: 659
diff changeset
   202
3907
3916d3edc89c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1566
diff changeset
   203
	if (n <= 10) {
3916d3edc89c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1566
diff changeset
   204
	    ap = __ArrayInstPtr(argArray)->a_element;
3916d3edc89c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1566
diff changeset
   205
	    for (i=0; i<NUMARGS; i++) {
3916d3edc89c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1566
diff changeset
   206
		args[i] = convertST_to_C(*ap++);
3916d3edc89c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1566
diff changeset
   207
	    }
3916d3edc89c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1566
diff changeset
   208
	}
3916d3edc89c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1566
diff changeset
   209
	switch (n) {
3916d3edc89c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1566
diff changeset
   210
	    case 0:
3916d3edc89c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1566
diff changeset
   211
		retVal = (*func)();
3916d3edc89c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1566
diff changeset
   212
		break;
3916d3edc89c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1566
diff changeset
   213
	    case 1:
3916d3edc89c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1566
diff changeset
   214
		retVal = (*func)(args[0]);
3916d3edc89c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1566
diff changeset
   215
		break;
3916d3edc89c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1566
diff changeset
   216
	    case 2:
3916d3edc89c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1566
diff changeset
   217
		retVal = (*func)(args[0], args[1]);
3916d3edc89c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1566
diff changeset
   218
		break;
3916d3edc89c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1566
diff changeset
   219
	    case 3:
3916d3edc89c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1566
diff changeset
   220
		retVal = (*func)(args[0], args[1], args[2]);
3916d3edc89c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1566
diff changeset
   221
		break;
3916d3edc89c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1566
diff changeset
   222
	    case 4:
3916d3edc89c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1566
diff changeset
   223
		retVal = (*func)(args[0], args[1], args[2], args[3]);
3916d3edc89c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1566
diff changeset
   224
		break;
3916d3edc89c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1566
diff changeset
   225
	    case 5:
3916d3edc89c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1566
diff changeset
   226
		retVal = (*func)(args[0], args[1], args[2], args[3],
3916d3edc89c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1566
diff changeset
   227
				 args[4]);
3916d3edc89c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1566
diff changeset
   228
		break;
3916d3edc89c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1566
diff changeset
   229
	    case 6:
3916d3edc89c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1566
diff changeset
   230
		retVal = (*func)(args[0], args[1], args[2], args[3],
3916d3edc89c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1566
diff changeset
   231
				 args[4], args[5]);
3916d3edc89c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1566
diff changeset
   232
		break;
3916d3edc89c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1566
diff changeset
   233
	    case 7:
3916d3edc89c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1566
diff changeset
   234
		retVal = (*func)(args[0], args[1], args[2], args[3],
3916d3edc89c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1566
diff changeset
   235
				 args[4], args[5], args[6]);
3916d3edc89c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1566
diff changeset
   236
		break;
3916d3edc89c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1566
diff changeset
   237
	    case 8:
3916d3edc89c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1566
diff changeset
   238
		retVal = (*func)(args[0], args[1], args[2], args[3],
3916d3edc89c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1566
diff changeset
   239
				 args[4], args[5], args[6], args[7]);
3916d3edc89c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1566
diff changeset
   240
		break;
3916d3edc89c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1566
diff changeset
   241
	    case 9:
3916d3edc89c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1566
diff changeset
   242
		retVal = (*func)(args[0], args[1], args[2], args[3],
3916d3edc89c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1566
diff changeset
   243
				 args[4], args[5], args[6], args[7],
3916d3edc89c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1566
diff changeset
   244
				 args[8]);
3916d3edc89c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1566
diff changeset
   245
		break;
3916d3edc89c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1566
diff changeset
   246
	    case 10:
3916d3edc89c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1566
diff changeset
   247
		retVal = (*func)(args[0], args[1], args[2], args[3],
3916d3edc89c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1566
diff changeset
   248
				 args[4], args[5], args[6], args[7],
3916d3edc89c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1566
diff changeset
   249
				 args[8], args[9]);
3916d3edc89c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1566
diff changeset
   250
		break;
3916d3edc89c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1566
diff changeset
   251
	    default:
3916d3edc89c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1566
diff changeset
   252
		goto err;
3916d3edc89c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1566
diff changeset
   253
	}
3916d3edc89c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1566
diff changeset
   254
	RETURN (__MKINT(retVal));
660
738f8b4edcac checkin from browser
Claus Gittinger <cg@exept.de>
parents: 659
diff changeset
   255
    }
738f8b4edcac checkin from browser
Claus Gittinger <cg@exept.de>
parents: 659
diff changeset
   256
  err: ;
738f8b4edcac checkin from browser
Claus Gittinger <cg@exept.de>
parents: 659
diff changeset
   257
%}.
738f8b4edcac checkin from browser
Claus Gittinger <cg@exept.de>
parents: 659
diff changeset
   258
    self primitiveFailed
738f8b4edcac checkin from browser
Claus Gittinger <cg@exept.de>
parents: 659
diff changeset
   259
738f8b4edcac checkin from browser
Claus Gittinger <cg@exept.de>
parents: 659
diff changeset
   260
    "Created: / 18.6.1998 / 18:05:46 / cg"
659
c48a5b89ca8e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   261
! !
c48a5b89ca8e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   262
c48a5b89ca8e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   263
!WinAPIFunction class methodsFor:'documentation'!
c48a5b89ca8e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   264
c48a5b89ca8e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   265
version
3907
3916d3edc89c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1566
diff changeset
   266
    ^ '$Header$'
659
c48a5b89ca8e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   267
! !