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