ExternalLibraryFunction.st
author Stefan Vogel <sv@exept.de>
Tue, 28 Apr 2020 16:22:44 +0200
changeset 25376 88a3329875ba
parent 25087 6be980cf75e3
permissions -rw-r--r--
#REFACTORING by stefan class: MethodDictionary class removed: #newWithCapacity: moved to superclass
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
8728
d70396dc4e96 copyright
Claus Gittinger <cg@exept.de>
parents: 8550
diff changeset
     1
"
d70396dc4e96 copyright
Claus Gittinger <cg@exept.de>
parents: 8550
diff changeset
     2
 COPYRIGHT (c) 2004 by eXept Software AG
9464
157fe6ca53e6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9463
diff changeset
     3
	      All Rights Reserved
8728
d70396dc4e96 copyright
Claus Gittinger <cg@exept.de>
parents: 8550
diff changeset
     4
d70396dc4e96 copyright
Claus Gittinger <cg@exept.de>
parents: 8550
diff changeset
     5
 This software is furnished under a license and may be used
d70396dc4e96 copyright
Claus Gittinger <cg@exept.de>
parents: 8550
diff changeset
     6
 only in accordance with the terms of that license and with the
d70396dc4e96 copyright
Claus Gittinger <cg@exept.de>
parents: 8550
diff changeset
     7
 inclusion of the above copyright notice.   This software may not
d70396dc4e96 copyright
Claus Gittinger <cg@exept.de>
parents: 8550
diff changeset
     8
 be provided or otherwise made available to, or used by, any
d70396dc4e96 copyright
Claus Gittinger <cg@exept.de>
parents: 8550
diff changeset
     9
 other person.  No title to or ownership of the software is
d70396dc4e96 copyright
Claus Gittinger <cg@exept.de>
parents: 8550
diff changeset
    10
 hereby transferred.
d70396dc4e96 copyright
Claus Gittinger <cg@exept.de>
parents: 8550
diff changeset
    11
"
8533
9065c547ea75 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    12
"{ Package: 'stx:libbasic' }"
9065c547ea75 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    13
19311
6f1d1ea6dba8 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 18240
diff changeset
    14
"{ NameSpace: Smalltalk }"
6f1d1ea6dba8 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 18240
diff changeset
    15
8533
9065c547ea75 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    16
ExternalFunction subclass:#ExternalLibraryFunction
9465
d11885052713 rewrite & cleanup
Claus Gittinger <cg@exept.de>
parents: 9464
diff changeset
    17
	instanceVariableNames:'flags moduleName returnType argumentTypes owningClass'
20299
7db2dc640f2f #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20297
diff changeset
    18
	classVariableNames:'CALLTYPE_API CALLTYPE_C CALLTYPE_MASK CALLTYPE_OLE
7db2dc640f2f #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20297
diff changeset
    19
		CALLTYPE_UNIX64 CALLTYPE_V8 CALLTYPE_V9 DLLPATH DllMapping
7db2dc640f2f #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20297
diff changeset
    20
		FLAG_ASYNC FLAG_NONVIRTUAL FLAG_OBJECTIVEC FLAG_RETVAL_IS_CONST
7db2dc640f2f #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20297
diff changeset
    21
		FLAG_UNLIMITEDSTACK FLAG_VIRTUAL LastModuleHandleHolder
24097
fe2d568b25c9 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 24078
diff changeset
    22
		LastModuleHandleName Verbose FLAG_RETVAL_MUST_FREE TypeMap'
9464
157fe6ca53e6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9463
diff changeset
    23
	poolDictionaries:''
157fe6ca53e6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9463
diff changeset
    24
	category:'System-Support'
8533
9065c547ea75 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    25
!
9065c547ea75 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    26
9322
41c391bfbf03 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9321
diff changeset
    27
!ExternalLibraryFunction primitiveDefinitions!
41c391bfbf03 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9321
diff changeset
    28
%{
20297
85746bbcaf03 compiler warning eliminated
Claus Gittinger <cg@exept.de>
parents: 20295
diff changeset
    29
#include "stxOSDefs.h"
85746bbcaf03 compiler warning eliminated
Claus Gittinger <cg@exept.de>
parents: 20295
diff changeset
    30
19314
698cf296ef6d mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents: 19313
diff changeset
    31
#define VERBOSE
9322
41c391bfbf03 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9321
diff changeset
    32
20290
952d5b62a161 implemented a non-FFI-based callout scheme which works with OSX
Claus Gittinger <cg@exept.de>
parents: 20289
diff changeset
    33
#ifdef VERBOSE
952d5b62a161 implemented a non-FFI-based callout scheme which works with OSX
Claus Gittinger <cg@exept.de>
parents: 20289
diff changeset
    34
#  define DEBUGCODE_IF(flag, code) if ((flag) == true) {  code }
952d5b62a161 implemented a non-FFI-based callout scheme which works with OSX
Claus Gittinger <cg@exept.de>
parents: 20289
diff changeset
    35
# else
952d5b62a161 implemented a non-FFI-based callout scheme which works with OSX
Claus Gittinger <cg@exept.de>
parents: 20289
diff changeset
    36
#  define DEBUG_IF(flag, code) /* nothing */
952d5b62a161 implemented a non-FFI-based callout scheme which works with OSX
Claus Gittinger <cg@exept.de>
parents: 20289
diff changeset
    37
# endif
952d5b62a161 implemented a non-FFI-based callout scheme which works with OSX
Claus Gittinger <cg@exept.de>
parents: 20289
diff changeset
    38
9337
ab6bbf58bf0a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9336
diff changeset
    39
#ifdef HAVE_FFI
20288
604e46cfbf18 ffi for mingw - 64-bit machine has no API_CALL
Claus Gittinger <cg@exept.de>
parents: 19951
diff changeset
    40
25087
6be980cf75e3 gcc fixes
Claus Gittinger <cg@exept.de>
parents: 24826
diff changeset
    41
# ifdef __osx__
6be980cf75e3 gcc fixes
Claus Gittinger <cg@exept.de>
parents: 24826
diff changeset
    42
#  include <ffi/ffi.h>
6be980cf75e3 gcc fixes
Claus Gittinger <cg@exept.de>
parents: 24826
diff changeset
    43
# else
6be980cf75e3 gcc fixes
Claus Gittinger <cg@exept.de>
parents: 24826
diff changeset
    44
#  include <ffi.h>
6be980cf75e3 gcc fixes
Claus Gittinger <cg@exept.de>
parents: 24826
diff changeset
    45
# endif
9322
41c391bfbf03 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9321
diff changeset
    46
# define MAX_ARGS    128
9365
9003f8432516 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9347
diff changeset
    47
14659
410089913ca1 allow use of the standard (system) ffi
Claus Gittinger <cg@exept.de>
parents: 14632
diff changeset
    48
# ifdef USE_STANDARD_FFI
410089913ca1 allow use of the standard (system) ffi
Claus Gittinger <cg@exept.de>
parents: 14632
diff changeset
    49
#  define __get_ffi_type_sint() &ffi_type_sint
410089913ca1 allow use of the standard (system) ffi
Claus Gittinger <cg@exept.de>
parents: 14632
diff changeset
    50
#  define __get_ffi_type_sint8() &ffi_type_sint8
410089913ca1 allow use of the standard (system) ffi
Claus Gittinger <cg@exept.de>
parents: 14632
diff changeset
    51
#  define __get_ffi_type_sint16() &ffi_type_sint16
410089913ca1 allow use of the standard (system) ffi
Claus Gittinger <cg@exept.de>
parents: 14632
diff changeset
    52
#  define __get_ffi_type_sint32() &ffi_type_sint32
410089913ca1 allow use of the standard (system) ffi
Claus Gittinger <cg@exept.de>
parents: 14632
diff changeset
    53
#  define __get_ffi_type_sint64() &ffi_type_sint64
410089913ca1 allow use of the standard (system) ffi
Claus Gittinger <cg@exept.de>
parents: 14632
diff changeset
    54
#  define __get_ffi_type_uint() &ffi_type_uint
410089913ca1 allow use of the standard (system) ffi
Claus Gittinger <cg@exept.de>
parents: 14632
diff changeset
    55
#  define __get_ffi_type_uint8() &ffi_type_uint8
410089913ca1 allow use of the standard (system) ffi
Claus Gittinger <cg@exept.de>
parents: 14632
diff changeset
    56
#  define __get_ffi_type_uint16() &ffi_type_uint16
410089913ca1 allow use of the standard (system) ffi
Claus Gittinger <cg@exept.de>
parents: 14632
diff changeset
    57
#  define __get_ffi_type_uint32() &ffi_type_uint32
410089913ca1 allow use of the standard (system) ffi
Claus Gittinger <cg@exept.de>
parents: 14632
diff changeset
    58
#  define __get_ffi_type_uint64() &ffi_type_uint64
410089913ca1 allow use of the standard (system) ffi
Claus Gittinger <cg@exept.de>
parents: 14632
diff changeset
    59
#  define __get_ffi_type_float() &ffi_type_float
410089913ca1 allow use of the standard (system) ffi
Claus Gittinger <cg@exept.de>
parents: 14632
diff changeset
    60
#  define __get_ffi_type_double() &ffi_type_double
410089913ca1 allow use of the standard (system) ffi
Claus Gittinger <cg@exept.de>
parents: 14632
diff changeset
    61
#  define __get_ffi_type_void() &ffi_type_void
410089913ca1 allow use of the standard (system) ffi
Claus Gittinger <cg@exept.de>
parents: 14632
diff changeset
    62
#  define __get_ffi_type_pointer() &ffi_type_pointer
19931
0ea2a7e6bb41 calls without FFI
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
    63
14659
410089913ca1 allow use of the standard (system) ffi
Claus Gittinger <cg@exept.de>
parents: 14632
diff changeset
    64
# else
19931
0ea2a7e6bb41 calls without FFI
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
    65
19314
698cf296ef6d mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents: 19313
diff changeset
    66
   extern ffi_type *__get_ffi_type_sint();
698cf296ef6d mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents: 19313
diff changeset
    67
   extern ffi_type *__get_ffi_type_sint8();
698cf296ef6d mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents: 19313
diff changeset
    68
   extern ffi_type *__get_ffi_type_sint16();
698cf296ef6d mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents: 19313
diff changeset
    69
   extern ffi_type *__get_ffi_type_sint32();
698cf296ef6d mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents: 19313
diff changeset
    70
   extern ffi_type *__get_ffi_type_sint64();
698cf296ef6d mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents: 19313
diff changeset
    71
   extern ffi_type *__get_ffi_type_uint();
698cf296ef6d mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents: 19313
diff changeset
    72
   extern ffi_type *__get_ffi_type_uint8();
698cf296ef6d mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents: 19313
diff changeset
    73
   extern ffi_type *__get_ffi_type_uint16();
698cf296ef6d mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents: 19313
diff changeset
    74
   extern ffi_type *__get_ffi_type_uint32();
698cf296ef6d mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents: 19313
diff changeset
    75
   extern ffi_type *__get_ffi_type_uint64();
698cf296ef6d mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents: 19313
diff changeset
    76
   extern ffi_type *__get_ffi_type_float();
698cf296ef6d mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents: 19313
diff changeset
    77
   extern ffi_type *__get_ffi_type_double();
698cf296ef6d mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents: 19313
diff changeset
    78
   extern ffi_type *__get_ffi_type_void();
698cf296ef6d mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents: 19313
diff changeset
    79
   extern ffi_type *__get_ffi_type_pointer();
20307
678da26adf03 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 20299
diff changeset
    80
   extern INTLFUNC __get_ffi_prep_cif();
678da26adf03 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 20299
diff changeset
    81
   extern INTLFUNC __get_ffi_call();
19536
599f54c61bd8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 19535
diff changeset
    82
#  ifdef _MINGW__
599f54c61bd8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 19535
diff changeset
    83
#   define ffi_prep_cif (*(__get_ffi_prep_cif()))
20307
678da26adf03 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 20299
diff changeset
    84
#   define ffi_call     (*(__get_ffi_call()))
19536
599f54c61bd8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 19535
diff changeset
    85
#  endif
14659
410089913ca1 allow use of the standard (system) ffi
Claus Gittinger <cg@exept.de>
parents: 14632
diff changeset
    86
# endif
9365
9003f8432516 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9347
diff changeset
    87
19931
0ea2a7e6bb41 calls without FFI
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
    88
# define TYPE_UINT      __get_ffi_type_uint()
0ea2a7e6bb41 calls without FFI
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
    89
# define TYPE_UINT8     __get_ffi_type_uint8()
0ea2a7e6bb41 calls without FFI
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
    90
# define TYPE_UINT16    __get_ffi_type_uint16()
0ea2a7e6bb41 calls without FFI
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
    91
# define TYPE_UINT32    __get_ffi_type_uint32()
0ea2a7e6bb41 calls without FFI
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
    92
# define TYPE_UINT64    __get_ffi_type_uint64()
0ea2a7e6bb41 calls without FFI
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
    93
0ea2a7e6bb41 calls without FFI
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
    94
# define TYPE_SINT      __get_ffi_type_sint()
0ea2a7e6bb41 calls without FFI
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
    95
# define TYPE_SINT8     __get_ffi_type_sint8()
0ea2a7e6bb41 calls without FFI
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
    96
# define TYPE_SINT16    __get_ffi_type_sint16()
0ea2a7e6bb41 calls without FFI
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
    97
# define TYPE_SINT32    __get_ffi_type_sint32()
0ea2a7e6bb41 calls without FFI
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
    98
# define TYPE_SINT64    __get_ffi_type_sint64()
0ea2a7e6bb41 calls without FFI
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
    99
0ea2a7e6bb41 calls without FFI
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
   100
# define TYPE_POINTER   __get_ffi_type_pointer()
19950
Claus Gittinger <cg@exept.de>
parents: 19933
diff changeset
   101
# define TYPE_FLOAT     __get_ffi_type_float()
Claus Gittinger <cg@exept.de>
parents: 19933
diff changeset
   102
# define TYPE_DOUBLE    __get_ffi_type_double()
Claus Gittinger <cg@exept.de>
parents: 19933
diff changeset
   103
# define TYPE_VOID      __get_ffi_type_void()
24051
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
   104
# define TYPE_STRUCT    FFI_TYPE_STRUCT // __get_ffi_type_struct()
19931
0ea2a7e6bb41 calls without FFI
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
   105
0ea2a7e6bb41 calls without FFI
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
   106
#else /* NO FFI */
0ea2a7e6bb41 calls without FFI
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
   107
0ea2a7e6bb41 calls without FFI
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
   108
# define MAX_ARGS    15
0ea2a7e6bb41 calls without FFI
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
   109
# define TYPE_UINT      1
0ea2a7e6bb41 calls without FFI
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
   110
# define TYPE_UINT8     2
0ea2a7e6bb41 calls without FFI
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
   111
# define TYPE_UINT16    3
0ea2a7e6bb41 calls without FFI
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
   112
# define TYPE_UINT32    4
0ea2a7e6bb41 calls without FFI
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
   113
# define TYPE_UINT64    5
0ea2a7e6bb41 calls without FFI
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
   114
0ea2a7e6bb41 calls without FFI
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
   115
# define TYPE_SINT      11
0ea2a7e6bb41 calls without FFI
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
   116
# define TYPE_SINT8     12
0ea2a7e6bb41 calls without FFI
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
   117
# define TYPE_SINT16    13
0ea2a7e6bb41 calls without FFI
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
   118
# define TYPE_SINT32    14
0ea2a7e6bb41 calls without FFI
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
   119
# define TYPE_SINT64    15
0ea2a7e6bb41 calls without FFI
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
   120
0ea2a7e6bb41 calls without FFI
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
   121
# define TYPE_POINTER   20
0ea2a7e6bb41 calls without FFI
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
   122
# define TYPE_FLOAT     30
0ea2a7e6bb41 calls without FFI
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
   123
# define TYPE_DOUBLE    31
0ea2a7e6bb41 calls without FFI
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
   124
# define TYPE_VOID      40
0ea2a7e6bb41 calls without FFI
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
   125
0ea2a7e6bb41 calls without FFI
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
   126
# define FFI_DEFAULT_ABI        0
0ea2a7e6bb41 calls without FFI
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
   127
# define CALLTYPE_FFI_STDCALL   0
0ea2a7e6bb41 calls without FFI
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
   128
9337
ab6bbf58bf0a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9336
diff changeset
   129
#endif
9322
41c391bfbf03 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9321
diff changeset
   130
41c391bfbf03 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9321
diff changeset
   131
%}
41c391bfbf03 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9321
diff changeset
   132
! !
41c391bfbf03 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9321
diff changeset
   133
8728
d70396dc4e96 copyright
Claus Gittinger <cg@exept.de>
parents: 8550
diff changeset
   134
!ExternalLibraryFunction class methodsFor:'documentation'!
d70396dc4e96 copyright
Claus Gittinger <cg@exept.de>
parents: 8550
diff changeset
   135
d70396dc4e96 copyright
Claus Gittinger <cg@exept.de>
parents: 8550
diff changeset
   136
copyright
d70396dc4e96 copyright
Claus Gittinger <cg@exept.de>
parents: 8550
diff changeset
   137
"
d70396dc4e96 copyright
Claus Gittinger <cg@exept.de>
parents: 8550
diff changeset
   138
 COPYRIGHT (c) 2004 by eXept Software AG
9464
157fe6ca53e6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9463
diff changeset
   139
	      All Rights Reserved
8728
d70396dc4e96 copyright
Claus Gittinger <cg@exept.de>
parents: 8550
diff changeset
   140
d70396dc4e96 copyright
Claus Gittinger <cg@exept.de>
parents: 8550
diff changeset
   141
 This software is furnished under a license and may be used
d70396dc4e96 copyright
Claus Gittinger <cg@exept.de>
parents: 8550
diff changeset
   142
 only in accordance with the terms of that license and with the
d70396dc4e96 copyright
Claus Gittinger <cg@exept.de>
parents: 8550
diff changeset
   143
 inclusion of the above copyright notice.   This software may not
d70396dc4e96 copyright
Claus Gittinger <cg@exept.de>
parents: 8550
diff changeset
   144
 be provided or otherwise made available to, or used by, any
d70396dc4e96 copyright
Claus Gittinger <cg@exept.de>
parents: 8550
diff changeset
   145
 other person.  No title to or ownership of the software is
d70396dc4e96 copyright
Claus Gittinger <cg@exept.de>
parents: 8550
diff changeset
   146
 hereby transferred.
d70396dc4e96 copyright
Claus Gittinger <cg@exept.de>
parents: 8550
diff changeset
   147
"
9322
41c391bfbf03 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9321
diff changeset
   148
!
41c391bfbf03 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9321
diff changeset
   149
9331
c26a7de1468c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9330
diff changeset
   150
documentation
c26a7de1468c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9330
diff changeset
   151
"
c26a7de1468c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9330
diff changeset
   152
    instances of me are used to interface to external library functions (as found in a dll/shared object).
19933
d45636ff51df #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 19932
diff changeset
   153
    Foreign function calls are based on the FFI library if available.
d45636ff51df #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 19932
diff changeset
   154
    A limited fallback implementation is provided for systems with no libffi.
d45636ff51df #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 19932
diff changeset
   155
    (this may have limitations on the supported argument types; for example,
d45636ff51df #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 19932
diff changeset
   156
     the x86_64 fallback does not support float/double arguments).
19950
Claus Gittinger <cg@exept.de>
parents: 19933
diff changeset
   157
    Therefore the fallback should be considered a temporary workaround,
19933
d45636ff51df #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 19932
diff changeset
   158
    until libffi has been ported.
19950
Claus Gittinger <cg@exept.de>
parents: 19933
diff changeset
   159
12680
b0661f4ef910 changed: #documentation
Claus Gittinger <cg@exept.de>
parents: 12657
diff changeset
   160
    Inside a method, when a special external-call pragma such as:
19950
Claus Gittinger <cg@exept.de>
parents: 19933
diff changeset
   161
	<api: bool MessageBeep(uint)>
12680
b0661f4ef910 changed: #documentation
Claus Gittinger <cg@exept.de>
parents: 12657
diff changeset
   162
b0661f4ef910 changed: #documentation
Claus Gittinger <cg@exept.de>
parents: 12657
diff changeset
   163
    is encountered by the parser, the compiler generates a call via
19950
Claus Gittinger <cg@exept.de>
parents: 19933
diff changeset
   164
	<correspondingExternalLibraryFunctionObject> invokeWithArguments: argumentArray.
19549
7ebabee7eecd #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 19536
diff changeset
   165
    and the correspondingExternalLibraryFunctionObject is kept in the literal array.
9331
c26a7de1468c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9330
diff changeset
   166
c26a7de1468c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9330
diff changeset
   167
    In the invoke method, the library is checked to be loaded (and loaded if not already),
9336
f604a89f17f5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9331
diff changeset
   168
    the arguments are converted to C and pushed onto the C-stack, the function is called,
9331
c26a7de1468c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9330
diff changeset
   169
    and finally, the return value is converted back from C to a smalltalk object.
12680
b0661f4ef910 changed: #documentation
Claus Gittinger <cg@exept.de>
parents: 12657
diff changeset
   170
b0661f4ef910 changed: #documentation
Claus Gittinger <cg@exept.de>
parents: 12657
diff changeset
   171
    The parser supports the call-syntax of various other smalltalk dialects:
19950
Claus Gittinger <cg@exept.de>
parents: 19933
diff changeset
   172
	Squeak / ST-X:
Claus Gittinger <cg@exept.de>
parents: 19933
diff changeset
   173
	    <cdecl:   [async] [virtual|nonVirtual][const] returnType functionNameStringOrIndex ( argType1..argTypeN ) module: moduleName >
Claus Gittinger <cg@exept.de>
parents: 19933
diff changeset
   174
	    <apicall: [async] [virtual|nonVirtual][const] returnType functionNameStringOrIndex ( argType1..argTypeN ) module: moduleName >
12680
b0661f4ef910 changed: #documentation
Claus Gittinger <cg@exept.de>
parents: 12657
diff changeset
   175
19950
Claus Gittinger <cg@exept.de>
parents: 19933
diff changeset
   176
	Dolphin:
Claus Gittinger <cg@exept.de>
parents: 19933
diff changeset
   177
	    <stdcall: [virtual|nonVirtual][const] returnType functionNameStringOrIndex argType1..argTypeN>
Claus Gittinger <cg@exept.de>
parents: 19933
diff changeset
   178
	    <cdecl:   [virtual|nonVirtual][const] returnType functionNameStringOrIndex argType1..argTypeN>
12680
b0661f4ef910 changed: #documentation
Claus Gittinger <cg@exept.de>
parents: 12657
diff changeset
   179
19950
Claus Gittinger <cg@exept.de>
parents: 19933
diff changeset
   180
	ST/V:
Claus Gittinger <cg@exept.de>
parents: 19933
diff changeset
   181
	    <api: functionName argType1 .. argTypeN returnType>
Claus Gittinger <cg@exept.de>
parents: 19933
diff changeset
   182
	    <ccall: functionName argType1 .. argTypeN returnType>
Claus Gittinger <cg@exept.de>
parents: 19933
diff changeset
   183
	    <ole: vFunctionIndex argType1 .. argTypeN returnType>
12680
b0661f4ef910 changed: #documentation
Claus Gittinger <cg@exept.de>
parents: 12657
diff changeset
   184
19950
Claus Gittinger <cg@exept.de>
parents: 19933
diff changeset
   185
	VisualWorks:
Claus Gittinger <cg@exept.de>
parents: 19933
diff changeset
   186
	    <c: ...>
Claus Gittinger <cg@exept.de>
parents: 19933
diff changeset
   187
	    <c: #define NAME value>
9331
c26a7de1468c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9330
diff changeset
   188
"
c26a7de1468c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9330
diff changeset
   189
!
c26a7de1468c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9330
diff changeset
   190
9322
41c391bfbf03 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9321
diff changeset
   191
example
41c391bfbf03 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9321
diff changeset
   192
"
24046
6cf8161ea948 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 23834
diff changeset
   193
								[exBegin]
6cf8161ea948 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 23834
diff changeset
   194
	|f|
6cf8161ea948 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 23834
diff changeset
   195
6cf8161ea948 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 23834
diff changeset
   196
	f := ExternalLibraryFunction new.
6cf8161ea948 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 23834
diff changeset
   197
	f beCallTypeWINAPI.
6cf8161ea948 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 23834
diff changeset
   198
6cf8161ea948 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 23834
diff changeset
   199
	f name:'MessageBeep'
6cf8161ea948 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 23834
diff changeset
   200
	  module:'user32.dll'
6cf8161ea948 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 23834
diff changeset
   201
	  returnType:#boolean
6cf8161ea948 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 23834
diff changeset
   202
	  argumentTypes:#(uint).
6cf8161ea948 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 23834
diff changeset
   203
6cf8161ea948 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 23834
diff changeset
   204
	f invokeWith:1.
6cf8161ea948 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 23834
diff changeset
   205
								[exEnd]
14037
Michael Beyl <mb@exept.de>
parents: 13782
diff changeset
   206
Michael Beyl <mb@exept.de>
parents: 13782
diff changeset
   207
  Synchronous vs. Asynchronous calls:
Michael Beyl <mb@exept.de>
parents: 13782
diff changeset
   208
14516
359e4d2234af class: ExternalLibraryFunction
Stefan Vogel <sv@exept.de>
parents: 14506
diff changeset
   209
    by default, foreign function calls are synchronous, effectively blocking the whole ST/X system
24451
0aa7d8be211f #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 24338
diff changeset
   210
    (that is by purpose,´because most C-code is not prepared for being interrupted, and also, normal
14037
Michael Beyl <mb@exept.de>
parents: 13782
diff changeset
   211
     code is not prepared for a garbage collector to move objects around, while another C thread might
Michael Beyl <mb@exept.de>
parents: 13782
diff changeset
   212
     access the data...).
14625
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
   213
    Therefore, the following will block all ST/X activity for 10 seconds
14037
Michael Beyl <mb@exept.de>
parents: 13782
diff changeset
   214
    (try interacting with the launcher while the Sleep is performing):
Michael Beyl <mb@exept.de>
parents: 13782
diff changeset
   215
24046
6cf8161ea948 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 23834
diff changeset
   216
								[exBegin]
6cf8161ea948 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 23834
diff changeset
   217
	|f|
6cf8161ea948 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 23834
diff changeset
   218
6cf8161ea948 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 23834
diff changeset
   219
	f := ExternalLibraryFunction new.
6cf8161ea948 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 23834
diff changeset
   220
	f beCallTypeWINAPI.
6cf8161ea948 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 23834
diff changeset
   221
6cf8161ea948 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 23834
diff changeset
   222
	f name:'Sleep'
6cf8161ea948 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 23834
diff changeset
   223
	  module:'kernel32.dll'
6cf8161ea948 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 23834
diff changeset
   224
	  returnType:#void
6cf8161ea948 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 23834
diff changeset
   225
	  argumentTypes:#(uint).
6cf8161ea948 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 23834
diff changeset
   226
6cf8161ea948 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 23834
diff changeset
   227
	f invokeWith:10000.
6cf8161ea948 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 23834
diff changeset
   228
								[exEnd]
9322
41c391bfbf03 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9321
diff changeset
   229
14037
Michael Beyl <mb@exept.de>
parents: 13782
diff changeset
   230
    if you know what you do and you do not pass any possibly moving objects (such as strings) as argument,
Michael Beyl <mb@exept.de>
parents: 13782
diff changeset
   231
    the call can be made asynchronous. In that case, ONLY the calling thread will be blocked; all other smalltalk
21837
614d6247deae #DOCUMENTATION by mawalch
mawalch
parents: 21748
diff changeset
   232
    threads will continue to execute.
14037
Michael Beyl <mb@exept.de>
parents: 13782
diff changeset
   233
    (try interacting now with the launcher while the Sleep is performing):
24046
6cf8161ea948 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 23834
diff changeset
   234
								[exBegin]
6cf8161ea948 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 23834
diff changeset
   235
	|f|
6cf8161ea948 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 23834
diff changeset
   236
6cf8161ea948 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 23834
diff changeset
   237
	f := ExternalLibraryFunction new.
6cf8161ea948 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 23834
diff changeset
   238
	f beCallTypeWINAPI.
6cf8161ea948 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 23834
diff changeset
   239
	f beAsync.
6cf8161ea948 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 23834
diff changeset
   240
6cf8161ea948 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 23834
diff changeset
   241
	f name:'Sleep'
6cf8161ea948 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 23834
diff changeset
   242
	  module:'kernel32.dll'
6cf8161ea948 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 23834
diff changeset
   243
	  returnType:#void
6cf8161ea948 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 23834
diff changeset
   244
	  argumentTypes:#(uint).
6cf8161ea948 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 23834
diff changeset
   245
6cf8161ea948 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 23834
diff changeset
   246
	f invokeWith:10000.
6cf8161ea948 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 23834
diff changeset
   247
								[exEnd]
14037
Michael Beyl <mb@exept.de>
parents: 13782
diff changeset
   248
9322
41c391bfbf03 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9321
diff changeset
   249
"
8728
d70396dc4e96 copyright
Claus Gittinger <cg@exept.de>
parents: 8550
diff changeset
   250
! !
8533
9065c547ea75 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   251
8550
72982f85bd41 *** empty log message ***
ca
parents: 8533
diff changeset
   252
!ExternalLibraryFunction class methodsFor:'instance creation'!
72982f85bd41 *** empty log message ***
ca
parents: 8533
diff changeset
   253
23831
c741a73646f0 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 23829
diff changeset
   254
name:functionName module:moduleName callType:callTypeSymbol returnType:returnType argumentTypes:argTypes
c741a73646f0 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 23829
diff changeset
   255
    ^ self new
24046
6cf8161ea948 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 23834
diff changeset
   256
	name:functionName module:moduleName
6cf8161ea948 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 23834
diff changeset
   257
	returnType:returnType argumentTypes:argTypes;
6cf8161ea948 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 23834
diff changeset
   258
	callType:callTypeSymbol
23831
c741a73646f0 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 23829
diff changeset
   259
c741a73646f0 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 23829
diff changeset
   260
    "Created: / 04-03-2019 / 11:00:57 / Claus Gittinger"
c741a73646f0 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 23829
diff changeset
   261
!
c741a73646f0 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 23829
diff changeset
   262
9465
d11885052713 rewrite & cleanup
Claus Gittinger <cg@exept.de>
parents: 9464
diff changeset
   263
name:functionName module:moduleName returnType:returnType argumentTypes:argTypes
8550
72982f85bd41 *** empty log message ***
ca
parents: 8533
diff changeset
   264
    ^ self new
10025
053904a63549 stc-compiled ExternalLibraryFunctions
Claus Gittinger <cg@exept.de>
parents: 9981
diff changeset
   265
	name:functionName module:moduleName
053904a63549 stc-compiled ExternalLibraryFunctions
Claus Gittinger <cg@exept.de>
parents: 9981
diff changeset
   266
	returnType:returnType argumentTypes:argTypes
9465
d11885052713 rewrite & cleanup
Claus Gittinger <cg@exept.de>
parents: 9464
diff changeset
   267
d11885052713 rewrite & cleanup
Claus Gittinger <cg@exept.de>
parents: 9464
diff changeset
   268
    "Created: / 01-08-2006 / 15:19:08 / cg"
9463
864880338d7e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9460
diff changeset
   269
! !
864880338d7e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9460
diff changeset
   270
864880338d7e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9460
diff changeset
   271
!ExternalLibraryFunction class methodsFor:'class initialization'!
864880338d7e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9460
diff changeset
   272
11050
226b25e4bb97 comments
Claus Gittinger <cg@exept.de>
parents: 11013
diff changeset
   273
addToDllPath:aDirectoryPathName
226b25e4bb97 comments
Claus Gittinger <cg@exept.de>
parents: 11013
diff changeset
   274
    "can be used during initialization, to add more places for dll-loading"
226b25e4bb97 comments
Claus Gittinger <cg@exept.de>
parents: 11013
diff changeset
   275
19487
79d76a2de0f1 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 19483
diff changeset
   276
    |oldPath newPath|
11053
bcf4ebb25868 +removeFromDLLPath
Claus Gittinger <cg@exept.de>
parents: 11050
diff changeset
   277
bcf4ebb25868 +removeFromDLLPath
Claus Gittinger <cg@exept.de>
parents: 11050
diff changeset
   278
    oldPath := self dllPath.
22144
e3a0e9df945f #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22142
diff changeset
   279
    oldPath isNil ifTrue:[ oldPath := OrderedCollection new ].
11053
bcf4ebb25868 +removeFromDLLPath
Claus Gittinger <cg@exept.de>
parents: 11050
diff changeset
   280
    (oldPath includes:aDirectoryPathName) ifFalse:[
24046
6cf8161ea948 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 23834
diff changeset
   281
	newPath := oldPath asOrderedCollection.
6cf8161ea948 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 23834
diff changeset
   282
	newPath add:aDirectoryPathName.
6cf8161ea948 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 23834
diff changeset
   283
	self dllPath:newPath
11053
bcf4ebb25868 +removeFromDLLPath
Claus Gittinger <cg@exept.de>
parents: 11050
diff changeset
   284
    ]
20289
5472006d6a61 #DOCUMENTATION by sr
sr
parents: 20288
diff changeset
   285
5472006d6a61 #DOCUMENTATION by sr
sr
parents: 20288
diff changeset
   286
    "
5472006d6a61 #DOCUMENTATION by sr
sr
parents: 20288
diff changeset
   287
     self addToDllPath:'c:\matrix\API\dll'
5472006d6a61 #DOCUMENTATION by sr
sr
parents: 20288
diff changeset
   288
    "
11050
226b25e4bb97 comments
Claus Gittinger <cg@exept.de>
parents: 11013
diff changeset
   289
!
226b25e4bb97 comments
Claus Gittinger <cg@exept.de>
parents: 11013
diff changeset
   290
22802
95ea0b61a61e #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22556
diff changeset
   291
defaultDLLPath
95ea0b61a61e #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22556
diff changeset
   292
    "return a default dll-path, as per operating system"
95ea0b61a61e #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22556
diff changeset
   293
95ea0b61a61e #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22556
diff changeset
   294
    |path try|
95ea0b61a61e #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22556
diff changeset
   295
95ea0b61a61e #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22556
diff changeset
   296
    path := OrderedCollection with:'.'.
95ea0b61a61e #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22556
diff changeset
   297
    try := [:dir | dir asFilename exists ifTrue:[path add:dir]].
95ea0b61a61e #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22556
diff changeset
   298
95ea0b61a61e #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22556
diff changeset
   299
    OperatingSystem isUNIXlike ifTrue:[
24046
6cf8161ea948 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 23834
diff changeset
   300
	#(
6cf8161ea948 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 23834
diff changeset
   301
	    '/lib'
6cf8161ea948 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 23834
diff changeset
   302
	    '/usr/lib'
6cf8161ea948 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 23834
diff changeset
   303
	    '/usr/local/lib'
6cf8161ea948 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 23834
diff changeset
   304
	    '/opt/lib'
6cf8161ea948 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 23834
diff changeset
   305
	    '/opt/local/lib'
6cf8161ea948 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 23834
diff changeset
   306
	) do:try
22802
95ea0b61a61e #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22556
diff changeset
   307
    ].
95ea0b61a61e #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22556
diff changeset
   308
    ^ path
95ea0b61a61e #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22556
diff changeset
   309
95ea0b61a61e #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22556
diff changeset
   310
    "
95ea0b61a61e #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22556
diff changeset
   311
     self defaultDLLPath
95ea0b61a61e #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22556
diff changeset
   312
    "
95ea0b61a61e #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22556
diff changeset
   313
!
95ea0b61a61e #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22556
diff changeset
   314
14103
3df000b77712 class definition
Claus Gittinger <cg@exept.de>
parents: 14037
diff changeset
   315
dllMapping
3df000b77712 class definition
Claus Gittinger <cg@exept.de>
parents: 14037
diff changeset
   316
    "allows for dll's to be replaced,
3df000b77712 class definition
Claus Gittinger <cg@exept.de>
parents: 14037
diff changeset
   317
     for example, if you want to use the mozilla sqlite dll
19860
324edacff5cc unified cpu and os defines;
Claus Gittinger <cg@exept.de>
parents: 19549
diff changeset
   318
	C:\Program Files\Mozilla Firefox\mozsqlite3.dll
14103
3df000b77712 class definition
Claus Gittinger <cg@exept.de>
parents: 14037
diff changeset
   319
     for the sqlite3, execute:
19860
324edacff5cc unified cpu and os defines;
Claus Gittinger <cg@exept.de>
parents: 19549
diff changeset
   320
	ExternalLibraryFunction
324edacff5cc unified cpu and os defines;
Claus Gittinger <cg@exept.de>
parents: 19549
diff changeset
   321
	    dllMapping at:'sqlite3'
324edacff5cc unified cpu and os defines;
Claus Gittinger <cg@exept.de>
parents: 19549
diff changeset
   322
	    put: 'C:\Program Files\Mozilla Firefox\mozsqlite3.dll'
19549
7ebabee7eecd #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 19536
diff changeset
   323
     for mingw:
19860
324edacff5cc unified cpu and os defines;
Claus Gittinger <cg@exept.de>
parents: 19549
diff changeset
   324
	ExternalLibraryFunction
324edacff5cc unified cpu and os defines;
Claus Gittinger <cg@exept.de>
parents: 19549
diff changeset
   325
	    dllMapping at:'sqlite3'
324edacff5cc unified cpu and os defines;
Claus Gittinger <cg@exept.de>
parents: 19549
diff changeset
   326
	    put:'C:\mingw64\opt\bin\libsqlite3-0.dll'
14103
3df000b77712 class definition
Claus Gittinger <cg@exept.de>
parents: 14037
diff changeset
   327
    "
3df000b77712 class definition
Claus Gittinger <cg@exept.de>
parents: 14037
diff changeset
   328
3df000b77712 class definition
Claus Gittinger <cg@exept.de>
parents: 14037
diff changeset
   329
    DllMapping isNil ifTrue:[
19860
324edacff5cc unified cpu and os defines;
Claus Gittinger <cg@exept.de>
parents: 19549
diff changeset
   330
	DllMapping := Dictionary new.
14103
3df000b77712 class definition
Claus Gittinger <cg@exept.de>
parents: 14037
diff changeset
   331
    ].
3df000b77712 class definition
Claus Gittinger <cg@exept.de>
parents: 14037
diff changeset
   332
    ^ DllMapping
3df000b77712 class definition
Claus Gittinger <cg@exept.de>
parents: 14037
diff changeset
   333
3df000b77712 class definition
Claus Gittinger <cg@exept.de>
parents: 14037
diff changeset
   334
    "Created: / 10-04-2012 / 12:21:45 / cg"
3df000b77712 class definition
Claus Gittinger <cg@exept.de>
parents: 14037
diff changeset
   335
!
3df000b77712 class definition
Claus Gittinger <cg@exept.de>
parents: 14037
diff changeset
   336
21055
53363d877a99 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20996
diff changeset
   337
dllMapping:aDictionary
53363d877a99 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20996
diff changeset
   338
    "allows for dll's to be replaced,
53363d877a99 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20996
diff changeset
   339
     for example, if you want to use the mozilla sqlite dll
24046
6cf8161ea948 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 23834
diff changeset
   340
	C:\Program Files\Mozilla Firefox\mozsqlite3.dll
21055
53363d877a99 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20996
diff changeset
   341
     for the sqlite3, execute:
24046
6cf8161ea948 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 23834
diff changeset
   342
	ExternalLibraryFunction
6cf8161ea948 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 23834
diff changeset
   343
	    dllMapping at:'sqlite3'
6cf8161ea948 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 23834
diff changeset
   344
	    put: 'C:\Program Files\Mozilla Firefox\mozsqlite3.dll'
21055
53363d877a99 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20996
diff changeset
   345
     for mingw:
24046
6cf8161ea948 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 23834
diff changeset
   346
	ExternalLibraryFunction
6cf8161ea948 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 23834
diff changeset
   347
	    dllMapping at:'sqlite3'
6cf8161ea948 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 23834
diff changeset
   348
	    put:'C:\mingw64\opt\bin\libsqlite3-0.dll'
21055
53363d877a99 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20996
diff changeset
   349
    "
53363d877a99 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20996
diff changeset
   350
53363d877a99 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20996
diff changeset
   351
    DllMapping := aDictionary
53363d877a99 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20996
diff changeset
   352
53363d877a99 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20996
diff changeset
   353
    "Created: / 26-11-2016 / 04:06:14 / cg"
53363d877a99 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20996
diff changeset
   354
!
53363d877a99 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20996
diff changeset
   355
20299
7db2dc640f2f #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20297
diff changeset
   356
dllMappingAt:baseLibname put:aNameOrPath
7db2dc640f2f #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20297
diff changeset
   357
    "allows for dll's to be replaced,
7db2dc640f2f #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20297
diff changeset
   358
     for example, if you want to use the mozilla sqlite dll
20307
678da26adf03 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 20299
diff changeset
   359
	C:\Program Files\Mozilla Firefox\mozsqlite3.dll
20299
7db2dc640f2f #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20297
diff changeset
   360
     for the sqlite3, execute:
20307
678da26adf03 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 20299
diff changeset
   361
	ExternalLibraryFunction
678da26adf03 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 20299
diff changeset
   362
	    dllMappingAt:'sqlite3'
678da26adf03 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 20299
diff changeset
   363
	    put: 'C:\Program Files\Mozilla Firefox\mozsqlite3.dll'
20299
7db2dc640f2f #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20297
diff changeset
   364
     for mingw:
20307
678da26adf03 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 20299
diff changeset
   365
	ExternalLibraryFunction
678da26adf03 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 20299
diff changeset
   366
	    dllMappingAt:'sqlite3'
678da26adf03 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 20299
diff changeset
   367
	    put:'C:\mingw64\opt\bin\libsqlite3-0.dll'
20299
7db2dc640f2f #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20297
diff changeset
   368
    "
7db2dc640f2f #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20297
diff changeset
   369
7db2dc640f2f #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20297
diff changeset
   370
    self dllMapping at:baseLibname put: aNameOrPath
7db2dc640f2f #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20297
diff changeset
   371
!
7db2dc640f2f #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20297
diff changeset
   372
10270
897474c6c785 allow setting the dllPath
fm
parents: 10213
diff changeset
   373
dllPath
19549
7ebabee7eecd #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 19536
diff changeset
   374
    "provide a default dllPath, where external libraries are searched for"
7ebabee7eecd #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 19536
diff changeset
   375
13337
d1733931bc10 changed:
Stefan Vogel <sv@exept.de>
parents: 13334
diff changeset
   376
    ^ DLLPATH
21401
46251f16e9e5 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 21400
diff changeset
   377
46251f16e9e5 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 21400
diff changeset
   378
    "
46251f16e9e5 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 21400
diff changeset
   379
     ExternalLibraryFunction dllPath
46251f16e9e5 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 21400
diff changeset
   380
    "
46251f16e9e5 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 21400
diff changeset
   381
46251f16e9e5 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 21400
diff changeset
   382
    "Modified (comment): / 12-02-2017 / 02:15:23 / cg"
10270
897474c6c785 allow setting the dllPath
fm
parents: 10213
diff changeset
   383
!
897474c6c785 allow setting the dllPath
fm
parents: 10213
diff changeset
   384
897474c6c785 allow setting the dllPath
fm
parents: 10213
diff changeset
   385
dllPath:aCollectionOfDirectoryPathNames
19549
7ebabee7eecd #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 19536
diff changeset
   386
    "provide a default dllPath, where external libraries are searched for"
7ebabee7eecd #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 19536
diff changeset
   387
10270
897474c6c785 allow setting the dllPath
fm
parents: 10213
diff changeset
   388
    DLLPATH := aCollectionOfDirectoryPathNames
897474c6c785 allow setting the dllPath
fm
parents: 10213
diff changeset
   389
!
897474c6c785 allow setting the dllPath
fm
parents: 10213
diff changeset
   390
20958
4a8561ed705e #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20561
diff changeset
   391
flushModuleHandlesForLibrary:aLibraryName
4a8561ed705e #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20561
diff changeset
   392
    self flushModuleHandlesForWhich:[:fn | fn moduleName = aLibraryName].
4a8561ed705e #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20561
diff changeset
   393
4a8561ed705e #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20561
diff changeset
   394
    "
4a8561ed705e #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20561
diff changeset
   395
     self flushModuleHandlesForLibrary:'ole32.dll'
4a8561ed705e #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20561
diff changeset
   396
    "
4a8561ed705e #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20561
diff changeset
   397
4a8561ed705e #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20561
diff changeset
   398
    "Created: / 12-11-2016 / 11:49:09 / cg"
4a8561ed705e #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20561
diff changeset
   399
!
4a8561ed705e #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20561
diff changeset
   400
4a8561ed705e #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20561
diff changeset
   401
flushModuleHandlesForWhich:aBlock
4a8561ed705e #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20561
diff changeset
   402
    self allInstancesDo:[:fn |
24046
6cf8161ea948 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 23834
diff changeset
   403
	(aBlock value:fn) ifTrue:[
6cf8161ea948 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 23834
diff changeset
   404
	    fn setModuleHandle:nil.
6cf8161ea948 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 23834
diff changeset
   405
	]
20958
4a8561ed705e #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20561
diff changeset
   406
    ].
4a8561ed705e #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20561
diff changeset
   407
4a8561ed705e #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20561
diff changeset
   408
    "
4a8561ed705e #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20561
diff changeset
   409
     self flushModuleHandlesForLibrary:'ole32.dll'
4a8561ed705e #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20561
diff changeset
   410
    "
4a8561ed705e #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20561
diff changeset
   411
4a8561ed705e #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20561
diff changeset
   412
    "Created: / 12-11-2016 / 11:48:32 / cg"
4a8561ed705e #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20561
diff changeset
   413
!
4a8561ed705e #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20561
diff changeset
   414
9463
864880338d7e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9460
diff changeset
   415
initialize
10025
053904a63549 stc-compiled ExternalLibraryFunctions
Claus Gittinger <cg@exept.de>
parents: 9981
diff changeset
   416
    "using inline access to corresponding c--defines to avoid duplicate places of knowledge"
13337
d1733931bc10 changed:
Stefan Vogel <sv@exept.de>
parents: 13334
diff changeset
   417
d1733931bc10 changed:
Stefan Vogel <sv@exept.de>
parents: 13334
diff changeset
   418
    DLLPATH isNil ifTrue:[
24046
6cf8161ea948 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 23834
diff changeset
   419
	DLLPATH := self defaultDLLPath.
20309
98a12d386c4a #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 20307
diff changeset
   420
    ].
18228
061da222bd70 java support
Claus Gittinger <cg@exept.de>
parents: 15002
diff changeset
   421
%{
18240
28af09029a8b ifdef for SCHTEAM engine changed (not relevant for ST/X)
Claus Gittinger <cg@exept.de>
parents: 18228
diff changeset
   422
#ifndef __SCHTEAM__
20309
98a12d386c4a #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 20307
diff changeset
   423
    @global(FLAG_VIRTUAL) = __MKSMALLINT(__EXTL_FLAG_VIRTUAL);                  // a virtual c++ call
98a12d386c4a #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 20307
diff changeset
   424
    @global(FLAG_NONVIRTUAL) = __MKSMALLINT(__EXTL_FLAG_NONVIRTUAL);            // a non-virtual c++ call
98a12d386c4a #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 20307
diff changeset
   425
    @global(FLAG_OBJECTIVEC) = __MKSMALLINT(__EXTL_FLAG_OBJECTIVEC);            // an objectiveC message send
98a12d386c4a #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 20307
diff changeset
   426
    @global(FLAG_UNLIMITEDSTACK) = __MKSMALLINT(__EXTL_FLAG_UNLIMITEDSTACK);    // unlimitedstack under unix
98a12d386c4a #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 20307
diff changeset
   427
    @global(FLAG_ASYNC) = __MKSMALLINT(__EXTL_FLAG_ASYNC);                      // async under win32
21410
660679622f0c #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21409
diff changeset
   428
    @global(FLAG_RETVAL_IS_CONST) = __MKSMALLINT(__EXTL_FLAG_RETVAL_IS_CONST);    // retvalue is not to be registered for finalization
660679622f0c #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21409
diff changeset
   429
    @global(FLAG_RETVAL_MUST_FREE) = __MKSMALLINT(__EXTL_FLAG_RETVAL_MUST_FREE);  // retvalue is to be freed
9463
864880338d7e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9460
diff changeset
   430
20309
98a12d386c4a #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 20307
diff changeset
   431
    @global(CALLTYPE_API) = __MKSMALLINT(__EXTL_CALLTYPE_API);                  // WINAPI-call (win32 only)
98a12d386c4a #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 20307
diff changeset
   432
    @global(CALLTYPE_C) = __MKSMALLINT(__EXTL_CALLTYPE_C);                      // regular C-call (the default)
98a12d386c4a #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 20307
diff changeset
   433
    @global(CALLTYPE_V8) = __MKSMALLINT(__EXTL_CALLTYPE_V8);                    // v8 call (sparc only)
98a12d386c4a #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 20307
diff changeset
   434
    @global(CALLTYPE_V9) = __MKSMALLINT(__EXTL_CALLTYPE_V9);                    // v9 call (sparc only)
98a12d386c4a #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 20307
diff changeset
   435
    @global(CALLTYPE_UNIX64) = __MKSMALLINT(__EXTL_CALLTYPE_UNIX64);            // unix64 call (alpha only)
9463
864880338d7e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9460
diff changeset
   436
20309
98a12d386c4a #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 20307
diff changeset
   437
    @global(CALLTYPE_MASK) = __MKSMALLINT(__EXTL_CALLTYPE_MASK);
18228
061da222bd70 java support
Claus Gittinger <cg@exept.de>
parents: 15002
diff changeset
   438
#endif
20309
98a12d386c4a #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 20307
diff changeset
   439
%}.
9465
d11885052713 rewrite & cleanup
Claus Gittinger <cg@exept.de>
parents: 9464
diff changeset
   440
22802
95ea0b61a61e #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22556
diff changeset
   441
    "DLLPATH := nil.
10025
053904a63549 stc-compiled ExternalLibraryFunctions
Claus Gittinger <cg@exept.de>
parents: 9981
diff changeset
   442
     self initialize
053904a63549 stc-compiled ExternalLibraryFunctions
Claus Gittinger <cg@exept.de>
parents: 9981
diff changeset
   443
    "
053904a63549 stc-compiled ExternalLibraryFunctions
Claus Gittinger <cg@exept.de>
parents: 9981
diff changeset
   444
21410
660679622f0c #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21409
diff changeset
   445
    "Modified: / 12-02-2017 / 23:43:23 / cg"
11053
bcf4ebb25868 +removeFromDLLPath
Claus Gittinger <cg@exept.de>
parents: 11050
diff changeset
   446
!
bcf4ebb25868 +removeFromDLLPath
Claus Gittinger <cg@exept.de>
parents: 11050
diff changeset
   447
bcf4ebb25868 +removeFromDLLPath
Claus Gittinger <cg@exept.de>
parents: 11050
diff changeset
   448
removeFromDllPath:aDirectoryPathName
bcf4ebb25868 +removeFromDLLPath
Claus Gittinger <cg@exept.de>
parents: 11050
diff changeset
   449
    "remove added places from dll-loading"
bcf4ebb25868 +removeFromDLLPath
Claus Gittinger <cg@exept.de>
parents: 11050
diff changeset
   450
bcf4ebb25868 +removeFromDLLPath
Claus Gittinger <cg@exept.de>
parents: 11050
diff changeset
   451
    |oldPath|
bcf4ebb25868 +removeFromDLLPath
Claus Gittinger <cg@exept.de>
parents: 11050
diff changeset
   452
bcf4ebb25868 +removeFromDLLPath
Claus Gittinger <cg@exept.de>
parents: 11050
diff changeset
   453
    oldPath := self dllPath.
22144
e3a0e9df945f #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22142
diff changeset
   454
    oldPath notNil ifTrue:[
24046
6cf8161ea948 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 23834
diff changeset
   455
	self dllPath:(oldPath copyWithout:aDirectoryPathName)
22144
e3a0e9df945f #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22142
diff changeset
   456
    ].
11053
bcf4ebb25868 +removeFromDLLPath
Claus Gittinger <cg@exept.de>
parents: 11050
diff changeset
   457
bcf4ebb25868 +removeFromDLLPath
Claus Gittinger <cg@exept.de>
parents: 11050
diff changeset
   458
    "
23228
63b599c0c272 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 23227
diff changeset
   459
     |prevDllPath|
63b599c0c272 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 23227
diff changeset
   460
63b599c0c272 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 23227
diff changeset
   461
     prevDllPath := self dllPath.
63b599c0c272 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 23227
diff changeset
   462
     self removeFromDllPath:'C:\aaa\bbb'.
11586
a3b2eef8a74c int vs. sint
Claus Gittinger <cg@exept.de>
parents: 11426
diff changeset
   463
     self addToDllPath:'C:\aaa\bbb'.
23228
63b599c0c272 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 23227
diff changeset
   464
     self assert:self dllPath size = (prevDllPath size + 1).
11053
bcf4ebb25868 +removeFromDLLPath
Claus Gittinger <cg@exept.de>
parents: 11050
diff changeset
   465
     self removeFromDllPath:'C:\aaa\bbb'.
23228
63b599c0c272 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 23227
diff changeset
   466
     self assert:self dllPath size = (prevDllPath size).
11053
bcf4ebb25868 +removeFromDLLPath
Claus Gittinger <cg@exept.de>
parents: 11050
diff changeset
   467
    "
23228
63b599c0c272 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 23227
diff changeset
   468
63b599c0c272 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 23227
diff changeset
   469
    "Modified (comment): / 23-07-2018 / 11:16:26 / Stefan Vogel"
8550
72982f85bd41 *** empty log message ***
ca
parents: 8533
diff changeset
   470
! !
72982f85bd41 *** empty log message ***
ca
parents: 8533
diff changeset
   471
9321
734c7c432461 not yet finished
Claus Gittinger <cg@exept.de>
parents: 8891
diff changeset
   472
!ExternalLibraryFunction class methodsFor:'constants'!
734c7c432461 not yet finished
Claus Gittinger <cg@exept.de>
parents: 8891
diff changeset
   473
734c7c432461 not yet finished
Claus Gittinger <cg@exept.de>
parents: 8891
diff changeset
   474
callTypeAPI
9463
864880338d7e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9460
diff changeset
   475
    ^ CALLTYPE_API
9321
734c7c432461 not yet finished
Claus Gittinger <cg@exept.de>
parents: 8891
diff changeset
   476
9463
864880338d7e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9460
diff changeset
   477
    "Modified: / 01-08-2006 / 13:44:41 / cg"
9435
68f7e39efad7 support of asynchronous calls
ca
parents: 9418
diff changeset
   478
!
68f7e39efad7 support of asynchronous calls
ca
parents: 9418
diff changeset
   479
9321
734c7c432461 not yet finished
Claus Gittinger <cg@exept.de>
parents: 8891
diff changeset
   480
callTypeC
9463
864880338d7e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9460
diff changeset
   481
    ^ CALLTYPE_C
9321
734c7c432461 not yet finished
Claus Gittinger <cg@exept.de>
parents: 8891
diff changeset
   482
9463
864880338d7e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9460
diff changeset
   483
    "Modified: / 01-08-2006 / 13:44:49 / cg"
9435
68f7e39efad7 support of asynchronous calls
ca
parents: 9418
diff changeset
   484
!
68f7e39efad7 support of asynchronous calls
ca
parents: 9418
diff changeset
   485
9321
734c7c432461 not yet finished
Claus Gittinger <cg@exept.de>
parents: 8891
diff changeset
   486
callTypeCDecl
9463
864880338d7e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9460
diff changeset
   487
    ^ CALLTYPE_C
9321
734c7c432461 not yet finished
Claus Gittinger <cg@exept.de>
parents: 8891
diff changeset
   488
9463
864880338d7e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9460
diff changeset
   489
    "Modified: / 01-08-2006 / 13:44:52 / cg"
9435
68f7e39efad7 support of asynchronous calls
ca
parents: 9418
diff changeset
   490
!
68f7e39efad7 support of asynchronous calls
ca
parents: 9418
diff changeset
   491
10619
dc8c965a8602 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10618
diff changeset
   492
callTypeMASK
dc8c965a8602 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10618
diff changeset
   493
    ^ CALLTYPE_MASK
dc8c965a8602 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10618
diff changeset
   494
dc8c965a8602 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10618
diff changeset
   495
    "Modified: / 01-08-2006 / 13:44:57 / cg"
dc8c965a8602 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10618
diff changeset
   496
!
dc8c965a8602 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10618
diff changeset
   497
9321
734c7c432461 not yet finished
Claus Gittinger <cg@exept.de>
parents: 8891
diff changeset
   498
callTypeOLE
9463
864880338d7e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9460
diff changeset
   499
    ^ CALLTYPE_OLE
9435
68f7e39efad7 support of asynchronous calls
ca
parents: 9418
diff changeset
   500
9463
864880338d7e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9460
diff changeset
   501
    "Modified: / 01-08-2006 / 13:44:57 / cg"
22544
dc92d4e03fb9 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22163
diff changeset
   502
!
dc92d4e03fb9 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22163
diff changeset
   503
dc92d4e03fb9 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22163
diff changeset
   504
callTypeUNIX64
dc92d4e03fb9 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22163
diff changeset
   505
    ^ CALLTYPE_UNIX64
dc92d4e03fb9 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22163
diff changeset
   506
dc92d4e03fb9 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22163
diff changeset
   507
    "Modified: / 01-08-2006 / 13:44:57 / cg"
23828
cbcc99660889 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 23785
diff changeset
   508
!
cbcc99660889 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 23785
diff changeset
   509
cbcc99660889 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 23785
diff changeset
   510
invokeSelectors
cbcc99660889 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 23785
diff changeset
   511
    ^ #(
24046
6cf8161ea948 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 23834
diff changeset
   512
	#'invoke'
6cf8161ea948 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 23834
diff changeset
   513
	#'invokeWith:'
6cf8161ea948 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 23834
diff changeset
   514
	#'invokeWith:with:'
6cf8161ea948 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 23834
diff changeset
   515
	#'invokeWith:with:with:'
6cf8161ea948 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 23834
diff changeset
   516
	#'invokeWith:with:with:with:'
6cf8161ea948 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 23834
diff changeset
   517
	#'invokeWithArguments:'
6cf8161ea948 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 23834
diff changeset
   518
	#'invokeCPPVirtualOn:'
6cf8161ea948 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 23834
diff changeset
   519
	#'invokeCPPVirtualOn:with:'
6cf8161ea948 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 23834
diff changeset
   520
	#'invokeCPPVirtualOn:with:with:'
6cf8161ea948 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 23834
diff changeset
   521
	#'invokeCPPVirtualOn:with:with:with:'
6cf8161ea948 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 23834
diff changeset
   522
	#'invokeCPPVirtualOn:with:with:with:with:'
6cf8161ea948 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 23834
diff changeset
   523
	#'invokeCPPVirtualOn:withArguments:'
6cf8161ea948 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 23834
diff changeset
   524
	#'invokeObjCOn:'
6cf8161ea948 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 23834
diff changeset
   525
	#'invokeObjCOn:with:'
6cf8161ea948 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 23834
diff changeset
   526
	#'invokeObjCOn:with:with:'
6cf8161ea948 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 23834
diff changeset
   527
	#'invokeObjCOn:with:with:with:'
6cf8161ea948 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 23834
diff changeset
   528
	#'invokeObjCOn:with:with:with:with:'
6cf8161ea948 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 23834
diff changeset
   529
	#'invokeObjCOn:withArguments:'
23828
cbcc99660889 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 23785
diff changeset
   530
    )
cbcc99660889 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 23785
diff changeset
   531
cbcc99660889 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 23785
diff changeset
   532
    "Created: / 04-03-2019 / 09:35:51 / Claus Gittinger"
9321
734c7c432461 not yet finished
Claus Gittinger <cg@exept.de>
parents: 8891
diff changeset
   533
! !
734c7c432461 not yet finished
Claus Gittinger <cg@exept.de>
parents: 8891
diff changeset
   534
19505
3014e8447db8 #UI_ENHANCEMENT
Claus Gittinger <cg@exept.de>
parents: 19501
diff changeset
   535
!ExternalLibraryFunction class methodsFor:'debugging'!
3014e8447db8 #UI_ENHANCEMENT
Claus Gittinger <cg@exept.de>
parents: 19501
diff changeset
   536
3014e8447db8 #UI_ENHANCEMENT
Claus Gittinger <cg@exept.de>
parents: 19501
diff changeset
   537
verbose:aBoolean
3014e8447db8 #UI_ENHANCEMENT
Claus Gittinger <cg@exept.de>
parents: 19501
diff changeset
   538
    "turn on/off tracing of calls"
3014e8447db8 #UI_ENHANCEMENT
Claus Gittinger <cg@exept.de>
parents: 19501
diff changeset
   539
3014e8447db8 #UI_ENHANCEMENT
Claus Gittinger <cg@exept.de>
parents: 19501
diff changeset
   540
    Verbose := aBoolean
3014e8447db8 #UI_ENHANCEMENT
Claus Gittinger <cg@exept.de>
parents: 19501
diff changeset
   541
3014e8447db8 #UI_ENHANCEMENT
Claus Gittinger <cg@exept.de>
parents: 19501
diff changeset
   542
    "
3014e8447db8 #UI_ENHANCEMENT
Claus Gittinger <cg@exept.de>
parents: 19501
diff changeset
   543
     ExternalLibraryFunction verbose:true
3014e8447db8 #UI_ENHANCEMENT
Claus Gittinger <cg@exept.de>
parents: 19501
diff changeset
   544
    "
3014e8447db8 #UI_ENHANCEMENT
Claus Gittinger <cg@exept.de>
parents: 19501
diff changeset
   545
3014e8447db8 #UI_ENHANCEMENT
Claus Gittinger <cg@exept.de>
parents: 19501
diff changeset
   546
    "Created: / 30-03-2016 / 17:28:23 / cg"
3014e8447db8 #UI_ENHANCEMENT
Claus Gittinger <cg@exept.de>
parents: 19501
diff changeset
   547
! !
3014e8447db8 #UI_ENHANCEMENT
Claus Gittinger <cg@exept.de>
parents: 19501
diff changeset
   548
19490
4d29d49edd98 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 19489
diff changeset
   549
!ExternalLibraryFunction class methodsFor:'type name mapping'!
4d29d49edd98 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 19489
diff changeset
   550
24104
d5fa45826506 #BUGFIX by Stefan Reise
sr
parents: 24098
diff changeset
   551
adjustAllTypes
d5fa45826506 #BUGFIX by Stefan Reise
sr
parents: 24098
diff changeset
   552
    "because adjustTypes is invoked only once (when the ext-call is first created),
d5fa45826506 #BUGFIX by Stefan Reise
sr
parents: 24098
diff changeset
   553
     any change in the type mapping (ffiTypeSymbolForType: or mapType) will not
d5fa45826506 #BUGFIX by Stefan Reise
sr
parents: 24098
diff changeset
   554
     affect existing lib-calls.
d5fa45826506 #BUGFIX by Stefan Reise
sr
parents: 24098
diff changeset
   555
     Use this, to adjust all thoseafter a change in the type mapping"
d5fa45826506 #BUGFIX by Stefan Reise
sr
parents: 24098
diff changeset
   556
d5fa45826506 #BUGFIX by Stefan Reise
sr
parents: 24098
diff changeset
   557
    self allSubInstancesDo:[:eachCall |
24335
0b12e9a57aa2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 24104
diff changeset
   558
	eachCall adjustTypes
24104
d5fa45826506 #BUGFIX by Stefan Reise
sr
parents: 24098
diff changeset
   559
    ].
d5fa45826506 #BUGFIX by Stefan Reise
sr
parents: 24098
diff changeset
   560
d5fa45826506 #BUGFIX by Stefan Reise
sr
parents: 24098
diff changeset
   561
    "Created: / 02-05-2019 / 14:31:37 / Stefan Reise"
d5fa45826506 #BUGFIX by Stefan Reise
sr
parents: 24098
diff changeset
   562
!
d5fa45826506 #BUGFIX by Stefan Reise
sr
parents: 24098
diff changeset
   563
19490
4d29d49edd98 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 19489
diff changeset
   564
ffiTypeSymbolForType:aType
22162
aeace092a850 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 22144
diff changeset
   565
    "map aType to one of the ffi-supported ones:
24335
0b12e9a57aa2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 24104
diff changeset
   566
	sint8, sint16, sint32, sint64
0b12e9a57aa2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 24104
diff changeset
   567
	uint8, uint16, uint32, uint64
0b12e9a57aa2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 24104
diff changeset
   568
	long ulong int uint
0b12e9a57aa2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 24104
diff changeset
   569
	bool float double void pointer handle
19490
4d29d49edd98 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 19489
diff changeset
   570
    "
4d29d49edd98 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 19489
diff changeset
   571
24097
fe2d568b25c9 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 24078
diff changeset
   572
    |mappedType|
24098
25db884de25a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 24097
diff changeset
   573
24097
fe2d568b25c9 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 24078
diff changeset
   574
    TypeMap notNil ifTrue:[
24335
0b12e9a57aa2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 24104
diff changeset
   575
	(mappedType := TypeMap at:aType ifAbsent:nil) notNil ifTrue:[^ mappedType].
24097
fe2d568b25c9 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 24078
diff changeset
   576
    ].
24098
25db884de25a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 24097
diff changeset
   577
19490
4d29d49edd98 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 19489
diff changeset
   578
    aType == #sint8           ifTrue:[^ aType ].
4d29d49edd98 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 19489
diff changeset
   579
    aType == #sint16          ifTrue:[^ aType ].
4d29d49edd98 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 19489
diff changeset
   580
    aType == #sint32          ifTrue:[^ aType ].
4d29d49edd98 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 19489
diff changeset
   581
    aType == #sint64          ifTrue:[^ aType ].
4d29d49edd98 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 19489
diff changeset
   582
    aType == #uint8           ifTrue:[^ aType ].
4d29d49edd98 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 19489
diff changeset
   583
    aType == #uint16          ifTrue:[^ aType ].
4d29d49edd98 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 19489
diff changeset
   584
    aType == #uint32          ifTrue:[^ aType ].
4d29d49edd98 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 19489
diff changeset
   585
    aType == #uint64          ifTrue:[^ aType ].
4d29d49edd98 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 19489
diff changeset
   586
    aType == #double          ifTrue:[^ aType ].
4d29d49edd98 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 19489
diff changeset
   587
    aType == #float           ifTrue:[^ aType ].
4d29d49edd98 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 19489
diff changeset
   588
    aType == #char            ifTrue:[^ aType ].
4d29d49edd98 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 19489
diff changeset
   589
    aType == #void            ifTrue:[^ aType ].
4d29d49edd98 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 19489
diff changeset
   590
    aType == #bool            ifTrue:[^ aType ].
4d29d49edd98 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 19489
diff changeset
   591
    aType == #pointer         ifTrue:[^ aType ].
4d29d49edd98 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 19489
diff changeset
   592
    aType == #charPointer     ifTrue:[^ aType ].
4d29d49edd98 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 19489
diff changeset
   593
    aType == #wcharPointer    ifTrue:[^ aType ].
4d29d49edd98 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 19489
diff changeset
   594
4d29d49edd98 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 19489
diff changeset
   595
    aType == #int8            ifTrue:[^ #sint8 ].
4d29d49edd98 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 19489
diff changeset
   596
    aType == #int16           ifTrue:[^ #sint16 ].
4d29d49edd98 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 19489
diff changeset
   597
    aType == #int32           ifTrue:[^ #sint32 ].
4d29d49edd98 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 19489
diff changeset
   598
    aType == #int64           ifTrue:[^ #sint64 ].
4d29d49edd98 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 19489
diff changeset
   599
4d29d49edd98 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 19489
diff changeset
   600
    aType == #voidPointer         ifTrue:[^ #pointer ].
4d29d49edd98 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 19489
diff changeset
   601
    aType == #uint8Pointer        ifTrue:[^ #pointer ].
4d29d49edd98 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 19489
diff changeset
   602
    aType == #voidPointerPointer  ifTrue:[^ #pointer ].
4d29d49edd98 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 19489
diff changeset
   603
4d29d49edd98 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 19489
diff changeset
   604
    aType == #short           ifTrue:[^ #sint16 ].
4d29d49edd98 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 19489
diff changeset
   605
    aType == #long            ifTrue:[^ #long ].
4d29d49edd98 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 19489
diff changeset
   606
    aType == #int             ifTrue:[^ #int ].
4d29d49edd98 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 19489
diff changeset
   607
    aType == #uint            ifTrue:[^ #uint ].
4d29d49edd98 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 19489
diff changeset
   608
    aType == #ushort          ifTrue:[^ #uint16 ].
4d29d49edd98 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 19489
diff changeset
   609
    aType == #ulong           ifTrue:[^ #ulong ].
4d29d49edd98 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 19489
diff changeset
   610
    aType == #uchar           ifTrue:[^ #uint8 ].
4d29d49edd98 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 19489
diff changeset
   611
    aType == #byte            ifTrue:[^ #uint8 ].
4d29d49edd98 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 19489
diff changeset
   612
    aType == #longlong        ifTrue:[^ #sint64 ].
4d29d49edd98 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 19489
diff changeset
   613
    aType == #longLong        ifTrue:[^ #sint64 ].
4d29d49edd98 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 19489
diff changeset
   614
    aType == #ulonglong       ifTrue:[^ #uint64 ].
4d29d49edd98 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 19489
diff changeset
   615
    aType == #ulongLong       ifTrue:[^ #uint64 ].
4d29d49edd98 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 19489
diff changeset
   616
22162
aeace092a850 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 22144
diff changeset
   617
    aType == #unsignedInt     ifTrue:[^ #uint ].
aeace092a850 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 22144
diff changeset
   618
    aType == #unsignedShort   ifTrue:[^ #uint16 ].
aeace092a850 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 22144
diff changeset
   619
    aType == #unsignedLong    ifTrue:[^ #ulong ].
aeace092a850 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 22144
diff changeset
   620
    aType == #unsignedChar    ifTrue:[^ #uint8 ].
aeace092a850 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 22144
diff changeset
   621
19490
4d29d49edd98 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 19489
diff changeset
   622
    "/ windefs
24097
fe2d568b25c9 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 24078
diff changeset
   623
    (aType == #dword or:[aType == #DWORD])   ifTrue:[^ #uint32 ].
fe2d568b25c9 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 24078
diff changeset
   624
    (aType == #sdword or:[aType == #SDWORD]) ifTrue:[^ #sint32 ].
fe2d568b25c9 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 24078
diff changeset
   625
    (aType == #word or:[aType == #WORD])     ifTrue:[^ #uint16 ].
fe2d568b25c9 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 24078
diff changeset
   626
    (aType == #sword or:[aType == #SWORD])   ifTrue:[^ #sint16 ].
fe2d568b25c9 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 24078
diff changeset
   627
    (aType == #dwordlong or:[aType == #DWORDLONG])   ifTrue:[^ #uint64 ].
fe2d568b25c9 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 24078
diff changeset
   628
    (aType == #dword32 or:[aType == #DWORD32])   ifTrue:[^ #uint32 ].
fe2d568b25c9 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 24078
diff changeset
   629
    (aType == #dword64 or:[aType == #DWORD64])   ifTrue:[^ #uint64 ].
fe2d568b25c9 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 24078
diff changeset
   630
    (aType == #handle or:[aType == #HANDLE])     ifTrue:[^ #pointer ].
fe2d568b25c9 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 24078
diff changeset
   631
    (aType == #hbitmap or:[aType == #HBITMAP])   ifTrue:[^ #pointer ].
fe2d568b25c9 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 24078
diff changeset
   632
    (aType == #hdc or:[aType == #HDC])           ifTrue:[^ #pointer ].
fe2d568b25c9 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 24078
diff changeset
   633
    (aType == #hfile or:[aType == #HFILE])       ifTrue:[^ #int ].
19490
4d29d49edd98 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 19489
diff changeset
   634
    aType == #lpstr           ifTrue:[^ #charPointer ].
4d29d49edd98 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 19489
diff changeset
   635
    aType == #boolean         ifTrue:[^ #bool ].
4d29d49edd98 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 19489
diff changeset
   636
    "/ care for 64bit machines
22901
86ede7b35328 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 22802
diff changeset
   637
    aType == #ulongReturn     ifTrue:[^ ExternalBytes sizeofPointer == 8 ifTrue:[#uint64] ifFalse:[#uint32]].
19490
4d29d49edd98 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 19489
diff changeset
   638
    aType == #none            ifTrue:[^ #void ].
4d29d49edd98 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 19489
diff changeset
   639
    aType == #struct          ifTrue:[^ #pointer ].
4d29d49edd98 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 19489
diff changeset
   640
    aType == #structIn        ifTrue:[^ #pointer ].
4d29d49edd98 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 19489
diff changeset
   641
    aType == #structOut       ifTrue:[^ #pointer ].
4d29d49edd98 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 19489
diff changeset
   642
    aType == #structInOut     ifTrue:[^ #pointer ].
4d29d49edd98 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 19489
diff changeset
   643
    aType == #unsigned        ifTrue:[^ #uint ].
4d29d49edd98 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 19489
diff changeset
   644
4d29d49edd98 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 19489
diff changeset
   645
    aType == #ATOM            ifTrue:[^ #uint16 ].
4d29d49edd98 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 19489
diff changeset
   646
    aType == #BOOL            ifTrue:[^ #int ].
4d29d49edd98 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 19489
diff changeset
   647
    aType == #BOOLEAN         ifTrue:[^ #uint8 ].
4d29d49edd98 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 19489
diff changeset
   648
    aType == #BYTE            ifTrue:[^ #uint8 ].
24335
0b12e9a57aa2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 24104
diff changeset
   649
    "/ actually described as long (i.e. signed) in MS-docmentation,
24104
d5fa45826506 #BUGFIX by Stefan Reise
sr
parents: 24098
diff changeset
   650
    "/ but our code seems to depend on it being a uint32. See OLE code HRESULT succeeded:hresult
d5fa45826506 #BUGFIX by Stefan Reise
sr
parents: 24098
diff changeset
   651
    (aType == #hresult or:[aType == #HRESULT])   ifTrue:[^ #uint32 ].
24097
fe2d568b25c9 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 24078
diff changeset
   652
    (aType == #lparam or:[aType == #LPARAM])   ifTrue:[^ #pointer ].
fe2d568b25c9 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 24078
diff changeset
   653
    (aType == #wparam or:[aType == #WPARAM])   ifTrue:[^ #pointer ].
19501
4922889c4309 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 19494
diff changeset
   654
22162
aeace092a850 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 22144
diff changeset
   655
    aType == #LPWSTR          ifTrue:[^ #wcharPointer].
20528
4a4e915617b6 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20512
diff changeset
   656
    aType == #BSTR            ifTrue:[^ #wcharPointer].
4a4e915617b6 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20512
diff changeset
   657
19490
4d29d49edd98 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 19489
diff changeset
   658
    "/ care for 64bit machines
22901
86ede7b35328 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 22802
diff changeset
   659
    aType == #SIZE_T          ifTrue:[^ ExternalBytes sizeofPointer == 8 ifTrue:[#uint64] ifFalse:[#uint32]].
19490
4d29d49edd98 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 19489
diff changeset
   660
4d29d49edd98 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 19489
diff changeset
   661
    (aType isString or:[aType isSymbol]) ifFalse:[
24335
0b12e9a57aa2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 24104
diff changeset
   662
	aType isArray ifTrue:[
0b12e9a57aa2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 24104
diff changeset
   663
	    ^ aType collect:[:each | self ffiTypeSymbolForType:each]
0b12e9a57aa2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 24104
diff changeset
   664
	].
0b12e9a57aa2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 24104
diff changeset
   665
0b12e9a57aa2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 24104
diff changeset
   666
	CType isNil ifTrue:[
0b12e9a57aa2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 24104
diff changeset
   667
	    self error:'unknown type'.
0b12e9a57aa2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 24104
diff changeset
   668
	].
0b12e9a57aa2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 24104
diff changeset
   669
	"/ assume it is a ctype
0b12e9a57aa2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 24104
diff changeset
   670
	^ aType typeSymbol.
19490
4d29d49edd98 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 19489
diff changeset
   671
    ].
4d29d49edd98 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 19489
diff changeset
   672
4d29d49edd98 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 19489
diff changeset
   673
    (aType endsWith:'*') ifTrue:[
24335
0b12e9a57aa2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 24104
diff changeset
   674
	^ #pointer.
19490
4d29d49edd98 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 19489
diff changeset
   675
    ].
4d29d49edd98 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 19489
diff changeset
   676
    (aType endsWith:'Pointer') ifTrue:[
24335
0b12e9a57aa2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 24104
diff changeset
   677
	^ #pointer.
19490
4d29d49edd98 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 19489
diff changeset
   678
    ].
4d29d49edd98 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 19489
diff changeset
   679
    ^ aType
4d29d49edd98 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 19489
diff changeset
   680
22162
aeace092a850 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 22144
diff changeset
   681
    "Modified: / 04-08-2017 / 10:36:37 / cg"
24097
fe2d568b25c9 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 24078
diff changeset
   682
    "Modified: / 30-04-2019 / 18:13:25 / Claus Gittinger"
24104
d5fa45826506 #BUGFIX by Stefan Reise
sr
parents: 24098
diff changeset
   683
    "Modified: / 02-05-2019 / 14:26:41 / Stefan Reise"
24097
fe2d568b25c9 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 24078
diff changeset
   684
!
fe2d568b25c9 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 24078
diff changeset
   685
fe2d568b25c9 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 24078
diff changeset
   686
mapType:aTypeSymbol toFFI:mappedType
fe2d568b25c9 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 24078
diff changeset
   687
    "additional user defined type map:
24098
25db884de25a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 24097
diff changeset
   688
	eg. self mapType:#INT8 toFFI:#int8
24097
fe2d568b25c9 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 24078
diff changeset
   689
     allows use of INT8 in external function api declarations.
fe2d568b25c9 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 24078
diff changeset
   690
     mappedType should be one of the ffi-supported ones:
24098
25db884de25a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 24097
diff changeset
   691
	sint8, sint16, sint32, sint64
25db884de25a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 24097
diff changeset
   692
	uint8, uint16, uint32, uint64
25db884de25a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 24097
diff changeset
   693
	long ulong int uint
25db884de25a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 24097
diff changeset
   694
	bool float double void pointer handle"
24097
fe2d568b25c9 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 24078
diff changeset
   695
fe2d568b25c9 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 24078
diff changeset
   696
    TypeMap isNil ifTrue:[
24098
25db884de25a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 24097
diff changeset
   697
	TypeMap := Dictionary new.
24097
fe2d568b25c9 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 24078
diff changeset
   698
    ].
fe2d568b25c9 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 24078
diff changeset
   699
    TypeMap at:aTypeSymbol put:mappedType
fe2d568b25c9 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 24078
diff changeset
   700
fe2d568b25c9 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 24078
diff changeset
   701
    "Created: / 30-04-2019 / 18:15:06 / Claus Gittinger"
19490
4d29d49edd98 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 19489
diff changeset
   702
! !
4d29d49edd98 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 19489
diff changeset
   703
9321
734c7c432461 not yet finished
Claus Gittinger <cg@exept.de>
parents: 8891
diff changeset
   704
!ExternalLibraryFunction methodsFor:'accessing'!
734c7c432461 not yet finished
Claus Gittinger <cg@exept.de>
parents: 8891
diff changeset
   705
734c7c432461 not yet finished
Claus Gittinger <cg@exept.de>
parents: 8891
diff changeset
   706
argumentTypes
734c7c432461 not yet finished
Claus Gittinger <cg@exept.de>
parents: 8891
diff changeset
   707
    ^ argumentTypes
9463
864880338d7e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9460
diff changeset
   708
!
864880338d7e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9460
diff changeset
   709
11426
1fccae300393 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 11053
diff changeset
   710
argumentTypesString
11586
a3b2eef8a74c int vs. sint
Claus Gittinger <cg@exept.de>
parents: 11426
diff changeset
   711
    ^ String
a3b2eef8a74c int vs. sint
Claus Gittinger <cg@exept.de>
parents: 11426
diff changeset
   712
	streamContents:[:s |
a3b2eef8a74c int vs. sint
Claus Gittinger <cg@exept.de>
parents: 11426
diff changeset
   713
	    argumentTypes do:[:eachArgType |
a3b2eef8a74c int vs. sint
Claus Gittinger <cg@exept.de>
parents: 11426
diff changeset
   714
		eachArgType printOn:s.
a3b2eef8a74c int vs. sint
Claus Gittinger <cg@exept.de>
parents: 11426
diff changeset
   715
	    ] separatedBy:[
a3b2eef8a74c int vs. sint
Claus Gittinger <cg@exept.de>
parents: 11426
diff changeset
   716
		s nextPutAll:','.
a3b2eef8a74c int vs. sint
Claus Gittinger <cg@exept.de>
parents: 11426
diff changeset
   717
	    ].
a3b2eef8a74c int vs. sint
Claus Gittinger <cg@exept.de>
parents: 11426
diff changeset
   718
	].
11426
1fccae300393 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 11053
diff changeset
   719
!
1fccae300393 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 11053
diff changeset
   720
9463
864880338d7e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9460
diff changeset
   721
beAsync
864880338d7e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9460
diff changeset
   722
    "let this execute in a separate thread, in par with the other execution thread(s).
864880338d7e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9460
diff changeset
   723
     Ignored under unix/linux (until those support multiple threads too)."
864880338d7e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9460
diff changeset
   724
22556
cb550d205576 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 22544
diff changeset
   725
    flags := flags bitOr: FLAG_ASYNC.
9463
864880338d7e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9460
diff changeset
   726
864880338d7e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9460
diff changeset
   727
    "Created: / 01-08-2006 / 13:42:38 / cg"
864880338d7e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9460
diff changeset
   728
!
864880338d7e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9460
diff changeset
   729
9465
d11885052713 rewrite & cleanup
Claus Gittinger <cg@exept.de>
parents: 9464
diff changeset
   730
beCallTypeAPI
22556
cb550d205576 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 22544
diff changeset
   731
    flags := flags bitOr: CALLTYPE_API.
9465
d11885052713 rewrite & cleanup
Claus Gittinger <cg@exept.de>
parents: 9464
diff changeset
   732
d11885052713 rewrite & cleanup
Claus Gittinger <cg@exept.de>
parents: 9464
diff changeset
   733
    "Created: / 01-08-2006 / 15:12:40 / cg"
d11885052713 rewrite & cleanup
Claus Gittinger <cg@exept.de>
parents: 9464
diff changeset
   734
!
d11885052713 rewrite & cleanup
Claus Gittinger <cg@exept.de>
parents: 9464
diff changeset
   735
d11885052713 rewrite & cleanup
Claus Gittinger <cg@exept.de>
parents: 9464
diff changeset
   736
beCallTypeC
22556
cb550d205576 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 22544
diff changeset
   737
    flags := flags bitOr: CALLTYPE_C.
9465
d11885052713 rewrite & cleanup
Claus Gittinger <cg@exept.de>
parents: 9464
diff changeset
   738
d11885052713 rewrite & cleanup
Claus Gittinger <cg@exept.de>
parents: 9464
diff changeset
   739
    "Created: / 01-08-2006 / 15:12:40 / cg"
d11885052713 rewrite & cleanup
Claus Gittinger <cg@exept.de>
parents: 9464
diff changeset
   740
!
d11885052713 rewrite & cleanup
Claus Gittinger <cg@exept.de>
parents: 9464
diff changeset
   741
10481
b3526180579f +isExternalLibraryFunction
fm
parents: 10440
diff changeset
   742
beCallTypeOLE
22556
cb550d205576 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 22544
diff changeset
   743
    flags := flags bitOr: FLAG_VIRTUAL.
10481
b3526180579f +isExternalLibraryFunction
fm
parents: 10440
diff changeset
   744
b3526180579f +isExternalLibraryFunction
fm
parents: 10440
diff changeset
   745
    "Created: / 01-08-2006 / 15:12:40 / cg"
b3526180579f +isExternalLibraryFunction
fm
parents: 10440
diff changeset
   746
!
b3526180579f +isExternalLibraryFunction
fm
parents: 10440
diff changeset
   747
9465
d11885052713 rewrite & cleanup
Claus Gittinger <cg@exept.de>
parents: 9464
diff changeset
   748
beCallTypeUNIX64
22556
cb550d205576 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 22544
diff changeset
   749
    flags := flags bitOr: CALLTYPE_UNIX64.
9465
d11885052713 rewrite & cleanup
Claus Gittinger <cg@exept.de>
parents: 9464
diff changeset
   750
d11885052713 rewrite & cleanup
Claus Gittinger <cg@exept.de>
parents: 9464
diff changeset
   751
    "Created: / 01-08-2006 / 15:13:38 / cg"
d11885052713 rewrite & cleanup
Claus Gittinger <cg@exept.de>
parents: 9464
diff changeset
   752
!
d11885052713 rewrite & cleanup
Claus Gittinger <cg@exept.de>
parents: 9464
diff changeset
   753
d11885052713 rewrite & cleanup
Claus Gittinger <cg@exept.de>
parents: 9464
diff changeset
   754
beCallTypeV8
22556
cb550d205576 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 22544
diff changeset
   755
    flags := flags bitOr: CALLTYPE_V8.
9465
d11885052713 rewrite & cleanup
Claus Gittinger <cg@exept.de>
parents: 9464
diff changeset
   756
d11885052713 rewrite & cleanup
Claus Gittinger <cg@exept.de>
parents: 9464
diff changeset
   757
    "Created: / 01-08-2006 / 15:13:28 / cg"
d11885052713 rewrite & cleanup
Claus Gittinger <cg@exept.de>
parents: 9464
diff changeset
   758
!
d11885052713 rewrite & cleanup
Claus Gittinger <cg@exept.de>
parents: 9464
diff changeset
   759
d11885052713 rewrite & cleanup
Claus Gittinger <cg@exept.de>
parents: 9464
diff changeset
   760
beCallTypeV9
22556
cb550d205576 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 22544
diff changeset
   761
    flags := flags bitOr: CALLTYPE_V9.
9465
d11885052713 rewrite & cleanup
Claus Gittinger <cg@exept.de>
parents: 9464
diff changeset
   762
d11885052713 rewrite & cleanup
Claus Gittinger <cg@exept.de>
parents: 9464
diff changeset
   763
    "Created: / 01-08-2006 / 15:13:31 / cg"
d11885052713 rewrite & cleanup
Claus Gittinger <cg@exept.de>
parents: 9464
diff changeset
   764
!
d11885052713 rewrite & cleanup
Claus Gittinger <cg@exept.de>
parents: 9464
diff changeset
   765
d11885052713 rewrite & cleanup
Claus Gittinger <cg@exept.de>
parents: 9464
diff changeset
   766
beCallTypeWINAPI
d11885052713 rewrite & cleanup
Claus Gittinger <cg@exept.de>
parents: 9464
diff changeset
   767
    self beCallTypeAPI
d11885052713 rewrite & cleanup
Claus Gittinger <cg@exept.de>
parents: 9464
diff changeset
   768
d11885052713 rewrite & cleanup
Claus Gittinger <cg@exept.de>
parents: 9464
diff changeset
   769
    "Modified: / 01-08-2006 / 15:14:02 / cg"
d11885052713 rewrite & cleanup
Claus Gittinger <cg@exept.de>
parents: 9464
diff changeset
   770
!
d11885052713 rewrite & cleanup
Claus Gittinger <cg@exept.de>
parents: 9464
diff changeset
   771
9525
120234adc94e const specifier (is this a good name ?)
ca
parents: 9524
diff changeset
   772
beConstReturnValue
10025
053904a63549 stc-compiled ExternalLibraryFunctions
Claus Gittinger <cg@exept.de>
parents: 9981
diff changeset
   773
    "specify that a pointer return value is not to be finalized
9525
120234adc94e const specifier (is this a good name ?)
ca
parents: 9524
diff changeset
   774
     (i.e. points to static data or data which is freed by c)"
120234adc94e const specifier (is this a good name ?)
ca
parents: 9524
diff changeset
   775
22556
cb550d205576 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 22544
diff changeset
   776
    flags := flags bitOr: FLAG_RETVAL_IS_CONST.
9525
120234adc94e const specifier (is this a good name ?)
ca
parents: 9524
diff changeset
   777
120234adc94e const specifier (is this a good name ?)
ca
parents: 9524
diff changeset
   778
    "Created: / 01-08-2006 / 13:56:48 / cg"
120234adc94e const specifier (is this a good name ?)
ca
parents: 9524
diff changeset
   779
!
120234adc94e const specifier (is this a good name ?)
ca
parents: 9524
diff changeset
   780
21410
660679622f0c #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21409
diff changeset
   781
beMustFreeReturnValue
660679622f0c #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21409
diff changeset
   782
    "specify that a pointer return value is to be freed explicitly by st/x
660679622f0c #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21409
diff changeset
   783
     (i.e. points to mallocd data which is not freed by c)"
660679622f0c #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21409
diff changeset
   784
22556
cb550d205576 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 22544
diff changeset
   785
    flags := flags bitOr: FLAG_RETVAL_MUST_FREE.
21410
660679622f0c #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21409
diff changeset
   786
660679622f0c #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21409
diff changeset
   787
    "Created: / 12-02-2017 / 23:41:48 / cg"
660679622f0c #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21409
diff changeset
   788
!
660679622f0c #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21409
diff changeset
   789
9463
864880338d7e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9460
diff changeset
   790
beNonVirtualCPP
864880338d7e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9460
diff changeset
   791
    "specify this as a non-virtual c++-function"
864880338d7e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9460
diff changeset
   792
22556
cb550d205576 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 22544
diff changeset
   793
    flags := flags bitOr: FLAG_NONVIRTUAL.
9463
864880338d7e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9460
diff changeset
   794
864880338d7e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9460
diff changeset
   795
    "Created: / 01-08-2006 / 13:56:44 / cg"
864880338d7e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9460
diff changeset
   796
!
864880338d7e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9460
diff changeset
   797
19311
6f1d1ea6dba8 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 18240
diff changeset
   798
beObjectiveC
6f1d1ea6dba8 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 18240
diff changeset
   799
    "specify this as an objective-c message send"
6f1d1ea6dba8 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 18240
diff changeset
   800
22556
cb550d205576 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 22544
diff changeset
   801
    flags := flags bitOr: FLAG_OBJECTIVEC.
19311
6f1d1ea6dba8 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 18240
diff changeset
   802
6f1d1ea6dba8 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 18240
diff changeset
   803
    "Created: / 01-08-2006 / 13:56:48 / cg"
6f1d1ea6dba8 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 18240
diff changeset
   804
!
6f1d1ea6dba8 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 18240
diff changeset
   805
9463
864880338d7e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9460
diff changeset
   806
beUnlimitedStack
864880338d7e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9460
diff changeset
   807
    "let this execute on the c-stack (as opposed to the thread-stack)
864880338d7e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9460
diff changeset
   808
     for unlimited auto-sized-stack under unix/linux.
864880338d7e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9460
diff changeset
   809
     Ignored under windows."
864880338d7e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9460
diff changeset
   810
22556
cb550d205576 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 22544
diff changeset
   811
    flags := flags bitOr: FLAG_UNLIMITEDSTACK.
9463
864880338d7e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9460
diff changeset
   812
864880338d7e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9460
diff changeset
   813
    "Created: / 01-08-2006 / 13:41:54 / cg"
864880338d7e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9460
diff changeset
   814
!
864880338d7e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9460
diff changeset
   815
864880338d7e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9460
diff changeset
   816
beVirtualCPP
864880338d7e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9460
diff changeset
   817
    "specify this as a virtual c++-function"
864880338d7e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9460
diff changeset
   818
22556
cb550d205576 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 22544
diff changeset
   819
    flags := flags bitOr: FLAG_VIRTUAL.
9463
864880338d7e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9460
diff changeset
   820
864880338d7e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9460
diff changeset
   821
    "Created: / 01-08-2006 / 13:56:48 / cg"
864880338d7e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9460
diff changeset
   822
!
864880338d7e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9460
diff changeset
   823
23831
c741a73646f0 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 23829
diff changeset
   824
callType:aSymbol
c741a73646f0 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 23829
diff changeset
   825
    (aSymbol sameAs:'api') ifTrue:[
24046
6cf8161ea948 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 23834
diff changeset
   826
	self beCallTypeAPI.
6cf8161ea948 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 23834
diff changeset
   827
	^ self.
23831
c741a73646f0 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 23829
diff changeset
   828
    ].
c741a73646f0 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 23829
diff changeset
   829
    (aSymbol sameAs:'ole') ifTrue:[
24046
6cf8161ea948 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 23834
diff changeset
   830
	self beCallTypeOLE.
6cf8161ea948 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 23834
diff changeset
   831
	^ self.
23831
c741a73646f0 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 23829
diff changeset
   832
    ].
c741a73646f0 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 23829
diff changeset
   833
    (aSymbol sameAs:'c') ifTrue:[
24046
6cf8161ea948 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 23834
diff changeset
   834
	self beCallTypeC.
6cf8161ea948 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 23834
diff changeset
   835
	^ self.
23831
c741a73646f0 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 23829
diff changeset
   836
    ].
c741a73646f0 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 23829
diff changeset
   837
    (aSymbol sameAs:'objc') ifTrue:[
24046
6cf8161ea948 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 23834
diff changeset
   838
	self beObjectiveC.
6cf8161ea948 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 23834
diff changeset
   839
	^ self.
23831
c741a73646f0 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 23829
diff changeset
   840
    ].
c741a73646f0 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 23829
diff changeset
   841
    (aSymbol sameAs:'virtualCPP') ifTrue:[
24046
6cf8161ea948 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 23834
diff changeset
   842
	self beCallTypeC.
6cf8161ea948 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 23834
diff changeset
   843
	self beVirtualCPP.
6cf8161ea948 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 23834
diff changeset
   844
	^ self.
23831
c741a73646f0 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 23829
diff changeset
   845
    ].
c741a73646f0 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 23829
diff changeset
   846
    self error:'unknown calltype'
c741a73646f0 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 23829
diff changeset
   847
c741a73646f0 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 23829
diff changeset
   848
    "Created: / 04-03-2019 / 11:02:12 / Claus Gittinger"
c741a73646f0 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 23829
diff changeset
   849
!
c741a73646f0 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 23829
diff changeset
   850
9465
d11885052713 rewrite & cleanup
Claus Gittinger <cg@exept.de>
parents: 9464
diff changeset
   851
callTypeNumber
22556
cb550d205576 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 22544
diff changeset
   852
    ^ flags bitAnd: CALLTYPE_MASK.
9465
d11885052713 rewrite & cleanup
Claus Gittinger <cg@exept.de>
parents: 9464
diff changeset
   853
d11885052713 rewrite & cleanup
Claus Gittinger <cg@exept.de>
parents: 9464
diff changeset
   854
    "Created: / 01-08-2006 / 15:12:10 / cg"
d11885052713 rewrite & cleanup
Claus Gittinger <cg@exept.de>
parents: 9464
diff changeset
   855
!
d11885052713 rewrite & cleanup
Claus Gittinger <cg@exept.de>
parents: 9464
diff changeset
   856
9463
864880338d7e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9460
diff changeset
   857
isAsync
864880338d7e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9460
diff changeset
   858
    "is this executed in a separate thread, in par with the other execution thread(s) ?"
864880338d7e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9460
diff changeset
   859
22556
cb550d205576 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 22544
diff changeset
   860
    ^ flags bitTest: FLAG_ASYNC.
9463
864880338d7e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9460
diff changeset
   861
864880338d7e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9460
diff changeset
   862
    "Created: / 01-08-2006 / 13:46:53 / cg"
864880338d7e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9460
diff changeset
   863
!
864880338d7e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9460
diff changeset
   864
9519
ad18bf96758d *** empty log message ***
ca
parents: 9483
diff changeset
   865
isCPPFunction
ad18bf96758d *** empty log message ***
ca
parents: 9483
diff changeset
   866
    "is this a virtual or non-virtual c++-function ?"
ad18bf96758d *** empty log message ***
ca
parents: 9483
diff changeset
   867
22556
cb550d205576 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 22544
diff changeset
   868
    ^ flags bitTest: (FLAG_VIRTUAL bitOr: FLAG_NONVIRTUAL).
9519
ad18bf96758d *** empty log message ***
ca
parents: 9483
diff changeset
   869
ad18bf96758d *** empty log message ***
ca
parents: 9483
diff changeset
   870
    "Created: / 01-08-2006 / 13:56:54 / cg"
ad18bf96758d *** empty log message ***
ca
parents: 9483
diff changeset
   871
!
ad18bf96758d *** empty log message ***
ca
parents: 9483
diff changeset
   872
9465
d11885052713 rewrite & cleanup
Claus Gittinger <cg@exept.de>
parents: 9464
diff changeset
   873
isCallTypeAPI
19490
4d29d49edd98 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 19489
diff changeset
   874
    "is this a windows API-call linkage call.
4d29d49edd98 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 19489
diff changeset
   875
     Attention: this uses a different call API (callee unwinds the stack),
4d29d49edd98 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 19489
diff changeset
   876
     and MUST be declared as such for many Kernel functions.
4d29d49edd98 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 19489
diff changeset
   877
     The calltype API is one of the worst historic garbage kept by MS..."
4d29d49edd98 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 19489
diff changeset
   878
22556
cb550d205576 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 22544
diff changeset
   879
    ^ (flags bitAnd: CALLTYPE_MASK) == CALLTYPE_API.
9465
d11885052713 rewrite & cleanup
Claus Gittinger <cg@exept.de>
parents: 9464
diff changeset
   880
d11885052713 rewrite & cleanup
Claus Gittinger <cg@exept.de>
parents: 9464
diff changeset
   881
    "Created: / 01-08-2006 / 15:21:16 / cg"
d11885052713 rewrite & cleanup
Claus Gittinger <cg@exept.de>
parents: 9464
diff changeset
   882
!
d11885052713 rewrite & cleanup
Claus Gittinger <cg@exept.de>
parents: 9464
diff changeset
   883
d11885052713 rewrite & cleanup
Claus Gittinger <cg@exept.de>
parents: 9464
diff changeset
   884
isCallTypeC
19490
4d29d49edd98 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 19489
diff changeset
   885
    "is this a regular C-call (attention: on windows, there are two kinds of calls)"
4d29d49edd98 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 19489
diff changeset
   886
22556
cb550d205576 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 22544
diff changeset
   887
    ^ (flags bitAnd: CALLTYPE_MASK) == CALLTYPE_C.
9465
d11885052713 rewrite & cleanup
Claus Gittinger <cg@exept.de>
parents: 9464
diff changeset
   888
d11885052713 rewrite & cleanup
Claus Gittinger <cg@exept.de>
parents: 9464
diff changeset
   889
    "Created: / 01-08-2006 / 15:21:23 / cg"
d11885052713 rewrite & cleanup
Claus Gittinger <cg@exept.de>
parents: 9464
diff changeset
   890
!
d11885052713 rewrite & cleanup
Claus Gittinger <cg@exept.de>
parents: 9464
diff changeset
   891
10483
79c64bcd4d29 +ole queries
fm
parents: 10481
diff changeset
   892
isCallTypeOLE
19490
4d29d49edd98 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 19489
diff changeset
   893
    "is this an OLE-object call ? (eg. a virtual c++ call; same as isCallTypeCPP)"
4d29d49edd98 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 19489
diff changeset
   894
22556
cb550d205576 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 22544
diff changeset
   895
    ^ flags bitTest: FLAG_VIRTUAL.
10483
79c64bcd4d29 +ole queries
fm
parents: 10481
diff changeset
   896
79c64bcd4d29 +ole queries
fm
parents: 10481
diff changeset
   897
    "Created: / 01-08-2006 / 15:21:23 / cg"
20958
4a8561ed705e #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20561
diff changeset
   898
    "Modified (format): / 12-11-2016 / 11:37:38 / cg"
10483
79c64bcd4d29 +ole queries
fm
parents: 10481
diff changeset
   899
!
79c64bcd4d29 +ole queries
fm
parents: 10481
diff changeset
   900
9525
120234adc94e const specifier (is this a good name ?)
ca
parents: 9524
diff changeset
   901
isConstReturnValue
10025
053904a63549 stc-compiled ExternalLibraryFunctions
Claus Gittinger <cg@exept.de>
parents: 9981
diff changeset
   902
    "is the pointer return value not to be finalized
9525
120234adc94e const specifier (is this a good name ?)
ca
parents: 9524
diff changeset
   903
     (i.e. points to static data or data which is freed by c)"
120234adc94e const specifier (is this a good name ?)
ca
parents: 9524
diff changeset
   904
22556
cb550d205576 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 22544
diff changeset
   905
    ^ flags bitTest: FLAG_RETVAL_IS_CONST.
9525
120234adc94e const specifier (is this a good name ?)
ca
parents: 9524
diff changeset
   906
120234adc94e const specifier (is this a good name ?)
ca
parents: 9524
diff changeset
   907
    "Created: / 01-08-2006 / 13:56:48 / cg"
120234adc94e const specifier (is this a good name ?)
ca
parents: 9524
diff changeset
   908
!
120234adc94e const specifier (is this a good name ?)
ca
parents: 9524
diff changeset
   909
9463
864880338d7e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9460
diff changeset
   910
isNonVirtualCPP
864880338d7e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9460
diff changeset
   911
    "is this a non-virtual c++-function ?"
864880338d7e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9460
diff changeset
   912
22556
cb550d205576 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 22544
diff changeset
   913
    ^ flags bitTest: FLAG_NONVIRTUAL.
9463
864880338d7e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9460
diff changeset
   914
864880338d7e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9460
diff changeset
   915
    "Created: / 01-08-2006 / 13:56:51 / cg"
864880338d7e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9460
diff changeset
   916
!
864880338d7e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9460
diff changeset
   917
19311
6f1d1ea6dba8 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 18240
diff changeset
   918
isObjectiveC
6f1d1ea6dba8 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 18240
diff changeset
   919
    "is this an objective-C message?"
6f1d1ea6dba8 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 18240
diff changeset
   920
22556
cb550d205576 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 22544
diff changeset
   921
    ^ flags bitTest: FLAG_OBJECTIVEC.
19311
6f1d1ea6dba8 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 18240
diff changeset
   922
!
6f1d1ea6dba8 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 18240
diff changeset
   923
9463
864880338d7e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9460
diff changeset
   924
isUnlimitedStack
864880338d7e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9460
diff changeset
   925
    "will this execute on the c-stack (as opposed to the thread-stack)
864880338d7e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9460
diff changeset
   926
     for unlimited auto-sized-stack under unix/linux.
864880338d7e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9460
diff changeset
   927
     Ignored under windows."
864880338d7e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9460
diff changeset
   928
22556
cb550d205576 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 22544
diff changeset
   929
    ^ flags bitTest: FLAG_UNLIMITEDSTACK.
9463
864880338d7e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9460
diff changeset
   930
864880338d7e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9460
diff changeset
   931
    "Created: / 01-08-2006 / 14:17:07 / cg"
864880338d7e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9460
diff changeset
   932
!
864880338d7e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9460
diff changeset
   933
864880338d7e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9460
diff changeset
   934
isVirtualCPP
19490
4d29d49edd98 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 19489
diff changeset
   935
    "is this a virtual c++-function (same as isCallTypeOLE) ?"
9463
864880338d7e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9460
diff changeset
   936
22556
cb550d205576 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 22544
diff changeset
   937
    ^ flags bitTest: FLAG_VIRTUAL.
9463
864880338d7e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9460
diff changeset
   938
864880338d7e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9460
diff changeset
   939
    "Created: / 01-08-2006 / 13:56:54 / cg"
10483
79c64bcd4d29 +ole queries
fm
parents: 10481
diff changeset
   940
!
79c64bcd4d29 +ole queries
fm
parents: 10481
diff changeset
   941
11426
1fccae300393 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 11053
diff changeset
   942
moduleName
1fccae300393 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 11053
diff changeset
   943
    ^ moduleName
1fccae300393 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 11053
diff changeset
   944
!
1fccae300393 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 11053
diff changeset
   945
21409
c405d6641c96 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21408
diff changeset
   946
mustFreeReturnValue
22556
cb550d205576 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 22544
diff changeset
   947
    "answer true, if a pointer to some C-datum is returned, which must be freed by ST/X.
21409
c405d6641c96 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21408
diff changeset
   948
     (i.e. points to malloc'd data which is NOT freed by c)"
c405d6641c96 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21408
diff changeset
   949
22556
cb550d205576 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 22544
diff changeset
   950
    ^ flags bitTest: FLAG_RETVAL_MUST_FREE.
21409
c405d6641c96 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21408
diff changeset
   951
c405d6641c96 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21408
diff changeset
   952
    "Created: / 12-02-2017 / 23:31:27 / cg"
c405d6641c96 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21408
diff changeset
   953
!
c405d6641c96 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21408
diff changeset
   954
10484
29039d89239d + returnType
fm
parents: 10483
diff changeset
   955
returnType
29039d89239d + returnType
fm
parents: 10483
diff changeset
   956
    ^ returnType
29039d89239d + returnType
fm
parents: 10483
diff changeset
   957
!
29039d89239d + returnType
fm
parents: 10483
diff changeset
   958
10483
79c64bcd4d29 +ole queries
fm
parents: 10481
diff changeset
   959
vtableIndex
79c64bcd4d29 +ole queries
fm
parents: 10481
diff changeset
   960
    name isNumber ifFalse:[^ nil].
79c64bcd4d29 +ole queries
fm
parents: 10481
diff changeset
   961
    ^ name.
9321
734c7c432461 not yet finished
Claus Gittinger <cg@exept.de>
parents: 8891
diff changeset
   962
! !
734c7c432461 not yet finished
Claus Gittinger <cg@exept.de>
parents: 8891
diff changeset
   963
20289
5472006d6a61 #DOCUMENTATION by sr
sr
parents: 20288
diff changeset
   964
8891
c30a030ff5ec more FFI (foreign function interface) support - still incomplete
Stefan Vogel <sv@exept.de>
parents: 8728
diff changeset
   965
!ExternalLibraryFunction methodsFor:'invoking'!
c30a030ff5ec more FFI (foreign function interface) support - still incomplete
Stefan Vogel <sv@exept.de>
parents: 8728
diff changeset
   966
c30a030ff5ec more FFI (foreign function interface) support - still incomplete
Stefan Vogel <sv@exept.de>
parents: 8728
diff changeset
   967
invoke
23828
cbcc99660889 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 23785
diff changeset
   968
    "call the function with no arguments"
cbcc99660889 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 23785
diff changeset
   969
9321
734c7c432461 not yet finished
Claus Gittinger <cg@exept.de>
parents: 8891
diff changeset
   970
    self hasCode ifFalse:[
24046
6cf8161ea948 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 23834
diff changeset
   971
	self prepareInvoke.
8891
c30a030ff5ec more FFI (foreign function interface) support - still incomplete
Stefan Vogel <sv@exept.de>
parents: 8728
diff changeset
   972
    ].
23829
209adc65cf44 renamed private method
Claus Gittinger <cg@exept.de>
parents: 23828
diff changeset
   973
    ^ self invokeFFIwithArguments:nil forInstance:nil
23828
cbcc99660889 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 23785
diff changeset
   974
cbcc99660889 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 23785
diff changeset
   975
    "Modified (comment): / 04-03-2019 / 09:41:20 / Claus Gittinger"
8891
c30a030ff5ec more FFI (foreign function interface) support - still incomplete
Stefan Vogel <sv@exept.de>
parents: 8728
diff changeset
   976
!
c30a030ff5ec more FFI (foreign function interface) support - still incomplete
Stefan Vogel <sv@exept.de>
parents: 8728
diff changeset
   977
9347
31adc57e6954 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9346
diff changeset
   978
invokeCPPVirtualOn:anInstance
23828
cbcc99660889 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 23785
diff changeset
   979
    "call a CPP virtual function with no arguments"
24046
6cf8161ea948 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 23834
diff changeset
   980
9341
719fcf48695b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9340
diff changeset
   981
    self hasCode ifFalse:[
24046
6cf8161ea948 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 23834
diff changeset
   982
	self prepareInvoke.
9341
719fcf48695b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9340
diff changeset
   983
    ].
23829
209adc65cf44 renamed private method
Claus Gittinger <cg@exept.de>
parents: 23828
diff changeset
   984
    ^ self invokeFFIwithArguments:nil forInstance:anInstance
23828
cbcc99660889 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 23785
diff changeset
   985
cbcc99660889 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 23785
diff changeset
   986
    "Modified (comment): / 04-03-2019 / 09:39:27 / Claus Gittinger"
9341
719fcf48695b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9340
diff changeset
   987
!
719fcf48695b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9340
diff changeset
   988
23828
cbcc99660889 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 23785
diff changeset
   989
invokeCPPVirtualOn:anInstance with:arg
cbcc99660889 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 23785
diff changeset
   990
    "call a CPP virtual function with 1 argument"
cbcc99660889 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 23785
diff changeset
   991
9341
719fcf48695b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9340
diff changeset
   992
    self hasCode ifFalse:[
24046
6cf8161ea948 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 23834
diff changeset
   993
	self prepareInvoke.
9341
719fcf48695b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9340
diff changeset
   994
    ].
24046
6cf8161ea948 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 23834
diff changeset
   995
    ^ self
6cf8161ea948 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 23834
diff changeset
   996
	invokeFFIwithArguments:(Array with:arg)
6cf8161ea948 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 23834
diff changeset
   997
	forInstance:anInstance
23828
cbcc99660889 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 23785
diff changeset
   998
cbcc99660889 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 23785
diff changeset
   999
    "Modified (comment): / 04-03-2019 / 09:39:34 / Claus Gittinger"
9341
719fcf48695b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9340
diff changeset
  1000
!
719fcf48695b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9340
diff changeset
  1001
23828
cbcc99660889 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 23785
diff changeset
  1002
invokeCPPVirtualOn:anInstance with:arg1 with:arg2
cbcc99660889 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 23785
diff changeset
  1003
    "call a CPP virtual function with 2 arguments"
cbcc99660889 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 23785
diff changeset
  1004
9341
719fcf48695b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9340
diff changeset
  1005
    self hasCode ifFalse:[
24046
6cf8161ea948 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 23834
diff changeset
  1006
	self prepareInvoke.
9341
719fcf48695b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9340
diff changeset
  1007
    ].
24046
6cf8161ea948 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 23834
diff changeset
  1008
    ^ self
6cf8161ea948 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 23834
diff changeset
  1009
	invokeFFIwithArguments:(Array with:arg1 with:arg2)
6cf8161ea948 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 23834
diff changeset
  1010
	forInstance:anInstance
23828
cbcc99660889 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 23785
diff changeset
  1011
cbcc99660889 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 23785
diff changeset
  1012
    "Modified (comment): / 04-03-2019 / 09:39:38 / Claus Gittinger"
cbcc99660889 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 23785
diff changeset
  1013
!
cbcc99660889 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 23785
diff changeset
  1014
cbcc99660889 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 23785
diff changeset
  1015
invokeCPPVirtualOn:anInstance with:arg1 with:arg2 with:arg3
cbcc99660889 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 23785
diff changeset
  1016
    "call a CPP virtual function with 3 arguments"
cbcc99660889 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 23785
diff changeset
  1017
cbcc99660889 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 23785
diff changeset
  1018
    self hasCode ifFalse:[
24046
6cf8161ea948 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 23834
diff changeset
  1019
	self prepareInvoke.
23828
cbcc99660889 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 23785
diff changeset
  1020
    ].
24046
6cf8161ea948 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 23834
diff changeset
  1021
    ^ self
6cf8161ea948 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 23834
diff changeset
  1022
	invokeFFIwithArguments:(Array with:arg1 with:arg2 with:arg3)
6cf8161ea948 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 23834
diff changeset
  1023
	forInstance:anInstance
23828
cbcc99660889 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 23785
diff changeset
  1024
cbcc99660889 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 23785
diff changeset
  1025
    "Modified (comment): / 04-03-2019 / 09:39:43 / Claus Gittinger"
9341
719fcf48695b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9340
diff changeset
  1026
!
719fcf48695b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9340
diff changeset
  1027
23828
cbcc99660889 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 23785
diff changeset
  1028
invokeCPPVirtualOn:anInstance with:arg1 with:arg2 with:arg3 with:arg4
cbcc99660889 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 23785
diff changeset
  1029
    "call a CPP virtual function with 4 arguments"
cbcc99660889 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 23785
diff changeset
  1030
9341
719fcf48695b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9340
diff changeset
  1031
    self hasCode ifFalse:[
24046
6cf8161ea948 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 23834
diff changeset
  1032
	self prepareInvoke.
9341
719fcf48695b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9340
diff changeset
  1033
    ].
24046
6cf8161ea948 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 23834
diff changeset
  1034
    ^ self
6cf8161ea948 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 23834
diff changeset
  1035
	invokeFFIwithArguments:(Array with:arg1 with:arg2 with:arg3 with:arg4)
6cf8161ea948 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 23834
diff changeset
  1036
	forInstance:anInstance
23828
cbcc99660889 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 23785
diff changeset
  1037
cbcc99660889 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 23785
diff changeset
  1038
    "Modified (comment): / 04-03-2019 / 09:39:48 / Claus Gittinger"
9341
719fcf48695b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9340
diff changeset
  1039
!
719fcf48695b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9340
diff changeset
  1040
23828
cbcc99660889 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 23785
diff changeset
  1041
invokeCPPVirtualOn:anInstance withArguments:args
cbcc99660889 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 23785
diff changeset
  1042
    "call a CPP virtual function with up to maxArgs (15) arguments"
cbcc99660889 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 23785
diff changeset
  1043
9341
719fcf48695b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9340
diff changeset
  1044
    self hasCode ifFalse:[
24046
6cf8161ea948 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 23834
diff changeset
  1045
	self prepareInvoke.
9341
719fcf48695b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9340
diff changeset
  1046
    ].
24046
6cf8161ea948 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 23834
diff changeset
  1047
    ^ self
6cf8161ea948 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 23834
diff changeset
  1048
	invokeFFIwithArguments:args
6cf8161ea948 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 23834
diff changeset
  1049
	forInstance:anInstance
23828
cbcc99660889 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 23785
diff changeset
  1050
cbcc99660889 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 23785
diff changeset
  1051
    "Modified (comment): / 04-03-2019 / 09:39:57 / Claus Gittinger"
9341
719fcf48695b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9340
diff changeset
  1052
!
719fcf48695b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9340
diff changeset
  1053
23828
cbcc99660889 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 23785
diff changeset
  1054
invokeObjCOn:anInstance
cbcc99660889 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 23785
diff changeset
  1055
    "call an ObjC method with no arguments"
cbcc99660889 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 23785
diff changeset
  1056
10481
b3526180579f +isExternalLibraryFunction
fm
parents: 10440
diff changeset
  1057
    self hasCode ifFalse:[
24046
6cf8161ea948 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 23834
diff changeset
  1058
	self prepareObjCInvoke.
10481
b3526180579f +isExternalLibraryFunction
fm
parents: 10440
diff changeset
  1059
    ].
23829
209adc65cf44 renamed private method
Claus Gittinger <cg@exept.de>
parents: 23828
diff changeset
  1060
    ^ self invokeFFIwithArguments:nil forInstance:anInstance
23828
cbcc99660889 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 23785
diff changeset
  1061
cbcc99660889 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 23785
diff changeset
  1062
    "Created: / 04-03-2019 / 09:12:12 / Claus Gittinger"
cbcc99660889 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 23785
diff changeset
  1063
!
cbcc99660889 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 23785
diff changeset
  1064
cbcc99660889 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 23785
diff changeset
  1065
invokeObjCOn:anInstance withArguments:args
cbcc99660889 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 23785
diff changeset
  1066
    "call an ObjC method with up to maxArgs (15) arguments"
cbcc99660889 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 23785
diff changeset
  1067
cbcc99660889 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 23785
diff changeset
  1068
    self hasCode ifFalse:[
24046
6cf8161ea948 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 23834
diff changeset
  1069
	self prepareObjCInvoke.
23828
cbcc99660889 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 23785
diff changeset
  1070
    ].
23829
209adc65cf44 renamed private method
Claus Gittinger <cg@exept.de>
parents: 23828
diff changeset
  1071
    ^ self invokeFFIwithArguments:args forInstance:anInstance
23828
cbcc99660889 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 23785
diff changeset
  1072
cbcc99660889 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 23785
diff changeset
  1073
    "Created: / 04-03-2019 / 09:39:03 / Claus Gittinger"
10481
b3526180579f +isExternalLibraryFunction
fm
parents: 10440
diff changeset
  1074
!
b3526180579f +isExternalLibraryFunction
fm
parents: 10440
diff changeset
  1075
8891
c30a030ff5ec more FFI (foreign function interface) support - still incomplete
Stefan Vogel <sv@exept.de>
parents: 8728
diff changeset
  1076
invokeWith:arg
23828
cbcc99660889 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 23785
diff changeset
  1077
    "call the function with 1 argument"
cbcc99660889 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 23785
diff changeset
  1078
9321
734c7c432461 not yet finished
Claus Gittinger <cg@exept.de>
parents: 8891
diff changeset
  1079
    self hasCode ifFalse:[
24046
6cf8161ea948 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 23834
diff changeset
  1080
	self prepareInvoke.
9321
734c7c432461 not yet finished
Claus Gittinger <cg@exept.de>
parents: 8891
diff changeset
  1081
    ].
23829
209adc65cf44 renamed private method
Claus Gittinger <cg@exept.de>
parents: 23828
diff changeset
  1082
    ^ self invokeFFIwithArguments:(Array with:arg) forInstance:nil
23828
cbcc99660889 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 23785
diff changeset
  1083
cbcc99660889 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 23785
diff changeset
  1084
    "Modified (comment): / 04-03-2019 / 09:41:14 / Claus Gittinger"
9321
734c7c432461 not yet finished
Claus Gittinger <cg@exept.de>
parents: 8891
diff changeset
  1085
!
8891
c30a030ff5ec more FFI (foreign function interface) support - still incomplete
Stefan Vogel <sv@exept.de>
parents: 8728
diff changeset
  1086
9321
734c7c432461 not yet finished
Claus Gittinger <cg@exept.de>
parents: 8891
diff changeset
  1087
invokeWith:arg1 with:arg2
23828
cbcc99660889 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 23785
diff changeset
  1088
    "call the function with 2 arguments"
cbcc99660889 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 23785
diff changeset
  1089
9321
734c7c432461 not yet finished
Claus Gittinger <cg@exept.de>
parents: 8891
diff changeset
  1090
    self hasCode ifFalse:[
24046
6cf8161ea948 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 23834
diff changeset
  1091
	self prepareInvoke.
8891
c30a030ff5ec more FFI (foreign function interface) support - still incomplete
Stefan Vogel <sv@exept.de>
parents: 8728
diff changeset
  1092
    ].
23829
209adc65cf44 renamed private method
Claus Gittinger <cg@exept.de>
parents: 23828
diff changeset
  1093
    ^ self invokeFFIwithArguments:(Array with:arg1 with:arg2) forInstance:nil
23828
cbcc99660889 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 23785
diff changeset
  1094
cbcc99660889 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 23785
diff changeset
  1095
    "Modified (comment): / 04-03-2019 / 09:41:07 / Claus Gittinger"
9321
734c7c432461 not yet finished
Claus Gittinger <cg@exept.de>
parents: 8891
diff changeset
  1096
!
734c7c432461 not yet finished
Claus Gittinger <cg@exept.de>
parents: 8891
diff changeset
  1097
734c7c432461 not yet finished
Claus Gittinger <cg@exept.de>
parents: 8891
diff changeset
  1098
invokeWith:arg1 with:arg2 with:arg3
23828
cbcc99660889 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 23785
diff changeset
  1099
    "call the function with 3 arguments"
cbcc99660889 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 23785
diff changeset
  1100
9321
734c7c432461 not yet finished
Claus Gittinger <cg@exept.de>
parents: 8891
diff changeset
  1101
    self hasCode ifFalse:[
24046
6cf8161ea948 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 23834
diff changeset
  1102
	self prepareInvoke.
9321
734c7c432461 not yet finished
Claus Gittinger <cg@exept.de>
parents: 8891
diff changeset
  1103
    ].
23829
209adc65cf44 renamed private method
Claus Gittinger <cg@exept.de>
parents: 23828
diff changeset
  1104
    ^ self invokeFFIwithArguments:(Array with:arg1 with:arg2 with:arg3) forInstance:nil
23828
cbcc99660889 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 23785
diff changeset
  1105
cbcc99660889 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 23785
diff changeset
  1106
    "Modified (comment): / 04-03-2019 / 09:41:01 / Claus Gittinger"
9321
734c7c432461 not yet finished
Claus Gittinger <cg@exept.de>
parents: 8891
diff changeset
  1107
!
8891
c30a030ff5ec more FFI (foreign function interface) support - still incomplete
Stefan Vogel <sv@exept.de>
parents: 8728
diff changeset
  1108
9321
734c7c432461 not yet finished
Claus Gittinger <cg@exept.de>
parents: 8891
diff changeset
  1109
invokeWith:arg1 with:arg2 with:arg3 with:arg4
23828
cbcc99660889 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 23785
diff changeset
  1110
    "call the function with 4 arguments"
cbcc99660889 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 23785
diff changeset
  1111
9321
734c7c432461 not yet finished
Claus Gittinger <cg@exept.de>
parents: 8891
diff changeset
  1112
    self hasCode ifFalse:[
24046
6cf8161ea948 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 23834
diff changeset
  1113
	self prepareInvoke.
9321
734c7c432461 not yet finished
Claus Gittinger <cg@exept.de>
parents: 8891
diff changeset
  1114
    ].
23829
209adc65cf44 renamed private method
Claus Gittinger <cg@exept.de>
parents: 23828
diff changeset
  1115
    ^ self invokeFFIwithArguments:(Array with:arg1 with:arg2 with:arg3 with:arg4) forInstance:nil
23828
cbcc99660889 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 23785
diff changeset
  1116
cbcc99660889 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 23785
diff changeset
  1117
    "Modified (comment): / 04-03-2019 / 09:40:56 / Claus Gittinger"
9321
734c7c432461 not yet finished
Claus Gittinger <cg@exept.de>
parents: 8891
diff changeset
  1118
!
8891
c30a030ff5ec more FFI (foreign function interface) support - still incomplete
Stefan Vogel <sv@exept.de>
parents: 8728
diff changeset
  1119
9321
734c7c432461 not yet finished
Claus Gittinger <cg@exept.de>
parents: 8891
diff changeset
  1120
invokeWithArguments:argArray
23828
cbcc99660889 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 23785
diff changeset
  1121
    "call the function with up to maxArgs (15) arguments"
cbcc99660889 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 23785
diff changeset
  1122
9321
734c7c432461 not yet finished
Claus Gittinger <cg@exept.de>
parents: 8891
diff changeset
  1123
    self hasCode ifFalse:[
24046
6cf8161ea948 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 23834
diff changeset
  1124
	self prepareInvoke.
9321
734c7c432461 not yet finished
Claus Gittinger <cg@exept.de>
parents: 8891
diff changeset
  1125
    ].
23829
209adc65cf44 renamed private method
Claus Gittinger <cg@exept.de>
parents: 23828
diff changeset
  1126
    ^ self invokeFFIwithArguments:argArray forInstance:nil
9465
d11885052713 rewrite & cleanup
Claus Gittinger <cg@exept.de>
parents: 9464
diff changeset
  1127
d11885052713 rewrite & cleanup
Claus Gittinger <cg@exept.de>
parents: 9464
diff changeset
  1128
    "Modified: / 01-08-2006 / 16:04:08 / cg"
23828
cbcc99660889 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 23785
diff changeset
  1129
    "Modified (comment): / 04-03-2019 / 09:40:48 / Claus Gittinger"
9321
734c7c432461 not yet finished
Claus Gittinger <cg@exept.de>
parents: 8891
diff changeset
  1130
! !
734c7c432461 not yet finished
Claus Gittinger <cg@exept.de>
parents: 8891
diff changeset
  1131
734c7c432461 not yet finished
Claus Gittinger <cg@exept.de>
parents: 8891
diff changeset
  1132
!ExternalLibraryFunction methodsFor:'printing'!
734c7c432461 not yet finished
Claus Gittinger <cg@exept.de>
parents: 8891
diff changeset
  1133
734c7c432461 not yet finished
Claus Gittinger <cg@exept.de>
parents: 8891
diff changeset
  1134
printOn:aStream
21487
82faecee87f2 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 21412
diff changeset
  1135
    aStream nextPut:$<.
9465
d11885052713 rewrite & cleanup
Claus Gittinger <cg@exept.de>
parents: 9464
diff changeset
  1136
    self isCallTypeAPI ifTrue:[
24046
6cf8161ea948 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 23834
diff changeset
  1137
	'API: ' printOn:aStream.
9465
d11885052713 rewrite & cleanup
Claus Gittinger <cg@exept.de>
parents: 9464
diff changeset
  1138
    ] ifFalse:[
24046
6cf8161ea948 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 23834
diff changeset
  1139
	self isCallTypeOLE ifTrue:[
6cf8161ea948 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 23834
diff changeset
  1140
	    'OLE: ' printOn:aStream.
6cf8161ea948 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 23834
diff changeset
  1141
	] ifFalse:[
6cf8161ea948 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 23834
diff changeset
  1142
	    self isCallTypeC ifTrue:[
6cf8161ea948 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 23834
diff changeset
  1143
		'C: ' printOn:aStream.
6cf8161ea948 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 23834
diff changeset
  1144
	    ] ifFalse:[
6cf8161ea948 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 23834
diff changeset
  1145
		self isObjectiveC ifTrue:[
6cf8161ea948 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 23834
diff changeset
  1146
		    'ObjC: #' printOn:aStream.
6cf8161ea948 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 23834
diff changeset
  1147
		] ifFalse:[
6cf8161ea948 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 23834
diff changeset
  1148
		    aStream nextPutAll:'Error: unknown call type '.
6cf8161ea948 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 23834
diff changeset
  1149
		].
6cf8161ea948 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 23834
diff changeset
  1150
	    ].
6cf8161ea948 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 23834
diff changeset
  1151
	].
9465
d11885052713 rewrite & cleanup
Claus Gittinger <cg@exept.de>
parents: 9464
diff changeset
  1152
    ].
9321
734c7c432461 not yet finished
Claus Gittinger <cg@exept.de>
parents: 8891
diff changeset
  1153
    name printOn:aStream.
9465
d11885052713 rewrite & cleanup
Claus Gittinger <cg@exept.de>
parents: 9464
diff changeset
  1154
    moduleName notNil ifTrue:[
24046
6cf8161ea948 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 23834
diff changeset
  1155
	aStream nextPutAll:' module:'.
6cf8161ea948 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 23834
diff changeset
  1156
	moduleName printOn:aStream.
9465
d11885052713 rewrite & cleanup
Claus Gittinger <cg@exept.de>
parents: 9464
diff changeset
  1157
    ].
21487
82faecee87f2 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 21412
diff changeset
  1158
    aStream nextPut:$>.
9465
d11885052713 rewrite & cleanup
Claus Gittinger <cg@exept.de>
parents: 9464
diff changeset
  1159
14356
d0e1264c11fe changed: #printOn:
Claus Gittinger <cg@exept.de>
parents: 14103
diff changeset
  1160
    "Modified: / 25-09-2012 / 12:06:14 / cg"
21487
82faecee87f2 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 21412
diff changeset
  1161
    "Modified: / 17-02-2017 / 09:48:25 / stefan"
23834
3edb64074d7b #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 23831
diff changeset
  1162
    "Modified: / 04-03-2019 / 11:56:18 / Claus Gittinger"
8891
c30a030ff5ec more FFI (foreign function interface) support - still incomplete
Stefan Vogel <sv@exept.de>
parents: 8728
diff changeset
  1163
! !
c30a030ff5ec more FFI (foreign function interface) support - still incomplete
Stefan Vogel <sv@exept.de>
parents: 8728
diff changeset
  1164
c30a030ff5ec more FFI (foreign function interface) support - still incomplete
Stefan Vogel <sv@exept.de>
parents: 8728
diff changeset
  1165
!ExternalLibraryFunction methodsFor:'private'!
c30a030ff5ec more FFI (foreign function interface) support - still incomplete
Stefan Vogel <sv@exept.de>
parents: 8728
diff changeset
  1166
10213
31717eee6fb2 changed #ffiTypeSymbolForType:
fm
parents: 10025
diff changeset
  1167
adjustTypes
19490
4d29d49edd98 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 19489
diff changeset
  1168
    "map all those existing type names to a small number of definite ffi type names.
4d29d49edd98 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 19489
diff changeset
  1169
     This is needed, because there are so many different C-type names found in code imported
4d29d49edd98 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 19489
diff changeset
  1170
     from various Smalltalk dialects' library function call declarations.
4d29d49edd98 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 19489
diff changeset
  1171
     For example: all of word, WORD, unsignedShort, ushort, uShort etc. will map to uint16.
4d29d49edd98 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 19489
diff changeset
  1172
     Also, this deals with pointer size differences."
4d29d49edd98 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 19489
diff changeset
  1173
19313
4e56f471a6c3 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 19311
diff changeset
  1174
    argumentTypes notEmptyOrNil ifTrue:[
19535
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1175
	argumentTypes := argumentTypes collect:[:argType | self class ffiTypeSymbolForType:argType].
10213
31717eee6fb2 changed #ffiTypeSymbolForType:
fm
parents: 10025
diff changeset
  1176
    ].
19490
4d29d49edd98 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 19489
diff changeset
  1177
    returnType := self class ffiTypeSymbolForType:returnType.
10213
31717eee6fb2 changed #ffiTypeSymbolForType:
fm
parents: 10025
diff changeset
  1178
!
31717eee6fb2 changed #ffiTypeSymbolForType:
fm
parents: 10025
diff changeset
  1179
22141
d5c9d544447f #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 22140
diff changeset
  1180
convertArgument:arg
d5c9d544447f #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 22140
diff changeset
  1181
    "a chance to convert arguments to one of the primitive (native) types."
24046
6cf8161ea948 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 23834
diff changeset
  1182
22141
d5c9d544447f #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 22140
diff changeset
  1183
    CDatum notNil ifTrue:[
24046
6cf8161ea948 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 23834
diff changeset
  1184
	arg isCDatum ifTrue:[
6cf8161ea948 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 23834
diff changeset
  1185
	    arg offset == 0 ifTrue:[
6cf8161ea948 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 23834
diff changeset
  1186
		^ (arg data)
6cf8161ea948 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 23834
diff changeset
  1187
	    ].
6cf8161ea948 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 23834
diff changeset
  1188
	    arg data isExternalBytes ifTrue:[
6cf8161ea948 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 23834
diff changeset
  1189
		^ ExternalAddress newAddress:(arg data address + arg offset).
6cf8161ea948 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 23834
diff changeset
  1190
	    ].
6cf8161ea948 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 23834
diff changeset
  1191
	].
22141
d5c9d544447f #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 22140
diff changeset
  1192
    ].
d5c9d544447f #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 22140
diff changeset
  1193
    ^ arg.
d5c9d544447f #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 22140
diff changeset
  1194
d5c9d544447f #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 22140
diff changeset
  1195
    "Created: / 01-08-2017 / 14:00:45 / cg"
d5c9d544447f #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 22140
diff changeset
  1196
!
d5c9d544447f #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 22140
diff changeset
  1197
8891
c30a030ff5ec more FFI (foreign function interface) support - still incomplete
Stefan Vogel <sv@exept.de>
parents: 8728
diff changeset
  1198
linkToModule
c30a030ff5ec more FFI (foreign function interface) support - still incomplete
Stefan Vogel <sv@exept.de>
parents: 8728
diff changeset
  1199
    "link this function to the external module.
24451
0aa7d8be211f #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 24338
diff changeset
  1200
     I.e. retrieve the module handle and the code pointer.
0aa7d8be211f #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 24338
diff changeset
  1201
     The name of the DLL is retrieved either from the primitive declaration or
25087
6be980cf75e3 gcc fixes
Claus Gittinger <cg@exept.de>
parents: 24826
diff changeset
  1202
     the owning instance or its class"
8891
c30a030ff5ec more FFI (foreign function interface) support - still incomplete
Stefan Vogel <sv@exept.de>
parents: 8728
diff changeset
  1203
9465
d11885052713 rewrite & cleanup
Claus Gittinger <cg@exept.de>
parents: 9464
diff changeset
  1204
    |handle moduleNameUsed functionName|
8891
c30a030ff5ec more FFI (foreign function interface) support - still incomplete
Stefan Vogel <sv@exept.de>
parents: 8728
diff changeset
  1205
10481
b3526180579f +isExternalLibraryFunction
fm
parents: 10440
diff changeset
  1206
    name isNumber ifTrue:[
25087
6be980cf75e3 gcc fixes
Claus Gittinger <cg@exept.de>
parents: 24826
diff changeset
  1207
	self isCPPFunction ifTrue:[
6be980cf75e3 gcc fixes
Claus Gittinger <cg@exept.de>
parents: 24826
diff changeset
  1208
	    "/ no need to load a dll.
6be980cf75e3 gcc fixes
Claus Gittinger <cg@exept.de>
parents: 24826
diff changeset
  1209
	    ^ self
6be980cf75e3 gcc fixes
Claus Gittinger <cg@exept.de>
parents: 24826
diff changeset
  1210
	]
10481
b3526180579f +isExternalLibraryFunction
fm
parents: 10440
diff changeset
  1211
    ].
23834
3edb64074d7b #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 23831
diff changeset
  1212
    self isObjectiveC ifTrue:[
25087
6be980cf75e3 gcc fixes
Claus Gittinger <cg@exept.de>
parents: 24826
diff changeset
  1213
	"/ no need for a library - we will get the receiver
6be980cf75e3 gcc fixes
Claus Gittinger <cg@exept.de>
parents: 24826
diff changeset
  1214
	^ self.
23834
3edb64074d7b #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 23831
diff changeset
  1215
    ].
24046
6cf8161ea948 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 23834
diff changeset
  1216
13782
1994fe87f21e comment/format in: #linkToModule
Claus Gittinger <cg@exept.de>
parents: 13412
diff changeset
  1217
    "/ in some other smalltalks, there is no moduleName in the ffi-spec;
1994fe87f21e comment/format in: #linkToModule
Claus Gittinger <cg@exept.de>
parents: 13412
diff changeset
  1218
    "/ instead, the class provides the libraryName...
9465
d11885052713 rewrite & cleanup
Claus Gittinger <cg@exept.de>
parents: 9464
diff changeset
  1219
    (moduleNameUsed := moduleName) isNil ifTrue:[
25087
6be980cf75e3 gcc fixes
Claus Gittinger <cg@exept.de>
parents: 24826
diff changeset
  1220
	owningClass notNil ifTrue:[
6be980cf75e3 gcc fixes
Claus Gittinger <cg@exept.de>
parents: 24826
diff changeset
  1221
	    moduleNameUsed := owningClass theNonMetaclass perform:#libraryName ifNotUnderstood:nil.
6be980cf75e3 gcc fixes
Claus Gittinger <cg@exept.de>
parents: 24826
diff changeset
  1222
	    moduleNameUsed isNil ifTrue:[
6be980cf75e3 gcc fixes
Claus Gittinger <cg@exept.de>
parents: 24826
diff changeset
  1223
		moduleNameUsed := owningClass theMetaclass perform:#libraryName ifNotUnderstood:nil.
6be980cf75e3 gcc fixes
Claus Gittinger <cg@exept.de>
parents: 24826
diff changeset
  1224
	    ].
6be980cf75e3 gcc fixes
Claus Gittinger <cg@exept.de>
parents: 24826
diff changeset
  1225
	].
6be980cf75e3 gcc fixes
Claus Gittinger <cg@exept.de>
parents: 24826
diff changeset
  1226
	moduleNameUsed isNil ifTrue:[
6be980cf75e3 gcc fixes
Claus Gittinger <cg@exept.de>
parents: 24826
diff changeset
  1227
	    self error:'Missing shared library name'.
6be980cf75e3 gcc fixes
Claus Gittinger <cg@exept.de>
parents: 24826
diff changeset
  1228
	].
6be980cf75e3 gcc fixes
Claus Gittinger <cg@exept.de>
parents: 24826
diff changeset
  1229
	moduleNameUsed := moduleNameUsed asSymbol.
9321
734c7c432461 not yet finished
Claus Gittinger <cg@exept.de>
parents: 8891
diff changeset
  1230
    ].
11586
a3b2eef8a74c int vs. sint
Claus Gittinger <cg@exept.de>
parents: 11426
diff changeset
  1231
    moduleHandle isNil ifTrue:[
25087
6be980cf75e3 gcc fixes
Claus Gittinger <cg@exept.de>
parents: 24826
diff changeset
  1232
	"/ speedup. in 95% of all calls, the same moduleName is resolved here
6be980cf75e3 gcc fixes
Claus Gittinger <cg@exept.de>
parents: 24826
diff changeset
  1233
	(LastModuleHandleHolder isNil
6be980cf75e3 gcc fixes
Claus Gittinger <cg@exept.de>
parents: 24826
diff changeset
  1234
	or:[ (handle := LastModuleHandleHolder at:1) isNil
6be980cf75e3 gcc fixes
Claus Gittinger <cg@exept.de>
parents: 24826
diff changeset
  1235
	or:[ handle == -1
6be980cf75e3 gcc fixes
Claus Gittinger <cg@exept.de>
parents: 24826
diff changeset
  1236
	or:[ LastModuleHandleName ~= moduleNameUsed ]]]) ifTrue:[
6be980cf75e3 gcc fixes
Claus Gittinger <cg@exept.de>
parents: 24826
diff changeset
  1237
6be980cf75e3 gcc fixes
Claus Gittinger <cg@exept.de>
parents: 24826
diff changeset
  1238
	    handle := self loadLibrary:moduleNameUsed.
6be980cf75e3 gcc fixes
Claus Gittinger <cg@exept.de>
parents: 24826
diff changeset
  1239
	    LastModuleHandleHolder := WeakArray with:handle.
6be980cf75e3 gcc fixes
Claus Gittinger <cg@exept.de>
parents: 24826
diff changeset
  1240
	    LastModuleHandleName := moduleNameUsed.
6be980cf75e3 gcc fixes
Claus Gittinger <cg@exept.de>
parents: 24826
diff changeset
  1241
	].
6be980cf75e3 gcc fixes
Claus Gittinger <cg@exept.de>
parents: 24826
diff changeset
  1242
	self assert:(handle isInteger not).
6be980cf75e3 gcc fixes
Claus Gittinger <cg@exept.de>
parents: 24826
diff changeset
  1243
	moduleHandle := handle.
8891
c30a030ff5ec more FFI (foreign function interface) support - still incomplete
Stefan Vogel <sv@exept.de>
parents: 8728
diff changeset
  1244
    ].
9341
719fcf48695b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9340
diff changeset
  1245
    name isNumber ifFalse:[
25087
6be980cf75e3 gcc fixes
Claus Gittinger <cg@exept.de>
parents: 24826
diff changeset
  1246
	functionName := name.
6be980cf75e3 gcc fixes
Claus Gittinger <cg@exept.de>
parents: 24826
diff changeset
  1247
	(moduleHandle getFunctionAddress:functionName into:self) isNil ifTrue:[
6be980cf75e3 gcc fixes
Claus Gittinger <cg@exept.de>
parents: 24826
diff changeset
  1248
	    (moduleHandle getFunctionAddress:('_', functionName) into:self) isNil ifTrue:[
6be980cf75e3 gcc fixes
Claus Gittinger <cg@exept.de>
parents: 24826
diff changeset
  1249
		moduleHandle := nil.
6be980cf75e3 gcc fixes
Claus Gittinger <cg@exept.de>
parents: 24826
diff changeset
  1250
		LastModuleHandleHolder := LastModuleHandleName := nil.
6be980cf75e3 gcc fixes
Claus Gittinger <cg@exept.de>
parents: 24826
diff changeset
  1251
		ObjectFileLoader::ObjectFileLoadError raiseRequestErrorString:'Missing function: "', name, '" in shared library: "', moduleNameUsed, '"'.
6be980cf75e3 gcc fixes
Claus Gittinger <cg@exept.de>
parents: 24826
diff changeset
  1252
	    ].
6be980cf75e3 gcc fixes
Claus Gittinger <cg@exept.de>
parents: 24826
diff changeset
  1253
	].
9321
734c7c432461 not yet finished
Claus Gittinger <cg@exept.de>
parents: 8891
diff changeset
  1254
    ].
9392
11914531960a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9386
diff changeset
  1255
22163
b9b7b1d22df5 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 22162
diff changeset
  1256
    "Modified: / 04-08-2017 / 20:10:41 / cg"
22904
19e24d06132f #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 22901
diff changeset
  1257
    "Modified: / 11-05-2018 / 12:18:14 / stefan"
23227
7fa1f7a52a26 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 22904
diff changeset
  1258
    "Modified: / 22-07-2018 / 15:16:19 / Stefan Vogel"
24451
0aa7d8be211f #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 24338
diff changeset
  1259
    "Modified: / 22-07-2019 / 01:24:00 / Claus Gittinger"
0aa7d8be211f #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 24338
diff changeset
  1260
    "Modified (comment): / 22-07-2019 / 07:23:36 / Claus Gittinger"
9321
734c7c432461 not yet finished
Claus Gittinger <cg@exept.de>
parents: 8891
diff changeset
  1261
!
734c7c432461 not yet finished
Claus Gittinger <cg@exept.de>
parents: 8891
diff changeset
  1262
10270
897474c6c785 allow setting the dllPath
fm
parents: 10213
diff changeset
  1263
loadLibrary:dllName
19490
4d29d49edd98 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 19489
diff changeset
  1264
    "load a dll.
21408
e641024561c6 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21402
diff changeset
  1265
     Returns a handle or nil.
19490
4d29d49edd98 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 19489
diff changeset
  1266
     Notice the dllMapping mechanism, which can be used to silently load different dlls.
4d29d49edd98 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 19489
diff changeset
  1267
     This is useful, if some code has a hardcoded dll-name in it, which needs to be changed,
4d29d49edd98 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 19489
diff changeset
  1268
     but you do not want or cannot recompile the methods (i.e. no source avail)"
4d29d49edd98 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 19489
diff changeset
  1269
23228
63b599c0c272 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 23227
diff changeset
  1270
    |handle nameString filename dllPaths hasSuffix|
10279
60c42983fdd4 first test whether the dllName is the complete filename
ca
parents: 10270
diff changeset
  1271
23227
7fa1f7a52a26 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 22904
diff changeset
  1272
    ObjectFileLoader isNil ifTrue:[
25087
6be980cf75e3 gcc fixes
Claus Gittinger <cg@exept.de>
parents: 24826
diff changeset
  1273
	"no libcomp loaded"
6be980cf75e3 gcc fixes
Claus Gittinger <cg@exept.de>
parents: 24826
diff changeset
  1274
	^ self primitiveFailed:'libcomp:ObjectFileLoader is not available'.
23227
7fa1f7a52a26 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 22904
diff changeset
  1275
    ].
7fa1f7a52a26 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 22904
diff changeset
  1276
24826
d73b54f3c744 #UI_ENHANCEMENT by exept
Claus Gittinger <cg@exept.de>
parents: 24825
diff changeset
  1277
    (ObjectFileLoader canLoadObjectFiles) ifFalse:[
25087
6be980cf75e3 gcc fixes
Claus Gittinger <cg@exept.de>
parents: 24826
diff changeset
  1278
	ObjectFileLoader::ObjectFileLoadError raiseErrorString:('ObjectFileLoader cannot load dll/module: "%1"' bindWith:dllName).
6be980cf75e3 gcc fixes
Claus Gittinger <cg@exept.de>
parents: 24826
diff changeset
  1279
	^ nil.
20561
3c0b80431555 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 20528
diff changeset
  1280
    ].
3c0b80431555 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 20528
diff changeset
  1281
14103
3df000b77712 class definition
Claus Gittinger <cg@exept.de>
parents: 14037
diff changeset
  1282
    filename := dllName.
3df000b77712 class definition
Claus Gittinger <cg@exept.de>
parents: 14037
diff changeset
  1283
    DllMapping notNil ifTrue:[
25087
6be980cf75e3 gcc fixes
Claus Gittinger <cg@exept.de>
parents: 24826
diff changeset
  1284
	filename := DllMapping at:dllName ifAbsent:[ filename ]
14103
3df000b77712 class definition
Claus Gittinger <cg@exept.de>
parents: 14037
diff changeset
  1285
    ].
3df000b77712 class definition
Claus Gittinger <cg@exept.de>
parents: 14037
diff changeset
  1286
3df000b77712 class definition
Claus Gittinger <cg@exept.de>
parents: 14037
diff changeset
  1287
    filename := filename asFilename.
10279
60c42983fdd4 first test whether the dllName is the complete filename
ca
parents: 10270
diff changeset
  1288
12937
7d5f512fb14a changed: #loadLibrary:
Stefan Vogel <sv@exept.de>
parents: 12680
diff changeset
  1289
    "try to load, maybe the system knows where to find the dll"
7d5f512fb14a changed: #loadLibrary:
Stefan Vogel <sv@exept.de>
parents: 12680
diff changeset
  1290
    handle := ObjectFileLoader loadDynamicObject:filename.
23228
63b599c0c272 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 23227
diff changeset
  1291
    handle notNil ifTrue:[
25087
6be980cf75e3 gcc fixes
Claus Gittinger <cg@exept.de>
parents: 24826
diff changeset
  1292
	^ handle
23228
63b599c0c272 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 23227
diff changeset
  1293
    ].
63b599c0c272 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 23227
diff changeset
  1294
63b599c0c272 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 23227
diff changeset
  1295
    nameString := filename name.
63b599c0c272 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 23227
diff changeset
  1296
    hasSuffix := filename suffix notEmpty.
63b599c0c272 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 23227
diff changeset
  1297
63b599c0c272 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 23227
diff changeset
  1298
    filename isAbsolute ifTrue:[
25087
6be980cf75e3 gcc fixes
Claus Gittinger <cg@exept.de>
parents: 24826
diff changeset
  1299
	hasSuffix ifFalse:[
6be980cf75e3 gcc fixes
Claus Gittinger <cg@exept.de>
parents: 24826
diff changeset
  1300
	    "/ try again with the OS-specific dll-extension
6be980cf75e3 gcc fixes
Claus Gittinger <cg@exept.de>
parents: 24826
diff changeset
  1301
	    ObjectFileLoader sharedLibrarySuffixes do:[:eachPossibleSuffix |
6be980cf75e3 gcc fixes
Claus Gittinger <cg@exept.de>
parents: 24826
diff changeset
  1302
		handle := ObjectFileLoader loadDynamicObject:(filename withSuffix:eachPossibleSuffix).
6be980cf75e3 gcc fixes
Claus Gittinger <cg@exept.de>
parents: 24826
diff changeset
  1303
		handle notNil ifTrue:[
6be980cf75e3 gcc fixes
Claus Gittinger <cg@exept.de>
parents: 24826
diff changeset
  1304
		    ^ handle
6be980cf75e3 gcc fixes
Claus Gittinger <cg@exept.de>
parents: 24826
diff changeset
  1305
		].
6be980cf75e3 gcc fixes
Claus Gittinger <cg@exept.de>
parents: 24826
diff changeset
  1306
	    ].
6be980cf75e3 gcc fixes
Claus Gittinger <cg@exept.de>
parents: 24826
diff changeset
  1307
	].
23228
63b599c0c272 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 23227
diff changeset
  1308
    ] ifFalse:[
25087
6be980cf75e3 gcc fixes
Claus Gittinger <cg@exept.de>
parents: 24826
diff changeset
  1309
	"First ask the class defining the ExternalFunction for the location of the dlls ..."
6be980cf75e3 gcc fixes
Claus Gittinger <cg@exept.de>
parents: 24826
diff changeset
  1310
	dllPaths := #().
6be980cf75e3 gcc fixes
Claus Gittinger <cg@exept.de>
parents: 24826
diff changeset
  1311
	owningClass notNil ifTrue:[
6be980cf75e3 gcc fixes
Claus Gittinger <cg@exept.de>
parents: 24826
diff changeset
  1312
	    dllPaths := owningClass dllPath.
6be980cf75e3 gcc fixes
Claus Gittinger <cg@exept.de>
parents: 24826
diff changeset
  1313
	].
6be980cf75e3 gcc fixes
Claus Gittinger <cg@exept.de>
parents: 24826
diff changeset
  1314
	".. then ask the system .. and the settings"
6be980cf75e3 gcc fixes
Claus Gittinger <cg@exept.de>
parents: 24826
diff changeset
  1315
	dllPaths := dllPaths, self class dllPath, UserPreferences current dllPath.
6be980cf75e3 gcc fixes
Claus Gittinger <cg@exept.de>
parents: 24826
diff changeset
  1316
6be980cf75e3 gcc fixes
Claus Gittinger <cg@exept.de>
parents: 24826
diff changeset
  1317
	dllPaths do:[:eachDirectory |
6be980cf75e3 gcc fixes
Claus Gittinger <cg@exept.de>
parents: 24826
diff changeset
  1318
	    |libraryName|
6be980cf75e3 gcc fixes
Claus Gittinger <cg@exept.de>
parents: 24826
diff changeset
  1319
6be980cf75e3 gcc fixes
Claus Gittinger <cg@exept.de>
parents: 24826
diff changeset
  1320
	    libraryName := eachDirectory asFilename construct:nameString.
6be980cf75e3 gcc fixes
Claus Gittinger <cg@exept.de>
parents: 24826
diff changeset
  1321
	    hasSuffix ifTrue:[
6be980cf75e3 gcc fixes
Claus Gittinger <cg@exept.de>
parents: 24826
diff changeset
  1322
		handle := ObjectFileLoader loadDynamicObject:libraryName.
6be980cf75e3 gcc fixes
Claus Gittinger <cg@exept.de>
parents: 24826
diff changeset
  1323
		handle notNil ifTrue:[
6be980cf75e3 gcc fixes
Claus Gittinger <cg@exept.de>
parents: 24826
diff changeset
  1324
		    ^ handle
6be980cf75e3 gcc fixes
Claus Gittinger <cg@exept.de>
parents: 24826
diff changeset
  1325
		].
6be980cf75e3 gcc fixes
Claus Gittinger <cg@exept.de>
parents: 24826
diff changeset
  1326
	    ] ifFalse:[
6be980cf75e3 gcc fixes
Claus Gittinger <cg@exept.de>
parents: 24826
diff changeset
  1327
		ObjectFileLoader sharedLibrarySuffixes do:[:eachPossibleSuffix |
6be980cf75e3 gcc fixes
Claus Gittinger <cg@exept.de>
parents: 24826
diff changeset
  1328
		    handle := ObjectFileLoader loadDynamicObject:(libraryName withSuffix:eachPossibleSuffix).
6be980cf75e3 gcc fixes
Claus Gittinger <cg@exept.de>
parents: 24826
diff changeset
  1329
		    handle notNil ifTrue:[
6be980cf75e3 gcc fixes
Claus Gittinger <cg@exept.de>
parents: 24826
diff changeset
  1330
			^ handle
6be980cf75e3 gcc fixes
Claus Gittinger <cg@exept.de>
parents: 24826
diff changeset
  1331
		    ].
6be980cf75e3 gcc fixes
Claus Gittinger <cg@exept.de>
parents: 24826
diff changeset
  1332
		].
6be980cf75e3 gcc fixes
Claus Gittinger <cg@exept.de>
parents: 24826
diff changeset
  1333
	    ].
6be980cf75e3 gcc fixes
Claus Gittinger <cg@exept.de>
parents: 24826
diff changeset
  1334
	].
10279
60c42983fdd4 first test whether the dllName is the complete filename
ca
parents: 10270
diff changeset
  1335
    ].
10270
897474c6c785 allow setting the dllPath
fm
parents: 10213
diff changeset
  1336
12436
92a968c9ca92 changed:
Claus Gittinger <cg@exept.de>
parents: 11586
diff changeset
  1337
21400
cbcbe62447f8 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 21055
diff changeset
  1338
    "/ check for: the dll-path in:
cbcbe62447f8 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 21055
diff changeset
  1339
    "/      - owningClass dllPath
cbcbe62447f8 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 21055
diff changeset
  1340
    "/      - self class dllPath
cbcbe62447f8 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 21055
diff changeset
  1341
    "/ check for: the dll-name mapping
cbcbe62447f8 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 21055
diff changeset
  1342
    "/      - DllMapping (the classVar, but accessed via self class dllMapping)
cbcbe62447f8 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 21055
diff changeset
  1343
    "/        this can map both basenames and whole pathnames
cbcbe62447f8 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 21055
diff changeset
  1344
    "/ eg: self class dllMapping at:'libtesseract' put:('/opt/local/lib/libtesseract.dylib').
cbcbe62447f8 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 21055
diff changeset
  1345
    "/ see also the settings dialog for external libraries.
23227
7fa1f7a52a26 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 22904
diff changeset
  1346
    ObjectFileLoader::ObjectFileLoadError
25087
6be980cf75e3 gcc fixes
Claus Gittinger <cg@exept.de>
parents: 24826
diff changeset
  1347
	raiseErrorString:('Cannot find or load dll/module: "%1" (check dllPath settings)' bindWith:nameString).
10270
897474c6c785 allow setting the dllPath
fm
parents: 10213
diff changeset
  1348
    ^ nil
14103
3df000b77712 class definition
Claus Gittinger <cg@exept.de>
parents: 14037
diff changeset
  1349
21411
f68aa46aa3d6 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21410
diff changeset
  1350
    "Modified: / 13-02-2017 / 01:14:05 / cg"
23228
63b599c0c272 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 23227
diff changeset
  1351
    "Modified: / 22-07-2018 / 16:34:24 / Stefan Vogel"
10270
897474c6c785 allow setting the dllPath
fm
parents: 10213
diff changeset
  1352
!
897474c6c785 allow setting the dllPath
fm
parents: 10213
diff changeset
  1353
9321
734c7c432461 not yet finished
Claus Gittinger <cg@exept.de>
parents: 8891
diff changeset
  1354
prepareInvoke
19490
4d29d49edd98 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 19489
diff changeset
  1355
    "called before invoked.
19535
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1356
     When called the very first time, moduleHandle is nil,
19490
4d29d49edd98 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 19489
diff changeset
  1357
     and we ensure that the dll is loaded, the function address is extracted"
4d29d49edd98 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 19489
diff changeset
  1358
10270
897474c6c785 allow setting the dllPath
fm
parents: 10213
diff changeset
  1359
    (moduleHandle isNil or:[self hasCode not]) ifTrue:[
19535
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1360
	self linkToModule.
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1361
	self adjustTypes.
8891
c30a030ff5ec more FFI (foreign function interface) support - still incomplete
Stefan Vogel <sv@exept.de>
parents: 8728
diff changeset
  1362
    ].
23828
cbcc99660889 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 23785
diff changeset
  1363
!
cbcc99660889 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 23785
diff changeset
  1364
cbcc99660889 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 23785
diff changeset
  1365
prepareObjCInvoke
cbcc99660889 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 23785
diff changeset
  1366
    "called before invoked"
cbcc99660889 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 23785
diff changeset
  1367
cbcc99660889 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 23785
diff changeset
  1368
    "Created: / 04-03-2019 / 09:20:39 / Claus Gittinger"
8891
c30a030ff5ec more FFI (foreign function interface) support - still incomplete
Stefan Vogel <sv@exept.de>
parents: 8728
diff changeset
  1369
! !
c30a030ff5ec more FFI (foreign function interface) support - still incomplete
Stefan Vogel <sv@exept.de>
parents: 8728
diff changeset
  1370
8550
72982f85bd41 *** empty log message ***
ca
parents: 8533
diff changeset
  1371
!ExternalLibraryFunction methodsFor:'private-accessing'!
72982f85bd41 *** empty log message ***
ca
parents: 8533
diff changeset
  1372
9466
73333f358696 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9465
diff changeset
  1373
name:functionNameOrVirtualIndex module:aModuleName returnType:aReturnType argumentTypes:argTypes
24046
6cf8161ea948 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 23834
diff changeset
  1374
    flags := 0.
9466
73333f358696 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9465
diff changeset
  1375
    name := functionNameOrVirtualIndex.
73333f358696 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9465
diff changeset
  1376
    functionNameOrVirtualIndex isNumber ifTrue:[
24046
6cf8161ea948 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 23834
diff changeset
  1377
	self beVirtualCPP.
9466
73333f358696 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9465
diff changeset
  1378
    ].
8891
c30a030ff5ec more FFI (foreign function interface) support - still incomplete
Stefan Vogel <sv@exept.de>
parents: 8728
diff changeset
  1379
    moduleName := aModuleName.
c30a030ff5ec more FFI (foreign function interface) support - still incomplete
Stefan Vogel <sv@exept.de>
parents: 8728
diff changeset
  1380
    returnType := aReturnType.
c30a030ff5ec more FFI (foreign function interface) support - still incomplete
Stefan Vogel <sv@exept.de>
parents: 8728
diff changeset
  1381
    argumentTypes := argTypes.
9465
d11885052713 rewrite & cleanup
Claus Gittinger <cg@exept.de>
parents: 9464
diff changeset
  1382
d11885052713 rewrite & cleanup
Claus Gittinger <cg@exept.de>
parents: 9464
diff changeset
  1383
    "Created: / 01-08-2006 / 15:19:52 / cg"
9466
73333f358696 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9465
diff changeset
  1384
    "Modified: / 02-08-2006 / 17:20:13 / cg"
9465
d11885052713 rewrite & cleanup
Claus Gittinger <cg@exept.de>
parents: 9464
diff changeset
  1385
!
d11885052713 rewrite & cleanup
Claus Gittinger <cg@exept.de>
parents: 9464
diff changeset
  1386
11426
1fccae300393 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 11053
diff changeset
  1387
owningClass
1fccae300393 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 11053
diff changeset
  1388
    ^ owningClass
1fccae300393 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 11053
diff changeset
  1389
!
1fccae300393 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 11053
diff changeset
  1390
9465
d11885052713 rewrite & cleanup
Claus Gittinger <cg@exept.de>
parents: 9464
diff changeset
  1391
owningClass:aClass
d11885052713 rewrite & cleanup
Claus Gittinger <cg@exept.de>
parents: 9464
diff changeset
  1392
    owningClass := aClass.
d11885052713 rewrite & cleanup
Claus Gittinger <cg@exept.de>
parents: 9464
diff changeset
  1393
d11885052713 rewrite & cleanup
Claus Gittinger <cg@exept.de>
parents: 9464
diff changeset
  1394
    "Created: / 01-08-2006 / 15:22:50 / cg"
10603
da9b7ed81caf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10514
diff changeset
  1395
!
da9b7ed81caf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10514
diff changeset
  1396
11586
a3b2eef8a74c int vs. sint
Claus Gittinger <cg@exept.de>
parents: 11426
diff changeset
  1397
setModuleName:aModuleName
10603
da9b7ed81caf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10514
diff changeset
  1398
    aModuleName ~= moduleName ifTrue:[
11586
a3b2eef8a74c int vs. sint
Claus Gittinger <cg@exept.de>
parents: 11426
diff changeset
  1399
	self code:nil.
a3b2eef8a74c int vs. sint
Claus Gittinger <cg@exept.de>
parents: 11426
diff changeset
  1400
	moduleHandle := nil.
a3b2eef8a74c int vs. sint
Claus Gittinger <cg@exept.de>
parents: 11426
diff changeset
  1401
	moduleName := aModuleName.
10603
da9b7ed81caf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10514
diff changeset
  1402
    ].
da9b7ed81caf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10514
diff changeset
  1403
da9b7ed81caf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10514
diff changeset
  1404
    "Created: / 07-06-2007 / 10:20:17 / cg"
8550
72982f85bd41 *** empty log message ***
ca
parents: 8533
diff changeset
  1405
! !
72982f85bd41 *** empty log message ***
ca
parents: 8533
diff changeset
  1406
9342
e548ce80ab02 virtual calls
Claus Gittinger <cg@exept.de>
parents: 9341
diff changeset
  1407
!ExternalLibraryFunction methodsFor:'private-invoking'!
e548ce80ab02 virtual calls
Claus Gittinger <cg@exept.de>
parents: 9341
diff changeset
  1408
9347
31adc57e6954 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9346
diff changeset
  1409
invokeCPPVirtualFFIOn:instance withArguments:arguments
23829
209adc65cf44 renamed private method
Claus Gittinger <cg@exept.de>
parents: 23828
diff changeset
  1410
    ^ self invokeFFIwithArguments:arguments forInstance:instance
9463
864880338d7e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9460
diff changeset
  1411
864880338d7e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9460
diff changeset
  1412
    "Modified: / 01-08-2006 / 13:55:30 / cg"
9342
e548ce80ab02 virtual calls
Claus Gittinger <cg@exept.de>
parents: 9341
diff changeset
  1413
!
e548ce80ab02 virtual calls
Claus Gittinger <cg@exept.de>
parents: 9341
diff changeset
  1414
9347
31adc57e6954 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9346
diff changeset
  1415
invokeFFIWithArguments:arguments
23829
209adc65cf44 renamed private method
Claus Gittinger <cg@exept.de>
parents: 23828
diff changeset
  1416
    ^ self invokeFFIwithArguments:arguments forInstance:nil
9463
864880338d7e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9460
diff changeset
  1417
864880338d7e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9460
diff changeset
  1418
    "Modified: / 01-08-2006 / 13:55:35 / cg"
9347
31adc57e6954 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9346
diff changeset
  1419
!
31adc57e6954 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9346
diff changeset
  1420
24046
6cf8161ea948 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 23834
diff changeset
  1421
invokeFFIwithArguments:argumentsOrNilArg forInstance:aReceiverOrNil
14659
410089913ca1 allow use of the standard (system) ffi
Claus Gittinger <cg@exept.de>
parents: 14632
diff changeset
  1422
    "basic invoke mechanism. Calls the function represented by the receiver with argumentsOrNil.
410089913ca1 allow use of the standard (system) ffi
Claus Gittinger <cg@exept.de>
parents: 14632
diff changeset
  1423
     For cplusplus, aReceiverOrNil is required to be an externalStructure like object;
410089913ca1 allow use of the standard (system) ffi
Claus Gittinger <cg@exept.de>
parents: 14632
diff changeset
  1424
     for objectiveC, it must be an ObjectiveC object"
410089913ca1 allow use of the standard (system) ffi
Claus Gittinger <cg@exept.de>
parents: 14632
diff changeset
  1425
19341
2ab29dd7ec1a mingw 64bit fixes (xxLL in constants - sigh)
Claus Gittinger <cg@exept.de>
parents: 19334
diff changeset
  1426
    |argTypeSymbols returnTypeSymbol failureCode failureArgNr failureInfo returnValue stClass vtOffset
14659
410089913ca1 allow use of the standard (system) ffi
Claus Gittinger <cg@exept.de>
parents: 14632
diff changeset
  1427
     virtual objectiveC async unlimitedStack callTypeNumber returnValueClass argValueClass
22141
d5c9d544447f #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 22140
diff changeset
  1428
     oldReturnType oldArgumentTypes mustFreeRetVal alreadyFreed argumentsOrNil|
9342
e548ce80ab02 virtual calls
Claus Gittinger <cg@exept.de>
parents: 9341
diff changeset
  1429
24046
6cf8161ea948 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 23834
diff changeset
  1430
    argumentsOrNil := argumentsOrNilArg.
10025
053904a63549 stc-compiled ExternalLibraryFunctions
Claus Gittinger <cg@exept.de>
parents: 9981
diff changeset
  1431
    argTypeSymbols := argumentTypes.
053904a63549 stc-compiled ExternalLibraryFunctions
Claus Gittinger <cg@exept.de>
parents: 9981
diff changeset
  1432
    returnTypeSymbol := returnType.
9346
a95e2cf0e56f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9344
diff changeset
  1433
10025
053904a63549 stc-compiled ExternalLibraryFunctions
Claus Gittinger <cg@exept.de>
parents: 9981
diff changeset
  1434
    virtual := self isVirtualCPP.
14659
410089913ca1 allow use of the standard (system) ffi
Claus Gittinger <cg@exept.de>
parents: 14632
diff changeset
  1435
    objectiveC := self isObjectiveC.
9524
2af286bbcac3 *** empty log message ***
ca
parents: 9519
diff changeset
  1436
    (virtual "or:[self isNonVirtualCPP]") ifTrue:[
24051
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  1437
	aReceiverOrNil isNil ifTrue:[
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  1438
	    "/ must have a c++ object instance
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  1439
	    self primitiveFailed.
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  1440
	].
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  1441
24076
95f599b6fe97 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 24075
diff changeset
  1442
	"/ and it must be a kind of ExternalStructure
24051
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  1443
	(aReceiverOrNil isKindOf:ExternalStructure) ifFalse:[
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  1444
	    self primitiveFailed.
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  1445
	].
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  1446
	virtual ifTrue:[
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  1447
	    vtOffset := name.
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  1448
	    (vtOffset between:0 and:10000) ifFalse:[
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  1449
		self primitiveFailed.
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  1450
	    ]
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  1451
	].
9463
864880338d7e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9460
diff changeset
  1452
    ] ifFalse:[
24051
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  1453
	objectiveC ifTrue:[
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  1454
	    aReceiverOrNil isNil ifTrue:[
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  1455
		"/ must have an objective-c object instance
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  1456
		self primitiveFailed.
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  1457
	    ].
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  1458
	    (aReceiverOrNil isObjectiveCObject) ifFalse:[
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  1459
		self primitiveFailed
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  1460
	    ]
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  1461
	] ifFalse:[
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  1462
	    aReceiverOrNil notNil ifTrue:[
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  1463
		"/ must NOT have a c++/objectiveC object instance
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  1464
		self primitiveFailed.
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  1465
	    ]
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  1466
	].
9342
e548ce80ab02 virtual calls
Claus Gittinger <cg@exept.de>
parents: 9341
diff changeset
  1467
    ].
9463
864880338d7e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9460
diff changeset
  1468
    async := self isAsync.
864880338d7e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9460
diff changeset
  1469
    unlimitedStack := self isUnlimitedStack.
9465
d11885052713 rewrite & cleanup
Claus Gittinger <cg@exept.de>
parents: 9464
diff changeset
  1470
    callTypeNumber := self callTypeNumber.
21412
67b11b143a30 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21411
diff changeset
  1471
    mustFreeRetVal := self mustFreeReturnValue.
67b11b143a30 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21411
diff changeset
  1472
    alreadyFreed := false.
21748
0172bd7d20b4 #DOCUMENTATION by mawalch
mawalch
parents: 21487
diff changeset
  1473
23785
617f45e9fffa #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 23228
diff changeset
  1474
    argumentsOrNil size ~~ 0 ifTrue:[
24051
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  1475
	argumentsOrNil := argumentsOrNil collect:[:arg | self convertArgument:arg]
22141
d5c9d544447f #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 22140
diff changeset
  1476
    ].
24046
6cf8161ea948 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 23834
diff changeset
  1477
10512
5a01829213ab *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10484
diff changeset
  1478
    "/ Transcript show:name; show:' async:'; showCR:async.
9342
e548ce80ab02 virtual calls
Claus Gittinger <cg@exept.de>
parents: 9341
diff changeset
  1479
9459
6cd520c582b3 change from unlimited to big stack, to allow for interrupts to be handled
ca
parents: 9436
diff changeset
  1480
%{  /* STACK: 100000 */
14659
410089913ca1 allow use of the standard (system) ffi
Claus Gittinger <cg@exept.de>
parents: 14632
diff changeset
  1481
19931
0ea2a7e6bb41 calls without FFI
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
  1482
#define VERBOSE
0ea2a7e6bb41 calls without FFI
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
  1483
24064
9f4295bdff8e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 24055
diff changeset
  1484
#define MAX_NUM_STRUCT_ARGS    1
9f4295bdff8e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 24055
diff changeset
  1485
#define MAX_NUM_STRUCT_FIELDS  4
9f4295bdff8e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 24055
diff changeset
  1486
10025
053904a63549 stc-compiled ExternalLibraryFunctions
Claus Gittinger <cg@exept.de>
parents: 9981
diff changeset
  1487
#ifdef HAVE_FFI
19931
0ea2a7e6bb41 calls without FFI
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
  1488
12504
c9987bb76eb6 untested long long return value
Claus Gittinger <cg@exept.de>
parents: 12503
diff changeset
  1489
# ifdef __GNUC__
14659
410089913ca1 allow use of the standard (system) ffi
Claus Gittinger <cg@exept.de>
parents: 14632
diff changeset
  1490
#  ifndef HAS_LONGLONG
410089913ca1 allow use of the standard (system) ffi
Claus Gittinger <cg@exept.de>
parents: 14632
diff changeset
  1491
#   define HAS_LONGLONG
410089913ca1 allow use of the standard (system) ffi
Claus Gittinger <cg@exept.de>
parents: 14632
diff changeset
  1492
#  endif
12504
c9987bb76eb6 untested long long return value
Claus Gittinger <cg@exept.de>
parents: 12503
diff changeset
  1493
# endif
c9987bb76eb6 untested long long return value
Claus Gittinger <cg@exept.de>
parents: 12503
diff changeset
  1494
# if defined(__BORLANDC__) || defined(__VISUALC__)
c9987bb76eb6 untested long long return value
Claus Gittinger <cg@exept.de>
parents: 12503
diff changeset
  1495
#  define HAS_INT64
19364
4bf0b2b33b65 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 19357
diff changeset
  1496
#  ifndef __LO32
4bf0b2b33b65 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 19357
diff changeset
  1497
#   define __LO32(ll) ((ll) & 0xFFFFFFFFL)
4bf0b2b33b65 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 19357
diff changeset
  1498
#   define __HI32(ll) (((ll)>>32) & 0xFFFFFFFFL)
4bf0b2b33b65 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 19357
diff changeset
  1499
#  endif
12504
c9987bb76eb6 untested long long return value
Claus Gittinger <cg@exept.de>
parents: 12503
diff changeset
  1500
# endif
19931
0ea2a7e6bb41 calls without FFI
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
  1501
9342
e548ce80ab02 virtual calls
Claus Gittinger <cg@exept.de>
parents: 9341
diff changeset
  1502
    ffi_cif __cif;
e548ce80ab02 virtual calls
Claus Gittinger <cg@exept.de>
parents: 9341
diff changeset
  1503
    ffi_type *__argTypesIncludingThis[MAX_ARGS+1];
e548ce80ab02 virtual calls
Claus Gittinger <cg@exept.de>
parents: 9341
diff changeset
  1504
    ffi_type **__argTypes = __argTypesIncludingThis;
e548ce80ab02 virtual calls
Claus Gittinger <cg@exept.de>
parents: 9341
diff changeset
  1505
    ffi_type *__returnType = NULL;
19931
0ea2a7e6bb41 calls without FFI
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
  1506
    ffi_type *thisType;
24050
f39b5494bc52 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 24048
diff changeset
  1507
    ffi_type structTypes[MAX_NUM_STRUCT_ARGS];
f39b5494bc52 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 24048
diff changeset
  1508
    ffi_type *structTypeFields[MAX_NUM_STRUCT_ARGS][MAX_NUM_STRUCT_FIELDS+1];
19931
0ea2a7e6bb41 calls without FFI
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
  1509
    ffi_abi __callType = FFI_DEFAULT_ABI;
0ea2a7e6bb41 calls without FFI
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
  1510
0ea2a7e6bb41 calls without FFI
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
  1511
#else
0ea2a7e6bb41 calls without FFI
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
  1512
0ea2a7e6bb41 calls without FFI
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
  1513
    int __argTypesIncludingThis[MAX_ARGS+1];
0ea2a7e6bb41 calls without FFI
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
  1514
    int *__argTypes = __argTypesIncludingThis;
0ea2a7e6bb41 calls without FFI
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
  1515
    int __returnType = 0;
0ea2a7e6bb41 calls without FFI
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
  1516
    int thisType;
0ea2a7e6bb41 calls without FFI
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
  1517
    int __callType = FFI_DEFAULT_ABI;
24064
9f4295bdff8e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 24055
diff changeset
  1518
    int structTypes[MAX_NUM_STRUCT_ARGS];
9f4295bdff8e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 24055
diff changeset
  1519
    int *structTypeFields[MAX_NUM_STRUCT_ARGS][MAX_NUM_STRUCT_FIELDS+1];
20290
952d5b62a161 implemented a non-FFI-based callout scheme which works with OSX
Claus Gittinger <cg@exept.de>
parents: 20289
diff changeset
  1520
19951
2ba5ef097a79 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 19950
diff changeset
  1521
#endif
20290
952d5b62a161 implemented a non-FFI-based callout scheme which works with OSX
Claus Gittinger <cg@exept.de>
parents: 20289
diff changeset
  1522
952d5b62a161 implemented a non-FFI-based callout scheme which works with OSX
Claus Gittinger <cg@exept.de>
parents: 20289
diff changeset
  1523
    int __numFloatOrDoubleArgs = 0;
24050
f39b5494bc52 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 24048
diff changeset
  1524
    int numStructArgs = 0;
12504
c9987bb76eb6 untested long long return value
Claus Gittinger <cg@exept.de>
parents: 12503
diff changeset
  1525
9342
e548ce80ab02 virtual calls
Claus Gittinger <cg@exept.de>
parents: 9341
diff changeset
  1526
    union u {
24051
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  1527
	INT iVal;
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  1528
	float fVal;
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  1529
	double dVal;
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  1530
	void *pointerVal;
19365
83a120bf2212 Fix syntax error bug with gcc32
Stefan Vogel <sv@exept.de>
parents: 19364
diff changeset
  1531
# if 0 && defined(HAS_LONGLONG)
24051
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  1532
	long long longLongVal;
12504
c9987bb76eb6 untested long long return value
Claus Gittinger <cg@exept.de>
parents: 12503
diff changeset
  1533
# else
24051
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  1534
	__int64__ longLongVal;
12504
c9987bb76eb6 untested long long return value
Claus Gittinger <cg@exept.de>
parents: 12503
diff changeset
  1535
# endif
9342
e548ce80ab02 virtual calls
Claus Gittinger <cg@exept.de>
parents: 9341
diff changeset
  1536
    };
e548ce80ab02 virtual calls
Claus Gittinger <cg@exept.de>
parents: 9341
diff changeset
  1537
    union u __argValuesIncludingThis[MAX_ARGS+1];
e548ce80ab02 virtual calls
Claus Gittinger <cg@exept.de>
parents: 9341
diff changeset
  1538
    union u *__argValues = __argValuesIncludingThis;
e548ce80ab02 virtual calls
Claus Gittinger <cg@exept.de>
parents: 9341
diff changeset
  1539
    union u __returnValue;
e548ce80ab02 virtual calls
Claus Gittinger <cg@exept.de>
parents: 9341
diff changeset
  1540
    void *__argValuePointersIncludingThis[MAX_ARGS+1];
e548ce80ab02 virtual calls
Claus Gittinger <cg@exept.de>
parents: 9341
diff changeset
  1541
    void **__argValuePointers = __argValuePointersIncludingThis;
e548ce80ab02 virtual calls
Claus Gittinger <cg@exept.de>
parents: 9341
diff changeset
  1542
    void *__returnValuePointer;
e548ce80ab02 virtual calls
Claus Gittinger <cg@exept.de>
parents: 9341
diff changeset
  1543
    int __numArgs, __numArgsIncludingThis;
19311
6f1d1ea6dba8 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 18240
diff changeset
  1544
    static INT null = 0;
19341
2ab29dd7ec1a mingw 64bit fixes (xxLL in constants - sigh)
Claus Gittinger <cg@exept.de>
parents: 19334
diff changeset
  1545
    int i = -1;
20307
678da26adf03 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 20299
diff changeset
  1546
    voidFUNC codeAddress = (voidFUNC)__INST(code_);
10440
b643af58f8bf invoking without arguments
fm
parents: 10279
diff changeset
  1547
    int __numArgsWanted;
12579
516bba5b3e57 changed: #ffiTypeSymbolForType:
Claus Gittinger <cg@exept.de>
parents: 12504
diff changeset
  1548
12504
c9987bb76eb6 untested long long return value
Claus Gittinger <cg@exept.de>
parents: 12503
diff changeset
  1549
#   define __FAIL__(fcode) \
10603
da9b7ed81caf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10514
diff changeset
  1550
    { \
24051
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  1551
	failureCode = fcode; failureArgNr = __mkSmallInteger(i+1); goto getOutOfHere; \
10603
da9b7ed81caf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10514
diff changeset
  1552
    }
9342
e548ce80ab02 virtual calls
Claus Gittinger <cg@exept.de>
parents: 9341
diff changeset
  1553
10440
b643af58f8bf invoking without arguments
fm
parents: 10279
diff changeset
  1554
    if (argumentsOrNil == nil) {
24051
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  1555
	__numArgs = 0;
21402
13718cea3cea #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 21401
diff changeset
  1556
    } else if (__isArrayLike(argumentsOrNil)) {
24051
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  1557
	__numArgs = __arraySize(argumentsOrNil);
9342
e548ce80ab02 virtual calls
Claus Gittinger <cg@exept.de>
parents: 9341
diff changeset
  1558
    } else {
24051
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  1559
	__FAIL__(@symbol(BadArgumentVector))
10440
b643af58f8bf invoking without arguments
fm
parents: 10279
diff changeset
  1560
    }
b643af58f8bf invoking without arguments
fm
parents: 10279
diff changeset
  1561
    if (argTypeSymbols == nil) {
24051
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  1562
	__numArgsWanted = 0;
21402
13718cea3cea #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 21401
diff changeset
  1563
    } else if (__isArrayLike(argTypeSymbols)) {
24051
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  1564
	__numArgsWanted = __arraySize(argTypeSymbols);
10440
b643af58f8bf invoking without arguments
fm
parents: 10279
diff changeset
  1565
    } else {
24051
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  1566
	__FAIL__(@symbol(BadArgumentTypeVector))
10440
b643af58f8bf invoking without arguments
fm
parents: 10279
diff changeset
  1567
    }
b643af58f8bf invoking without arguments
fm
parents: 10279
diff changeset
  1568
b643af58f8bf invoking without arguments
fm
parents: 10279
diff changeset
  1569
    if (__numArgs != __numArgsWanted) {
24051
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  1570
	__FAIL__(@symbol(ArgumentCountMismatch))
9342
e548ce80ab02 virtual calls
Claus Gittinger <cg@exept.de>
parents: 9341
diff changeset
  1571
    }
e548ce80ab02 virtual calls
Claus Gittinger <cg@exept.de>
parents: 9341
diff changeset
  1572
    if (__numArgs > MAX_ARGS) {
24051
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  1573
	__FAIL__(@symbol(TooManyArguments))
9342
e548ce80ab02 virtual calls
Claus Gittinger <cg@exept.de>
parents: 9341
diff changeset
  1574
    }
e548ce80ab02 virtual calls
Claus Gittinger <cg@exept.de>
parents: 9341
diff changeset
  1575
e548ce80ab02 virtual calls
Claus Gittinger <cg@exept.de>
parents: 9341
diff changeset
  1576
    /*
19501
4922889c4309 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 19494
diff changeset
  1577
     * validate the return type and map it to an ffi_type
9342
e548ce80ab02 virtual calls
Claus Gittinger <cg@exept.de>
parents: 9341
diff changeset
  1578
     */
e548ce80ab02 virtual calls
Claus Gittinger <cg@exept.de>
parents: 9341
diff changeset
  1579
    __returnValuePointer = &__returnValue;
9479
68d12a181d4a handle types; sint32 types.
ca
parents: 9466
diff changeset
  1580
9483
3bea515ce81e *** empty log message ***
fm
parents: 9479
diff changeset
  1581
    if (returnTypeSymbol == @symbol(voidPointer)) {
24051
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  1582
	returnTypeSymbol = @symbol(handle);
19501
4922889c4309 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 19494
diff changeset
  1583
    } else if (returnTypeSymbol == @symbol(hresult)) {
24098
25db884de25a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 24097
diff changeset
  1584
	returnTypeSymbol = @symbol(long);
9483
3bea515ce81e *** empty log message ***
fm
parents: 9479
diff changeset
  1585
    }
9479
68d12a181d4a handle types; sint32 types.
ca
parents: 9466
diff changeset
  1586
9342
e548ce80ab02 virtual calls
Claus Gittinger <cg@exept.de>
parents: 9341
diff changeset
  1587
    if (returnTypeSymbol == @symbol(int)) {
24051
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  1588
	__returnType = TYPE_SINT;
9342
e548ce80ab02 virtual calls
Claus Gittinger <cg@exept.de>
parents: 9341
diff changeset
  1589
    } else if (returnTypeSymbol == @symbol(uint)) {
24051
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  1590
	__returnType = TYPE_UINT;
9479
68d12a181d4a handle types; sint32 types.
ca
parents: 9466
diff changeset
  1591
    } else if (returnTypeSymbol == @symbol(uint8)) {
24051
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  1592
	__returnType = TYPE_UINT8;
9479
68d12a181d4a handle types; sint32 types.
ca
parents: 9466
diff changeset
  1593
    } else if (returnTypeSymbol == @symbol(uint16)) {
24051
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  1594
	__returnType = TYPE_UINT16;
9479
68d12a181d4a handle types; sint32 types.
ca
parents: 9466
diff changeset
  1595
    } else if (returnTypeSymbol == @symbol(uint32)) {
24051
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  1596
	__returnType = TYPE_UINT32;
9479
68d12a181d4a handle types; sint32 types.
ca
parents: 9466
diff changeset
  1597
    } else if (returnTypeSymbol == @symbol(uint64)) {
24051
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  1598
	__returnType = TYPE_UINT64;
9479
68d12a181d4a handle types; sint32 types.
ca
parents: 9466
diff changeset
  1599
68d12a181d4a handle types; sint32 types.
ca
parents: 9466
diff changeset
  1600
    } else if (returnTypeSymbol == @symbol(sint)) {
24051
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  1601
	__returnType = TYPE_SINT;
9479
68d12a181d4a handle types; sint32 types.
ca
parents: 9466
diff changeset
  1602
    } else if (returnTypeSymbol == @symbol(sint8)) {
24051
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  1603
	__returnType = TYPE_SINT8;
9479
68d12a181d4a handle types; sint32 types.
ca
parents: 9466
diff changeset
  1604
    } else if (returnTypeSymbol == @symbol(sint16)) {
24051
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  1605
	__returnType = TYPE_SINT16;
9479
68d12a181d4a handle types; sint32 types.
ca
parents: 9466
diff changeset
  1606
    } else if (returnTypeSymbol == @symbol(sint32)) {
24051
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  1607
	__returnType = TYPE_SINT32;
9479
68d12a181d4a handle types; sint32 types.
ca
parents: 9466
diff changeset
  1608
    } else if (returnTypeSymbol == @symbol(sint64)) {
24051
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  1609
	__returnType = TYPE_SINT64;
9479
68d12a181d4a handle types; sint32 types.
ca
parents: 9466
diff changeset
  1610
9342
e548ce80ab02 virtual calls
Claus Gittinger <cg@exept.de>
parents: 9341
diff changeset
  1611
    } else if (returnTypeSymbol == @symbol(long)) {
24051
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  1612
	if (sizeof(long) == 4) {
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  1613
	   returnTypeSymbol = @symbol(sint32);
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  1614
	   __returnType = TYPE_SINT32;
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  1615
	} else if (sizeof(long) == 8) {
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  1616
	   returnTypeSymbol = @symbol(sint64);
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  1617
	   __returnType = TYPE_SINT64;
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  1618
	} else {
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  1619
	    __FAIL__(@symbol(UnknownReturnType))
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  1620
	}
9479
68d12a181d4a handle types; sint32 types.
ca
parents: 9466
diff changeset
  1621
9342
e548ce80ab02 virtual calls
Claus Gittinger <cg@exept.de>
parents: 9341
diff changeset
  1622
    } else if (returnTypeSymbol == @symbol(ulong)) {
24051
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  1623
	if (sizeof(long) == 4) {
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  1624
	   returnTypeSymbol = @symbol(uint32);
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  1625
	   __returnType = TYPE_UINT32;
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  1626
	}else if (sizeof(long) == 8) {
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  1627
	   returnTypeSymbol = @symbol(uint64);
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  1628
	   __returnType = TYPE_UINT64;
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  1629
	} else {
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  1630
	    __FAIL__(@symbol(UnknownReturnType))
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  1631
	}
9479
68d12a181d4a handle types; sint32 types.
ca
parents: 9466
diff changeset
  1632
10025
053904a63549 stc-compiled ExternalLibraryFunctions
Claus Gittinger <cg@exept.de>
parents: 9981
diff changeset
  1633
    } else if (returnTypeSymbol == @symbol(bool)) {
24051
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  1634
	__returnType = TYPE_UINT;
24052
d9fb5cb43b52 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 24051
diff changeset
  1635
    } else if (returnTypeSymbol == @symbol(char)) {
d9fb5cb43b52 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 24051
diff changeset
  1636
	__returnType = TYPE_UINT8;
9479
68d12a181d4a handle types; sint32 types.
ca
parents: 9466
diff changeset
  1637
9342
e548ce80ab02 virtual calls
Claus Gittinger <cg@exept.de>
parents: 9341
diff changeset
  1638
    } else if (returnTypeSymbol == @symbol(float)) {
24051
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  1639
	__returnType = TYPE_FLOAT;
9342
e548ce80ab02 virtual calls
Claus Gittinger <cg@exept.de>
parents: 9341
diff changeset
  1640
    } else if (returnTypeSymbol == @symbol(double)) {
24051
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  1641
	__returnType = TYPE_DOUBLE;
9479
68d12a181d4a handle types; sint32 types.
ca
parents: 9466
diff changeset
  1642
9342
e548ce80ab02 virtual calls
Claus Gittinger <cg@exept.de>
parents: 9341
diff changeset
  1643
    } else if (returnTypeSymbol == @symbol(void)) {
24051
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  1644
	__returnType = TYPE_VOID;
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  1645
	__returnValuePointer = NULL;
11586
a3b2eef8a74c int vs. sint
Claus Gittinger <cg@exept.de>
parents: 11426
diff changeset
  1646
    } else if ((returnTypeSymbol == @symbol(pointer))
24051
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  1647
	       || (returnTypeSymbol == @symbol(handle))
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  1648
	       || (returnTypeSymbol == @symbol(charPointer))
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  1649
	       || (returnTypeSymbol == @symbol(bytePointer))
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  1650
	       || (returnTypeSymbol == @symbol(floatPointer))
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  1651
	       || (returnTypeSymbol == @symbol(doublePointer))
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  1652
	       || (returnTypeSymbol == @symbol(intPointer))
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  1653
	       || (returnTypeSymbol == @symbol(shortPointer))
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  1654
	       || (returnTypeSymbol == @symbol(wcharPointer))) {
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  1655
	__returnType = TYPE_POINTER;
9342
e548ce80ab02 virtual calls
Claus Gittinger <cg@exept.de>
parents: 9341
diff changeset
  1656
    } else {
24051
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  1657
	if (__isSymbol(returnTypeSymbol)
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  1658
	 && ((returnValueClass = __GLOBAL_GET(returnTypeSymbol)) != nil)) {
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  1659
	    if (! __isBehaviorLike(returnValueClass)) {
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  1660
		__FAIL__(@symbol(NonBehaviorReturnType))
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  1661
	    }
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  1662
	    if (! __qIsSubclassOfExternalAddress(returnValueClass)) {
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  1663
		__FAIL__(@symbol(NonExternalAddressReturnType))
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  1664
	    }
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  1665
	    __returnType = TYPE_POINTER;
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  1666
	    returnTypeSymbol = @symbol(pointer);
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  1667
	} else {
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  1668
	    __FAIL__(@symbol(UnknownReturnType))
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  1669
	}
9342
e548ce80ab02 virtual calls
Claus Gittinger <cg@exept.de>
parents: 9341
diff changeset
  1670
    }
e548ce80ab02 virtual calls
Claus Gittinger <cg@exept.de>
parents: 9341
diff changeset
  1671
e548ce80ab02 virtual calls
Claus Gittinger <cg@exept.de>
parents: 9341
diff changeset
  1672
    /*
e548ce80ab02 virtual calls
Claus Gittinger <cg@exept.de>
parents: 9341
diff changeset
  1673
     * validate the c++ object
e548ce80ab02 virtual calls
Claus Gittinger <cg@exept.de>
parents: 9341
diff changeset
  1674
     */
14659
410089913ca1 allow use of the standard (system) ffi
Claus Gittinger <cg@exept.de>
parents: 14632
diff changeset
  1675
    if (aReceiverOrNil != nil) {
24051
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  1676
	struct cPlusPlusInstance {
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  1677
	    void **vTable;
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  1678
	};
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  1679
	struct cPlusPlusInstance *inst;
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  1680
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  1681
	if (__isExternalAddressLike(aReceiverOrNil)) {
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  1682
	    inst = (void *)(__externalAddressVal(aReceiverOrNil));
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  1683
	} else if (__isExternalBytesLike(aReceiverOrNil)) {
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  1684
	    inst = (void *)(__externalBytesVal(aReceiverOrNil));
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  1685
	} else {
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  1686
	    __FAIL__(@symbol(InvalidInstance))
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  1687
	}
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  1688
	if (inst == NULL) {
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  1689
	    __FAIL__(@symbol(BadReceiver))
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  1690
	}
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  1691
	__argValues[0].pointerVal = inst;
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  1692
	__argValuePointersIncludingThis[0] = &(__argValues[0]);
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  1693
	__argTypes[0] = TYPE_POINTER;
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  1694
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  1695
	__argValuePointers = &__argValuePointersIncludingThis[1];
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  1696
	__argTypes = &__argTypesIncludingThis[1];
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  1697
	__argValues = &__argValuesIncludingThis[1];
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  1698
	__numArgsIncludingThis = __numArgs + 1;
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  1699
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  1700
	if (virtual == true) {
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  1701
	    if (! __isSmallInteger(vtOffset)) {
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  1702
		__FAIL__(@symbol(InvalidVTableIndex))
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  1703
	    }
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  1704
	    codeAddress = inst->vTable[__intVal(vtOffset)];
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  1705
	    DEBUGCODE_IF( @global(Verbose), {
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  1706
		printf("virtual %"_ld_" codeAddress: %p\n", (INT)(__intVal(vtOffset)), codeAddress);
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  1707
	    })
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  1708
	}
9342
e548ce80ab02 virtual calls
Claus Gittinger <cg@exept.de>
parents: 9341
diff changeset
  1709
    } else {
24051
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  1710
	__numArgsIncludingThis = __numArgs;
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  1711
	DEBUGCODE_IF( @global(Verbose), {
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  1712
	    printf("codeAddress: %p\n", codeAddress);
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  1713
	})
24046
6cf8161ea948 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 23834
diff changeset
  1714
    }
6cf8161ea948 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 23834
diff changeset
  1715
6cf8161ea948 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 23834
diff changeset
  1716
    if (codeAddress == NULL) {
24051
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  1717
	__FAIL__(@symbol(BadCodeAddress))
9342
e548ce80ab02 virtual calls
Claus Gittinger <cg@exept.de>
parents: 9341
diff changeset
  1718
    }
e548ce80ab02 virtual calls
Claus Gittinger <cg@exept.de>
parents: 9341
diff changeset
  1719
e548ce80ab02 virtual calls
Claus Gittinger <cg@exept.de>
parents: 9341
diff changeset
  1720
    /*
19501
4922889c4309 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 19494
diff changeset
  1721
     * validate all arg types, map each to an ffi_type, and setup arg-buffers
9342
e548ce80ab02 virtual calls
Claus Gittinger <cg@exept.de>
parents: 9341
diff changeset
  1722
     */
e548ce80ab02 virtual calls
Claus Gittinger <cg@exept.de>
parents: 9341
diff changeset
  1723
    for (i=0; i<__numArgs; i++) {
24051
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  1724
	void *argValuePtr;
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  1725
	OBJ typeSymbol;
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  1726
	OBJ arg;
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  1727
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  1728
	failureInfo = __mkSmallInteger(i+1);   /* in case there is one */
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  1729
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  1730
	typeSymbol = __ArrayInstPtr(argTypeSymbols)->a_element[i];
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  1731
	arg = __ArrayInstPtr(argumentsOrNil)->a_element[i];
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  1732
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  1733
	DEBUGCODE_IF( @global(Verbose), {
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  1734
	    printf("arg%d type:\n", i+1); __dumpObject__(typeSymbol, __LINE__, __FILE__);
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  1735
	    printf("arg%d Value:\n", i+1); __dumpObject__(arg, __LINE__, __FILE__);
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  1736
	})
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  1737
24098
25db884de25a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 24097
diff changeset
  1738
	// some remapping...
24051
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  1739
	if (typeSymbol == @symbol(handle)) {
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  1740
	    typeSymbol = @symbol(pointer);
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  1741
	} else if (typeSymbol == @symbol(voidPointer)) {
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  1742
	    typeSymbol = @symbol(pointer);
24098
25db884de25a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 24097
diff changeset
  1743
	} else if (typeSymbol == @symbol(hresult)) {
25db884de25a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 24097
diff changeset
  1744
	    typeSymbol = @symbol(long);
24051
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  1745
	}
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  1746
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  1747
	if (typeSymbol == @symbol(long)) {
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  1748
	    if (sizeof(long) == sizeof(int)) {
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  1749
		typeSymbol = @symbol(sint);
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  1750
	    } else {
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  1751
		if (sizeof(long) == 4) {
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  1752
		    typeSymbol = @symbol(sint32);
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  1753
		} else if (sizeof(long) == 8) {
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  1754
		    typeSymbol = @symbol(sint64);
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  1755
		}
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  1756
	    }
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  1757
	}
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  1758
	if (typeSymbol == @symbol(ulong)) {
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  1759
	    if (sizeof(unsigned long) == sizeof(unsigned int)) {
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  1760
		typeSymbol = @symbol(uint);
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  1761
	    } else {
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  1762
		if (sizeof(long) == 4) {
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  1763
		    typeSymbol = @symbol(uint32);
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  1764
		} else if (sizeof(long) == 8) {
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  1765
		    typeSymbol = @symbol(uint64);
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  1766
		}
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  1767
	    }
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  1768
	}
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  1769
24098
25db884de25a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 24097
diff changeset
  1770
	// check and possibly convert arguments
24051
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  1771
	if (typeSymbol == @symbol(int) || typeSymbol == @symbol(sint)) {
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  1772
	    thisType = TYPE_SINT;
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  1773
	    if (__isSmallInteger(arg)) {
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  1774
		__argValues[i].iVal = __intVal(arg);
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  1775
	    } else {
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  1776
		__argValues[i].iVal = __signedLongIntVal(arg);
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  1777
		if (__argValues[i].iVal == 0) {
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  1778
		    DEBUGCODE_IF( @global(Verbose), {
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  1779
			printf("invalidArgument: arg%d sint value out of range [%d]\n", i+1, __LINE__);
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  1780
		    })
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  1781
		    __FAIL__(@symbol(InvalidArgument))
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  1782
		}
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  1783
	    }
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  1784
	    argValuePtr = &(__argValues[i].iVal);
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  1785
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  1786
	} else if (typeSymbol == @symbol(uint)) {
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  1787
	    thisType = TYPE_UINT;
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  1788
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  1789
	    if (__isSmallInteger(arg)) {
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  1790
		__argValues[i].iVal = __intVal(arg);
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  1791
	    } else {
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  1792
		__argValues[i].iVal = __unsignedLongIntVal(arg);
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  1793
		if (__argValues[i].iVal == 0) {
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  1794
		    DEBUGCODE_IF( @global(Verbose), {
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  1795
			printf("invalidArgument: arg%d uint value out of range [%d]\n", i+1, __LINE__);
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  1796
		    })
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  1797
		    __FAIL__(@symbol(InvalidArgument))
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  1798
		}
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  1799
	    }
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  1800
	    argValuePtr = &(__argValues[i].iVal);
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  1801
24078
13363abcd11f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 24077
diff changeset
  1802
	} else if ((typeSymbol == @symbol(uint8)) || (typeSymbol == @symbol(char))) {
24051
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  1803
	    thisType = TYPE_UINT8;
24077
1163f3c0012e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 24076
diff changeset
  1804
	    if (arg == __STX_true) {
1163f3c0012e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 24076
diff changeset
  1805
		__argValues[i].iVal = 1;
1163f3c0012e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 24076
diff changeset
  1806
	    } else if (arg == __STX_false) {
1163f3c0012e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 24076
diff changeset
  1807
		__argValues[i].iVal = 0;
24078
13363abcd11f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 24077
diff changeset
  1808
	    } else if (__isCharacter(arg)) {
13363abcd11f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 24077
diff changeset
  1809
		__argValues[i].iVal = __intVal(__characterVal(arg));
24077
1163f3c0012e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 24076
diff changeset
  1810
	    } else {
1163f3c0012e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 24076
diff changeset
  1811
		if (! __isSmallInteger(arg)) {
1163f3c0012e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 24076
diff changeset
  1812
		    DEBUGCODE_IF( @global(Verbose), {
1163f3c0012e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 24076
diff changeset
  1813
			printf("invalidArgument: arg%d uint8 value out of range [%d]\n", i+1, __LINE__);
1163f3c0012e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 24076
diff changeset
  1814
		    })
1163f3c0012e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 24076
diff changeset
  1815
		    __FAIL__(@symbol(InvalidArgument))
1163f3c0012e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 24076
diff changeset
  1816
		}
1163f3c0012e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 24076
diff changeset
  1817
		__argValues[i].iVal = __intVal(arg);
1163f3c0012e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 24076
diff changeset
  1818
		if (((unsigned)(__argValues[i].iVal)) > 0xFF) {
1163f3c0012e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 24076
diff changeset
  1819
		    DEBUGCODE_IF( @global(Verbose), {
1163f3c0012e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 24076
diff changeset
  1820
			printf("invalidArgument: arg%d uint8 value out of range [%d]\n", i+1, __LINE__);
1163f3c0012e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 24076
diff changeset
  1821
		    })
1163f3c0012e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 24076
diff changeset
  1822
		    __FAIL__(@symbol(InvalidArgument))
1163f3c0012e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 24076
diff changeset
  1823
		}
24051
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  1824
	    }
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  1825
	    argValuePtr = &(__argValues[i].iVal);
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  1826
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  1827
	} else if (typeSymbol == @symbol(sint8)) {
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  1828
	    thisType = TYPE_SINT8;
24077
1163f3c0012e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 24076
diff changeset
  1829
	    if (arg == __STX_true) {
1163f3c0012e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 24076
diff changeset
  1830
		__argValues[i].iVal = 1;
1163f3c0012e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 24076
diff changeset
  1831
	    } else if (arg == __STX_false) {
1163f3c0012e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 24076
diff changeset
  1832
		__argValues[i].iVal = 0;
1163f3c0012e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 24076
diff changeset
  1833
	    } else {
1163f3c0012e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 24076
diff changeset
  1834
		if (! __isSmallInteger(arg)) {
1163f3c0012e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 24076
diff changeset
  1835
		    DEBUGCODE_IF( @global(Verbose), {
1163f3c0012e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 24076
diff changeset
  1836
			printf("invalidArgument: arg%d sint8 value out of range [%d]\n", i+1, __LINE__);
1163f3c0012e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 24076
diff changeset
  1837
		    })
1163f3c0012e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 24076
diff changeset
  1838
		    __FAIL__(@symbol(InvalidArgument))
1163f3c0012e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 24076
diff changeset
  1839
		}
1163f3c0012e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 24076
diff changeset
  1840
		__argValues[i].iVal = __intVal(arg);
1163f3c0012e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 24076
diff changeset
  1841
		if (((__argValues[i].iVal) < -0x80) || ((__argValues[i].iVal) > 0x7F))  {
1163f3c0012e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 24076
diff changeset
  1842
		    DEBUGCODE_IF( @global(Verbose), {
1163f3c0012e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 24076
diff changeset
  1843
			printf("invalidArgument: arg%d sint8 value out of range [%d]\n", i+1, __LINE__);
1163f3c0012e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 24076
diff changeset
  1844
		    })
1163f3c0012e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 24076
diff changeset
  1845
		    __FAIL__(@symbol(InvalidArgument))
1163f3c0012e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 24076
diff changeset
  1846
		}
24051
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  1847
	    }
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  1848
	    argValuePtr = &(__argValues[i].iVal);
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  1849
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  1850
	} else if (typeSymbol == @symbol(uint16)) {
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  1851
	    thisType = TYPE_UINT16;
24078
13363abcd11f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 24077
diff changeset
  1852
	    if (__isCharacter(arg)) {
13363abcd11f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 24077
diff changeset
  1853
		__argValues[i].iVal = __intVal(__characterVal(arg));
13363abcd11f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 24077
diff changeset
  1854
	    } else {
13363abcd11f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 24077
diff changeset
  1855
		if (! __isSmallInteger(arg)) {
13363abcd11f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 24077
diff changeset
  1856
		    DEBUGCODE_IF( @global(Verbose), {
13363abcd11f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 24077
diff changeset
  1857
			printf("invalidArgument: arg%d uint16 value out of range [%d]\n", i+1, __LINE__);
13363abcd11f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 24077
diff changeset
  1858
		    })
13363abcd11f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 24077
diff changeset
  1859
		    __FAIL__(@symbol(InvalidArgument))
13363abcd11f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 24077
diff changeset
  1860
		}
13363abcd11f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 24077
diff changeset
  1861
		__argValues[i].iVal = __intVal(arg);
13363abcd11f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 24077
diff changeset
  1862
		if (((unsigned)(__argValues[i].iVal)) > 0xFFFF) {
13363abcd11f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 24077
diff changeset
  1863
		    DEBUGCODE_IF( @global(Verbose), {
13363abcd11f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 24077
diff changeset
  1864
			printf("invalidArgument: arg%d uint16 value out of range [%d]\n", i+1, __LINE__);
13363abcd11f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 24077
diff changeset
  1865
		    })
13363abcd11f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 24077
diff changeset
  1866
		    __FAIL__(@symbol(InvalidArgument))
13363abcd11f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 24077
diff changeset
  1867
		}
24051
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  1868
	    }
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  1869
	    argValuePtr = &(__argValues[i].iVal);
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  1870
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  1871
	} else if (typeSymbol == @symbol(sint16)) {
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  1872
	    thisType = TYPE_SINT16;
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  1873
	    if (! __isSmallInteger(arg)) {
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  1874
		DEBUGCODE_IF( @global(Verbose), {
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  1875
		    printf("invalidArgument: arg%d sint16 value out of range [%d]\n", i+1, __LINE__);
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  1876
		})
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  1877
		__FAIL__(@symbol(InvalidArgument))
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  1878
	    }
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  1879
	    __argValues[i].iVal = __intVal(arg);
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  1880
	    if (((__argValues[i].iVal) < -0x8000) || ((__argValues[i].iVal) > 0x7FFF))  {
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  1881
		DEBUGCODE_IF( @global(Verbose), {
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  1882
		    printf("invalidArgument: arg%d sint16 value out of range [%d]\n", i+1, __LINE__);
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  1883
		})
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  1884
		__FAIL__(@symbol(InvalidArgument))
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  1885
	    }
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  1886
	    argValuePtr = &(__argValues[i].iVal);
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  1887
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  1888
	} else if (typeSymbol == @symbol(uint32)) {
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  1889
	    thisType = TYPE_UINT32;
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  1890
	    if (__isSmallInteger(arg)) {
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  1891
		__argValues[i].iVal = __intVal(arg);
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  1892
	    } else {
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  1893
		__argValues[i].iVal = __unsignedLongIntVal(arg);
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  1894
		if (__argValues[i].iVal == 0) {
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  1895
		    DEBUGCODE_IF( @global(Verbose), {
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  1896
			printf("invalidArgument: arg%d uint32 value out of range [%d]\n", i+1, __LINE__);
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  1897
		    })
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  1898
		    __FAIL__(@symbol(InvalidArgument))
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  1899
		}
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  1900
	    }
19334
0488e4bae939 mingw 64bit fixes
Claus Gittinger <cg@exept.de>
parents: 19314
diff changeset
  1901
# if __POINTER_SIZE__ == 8
24051
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  1902
	    if ((__argValues[i].iVal) < 0)  {
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  1903
		DEBUGCODE_IF( @global(Verbose), {
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  1904
		    printf("invalidArgument: arg%d uint32 value out of range [%d]\n", i+1, __LINE__);
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  1905
		})
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  1906
		__FAIL__(@symbol(InvalidArgument))
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  1907
	    }
19334
0488e4bae939 mingw 64bit fixes
Claus Gittinger <cg@exept.de>
parents: 19314
diff changeset
  1908
# endif
24051
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  1909
	    argValuePtr = &(__argValues[i].iVal);
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  1910
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  1911
	 } else if (typeSymbol == @symbol(sint32)) {
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  1912
	    thisType = TYPE_SINT32;
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  1913
	    if (__isSmallInteger(arg)) {
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  1914
		__argValues[i].iVal = __intVal(arg);
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  1915
	    } else {
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  1916
		__argValues[i].iVal = __signedLongIntVal(arg);
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  1917
		if (__argValues[i].iVal == 0) {
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  1918
		    DEBUGCODE_IF( @global(Verbose), {
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  1919
			printf("invalidArgument: arg%d sint32 value out of range [%d]\n", i+1, __LINE__);
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  1920
		    })
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  1921
		    __FAIL__(@symbol(InvalidArgument))
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  1922
		}
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  1923
	    }
19334
0488e4bae939 mingw 64bit fixes
Claus Gittinger <cg@exept.de>
parents: 19314
diff changeset
  1924
# if __POINTER_SIZE__ == 8
24051
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  1925
	    if (((__argValues[i].iVal) < -0x80000000LL) || ((__argValues[i].iVal) > 0x7FFFFFFFLL))  {
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  1926
		DEBUGCODE_IF( @global(Verbose), {
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  1927
		    printf("invalidArgument: arg%d sint32 value (%"_lx_") out of range [%d]\n", i+1, __argValues[i].iVal, __LINE__);
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  1928
		})
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  1929
		__FAIL__(@symbol(InvalidArgument))
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  1930
	    }
19334
0488e4bae939 mingw 64bit fixes
Claus Gittinger <cg@exept.de>
parents: 19314
diff changeset
  1931
# endif
24051
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  1932
	    argValuePtr = &(__argValues[i].iVal);
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  1933
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  1934
	} else if (typeSymbol == @symbol(uint64)) {
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  1935
	    thisType = TYPE_UINT64;
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  1936
	    if (__isSmallInteger(arg)) {
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  1937
		__argValues[i].iVal = __intVal(arg);
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  1938
	    } else {
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  1939
		__argValues[i].iVal = __unsignedLongIntVal(arg);
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  1940
		if (__argValues[i].iVal == 0) {
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  1941
		    DEBUGCODE_IF( @global(Verbose), {
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  1942
			printf("invalidArgument: arg%d uint64 value out of range [%d]\n", i+1, __LINE__);
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  1943
		    })
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  1944
		    __FAIL__(@symbol(InvalidArgument))
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  1945
		}
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  1946
	    }
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  1947
	    argValuePtr = &(__argValues[i].iVal);
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  1948
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  1949
	 } else if (typeSymbol == @symbol(sint64)) {
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  1950
	    thisType = TYPE_SINT64;
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  1951
	    if (__isSmallInteger(arg)) {
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  1952
		__argValues[i].iVal = __intVal(arg);
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  1953
	    } else {
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  1954
		__argValues[i].iVal = __signedLongIntVal(arg);
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  1955
		if (__argValues[i].iVal == 0) {
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  1956
		    DEBUGCODE_IF( @global(Verbose), {
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  1957
			printf("invalidArgument: arg%d sint64 value out of range [%d]\n", i+1, __LINE__);
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  1958
		    })
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  1959
		    __FAIL__(@symbol(InvalidArgument))
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  1960
		}
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  1961
	    }
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  1962
	    argValuePtr = &(__argValues[i].iVal);
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  1963
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  1964
	} else if (typeSymbol == @symbol(float)) {
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  1965
	    thisType = TYPE_FLOAT;
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  1966
	    if (__isSmallInteger(arg)) {
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  1967
		__argValues[i].fVal = (float)(__intVal(arg));
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  1968
	    } else if (__isFloat(arg)) {
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  1969
		__argValues[i].fVal = (float)(__floatVal(arg));
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  1970
	    } else if (__isShortFloat(arg)) {
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  1971
		__argValues[i].fVal = (float)(__shortFloatVal(arg));
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  1972
	    } else {
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  1973
		DEBUGCODE_IF( @global(Verbose), {
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  1974
		    printf("invalidArgument: arg%d non float value [%d]\n", i+1, __LINE__);
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  1975
		})
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  1976
		__FAIL__(@symbol(InvalidArgument))
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  1977
	    }
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  1978
	    argValuePtr = &(__argValues[i].fVal);
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  1979
	} else if (typeSymbol == @symbol(double)) {
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  1980
	    thisType = TYPE_DOUBLE;
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  1981
	    if (__isSmallInteger(arg)) {
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  1982
		__argValues[i].dVal = (double)(__intVal(arg));
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  1983
	    } else if (__isFloat(arg)) {
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  1984
		__argValues[i].dVal = (double)(__floatVal(arg));
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  1985
	    } else if (__isShortFloat(arg)) {
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  1986
		__argValues[i].dVal = (double)(__shortFloatVal(arg));
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  1987
	    } else {
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  1988
		DEBUGCODE_IF( @global(Verbose), {
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  1989
		    printf("invalidArgument: arg%d non double value [%d]\n", i+1, __LINE__);
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  1990
		})
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  1991
		__FAIL__(@symbol(InvalidArgument))
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  1992
	    }
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  1993
	    argValuePtr = &(__argValues[i].dVal);
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  1994
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  1995
	} else if (typeSymbol == @symbol(void)) {
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  1996
	    thisType = TYPE_VOID;
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  1997
	    argValuePtr = &null;
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  1998
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  1999
	} else if (typeSymbol == @symbol(charPointer)) {
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2000
	    thisType = TYPE_POINTER;
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2001
	    if (__isStringLike(arg)) {
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2002
		if (async == true) goto badArgForAsyncCall;
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2003
		__argValues[i].pointerVal = (void *)(__stringVal(arg));
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2004
	    } else if (__isBytes(arg)) {
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2005
		if (async == true) goto badArgForAsyncCall;
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2006
		__argValues[i].pointerVal = (void *)(__byteArrayVal(arg));
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2007
	    } else if (__isExternalAddressLike(arg)) {
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2008
		__argValues[i].pointerVal = (void *)(__externalAddressVal(arg));
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2009
	    } else if (__isExternalBytesLike(arg)) {
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2010
		__argValues[i].pointerVal = (void *)(__externalBytesVal(arg));
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2011
	    } else {
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2012
		if (arg == nil) {
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2013
		    __argValues[i].pointerVal = (void *)0;
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2014
		} else {
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2015
		    DEBUGCODE_IF( @global(Verbose), {
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2016
			printf("invalidArgument: arg%d non charPointer value [%d]\n", i+1, __LINE__);
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2017
		    })
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2018
		    __FAIL__(@symbol(InvalidArgument))
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2019
		}
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2020
	    }
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2021
	    argValuePtr = &(__argValues[i].pointerVal);;
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2022
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2023
	} else if (typeSymbol == @symbol(wcharPointer)) {
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2024
	    thisType = TYPE_POINTER;
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2025
	    if (__isUnicode16String(arg)) {
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2026
		if (async == true) goto badArgForAsyncCall;
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2027
		__argValues[i].pointerVal = (void *)(__unicode16StringVal(arg));
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2028
	    } else if (__isBytes(arg)) {
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2029
		if (async == true) goto badArgForAsyncCall;
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2030
		__argValues[i].pointerVal = (void *)(__byteArrayVal(arg));
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2031
	    } else if (__isExternalAddressLike(arg)) {
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2032
		__argValues[i].pointerVal = (void *)(__externalAddressVal(arg));
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2033
	    } else if (__isExternalBytesLike(arg)) {
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2034
		__argValues[i].pointerVal = (void *)(__externalBytesVal(arg));
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2035
	    } else {
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2036
		if (arg == nil) {
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2037
		    __argValues[i].pointerVal = (void *)0;
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2038
		} else {
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2039
		    DEBUGCODE_IF( @global(Verbose), {
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2040
			printf("invalidArgument: arg%d non wcharPointer value [%d]\n", i+1, __LINE__);
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2041
		    })
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2042
		    __FAIL__(@symbol(InvalidArgument))
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2043
		}
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2044
	    }
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2045
	    argValuePtr = &(__argValues[i].pointerVal);;
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2046
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2047
	} else if (typeSymbol == @symbol(floatPointer)) {
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2048
	    thisType = TYPE_POINTER;
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2049
	    if (__isBytes(arg)) {
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2050
		if (async == true) goto badArgForAsyncCall;
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2051
		__argValues[i].pointerVal = (void *)(__byteArrayVal(arg));
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2052
	    } else if (__isExternalAddressLike(arg)) {
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2053
		__argValues[i].pointerVal = (void *)(__externalAddressVal(arg));
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2054
	    } else if (__isExternalBytesLike(arg)) {
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2055
		__argValues[i].pointerVal = (void *)(__externalBytesVal(arg));
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2056
	    } else if (__isFloats(arg)) {
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2057
		char *p = (char *)(__FloatArrayInstPtr(arg)->f_element);
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2058
		int nInstBytes;
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2059
		OBJ cls;
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2060
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2061
		if (async == true) goto badArgForAsyncCall;
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2062
		cls = __qClass(arg);
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2063
		nInstBytes = __OBJS2BYTES__(__intVal(__ClassInstPtr(cls)->c_ninstvars));
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2064
		p = p + nInstBytes;
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2065
		__argValues[i].pointerVal = p;
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2066
	    } else {
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2067
		if (arg == nil) {
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2068
		    __argValues[i].pointerVal = (void *)0;
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2069
		} else {
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2070
		    DEBUGCODE_IF( @global(Verbose), {
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2071
			printf("invalidArgument: arg%d non floatPointer value [%d]\n", i+1, __LINE__);
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2072
		    })
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2073
		    __FAIL__(@symbol(InvalidArgument))
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2074
		}
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2075
	    }
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2076
	    argValuePtr = &(__argValues[i].pointerVal);;
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2077
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2078
	} else if (typeSymbol == @symbol(doublePointer)) {
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2079
	    thisType = TYPE_POINTER;
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2080
	    if (__isBytes(arg)) {
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2081
		if (async == true) goto badArgForAsyncCall;
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2082
		__argValues[i].pointerVal = (void *)(__byteArrayVal(arg));
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2083
	    } else if (__isExternalAddressLike(arg)) {
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2084
		__argValues[i].pointerVal = (void *)(__externalAddressVal(arg));
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2085
	    } else if (__isExternalBytesLike(arg)) {
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2086
		__argValues[i].pointerVal = (void *)(__externalBytesVal(arg));
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2087
	    } else if (__isDoubles(arg)) {
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2088
		char *p = (char *)(__DoubleArrayInstPtr(arg)->d_element);
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2089
		int nInstBytes;
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2090
		OBJ cls;
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2091
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2092
		if (async == true) goto badArgForAsyncCall;
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2093
		cls = __qClass(arg);
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2094
		nInstBytes = __OBJS2BYTES__(__intVal(__ClassInstPtr(cls)->c_ninstvars));
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2095
		p = p + nInstBytes;
12504
c9987bb76eb6 untested long long return value
Claus Gittinger <cg@exept.de>
parents: 12503
diff changeset
  2096
# ifdef __NEED_DOUBLE_ALIGN
24051
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2097
		if ((INT)(__DoubleArrayInstPtr(arg)->d_element) & (__DOUBLE_ALIGN-1)) {
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2098
		    int delta = __DOUBLE_ALIGN - ((INT)p & (__DOUBLE_ALIGN-1));
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2099
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2100
		    p += delta;
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2101
		}
12504
c9987bb76eb6 untested long long return value
Claus Gittinger <cg@exept.de>
parents: 12503
diff changeset
  2102
# endif
24051
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2103
		__argValues[i].pointerVal = p;
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2104
	    } else {
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2105
		if (arg == nil) {
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2106
		    __argValues[i].pointerVal = (void *)0;
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2107
		} else {
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2108
		    DEBUGCODE_IF( @global(Verbose), {
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2109
			printf("invalidArgument: arg%d non doublePointer value [%d]\n", i+1, __LINE__);
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2110
		    })
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2111
		    __FAIL__(@symbol(InvalidArgument))
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2112
		}
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2113
	    }
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2114
	    argValuePtr = &(__argValues[i].pointerVal);;
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2115
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2116
	} else if (typeSymbol == @symbol(pointer)) {
20290
952d5b62a161 implemented a non-FFI-based callout scheme which works with OSX
Claus Gittinger <cg@exept.de>
parents: 20289
diff changeset
  2117
    commonPointerTypeArg: ;
24051
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2118
	    thisType = TYPE_POINTER;
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2119
	    if (arg == nil) {
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2120
		__argValues[i].pointerVal = NULL;
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2121
	    } else if (__isExternalAddressLike(arg)) {
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2122
		__argValues[i].pointerVal = (void *)(__externalAddressVal(arg));
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2123
	    } else if (__isExternalBytesLike(arg)) {
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2124
		__argValues[i].pointerVal = (void *)(__externalBytesVal(arg));
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2125
	    } else if (__isByteArrayLike(arg)) {
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2126
		if (async == true) goto badArgForAsyncCall;
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2127
		__argValues[i].pointerVal = (void *)(__byteArrayVal(arg));
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2128
	    } else if (__isWordArray(arg) || __isSignedWordArray(arg)
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2129
		    || __isIntegerArray(arg) || __isSignedIntegerArray(arg)) {
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2130
		if (async == true) goto badArgForAsyncCall;
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2131
		__argValues[i].pointerVal = (void *)(__integerArrayVal(arg));
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2132
	    } else if (__isFloatArray(arg)) {
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2133
		if (async == true) goto badArgForAsyncCall;
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2134
		__argValues[i].pointerVal = (void *)(__FloatArrayInstPtr(arg)->f_element);
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2135
	    } else if (__isDoubleArray(arg)) {
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2136
		if (async == true) goto badArgForAsyncCall;
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2137
		__argValues[i].pointerVal = (void *)(__DoubleArrayInstPtr(arg)->d_element);
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2138
	    } else if (__isStringLike(arg)) {
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2139
		if (async == true) {
9435
68f7e39efad7 support of asynchronous calls
ca
parents: 9418
diff changeset
  2140
badArgForAsyncCall: ;
24050
f39b5494bc52 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 24048
diff changeset
  2141
		    DEBUGCODE_IF( @global(Verbose), {
f39b5494bc52 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 24048
diff changeset
  2142
			printf("invalidArgument: arg%d not allowed for async call [%d]\n", i+1, __LINE__);
f39b5494bc52 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 24048
diff changeset
  2143
		    })
f39b5494bc52 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 24048
diff changeset
  2144
		    __FAIL__(@symbol(BadArgForAsyncCall))
f39b5494bc52 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 24048
diff changeset
  2145
		}
f39b5494bc52 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 24048
diff changeset
  2146
		__argValues[i].pointerVal = (void *)(__stringVal(arg));
f39b5494bc52 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 24048
diff changeset
  2147
	    } else if (__isBytes(arg) || __isWords(arg) || __isLongs(arg)) {
f39b5494bc52 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 24048
diff changeset
  2148
		char *p = (char *)(__byteArrayVal(arg));
f39b5494bc52 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 24048
diff changeset
  2149
		int nInstBytes;
f39b5494bc52 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 24048
diff changeset
  2150
		OBJ cls;
f39b5494bc52 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 24048
diff changeset
  2151
f39b5494bc52 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 24048
diff changeset
  2152
		if (async == true) goto badArgForAsyncCall;
f39b5494bc52 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 24048
diff changeset
  2153
		cls = __qClass(arg);
f39b5494bc52 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 24048
diff changeset
  2154
		nInstBytes = __OBJS2BYTES__(__intVal(__ClassInstPtr(cls)->c_ninstvars));
f39b5494bc52 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 24048
diff changeset
  2155
		__argValues[i].pointerVal = p + nInstBytes;
f39b5494bc52 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 24048
diff changeset
  2156
	    } else {
f39b5494bc52 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 24048
diff changeset
  2157
		DEBUGCODE_IF( @global(Verbose), {
f39b5494bc52 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 24048
diff changeset
  2158
		    printf("invalidArgument: arg%d non pointer value [%d]\n", i+1, __LINE__);
f39b5494bc52 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 24048
diff changeset
  2159
		})
f39b5494bc52 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 24048
diff changeset
  2160
		__FAIL__(@symbol(InvalidArgument))
f39b5494bc52 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 24048
diff changeset
  2161
	    }
f39b5494bc52 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 24048
diff changeset
  2162
	    argValuePtr = &(__argValues[i].pointerVal);;
f39b5494bc52 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 24048
diff changeset
  2163
f39b5494bc52 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 24048
diff changeset
  2164
	} else if (typeSymbol == @symbol(bool)) {
f39b5494bc52 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 24048
diff changeset
  2165
	    thisType = TYPE_UINT;
f39b5494bc52 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 24048
diff changeset
  2166
f39b5494bc52 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 24048
diff changeset
  2167
	    if (arg == true) {
f39b5494bc52 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 24048
diff changeset
  2168
		__argValues[i].iVal = 1;
f39b5494bc52 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 24048
diff changeset
  2169
	    } else if (arg == false) {
f39b5494bc52 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 24048
diff changeset
  2170
		__argValues[i].iVal = 0;
f39b5494bc52 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 24048
diff changeset
  2171
	    } else if (__isSmallInteger(arg)) {
f39b5494bc52 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 24048
diff changeset
  2172
		__argValues[i].iVal = __intVal(arg);
f39b5494bc52 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 24048
diff changeset
  2173
	    } else {
f39b5494bc52 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 24048
diff changeset
  2174
		__argValues[i].iVal = __unsignedLongIntVal(arg);
f39b5494bc52 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 24048
diff changeset
  2175
		if (__argValues[i].iVal == 0) {
f39b5494bc52 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 24048
diff changeset
  2176
		    DEBUGCODE_IF( @global(Verbose), {
f39b5494bc52 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 24048
diff changeset
  2177
			printf("invalidArgument: arg%d non bool value [%d]\n", i+1, __LINE__);
f39b5494bc52 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 24048
diff changeset
  2178
		    })
f39b5494bc52 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 24048
diff changeset
  2179
		    __FAIL__(@symbol(InvalidArgument))
f39b5494bc52 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 24048
diff changeset
  2180
		}
f39b5494bc52 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 24048
diff changeset
  2181
	    }
f39b5494bc52 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 24048
diff changeset
  2182
	    argValuePtr = &(__argValues[i].iVal);
f39b5494bc52 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 24048
diff changeset
  2183
	} else {
f39b5494bc52 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 24048
diff changeset
  2184
	    if (__isSymbol(typeSymbol)
f39b5494bc52 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 24048
diff changeset
  2185
	     && ((argValueClass = __GLOBAL_GET(typeSymbol)) != nil)) {
f39b5494bc52 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 24048
diff changeset
  2186
		if (! __isBehaviorLike(argValueClass)) {
f39b5494bc52 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 24048
diff changeset
  2187
		    __FAIL__(@symbol(NonBehaviorArgumentType))
f39b5494bc52 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 24048
diff changeset
  2188
		}
f39b5494bc52 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 24048
diff changeset
  2189
		if (! __qIsSubclassOfExternalAddress(argValueClass)) {
f39b5494bc52 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 24048
diff changeset
  2190
		    __FAIL__(@symbol(NonExternalAddressArgumentType))
f39b5494bc52 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 24048
diff changeset
  2191
		}
f39b5494bc52 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 24048
diff changeset
  2192
		goto commonPointerTypeArg; /* sorry */
f39b5494bc52 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 24048
diff changeset
  2193
	    } else {
24065
3e8a516887d8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 24064
diff changeset
  2194
#ifdef HAVE_FFI
24050
f39b5494bc52 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 24048
diff changeset
  2195
		if (__isArray(typeSymbol)) {
f39b5494bc52 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 24048
diff changeset
  2196
		    // struct
f39b5494bc52 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 24048
diff changeset
  2197
		    int numFields = __arraySize(typeSymbol);
24051
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2198
		    int fi;
24050
f39b5494bc52 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 24048
diff changeset
  2199
		    ffi_type **fieldTypes;
f39b5494bc52 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 24048
diff changeset
  2200
24051
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2201
		    DEBUGCODE_IF( @global(Verbose), {
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2202
			printf("struct arg%d\n", i+1);
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2203
		    })
24050
f39b5494bc52 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 24048
diff changeset
  2204
		    if (numStructArgs >= MAX_NUM_STRUCT_ARGS) {
f39b5494bc52 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 24048
diff changeset
  2205
			__FAIL__(@symbol(TooManyStructArguments))
f39b5494bc52 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 24048
diff changeset
  2206
		    }
f39b5494bc52 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 24048
diff changeset
  2207
		    if (numFields > MAX_NUM_STRUCT_FIELDS) {
f39b5494bc52 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 24048
diff changeset
  2208
			__FAIL__(@symbol(TooManyStructFields))
f39b5494bc52 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 24048
diff changeset
  2209
		    }
f39b5494bc52 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 24048
diff changeset
  2210
		    fieldTypes = &(structTypeFields[numStructArgs][0]);
24051
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2211
		    thisType = &(structTypes[numStructArgs]);
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2212
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2213
		    thisType->size = 0;
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2214
		    thisType->alignment = 0;
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2215
		    thisType->elements = fieldTypes;
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2216
		    thisType->type = TYPE_STRUCT;
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2217
		    for (fi=0; fi<numFields; fi++) {
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2218
			OBJ fieldTypeSymbol = __arrayVal(typeSymbol)[fi];
24050
f39b5494bc52 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 24048
diff changeset
  2219
f39b5494bc52 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 24048
diff changeset
  2220
			if (fieldTypeSymbol == @symbol(float)) {
24051
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2221
			    fieldTypes[fi] = TYPE_FLOAT;
24050
f39b5494bc52 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 24048
diff changeset
  2222
			} else if (fieldTypeSymbol == @symbol(double)) {
24051
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2223
			    fieldTypes[fi] = TYPE_DOUBLE;
24050
f39b5494bc52 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 24048
diff changeset
  2224
			} else if (fieldTypeSymbol == @symbol(int)) {
24051
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2225
			    fieldTypes[fi] = TYPE_SINT;
24050
f39b5494bc52 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 24048
diff changeset
  2226
			} else {
24074
69ee642ca7dd *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 24065
diff changeset
  2227
			    if (__isArray(fieldTypeSymbol)) {
69ee642ca7dd *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 24065
diff changeset
  2228
				int numFields2 = __arraySize(fieldTypeSymbol);
69ee642ca7dd *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 24065
diff changeset
  2229
				int fi2;
69ee642ca7dd *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 24065
diff changeset
  2230
69ee642ca7dd *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 24065
diff changeset
  2231
				for (fi2=0; fi2<numFields2; fi2++) {
69ee642ca7dd *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 24065
diff changeset
  2232
				    OBJ fieldTypeSymbol2 = __arrayVal(fieldTypeSymbol)[fi2];
69ee642ca7dd *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 24065
diff changeset
  2233
69ee642ca7dd *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 24065
diff changeset
  2234
				    if (fieldTypeSymbol2 == @symbol(float)) {
69ee642ca7dd *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 24065
diff changeset
  2235
					fieldTypes[fi++] = TYPE_FLOAT;
69ee642ca7dd *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 24065
diff changeset
  2236
				    } else if (fieldTypeSymbol2 == @symbol(double)) {
69ee642ca7dd *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 24065
diff changeset
  2237
					fieldTypes[fi++] = TYPE_DOUBLE;
69ee642ca7dd *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 24065
diff changeset
  2238
				    } else if (fieldTypeSymbol == @symbol(int)) {
69ee642ca7dd *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 24065
diff changeset
  2239
					fieldTypes[fi++] = TYPE_SINT;
69ee642ca7dd *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 24065
diff changeset
  2240
				    } else {
69ee642ca7dd *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 24065
diff changeset
  2241
					__FAIL__(@symbol(UnsupportedFieldType2))
69ee642ca7dd *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 24065
diff changeset
  2242
				    }
69ee642ca7dd *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 24065
diff changeset
  2243
				}
69ee642ca7dd *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 24065
diff changeset
  2244
				fi--;
69ee642ca7dd *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 24065
diff changeset
  2245
			    } else {
69ee642ca7dd *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 24065
diff changeset
  2246
				__FAIL__(@symbol(UnsupportedFieldType))
69ee642ca7dd *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 24065
diff changeset
  2247
			    }
24050
f39b5494bc52 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 24048
diff changeset
  2248
			}
f39b5494bc52 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 24048
diff changeset
  2249
		    }
24051
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2250
		    fieldTypes[fi] = NULL;
24050
f39b5494bc52 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 24048
diff changeset
  2251
		    numStructArgs++;
f39b5494bc52 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 24048
diff changeset
  2252
		    // arg must be either a byteArray or externalBytes pointing to the struct
f39b5494bc52 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 24048
diff changeset
  2253
		    // i.e. a CDatum's underlying storage
f39b5494bc52 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 24048
diff changeset
  2254
		    if (__isByteArray(arg)) {
f39b5494bc52 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 24048
diff changeset
  2255
			if (async == true) goto badArgForAsyncCall;
f39b5494bc52 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 24048
diff changeset
  2256
			argValuePtr = (void *)(__byteArrayVal(arg));
f39b5494bc52 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 24048
diff changeset
  2257
		    } else if (__isExternalAddressLike(arg)) {
f39b5494bc52 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 24048
diff changeset
  2258
			argValuePtr = (void *)(__externalAddressVal(arg));
f39b5494bc52 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 24048
diff changeset
  2259
		    } else if (__isExternalBytesLike(arg)) {
f39b5494bc52 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 24048
diff changeset
  2260
			argValuePtr = (void *)(__externalBytesVal(arg));
f39b5494bc52 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 24048
diff changeset
  2261
		    } else {
f39b5494bc52 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 24048
diff changeset
  2262
			__FAIL__(@symbol(InvalidArgument))
f39b5494bc52 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 24048
diff changeset
  2263
		    }
24065
3e8a516887d8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 24064
diff changeset
  2264
		} else
3e8a516887d8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 24064
diff changeset
  2265
#endif
3e8a516887d8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 24064
diff changeset
  2266
		{
3e8a516887d8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 24064
diff changeset
  2267
		    __FAIL__(@symbol(InvalidArgument))
24050
f39b5494bc52 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 24048
diff changeset
  2268
		}
f39b5494bc52 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 24048
diff changeset
  2269
	    }
f39b5494bc52 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 24048
diff changeset
  2270
	}
f39b5494bc52 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 24048
diff changeset
  2271
f39b5494bc52 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 24048
diff changeset
  2272
	__argTypes[i] = thisType;
f39b5494bc52 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 24048
diff changeset
  2273
	__argValuePointers[i] = argValuePtr;
f39b5494bc52 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 24048
diff changeset
  2274
f39b5494bc52 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 24048
diff changeset
  2275
	if ((thisType == TYPE_FLOAT) || (thisType == TYPE_DOUBLE)) {
f39b5494bc52 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 24048
diff changeset
  2276
	    __numFloatOrDoubleArgs++;
f39b5494bc52 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 24048
diff changeset
  2277
	}
f39b5494bc52 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 24048
diff changeset
  2278
	DEBUGCODE_IF( @global(Verbose), {
f39b5494bc52 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 24048
diff changeset
  2279
	    char *typeString = "TYPE_OTHER";
f39b5494bc52 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 24048
diff changeset
  2280
f39b5494bc52 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 24048
diff changeset
  2281
	    if (thisType == TYPE_POINTER) {
f39b5494bc52 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 24048
diff changeset
  2282
		typeString = "TYPE_POINTER";
f39b5494bc52 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 24048
diff changeset
  2283
	    } else if (thisType == TYPE_VOID) {
f39b5494bc52 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 24048
diff changeset
  2284
		typeString = "TYPE_VOID";
f39b5494bc52 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 24048
diff changeset
  2285
	    } else if (thisType == TYPE_FLOAT) {
f39b5494bc52 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 24048
diff changeset
  2286
		typeString = "TYPE_FLOAT";
f39b5494bc52 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 24048
diff changeset
  2287
	    } else if (thisType == TYPE_DOUBLE) {
f39b5494bc52 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 24048
diff changeset
  2288
		typeString = "TYPE_DOUBLE";
f39b5494bc52 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 24048
diff changeset
  2289
	    } else if (thisType == TYPE_UINT) {
f39b5494bc52 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 24048
diff changeset
  2290
		typeString = "TYPE_UINT";
f39b5494bc52 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 24048
diff changeset
  2291
	    } else if (thisType == TYPE_SINT) {
f39b5494bc52 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 24048
diff changeset
  2292
		typeString = "TYPE_SINT";
f39b5494bc52 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 24048
diff changeset
  2293
	    }
f39b5494bc52 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 24048
diff changeset
  2294
	    printf("arg%d: %"_lx_" type:%"_lx_" (%s)\n",
f39b5494bc52 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 24048
diff changeset
  2295
			i+1,
f39b5494bc52 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 24048
diff changeset
  2296
			(INT)(__argValues[i].iVal), (INT)thisType, typeString);
f39b5494bc52 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 24048
diff changeset
  2297
	})
9342
e548ce80ab02 virtual calls
Claus Gittinger <cg@exept.de>
parents: 9341
diff changeset
  2298
    }
9465
d11885052713 rewrite & cleanup
Claus Gittinger <cg@exept.de>
parents: 9464
diff changeset
  2299
    failureInfo = nil;
9342
e548ce80ab02 virtual calls
Claus Gittinger <cg@exept.de>
parents: 9341
diff changeset
  2300
9465
d11885052713 rewrite & cleanup
Claus Gittinger <cg@exept.de>
parents: 9464
diff changeset
  2301
    if (callTypeNumber == @global(CALLTYPE_API)) {
20288
604e46cfbf18 ffi for mingw - 64-bit machine has no API_CALL
Claus Gittinger <cg@exept.de>
parents: 19951
diff changeset
  2302
#  ifdef __MINGW64__
24051
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2303
	__callType = FFI_DEFAULT_ABI;
20288
604e46cfbf18 ffi for mingw - 64-bit machine has no API_CALL
Claus Gittinger <cg@exept.de>
parents: 19951
diff changeset
  2304
#  else
20309
98a12d386c4a #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 20307
diff changeset
  2305
#   ifdef CALLTYPE_API
24051
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2306
	__callType = CALLTYPE_API;
20309
98a12d386c4a #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 20307
diff changeset
  2307
#   else
98a12d386c4a #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 20307
diff changeset
  2308
#    ifdef CALLTYPE_FFI_STDCALL
24051
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2309
	__callType = CALLTYPE_FFI_STDCALL;
20309
98a12d386c4a #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 20307
diff changeset
  2310
#    else
24051
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2311
	DEBUGCODE_IF( @global(Verbose), {
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2312
	    printf("STDCALL\n");
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2313
	})
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2314
	failureCode = @symbol(FFICallTypeNotSupported);
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2315
	goto getOutOfHere;
20309
98a12d386c4a #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 20307
diff changeset
  2316
#    endif
20288
604e46cfbf18 ffi for mingw - 64-bit machine has no API_CALL
Claus Gittinger <cg@exept.de>
parents: 19951
diff changeset
  2317
#   endif
19931
0ea2a7e6bb41 calls without FFI
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
  2318
#  endif
9342
e548ce80ab02 virtual calls
Claus Gittinger <cg@exept.de>
parents: 9341
diff changeset
  2319
    }
19931
0ea2a7e6bb41 calls without FFI
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
  2320
0ea2a7e6bb41 calls without FFI
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
  2321
    // these calltypes are only supported on some systems; others report an error
9465
d11885052713 rewrite & cleanup
Claus Gittinger <cg@exept.de>
parents: 9464
diff changeset
  2322
    if (callTypeNumber == @global(CALLTYPE_V8)) {
19931
0ea2a7e6bb41 calls without FFI
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
  2323
#  ifdef CALLTYPE_FFI_V8
24051
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2324
	__callType = CALLTYPE_FFI_V8;
19931
0ea2a7e6bb41 calls without FFI
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
  2325
#  else
24051
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2326
	failureCode = @symbol(FFICallTypeNotSupported);
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2327
	goto getOutOfHere;
19931
0ea2a7e6bb41 calls without FFI
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
  2328
#  endif
9342
e548ce80ab02 virtual calls
Claus Gittinger <cg@exept.de>
parents: 9341
diff changeset
  2329
    }
19931
0ea2a7e6bb41 calls without FFI
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
  2330
9465
d11885052713 rewrite & cleanup
Claus Gittinger <cg@exept.de>
parents: 9464
diff changeset
  2331
    if (callTypeNumber == @global(CALLTYPE_V9)) {
19931
0ea2a7e6bb41 calls without FFI
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
  2332
#  ifdef CALLTYPE_FFI_V9
24051
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2333
	__callType = CALLTYPE_FFI_V9;
19931
0ea2a7e6bb41 calls without FFI
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
  2334
#  else
24051
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2335
	failureCode = @symbol(FFICallTypeNotSupported);
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2336
	goto getOutOfHere;
19931
0ea2a7e6bb41 calls without FFI
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
  2337
#  endif
9342
e548ce80ab02 virtual calls
Claus Gittinger <cg@exept.de>
parents: 9341
diff changeset
  2338
    }
19931
0ea2a7e6bb41 calls without FFI
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
  2339
9465
d11885052713 rewrite & cleanup
Claus Gittinger <cg@exept.de>
parents: 9464
diff changeset
  2340
    if (callTypeNumber == @global(CALLTYPE_UNIX64)) {
19931
0ea2a7e6bb41 calls without FFI
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
  2341
#  ifdef CALLTYPE_FFI_UNIX64
24051
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2342
	__callType = CALLTYPE_FFI_UNIX64;
19931
0ea2a7e6bb41 calls without FFI
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
  2343
#  else
24051
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2344
	failureCode = @symbol(FFICallTypeNotSupported);
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2345
	goto getOutOfHere;
19931
0ea2a7e6bb41 calls without FFI
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
  2346
#  endif
9342
e548ce80ab02 virtual calls
Claus Gittinger <cg@exept.de>
parents: 9341
diff changeset
  2347
    }
e548ce80ab02 virtual calls
Claus Gittinger <cg@exept.de>
parents: 9341
diff changeset
  2348
19931
0ea2a7e6bb41 calls without FFI
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
  2349
# ifdef HAVE_FFI
24051
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2350
    DEBUGCODE_IF( @global(Verbose), {
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2351
	printf("prep: numargs=%d\n", __numArgsIncludingThis);
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2352
    })
20288
604e46cfbf18 ffi for mingw - 64-bit machine has no API_CALL
Claus Gittinger <cg@exept.de>
parents: 19951
diff changeset
  2353
9342
e548ce80ab02 virtual calls
Claus Gittinger <cg@exept.de>
parents: 9341
diff changeset
  2354
    if (ffi_prep_cif(&__cif, __callType, __numArgsIncludingThis, __returnType, __argTypesIncludingThis) != FFI_OK) {
24051
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2355
	__FAIL__(@symbol(FFIPrepareFailed))
9342
e548ce80ab02 virtual calls
Claus Gittinger <cg@exept.de>
parents: 9341
diff changeset
  2356
    }
9463
864880338d7e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9460
diff changeset
  2357
    if (async == true) {
24051
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2358
	DEBUGCODE_IF( @global(Verbose), {
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2359
	    printf("async call 0x%p\n", codeAddress);
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2360
	})
19931
0ea2a7e6bb41 calls without FFI
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
  2361
#  ifdef __win32__
24051
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2362
	__STX_C_CALL4( "ffi_call", ffi_call, &__cif, codeAddress, __returnValuePointer, __argValuePointersIncludingThis);
19931
0ea2a7e6bb41 calls without FFI
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
  2363
#  else
24051
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2364
	__BEGIN_INTERRUPTABLE__
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2365
	ffi_call(&__cif, codeAddress, __returnValuePointer, __argValuePointersIncludingThis);
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2366
	__END_INTERRUPTABLE__
19931
0ea2a7e6bb41 calls without FFI
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
  2367
#  endif
9435
68f7e39efad7 support of asynchronous calls
ca
parents: 9418
diff changeset
  2368
    } else {
24051
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2369
	if (unlimitedStack == true) {
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2370
	    DEBUGCODE_IF( @global(Verbose), {
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2371
		printf("UNLIMITEDSTACKCALL call 0x%p\n", codeAddress);
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2372
	    })
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2373
	    __UNLIMITEDSTACKCALL4__((OBJFUNC)ffi_call, (INT)(&__cif), (INT)codeAddress, (INT)__returnValuePointer, (INT)__argValuePointersIncludingThis);
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2374
	} else {
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2375
	    DEBUGCODE_IF( @global(Verbose), {
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2376
		printf("call 0x%p\n", codeAddress);
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2377
	    })
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2378
	    ffi_call(&__cif, codeAddress, __returnValuePointer, __argValuePointersIncludingThis);
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2379
	}
9435
68f7e39efad7 support of asynchronous calls
ca
parents: 9418
diff changeset
  2380
    }
19931
0ea2a7e6bb41 calls without FFI
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
  2381
0ea2a7e6bb41 calls without FFI
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
  2382
# else /* NO FFI */
0ea2a7e6bb41 calls without FFI
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
  2383
0ea2a7e6bb41 calls without FFI
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
  2384
    // this is a fallback; simply assume that pointer and regular args
0ea2a7e6bb41 calls without FFI
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
  2385
    // can be passed in the same registers, and that all args are casted to the same
0ea2a7e6bb41 calls without FFI
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
  2386
    // (pointer-) size.
0ea2a7e6bb41 calls without FFI
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
  2387
    // Also, that float/doubles are passed down in regular registers,
21748
0172bd7d20b4 #DOCUMENTATION by mawalch
mawalch
parents: 21487
diff changeset
  2388
    // and the return types float and double are handled differently from ints.
19931
0ea2a7e6bb41 calls without FFI
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
  2389
    // If that is not correct for your CPU/architecture, an ifndef is required here.
20290
952d5b62a161 implemented a non-FFI-based callout scheme which works with OSX
Claus Gittinger <cg@exept.de>
parents: 20289
diff changeset
  2390
    // No longer limited to non-double args: for x86_64, sort by non-float/float args and
952d5b62a161 implemented a non-FFI-based callout scheme which works with OSX
Claus Gittinger <cg@exept.de>
parents: 20289
diff changeset
  2391
    // pass down separately.
19931
0ea2a7e6bb41 calls without FFI
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
  2392
0ea2a7e6bb41 calls without FFI
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
  2393
    {
24051
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2394
	VOIDPTRFUNC fi = (VOIDPTRFUNC)codeAddress;
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2395
	DOUBLEFUNC fd = (DOUBLEFUNC)codeAddress;
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2396
	int rI[MAX_ARGS], dI[MAX_ARGS];
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2397
	int i;
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2398
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2399
	// sort the float/double args into a separate arglist and pass them AFTER the regular args.
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2400
	// This is possible, because all doubles are passed in floating-pnt registers,
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2401
	// no matter where they are in the arglist.
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2402
	int argI = 0, nonDoubleI = 0, doubleI = 0;
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2403
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2404
	for (argI=0; argI<__numArgsIncludingThis; argI++) {
20290
952d5b62a161 implemented a non-FFI-based callout scheme which works with OSX
Claus Gittinger <cg@exept.de>
parents: 20289
diff changeset
  2405
#  if defined(__x86_64__)
24051
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2406
	    if ((__argTypesIncludingThis[argI] == TYPE_DOUBLE)
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2407
	     || (__argTypesIncludingThis[argI] == TYPE_FLOAT)) {
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2408
		dI[doubleI++] = argI;
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2409
	    } else
20290
952d5b62a161 implemented a non-FFI-based callout scheme which works with OSX
Claus Gittinger <cg@exept.de>
parents: 20289
diff changeset
  2410
#  endif // __x86_64__
24051
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2411
	    {
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2412
		rI[nonDoubleI++] = argI;
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2413
	    }
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2414
	}
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2415
	for (i=doubleI; i<__numArgsIncludingThis; i++) dI[doubleI++] = 0;
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2416
	for (i=nonDoubleI; i<__numArgsIncludingThis; i++) rI[nonDoubleI++] = 0;
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2417
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2418
	DEBUGCODE_IF( @global(Verbose), {
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2419
	    printf("call %p with %d args (%d regular, %d double)\n",
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2420
			codeAddress, __numArgsIncludingThis, nonDoubleI, doubleI);
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2421
	})
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2422
	if (doubleI == 0) {
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2423
	    // no double args
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2424
	    switch (__returnType) {
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2425
		case TYPE_FLOAT:
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2426
		case TYPE_DOUBLE:
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2427
		    DEBUGCODE_IF( @global(Verbose), {
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2428
			printf("non-double arg; double retval\n");
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2429
		    })
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2430
		    switch (__numArgsIncludingThis) {
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2431
			case 0:
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2432
			    __returnValue.dVal = (*fd)();
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2433
			    break;
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2434
			case 1:
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2435
			    __returnValue.dVal = (*fd)( __argValues[rI[0]].pointerVal );
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2436
			    break;
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2437
			case 2:
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2438
			    __returnValue.dVal = (*fd)( __argValues[rI[0]].pointerVal, __argValues[rI[1]].pointerVal );
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2439
			    break;
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2440
			case 3:
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2441
			    __returnValue.dVal = (*fd)( __argValues[rI[0]].pointerVal, __argValues[rI[1]].pointerVal,
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2442
							__argValues[rI[2]].pointerVal );
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2443
			    break;
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2444
			case 4:
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2445
			    __returnValue.dVal = (*fd)( __argValues[rI[0]].pointerVal, __argValues[rI[1]].pointerVal,
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2446
							__argValues[rI[2]].pointerVal, __argValues[rI[3]].pointerVal );
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2447
			    break;
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2448
			case 5:
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2449
			    __returnValue.dVal = (*fd)( __argValues[rI[0]].pointerVal, __argValues[rI[1]].pointerVal,
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2450
							__argValues[rI[2]].pointerVal, __argValues[rI[3]].pointerVal,
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2451
							__argValues[rI[4]].pointerVal );
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2452
			    break;
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2453
			case 6:
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2454
			    __returnValue.dVal = (*fd)( __argValues[rI[0]].pointerVal, __argValues[rI[1]].pointerVal,
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2455
							__argValues[rI[2]].pointerVal, __argValues[rI[3]].pointerVal,
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2456
							__argValues[rI[4]].pointerVal, __argValues[rI[5]].pointerVal );
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2457
			    break;
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2458
			case 7:
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2459
			    __returnValue.dVal = (*fd)( __argValues[rI[0]].pointerVal, __argValues[rI[1]].pointerVal,
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2460
							__argValues[rI[2]].pointerVal, __argValues[rI[3]].pointerVal,
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2461
							__argValues[rI[4]].pointerVal, __argValues[rI[5]].pointerVal,
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2462
							__argValues[rI[6]].pointerVal );
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2463
			    break;
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2464
			case 8:
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2465
			    __returnValue.dVal = (*fd)( __argValues[rI[0]].pointerVal, __argValues[rI[1]].pointerVal,
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2466
							__argValues[rI[2]].pointerVal, __argValues[rI[3]].pointerVal,
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2467
							__argValues[rI[4]].pointerVal, __argValues[rI[5]].pointerVal,
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2468
							__argValues[rI[6]].pointerVal, __argValues[rI[7]].pointerVal );
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2469
			    break;
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2470
			case 9:
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2471
			    __returnValue.dVal = (*fd)( __argValues[rI[0]].pointerVal, __argValues[rI[1]].pointerVal,
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2472
							__argValues[rI[2]].pointerVal, __argValues[rI[3]].pointerVal,
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2473
							__argValues[rI[4]].pointerVal, __argValues[rI[5]].pointerVal,
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2474
							__argValues[rI[6]].pointerVal, __argValues[rI[7]].pointerVal,
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2475
							__argValues[rI[8]].pointerVal );
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2476
			    break;
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2477
			case 10:
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2478
			    __returnValue.dVal = (*fd)( __argValues[rI[0]].pointerVal, __argValues[rI[1]].pointerVal,
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2479
							__argValues[rI[2]].pointerVal, __argValues[rI[3]].pointerVal,
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2480
							__argValues[rI[4]].pointerVal, __argValues[rI[5]].pointerVal,
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2481
							__argValues[rI[6]].pointerVal, __argValues[rI[7]].pointerVal,
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2482
							__argValues[rI[8]].pointerVal, __argValues[rI[9]].pointerVal );
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2483
			    break;
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2484
			case 11:
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2485
			    __returnValue.dVal = (*fd)( __argValues[rI[0]].pointerVal, __argValues[rI[1]].pointerVal,
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2486
							__argValues[rI[2]].pointerVal, __argValues[rI[3]].pointerVal,
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2487
							__argValues[rI[4]].pointerVal, __argValues[rI[5]].pointerVal,
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2488
							__argValues[rI[6]].pointerVal, __argValues[rI[7]].pointerVal,
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2489
							__argValues[rI[8]].pointerVal, __argValues[rI[9]].pointerVal,
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2490
							__argValues[rI[10]].pointerVal );
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2491
			    break;
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2492
			case 12:
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2493
			    __returnValue.dVal = (*fd)( __argValues[rI[0]].pointerVal, __argValues[rI[1]].pointerVal,
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2494
							__argValues[rI[2]].pointerVal, __argValues[rI[3]].pointerVal,
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2495
							__argValues[rI[4]].pointerVal, __argValues[rI[5]].pointerVal,
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2496
							__argValues[rI[6]].pointerVal, __argValues[rI[7]].pointerVal,
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2497
							__argValues[rI[8]].pointerVal, __argValues[rI[9]].pointerVal,
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2498
							__argValues[rI[10]].pointerVal, __argValues[rI[11]].pointerVal );
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2499
			    break;
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2500
			case 13:
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2501
			    __returnValue.dVal = (*fd)( __argValues[rI[0]].pointerVal, __argValues[rI[1]].pointerVal,
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2502
							__argValues[rI[2]].pointerVal, __argValues[rI[3]].pointerVal,
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2503
							__argValues[rI[4]].pointerVal, __argValues[rI[5]].pointerVal,
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2504
							__argValues[rI[6]].pointerVal, __argValues[rI[7]].pointerVal,
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2505
							__argValues[rI[8]].pointerVal, __argValues[rI[9]].pointerVal,
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2506
							__argValues[rI[10]].pointerVal, __argValues[rI[11]].pointerVal,
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2507
							__argValues[rI[12]].pointerVal );
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2508
			    break;
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2509
			case 14:
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2510
			    __returnValue.dVal = (*fd)( __argValues[rI[0]].pointerVal, __argValues[rI[1]].pointerVal,
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2511
							__argValues[rI[2]].pointerVal, __argValues[rI[3]].pointerVal,
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2512
							__argValues[rI[4]].pointerVal, __argValues[rI[5]].pointerVal,
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2513
							__argValues[rI[6]].pointerVal, __argValues[rI[7]].pointerVal,
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2514
							__argValues[rI[8]].pointerVal, __argValues[rI[9]].pointerVal,
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2515
							__argValues[rI[10]].pointerVal, __argValues[rI[11]].pointerVal,
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2516
							__argValues[rI[12]].pointerVal, __argValues[rI[13]].pointerVal );
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2517
			    break;
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2518
			case 15:
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2519
			    __returnValue.dVal = (*fd)( __argValues[rI[0]].pointerVal, __argValues[rI[1]].pointerVal,
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2520
							__argValues[rI[2]].pointerVal, __argValues[rI[3]].pointerVal,
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2521
							__argValues[rI[4]].pointerVal, __argValues[rI[5]].pointerVal,
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2522
							__argValues[rI[6]].pointerVal, __argValues[rI[7]].pointerVal,
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2523
							__argValues[rI[8]].pointerVal, __argValues[rI[9]].pointerVal,
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2524
							__argValues[rI[10]].pointerVal, __argValues[rI[11]].pointerVal,
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2525
							__argValues[rI[12]].pointerVal, __argValues[rI[13]].pointerVal,
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2526
							__argValues[rI[14]].pointerVal );
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2527
			    break;
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2528
			default:
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2529
			    failureCode = @symbol(TooManyArguments);
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2530
			    goto getOutOfHere;
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2531
		    }
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2532
		    break;
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2533
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2534
		default:
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2535
		    DEBUGCODE_IF( @global(Verbose), {
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2536
			printf("non-double arg; non-double retval\n");
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2537
		    })
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2538
		    switch (__numArgsIncludingThis) {
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2539
			case 0:
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2540
			    __returnValue.pointerVal = (*fi)();
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2541
			    break;
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2542
			case 1:
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2543
			    __returnValue.pointerVal = (*fi)( __argValues[rI[0]].pointerVal );
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2544
			    break;
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2545
			case 2:
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2546
			    __returnValue.pointerVal = (*fi)( __argValues[rI[0]].pointerVal, __argValues[rI[1]].pointerVal );
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2547
			    break;
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2548
			case 3:
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2549
			    __returnValue.pointerVal = (*fi)( __argValues[rI[0]].pointerVal, __argValues[rI[1]].pointerVal, __argValues[rI[2]].pointerVal );
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2550
			    break;
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2551
			case 4:
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2552
			    __returnValue.pointerVal = (*fi)( __argValues[rI[0]].pointerVal, __argValues[rI[1]].pointerVal, __argValues[rI[2]].pointerVal,
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2553
							     __argValues[rI[3]].pointerVal );
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2554
			    break;
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2555
			case 5:
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2556
			    __returnValue.pointerVal = (*fi)( __argValues[rI[0]].pointerVal, __argValues[rI[1]].pointerVal, __argValues[rI[2]].pointerVal,
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2557
							     __argValues[rI[3]].pointerVal, __argValues[rI[4]].pointerVal );
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2558
			    break;
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2559
			case 6:
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2560
			    __returnValue.pointerVal = (*fi)( __argValues[rI[0]].pointerVal, __argValues[rI[1]].pointerVal, __argValues[rI[2]].pointerVal,
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2561
							     __argValues[rI[3]].pointerVal, __argValues[rI[4]].pointerVal, __argValues[rI[5]].pointerVal );
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2562
			    break;
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2563
			case 7:
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2564
			    __returnValue.pointerVal = (*fi)( __argValues[rI[0]].pointerVal, __argValues[rI[1]].pointerVal, __argValues[rI[2]].pointerVal,
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2565
							     __argValues[rI[3]].pointerVal, __argValues[rI[4]].pointerVal, __argValues[rI[5]].pointerVal,
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2566
							     __argValues[rI[6]].pointerVal );
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2567
			    break;
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2568
			case 8:
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2569
			    __returnValue.pointerVal = (*fi)( __argValues[rI[0]].pointerVal, __argValues[rI[1]].pointerVal, __argValues[rI[2]].pointerVal,
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2570
							     __argValues[rI[3]].pointerVal, __argValues[rI[4]].pointerVal, __argValues[rI[5]].pointerVal,
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2571
							     __argValues[rI[6]].pointerVal, __argValues[rI[7]].pointerVal );
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2572
			    break;
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2573
			case 9:
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2574
			    __returnValue.pointerVal = (*fi)( __argValues[rI[0]].pointerVal, __argValues[rI[1]].pointerVal, __argValues[rI[2]].pointerVal,
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2575
							     __argValues[rI[3]].pointerVal, __argValues[rI[4]].pointerVal, __argValues[rI[5]].pointerVal,
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2576
							     __argValues[rI[6]].pointerVal, __argValues[rI[7]].pointerVal, __argValues[rI[8]].pointerVal );
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2577
			    break;
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2578
			case 10:
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2579
			    __returnValue.pointerVal = (*fi)( __argValues[rI[0]].pointerVal, __argValues[rI[1]].pointerVal, __argValues[rI[2]].pointerVal,
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2580
							     __argValues[rI[3]].pointerVal, __argValues[rI[4]].pointerVal, __argValues[rI[5]].pointerVal,
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2581
							     __argValues[rI[6]].pointerVal, __argValues[rI[7]].pointerVal, __argValues[rI[8]].pointerVal,
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2582
							     __argValues[rI[9]].pointerVal );
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2583
			    break;
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2584
			case 11:
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2585
			    __returnValue.pointerVal = (*fi)( __argValues[rI[0]].pointerVal, __argValues[rI[1]].pointerVal, __argValues[rI[2]].pointerVal,
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2586
							     __argValues[rI[3]].pointerVal, __argValues[rI[4]].pointerVal, __argValues[rI[5]].pointerVal,
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2587
							     __argValues[rI[6]].pointerVal, __argValues[rI[7]].pointerVal, __argValues[rI[8]].pointerVal,
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2588
							     __argValues[rI[9]].pointerVal, __argValues[rI[10]].pointerVal );
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2589
			    break;
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2590
			case 12:
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2591
			    __returnValue.pointerVal = (*fi)( __argValues[rI[0]].pointerVal, __argValues[rI[1]].pointerVal, __argValues[rI[2]].pointerVal,
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2592
							     __argValues[rI[3]].pointerVal, __argValues[rI[4]].pointerVal, __argValues[rI[5]].pointerVal,
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2593
							     __argValues[rI[6]].pointerVal, __argValues[rI[7]].pointerVal, __argValues[rI[8]].pointerVal,
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2594
							     __argValues[rI[9]].pointerVal, __argValues[rI[10]].pointerVal, __argValues[rI[11]].pointerVal );
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2595
			    break;
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2596
			case 13:
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2597
			    __returnValue.pointerVal = (*fi)( __argValues[rI[0]].pointerVal, __argValues[rI[1]].pointerVal, __argValues[rI[2]].pointerVal,
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2598
							     __argValues[rI[3]].pointerVal, __argValues[rI[4]].pointerVal, __argValues[rI[5]].pointerVal,
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2599
							     __argValues[rI[6]].pointerVal, __argValues[rI[7]].pointerVal, __argValues[rI[8]].pointerVal,
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2600
							     __argValues[rI[9]].pointerVal, __argValues[rI[10]].pointerVal, __argValues[rI[11]].pointerVal,
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2601
							     __argValues[rI[12]].pointerVal );
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2602
			    break;
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2603
			case 14:
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2604
			    __returnValue.pointerVal = (*fi)( __argValues[rI[0]].pointerVal, __argValues[rI[1]].pointerVal, __argValues[rI[2]].pointerVal,
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2605
							     __argValues[rI[3]].pointerVal, __argValues[rI[4]].pointerVal, __argValues[rI[5]].pointerVal,
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2606
							     __argValues[rI[6]].pointerVal, __argValues[rI[7]].pointerVal, __argValues[rI[8]].pointerVal,
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2607
							     __argValues[rI[9]].pointerVal, __argValues[rI[10]].pointerVal, __argValues[rI[11]].pointerVal,
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2608
							     __argValues[rI[12]].pointerVal, __argValues[rI[13]].pointerVal );
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2609
			    break;
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2610
			case 15:
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2611
			    __returnValue.pointerVal = (*fi)( __argValues[rI[0]].pointerVal, __argValues[rI[1]].pointerVal, __argValues[rI[2]].pointerVal,
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2612
							     __argValues[rI[3]].pointerVal, __argValues[rI[4]].pointerVal, __argValues[rI[5]].pointerVal,
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2613
							     __argValues[rI[6]].pointerVal, __argValues[rI[7]].pointerVal, __argValues[rI[8]].pointerVal,
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2614
							     __argValues[rI[9]].pointerVal, __argValues[rI[10]].pointerVal, __argValues[rI[11]].pointerVal,
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2615
							     __argValues[rI[12]].pointerVal, __argValues[rI[13]].pointerVal, __argValues[rI[14]].pointerVal );
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2616
			    break;
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2617
			default:
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2618
			    failureCode = @symbol(TooManyArguments);
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2619
			    goto getOutOfHere;
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2620
		    }
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2621
	    }
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2622
	} else {
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2623
	    // has double args
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2624
	    switch (__returnType) {
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2625
		case TYPE_FLOAT:
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2626
		case TYPE_DOUBLE:
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2627
		    DEBUGCODE_IF( @global(Verbose), {
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2628
			printf("double arg(s); double retval\n");
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2629
		    })
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2630
		    switch (__numArgsIncludingThis) {
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2631
			case 0:
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2632
			    __returnValue.dVal = (*fd)( );
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2633
			    break;
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2634
			case 1:
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2635
			    __returnValue.dVal = (*fd)( __argValues[rI[0]].pointerVal,
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2636
							__argValues[dI[0]].dVal );
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2637
			    break;
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2638
			case 2:
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2639
			    __returnValue.dVal = (*fd)( __argValues[rI[0]].pointerVal, __argValues[rI[1]].pointerVal,
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2640
							__argValues[dI[0]].dVal, __argValues[dI[1]].dVal
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2641
						      );
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2642
			    break;
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2643
			case 3:
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2644
			    __returnValue.dVal = (*fd)( __argValues[rI[0]].pointerVal, __argValues[rI[1]].pointerVal,
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2645
							__argValues[rI[2]].pointerVal,
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2646
							__argValues[dI[0]].dVal, __argValues[dI[1]].dVal,
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2647
							__argValues[dI[2]].dVal
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2648
						      );
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2649
			    break;
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2650
			case 4:
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2651
			    __returnValue.dVal = (*fd)( __argValues[rI[0]].pointerVal, __argValues[rI[1]].pointerVal,
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2652
							__argValues[rI[2]].pointerVal, __argValues[rI[3]].pointerVal,
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2653
							__argValues[dI[0]].dVal, __argValues[dI[1]].dVal,
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2654
							__argValues[dI[2]].dVal, __argValues[dI[3]].dVal
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2655
						      );
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2656
			    break;
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2657
			case 5:
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2658
			    __returnValue.dVal = (*fd)( __argValues[rI[0]].pointerVal, __argValues[rI[1]].pointerVal,
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2659
							__argValues[rI[2]].pointerVal, __argValues[rI[3]].pointerVal,
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2660
							__argValues[rI[4]].pointerVal,
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2661
							__argValues[dI[0]].dVal, __argValues[dI[1]].dVal,
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2662
							__argValues[dI[2]].dVal, __argValues[dI[3]].dVal,
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2663
							__argValues[dI[4]].dVal
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2664
						      );
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2665
			    break;
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2666
			case 6:
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2667
			    __returnValue.dVal = (*fd)( __argValues[rI[0]].pointerVal, __argValues[rI[1]].pointerVal,
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2668
							__argValues[rI[2]].pointerVal, __argValues[rI[3]].pointerVal,
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2669
							__argValues[rI[4]].pointerVal, __argValues[rI[5]].pointerVal,
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2670
							__argValues[dI[0]].dVal, __argValues[dI[1]].dVal,
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2671
							__argValues[dI[2]].dVal, __argValues[dI[3]].dVal,
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2672
							__argValues[dI[4]].dVal, __argValues[dI[5]].dVal
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2673
						      );
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2674
			    break;
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2675
			case 7:
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2676
			    __returnValue.dVal = (*fd)( __argValues[rI[0]].pointerVal, __argValues[rI[1]].pointerVal,
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2677
							__argValues[rI[2]].pointerVal, __argValues[rI[3]].pointerVal,
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2678
							__argValues[rI[4]].pointerVal, __argValues[rI[5]].pointerVal,
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2679
							__argValues[rI[6]].pointerVal,
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2680
							__argValues[dI[0]].dVal, __argValues[dI[1]].dVal,
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2681
							__argValues[dI[2]].dVal, __argValues[dI[3]].dVal,
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2682
							__argValues[dI[4]].dVal, __argValues[dI[5]].dVal,
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2683
							__argValues[dI[6]].dVal
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2684
						      );
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2685
			    break;
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2686
			case 8:
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2687
			    __returnValue.dVal = (*fd)( __argValues[rI[0]].pointerVal, __argValues[rI[1]].pointerVal,
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2688
							__argValues[rI[2]].pointerVal, __argValues[rI[3]].pointerVal,
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2689
							__argValues[rI[4]].pointerVal, __argValues[rI[5]].pointerVal,
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2690
							__argValues[rI[6]].pointerVal, __argValues[rI[7]].pointerVal,
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2691
							__argValues[dI[0]].dVal, __argValues[dI[1]].dVal,
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2692
							__argValues[dI[2]].dVal, __argValues[dI[3]].dVal,
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2693
							__argValues[dI[4]].dVal, __argValues[dI[5]].dVal,
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2694
							__argValues[dI[6]].dVal, __argValues[dI[7]].dVal
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2695
						      );
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2696
			    break;
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2697
			case 9:
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2698
			    __returnValue.dVal = (*fd)( __argValues[rI[0]].pointerVal, __argValues[rI[1]].pointerVal,
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2699
							__argValues[rI[2]].pointerVal, __argValues[rI[3]].pointerVal,
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2700
							__argValues[rI[4]].pointerVal, __argValues[rI[5]].pointerVal,
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2701
							__argValues[rI[6]].pointerVal, __argValues[rI[7]].pointerVal,
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2702
							__argValues[rI[8]].pointerVal,
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2703
							__argValues[dI[0]].dVal, __argValues[dI[1]].dVal,
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2704
							__argValues[dI[2]].dVal, __argValues[dI[3]].dVal,
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2705
							__argValues[dI[4]].dVal, __argValues[dI[5]].dVal,
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2706
							__argValues[dI[6]].dVal, __argValues[dI[7]].dVal,
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2707
							__argValues[dI[8]].dVal
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2708
						      );
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2709
			    break;
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2710
			case 10:
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2711
			    __returnValue.dVal = (*fd)( __argValues[rI[0]].pointerVal, __argValues[rI[1]].pointerVal,
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2712
							__argValues[rI[2]].pointerVal, __argValues[rI[3]].pointerVal,
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2713
							__argValues[rI[4]].pointerVal, __argValues[rI[5]].pointerVal,
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2714
							__argValues[rI[6]].pointerVal, __argValues[rI[7]].pointerVal,
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2715
							__argValues[rI[8]].pointerVal, __argValues[rI[9]].pointerVal,
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2716
							__argValues[dI[0]].dVal, __argValues[dI[1]].dVal,
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2717
							__argValues[dI[2]].dVal, __argValues[dI[3]].dVal,
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2718
							__argValues[dI[4]].dVal, __argValues[dI[5]].dVal,
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2719
							__argValues[dI[6]].dVal, __argValues[dI[7]].dVal,
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2720
							__argValues[dI[8]].dVal, __argValues[dI[9]].dVal
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2721
						      );
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2722
			    break;
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2723
			case 11:
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2724
			    __returnValue.dVal = (*fd)( __argValues[rI[0]].pointerVal, __argValues[rI[1]].pointerVal,
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2725
							__argValues[rI[2]].pointerVal, __argValues[rI[3]].pointerVal,
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2726
							__argValues[rI[4]].pointerVal, __argValues[rI[5]].pointerVal,
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2727
							__argValues[rI[6]].pointerVal, __argValues[rI[7]].pointerVal,
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2728
							__argValues[rI[8]].pointerVal, __argValues[rI[9]].pointerVal,
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2729
							__argValues[rI[10]].pointerVal,
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2730
							__argValues[dI[0]].dVal, __argValues[dI[1]].dVal,
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2731
							__argValues[dI[2]].dVal, __argValues[dI[3]].dVal,
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2732
							__argValues[dI[4]].dVal, __argValues[dI[5]].dVal,
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2733
							__argValues[dI[6]].dVal, __argValues[dI[7]].dVal,
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2734
							__argValues[dI[8]].dVal, __argValues[dI[9]].dVal,
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2735
							__argValues[dI[10]].dVal
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2736
						      );
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2737
			    break;
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2738
			case 12:
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2739
			    __returnValue.dVal = (*fd)( __argValues[rI[0]].pointerVal, __argValues[rI[1]].pointerVal,
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2740
							__argValues[rI[2]].pointerVal, __argValues[rI[3]].pointerVal,
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2741
							__argValues[rI[4]].pointerVal, __argValues[rI[5]].pointerVal,
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2742
							__argValues[rI[6]].pointerVal, __argValues[rI[7]].pointerVal,
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2743
							__argValues[rI[8]].pointerVal, __argValues[rI[9]].pointerVal,
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2744
							__argValues[rI[10]].pointerVal, __argValues[rI[11]].pointerVal,
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2745
							__argValues[dI[0]].dVal, __argValues[dI[1]].dVal,
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2746
							__argValues[dI[2]].dVal, __argValues[dI[3]].dVal,
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2747
							__argValues[dI[4]].dVal, __argValues[dI[5]].dVal,
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2748
							__argValues[dI[6]].dVal, __argValues[dI[7]].dVal,
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2749
							__argValues[dI[8]].dVal, __argValues[dI[9]].dVal,
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2750
							__argValues[dI[10]].dVal, __argValues[dI[11]].dVal
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2751
						      );
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2752
			    break;
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2753
			case 13:
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2754
			    __returnValue.dVal = (*fd)( __argValues[rI[0]].pointerVal, __argValues[rI[1]].pointerVal,
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2755
							__argValues[rI[2]].pointerVal, __argValues[rI[3]].pointerVal,
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2756
							__argValues[rI[4]].pointerVal, __argValues[rI[5]].pointerVal,
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2757
							__argValues[rI[6]].pointerVal, __argValues[rI[7]].pointerVal,
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2758
							__argValues[rI[8]].pointerVal, __argValues[rI[9]].pointerVal,
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2759
							__argValues[rI[10]].pointerVal, __argValues[rI[11]].pointerVal,
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2760
							__argValues[rI[12]].pointerVal,
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2761
							__argValues[dI[0]].dVal, __argValues[dI[1]].dVal,
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2762
							__argValues[dI[2]].dVal, __argValues[dI[3]].dVal,
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2763
							__argValues[dI[4]].dVal, __argValues[dI[5]].dVal,
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2764
							__argValues[dI[6]].dVal, __argValues[dI[7]].dVal,
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2765
							__argValues[dI[8]].dVal, __argValues[dI[9]].dVal,
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2766
							__argValues[dI[10]].dVal, __argValues[dI[11]].dVal,
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2767
							__argValues[dI[12]].dVal
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2768
						      );
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2769
			    break;
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2770
			case 14:
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2771
			    __returnValue.dVal = (*fd)( __argValues[rI[0]].pointerVal, __argValues[rI[1]].pointerVal,
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2772
							__argValues[rI[2]].pointerVal, __argValues[rI[3]].pointerVal,
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2773
							__argValues[rI[4]].pointerVal, __argValues[rI[5]].pointerVal,
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2774
							__argValues[rI[6]].pointerVal, __argValues[rI[7]].pointerVal,
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2775
							__argValues[rI[8]].pointerVal, __argValues[rI[9]].pointerVal,
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2776
							__argValues[rI[10]].pointerVal, __argValues[rI[11]].pointerVal,
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2777
							__argValues[rI[12]].pointerVal, __argValues[rI[13]].pointerVal,
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2778
							__argValues[dI[0]].dVal, __argValues[dI[1]].dVal,
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2779
							__argValues[dI[2]].dVal, __argValues[dI[3]].dVal,
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2780
							__argValues[dI[4]].dVal, __argValues[dI[5]].dVal,
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2781
							__argValues[dI[6]].dVal, __argValues[dI[7]].dVal,
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2782
							__argValues[dI[8]].dVal, __argValues[dI[9]].dVal,
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2783
							__argValues[dI[10]].dVal, __argValues[dI[11]].dVal,
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2784
							__argValues[dI[12]].dVal, __argValues[dI[13]].dVal
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2785
						      );
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2786
			    break;
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2787
			case 15:
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2788
			    __returnValue.dVal = (*fd)( __argValues[rI[0]].pointerVal, __argValues[rI[1]].pointerVal,
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2789
							__argValues[rI[2]].pointerVal, __argValues[rI[3]].pointerVal,
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2790
							__argValues[rI[4]].pointerVal, __argValues[rI[5]].pointerVal,
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2791
							__argValues[rI[6]].pointerVal, __argValues[rI[7]].pointerVal,
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2792
							__argValues[rI[8]].pointerVal, __argValues[rI[9]].pointerVal,
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2793
							__argValues[rI[10]].pointerVal, __argValues[rI[11]].pointerVal,
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2794
							__argValues[rI[12]].pointerVal, __argValues[rI[13]].pointerVal,
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2795
							__argValues[rI[14]].pointerVal,
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2796
							__argValues[dI[0]].dVal, __argValues[dI[1]].dVal,
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2797
							__argValues[dI[2]].dVal, __argValues[dI[3]].dVal,
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2798
							__argValues[dI[4]].dVal, __argValues[dI[5]].dVal,
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2799
							__argValues[dI[6]].dVal, __argValues[dI[7]].dVal,
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2800
							__argValues[dI[8]].dVal, __argValues[dI[9]].dVal,
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2801
							__argValues[dI[10]].dVal, __argValues[dI[11]].dVal,
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2802
							__argValues[dI[12]].dVal, __argValues[dI[13]].dVal,
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2803
							__argValues[dI[14]].dVal
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2804
						      );
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2805
			    break;
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2806
			default:
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2807
			    failureCode = @symbol(TooManyArguments);
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2808
			    goto getOutOfHere;
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2809
		    }
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2810
		    break;
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2811
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2812
		default:
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2813
		    DEBUGCODE_IF( @global(Verbose), {
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2814
			printf("double arg(s); non-double retval\n");
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2815
		    })
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2816
		    switch (__numArgsIncludingThis) {
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2817
			case 0:
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2818
			    __returnValue.pointerVal = (*fi)( );
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2819
			    break;
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2820
			case 1:
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2821
			    __returnValue.pointerVal = (*fi)( __argValues[rI[0]].pointerVal,
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2822
							      __argValues[dI[0]].dVal );
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2823
			    break;
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2824
			case 2:
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2825
			    __returnValue.pointerVal = (*fi)( __argValues[rI[0]].pointerVal, __argValues[rI[1]].pointerVal,
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2826
							      __argValues[dI[0]].dVal, __argValues[dI[1]].dVal
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2827
							    );
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2828
			    break;
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2829
			case 3:
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2830
			    __returnValue.pointerVal = (*fi)( __argValues[rI[0]].pointerVal, __argValues[rI[1]].pointerVal,
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2831
							      __argValues[rI[2]].pointerVal,
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2832
							      __argValues[dI[0]].dVal, __argValues[dI[1]].dVal,
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2833
							      __argValues[dI[2]].dVal
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2834
							    );
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2835
			    break;
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2836
			case 4:
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2837
			    __returnValue.pointerVal = (*fi)( __argValues[rI[0]].pointerVal, __argValues[rI[1]].pointerVal,
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2838
							      __argValues[rI[2]].pointerVal, __argValues[rI[3]].pointerVal,
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2839
							      __argValues[dI[0]].dVal, __argValues[dI[1]].dVal,
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2840
							      __argValues[dI[2]].dVal, __argValues[dI[3]].dVal
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2841
							    );
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2842
			    break;
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2843
			case 5:
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2844
			    __returnValue.pointerVal = (*fi)( __argValues[rI[0]].pointerVal, __argValues[rI[1]].pointerVal,
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2845
							      __argValues[rI[2]].pointerVal, __argValues[rI[3]].pointerVal,
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2846
							      __argValues[rI[4]].pointerVal,
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2847
							      __argValues[dI[0]].dVal, __argValues[dI[1]].dVal,
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2848
							      __argValues[dI[2]].dVal, __argValues[dI[3]].dVal,
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2849
							      __argValues[dI[4]].dVal
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2850
							    );
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2851
			    break;
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2852
			case 6:
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2853
			    __returnValue.pointerVal = (*fi)( __argValues[rI[0]].pointerVal, __argValues[rI[1]].pointerVal,
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2854
							      __argValues[rI[2]].pointerVal, __argValues[rI[3]].pointerVal,
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2855
							      __argValues[rI[4]].pointerVal, __argValues[rI[5]].pointerVal,
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2856
							      __argValues[dI[0]].dVal, __argValues[dI[1]].dVal,
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2857
							      __argValues[dI[2]].dVal, __argValues[dI[3]].dVal,
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2858
							      __argValues[dI[4]].dVal, __argValues[dI[5]].dVal
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2859
							    );
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2860
			    break;
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2861
			case 7:
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2862
			    __returnValue.pointerVal = (*fi)( __argValues[rI[0]].pointerVal, __argValues[rI[1]].pointerVal,
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2863
							      __argValues[rI[2]].pointerVal, __argValues[rI[3]].pointerVal,
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2864
							      __argValues[rI[4]].pointerVal, __argValues[rI[5]].pointerVal,
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2865
							      __argValues[rI[6]].pointerVal,
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2866
							      __argValues[dI[0]].dVal, __argValues[dI[1]].dVal,
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2867
							      __argValues[dI[2]].dVal, __argValues[dI[3]].dVal,
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2868
							      __argValues[dI[4]].dVal, __argValues[dI[5]].dVal,
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2869
							      __argValues[dI[6]].dVal
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2870
							    );
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2871
			    break;
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2872
			case 8:
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2873
			    __returnValue.pointerVal = (*fi)( __argValues[rI[0]].pointerVal, __argValues[rI[1]].pointerVal,
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2874
							      __argValues[rI[2]].pointerVal, __argValues[rI[3]].pointerVal,
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2875
							      __argValues[rI[4]].pointerVal, __argValues[rI[5]].pointerVal,
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2876
							      __argValues[rI[6]].pointerVal, __argValues[rI[7]].pointerVal,
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2877
							      __argValues[dI[0]].dVal, __argValues[dI[1]].dVal,
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2878
							      __argValues[dI[2]].dVal, __argValues[dI[3]].dVal,
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2879
							      __argValues[dI[4]].dVal, __argValues[dI[5]].dVal,
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2880
							      __argValues[dI[6]].dVal, __argValues[dI[7]].dVal
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2881
							    );
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2882
			    break;
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2883
			case 9:
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2884
			    __returnValue.pointerVal = (*fi)( __argValues[rI[0]].pointerVal, __argValues[rI[1]].pointerVal,
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2885
							      __argValues[rI[2]].pointerVal, __argValues[rI[3]].pointerVal,
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2886
							      __argValues[rI[4]].pointerVal, __argValues[rI[5]].pointerVal,
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2887
							      __argValues[rI[6]].pointerVal, __argValues[rI[7]].pointerVal,
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2888
							      __argValues[rI[8]].pointerVal,
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2889
							      __argValues[dI[0]].dVal, __argValues[dI[1]].dVal,
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2890
							      __argValues[dI[2]].dVal, __argValues[dI[3]].dVal,
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2891
							      __argValues[dI[4]].dVal, __argValues[dI[5]].dVal,
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2892
							      __argValues[dI[6]].dVal, __argValues[dI[7]].dVal,
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2893
							      __argValues[dI[8]].dVal
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2894
							    );
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2895
			    break;
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2896
			case 10:
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2897
			    __returnValue.pointerVal = (*fi)( __argValues[rI[0]].pointerVal, __argValues[rI[1]].pointerVal,
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2898
							      __argValues[rI[2]].pointerVal, __argValues[rI[3]].pointerVal,
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2899
							      __argValues[rI[4]].pointerVal, __argValues[rI[5]].pointerVal,
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2900
							      __argValues[rI[6]].pointerVal, __argValues[rI[7]].pointerVal,
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2901
							      __argValues[rI[8]].pointerVal, __argValues[rI[9]].pointerVal,
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2902
							      __argValues[dI[0]].dVal, __argValues[dI[1]].dVal,
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2903
							      __argValues[dI[2]].dVal, __argValues[dI[3]].dVal,
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2904
							      __argValues[dI[4]].dVal, __argValues[dI[5]].dVal,
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2905
							      __argValues[dI[6]].dVal, __argValues[dI[7]].dVal,
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2906
							      __argValues[dI[8]].dVal, __argValues[dI[9]].dVal
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2907
							    );
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2908
			    break;
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2909
			case 11:
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2910
			    __returnValue.pointerVal = (*fi)( __argValues[rI[0]].pointerVal, __argValues[rI[1]].pointerVal,
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2911
							      __argValues[rI[2]].pointerVal, __argValues[rI[3]].pointerVal,
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2912
							      __argValues[rI[4]].pointerVal, __argValues[rI[5]].pointerVal,
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2913
							      __argValues[rI[6]].pointerVal, __argValues[rI[7]].pointerVal,
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2914
							      __argValues[rI[8]].pointerVal, __argValues[rI[9]].pointerVal,
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2915
							      __argValues[rI[10]].pointerVal,
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2916
							      __argValues[dI[0]].dVal, __argValues[dI[1]].dVal,
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2917
							      __argValues[dI[2]].dVal, __argValues[dI[3]].dVal,
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2918
							      __argValues[dI[4]].dVal, __argValues[dI[5]].dVal,
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2919
							      __argValues[dI[6]].dVal, __argValues[dI[7]].dVal,
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2920
							      __argValues[dI[8]].dVal, __argValues[dI[9]].dVal,
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2921
							      __argValues[dI[10]].dVal
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2922
							    );
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2923
			    break;
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2924
			case 12:
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2925
			    __returnValue.pointerVal = (*fi)( __argValues[rI[0]].pointerVal, __argValues[rI[1]].pointerVal,
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2926
							      __argValues[rI[2]].pointerVal, __argValues[rI[3]].pointerVal,
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2927
							      __argValues[rI[4]].pointerVal, __argValues[rI[5]].pointerVal,
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2928
							      __argValues[rI[6]].pointerVal, __argValues[rI[7]].pointerVal,
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2929
							      __argValues[rI[8]].pointerVal, __argValues[rI[9]].pointerVal,
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2930
							      __argValues[rI[10]].pointerVal, __argValues[rI[11]].pointerVal,
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2931
							      __argValues[dI[0]].dVal, __argValues[dI[1]].dVal,
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2932
							      __argValues[dI[2]].dVal, __argValues[dI[3]].dVal,
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2933
							      __argValues[dI[4]].dVal, __argValues[dI[5]].dVal,
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2934
							      __argValues[dI[6]].dVal, __argValues[dI[7]].dVal,
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2935
							      __argValues[dI[8]].dVal, __argValues[dI[9]].dVal,
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2936
							      __argValues[dI[10]].dVal, __argValues[dI[11]].dVal
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2937
							    );
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2938
			    break;
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2939
			case 13:
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2940
			    __returnValue.pointerVal = (*fi)( __argValues[rI[0]].pointerVal, __argValues[rI[1]].pointerVal,
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2941
							      __argValues[rI[2]].pointerVal, __argValues[rI[3]].pointerVal,
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2942
							      __argValues[rI[4]].pointerVal, __argValues[rI[5]].pointerVal,
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2943
							      __argValues[rI[6]].pointerVal, __argValues[rI[7]].pointerVal,
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2944
							      __argValues[rI[8]].pointerVal, __argValues[rI[9]].pointerVal,
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2945
							      __argValues[rI[10]].pointerVal, __argValues[rI[11]].pointerVal,
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2946
							      __argValues[rI[12]].pointerVal,
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2947
							      __argValues[dI[0]].dVal, __argValues[dI[1]].dVal,
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2948
							      __argValues[dI[2]].dVal, __argValues[dI[3]].dVal,
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2949
							      __argValues[dI[4]].dVal, __argValues[dI[5]].dVal,
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2950
							      __argValues[dI[6]].dVal, __argValues[dI[7]].dVal,
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2951
							      __argValues[dI[8]].dVal, __argValues[dI[9]].dVal,
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2952
							      __argValues[dI[10]].dVal, __argValues[dI[11]].dVal,
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2953
							      __argValues[dI[12]].dVal
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2954
							    );
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2955
			    break;
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2956
			case 14:
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2957
			    __returnValue.pointerVal = (*fi)( __argValues[rI[0]].pointerVal, __argValues[rI[1]].pointerVal,
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2958
							      __argValues[rI[2]].pointerVal, __argValues[rI[3]].pointerVal,
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2959
							      __argValues[rI[4]].pointerVal, __argValues[rI[5]].pointerVal,
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2960
							      __argValues[rI[6]].pointerVal, __argValues[rI[7]].pointerVal,
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2961
							      __argValues[rI[8]].pointerVal, __argValues[rI[9]].pointerVal,
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2962
							      __argValues[rI[10]].pointerVal, __argValues[rI[11]].pointerVal,
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2963
							      __argValues[rI[12]].pointerVal, __argValues[rI[13]].pointerVal,
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2964
							      __argValues[dI[0]].dVal, __argValues[dI[1]].dVal,
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2965
							      __argValues[dI[2]].dVal, __argValues[dI[3]].dVal,
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2966
							      __argValues[dI[4]].dVal, __argValues[dI[5]].dVal,
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2967
							      __argValues[dI[6]].dVal, __argValues[dI[7]].dVal,
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2968
							      __argValues[dI[8]].dVal, __argValues[dI[9]].dVal,
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2969
							      __argValues[dI[10]].dVal, __argValues[dI[11]].dVal,
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2970
							      __argValues[dI[12]].dVal, __argValues[dI[13]].dVal
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2971
							    );
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2972
			    break;
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2973
			case 15:
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2974
			    __returnValue.pointerVal = (*fi)( __argValues[rI[0]].pointerVal, __argValues[rI[1]].pointerVal,
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2975
							      __argValues[rI[2]].pointerVal, __argValues[rI[3]].pointerVal,
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2976
							      __argValues[rI[4]].pointerVal, __argValues[rI[5]].pointerVal,
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2977
							      __argValues[rI[6]].pointerVal, __argValues[rI[7]].pointerVal,
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2978
							      __argValues[rI[8]].pointerVal, __argValues[rI[9]].pointerVal,
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2979
							      __argValues[rI[10]].pointerVal, __argValues[rI[11]].pointerVal,
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2980
							      __argValues[rI[12]].pointerVal, __argValues[rI[13]].pointerVal,
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2981
							      __argValues[rI[14]].pointerVal,
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2982
							      __argValues[dI[0]].dVal, __argValues[dI[1]].dVal,
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2983
							      __argValues[dI[2]].dVal, __argValues[dI[3]].dVal,
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2984
							      __argValues[dI[4]].dVal, __argValues[dI[5]].dVal,
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2985
							      __argValues[dI[6]].dVal, __argValues[dI[7]].dVal,
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2986
							      __argValues[dI[8]].dVal, __argValues[dI[9]].dVal,
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2987
							      __argValues[dI[10]].dVal, __argValues[dI[11]].dVal,
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2988
							      __argValues[dI[12]].dVal, __argValues[dI[13]].dVal,
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2989
							      __argValues[dI[14]].dVal
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2990
							    );
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2991
			    break;
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2992
			default:
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2993
			    failureCode = @symbol(TooManyArguments);
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2994
			    goto getOutOfHere;
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2995
		    }
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2996
	    }
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  2997
	}
19931
0ea2a7e6bb41 calls without FFI
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
  2998
    }
20290
952d5b62a161 implemented a non-FFI-based callout scheme which works with OSX
Claus Gittinger <cg@exept.de>
parents: 20289
diff changeset
  2999
# endif // alternative to FFI
19931
0ea2a7e6bb41 calls without FFI
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
  3000
24046
6cf8161ea948 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 23834
diff changeset
  3001
    if (returnTypeSymbol == @symbol(void)) {
24051
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  3002
	RETURN ( nil );
24046
6cf8161ea948 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 23834
diff changeset
  3003
    }
6cf8161ea948 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 23834
diff changeset
  3004
20290
952d5b62a161 implemented a non-FFI-based callout scheme which works with OSX
Claus Gittinger <cg@exept.de>
parents: 20289
diff changeset
  3005
    DEBUGCODE_IF( @global(Verbose), {
24051
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  3006
	printf("retval is %"_ld_" (0x%"_lx_")\n", (INT)(__returnValue.iVal), (INT)(__returnValue.iVal));
20290
952d5b62a161 implemented a non-FFI-based callout scheme which works with OSX
Claus Gittinger <cg@exept.de>
parents: 20289
diff changeset
  3007
    })
19314
698cf296ef6d mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents: 19313
diff changeset
  3008
11586
a3b2eef8a74c int vs. sint
Claus Gittinger <cg@exept.de>
parents: 11426
diff changeset
  3009
    if ((returnTypeSymbol == @symbol(int))
a3b2eef8a74c int vs. sint
Claus Gittinger <cg@exept.de>
parents: 11426
diff changeset
  3010
     || (returnTypeSymbol == @symbol(sint))
9479
68d12a181d4a handle types; sint32 types.
ca
parents: 9466
diff changeset
  3011
     || (returnTypeSymbol == @symbol(sint8))
68d12a181d4a handle types; sint32 types.
ca
parents: 9466
diff changeset
  3012
     || (returnTypeSymbol == @symbol(sint16))
68d12a181d4a handle types; sint32 types.
ca
parents: 9466
diff changeset
  3013
     || (returnTypeSymbol == @symbol(sint32))) {
24051
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  3014
	DEBUGCODE_IF( @global(Verbose), {
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  3015
	    printf("return int: %"_lx_"\n", (INT)(__returnValue.iVal));
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  3016
	})
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  3017
	RETURN ( __MKINT(__returnValue.iVal) );
9342
e548ce80ab02 virtual calls
Claus Gittinger <cg@exept.de>
parents: 9341
diff changeset
  3018
    }
e548ce80ab02 virtual calls
Claus Gittinger <cg@exept.de>
parents: 9341
diff changeset
  3019
    if ((returnTypeSymbol == @symbol(uint))
e548ce80ab02 virtual calls
Claus Gittinger <cg@exept.de>
parents: 9341
diff changeset
  3020
     || (returnTypeSymbol == @symbol(uint8))
e548ce80ab02 virtual calls
Claus Gittinger <cg@exept.de>
parents: 9341
diff changeset
  3021
     || (returnTypeSymbol == @symbol(uint16))
e548ce80ab02 virtual calls
Claus Gittinger <cg@exept.de>
parents: 9341
diff changeset
  3022
     || (returnTypeSymbol == @symbol(uint32))) {
24051
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  3023
	DEBUGCODE_IF( @global(Verbose), {
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  3024
	    printf("return uint: %"_lx_"\n", (INT)(__returnValue.iVal));
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  3025
	})
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  3026
	RETURN ( __MKUINT(__returnValue.iVal) );
9342
e548ce80ab02 virtual calls
Claus Gittinger <cg@exept.de>
parents: 9341
diff changeset
  3027
    }
10025
053904a63549 stc-compiled ExternalLibraryFunctions
Claus Gittinger <cg@exept.de>
parents: 9981
diff changeset
  3028
    if (returnTypeSymbol == @symbol(bool)) {
24051
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  3029
	RETURN ( __returnValue.iVal ? true : false );
9342
e548ce80ab02 virtual calls
Claus Gittinger <cg@exept.de>
parents: 9341
diff changeset
  3030
    }
e548ce80ab02 virtual calls
Claus Gittinger <cg@exept.de>
parents: 9341
diff changeset
  3031
    if (returnTypeSymbol == @symbol(float)) {
24051
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  3032
	RETURN ( __MKFLOAT(__returnValue.fVal ));
9342
e548ce80ab02 virtual calls
Claus Gittinger <cg@exept.de>
parents: 9341
diff changeset
  3033
    }
e548ce80ab02 virtual calls
Claus Gittinger <cg@exept.de>
parents: 9341
diff changeset
  3034
    if (returnTypeSymbol == @symbol(double)) {
24051
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  3035
	RETURN ( __MKFLOAT(__returnValue.dVal ));
9342
e548ce80ab02 virtual calls
Claus Gittinger <cg@exept.de>
parents: 9341
diff changeset
  3036
    }
9463
864880338d7e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9460
diff changeset
  3037
    if (returnTypeSymbol == @symbol(char)) {
24051
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  3038
	RETURN ( __MKCHARACTER(__returnValue.iVal & 0xFF) );
9463
864880338d7e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9460
diff changeset
  3039
    }
864880338d7e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9460
diff changeset
  3040
    if (returnTypeSymbol == @symbol(wchar)) {
24051
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  3041
	RETURN ( __MKUCHARACTER(__returnValue.iVal & 0xFFFF) );
12504
c9987bb76eb6 untested long long return value
Claus Gittinger <cg@exept.de>
parents: 12503
diff changeset
  3042
    }
c9987bb76eb6 untested long long return value
Claus Gittinger <cg@exept.de>
parents: 12503
diff changeset
  3043
    if (returnTypeSymbol == @symbol(sint64)) {
19356
5ca3989a13f0 bcc fixes
Claus Gittinger <cg@exept.de>
parents: 19355
diff changeset
  3044
# if (__POINTER_SIZE__ == 8)
19355
58ef1e6a54f9 fix for bcc
Claus Gittinger <cg@exept.de>
parents: 19343
diff changeset
  3045
24051
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  3046
	DEBUGCODE_IF( @global(Verbose), {
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  3047
	    printf("return sint64: %"_lx_"\n", (INT)(__returnValue.longLongVal));
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  3048
	})
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  3049
	RETURN ( __MKINT(__returnValue.longLongVal) );
19314
698cf296ef6d mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents: 19313
diff changeset
  3050
# else
24051
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  3051
	DEBUGCODE_IF( @global(Verbose), {
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  3052
	    printf("return sint64: %lx%08lx\n", __HI32(__returnValue.longLongVal), __LO32(__returnValue.longLongVal));
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  3053
	})
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  3054
	RETURN ( __MKINT64(&__returnValue.longLongVal) );
19314
698cf296ef6d mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents: 19313
diff changeset
  3055
# endif
12504
c9987bb76eb6 untested long long return value
Claus Gittinger <cg@exept.de>
parents: 12503
diff changeset
  3056
    }
c9987bb76eb6 untested long long return value
Claus Gittinger <cg@exept.de>
parents: 12503
diff changeset
  3057
    if (returnTypeSymbol == @symbol(uint64)) {
19356
5ca3989a13f0 bcc fixes
Claus Gittinger <cg@exept.de>
parents: 19355
diff changeset
  3058
# if (__POINTER_SIZE__ == 8)
24051
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  3059
	DEBUGCODE_IF( @global(Verbose), {
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  3060
	    printf("return uint64: %"_lx_"\n", (unsigned INT)(__returnValue.longLongVal));
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  3061
	})
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  3062
	RETURN ( __MKUINT(__returnValue.longLongVal) );
19314
698cf296ef6d mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents: 19313
diff changeset
  3063
# else
24051
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  3064
	DEBUGCODE_IF( @global(Verbose), {
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  3065
	    printf("return sint64: %lx%08lx\n", __HI32(__returnValue.longLongVal), __LO32(__returnValue.longLongVal));
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  3066
	})
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  3067
	RETURN ( __MKUINT64(&__returnValue.longLongVal) );
19314
698cf296ef6d mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents: 19313
diff changeset
  3068
# endif
9463
864880338d7e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9460
diff changeset
  3069
    }
11586
a3b2eef8a74c int vs. sint
Claus Gittinger <cg@exept.de>
parents: 11426
diff changeset
  3070
20290
952d5b62a161 implemented a non-FFI-based callout scheme which works with OSX
Claus Gittinger <cg@exept.de>
parents: 20289
diff changeset
  3071
    DEBUGCODE_IF( @global(Verbose), {
24051
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  3072
	printf("return pointer: %"_lx_"\n", (INT)(__returnValue.pointerVal));
20290
952d5b62a161 implemented a non-FFI-based callout scheme which works with OSX
Claus Gittinger <cg@exept.de>
parents: 20289
diff changeset
  3073
    })
9346
a95e2cf0e56f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9344
diff changeset
  3074
    if (returnTypeSymbol == @symbol(handle)) {
24053
771e243d3ce8 null pointers returned as nil
Claus Gittinger <cg@exept.de>
parents: 24052
diff changeset
  3075
	returnValue = (__returnValue.pointerVal == NULL)
771e243d3ce8 null pointers returned as nil
Claus Gittinger <cg@exept.de>
parents: 24052
diff changeset
  3076
			? nil : __MKEXTERNALADDRESS(__returnValue.pointerVal);
9346
a95e2cf0e56f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9344
diff changeset
  3077
    } else if (returnTypeSymbol == @symbol(pointer)) {
24053
771e243d3ce8 null pointers returned as nil
Claus Gittinger <cg@exept.de>
parents: 24052
diff changeset
  3078
	returnValue = (__returnValue.pointerVal == NULL)
771e243d3ce8 null pointers returned as nil
Claus Gittinger <cg@exept.de>
parents: 24052
diff changeset
  3079
			? nil : __MKEXTERNALBYTES(__returnValue.pointerVal);
10603
da9b7ed81caf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10514
diff changeset
  3080
    } else if (returnTypeSymbol == @symbol(bytePointer)) {
24053
771e243d3ce8 null pointers returned as nil
Claus Gittinger <cg@exept.de>
parents: 24052
diff changeset
  3081
	returnValue = (__returnValue.pointerVal == NULL)
771e243d3ce8 null pointers returned as nil
Claus Gittinger <cg@exept.de>
parents: 24052
diff changeset
  3082
			? nil : __MKEXTERNALBYTES(__returnValue.pointerVal);
9463
864880338d7e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9460
diff changeset
  3083
    } else if (returnTypeSymbol == @symbol(charPointer)) {
24053
771e243d3ce8 null pointers returned as nil
Claus Gittinger <cg@exept.de>
parents: 24052
diff changeset
  3084
	if (__returnValue.pointerVal == NULL) {
771e243d3ce8 null pointers returned as nil
Claus Gittinger <cg@exept.de>
parents: 24052
diff changeset
  3085
	    returnValue = nil;
771e243d3ce8 null pointers returned as nil
Claus Gittinger <cg@exept.de>
parents: 24052
diff changeset
  3086
	} else {
771e243d3ce8 null pointers returned as nil
Claus Gittinger <cg@exept.de>
parents: 24052
diff changeset
  3087
	    returnValue = __MKSTRING(__returnValue.pointerVal);
771e243d3ce8 null pointers returned as nil
Claus Gittinger <cg@exept.de>
parents: 24052
diff changeset
  3088
	    if (mustFreeRetVal == true) {
771e243d3ce8 null pointers returned as nil
Claus Gittinger <cg@exept.de>
parents: 24052
diff changeset
  3089
		free(__returnValue.pointerVal);
771e243d3ce8 null pointers returned as nil
Claus Gittinger <cg@exept.de>
parents: 24052
diff changeset
  3090
		alreadyFreed = true;
771e243d3ce8 null pointers returned as nil
Claus Gittinger <cg@exept.de>
parents: 24052
diff changeset
  3091
	    }
24051
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  3092
	}
9463
864880338d7e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9460
diff changeset
  3093
    } else if (returnTypeSymbol == @symbol(wcharPointer)) {
24053
771e243d3ce8 null pointers returned as nil
Claus Gittinger <cg@exept.de>
parents: 24052
diff changeset
  3094
	if (__returnValue.pointerVal == NULL) {
771e243d3ce8 null pointers returned as nil
Claus Gittinger <cg@exept.de>
parents: 24052
diff changeset
  3095
	    returnValue = nil;
771e243d3ce8 null pointers returned as nil
Claus Gittinger <cg@exept.de>
parents: 24052
diff changeset
  3096
	} else {
771e243d3ce8 null pointers returned as nil
Claus Gittinger <cg@exept.de>
parents: 24052
diff changeset
  3097
	    returnValue = __MKU16STRING(__returnValue.pointerVal);
771e243d3ce8 null pointers returned as nil
Claus Gittinger <cg@exept.de>
parents: 24052
diff changeset
  3098
	    if (mustFreeRetVal == true) {
771e243d3ce8 null pointers returned as nil
Claus Gittinger <cg@exept.de>
parents: 24052
diff changeset
  3099
		free(__returnValue.pointerVal);
771e243d3ce8 null pointers returned as nil
Claus Gittinger <cg@exept.de>
parents: 24052
diff changeset
  3100
		alreadyFreed = true;
771e243d3ce8 null pointers returned as nil
Claus Gittinger <cg@exept.de>
parents: 24052
diff changeset
  3101
	    }
24051
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  3102
	}
9342
e548ce80ab02 virtual calls
Claus Gittinger <cg@exept.de>
parents: 9341
diff changeset
  3103
    } else {
24051
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  3104
	__FAIL__(@symbol(UnknownReturnType2))
9342
e548ce80ab02 virtual calls
Claus Gittinger <cg@exept.de>
parents: 9341
diff changeset
  3105
    }
19931
0ea2a7e6bb41 calls without FFI
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
  3106
9342
e548ce80ab02 virtual calls
Claus Gittinger <cg@exept.de>
parents: 9341
diff changeset
  3107
getOutOfHere: ;
e548ce80ab02 virtual calls
Claus Gittinger <cg@exept.de>
parents: 9341
diff changeset
  3108
%}.
e548ce80ab02 virtual calls
Claus Gittinger <cg@exept.de>
parents: 9341
diff changeset
  3109
    failureCode notNil ifTrue:[
24051
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  3110
	(failureCode == #UnknownReturnType or:[ failureCode == #UnknownArgumentType ]) ifTrue:[
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  3111
	    oldReturnType := returnType.
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  3112
	    oldArgumentTypes := argumentTypes.
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  3113
	    self adjustTypes.
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  3114
	    ((oldReturnType ~= returnType) or:[oldArgumentTypes ~= argumentTypes]) ifTrue:[
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  3115
		thisContext methodHome restart
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  3116
	    ].
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  3117
	].
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  3118
	(failureCode == #BadArgForAsyncCall) ifTrue:[
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  3119
	    ^ self tryAgainWithAsyncSafeArguments:argumentsOrNil forInstance:aReceiverOrNil
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  3120
	].
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  3121
	(failureCode == #FFINotSupported) ifTrue:[
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  3122
	    ^ self primitiveFailed:'FFI support missing in this build'.
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  3123
	].
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  3124
	(failureCode == #InvalidArgument) ifTrue:[
24055
6b7d72a17973 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 24053
diff changeset
  3125
	    ^ self primitiveFailed:('cannot convert argument: #%1 (to %2)'
6b7d72a17973 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 24053
diff changeset
  3126
					bindWith:failureArgNr with:(argTypeSymbols at:failureArgNr)).
24052
d9fb5cb43b52 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 24051
diff changeset
  3127
	].
d9fb5cb43b52 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 24051
diff changeset
  3128
	(failureCode == #UnknownReturnType) ifTrue:[
d9fb5cb43b52 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 24051
diff changeset
  3129
	    ^ self primitiveFailed:('unknown return type: #%1' bindWith:returnTypeSymbol).
24051
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  3130
	].
24052
d9fb5cb43b52 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 24051
diff changeset
  3131
	(failureCode == #UnknownReturnType2) ifTrue:[
d9fb5cb43b52 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 24051
diff changeset
  3132
	    ^ self primitiveFailed:('don''t know how to convert return value with type: #%1' bindWith:returnTypeSymbol).
d9fb5cb43b52 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 24051
diff changeset
  3133
	].
d9fb5cb43b52 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 24051
diff changeset
  3134
	^ self primitiveFailed.   "see failureCode and failureInfo for details"
9342
e548ce80ab02 virtual calls
Claus Gittinger <cg@exept.de>
parents: 9341
diff changeset
  3135
    ].
e548ce80ab02 virtual calls
Claus Gittinger <cg@exept.de>
parents: 9341
diff changeset
  3136
21412
67b11b143a30 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21411
diff changeset
  3137
    (mustFreeRetVal and:[alreadyFreed not]) ifTrue:[
24051
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  3138
	returnValue registerForFinalization.
21412
67b11b143a30 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21411
diff changeset
  3139
    ].
67b11b143a30 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21411
diff changeset
  3140
9483
3bea515ce81e *** empty log message ***
fm
parents: 9479
diff changeset
  3141
    returnType isSymbol ifTrue:[
24051
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  3142
	returnValueClass notNil ifTrue:[
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  3143
	    self isConstReturnValue ifTrue:[
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  3144
		returnValue changeClassTo:returnValueClass.
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  3145
		^ returnValue
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  3146
	    ].
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  3147
	    ^ returnValueClass fromExternalAddress:returnValue.
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  3148
	].
9483
3bea515ce81e *** empty log message ***
fm
parents: 9479
diff changeset
  3149
    ] ifFalse:[
24051
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  3150
	returnType isCPointer ifTrue:[
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  3151
	    returnType baseType isCStruct ifTrue:[
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  3152
		stClass := Smalltalk classNamed:returnType baseType name.
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  3153
		stClass notNil ifTrue:[
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  3154
		    self isConstReturnValue ifTrue:[
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  3155
			returnValue changeClassTo:returnValueClass.
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  3156
			^ returnValue
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  3157
		    ].
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  3158
		    ^ stClass fromExternalAddress:returnValue.
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  3159
		].
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  3160
	    ].
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  3161
	    returnType baseType isCChar ifTrue:[
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  3162
		^ returnValue stringAt:1
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  3163
	    ].
f531b38415db struct args
Claus Gittinger <cg@exept.de>
parents: 24050
diff changeset
  3164
	].
9342
e548ce80ab02 virtual calls
Claus Gittinger <cg@exept.de>
parents: 9341
diff changeset
  3165
    ].
e548ce80ab02 virtual calls
Claus Gittinger <cg@exept.de>
parents: 9341
diff changeset
  3166
e548ce80ab02 virtual calls
Claus Gittinger <cg@exept.de>
parents: 9341
diff changeset
  3167
    ^ returnValue
9463
864880338d7e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9460
diff changeset
  3168
864880338d7e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9460
diff changeset
  3169
    "Created: / 01-08-2006 / 13:56:23 / cg"
21748
0172bd7d20b4 #DOCUMENTATION by mawalch
mawalch
parents: 21487
diff changeset
  3170
    "Modified: / 15-05-2017 / 19:48:52 / mawalch"
22141
d5c9d544447f #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 22140
diff changeset
  3171
    "Modified: / 01-08-2017 / 14:03:52 / cg"
24048
1839f4b8eb2e #QUALITY by stefan
Stefan Vogel <sv@exept.de>
parents: 24046
diff changeset
  3172
    "Modified: / 04-04-2019 / 14:10:32 / Stefan Vogel"
24074
69ee642ca7dd *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 24065
diff changeset
  3173
    "Modified: / 13-04-2019 / 17:55:45 / Claus Gittinger"
14037
Michael Beyl <mb@exept.de>
parents: 13782
diff changeset
  3174
!
Michael Beyl <mb@exept.de>
parents: 13782
diff changeset
  3175
23829
209adc65cf44 renamed private method
Claus Gittinger <cg@exept.de>
parents: 23828
diff changeset
  3176
tryAgainWithAsyncSafeArguments:argumentsOrNil forInstance:aReceiverOrNil
14037
Michael Beyl <mb@exept.de>
parents: 13782
diff changeset
  3177
    "invoked by the call primitive, iff GC-unsave arguments where passed to the call.
Michael Beyl <mb@exept.de>
parents: 13782
diff changeset
  3178
     Here, allocate non-movable blocks of memory and copy the arguments into them,
Michael Beyl <mb@exept.de>
parents: 13782
diff changeset
  3179
     then try the call again, copy changed values back, and release the memeory."
Michael Beyl <mb@exept.de>
parents: 13782
diff changeset
  3180
Michael Beyl <mb@exept.de>
parents: 13782
diff changeset
  3181
    |saveArguments anyBadArg result originalToSaveArgMapping|
Michael Beyl <mb@exept.de>
parents: 13782
diff changeset
  3182
Michael Beyl <mb@exept.de>
parents: 13782
diff changeset
  3183
    argumentsOrNil isNil ifTrue:[
14625
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  3184
	^ self primitiveFailed
14037
Michael Beyl <mb@exept.de>
parents: 13782
diff changeset
  3185
    ].
14506
e53548cdc24d changed: #tryAgainWithAsyncSafeArguments:forCPPInstance:
anwild
parents: 14412
diff changeset
  3186
    thisContext isRecursive ifTrue: [^self primitiveFailed].
14037
Michael Beyl <mb@exept.de>
parents: 13782
diff changeset
  3187
Michael Beyl <mb@exept.de>
parents: 13782
diff changeset
  3188
    anyBadArg := false.
Michael Beyl <mb@exept.de>
parents: 13782
diff changeset
  3189
    originalToSaveArgMapping := IdentityDictionary new.
Michael Beyl <mb@exept.de>
parents: 13782
diff changeset
  3190
14625
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  3191
    saveArguments := argumentsOrNil
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  3192
			collect:[:eachArg |
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  3193
			    |saveArg|
14037
Michael Beyl <mb@exept.de>
parents: 13782
diff changeset
  3194
14625
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  3195
			    (originalToSaveArgMapping includesKey:eachArg) ifTrue:[
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  3196
				saveArg := originalToSaveArgMapping at:eachArg
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  3197
			    ] ifFalse:[
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  3198
				eachArg isString ifTrue:[
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  3199
				    saveArg := (ExternalBytes fromString:eachArg) register.
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  3200
				    anyBadArg := true.
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  3201
				    originalToSaveArgMapping at:eachArg put:saveArg.
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  3202
				] ifFalse:[
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  3203
				    eachArg isByteCollection ifTrue:[
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  3204
					saveArg := (ExternalBytes from:eachArg) register.
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  3205
					originalToSaveArgMapping at:eachArg put:saveArg.
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  3206
					anyBadArg := true.
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  3207
				    ] ifFalse:[
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  3208
					saveArg := eachArg
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  3209
				    ]
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  3210
				].
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  3211
			    ].
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  3212
			    saveArg
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  3213
			].
14037
Michael Beyl <mb@exept.de>
parents: 13782
diff changeset
  3214
Michael Beyl <mb@exept.de>
parents: 13782
diff changeset
  3215
    anyBadArg ifFalse:[
14625
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  3216
	"avoid recursion..."
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  3217
	^ self primitiveFailed
14037
Michael Beyl <mb@exept.de>
parents: 13782
diff changeset
  3218
    ].
Michael Beyl <mb@exept.de>
parents: 13782
diff changeset
  3219
23829
209adc65cf44 renamed private method
Claus Gittinger <cg@exept.de>
parents: 23828
diff changeset
  3220
    result := self invokeFFIwithArguments:saveArguments forInstance:aReceiverOrNil.
14037
Michael Beyl <mb@exept.de>
parents: 13782
diff changeset
  3221
Michael Beyl <mb@exept.de>
parents: 13782
diff changeset
  3222
    "/ copy back !!
Michael Beyl <mb@exept.de>
parents: 13782
diff changeset
  3223
    originalToSaveArgMapping keysAndValuesDo:[:arg :saveArg |
14625
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  3224
	arg isSymbol ifFalse:[
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  3225
	    arg replaceFrom:1 to:(arg size) with:saveArg startingAt:1.
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  3226
	].
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  3227
	saveArg free.
14037
Michael Beyl <mb@exept.de>
parents: 13782
diff changeset
  3228
    ].
Michael Beyl <mb@exept.de>
parents: 13782
diff changeset
  3229
    ^ result.
14506
e53548cdc24d changed: #tryAgainWithAsyncSafeArguments:forCPPInstance:
anwild
parents: 14412
diff changeset
  3230
e53548cdc24d changed: #tryAgainWithAsyncSafeArguments:forCPPInstance:
anwild
parents: 14412
diff changeset
  3231
    "Modified (format): / 06-11-2012 / 10:52:41 / anwild"
9342
e548ce80ab02 virtual calls
Claus Gittinger <cg@exept.de>
parents: 9341
diff changeset
  3232
! !
e548ce80ab02 virtual calls
Claus Gittinger <cg@exept.de>
parents: 9341
diff changeset
  3233
10481
b3526180579f +isExternalLibraryFunction
fm
parents: 10440
diff changeset
  3234
!ExternalLibraryFunction methodsFor:'testing'!
b3526180579f +isExternalLibraryFunction
fm
parents: 10440
diff changeset
  3235
10603
da9b7ed81caf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10514
diff changeset
  3236
isExternalLibraryFunction
da9b7ed81caf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10514
diff changeset
  3237
    "return true, if the receiver is some kind of externalLibrary function;
da9b7ed81caf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10514
diff changeset
  3238
     true is returned here"
da9b7ed81caf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10514
diff changeset
  3239
da9b7ed81caf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10514
diff changeset
  3240
    ^true
da9b7ed81caf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10514
diff changeset
  3241
da9b7ed81caf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10514
diff changeset
  3242
    "Created: / 07-06-2007 / 10:36:40 / cg"
10481
b3526180579f +isExternalLibraryFunction
fm
parents: 10440
diff changeset
  3243
! !
b3526180579f +isExternalLibraryFunction
fm
parents: 10440
diff changeset
  3244
8533
9065c547ea75 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3245
!ExternalLibraryFunction class methodsFor:'documentation'!
9065c547ea75 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3246
19487
79d76a2de0f1 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 19483
diff changeset
  3247
version
79d76a2de0f1 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 19483
diff changeset
  3248
    ^ '$Header$'
79d76a2de0f1 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 19483
diff changeset
  3249
!
79d76a2de0f1 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 19483
diff changeset
  3250
13412
9a5f99d66cd9 Jan's changes
vrany
parents: 13337
diff changeset
  3251
version_CVS
19311
6f1d1ea6dba8 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 18240
diff changeset
  3252
    ^ '$Header$'
12436
92a968c9ca92 changed:
Claus Gittinger <cg@exept.de>
parents: 11586
diff changeset
  3253
!
92a968c9ca92 changed:
Claus Gittinger <cg@exept.de>
parents: 11586
diff changeset
  3254
13412
9a5f99d66cd9 Jan's changes
vrany
parents: 13337
diff changeset
  3255
version_SVN
19311
6f1d1ea6dba8 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 18240
diff changeset
  3256
    ^ '$ Id: ExternalLibraryFunction.st 10643 2011-06-08 21:53:07Z vranyj1  $'
8533
9065c547ea75 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3257
! !
9463
864880338d7e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9460
diff changeset
  3258
19311
6f1d1ea6dba8 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 18240
diff changeset
  3259
9463
864880338d7e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9460
diff changeset
  3260
ExternalLibraryFunction initialize!