ExternalLibraryFunction.st
author Claus Gittinger <cg@exept.de>
Mon, 06 Jun 2016 10:00:18 +0200
changeset 19950 ee2f6bfd55c1
parent 19933 d45636ff51df
child 19951 2ba5ef097a79
permissions -rw-r--r--
bugfix
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
8728
d70396dc4e96 copyright
Claus Gittinger <cg@exept.de>
parents: 8550
diff changeset
     1
"
d70396dc4e96 copyright
Claus Gittinger <cg@exept.de>
parents: 8550
diff changeset
     2
 COPYRIGHT (c) 2004 by eXept Software AG
9464
157fe6ca53e6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9463
diff changeset
     3
	      All Rights Reserved
8728
d70396dc4e96 copyright
Claus Gittinger <cg@exept.de>
parents: 8550
diff changeset
     4
d70396dc4e96 copyright
Claus Gittinger <cg@exept.de>
parents: 8550
diff changeset
     5
 This software is furnished under a license and may be used
d70396dc4e96 copyright
Claus Gittinger <cg@exept.de>
parents: 8550
diff changeset
     6
 only in accordance with the terms of that license and with the
d70396dc4e96 copyright
Claus Gittinger <cg@exept.de>
parents: 8550
diff changeset
     7
 inclusion of the above copyright notice.   This software may not
d70396dc4e96 copyright
Claus Gittinger <cg@exept.de>
parents: 8550
diff changeset
     8
 be provided or otherwise made available to, or used by, any
d70396dc4e96 copyright
Claus Gittinger <cg@exept.de>
parents: 8550
diff changeset
     9
 other person.  No title to or ownership of the software is
d70396dc4e96 copyright
Claus Gittinger <cg@exept.de>
parents: 8550
diff changeset
    10
 hereby transferred.
d70396dc4e96 copyright
Claus Gittinger <cg@exept.de>
parents: 8550
diff changeset
    11
"
8533
9065c547ea75 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    12
"{ Package: 'stx:libbasic' }"
9065c547ea75 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    13
19311
6f1d1ea6dba8 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 18240
diff changeset
    14
"{ NameSpace: Smalltalk }"
6f1d1ea6dba8 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 18240
diff changeset
    15
8533
9065c547ea75 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    16
ExternalFunction subclass:#ExternalLibraryFunction
9465
d11885052713 rewrite & cleanup
Claus Gittinger <cg@exept.de>
parents: 9464
diff changeset
    17
	instanceVariableNames:'flags moduleName returnType argumentTypes owningClass'
14659
410089913ca1 allow use of the standard (system) ffi
Claus Gittinger <cg@exept.de>
parents: 14632
diff changeset
    18
	classVariableNames:'DLLPATH FLAG_VIRTUAL FLAG_NONVIRTUAL FLAG_OBJECTIVEC FLAG_ASYNC
10270
897474c6c785 allow setting the dllPath
fm
parents: 10213
diff changeset
    19
		FLAG_UNLIMITEDSTACK FLAG_RETVAL_IS_CONST CALLTYPE_MASK
897474c6c785 allow setting the dllPath
fm
parents: 10213
diff changeset
    20
		CALLTYPE_API CALLTYPE_C CALLTYPE_OLE CALLTYPE_V8 CALLTYPE_V9
19342
3afa63c8dcae #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19341
diff changeset
    21
		CALLTYPE_UNIX64 DllMapping Verbose LastModuleHandleHolder
3afa63c8dcae #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19341
diff changeset
    22
		LastModuleHandleName'
9464
157fe6ca53e6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9463
diff changeset
    23
	poolDictionaries:''
157fe6ca53e6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9463
diff changeset
    24
	category:'System-Support'
8533
9065c547ea75 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    25
!
9065c547ea75 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    26
9322
41c391bfbf03 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9321
diff changeset
    27
!ExternalLibraryFunction primitiveDefinitions!
41c391bfbf03 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9321
diff changeset
    28
%{
19314
698cf296ef6d mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents: 19313
diff changeset
    29
#define VERBOSE
9322
41c391bfbf03 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9321
diff changeset
    30
9337
ab6bbf58bf0a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9336
diff changeset
    31
#ifdef HAVE_FFI
ab6bbf58bf0a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9336
diff changeset
    32
# include <ffi.h>
9322
41c391bfbf03 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9321
diff changeset
    33
# define MAX_ARGS    128
9365
9003f8432516 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9347
diff changeset
    34
14659
410089913ca1 allow use of the standard (system) ffi
Claus Gittinger <cg@exept.de>
parents: 14632
diff changeset
    35
# ifdef USE_STANDARD_FFI
410089913ca1 allow use of the standard (system) ffi
Claus Gittinger <cg@exept.de>
parents: 14632
diff changeset
    36
#  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
    37
#  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
    38
#  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
    39
#  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
    40
#  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
    41
#  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
    42
#  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
    43
#  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
    44
#  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
    45
#  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
    46
#  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
    47
#  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
    48
#  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
    49
#  define __get_ffi_type_pointer() &ffi_type_pointer
19931
0ea2a7e6bb41 calls without FFI
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
    50
14659
410089913ca1 allow use of the standard (system) ffi
Claus Gittinger <cg@exept.de>
parents: 14632
diff changeset
    51
# else
19931
0ea2a7e6bb41 calls without FFI
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
    52
19314
698cf296ef6d mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents: 19313
diff changeset
    53
   extern ffi_type *__get_ffi_type_sint();
698cf296ef6d mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents: 19313
diff changeset
    54
   extern ffi_type *__get_ffi_type_sint8();
698cf296ef6d mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents: 19313
diff changeset
    55
   extern ffi_type *__get_ffi_type_sint16();
698cf296ef6d mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents: 19313
diff changeset
    56
   extern ffi_type *__get_ffi_type_sint32();
698cf296ef6d mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents: 19313
diff changeset
    57
   extern ffi_type *__get_ffi_type_sint64();
698cf296ef6d mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents: 19313
diff changeset
    58
   extern ffi_type *__get_ffi_type_uint();
698cf296ef6d mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents: 19313
diff changeset
    59
   extern ffi_type *__get_ffi_type_uint8();
698cf296ef6d mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents: 19313
diff changeset
    60
   extern ffi_type *__get_ffi_type_uint16();
698cf296ef6d mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents: 19313
diff changeset
    61
   extern ffi_type *__get_ffi_type_uint32();
698cf296ef6d mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents: 19313
diff changeset
    62
   extern ffi_type *__get_ffi_type_uint64();
698cf296ef6d mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents: 19313
diff changeset
    63
   extern ffi_type *__get_ffi_type_float();
698cf296ef6d mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents: 19313
diff changeset
    64
   extern ffi_type *__get_ffi_type_double();
698cf296ef6d mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents: 19313
diff changeset
    65
   extern ffi_type *__get_ffi_type_void();
698cf296ef6d mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents: 19313
diff changeset
    66
   extern ffi_type *__get_ffi_type_pointer();
19535
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
    67
   extern INTFUNC __get_ffi_prep_cif();
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
    68
   extern INTFUNC __get_ffi_call();
19536
599f54c61bd8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 19535
diff changeset
    69
#  ifdef _MINGW__
599f54c61bd8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 19535
diff changeset
    70
#   define ffi_prep_cif (*(__get_ffi_prep_cif()))
599f54c61bd8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 19535
diff changeset
    71
#   define ffi_call (*(__get_ffi_call()))
599f54c61bd8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 19535
diff changeset
    72
#  endif
14659
410089913ca1 allow use of the standard (system) ffi
Claus Gittinger <cg@exept.de>
parents: 14632
diff changeset
    73
# endif
9365
9003f8432516 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9347
diff changeset
    74
19931
0ea2a7e6bb41 calls without FFI
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
    75
# define TYPE_UINT      __get_ffi_type_uint()
0ea2a7e6bb41 calls without FFI
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
    76
# define TYPE_UINT8     __get_ffi_type_uint8()
0ea2a7e6bb41 calls without FFI
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
    77
# define TYPE_UINT16    __get_ffi_type_uint16()
0ea2a7e6bb41 calls without FFI
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
    78
# define TYPE_UINT32    __get_ffi_type_uint32()
0ea2a7e6bb41 calls without FFI
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
    79
# define TYPE_UINT64    __get_ffi_type_uint64()
0ea2a7e6bb41 calls without FFI
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
    80
0ea2a7e6bb41 calls without FFI
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
    81
# define TYPE_SINT      __get_ffi_type_sint()
0ea2a7e6bb41 calls without FFI
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
    82
# define TYPE_SINT8     __get_ffi_type_sint8()
0ea2a7e6bb41 calls without FFI
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
    83
# define TYPE_SINT16    __get_ffi_type_sint16()
0ea2a7e6bb41 calls without FFI
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
    84
# define TYPE_SINT32    __get_ffi_type_sint32()
0ea2a7e6bb41 calls without FFI
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
    85
# define TYPE_SINT64    __get_ffi_type_sint64()
0ea2a7e6bb41 calls without FFI
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
    86
0ea2a7e6bb41 calls without FFI
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
    87
# define TYPE_POINTER   __get_ffi_type_pointer()
19950
Claus Gittinger <cg@exept.de>
parents: 19933
diff changeset
    88
# define TYPE_FLOAT     __get_ffi_type_float()
Claus Gittinger <cg@exept.de>
parents: 19933
diff changeset
    89
# define TYPE_DOUBLE    __get_ffi_type_double()
Claus Gittinger <cg@exept.de>
parents: 19933
diff changeset
    90
# define TYPE_VOID      __get_ffi_type_void()
19931
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
#else /* NO FFI */
0ea2a7e6bb41 calls without FFI
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
    93
0ea2a7e6bb41 calls without FFI
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
    94
# define MAX_ARGS    15
0ea2a7e6bb41 calls without FFI
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
    95
# define TYPE_UINT      1
0ea2a7e6bb41 calls without FFI
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
    96
# define TYPE_UINT8     2
0ea2a7e6bb41 calls without FFI
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
    97
# define TYPE_UINT16    3
0ea2a7e6bb41 calls without FFI
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
    98
# define TYPE_UINT32    4
0ea2a7e6bb41 calls without FFI
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
    99
# define TYPE_UINT64    5
0ea2a7e6bb41 calls without FFI
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
   100
0ea2a7e6bb41 calls without FFI
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
   101
# define TYPE_SINT      11
0ea2a7e6bb41 calls without FFI
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
   102
# define TYPE_SINT8     12
0ea2a7e6bb41 calls without FFI
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
   103
# define TYPE_SINT16    13
0ea2a7e6bb41 calls without FFI
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
   104
# define TYPE_SINT32    14
0ea2a7e6bb41 calls without FFI
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
   105
# define TYPE_SINT64    15
0ea2a7e6bb41 calls without FFI
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
   106
0ea2a7e6bb41 calls without FFI
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
   107
# define TYPE_POINTER   20
0ea2a7e6bb41 calls without FFI
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
   108
# define TYPE_FLOAT     30
0ea2a7e6bb41 calls without FFI
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
   109
# define TYPE_DOUBLE    31
0ea2a7e6bb41 calls without FFI
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
   110
# define TYPE_VOID      40
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 FFI_DEFAULT_ABI        0
0ea2a7e6bb41 calls without FFI
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
   113
# define CALLTYPE_FFI_STDCALL   0
0ea2a7e6bb41 calls without FFI
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
   114
9337
ab6bbf58bf0a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9336
diff changeset
   115
#endif
9322
41c391bfbf03 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9321
diff changeset
   116
41c391bfbf03 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9321
diff changeset
   117
%}
41c391bfbf03 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9321
diff changeset
   118
! !
41c391bfbf03 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9321
diff changeset
   119
8728
d70396dc4e96 copyright
Claus Gittinger <cg@exept.de>
parents: 8550
diff changeset
   120
!ExternalLibraryFunction class methodsFor:'documentation'!
d70396dc4e96 copyright
Claus Gittinger <cg@exept.de>
parents: 8550
diff changeset
   121
d70396dc4e96 copyright
Claus Gittinger <cg@exept.de>
parents: 8550
diff changeset
   122
copyright
d70396dc4e96 copyright
Claus Gittinger <cg@exept.de>
parents: 8550
diff changeset
   123
"
d70396dc4e96 copyright
Claus Gittinger <cg@exept.de>
parents: 8550
diff changeset
   124
 COPYRIGHT (c) 2004 by eXept Software AG
9464
157fe6ca53e6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9463
diff changeset
   125
	      All Rights Reserved
8728
d70396dc4e96 copyright
Claus Gittinger <cg@exept.de>
parents: 8550
diff changeset
   126
d70396dc4e96 copyright
Claus Gittinger <cg@exept.de>
parents: 8550
diff changeset
   127
 This software is furnished under a license and may be used
d70396dc4e96 copyright
Claus Gittinger <cg@exept.de>
parents: 8550
diff changeset
   128
 only in accordance with the terms of that license and with the
d70396dc4e96 copyright
Claus Gittinger <cg@exept.de>
parents: 8550
diff changeset
   129
 inclusion of the above copyright notice.   This software may not
d70396dc4e96 copyright
Claus Gittinger <cg@exept.de>
parents: 8550
diff changeset
   130
 be provided or otherwise made available to, or used by, any
d70396dc4e96 copyright
Claus Gittinger <cg@exept.de>
parents: 8550
diff changeset
   131
 other person.  No title to or ownership of the software is
d70396dc4e96 copyright
Claus Gittinger <cg@exept.de>
parents: 8550
diff changeset
   132
 hereby transferred.
d70396dc4e96 copyright
Claus Gittinger <cg@exept.de>
parents: 8550
diff changeset
   133
"
9322
41c391bfbf03 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9321
diff changeset
   134
!
41c391bfbf03 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9321
diff changeset
   135
9331
c26a7de1468c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9330
diff changeset
   136
documentation
c26a7de1468c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9330
diff changeset
   137
"
c26a7de1468c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9330
diff changeset
   138
    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
   139
    Foreign function calls are based on the FFI library if available.
d45636ff51df #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 19932
diff changeset
   140
    A limited fallback implementation is provided for systems with no libffi.
d45636ff51df #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 19932
diff changeset
   141
    (this may have limitations on the supported argument types; for example,
d45636ff51df #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 19932
diff changeset
   142
     the x86_64 fallback does not support float/double arguments).
19950
Claus Gittinger <cg@exept.de>
parents: 19933
diff changeset
   143
    Therefore the fallback should be considered a temporary workaround,
19933
d45636ff51df #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 19932
diff changeset
   144
    until libffi has been ported.
19950
Claus Gittinger <cg@exept.de>
parents: 19933
diff changeset
   145
12680
b0661f4ef910 changed: #documentation
Claus Gittinger <cg@exept.de>
parents: 12657
diff changeset
   146
    Inside a method, when a special external-call pragma such as:
19950
Claus Gittinger <cg@exept.de>
parents: 19933
diff changeset
   147
	<api: bool MessageBeep(uint)>
12680
b0661f4ef910 changed: #documentation
Claus Gittinger <cg@exept.de>
parents: 12657
diff changeset
   148
b0661f4ef910 changed: #documentation
Claus Gittinger <cg@exept.de>
parents: 12657
diff changeset
   149
    is encountered by the parser, the compiler generates a call via
19950
Claus Gittinger <cg@exept.de>
parents: 19933
diff changeset
   150
	<correspondingExternalLibraryFunctionObject> invokeWithArguments: argumentArray.
19549
7ebabee7eecd #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 19536
diff changeset
   151
    and the correspondingExternalLibraryFunctionObject is kept in the literal array.
9331
c26a7de1468c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9330
diff changeset
   152
c26a7de1468c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9330
diff changeset
   153
    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
   154
    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
   155
    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
   156
b0661f4ef910 changed: #documentation
Claus Gittinger <cg@exept.de>
parents: 12657
diff changeset
   157
    The parser supports the call-syntax of various other smalltalk dialects:
19950
Claus Gittinger <cg@exept.de>
parents: 19933
diff changeset
   158
	Squeak / ST-X:
Claus Gittinger <cg@exept.de>
parents: 19933
diff changeset
   159
	    <cdecl:   [async] [virtual|nonVirtual][const] returnType functionNameStringOrIndex ( argType1..argTypeN ) module: moduleName >
Claus Gittinger <cg@exept.de>
parents: 19933
diff changeset
   160
	    <apicall: [async] [virtual|nonVirtual][const] returnType functionNameStringOrIndex ( argType1..argTypeN ) module: moduleName >
12680
b0661f4ef910 changed: #documentation
Claus Gittinger <cg@exept.de>
parents: 12657
diff changeset
   161
19950
Claus Gittinger <cg@exept.de>
parents: 19933
diff changeset
   162
	Dolphin:
Claus Gittinger <cg@exept.de>
parents: 19933
diff changeset
   163
	    <stdcall: [virtual|nonVirtual][const] returnType functionNameStringOrIndex argType1..argTypeN>
Claus Gittinger <cg@exept.de>
parents: 19933
diff changeset
   164
	    <cdecl:   [virtual|nonVirtual][const] returnType functionNameStringOrIndex argType1..argTypeN>
12680
b0661f4ef910 changed: #documentation
Claus Gittinger <cg@exept.de>
parents: 12657
diff changeset
   165
19950
Claus Gittinger <cg@exept.de>
parents: 19933
diff changeset
   166
	ST/V:
Claus Gittinger <cg@exept.de>
parents: 19933
diff changeset
   167
	    <api: functionName argType1 .. argTypeN returnType>
Claus Gittinger <cg@exept.de>
parents: 19933
diff changeset
   168
	    <ccall: functionName argType1 .. argTypeN returnType>
Claus Gittinger <cg@exept.de>
parents: 19933
diff changeset
   169
	    <ole: vFunctionIndex argType1 .. argTypeN returnType>
12680
b0661f4ef910 changed: #documentation
Claus Gittinger <cg@exept.de>
parents: 12657
diff changeset
   170
19950
Claus Gittinger <cg@exept.de>
parents: 19933
diff changeset
   171
	VisualWorks:
Claus Gittinger <cg@exept.de>
parents: 19933
diff changeset
   172
	    <c: ...>
Claus Gittinger <cg@exept.de>
parents: 19933
diff changeset
   173
	    <c: #define NAME value>
9331
c26a7de1468c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9330
diff changeset
   174
"
c26a7de1468c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9330
diff changeset
   175
!
c26a7de1468c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9330
diff changeset
   176
9322
41c391bfbf03 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9321
diff changeset
   177
example
41c391bfbf03 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9321
diff changeset
   178
"
14625
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
   179
								[exBegin]
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
   180
	|f|
14037
Michael Beyl <mb@exept.de>
parents: 13782
diff changeset
   181
14625
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
   182
	f := ExternalLibraryFunction new.
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
   183
	f beCallTypeWINAPI.
14037
Michael Beyl <mb@exept.de>
parents: 13782
diff changeset
   184
14625
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
   185
	f name:'MessageBeep'
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
   186
	  module:'user32.dll'
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
   187
	  returnType:#boolean
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
   188
	  argumentTypes:#(uint).
14037
Michael Beyl <mb@exept.de>
parents: 13782
diff changeset
   189
14625
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
   190
	f invokeWith:1.
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
   191
								[exEnd]
14037
Michael Beyl <mb@exept.de>
parents: 13782
diff changeset
   192
Michael Beyl <mb@exept.de>
parents: 13782
diff changeset
   193
  Synchronous vs. Asynchronous calls:
Michael Beyl <mb@exept.de>
parents: 13782
diff changeset
   194
14516
359e4d2234af class: ExternalLibraryFunction
Stefan Vogel <sv@exept.de>
parents: 14506
diff changeset
   195
    by default, foreign function calls are synchronous, effectively blocking the whole ST/X system
19514
7605a907a2eb #UI_ENHANCEMENT
Claus Gittinger <cg@exept.de>
parents: 19505
diff changeset
   196
    (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
   197
     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
   198
     access the data...).
14625
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
   199
    Therefore, the following will block all ST/X activity for 10 seconds
14037
Michael Beyl <mb@exept.de>
parents: 13782
diff changeset
   200
    (try interacting with the launcher while the Sleep is performing):
Michael Beyl <mb@exept.de>
parents: 13782
diff changeset
   201
14625
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
   202
								[exBegin]
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
   203
	|f|
9322
41c391bfbf03 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9321
diff changeset
   204
14625
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
   205
	f := ExternalLibraryFunction new.
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
   206
	f beCallTypeWINAPI.
14037
Michael Beyl <mb@exept.de>
parents: 13782
diff changeset
   207
14625
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
   208
	f name:'Sleep'
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
   209
	  module:'kernel32.dll'
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
   210
	  returnType:#void
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
   211
	  argumentTypes:#(uint).
14037
Michael Beyl <mb@exept.de>
parents: 13782
diff changeset
   212
14625
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
   213
	f invokeWith:10000.
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
   214
								[exEnd]
9322
41c391bfbf03 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9321
diff changeset
   215
14037
Michael Beyl <mb@exept.de>
parents: 13782
diff changeset
   216
    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
   217
    the call can be made asynchronous. In that case, ONLY the calling thread will be blocked; all other smalltalk
Michael Beyl <mb@exept.de>
parents: 13782
diff changeset
   218
    threads wil continue to execute.
Michael Beyl <mb@exept.de>
parents: 13782
diff changeset
   219
    (try interacting now with the launcher while the Sleep is performing):
14625
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
   220
								[exBegin]
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
   221
	|f|
14037
Michael Beyl <mb@exept.de>
parents: 13782
diff changeset
   222
14625
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
   223
	f := ExternalLibraryFunction new.
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
   224
	f beCallTypeWINAPI.
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
   225
	f beAsync.
14037
Michael Beyl <mb@exept.de>
parents: 13782
diff changeset
   226
14625
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
   227
	f name:'Sleep'
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
   228
	  module:'kernel32.dll'
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
   229
	  returnType:#void
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
   230
	  argumentTypes:#(uint).
14037
Michael Beyl <mb@exept.de>
parents: 13782
diff changeset
   231
14625
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
   232
	f invokeWith:10000.
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
   233
								[exEnd]
14037
Michael Beyl <mb@exept.de>
parents: 13782
diff changeset
   234
9322
41c391bfbf03 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9321
diff changeset
   235
"
8728
d70396dc4e96 copyright
Claus Gittinger <cg@exept.de>
parents: 8550
diff changeset
   236
! !
8533
9065c547ea75 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   237
8550
72982f85bd41 *** empty log message ***
ca
parents: 8533
diff changeset
   238
!ExternalLibraryFunction class methodsFor:'instance creation'!
72982f85bd41 *** empty log message ***
ca
parents: 8533
diff changeset
   239
9465
d11885052713 rewrite & cleanup
Claus Gittinger <cg@exept.de>
parents: 9464
diff changeset
   240
name:functionName module:moduleName returnType:returnType argumentTypes:argTypes
8550
72982f85bd41 *** empty log message ***
ca
parents: 8533
diff changeset
   241
    ^ self new
10025
053904a63549 stc-compiled ExternalLibraryFunctions
Claus Gittinger <cg@exept.de>
parents: 9981
diff changeset
   242
	name:functionName module:moduleName
053904a63549 stc-compiled ExternalLibraryFunctions
Claus Gittinger <cg@exept.de>
parents: 9981
diff changeset
   243
	returnType:returnType argumentTypes:argTypes
9465
d11885052713 rewrite & cleanup
Claus Gittinger <cg@exept.de>
parents: 9464
diff changeset
   244
d11885052713 rewrite & cleanup
Claus Gittinger <cg@exept.de>
parents: 9464
diff changeset
   245
    "Created: / 01-08-2006 / 15:19:08 / cg"
9463
864880338d7e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9460
diff changeset
   246
! !
864880338d7e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9460
diff changeset
   247
864880338d7e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9460
diff changeset
   248
!ExternalLibraryFunction class methodsFor:'class initialization'!
864880338d7e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9460
diff changeset
   249
11050
226b25e4bb97 comments
Claus Gittinger <cg@exept.de>
parents: 11013
diff changeset
   250
addToDllPath:aDirectoryPathName
226b25e4bb97 comments
Claus Gittinger <cg@exept.de>
parents: 11013
diff changeset
   251
    "can be used during initialization, to add more places for dll-loading"
226b25e4bb97 comments
Claus Gittinger <cg@exept.de>
parents: 11013
diff changeset
   252
19487
79d76a2de0f1 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 19483
diff changeset
   253
    |oldPath newPath|
11053
bcf4ebb25868 +removeFromDLLPath
Claus Gittinger <cg@exept.de>
parents: 11050
diff changeset
   254
bcf4ebb25868 +removeFromDLLPath
Claus Gittinger <cg@exept.de>
parents: 11050
diff changeset
   255
    oldPath := self dllPath.
bcf4ebb25868 +removeFromDLLPath
Claus Gittinger <cg@exept.de>
parents: 11050
diff changeset
   256
    (oldPath includes:aDirectoryPathName) ifFalse:[
19535
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
   257
	newPath := oldPath asOrderedCollection.
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
   258
	newPath add:aDirectoryPathName.
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
   259
	self dllPath:newPath
11053
bcf4ebb25868 +removeFromDLLPath
Claus Gittinger <cg@exept.de>
parents: 11050
diff changeset
   260
    ]
11050
226b25e4bb97 comments
Claus Gittinger <cg@exept.de>
parents: 11013
diff changeset
   261
!
226b25e4bb97 comments
Claus Gittinger <cg@exept.de>
parents: 11013
diff changeset
   262
14103
3df000b77712 class definition
Claus Gittinger <cg@exept.de>
parents: 14037
diff changeset
   263
dllMapping
3df000b77712 class definition
Claus Gittinger <cg@exept.de>
parents: 14037
diff changeset
   264
    "allows for dll's to be replaced,
3df000b77712 class definition
Claus Gittinger <cg@exept.de>
parents: 14037
diff changeset
   265
     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
   266
	C:\Program Files\Mozilla Firefox\mozsqlite3.dll
14103
3df000b77712 class definition
Claus Gittinger <cg@exept.de>
parents: 14037
diff changeset
   267
     for the sqlite3, execute:
19860
324edacff5cc unified cpu and os defines;
Claus Gittinger <cg@exept.de>
parents: 19549
diff changeset
   268
	ExternalLibraryFunction
324edacff5cc unified cpu and os defines;
Claus Gittinger <cg@exept.de>
parents: 19549
diff changeset
   269
	    dllMapping at:'sqlite3'
324edacff5cc unified cpu and os defines;
Claus Gittinger <cg@exept.de>
parents: 19549
diff changeset
   270
	    put: 'C:\Program Files\Mozilla Firefox\mozsqlite3.dll'
19549
7ebabee7eecd #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 19536
diff changeset
   271
     for mingw:
19860
324edacff5cc unified cpu and os defines;
Claus Gittinger <cg@exept.de>
parents: 19549
diff changeset
   272
	ExternalLibraryFunction
324edacff5cc unified cpu and os defines;
Claus Gittinger <cg@exept.de>
parents: 19549
diff changeset
   273
	    dllMapping at:'sqlite3'
324edacff5cc unified cpu and os defines;
Claus Gittinger <cg@exept.de>
parents: 19549
diff changeset
   274
	    put:'C:\mingw64\opt\bin\libsqlite3-0.dll'
14103
3df000b77712 class definition
Claus Gittinger <cg@exept.de>
parents: 14037
diff changeset
   275
    "
3df000b77712 class definition
Claus Gittinger <cg@exept.de>
parents: 14037
diff changeset
   276
3df000b77712 class definition
Claus Gittinger <cg@exept.de>
parents: 14037
diff changeset
   277
    DllMapping isNil ifTrue:[
19860
324edacff5cc unified cpu and os defines;
Claus Gittinger <cg@exept.de>
parents: 19549
diff changeset
   278
	DllMapping := Dictionary new.
14103
3df000b77712 class definition
Claus Gittinger <cg@exept.de>
parents: 14037
diff changeset
   279
    ].
3df000b77712 class definition
Claus Gittinger <cg@exept.de>
parents: 14037
diff changeset
   280
    ^ DllMapping
3df000b77712 class definition
Claus Gittinger <cg@exept.de>
parents: 14037
diff changeset
   281
3df000b77712 class definition
Claus Gittinger <cg@exept.de>
parents: 14037
diff changeset
   282
    "Created: / 10-04-2012 / 12:21:45 / cg"
3df000b77712 class definition
Claus Gittinger <cg@exept.de>
parents: 14037
diff changeset
   283
!
3df000b77712 class definition
Claus Gittinger <cg@exept.de>
parents: 14037
diff changeset
   284
10270
897474c6c785 allow setting the dllPath
fm
parents: 10213
diff changeset
   285
dllPath
19549
7ebabee7eecd #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 19536
diff changeset
   286
    "provide a default dllPath, where external libraries are searched for"
7ebabee7eecd #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 19536
diff changeset
   287
13337
d1733931bc10 changed:
Stefan Vogel <sv@exept.de>
parents: 13334
diff changeset
   288
    ^ DLLPATH
10270
897474c6c785 allow setting the dllPath
fm
parents: 10213
diff changeset
   289
!
897474c6c785 allow setting the dllPath
fm
parents: 10213
diff changeset
   290
897474c6c785 allow setting the dllPath
fm
parents: 10213
diff changeset
   291
dllPath:aCollectionOfDirectoryPathNames
19549
7ebabee7eecd #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 19536
diff changeset
   292
    "provide a default dllPath, where external libraries are searched for"
7ebabee7eecd #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 19536
diff changeset
   293
10270
897474c6c785 allow setting the dllPath
fm
parents: 10213
diff changeset
   294
    DLLPATH := aCollectionOfDirectoryPathNames
897474c6c785 allow setting the dllPath
fm
parents: 10213
diff changeset
   295
!
897474c6c785 allow setting the dllPath
fm
parents: 10213
diff changeset
   296
9463
864880338d7e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9460
diff changeset
   297
initialize
10025
053904a63549 stc-compiled ExternalLibraryFunctions
Claus Gittinger <cg@exept.de>
parents: 9981
diff changeset
   298
    "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
   299
d1733931bc10 changed:
Stefan Vogel <sv@exept.de>
parents: 13334
diff changeset
   300
    DLLPATH isNil ifTrue:[
14625
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
   301
	DLLPATH := #('.').
18228
061da222bd70 java support
Claus Gittinger <cg@exept.de>
parents: 15002
diff changeset
   302
%{
18240
28af09029a8b ifdef for SCHTEAM engine changed (not relevant for ST/X)
Claus Gittinger <cg@exept.de>
parents: 18228
diff changeset
   303
#ifndef __SCHTEAM__
18228
061da222bd70 java support
Claus Gittinger <cg@exept.de>
parents: 15002
diff changeset
   304
	@global(FLAG_VIRTUAL) = __MKSMALLINT(__EXTL_FLAG_VIRTUAL);                  // a virtual c++ call
061da222bd70 java support
Claus Gittinger <cg@exept.de>
parents: 15002
diff changeset
   305
	@global(FLAG_NONVIRTUAL) = __MKSMALLINT(__EXTL_FLAG_NONVIRTUAL);            // a non-virtual c++ call
061da222bd70 java support
Claus Gittinger <cg@exept.de>
parents: 15002
diff changeset
   306
	@global(FLAG_OBJECTIVEC) = __MKSMALLINT(__EXTL_FLAG_OBJECTIVEC);            // an objectiveC message send
061da222bd70 java support
Claus Gittinger <cg@exept.de>
parents: 15002
diff changeset
   307
	@global(FLAG_UNLIMITEDSTACK) = __MKSMALLINT(__EXTL_FLAG_UNLIMITEDSTACK);    // unlimitedstack under unix
061da222bd70 java support
Claus Gittinger <cg@exept.de>
parents: 15002
diff changeset
   308
	@global(FLAG_ASYNC) = __MKSMALLINT(__EXTL_FLAG_ASYNC);                      // async under win32
061da222bd70 java support
Claus Gittinger <cg@exept.de>
parents: 15002
diff changeset
   309
	@global(FLAG_RETVAL_IS_CONST) = __MKSMALLINT(__EXTL_FLAG_RETVAL_IS_CONST);  // return value is not to be registered for finalization
9463
864880338d7e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9460
diff changeset
   310
18228
061da222bd70 java support
Claus Gittinger <cg@exept.de>
parents: 15002
diff changeset
   311
	@global(CALLTYPE_API) = __MKSMALLINT(__EXTL_CALLTYPE_API);                  // WINAPI-call (win32 only)
061da222bd70 java support
Claus Gittinger <cg@exept.de>
parents: 15002
diff changeset
   312
	@global(CALLTYPE_C) = __MKSMALLINT(__EXTL_CALLTYPE_C);                      // regular C-call (the default)
061da222bd70 java support
Claus Gittinger <cg@exept.de>
parents: 15002
diff changeset
   313
	@global(CALLTYPE_V8) = __MKSMALLINT(__EXTL_CALLTYPE_V8);                    // v8 call (sparc only)
061da222bd70 java support
Claus Gittinger <cg@exept.de>
parents: 15002
diff changeset
   314
	@global(CALLTYPE_V9) = __MKSMALLINT(__EXTL_CALLTYPE_V9);                    // v9 call (sparc only)
061da222bd70 java support
Claus Gittinger <cg@exept.de>
parents: 15002
diff changeset
   315
	@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
   316
18228
061da222bd70 java support
Claus Gittinger <cg@exept.de>
parents: 15002
diff changeset
   317
	@global(CALLTYPE_MASK) = __MKSMALLINT(__EXTL_CALLTYPE_MASK);
061da222bd70 java support
Claus Gittinger <cg@exept.de>
parents: 15002
diff changeset
   318
#endif
061da222bd70 java support
Claus Gittinger <cg@exept.de>
parents: 15002
diff changeset
   319
%}
13337
d1733931bc10 changed:
Stefan Vogel <sv@exept.de>
parents: 13334
diff changeset
   320
    ].
9465
d11885052713 rewrite & cleanup
Claus Gittinger <cg@exept.de>
parents: 9464
diff changeset
   321
10025
053904a63549 stc-compiled ExternalLibraryFunctions
Claus Gittinger <cg@exept.de>
parents: 9981
diff changeset
   322
    "
053904a63549 stc-compiled ExternalLibraryFunctions
Claus Gittinger <cg@exept.de>
parents: 9981
diff changeset
   323
     self initialize
053904a63549 stc-compiled ExternalLibraryFunctions
Claus Gittinger <cg@exept.de>
parents: 9981
diff changeset
   324
    "
053904a63549 stc-compiled ExternalLibraryFunctions
Claus Gittinger <cg@exept.de>
parents: 9981
diff changeset
   325
053904a63549 stc-compiled ExternalLibraryFunctions
Claus Gittinger <cg@exept.de>
parents: 9981
diff changeset
   326
    "Modified: / 03-10-2006 / 21:27:47 / cg"
11053
bcf4ebb25868 +removeFromDLLPath
Claus Gittinger <cg@exept.de>
parents: 11050
diff changeset
   327
!
bcf4ebb25868 +removeFromDLLPath
Claus Gittinger <cg@exept.de>
parents: 11050
diff changeset
   328
bcf4ebb25868 +removeFromDLLPath
Claus Gittinger <cg@exept.de>
parents: 11050
diff changeset
   329
removeFromDllPath:aDirectoryPathName
bcf4ebb25868 +removeFromDLLPath
Claus Gittinger <cg@exept.de>
parents: 11050
diff changeset
   330
    "remove added places from dll-loading"
bcf4ebb25868 +removeFromDLLPath
Claus Gittinger <cg@exept.de>
parents: 11050
diff changeset
   331
bcf4ebb25868 +removeFromDLLPath
Claus Gittinger <cg@exept.de>
parents: 11050
diff changeset
   332
    |oldPath|
bcf4ebb25868 +removeFromDLLPath
Claus Gittinger <cg@exept.de>
parents: 11050
diff changeset
   333
bcf4ebb25868 +removeFromDLLPath
Claus Gittinger <cg@exept.de>
parents: 11050
diff changeset
   334
    oldPath := self dllPath.
bcf4ebb25868 +removeFromDLLPath
Claus Gittinger <cg@exept.de>
parents: 11050
diff changeset
   335
    self dllPath:(oldPath asOrderedCollection copyWithout:aDirectoryPathName)
bcf4ebb25868 +removeFromDLLPath
Claus Gittinger <cg@exept.de>
parents: 11050
diff changeset
   336
bcf4ebb25868 +removeFromDLLPath
Claus Gittinger <cg@exept.de>
parents: 11050
diff changeset
   337
    "
bcf4ebb25868 +removeFromDLLPath
Claus Gittinger <cg@exept.de>
parents: 11050
diff changeset
   338
     self dllPath.
11586
a3b2eef8a74c int vs. sint
Claus Gittinger <cg@exept.de>
parents: 11426
diff changeset
   339
     self addToDllPath:'C:\aaa\bbb'.
11053
bcf4ebb25868 +removeFromDLLPath
Claus Gittinger <cg@exept.de>
parents: 11050
diff changeset
   340
     self dllPath.
bcf4ebb25868 +removeFromDLLPath
Claus Gittinger <cg@exept.de>
parents: 11050
diff changeset
   341
     self removeFromDllPath:'C:\aaa\bbb'.
bcf4ebb25868 +removeFromDLLPath
Claus Gittinger <cg@exept.de>
parents: 11050
diff changeset
   342
     self dllPath.
bcf4ebb25868 +removeFromDLLPath
Claus Gittinger <cg@exept.de>
parents: 11050
diff changeset
   343
    "
8550
72982f85bd41 *** empty log message ***
ca
parents: 8533
diff changeset
   344
! !
72982f85bd41 *** empty log message ***
ca
parents: 8533
diff changeset
   345
9321
734c7c432461 not yet finished
Claus Gittinger <cg@exept.de>
parents: 8891
diff changeset
   346
!ExternalLibraryFunction class methodsFor:'constants'!
734c7c432461 not yet finished
Claus Gittinger <cg@exept.de>
parents: 8891
diff changeset
   347
734c7c432461 not yet finished
Claus Gittinger <cg@exept.de>
parents: 8891
diff changeset
   348
callTypeAPI
9463
864880338d7e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9460
diff changeset
   349
    ^ CALLTYPE_API
9321
734c7c432461 not yet finished
Claus Gittinger <cg@exept.de>
parents: 8891
diff changeset
   350
9463
864880338d7e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9460
diff changeset
   351
    "Modified: / 01-08-2006 / 13:44:41 / cg"
9435
68f7e39efad7 support of asynchronous calls
ca
parents: 9418
diff changeset
   352
!
68f7e39efad7 support of asynchronous calls
ca
parents: 9418
diff changeset
   353
9321
734c7c432461 not yet finished
Claus Gittinger <cg@exept.de>
parents: 8891
diff changeset
   354
callTypeC
9463
864880338d7e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9460
diff changeset
   355
    ^ CALLTYPE_C
9321
734c7c432461 not yet finished
Claus Gittinger <cg@exept.de>
parents: 8891
diff changeset
   356
9463
864880338d7e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9460
diff changeset
   357
    "Modified: / 01-08-2006 / 13:44:49 / cg"
9435
68f7e39efad7 support of asynchronous calls
ca
parents: 9418
diff changeset
   358
!
68f7e39efad7 support of asynchronous calls
ca
parents: 9418
diff changeset
   359
9321
734c7c432461 not yet finished
Claus Gittinger <cg@exept.de>
parents: 8891
diff changeset
   360
callTypeCDecl
9463
864880338d7e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9460
diff changeset
   361
    ^ CALLTYPE_C
9321
734c7c432461 not yet finished
Claus Gittinger <cg@exept.de>
parents: 8891
diff changeset
   362
9463
864880338d7e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9460
diff changeset
   363
    "Modified: / 01-08-2006 / 13:44:52 / cg"
9435
68f7e39efad7 support of asynchronous calls
ca
parents: 9418
diff changeset
   364
!
68f7e39efad7 support of asynchronous calls
ca
parents: 9418
diff changeset
   365
10619
dc8c965a8602 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10618
diff changeset
   366
callTypeMASK
dc8c965a8602 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10618
diff changeset
   367
    ^ CALLTYPE_MASK
dc8c965a8602 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10618
diff changeset
   368
dc8c965a8602 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10618
diff changeset
   369
    "Modified: / 01-08-2006 / 13:44:57 / cg"
dc8c965a8602 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10618
diff changeset
   370
!
dc8c965a8602 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10618
diff changeset
   371
9321
734c7c432461 not yet finished
Claus Gittinger <cg@exept.de>
parents: 8891
diff changeset
   372
callTypeOLE
9463
864880338d7e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9460
diff changeset
   373
    ^ CALLTYPE_OLE
9435
68f7e39efad7 support of asynchronous calls
ca
parents: 9418
diff changeset
   374
9463
864880338d7e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9460
diff changeset
   375
    "Modified: / 01-08-2006 / 13:44:57 / cg"
9321
734c7c432461 not yet finished
Claus Gittinger <cg@exept.de>
parents: 8891
diff changeset
   376
! !
734c7c432461 not yet finished
Claus Gittinger <cg@exept.de>
parents: 8891
diff changeset
   377
19505
3014e8447db8 #UI_ENHANCEMENT
Claus Gittinger <cg@exept.de>
parents: 19501
diff changeset
   378
!ExternalLibraryFunction class methodsFor:'debugging'!
3014e8447db8 #UI_ENHANCEMENT
Claus Gittinger <cg@exept.de>
parents: 19501
diff changeset
   379
3014e8447db8 #UI_ENHANCEMENT
Claus Gittinger <cg@exept.de>
parents: 19501
diff changeset
   380
verbose:aBoolean
3014e8447db8 #UI_ENHANCEMENT
Claus Gittinger <cg@exept.de>
parents: 19501
diff changeset
   381
    "turn on/off tracing of calls"
3014e8447db8 #UI_ENHANCEMENT
Claus Gittinger <cg@exept.de>
parents: 19501
diff changeset
   382
3014e8447db8 #UI_ENHANCEMENT
Claus Gittinger <cg@exept.de>
parents: 19501
diff changeset
   383
    Verbose := aBoolean
3014e8447db8 #UI_ENHANCEMENT
Claus Gittinger <cg@exept.de>
parents: 19501
diff changeset
   384
3014e8447db8 #UI_ENHANCEMENT
Claus Gittinger <cg@exept.de>
parents: 19501
diff changeset
   385
    "
3014e8447db8 #UI_ENHANCEMENT
Claus Gittinger <cg@exept.de>
parents: 19501
diff changeset
   386
     ExternalLibraryFunction verbose:true
3014e8447db8 #UI_ENHANCEMENT
Claus Gittinger <cg@exept.de>
parents: 19501
diff changeset
   387
    "
3014e8447db8 #UI_ENHANCEMENT
Claus Gittinger <cg@exept.de>
parents: 19501
diff changeset
   388
3014e8447db8 #UI_ENHANCEMENT
Claus Gittinger <cg@exept.de>
parents: 19501
diff changeset
   389
    "Created: / 30-03-2016 / 17:28:23 / cg"
3014e8447db8 #UI_ENHANCEMENT
Claus Gittinger <cg@exept.de>
parents: 19501
diff changeset
   390
! !
3014e8447db8 #UI_ENHANCEMENT
Claus Gittinger <cg@exept.de>
parents: 19501
diff changeset
   391
19490
4d29d49edd98 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 19489
diff changeset
   392
!ExternalLibraryFunction class methodsFor:'type name mapping'!
4d29d49edd98 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 19489
diff changeset
   393
4d29d49edd98 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 19489
diff changeset
   394
ffiTypeSymbolForType:aType
4d29d49edd98 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 19489
diff changeset
   395
    "map type to one of the ffi-supported ones:
19535
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
   396
	sint8, sint16, sint32, sint64
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
   397
	uint8, uint16, uint32, uint64
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
   398
	bool void pointer handle
19490
4d29d49edd98 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 19489
diff changeset
   399
    "
4d29d49edd98 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 19489
diff changeset
   400
4d29d49edd98 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 19489
diff changeset
   401
    aType == #sint8           ifTrue:[^ aType ].
4d29d49edd98 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 19489
diff changeset
   402
    aType == #sint16          ifTrue:[^ aType ].
4d29d49edd98 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 19489
diff changeset
   403
    aType == #sint32          ifTrue:[^ aType ].
4d29d49edd98 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 19489
diff changeset
   404
    aType == #sint64          ifTrue:[^ aType ].
4d29d49edd98 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 19489
diff changeset
   405
    aType == #uint8           ifTrue:[^ aType ].
4d29d49edd98 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 19489
diff changeset
   406
    aType == #uint16          ifTrue:[^ aType ].
4d29d49edd98 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 19489
diff changeset
   407
    aType == #uint32          ifTrue:[^ aType ].
4d29d49edd98 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 19489
diff changeset
   408
    aType == #uint64          ifTrue:[^ aType ].
4d29d49edd98 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 19489
diff changeset
   409
    aType == #double          ifTrue:[^ aType ].
4d29d49edd98 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 19489
diff changeset
   410
    aType == #float           ifTrue:[^ aType ].
4d29d49edd98 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 19489
diff changeset
   411
    aType == #char            ifTrue:[^ aType ].
4d29d49edd98 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 19489
diff changeset
   412
    aType == #void            ifTrue:[^ aType ].
4d29d49edd98 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 19489
diff changeset
   413
    aType == #bool            ifTrue:[^ aType ].
4d29d49edd98 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 19489
diff changeset
   414
    aType == #pointer         ifTrue:[^ aType ].
4d29d49edd98 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 19489
diff changeset
   415
    aType == #charPointer     ifTrue:[^ aType ].
4d29d49edd98 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 19489
diff changeset
   416
    aType == #wcharPointer    ifTrue:[^ aType ].
4d29d49edd98 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 19489
diff changeset
   417
4d29d49edd98 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 19489
diff changeset
   418
    aType == #int8            ifTrue:[^ #sint8 ].
4d29d49edd98 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 19489
diff changeset
   419
    aType == #int16           ifTrue:[^ #sint16 ].
4d29d49edd98 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 19489
diff changeset
   420
    aType == #int32           ifTrue:[^ #sint32 ].
4d29d49edd98 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 19489
diff changeset
   421
    aType == #int64           ifTrue:[^ #sint64 ].
4d29d49edd98 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 19489
diff changeset
   422
4d29d49edd98 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 19489
diff changeset
   423
    aType == #voidPointer         ifTrue:[^ #pointer ].
4d29d49edd98 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 19489
diff changeset
   424
    aType == #uint8Pointer        ifTrue:[^ #pointer ].
4d29d49edd98 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 19489
diff changeset
   425
    aType == #voidPointerPointer  ifTrue:[^ #pointer ].
4d29d49edd98 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 19489
diff changeset
   426
4d29d49edd98 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 19489
diff changeset
   427
    aType == #short           ifTrue:[^ #sint16 ].
4d29d49edd98 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 19489
diff changeset
   428
    aType == #long            ifTrue:[^ #long ].
4d29d49edd98 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 19489
diff changeset
   429
    aType == #int             ifTrue:[^ #int ].
4d29d49edd98 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 19489
diff changeset
   430
    aType == #uint            ifTrue:[^ #uint ].
4d29d49edd98 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 19489
diff changeset
   431
    aType == #ushort          ifTrue:[^ #uint16 ].
4d29d49edd98 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 19489
diff changeset
   432
    aType == #unsignedShort   ifTrue:[^ #uint16 ].
4d29d49edd98 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 19489
diff changeset
   433
    aType == #ulong           ifTrue:[^ #ulong ].
4d29d49edd98 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 19489
diff changeset
   434
    aType == #unsignedLong    ifTrue:[^ #ulong ].
4d29d49edd98 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 19489
diff changeset
   435
    aType == #uchar           ifTrue:[^ #uint8 ].
4d29d49edd98 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 19489
diff changeset
   436
    aType == #unsignedChar    ifTrue:[^ #uint8 ].
4d29d49edd98 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 19489
diff changeset
   437
    aType == #byte            ifTrue:[^ #uint8 ].
4d29d49edd98 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 19489
diff changeset
   438
    aType == #longlong        ifTrue:[^ #sint64 ].
4d29d49edd98 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 19489
diff changeset
   439
    aType == #longLong        ifTrue:[^ #sint64 ].
4d29d49edd98 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 19489
diff changeset
   440
    aType == #ulonglong       ifTrue:[^ #uint64 ].
4d29d49edd98 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 19489
diff changeset
   441
    aType == #ulongLong       ifTrue:[^ #uint64 ].
4d29d49edd98 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 19489
diff changeset
   442
4d29d49edd98 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 19489
diff changeset
   443
    "/ windefs
4d29d49edd98 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 19489
diff changeset
   444
    aType == #dword           ifTrue:[^ #uint32 ].
4d29d49edd98 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 19489
diff changeset
   445
    aType == #sdword          ifTrue:[^ #sint32 ].
4d29d49edd98 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 19489
diff changeset
   446
    aType == #word            ifTrue:[^ #uint16 ].
4d29d49edd98 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 19489
diff changeset
   447
    aType == #sword           ifTrue:[^ #sint16 ].
4d29d49edd98 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 19489
diff changeset
   448
    aType == #handle          ifTrue:[^ #pointer ].
4d29d49edd98 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 19489
diff changeset
   449
    aType == #lpstr           ifTrue:[^ #charPointer ].
19501
4922889c4309 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 19494
diff changeset
   450
    "/ aType == #hresult         ifTrue:[^ #uint32 ].  -- keep this; it is translated later (in invoke)
19490
4d29d49edd98 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 19489
diff changeset
   451
    aType == #boolean         ifTrue:[^ #bool ].
4d29d49edd98 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 19489
diff changeset
   452
    "/ care for 64bit machines
4d29d49edd98 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 19489
diff changeset
   453
    aType == #ulongReturn     ifTrue:[^ ExternalAddress pointerSize == 8 ifTrue:[#uint64] ifFalse:[#uint32]].
4d29d49edd98 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 19489
diff changeset
   454
    aType == #none            ifTrue:[^ #void ].
4d29d49edd98 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 19489
diff changeset
   455
    aType == #struct          ifTrue:[^ #pointer ].
4d29d49edd98 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 19489
diff changeset
   456
    aType == #structIn        ifTrue:[^ #pointer ].
4d29d49edd98 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 19489
diff changeset
   457
    aType == #structOut       ifTrue:[^ #pointer ].
4d29d49edd98 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 19489
diff changeset
   458
    aType == #structInOut     ifTrue:[^ #pointer ].
4d29d49edd98 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 19489
diff changeset
   459
    aType == #unsigned        ifTrue:[^ #uint ].
4d29d49edd98 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 19489
diff changeset
   460
4d29d49edd98 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 19489
diff changeset
   461
    aType == #ATOM            ifTrue:[^ #uint16 ].
4d29d49edd98 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 19489
diff changeset
   462
    aType == #BOOL            ifTrue:[^ #int ].
4d29d49edd98 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 19489
diff changeset
   463
    aType == #BOOLEAN         ifTrue:[^ #uint8 ].
4d29d49edd98 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 19489
diff changeset
   464
    aType == #BYTE            ifTrue:[^ #uint8 ].
4d29d49edd98 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 19489
diff changeset
   465
    aType == #DWORD           ifTrue:[^ #uint32 ].
4d29d49edd98 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 19489
diff changeset
   466
    aType == #HANDLE          ifTrue:[^ #pointer ].
19535
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
   467
    aType == #HRESULT         ifTrue:[^ #hresult ].
19501
4922889c4309 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 19494
diff changeset
   468
19490
4d29d49edd98 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 19489
diff changeset
   469
    "/ care for 64bit machines
4d29d49edd98 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 19489
diff changeset
   470
    aType == #SIZE_T          ifTrue:[^ ExternalAddress pointerSize == 8 ifTrue:[#uint64] ifFalse:[#uint32]].
19494
38815600ddbe #DOCUMENTATION
Claus Gittinger <cg@exept.de>
parents: 19490
diff changeset
   471
    aType == #BSTR            ifTrue:[^ #wcharPointer].
19490
4d29d49edd98 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 19489
diff changeset
   472
4d29d49edd98 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 19489
diff changeset
   473
    (aType isString or:[aType isSymbol]) ifFalse:[
19535
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
   474
	CType isNil ifTrue:[
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
   475
	    self error:'unknown type'.
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
   476
	].
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
   477
	^ aType typeSymbol.
19490
4d29d49edd98 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 19489
diff changeset
   478
    ].
4d29d49edd98 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 19489
diff changeset
   479
4d29d49edd98 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 19489
diff changeset
   480
    (aType endsWith:'*') ifTrue:[
19535
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
   481
	^ #pointer.
19490
4d29d49edd98 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 19489
diff changeset
   482
    ].
4d29d49edd98 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 19489
diff changeset
   483
    (aType endsWith:'Pointer') ifTrue:[
19535
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
   484
	^ #pointer.
19490
4d29d49edd98 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 19489
diff changeset
   485
    ].
4d29d49edd98 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 19489
diff changeset
   486
    ^ aType
4d29d49edd98 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 19489
diff changeset
   487
19501
4922889c4309 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 19494
diff changeset
   488
    "Modified (format): / 30-03-2016 / 13:45:09 / cg"
19490
4d29d49edd98 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 19489
diff changeset
   489
! !
4d29d49edd98 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 19489
diff changeset
   490
9321
734c7c432461 not yet finished
Claus Gittinger <cg@exept.de>
parents: 8891
diff changeset
   491
!ExternalLibraryFunction methodsFor:'accessing'!
734c7c432461 not yet finished
Claus Gittinger <cg@exept.de>
parents: 8891
diff changeset
   492
734c7c432461 not yet finished
Claus Gittinger <cg@exept.de>
parents: 8891
diff changeset
   493
argumentTypes
734c7c432461 not yet finished
Claus Gittinger <cg@exept.de>
parents: 8891
diff changeset
   494
    ^ argumentTypes
9463
864880338d7e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9460
diff changeset
   495
!
864880338d7e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9460
diff changeset
   496
11426
1fccae300393 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 11053
diff changeset
   497
argumentTypesString
11586
a3b2eef8a74c int vs. sint
Claus Gittinger <cg@exept.de>
parents: 11426
diff changeset
   498
    ^ String
a3b2eef8a74c int vs. sint
Claus Gittinger <cg@exept.de>
parents: 11426
diff changeset
   499
	streamContents:[:s |
a3b2eef8a74c int vs. sint
Claus Gittinger <cg@exept.de>
parents: 11426
diff changeset
   500
	    argumentTypes do:[:eachArgType |
a3b2eef8a74c int vs. sint
Claus Gittinger <cg@exept.de>
parents: 11426
diff changeset
   501
		eachArgType printOn:s.
a3b2eef8a74c int vs. sint
Claus Gittinger <cg@exept.de>
parents: 11426
diff changeset
   502
	    ] separatedBy:[
a3b2eef8a74c int vs. sint
Claus Gittinger <cg@exept.de>
parents: 11426
diff changeset
   503
		s nextPutAll:','.
a3b2eef8a74c int vs. sint
Claus Gittinger <cg@exept.de>
parents: 11426
diff changeset
   504
	    ].
a3b2eef8a74c int vs. sint
Claus Gittinger <cg@exept.de>
parents: 11426
diff changeset
   505
	].
11426
1fccae300393 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 11053
diff changeset
   506
!
1fccae300393 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 11053
diff changeset
   507
9463
864880338d7e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9460
diff changeset
   508
beAsync
864880338d7e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9460
diff changeset
   509
    "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
   510
     Ignored under unix/linux (until those support multiple threads too)."
864880338d7e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9460
diff changeset
   511
864880338d7e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9460
diff changeset
   512
    flags := (flags ? 0) bitOr: FLAG_ASYNC.
864880338d7e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9460
diff changeset
   513
864880338d7e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9460
diff changeset
   514
    "Created: / 01-08-2006 / 13:42:38 / cg"
864880338d7e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9460
diff changeset
   515
!
864880338d7e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9460
diff changeset
   516
9465
d11885052713 rewrite & cleanup
Claus Gittinger <cg@exept.de>
parents: 9464
diff changeset
   517
beCallTypeAPI
d11885052713 rewrite & cleanup
Claus Gittinger <cg@exept.de>
parents: 9464
diff changeset
   518
    flags := (flags ? 0) bitOr: CALLTYPE_API.
d11885052713 rewrite & cleanup
Claus Gittinger <cg@exept.de>
parents: 9464
diff changeset
   519
d11885052713 rewrite & cleanup
Claus Gittinger <cg@exept.de>
parents: 9464
diff changeset
   520
    "Created: / 01-08-2006 / 15:12:40 / cg"
d11885052713 rewrite & cleanup
Claus Gittinger <cg@exept.de>
parents: 9464
diff changeset
   521
!
d11885052713 rewrite & cleanup
Claus Gittinger <cg@exept.de>
parents: 9464
diff changeset
   522
d11885052713 rewrite & cleanup
Claus Gittinger <cg@exept.de>
parents: 9464
diff changeset
   523
beCallTypeC
d11885052713 rewrite & cleanup
Claus Gittinger <cg@exept.de>
parents: 9464
diff changeset
   524
    flags := (flags ? 0) bitOr: CALLTYPE_C.
d11885052713 rewrite & cleanup
Claus Gittinger <cg@exept.de>
parents: 9464
diff changeset
   525
d11885052713 rewrite & cleanup
Claus Gittinger <cg@exept.de>
parents: 9464
diff changeset
   526
    "Created: / 01-08-2006 / 15:12:40 / cg"
d11885052713 rewrite & cleanup
Claus Gittinger <cg@exept.de>
parents: 9464
diff changeset
   527
!
d11885052713 rewrite & cleanup
Claus Gittinger <cg@exept.de>
parents: 9464
diff changeset
   528
10481
b3526180579f +isExternalLibraryFunction
fm
parents: 10440
diff changeset
   529
beCallTypeOLE
b3526180579f +isExternalLibraryFunction
fm
parents: 10440
diff changeset
   530
    flags := (flags ? 0) bitOr: FLAG_VIRTUAL.
b3526180579f +isExternalLibraryFunction
fm
parents: 10440
diff changeset
   531
b3526180579f +isExternalLibraryFunction
fm
parents: 10440
diff changeset
   532
    "Created: / 01-08-2006 / 15:12:40 / cg"
b3526180579f +isExternalLibraryFunction
fm
parents: 10440
diff changeset
   533
!
b3526180579f +isExternalLibraryFunction
fm
parents: 10440
diff changeset
   534
9465
d11885052713 rewrite & cleanup
Claus Gittinger <cg@exept.de>
parents: 9464
diff changeset
   535
beCallTypeUNIX64
d11885052713 rewrite & cleanup
Claus Gittinger <cg@exept.de>
parents: 9464
diff changeset
   536
    flags := (flags ? 0) bitOr: CALLTYPE_UNIX64.
d11885052713 rewrite & cleanup
Claus Gittinger <cg@exept.de>
parents: 9464
diff changeset
   537
d11885052713 rewrite & cleanup
Claus Gittinger <cg@exept.de>
parents: 9464
diff changeset
   538
    "Created: / 01-08-2006 / 15:13:38 / cg"
d11885052713 rewrite & cleanup
Claus Gittinger <cg@exept.de>
parents: 9464
diff changeset
   539
!
d11885052713 rewrite & cleanup
Claus Gittinger <cg@exept.de>
parents: 9464
diff changeset
   540
d11885052713 rewrite & cleanup
Claus Gittinger <cg@exept.de>
parents: 9464
diff changeset
   541
beCallTypeV8
d11885052713 rewrite & cleanup
Claus Gittinger <cg@exept.de>
parents: 9464
diff changeset
   542
    flags := (flags ? 0) bitOr: CALLTYPE_V8.
d11885052713 rewrite & cleanup
Claus Gittinger <cg@exept.de>
parents: 9464
diff changeset
   543
d11885052713 rewrite & cleanup
Claus Gittinger <cg@exept.de>
parents: 9464
diff changeset
   544
    "Created: / 01-08-2006 / 15:13:28 / cg"
d11885052713 rewrite & cleanup
Claus Gittinger <cg@exept.de>
parents: 9464
diff changeset
   545
!
d11885052713 rewrite & cleanup
Claus Gittinger <cg@exept.de>
parents: 9464
diff changeset
   546
d11885052713 rewrite & cleanup
Claus Gittinger <cg@exept.de>
parents: 9464
diff changeset
   547
beCallTypeV9
d11885052713 rewrite & cleanup
Claus Gittinger <cg@exept.de>
parents: 9464
diff changeset
   548
    flags := (flags ? 0) bitOr: CALLTYPE_V9.
d11885052713 rewrite & cleanup
Claus Gittinger <cg@exept.de>
parents: 9464
diff changeset
   549
d11885052713 rewrite & cleanup
Claus Gittinger <cg@exept.de>
parents: 9464
diff changeset
   550
    "Created: / 01-08-2006 / 15:13:31 / cg"
d11885052713 rewrite & cleanup
Claus Gittinger <cg@exept.de>
parents: 9464
diff changeset
   551
!
d11885052713 rewrite & cleanup
Claus Gittinger <cg@exept.de>
parents: 9464
diff changeset
   552
d11885052713 rewrite & cleanup
Claus Gittinger <cg@exept.de>
parents: 9464
diff changeset
   553
beCallTypeWINAPI
d11885052713 rewrite & cleanup
Claus Gittinger <cg@exept.de>
parents: 9464
diff changeset
   554
    self beCallTypeAPI
d11885052713 rewrite & cleanup
Claus Gittinger <cg@exept.de>
parents: 9464
diff changeset
   555
d11885052713 rewrite & cleanup
Claus Gittinger <cg@exept.de>
parents: 9464
diff changeset
   556
    "Modified: / 01-08-2006 / 15:14:02 / cg"
d11885052713 rewrite & cleanup
Claus Gittinger <cg@exept.de>
parents: 9464
diff changeset
   557
!
d11885052713 rewrite & cleanup
Claus Gittinger <cg@exept.de>
parents: 9464
diff changeset
   558
9525
120234adc94e const specifier (is this a good name ?)
ca
parents: 9524
diff changeset
   559
beConstReturnValue
10025
053904a63549 stc-compiled ExternalLibraryFunctions
Claus Gittinger <cg@exept.de>
parents: 9981
diff changeset
   560
    "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
   561
     (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
   562
120234adc94e const specifier (is this a good name ?)
ca
parents: 9524
diff changeset
   563
    flags := (flags ? 0) bitOr: FLAG_RETVAL_IS_CONST.
120234adc94e const specifier (is this a good name ?)
ca
parents: 9524
diff changeset
   564
120234adc94e const specifier (is this a good name ?)
ca
parents: 9524
diff changeset
   565
    "Created: / 01-08-2006 / 13:56:48 / cg"
120234adc94e const specifier (is this a good name ?)
ca
parents: 9524
diff changeset
   566
!
120234adc94e const specifier (is this a good name ?)
ca
parents: 9524
diff changeset
   567
9463
864880338d7e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9460
diff changeset
   568
beNonVirtualCPP
864880338d7e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9460
diff changeset
   569
    "specify this as a non-virtual c++-function"
864880338d7e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9460
diff changeset
   570
864880338d7e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9460
diff changeset
   571
    flags := (flags ? 0) bitOr: FLAG_NONVIRTUAL.
864880338d7e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9460
diff changeset
   572
864880338d7e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9460
diff changeset
   573
    "Created: / 01-08-2006 / 13:56:44 / cg"
864880338d7e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9460
diff changeset
   574
!
864880338d7e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9460
diff changeset
   575
19311
6f1d1ea6dba8 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 18240
diff changeset
   576
beObjectiveC
6f1d1ea6dba8 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 18240
diff changeset
   577
    "specify this as an objective-c message send"
6f1d1ea6dba8 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 18240
diff changeset
   578
6f1d1ea6dba8 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 18240
diff changeset
   579
    flags := (flags ? 0) bitOr: FLAG_OBJECTIVEC.
6f1d1ea6dba8 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 18240
diff changeset
   580
6f1d1ea6dba8 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 18240
diff changeset
   581
    "Created: / 01-08-2006 / 13:56:48 / cg"
6f1d1ea6dba8 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 18240
diff changeset
   582
!
6f1d1ea6dba8 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 18240
diff changeset
   583
9463
864880338d7e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9460
diff changeset
   584
beUnlimitedStack
864880338d7e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9460
diff changeset
   585
    "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
   586
     for unlimited auto-sized-stack under unix/linux.
864880338d7e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9460
diff changeset
   587
     Ignored under windows."
864880338d7e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9460
diff changeset
   588
864880338d7e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9460
diff changeset
   589
    flags := (flags ? 0) bitOr: FLAG_UNLIMITEDSTACK.
864880338d7e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9460
diff changeset
   590
864880338d7e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9460
diff changeset
   591
    "Created: / 01-08-2006 / 13:41:54 / cg"
864880338d7e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9460
diff changeset
   592
!
864880338d7e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9460
diff changeset
   593
864880338d7e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9460
diff changeset
   594
beVirtualCPP
864880338d7e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9460
diff changeset
   595
    "specify this as a virtual c++-function"
864880338d7e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9460
diff changeset
   596
864880338d7e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9460
diff changeset
   597
    flags := (flags ? 0) bitOr: FLAG_VIRTUAL.
864880338d7e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9460
diff changeset
   598
864880338d7e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9460
diff changeset
   599
    "Created: / 01-08-2006 / 13:56:48 / cg"
864880338d7e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9460
diff changeset
   600
!
864880338d7e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9460
diff changeset
   601
9465
d11885052713 rewrite & cleanup
Claus Gittinger <cg@exept.de>
parents: 9464
diff changeset
   602
callTypeNumber
d11885052713 rewrite & cleanup
Claus Gittinger <cg@exept.de>
parents: 9464
diff changeset
   603
    ^ (flags ? 0) bitAnd: CALLTYPE_MASK.
d11885052713 rewrite & cleanup
Claus Gittinger <cg@exept.de>
parents: 9464
diff changeset
   604
d11885052713 rewrite & cleanup
Claus Gittinger <cg@exept.de>
parents: 9464
diff changeset
   605
    "Created: / 01-08-2006 / 15:12:10 / cg"
d11885052713 rewrite & cleanup
Claus Gittinger <cg@exept.de>
parents: 9464
diff changeset
   606
!
d11885052713 rewrite & cleanup
Claus Gittinger <cg@exept.de>
parents: 9464
diff changeset
   607
9463
864880338d7e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9460
diff changeset
   608
isAsync
864880338d7e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9460
diff changeset
   609
    "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
   610
864880338d7e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9460
diff changeset
   611
    ^ (flags ? 0) bitTest: FLAG_ASYNC.
864880338d7e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9460
diff changeset
   612
864880338d7e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9460
diff changeset
   613
    "Created: / 01-08-2006 / 13:46:53 / cg"
864880338d7e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9460
diff changeset
   614
!
864880338d7e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9460
diff changeset
   615
9519
ad18bf96758d *** empty log message ***
ca
parents: 9483
diff changeset
   616
isCPPFunction
ad18bf96758d *** empty log message ***
ca
parents: 9483
diff changeset
   617
    "is this a virtual or non-virtual c++-function ?"
ad18bf96758d *** empty log message ***
ca
parents: 9483
diff changeset
   618
ad18bf96758d *** empty log message ***
ca
parents: 9483
diff changeset
   619
    ^ (flags ? 0) bitTest: (FLAG_VIRTUAL bitOr: FLAG_NONVIRTUAL).
ad18bf96758d *** empty log message ***
ca
parents: 9483
diff changeset
   620
ad18bf96758d *** empty log message ***
ca
parents: 9483
diff changeset
   621
    "Created: / 01-08-2006 / 13:56:54 / cg"
ad18bf96758d *** empty log message ***
ca
parents: 9483
diff changeset
   622
!
ad18bf96758d *** empty log message ***
ca
parents: 9483
diff changeset
   623
9465
d11885052713 rewrite & cleanup
Claus Gittinger <cg@exept.de>
parents: 9464
diff changeset
   624
isCallTypeAPI
19490
4d29d49edd98 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 19489
diff changeset
   625
    "is this a windows API-call linkage call.
4d29d49edd98 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 19489
diff changeset
   626
     Attention: this uses a different call API (callee unwinds the stack),
4d29d49edd98 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 19489
diff changeset
   627
     and MUST be declared as such for many Kernel functions.
4d29d49edd98 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 19489
diff changeset
   628
     The calltype API is one of the worst historic garbage kept by MS..."
4d29d49edd98 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 19489
diff changeset
   629
9465
d11885052713 rewrite & cleanup
Claus Gittinger <cg@exept.de>
parents: 9464
diff changeset
   630
    ^ ((flags ? 0) bitAnd: CALLTYPE_MASK) == CALLTYPE_API.
d11885052713 rewrite & cleanup
Claus Gittinger <cg@exept.de>
parents: 9464
diff changeset
   631
d11885052713 rewrite & cleanup
Claus Gittinger <cg@exept.de>
parents: 9464
diff changeset
   632
    "Created: / 01-08-2006 / 15:21:16 / cg"
d11885052713 rewrite & cleanup
Claus Gittinger <cg@exept.de>
parents: 9464
diff changeset
   633
!
d11885052713 rewrite & cleanup
Claus Gittinger <cg@exept.de>
parents: 9464
diff changeset
   634
d11885052713 rewrite & cleanup
Claus Gittinger <cg@exept.de>
parents: 9464
diff changeset
   635
isCallTypeC
19490
4d29d49edd98 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 19489
diff changeset
   636
    "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
   637
9465
d11885052713 rewrite & cleanup
Claus Gittinger <cg@exept.de>
parents: 9464
diff changeset
   638
    ^ ((flags ? 0) bitAnd: CALLTYPE_MASK) == CALLTYPE_C.
d11885052713 rewrite & cleanup
Claus Gittinger <cg@exept.de>
parents: 9464
diff changeset
   639
d11885052713 rewrite & cleanup
Claus Gittinger <cg@exept.de>
parents: 9464
diff changeset
   640
    "Created: / 01-08-2006 / 15:21:23 / cg"
d11885052713 rewrite & cleanup
Claus Gittinger <cg@exept.de>
parents: 9464
diff changeset
   641
!
d11885052713 rewrite & cleanup
Claus Gittinger <cg@exept.de>
parents: 9464
diff changeset
   642
10483
79c64bcd4d29 +ole queries
fm
parents: 10481
diff changeset
   643
isCallTypeOLE
19490
4d29d49edd98 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 19489
diff changeset
   644
    "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
   645
10483
79c64bcd4d29 +ole queries
fm
parents: 10481
diff changeset
   646
    ^ ((flags ? 0) bitTest: FLAG_VIRTUAL).
79c64bcd4d29 +ole queries
fm
parents: 10481
diff changeset
   647
79c64bcd4d29 +ole queries
fm
parents: 10481
diff changeset
   648
    "Created: / 01-08-2006 / 15:21:23 / cg"
79c64bcd4d29 +ole queries
fm
parents: 10481
diff changeset
   649
!
79c64bcd4d29 +ole queries
fm
parents: 10481
diff changeset
   650
9525
120234adc94e const specifier (is this a good name ?)
ca
parents: 9524
diff changeset
   651
isConstReturnValue
10025
053904a63549 stc-compiled ExternalLibraryFunctions
Claus Gittinger <cg@exept.de>
parents: 9981
diff changeset
   652
    "is the pointer return value not to be finalized
9525
120234adc94e const specifier (is this a good name ?)
ca
parents: 9524
diff changeset
   653
     (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
   654
120234adc94e const specifier (is this a good name ?)
ca
parents: 9524
diff changeset
   655
    ^ (flags ? 0) bitTest: FLAG_RETVAL_IS_CONST.
120234adc94e const specifier (is this a good name ?)
ca
parents: 9524
diff changeset
   656
120234adc94e const specifier (is this a good name ?)
ca
parents: 9524
diff changeset
   657
    "Created: / 01-08-2006 / 13:56:48 / cg"
120234adc94e const specifier (is this a good name ?)
ca
parents: 9524
diff changeset
   658
!
120234adc94e const specifier (is this a good name ?)
ca
parents: 9524
diff changeset
   659
9463
864880338d7e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9460
diff changeset
   660
isNonVirtualCPP
864880338d7e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9460
diff changeset
   661
    "is this a non-virtual c++-function ?"
864880338d7e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9460
diff changeset
   662
864880338d7e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9460
diff changeset
   663
    ^ (flags ? 0) bitTest: FLAG_NONVIRTUAL.
864880338d7e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9460
diff changeset
   664
864880338d7e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9460
diff changeset
   665
    "Created: / 01-08-2006 / 13:56:51 / cg"
864880338d7e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9460
diff changeset
   666
!
864880338d7e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9460
diff changeset
   667
19311
6f1d1ea6dba8 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 18240
diff changeset
   668
isObjectiveC
6f1d1ea6dba8 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 18240
diff changeset
   669
    "is this an objective-C message?"
6f1d1ea6dba8 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 18240
diff changeset
   670
6f1d1ea6dba8 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 18240
diff changeset
   671
    ^ (flags ? 0) bitTest: FLAG_OBJECTIVEC.
6f1d1ea6dba8 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 18240
diff changeset
   672
!
6f1d1ea6dba8 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 18240
diff changeset
   673
9463
864880338d7e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9460
diff changeset
   674
isUnlimitedStack
864880338d7e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9460
diff changeset
   675
    "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
   676
     for unlimited auto-sized-stack under unix/linux.
864880338d7e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9460
diff changeset
   677
     Ignored under windows."
864880338d7e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9460
diff changeset
   678
864880338d7e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9460
diff changeset
   679
    ^ (flags ? 0) bitTest: FLAG_UNLIMITEDSTACK.
864880338d7e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9460
diff changeset
   680
864880338d7e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9460
diff changeset
   681
    "Created: / 01-08-2006 / 14:17:07 / cg"
864880338d7e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9460
diff changeset
   682
!
864880338d7e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9460
diff changeset
   683
864880338d7e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9460
diff changeset
   684
isVirtualCPP
19490
4d29d49edd98 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 19489
diff changeset
   685
    "is this a virtual c++-function (same as isCallTypeOLE) ?"
9463
864880338d7e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9460
diff changeset
   686
864880338d7e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9460
diff changeset
   687
    ^ (flags ? 0) bitTest: FLAG_VIRTUAL.
864880338d7e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9460
diff changeset
   688
864880338d7e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9460
diff changeset
   689
    "Created: / 01-08-2006 / 13:56:54 / cg"
10483
79c64bcd4d29 +ole queries
fm
parents: 10481
diff changeset
   690
!
79c64bcd4d29 +ole queries
fm
parents: 10481
diff changeset
   691
11426
1fccae300393 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 11053
diff changeset
   692
moduleName
1fccae300393 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 11053
diff changeset
   693
    ^ moduleName
1fccae300393 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 11053
diff changeset
   694
!
1fccae300393 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 11053
diff changeset
   695
10484
29039d89239d + returnType
fm
parents: 10483
diff changeset
   696
returnType
29039d89239d + returnType
fm
parents: 10483
diff changeset
   697
    ^ returnType
29039d89239d + returnType
fm
parents: 10483
diff changeset
   698
!
29039d89239d + returnType
fm
parents: 10483
diff changeset
   699
10483
79c64bcd4d29 +ole queries
fm
parents: 10481
diff changeset
   700
vtableIndex
79c64bcd4d29 +ole queries
fm
parents: 10481
diff changeset
   701
    name isNumber ifFalse:[^ nil].
79c64bcd4d29 +ole queries
fm
parents: 10481
diff changeset
   702
    ^ name.
9321
734c7c432461 not yet finished
Claus Gittinger <cg@exept.de>
parents: 8891
diff changeset
   703
! !
734c7c432461 not yet finished
Claus Gittinger <cg@exept.de>
parents: 8891
diff changeset
   704
8891
c30a030ff5ec more FFI (foreign function interface) support - still incomplete
Stefan Vogel <sv@exept.de>
parents: 8728
diff changeset
   705
!ExternalLibraryFunction methodsFor:'invoking'!
c30a030ff5ec more FFI (foreign function interface) support - still incomplete
Stefan Vogel <sv@exept.de>
parents: 8728
diff changeset
   706
c30a030ff5ec more FFI (foreign function interface) support - still incomplete
Stefan Vogel <sv@exept.de>
parents: 8728
diff changeset
   707
invoke
9321
734c7c432461 not yet finished
Claus Gittinger <cg@exept.de>
parents: 8891
diff changeset
   708
    self hasCode ifFalse:[
19314
698cf296ef6d mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents: 19313
diff changeset
   709
	self prepareInvoke.
8891
c30a030ff5ec more FFI (foreign function interface) support - still incomplete
Stefan Vogel <sv@exept.de>
parents: 8728
diff changeset
   710
    ].
19311
6f1d1ea6dba8 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 18240
diff changeset
   711
    ^ self invokeFFIwithArguments:nil forCPPInstance:nil
8891
c30a030ff5ec more FFI (foreign function interface) support - still incomplete
Stefan Vogel <sv@exept.de>
parents: 8728
diff changeset
   712
!
c30a030ff5ec more FFI (foreign function interface) support - still incomplete
Stefan Vogel <sv@exept.de>
parents: 8728
diff changeset
   713
9347
31adc57e6954 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9346
diff changeset
   714
invokeCPPVirtualOn:anInstance
9341
719fcf48695b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9340
diff changeset
   715
    self hasCode ifFalse:[
11586
a3b2eef8a74c int vs. sint
Claus Gittinger <cg@exept.de>
parents: 11426
diff changeset
   716
	self prepareInvoke.
9341
719fcf48695b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9340
diff changeset
   717
    ].
10440
b643af58f8bf invoking without arguments
fm
parents: 10279
diff changeset
   718
    ^ self invokeCPPVirtualFFIOn:anInstance withArguments:nil
9341
719fcf48695b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9340
diff changeset
   719
!
719fcf48695b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9340
diff changeset
   720
9347
31adc57e6954 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9346
diff changeset
   721
invokeCPPVirtualOn:instance with:arg
9341
719fcf48695b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9340
diff changeset
   722
    self hasCode ifFalse:[
10025
053904a63549 stc-compiled ExternalLibraryFunctions
Claus Gittinger <cg@exept.de>
parents: 9981
diff changeset
   723
	self prepareInvoke.
9341
719fcf48695b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9340
diff changeset
   724
    ].
9347
31adc57e6954 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9346
diff changeset
   725
    ^ self invokeCPPVirtualFFIOn:instance withArguments:(Array with:arg)
9341
719fcf48695b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9340
diff changeset
   726
!
719fcf48695b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9340
diff changeset
   727
9347
31adc57e6954 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9346
diff changeset
   728
invokeCPPVirtualOn:instance with:arg1 with:arg2
9341
719fcf48695b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9340
diff changeset
   729
    self hasCode ifFalse:[
10025
053904a63549 stc-compiled ExternalLibraryFunctions
Claus Gittinger <cg@exept.de>
parents: 9981
diff changeset
   730
	self prepareInvoke.
9341
719fcf48695b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9340
diff changeset
   731
    ].
9347
31adc57e6954 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9346
diff changeset
   732
    ^ self invokeCPPVirtualFFIOn:instance withArguments:(Array with:arg1 with:arg2)
9341
719fcf48695b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9340
diff changeset
   733
!
719fcf48695b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9340
diff changeset
   734
9347
31adc57e6954 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9346
diff changeset
   735
invokeCPPVirtualOn:instance with:arg1 with:arg2 with:arg3
9341
719fcf48695b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9340
diff changeset
   736
    self hasCode ifFalse:[
10025
053904a63549 stc-compiled ExternalLibraryFunctions
Claus Gittinger <cg@exept.de>
parents: 9981
diff changeset
   737
	self prepareInvoke.
9341
719fcf48695b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9340
diff changeset
   738
    ].
9347
31adc57e6954 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9346
diff changeset
   739
    ^ self invokeCPPVirtualFFIOn:instance withArguments:(Array with:arg1 with:arg2 with:arg3)
9341
719fcf48695b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9340
diff changeset
   740
!
719fcf48695b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9340
diff changeset
   741
9347
31adc57e6954 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9346
diff changeset
   742
invokeCPPVirtualOn:instance with:arg1 with:arg2 with:arg3 with:arg4
9341
719fcf48695b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9340
diff changeset
   743
    self hasCode ifFalse:[
10025
053904a63549 stc-compiled ExternalLibraryFunctions
Claus Gittinger <cg@exept.de>
parents: 9981
diff changeset
   744
	self prepareInvoke.
9341
719fcf48695b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9340
diff changeset
   745
    ].
9347
31adc57e6954 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9346
diff changeset
   746
    ^ self invokeCPPVirtualFFIOn:instance withArguments:(Array with:arg1 with:arg2 with:arg3 with:arg4)
9341
719fcf48695b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9340
diff changeset
   747
!
719fcf48695b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9340
diff changeset
   748
10481
b3526180579f +isExternalLibraryFunction
fm
parents: 10440
diff changeset
   749
invokeCPPVirtualOn:instance withArguments:args
b3526180579f +isExternalLibraryFunction
fm
parents: 10440
diff changeset
   750
    self hasCode ifFalse:[
11586
a3b2eef8a74c int vs. sint
Claus Gittinger <cg@exept.de>
parents: 11426
diff changeset
   751
	self prepareInvoke.
10481
b3526180579f +isExternalLibraryFunction
fm
parents: 10440
diff changeset
   752
    ].
b3526180579f +isExternalLibraryFunction
fm
parents: 10440
diff changeset
   753
    ^ self invokeCPPVirtualFFIOn:instance withArguments:args
b3526180579f +isExternalLibraryFunction
fm
parents: 10440
diff changeset
   754
!
b3526180579f +isExternalLibraryFunction
fm
parents: 10440
diff changeset
   755
8891
c30a030ff5ec more FFI (foreign function interface) support - still incomplete
Stefan Vogel <sv@exept.de>
parents: 8728
diff changeset
   756
invokeWith:arg
9321
734c7c432461 not yet finished
Claus Gittinger <cg@exept.de>
parents: 8891
diff changeset
   757
    self hasCode ifFalse:[
19314
698cf296ef6d mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents: 19313
diff changeset
   758
	self prepareInvoke.
9321
734c7c432461 not yet finished
Claus Gittinger <cg@exept.de>
parents: 8891
diff changeset
   759
    ].
19311
6f1d1ea6dba8 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 18240
diff changeset
   760
    ^ self invokeFFIwithArguments:(Array with:arg) forCPPInstance:nil
9321
734c7c432461 not yet finished
Claus Gittinger <cg@exept.de>
parents: 8891
diff changeset
   761
!
8891
c30a030ff5ec more FFI (foreign function interface) support - still incomplete
Stefan Vogel <sv@exept.de>
parents: 8728
diff changeset
   762
9321
734c7c432461 not yet finished
Claus Gittinger <cg@exept.de>
parents: 8891
diff changeset
   763
invokeWith:arg1 with:arg2
734c7c432461 not yet finished
Claus Gittinger <cg@exept.de>
parents: 8891
diff changeset
   764
    self hasCode ifFalse:[
19314
698cf296ef6d mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents: 19313
diff changeset
   765
	self prepareInvoke.
8891
c30a030ff5ec more FFI (foreign function interface) support - still incomplete
Stefan Vogel <sv@exept.de>
parents: 8728
diff changeset
   766
    ].
19311
6f1d1ea6dba8 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 18240
diff changeset
   767
    ^ self invokeFFIwithArguments:(Array with:arg1 with:arg2) forCPPInstance:nil
9321
734c7c432461 not yet finished
Claus Gittinger <cg@exept.de>
parents: 8891
diff changeset
   768
!
734c7c432461 not yet finished
Claus Gittinger <cg@exept.de>
parents: 8891
diff changeset
   769
734c7c432461 not yet finished
Claus Gittinger <cg@exept.de>
parents: 8891
diff changeset
   770
invokeWith:arg1 with:arg2 with:arg3
734c7c432461 not yet finished
Claus Gittinger <cg@exept.de>
parents: 8891
diff changeset
   771
    self hasCode ifFalse:[
19314
698cf296ef6d mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents: 19313
diff changeset
   772
	self prepareInvoke.
9321
734c7c432461 not yet finished
Claus Gittinger <cg@exept.de>
parents: 8891
diff changeset
   773
    ].
19311
6f1d1ea6dba8 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 18240
diff changeset
   774
    ^ self invokeFFIwithArguments:(Array with:arg1 with:arg2 with:arg3) forCPPInstance:nil
9321
734c7c432461 not yet finished
Claus Gittinger <cg@exept.de>
parents: 8891
diff changeset
   775
!
8891
c30a030ff5ec more FFI (foreign function interface) support - still incomplete
Stefan Vogel <sv@exept.de>
parents: 8728
diff changeset
   776
9321
734c7c432461 not yet finished
Claus Gittinger <cg@exept.de>
parents: 8891
diff changeset
   777
invokeWith:arg1 with:arg2 with:arg3 with:arg4
734c7c432461 not yet finished
Claus Gittinger <cg@exept.de>
parents: 8891
diff changeset
   778
    self hasCode ifFalse:[
19314
698cf296ef6d mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents: 19313
diff changeset
   779
	self prepareInvoke.
9321
734c7c432461 not yet finished
Claus Gittinger <cg@exept.de>
parents: 8891
diff changeset
   780
    ].
19311
6f1d1ea6dba8 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 18240
diff changeset
   781
    ^ self invokeFFIwithArguments:(Array with:arg1 with:arg2 with:arg3 with:arg4) forCPPInstance:nil
9321
734c7c432461 not yet finished
Claus Gittinger <cg@exept.de>
parents: 8891
diff changeset
   782
!
8891
c30a030ff5ec more FFI (foreign function interface) support - still incomplete
Stefan Vogel <sv@exept.de>
parents: 8728
diff changeset
   783
9321
734c7c432461 not yet finished
Claus Gittinger <cg@exept.de>
parents: 8891
diff changeset
   784
invokeWithArguments:argArray
734c7c432461 not yet finished
Claus Gittinger <cg@exept.de>
parents: 8891
diff changeset
   785
    self hasCode ifFalse:[
10025
053904a63549 stc-compiled ExternalLibraryFunctions
Claus Gittinger <cg@exept.de>
parents: 9981
diff changeset
   786
	self prepareInvoke.
9321
734c7c432461 not yet finished
Claus Gittinger <cg@exept.de>
parents: 8891
diff changeset
   787
    ].
9465
d11885052713 rewrite & cleanup
Claus Gittinger <cg@exept.de>
parents: 9464
diff changeset
   788
    ^ self invokeFFIwithArguments:argArray forCPPInstance:nil
d11885052713 rewrite & cleanup
Claus Gittinger <cg@exept.de>
parents: 9464
diff changeset
   789
d11885052713 rewrite & cleanup
Claus Gittinger <cg@exept.de>
parents: 9464
diff changeset
   790
    "Modified: / 01-08-2006 / 16:04:08 / cg"
9321
734c7c432461 not yet finished
Claus Gittinger <cg@exept.de>
parents: 8891
diff changeset
   791
! !
734c7c432461 not yet finished
Claus Gittinger <cg@exept.de>
parents: 8891
diff changeset
   792
734c7c432461 not yet finished
Claus Gittinger <cg@exept.de>
parents: 8891
diff changeset
   793
!ExternalLibraryFunction methodsFor:'printing'!
734c7c432461 not yet finished
Claus Gittinger <cg@exept.de>
parents: 8891
diff changeset
   794
734c7c432461 not yet finished
Claus Gittinger <cg@exept.de>
parents: 8891
diff changeset
   795
printOn:aStream
734c7c432461 not yet finished
Claus Gittinger <cg@exept.de>
parents: 8891
diff changeset
   796
    aStream nextPutAll:'<'.
9465
d11885052713 rewrite & cleanup
Claus Gittinger <cg@exept.de>
parents: 9464
diff changeset
   797
    self isCallTypeAPI ifTrue:[
14625
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
   798
	'API:' printOn:aStream.
9465
d11885052713 rewrite & cleanup
Claus Gittinger <cg@exept.de>
parents: 9464
diff changeset
   799
    ] ifFalse:[
14625
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
   800
	self isCallTypeOLE ifTrue:[
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
   801
	    'OLE:' printOn:aStream.
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
   802
	] ifFalse:[
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
   803
	    self isCallTypeC ifTrue:[
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
   804
		'C:' printOn:aStream.
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
   805
	    ] ifFalse:[
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
   806
		self error.
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
   807
	    ].
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
   808
	].
9465
d11885052713 rewrite & cleanup
Claus Gittinger <cg@exept.de>
parents: 9464
diff changeset
   809
    ].
9321
734c7c432461 not yet finished
Claus Gittinger <cg@exept.de>
parents: 8891
diff changeset
   810
    aStream nextPutAll:' '.
734c7c432461 not yet finished
Claus Gittinger <cg@exept.de>
parents: 8891
diff changeset
   811
    name printOn:aStream.
9465
d11885052713 rewrite & cleanup
Claus Gittinger <cg@exept.de>
parents: 9464
diff changeset
   812
    moduleName notNil ifTrue:[
14625
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
   813
	aStream nextPutAll:' module:'.
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
   814
	moduleName printOn:aStream.
9465
d11885052713 rewrite & cleanup
Claus Gittinger <cg@exept.de>
parents: 9464
diff changeset
   815
    ].
9321
734c7c432461 not yet finished
Claus Gittinger <cg@exept.de>
parents: 8891
diff changeset
   816
    aStream nextPutAll:'>'.
9465
d11885052713 rewrite & cleanup
Claus Gittinger <cg@exept.de>
parents: 9464
diff changeset
   817
14356
d0e1264c11fe changed: #printOn:
Claus Gittinger <cg@exept.de>
parents: 14103
diff changeset
   818
    "Modified: / 25-09-2012 / 12:06:14 / cg"
8891
c30a030ff5ec more FFI (foreign function interface) support - still incomplete
Stefan Vogel <sv@exept.de>
parents: 8728
diff changeset
   819
! !
c30a030ff5ec more FFI (foreign function interface) support - still incomplete
Stefan Vogel <sv@exept.de>
parents: 8728
diff changeset
   820
c30a030ff5ec more FFI (foreign function interface) support - still incomplete
Stefan Vogel <sv@exept.de>
parents: 8728
diff changeset
   821
!ExternalLibraryFunction methodsFor:'private'!
c30a030ff5ec more FFI (foreign function interface) support - still incomplete
Stefan Vogel <sv@exept.de>
parents: 8728
diff changeset
   822
10213
31717eee6fb2 changed #ffiTypeSymbolForType:
fm
parents: 10025
diff changeset
   823
adjustTypes
19490
4d29d49edd98 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 19489
diff changeset
   824
    "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
   825
     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
   826
     from various Smalltalk dialects' library function call declarations.
4d29d49edd98 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 19489
diff changeset
   827
     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
   828
     Also, this deals with pointer size differences."
4d29d49edd98 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 19489
diff changeset
   829
19313
4e56f471a6c3 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 19311
diff changeset
   830
    argumentTypes notEmptyOrNil ifTrue:[
19535
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
   831
	argumentTypes := argumentTypes collect:[:argType | self class ffiTypeSymbolForType:argType].
10213
31717eee6fb2 changed #ffiTypeSymbolForType:
fm
parents: 10025
diff changeset
   832
    ].
19490
4d29d49edd98 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 19489
diff changeset
   833
    returnType := self class ffiTypeSymbolForType:returnType.
10213
31717eee6fb2 changed #ffiTypeSymbolForType:
fm
parents: 10025
diff changeset
   834
!
31717eee6fb2 changed #ffiTypeSymbolForType:
fm
parents: 10025
diff changeset
   835
8891
c30a030ff5ec more FFI (foreign function interface) support - still incomplete
Stefan Vogel <sv@exept.de>
parents: 8728
diff changeset
   836
linkToModule
c30a030ff5ec more FFI (foreign function interface) support - still incomplete
Stefan Vogel <sv@exept.de>
parents: 8728
diff changeset
   837
    "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
   838
     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
   839
9465
d11885052713 rewrite & cleanup
Claus Gittinger <cg@exept.de>
parents: 9464
diff changeset
   840
    |handle moduleNameUsed functionName|
8891
c30a030ff5ec more FFI (foreign function interface) support - still incomplete
Stefan Vogel <sv@exept.de>
parents: 8728
diff changeset
   841
10481
b3526180579f +isExternalLibraryFunction
fm
parents: 10440
diff changeset
   842
    name isNumber ifTrue:[
19535
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
   843
	self isCPPFunction ifTrue:[
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
   844
	    "/ no need to load a dll.
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
   845
	    ^ self
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
   846
	]
10481
b3526180579f +isExternalLibraryFunction
fm
parents: 10440
diff changeset
   847
    ].
b3526180579f +isExternalLibraryFunction
fm
parents: 10440
diff changeset
   848
13782
1994fe87f21e comment/format in: #linkToModule
Claus Gittinger <cg@exept.de>
parents: 13412
diff changeset
   849
    "/ 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
   850
    "/ instead, the class provides the libraryName...
9465
d11885052713 rewrite & cleanup
Claus Gittinger <cg@exept.de>
parents: 9464
diff changeset
   851
    (moduleNameUsed := moduleName) isNil ifTrue:[
19535
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
   852
	owningClass isNil ifTrue:[
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
   853
	    self error:'Missing moduleName'.
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
   854
	].
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
   855
	moduleNameUsed := owningClass theNonMetaclass libraryName asSymbol.
9321
734c7c432461 not yet finished
Claus Gittinger <cg@exept.de>
parents: 8891
diff changeset
   856
    ].
11586
a3b2eef8a74c int vs. sint
Claus Gittinger <cg@exept.de>
parents: 11426
diff changeset
   857
    moduleHandle isNil ifTrue:[
19535
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
   858
	"/ speedup. in 95% of all calls, the same moduleName is resolved here
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
   859
	(LastModuleHandleHolder isNil
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
   860
	or:[ (handle := LastModuleHandleHolder at:1) isNil
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
   861
	or:[ LastModuleHandleName ~= moduleNameUsed ]]) ifTrue:[
19342
3afa63c8dcae #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19341
diff changeset
   862
19535
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
   863
	    handle := self loadLibrary:moduleNameUsed.
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
   864
	    handle isNil ifTrue:[
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
   865
		self error:('Cannot find or load dll/module: "%1"' bindWith: moduleNameUsed).
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
   866
	    ].
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
   867
	    LastModuleHandleHolder := WeakArray with:handle.
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
   868
	    LastModuleHandleName := moduleNameUsed.
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
   869
	].
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
   870
	moduleHandle := handle.
8891
c30a030ff5ec more FFI (foreign function interface) support - still incomplete
Stefan Vogel <sv@exept.de>
parents: 8728
diff changeset
   871
    ].
9341
719fcf48695b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9340
diff changeset
   872
    name isNumber ifFalse:[
19535
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
   873
	functionName := name.
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
   874
	(moduleHandle getFunctionAddress:functionName into:self) isNil ifTrue:[
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
   875
	    (moduleHandle getFunctionAddress:('_', functionName) into:self) isNil ifTrue:[
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
   876
		moduleHandle := nil.
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
   877
		self error:'Missing function: ', name, ' in module: ', moduleNameUsed.
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
   878
	    ].
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
   879
	].
9321
734c7c432461 not yet finished
Claus Gittinger <cg@exept.de>
parents: 8891
diff changeset
   880
    ].
9392
11914531960a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9386
diff changeset
   881
14103
3df000b77712 class definition
Claus Gittinger <cg@exept.de>
parents: 14037
diff changeset
   882
    "Modified: / 10-04-2012 / 12:12:44 / cg"
9321
734c7c432461 not yet finished
Claus Gittinger <cg@exept.de>
parents: 8891
diff changeset
   883
!
734c7c432461 not yet finished
Claus Gittinger <cg@exept.de>
parents: 8891
diff changeset
   884
10270
897474c6c785 allow setting the dllPath
fm
parents: 10213
diff changeset
   885
loadLibrary:dllName
19490
4d29d49edd98 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 19489
diff changeset
   886
    "load a dll.
4d29d49edd98 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 19489
diff changeset
   887
     Notice the dllMapping mechanism, which can be used to silently load different dlls.
4d29d49edd98 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 19489
diff changeset
   888
     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
   889
     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
   890
12436
92a968c9ca92 changed:
Claus Gittinger <cg@exept.de>
parents: 11586
diff changeset
   891
    |handle nameString filename|
10279
60c42983fdd4 first test whether the dllName is the complete filename
ca
parents: 10270
diff changeset
   892
14103
3df000b77712 class definition
Claus Gittinger <cg@exept.de>
parents: 14037
diff changeset
   893
    filename := dllName.
3df000b77712 class definition
Claus Gittinger <cg@exept.de>
parents: 14037
diff changeset
   894
    DllMapping notNil ifTrue:[
19535
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
   895
	filename := DllMapping at:filename ifAbsent:[ filename ]
14103
3df000b77712 class definition
Claus Gittinger <cg@exept.de>
parents: 14037
diff changeset
   896
    ].
3df000b77712 class definition
Claus Gittinger <cg@exept.de>
parents: 14037
diff changeset
   897
3df000b77712 class definition
Claus Gittinger <cg@exept.de>
parents: 14037
diff changeset
   898
    filename := filename asFilename.
12436
92a968c9ca92 changed:
Claus Gittinger <cg@exept.de>
parents: 11586
diff changeset
   899
    nameString := filename name.
10279
60c42983fdd4 first test whether the dllName is the complete filename
ca
parents: 10270
diff changeset
   900
12937
7d5f512fb14a changed: #loadLibrary:
Stefan Vogel <sv@exept.de>
parents: 12680
diff changeset
   901
    "try to load, maybe the system knows where to find the dll"
7d5f512fb14a changed: #loadLibrary:
Stefan Vogel <sv@exept.de>
parents: 12680
diff changeset
   902
    handle := ObjectFileLoader loadDynamicObject:filename.
7d5f512fb14a changed: #loadLibrary:
Stefan Vogel <sv@exept.de>
parents: 12680
diff changeset
   903
    handle notNil ifTrue:[^ handle ].
7d5f512fb14a changed: #loadLibrary:
Stefan Vogel <sv@exept.de>
parents: 12680
diff changeset
   904
12436
92a968c9ca92 changed:
Claus Gittinger <cg@exept.de>
parents: 11586
diff changeset
   905
    filename isAbsolute ifFalse:[
19535
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
   906
	"First ask the class defining the ExternalFunction for the location of the dlls ..."
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
   907
	owningClass notNil ifTrue:[
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
   908
	    owningClass dllPath do:[:eachDirectory |
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
   909
		handle := ObjectFileLoader
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
   910
			    loadDynamicObject:(eachDirectory asFilename construct:nameString) pathName.
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
   911
		handle notNil ifTrue:[^ handle ].
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
   912
	    ].
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
   913
	].
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
   914
	".. then ask the system"
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
   915
	self class dllPath do:[:eachDirectory |
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
   916
	    handle := ObjectFileLoader
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
   917
			loadDynamicObject:(eachDirectory asFilename construct:nameString) pathName.
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
   918
	    handle notNil ifTrue:[^ handle ].
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
   919
	].
10279
60c42983fdd4 first test whether the dllName is the complete filename
ca
parents: 10270
diff changeset
   920
    ].
10270
897474c6c785 allow setting the dllPath
fm
parents: 10213
diff changeset
   921
12436
92a968c9ca92 changed:
Claus Gittinger <cg@exept.de>
parents: 11586
diff changeset
   922
    filename suffix isEmpty ifTrue:[
19535
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
   923
	"/ try again with the OS-specific dll-extension
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
   924
	^ self loadLibrary:(filename withSuffix:ObjectFileLoader sharedLibrarySuffix)
10270
897474c6c785 allow setting the dllPath
fm
parents: 10213
diff changeset
   925
    ].
12436
92a968c9ca92 changed:
Claus Gittinger <cg@exept.de>
parents: 11586
diff changeset
   926
10270
897474c6c785 allow setting the dllPath
fm
parents: 10213
diff changeset
   927
    ^ nil
14103
3df000b77712 class definition
Claus Gittinger <cg@exept.de>
parents: 14037
diff changeset
   928
3df000b77712 class definition
Claus Gittinger <cg@exept.de>
parents: 14037
diff changeset
   929
    "Modified: / 10-04-2012 / 12:21:06 / cg"
10270
897474c6c785 allow setting the dllPath
fm
parents: 10213
diff changeset
   930
!
897474c6c785 allow setting the dllPath
fm
parents: 10213
diff changeset
   931
9321
734c7c432461 not yet finished
Claus Gittinger <cg@exept.de>
parents: 8891
diff changeset
   932
prepareInvoke
19490
4d29d49edd98 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 19489
diff changeset
   933
    "called before invoked.
19535
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
   934
     When called the very first time, moduleHandle is nil,
19490
4d29d49edd98 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 19489
diff changeset
   935
     and we ensure that the dll is loaded, the function address is extracted"
4d29d49edd98 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 19489
diff changeset
   936
10270
897474c6c785 allow setting the dllPath
fm
parents: 10213
diff changeset
   937
    (moduleHandle isNil or:[self hasCode not]) ifTrue:[
19535
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
   938
	self linkToModule.
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
   939
	self adjustTypes.
8891
c30a030ff5ec more FFI (foreign function interface) support - still incomplete
Stefan Vogel <sv@exept.de>
parents: 8728
diff changeset
   940
    ].
c30a030ff5ec more FFI (foreign function interface) support - still incomplete
Stefan Vogel <sv@exept.de>
parents: 8728
diff changeset
   941
! !
c30a030ff5ec more FFI (foreign function interface) support - still incomplete
Stefan Vogel <sv@exept.de>
parents: 8728
diff changeset
   942
8550
72982f85bd41 *** empty log message ***
ca
parents: 8533
diff changeset
   943
!ExternalLibraryFunction methodsFor:'private-accessing'!
72982f85bd41 *** empty log message ***
ca
parents: 8533
diff changeset
   944
9466
73333f358696 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9465
diff changeset
   945
name:functionNameOrVirtualIndex module:aModuleName returnType:aReturnType argumentTypes:argTypes
73333f358696 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9465
diff changeset
   946
    name := functionNameOrVirtualIndex.
73333f358696 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9465
diff changeset
   947
    functionNameOrVirtualIndex isNumber ifTrue:[
10025
053904a63549 stc-compiled ExternalLibraryFunctions
Claus Gittinger <cg@exept.de>
parents: 9981
diff changeset
   948
	self beVirtualCPP.
9466
73333f358696 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9465
diff changeset
   949
    ].
8891
c30a030ff5ec more FFI (foreign function interface) support - still incomplete
Stefan Vogel <sv@exept.de>
parents: 8728
diff changeset
   950
    moduleName := aModuleName.
c30a030ff5ec more FFI (foreign function interface) support - still incomplete
Stefan Vogel <sv@exept.de>
parents: 8728
diff changeset
   951
    returnType := aReturnType.
c30a030ff5ec more FFI (foreign function interface) support - still incomplete
Stefan Vogel <sv@exept.de>
parents: 8728
diff changeset
   952
    argumentTypes := argTypes.
9465
d11885052713 rewrite & cleanup
Claus Gittinger <cg@exept.de>
parents: 9464
diff changeset
   953
d11885052713 rewrite & cleanup
Claus Gittinger <cg@exept.de>
parents: 9464
diff changeset
   954
    "Created: / 01-08-2006 / 15:19:52 / cg"
9466
73333f358696 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9465
diff changeset
   955
    "Modified: / 02-08-2006 / 17:20:13 / cg"
9465
d11885052713 rewrite & cleanup
Claus Gittinger <cg@exept.de>
parents: 9464
diff changeset
   956
!
d11885052713 rewrite & cleanup
Claus Gittinger <cg@exept.de>
parents: 9464
diff changeset
   957
11426
1fccae300393 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 11053
diff changeset
   958
owningClass
1fccae300393 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 11053
diff changeset
   959
    ^ owningClass
1fccae300393 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 11053
diff changeset
   960
!
1fccae300393 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 11053
diff changeset
   961
9465
d11885052713 rewrite & cleanup
Claus Gittinger <cg@exept.de>
parents: 9464
diff changeset
   962
owningClass:aClass
d11885052713 rewrite & cleanup
Claus Gittinger <cg@exept.de>
parents: 9464
diff changeset
   963
    owningClass := aClass.
d11885052713 rewrite & cleanup
Claus Gittinger <cg@exept.de>
parents: 9464
diff changeset
   964
d11885052713 rewrite & cleanup
Claus Gittinger <cg@exept.de>
parents: 9464
diff changeset
   965
    "Created: / 01-08-2006 / 15:22:50 / cg"
10603
da9b7ed81caf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10514
diff changeset
   966
!
da9b7ed81caf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10514
diff changeset
   967
11586
a3b2eef8a74c int vs. sint
Claus Gittinger <cg@exept.de>
parents: 11426
diff changeset
   968
setModuleName:aModuleName
10603
da9b7ed81caf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10514
diff changeset
   969
    aModuleName ~= moduleName ifTrue:[
11586
a3b2eef8a74c int vs. sint
Claus Gittinger <cg@exept.de>
parents: 11426
diff changeset
   970
	self code:nil.
a3b2eef8a74c int vs. sint
Claus Gittinger <cg@exept.de>
parents: 11426
diff changeset
   971
	moduleHandle := nil.
a3b2eef8a74c int vs. sint
Claus Gittinger <cg@exept.de>
parents: 11426
diff changeset
   972
	moduleName := aModuleName.
10603
da9b7ed81caf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10514
diff changeset
   973
    ].
da9b7ed81caf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10514
diff changeset
   974
da9b7ed81caf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10514
diff changeset
   975
    "Created: / 07-06-2007 / 10:20:17 / cg"
8550
72982f85bd41 *** empty log message ***
ca
parents: 8533
diff changeset
   976
! !
72982f85bd41 *** empty log message ***
ca
parents: 8533
diff changeset
   977
9342
e548ce80ab02 virtual calls
Claus Gittinger <cg@exept.de>
parents: 9341
diff changeset
   978
!ExternalLibraryFunction methodsFor:'private-invoking'!
e548ce80ab02 virtual calls
Claus Gittinger <cg@exept.de>
parents: 9341
diff changeset
   979
9347
31adc57e6954 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9346
diff changeset
   980
invokeCPPVirtualFFIOn:instance withArguments:arguments
9463
864880338d7e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9460
diff changeset
   981
    ^ self invokeFFIwithArguments:arguments forCPPInstance:instance
864880338d7e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9460
diff changeset
   982
864880338d7e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9460
diff changeset
   983
    "Modified: / 01-08-2006 / 13:55:30 / cg"
9342
e548ce80ab02 virtual calls
Claus Gittinger <cg@exept.de>
parents: 9341
diff changeset
   984
!
e548ce80ab02 virtual calls
Claus Gittinger <cg@exept.de>
parents: 9341
diff changeset
   985
9347
31adc57e6954 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9346
diff changeset
   986
invokeFFIWithArguments:arguments
9463
864880338d7e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9460
diff changeset
   987
    ^ self invokeFFIwithArguments:arguments forCPPInstance:nil
864880338d7e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9460
diff changeset
   988
864880338d7e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9460
diff changeset
   989
    "Modified: / 01-08-2006 / 13:55:35 / cg"
9347
31adc57e6954 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9346
diff changeset
   990
!
31adc57e6954 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9346
diff changeset
   991
14659
410089913ca1 allow use of the standard (system) ffi
Claus Gittinger <cg@exept.de>
parents: 14632
diff changeset
   992
invokeFFIwithArguments:argumentsOrNil forCPPInstance:aReceiverOrNil
410089913ca1 allow use of the standard (system) ffi
Claus Gittinger <cg@exept.de>
parents: 14632
diff changeset
   993
    "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
   994
     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
   995
     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
   996
19341
2ab29dd7ec1a mingw 64bit fixes (xxLL in constants - sigh)
Claus Gittinger <cg@exept.de>
parents: 19334
diff changeset
   997
    |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
   998
     virtual objectiveC async unlimitedStack callTypeNumber returnValueClass argValueClass
410089913ca1 allow use of the standard (system) ffi
Claus Gittinger <cg@exept.de>
parents: 14632
diff changeset
   999
     oldReturnType oldArgumentTypes|
9342
e548ce80ab02 virtual calls
Claus Gittinger <cg@exept.de>
parents: 9341
diff changeset
  1000
10025
053904a63549 stc-compiled ExternalLibraryFunctions
Claus Gittinger <cg@exept.de>
parents: 9981
diff changeset
  1001
    argTypeSymbols := argumentTypes.
053904a63549 stc-compiled ExternalLibraryFunctions
Claus Gittinger <cg@exept.de>
parents: 9981
diff changeset
  1002
    returnTypeSymbol := returnType.
9346
a95e2cf0e56f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9344
diff changeset
  1003
10025
053904a63549 stc-compiled ExternalLibraryFunctions
Claus Gittinger <cg@exept.de>
parents: 9981
diff changeset
  1004
    virtual := self isVirtualCPP.
14659
410089913ca1 allow use of the standard (system) ffi
Claus Gittinger <cg@exept.de>
parents: 14632
diff changeset
  1005
    objectiveC := self isObjectiveC.
9524
2af286bbcac3 *** empty log message ***
ca
parents: 9519
diff changeset
  1006
    (virtual "or:[self isNonVirtualCPP]") ifTrue:[
19535
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1007
	aReceiverOrNil isNil ifTrue:[
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1008
	    "/ must have a c++ object instance
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1009
	    self primitiveFailed.
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1010
	].
9463
864880338d7e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9460
diff changeset
  1011
19535
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1012
	"/ and it must be a kind of ExternalStructure !!
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1013
	(aReceiverOrNil isKindOf:ExternalStructure) ifFalse:[
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1014
	    self primitiveFailed.
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1015
	].
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1016
	virtual ifTrue:[
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1017
	    vtOffset := name.
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1018
	    (vtOffset between:0 and:10000) ifFalse:[
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1019
		self primitiveFailed.
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1020
	    ]
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1021
	].
9463
864880338d7e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9460
diff changeset
  1022
    ] ifFalse:[
19535
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1023
	objectiveC ifTrue:[
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1024
	    aReceiverOrNil isNil ifTrue:[
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1025
		"/ must have an objective-c object instance
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1026
		self primitiveFailed.
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1027
	    ].
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1028
	    (aReceiverOrNil isObjectiveCObject) ifFalse:[
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1029
		self primitiveFailed
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1030
	    ]
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1031
	] ifFalse:[
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1032
	    aReceiverOrNil notNil ifTrue:[
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1033
		"/ must NOT have a c++/objectiveC object instance
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1034
		self primitiveFailed.
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1035
	    ]
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1036
	].
9342
e548ce80ab02 virtual calls
Claus Gittinger <cg@exept.de>
parents: 9341
diff changeset
  1037
    ].
9463
864880338d7e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9460
diff changeset
  1038
    async := self isAsync.
864880338d7e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9460
diff changeset
  1039
    unlimitedStack := self isUnlimitedStack.
9465
d11885052713 rewrite & cleanup
Claus Gittinger <cg@exept.de>
parents: 9464
diff changeset
  1040
    callTypeNumber := self callTypeNumber.
10512
5a01829213ab *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10484
diff changeset
  1041
    "/ Transcript show:name; show:' async:'; showCR:async.
9342
e548ce80ab02 virtual calls
Claus Gittinger <cg@exept.de>
parents: 9341
diff changeset
  1042
9459
6cd520c582b3 change from unlimited to big stack, to allow for interrupts to be handled
ca
parents: 9436
diff changeset
  1043
%{  /* STACK: 100000 */
14659
410089913ca1 allow use of the standard (system) ffi
Claus Gittinger <cg@exept.de>
parents: 14632
diff changeset
  1044
19931
0ea2a7e6bb41 calls without FFI
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
  1045
#define VERBOSE
0ea2a7e6bb41 calls without FFI
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
  1046
10025
053904a63549 stc-compiled ExternalLibraryFunctions
Claus Gittinger <cg@exept.de>
parents: 9981
diff changeset
  1047
#ifdef HAVE_FFI
19931
0ea2a7e6bb41 calls without FFI
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
  1048
12504
c9987bb76eb6 untested long long return value
Claus Gittinger <cg@exept.de>
parents: 12503
diff changeset
  1049
# ifdef __GNUC__
14659
410089913ca1 allow use of the standard (system) ffi
Claus Gittinger <cg@exept.de>
parents: 14632
diff changeset
  1050
#  ifndef HAS_LONGLONG
410089913ca1 allow use of the standard (system) ffi
Claus Gittinger <cg@exept.de>
parents: 14632
diff changeset
  1051
#   define HAS_LONGLONG
410089913ca1 allow use of the standard (system) ffi
Claus Gittinger <cg@exept.de>
parents: 14632
diff changeset
  1052
#  endif
12504
c9987bb76eb6 untested long long return value
Claus Gittinger <cg@exept.de>
parents: 12503
diff changeset
  1053
# endif
c9987bb76eb6 untested long long return value
Claus Gittinger <cg@exept.de>
parents: 12503
diff changeset
  1054
# if defined(__BORLANDC__) || defined(__VISUALC__)
c9987bb76eb6 untested long long return value
Claus Gittinger <cg@exept.de>
parents: 12503
diff changeset
  1055
#  define HAS_INT64
19364
4bf0b2b33b65 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 19357
diff changeset
  1056
#  ifndef __LO32
4bf0b2b33b65 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 19357
diff changeset
  1057
#   define __LO32(ll) ((ll) & 0xFFFFFFFFL)
4bf0b2b33b65 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 19357
diff changeset
  1058
#   define __HI32(ll) (((ll)>>32) & 0xFFFFFFFFL)
4bf0b2b33b65 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 19357
diff changeset
  1059
#  endif
12504
c9987bb76eb6 untested long long return value
Claus Gittinger <cg@exept.de>
parents: 12503
diff changeset
  1060
# endif
19931
0ea2a7e6bb41 calls without FFI
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
  1061
0ea2a7e6bb41 calls without FFI
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
  1062
9342
e548ce80ab02 virtual calls
Claus Gittinger <cg@exept.de>
parents: 9341
diff changeset
  1063
    ffi_cif __cif;
e548ce80ab02 virtual calls
Claus Gittinger <cg@exept.de>
parents: 9341
diff changeset
  1064
    ffi_type *__argTypesIncludingThis[MAX_ARGS+1];
e548ce80ab02 virtual calls
Claus Gittinger <cg@exept.de>
parents: 9341
diff changeset
  1065
    ffi_type **__argTypes = __argTypesIncludingThis;
e548ce80ab02 virtual calls
Claus Gittinger <cg@exept.de>
parents: 9341
diff changeset
  1066
    ffi_type *__returnType = NULL;
19931
0ea2a7e6bb41 calls without FFI
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
  1067
    ffi_type *thisType;
0ea2a7e6bb41 calls without FFI
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
  1068
    ffi_abi __callType = FFI_DEFAULT_ABI;
0ea2a7e6bb41 calls without FFI
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
  1069
0ea2a7e6bb41 calls without FFI
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
  1070
#else
0ea2a7e6bb41 calls without FFI
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
  1071
0ea2a7e6bb41 calls without FFI
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
  1072
    int __argTypesIncludingThis[MAX_ARGS+1];
0ea2a7e6bb41 calls without FFI
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
  1073
    int *__argTypes = __argTypesIncludingThis;
0ea2a7e6bb41 calls without FFI
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
  1074
    int __returnType = 0;
0ea2a7e6bb41 calls without FFI
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
  1075
    int thisType;
0ea2a7e6bb41 calls without FFI
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
  1076
    int __callType = FFI_DEFAULT_ABI;
19932
7fb01b7aff42 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 19931
diff changeset
  1077
    int __anyFloatOrDoubleArg = 0;
19931
0ea2a7e6bb41 calls without FFI
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
  1078
#endif
12504
c9987bb76eb6 untested long long return value
Claus Gittinger <cg@exept.de>
parents: 12503
diff changeset
  1079
9342
e548ce80ab02 virtual calls
Claus Gittinger <cg@exept.de>
parents: 9341
diff changeset
  1080
    union u {
19535
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1081
	INT iVal;
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1082
	float fVal;
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1083
	double dVal;
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1084
	void *pointerVal;
19365
83a120bf2212 Fix syntax error bug with gcc32
Stefan Vogel <sv@exept.de>
parents: 19364
diff changeset
  1085
# if 0 && defined(HAS_LONGLONG)
19535
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1086
	long long longLongVal;
12504
c9987bb76eb6 untested long long return value
Claus Gittinger <cg@exept.de>
parents: 12503
diff changeset
  1087
# else
19535
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1088
	__int64__ longLongVal;
12504
c9987bb76eb6 untested long long return value
Claus Gittinger <cg@exept.de>
parents: 12503
diff changeset
  1089
# endif
9342
e548ce80ab02 virtual calls
Claus Gittinger <cg@exept.de>
parents: 9341
diff changeset
  1090
    };
e548ce80ab02 virtual calls
Claus Gittinger <cg@exept.de>
parents: 9341
diff changeset
  1091
    union u __argValuesIncludingThis[MAX_ARGS+1];
e548ce80ab02 virtual calls
Claus Gittinger <cg@exept.de>
parents: 9341
diff changeset
  1092
    union u *__argValues = __argValuesIncludingThis;
e548ce80ab02 virtual calls
Claus Gittinger <cg@exept.de>
parents: 9341
diff changeset
  1093
    union u __returnValue;
e548ce80ab02 virtual calls
Claus Gittinger <cg@exept.de>
parents: 9341
diff changeset
  1094
    void *__argValuePointersIncludingThis[MAX_ARGS+1];
e548ce80ab02 virtual calls
Claus Gittinger <cg@exept.de>
parents: 9341
diff changeset
  1095
    void **__argValuePointers = __argValuePointersIncludingThis;
e548ce80ab02 virtual calls
Claus Gittinger <cg@exept.de>
parents: 9341
diff changeset
  1096
    void *__returnValuePointer;
e548ce80ab02 virtual calls
Claus Gittinger <cg@exept.de>
parents: 9341
diff changeset
  1097
    int __numArgs, __numArgsIncludingThis;
19311
6f1d1ea6dba8 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 18240
diff changeset
  1098
    static INT null = 0;
19341
2ab29dd7ec1a mingw 64bit fixes (xxLL in constants - sigh)
Claus Gittinger <cg@exept.de>
parents: 19334
diff changeset
  1099
    int i = -1;
9342
e548ce80ab02 virtual calls
Claus Gittinger <cg@exept.de>
parents: 9341
diff changeset
  1100
    VOIDFUNC codeAddress = (VOIDFUNC)__INST(code_);
10440
b643af58f8bf invoking without arguments
fm
parents: 10279
diff changeset
  1101
    int __numArgsWanted;
12579
516bba5b3e57 changed: #ffiTypeSymbolForType:
Claus Gittinger <cg@exept.de>
parents: 12504
diff changeset
  1102
12504
c9987bb76eb6 untested long long return value
Claus Gittinger <cg@exept.de>
parents: 12503
diff changeset
  1103
#   define __FAIL__(fcode) \
10603
da9b7ed81caf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10514
diff changeset
  1104
    { \
19535
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1105
	failureCode = fcode; failureArgNr = __mkSmallInteger(i+1); goto getOutOfHere; \
10603
da9b7ed81caf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10514
diff changeset
  1106
    }
9342
e548ce80ab02 virtual calls
Claus Gittinger <cg@exept.de>
parents: 9341
diff changeset
  1107
10440
b643af58f8bf invoking without arguments
fm
parents: 10279
diff changeset
  1108
    if (argumentsOrNil == nil) {
19535
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1109
	__numArgs = 0;
10440
b643af58f8bf invoking without arguments
fm
parents: 10279
diff changeset
  1110
    } else if (__isArray(argumentsOrNil)) {
19535
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1111
	__numArgs = __arraySize(argumentsOrNil);
9342
e548ce80ab02 virtual calls
Claus Gittinger <cg@exept.de>
parents: 9341
diff changeset
  1112
    } else {
19535
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1113
	__FAIL__(@symbol(BadArgumentVector))
10440
b643af58f8bf invoking without arguments
fm
parents: 10279
diff changeset
  1114
    }
b643af58f8bf invoking without arguments
fm
parents: 10279
diff changeset
  1115
    if (argTypeSymbols == nil) {
19535
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1116
	__numArgsWanted = 0;
10440
b643af58f8bf invoking without arguments
fm
parents: 10279
diff changeset
  1117
    } else if (__isArray(argTypeSymbols)) {
19535
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1118
	__numArgsWanted = __arraySize(argTypeSymbols);
10440
b643af58f8bf invoking without arguments
fm
parents: 10279
diff changeset
  1119
    } else {
19535
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1120
	__FAIL__(@symbol(BadArgumentTypeVector))
10440
b643af58f8bf invoking without arguments
fm
parents: 10279
diff changeset
  1121
    }
b643af58f8bf invoking without arguments
fm
parents: 10279
diff changeset
  1122
b643af58f8bf invoking without arguments
fm
parents: 10279
diff changeset
  1123
    if (__numArgs != __numArgsWanted) {
19535
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1124
	__FAIL__(@symbol(ArgumentCountMismatch))
9342
e548ce80ab02 virtual calls
Claus Gittinger <cg@exept.de>
parents: 9341
diff changeset
  1125
    }
e548ce80ab02 virtual calls
Claus Gittinger <cg@exept.de>
parents: 9341
diff changeset
  1126
    if (__numArgs > MAX_ARGS) {
19535
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1127
	__FAIL__(@symbol(TooManyArguments))
9342
e548ce80ab02 virtual calls
Claus Gittinger <cg@exept.de>
parents: 9341
diff changeset
  1128
    }
e548ce80ab02 virtual calls
Claus Gittinger <cg@exept.de>
parents: 9341
diff changeset
  1129
e548ce80ab02 virtual calls
Claus Gittinger <cg@exept.de>
parents: 9341
diff changeset
  1130
    /*
19501
4922889c4309 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 19494
diff changeset
  1131
     * validate the return type and map it to an ffi_type
9342
e548ce80ab02 virtual calls
Claus Gittinger <cg@exept.de>
parents: 9341
diff changeset
  1132
     */
e548ce80ab02 virtual calls
Claus Gittinger <cg@exept.de>
parents: 9341
diff changeset
  1133
    __returnValuePointer = &__returnValue;
9479
68d12a181d4a handle types; sint32 types.
ca
parents: 9466
diff changeset
  1134
9483
3bea515ce81e *** empty log message ***
fm
parents: 9479
diff changeset
  1135
    if (returnTypeSymbol == @symbol(voidPointer)) {
19535
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1136
	returnTypeSymbol = @symbol(handle);
19501
4922889c4309 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 19494
diff changeset
  1137
    } else if (returnTypeSymbol == @symbol(hresult)) {
19535
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1138
	returnTypeSymbol = @symbol(uint32);
9483
3bea515ce81e *** empty log message ***
fm
parents: 9479
diff changeset
  1139
    }
9479
68d12a181d4a handle types; sint32 types.
ca
parents: 9466
diff changeset
  1140
9342
e548ce80ab02 virtual calls
Claus Gittinger <cg@exept.de>
parents: 9341
diff changeset
  1141
    if (returnTypeSymbol == @symbol(int)) {
19931
0ea2a7e6bb41 calls without FFI
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
  1142
	__returnType = TYPE_SINT;
9342
e548ce80ab02 virtual calls
Claus Gittinger <cg@exept.de>
parents: 9341
diff changeset
  1143
    } else if (returnTypeSymbol == @symbol(uint)) {
19931
0ea2a7e6bb41 calls without FFI
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
  1144
	__returnType = TYPE_UINT;
9479
68d12a181d4a handle types; sint32 types.
ca
parents: 9466
diff changeset
  1145
    } else if (returnTypeSymbol == @symbol(uint8)) {
19931
0ea2a7e6bb41 calls without FFI
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
  1146
	__returnType = TYPE_UINT8;
9479
68d12a181d4a handle types; sint32 types.
ca
parents: 9466
diff changeset
  1147
    } else if (returnTypeSymbol == @symbol(uint16)) {
19931
0ea2a7e6bb41 calls without FFI
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
  1148
	__returnType = TYPE_UINT16;
9479
68d12a181d4a handle types; sint32 types.
ca
parents: 9466
diff changeset
  1149
    } else if (returnTypeSymbol == @symbol(uint32)) {
19931
0ea2a7e6bb41 calls without FFI
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
  1150
	__returnType = TYPE_UINT32;
9479
68d12a181d4a handle types; sint32 types.
ca
parents: 9466
diff changeset
  1151
    } else if (returnTypeSymbol == @symbol(uint64)) {
19931
0ea2a7e6bb41 calls without FFI
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
  1152
	__returnType = TYPE_UINT64;
9479
68d12a181d4a handle types; sint32 types.
ca
parents: 9466
diff changeset
  1153
68d12a181d4a handle types; sint32 types.
ca
parents: 9466
diff changeset
  1154
    } else if (returnTypeSymbol == @symbol(sint)) {
19931
0ea2a7e6bb41 calls without FFI
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
  1155
	__returnType = TYPE_SINT;
9479
68d12a181d4a handle types; sint32 types.
ca
parents: 9466
diff changeset
  1156
    } else if (returnTypeSymbol == @symbol(sint8)) {
19931
0ea2a7e6bb41 calls without FFI
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
  1157
	__returnType = TYPE_SINT8;
9479
68d12a181d4a handle types; sint32 types.
ca
parents: 9466
diff changeset
  1158
    } else if (returnTypeSymbol == @symbol(sint16)) {
19931
0ea2a7e6bb41 calls without FFI
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
  1159
	__returnType = TYPE_SINT16;
9479
68d12a181d4a handle types; sint32 types.
ca
parents: 9466
diff changeset
  1160
    } else if (returnTypeSymbol == @symbol(sint32)) {
19931
0ea2a7e6bb41 calls without FFI
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
  1161
	__returnType = TYPE_SINT32;
9479
68d12a181d4a handle types; sint32 types.
ca
parents: 9466
diff changeset
  1162
    } else if (returnTypeSymbol == @symbol(sint64)) {
19931
0ea2a7e6bb41 calls without FFI
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
  1163
	__returnType = TYPE_SINT64;
9479
68d12a181d4a handle types; sint32 types.
ca
parents: 9466
diff changeset
  1164
9342
e548ce80ab02 virtual calls
Claus Gittinger <cg@exept.de>
parents: 9341
diff changeset
  1165
    } else if (returnTypeSymbol == @symbol(long)) {
19535
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1166
	if (sizeof(long) == 4) {
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1167
	   returnTypeSymbol = @symbol(sint32);
19931
0ea2a7e6bb41 calls without FFI
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
  1168
	   __returnType = TYPE_SINT32;
19535
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1169
	} else if (sizeof(long) == 8) {
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1170
	   returnTypeSymbol = @symbol(sint64);
19931
0ea2a7e6bb41 calls without FFI
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
  1171
	   __returnType = TYPE_SINT64;
19535
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1172
	} else {
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1173
	    __FAIL__(@symbol(UnknownReturnType))
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1174
	}
9479
68d12a181d4a handle types; sint32 types.
ca
parents: 9466
diff changeset
  1175
9342
e548ce80ab02 virtual calls
Claus Gittinger <cg@exept.de>
parents: 9341
diff changeset
  1176
    } else if (returnTypeSymbol == @symbol(ulong)) {
19535
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1177
	if (sizeof(long) == 4) {
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1178
	   returnTypeSymbol = @symbol(uint32);
19931
0ea2a7e6bb41 calls without FFI
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
  1179
	   __returnType = TYPE_UINT32;
19535
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1180
	}else if (sizeof(long) == 8) {
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1181
	   returnTypeSymbol = @symbol(uint64);
19931
0ea2a7e6bb41 calls without FFI
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
  1182
	   __returnType = TYPE_UINT64;
19535
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1183
	} else {
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1184
	    __FAIL__(@symbol(UnknownReturnType))
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1185
	}
9479
68d12a181d4a handle types; sint32 types.
ca
parents: 9466
diff changeset
  1186
10025
053904a63549 stc-compiled ExternalLibraryFunctions
Claus Gittinger <cg@exept.de>
parents: 9981
diff changeset
  1187
    } else if (returnTypeSymbol == @symbol(bool)) {
19931
0ea2a7e6bb41 calls without FFI
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
  1188
	__returnType = TYPE_UINT;
9479
68d12a181d4a handle types; sint32 types.
ca
parents: 9466
diff changeset
  1189
9342
e548ce80ab02 virtual calls
Claus Gittinger <cg@exept.de>
parents: 9341
diff changeset
  1190
    } else if (returnTypeSymbol == @symbol(float)) {
19931
0ea2a7e6bb41 calls without FFI
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
  1191
	__returnType = TYPE_FLOAT;
9342
e548ce80ab02 virtual calls
Claus Gittinger <cg@exept.de>
parents: 9341
diff changeset
  1192
    } else if (returnTypeSymbol == @symbol(double)) {
19931
0ea2a7e6bb41 calls without FFI
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
  1193
	__returnType = TYPE_DOUBLE;
9479
68d12a181d4a handle types; sint32 types.
ca
parents: 9466
diff changeset
  1194
9342
e548ce80ab02 virtual calls
Claus Gittinger <cg@exept.de>
parents: 9341
diff changeset
  1195
    } else if (returnTypeSymbol == @symbol(void)) {
19931
0ea2a7e6bb41 calls without FFI
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
  1196
	__returnType = TYPE_VOID;
19535
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1197
	__returnValuePointer = NULL;
11586
a3b2eef8a74c int vs. sint
Claus Gittinger <cg@exept.de>
parents: 11426
diff changeset
  1198
    } else if ((returnTypeSymbol == @symbol(pointer))
19535
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1199
	       || (returnTypeSymbol == @symbol(handle))
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1200
	       || (returnTypeSymbol == @symbol(charPointer))
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1201
	       || (returnTypeSymbol == @symbol(bytePointer))
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1202
	       || (returnTypeSymbol == @symbol(floatPointer))
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1203
	       || (returnTypeSymbol == @symbol(doublePointer))
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1204
	       || (returnTypeSymbol == @symbol(intPointer))
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1205
	       || (returnTypeSymbol == @symbol(shortPointer))
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1206
	       || (returnTypeSymbol == @symbol(wcharPointer))) {
19931
0ea2a7e6bb41 calls without FFI
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
  1207
	__returnType = TYPE_POINTER;
9342
e548ce80ab02 virtual calls
Claus Gittinger <cg@exept.de>
parents: 9341
diff changeset
  1208
    } else {
19535
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1209
	if (__isSymbol(returnTypeSymbol)
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1210
	 && ((returnValueClass = __GLOBAL_GET(returnTypeSymbol)) != nil)) {
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1211
	    if (! __isBehaviorLike(returnValueClass)) {
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1212
		__FAIL__(@symbol(NonBehaviorReturnType))
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1213
	    }
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1214
	    if (! __qIsSubclassOfExternalAddress(returnValueClass)) {
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1215
		__FAIL__(@symbol(NonExternalAddressReturnType))
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1216
	    }
19931
0ea2a7e6bb41 calls without FFI
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
  1217
	    __returnType = TYPE_POINTER;
19535
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1218
	    returnTypeSymbol = @symbol(pointer);
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1219
	} else {
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1220
	    __FAIL__(@symbol(UnknownReturnType))
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1221
	}
9342
e548ce80ab02 virtual calls
Claus Gittinger <cg@exept.de>
parents: 9341
diff changeset
  1222
    }
e548ce80ab02 virtual calls
Claus Gittinger <cg@exept.de>
parents: 9341
diff changeset
  1223
e548ce80ab02 virtual calls
Claus Gittinger <cg@exept.de>
parents: 9341
diff changeset
  1224
    /*
e548ce80ab02 virtual calls
Claus Gittinger <cg@exept.de>
parents: 9341
diff changeset
  1225
     * validate the c++ object
e548ce80ab02 virtual calls
Claus Gittinger <cg@exept.de>
parents: 9341
diff changeset
  1226
     */
14659
410089913ca1 allow use of the standard (system) ffi
Claus Gittinger <cg@exept.de>
parents: 14632
diff changeset
  1227
    if (aReceiverOrNil != nil) {
19535
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1228
	struct cPlusPlusInstance {
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1229
	    void **vTable;
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1230
	};
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1231
	struct cPlusPlusInstance *inst;
9342
e548ce80ab02 virtual calls
Claus Gittinger <cg@exept.de>
parents: 9341
diff changeset
  1232
19535
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1233
	if (__isExternalAddressLike(aReceiverOrNil)) {
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1234
	    inst = (void *)(__externalAddressVal(aReceiverOrNil));
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1235
	} else if (__isExternalBytesLike(aReceiverOrNil)) {
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1236
	    inst = (void *)(__externalBytesVal(aReceiverOrNil));
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1237
	} else {
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1238
	    __FAIL__(@symbol(InvalidInstance))
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1239
	}
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1240
	__argValues[0].pointerVal = inst;
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1241
	__argValuePointersIncludingThis[0] = &(__argValues[0]);
19931
0ea2a7e6bb41 calls without FFI
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
  1242
	__argTypes[0] = TYPE_POINTER;
9342
e548ce80ab02 virtual calls
Claus Gittinger <cg@exept.de>
parents: 9341
diff changeset
  1243
19535
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1244
	__argValuePointers = &__argValuePointersIncludingThis[1];
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1245
	__argTypes = &__argTypesIncludingThis[1];
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1246
	__argValues = &__argValuesIncludingThis[1];
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1247
	__numArgsIncludingThis = __numArgs + 1;
9347
31adc57e6954 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9346
diff changeset
  1248
19535
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1249
	if (virtual == true) {
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1250
	    if (! __isSmallInteger(vtOffset)) {
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1251
		__FAIL__(@symbol(InvalidVTableIndex))
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1252
	    }
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1253
	    codeAddress = inst->vTable[__intVal(vtOffset)];
12504
c9987bb76eb6 untested long long return value
Claus Gittinger <cg@exept.de>
parents: 12503
diff changeset
  1254
# ifdef VERBOSE
19535
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1255
	    if (@global(Verbose) == true) {
19931
0ea2a7e6bb41 calls without FFI
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
  1256
		printf("virtual %"_ld_" codeAddress: %"_lx_"\n", (INT)(__intVal(vtOffset)), (INT)codeAddress);
19535
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1257
	    }
12504
c9987bb76eb6 untested long long return value
Claus Gittinger <cg@exept.de>
parents: 12503
diff changeset
  1258
# endif
19535
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1259
	}
9342
e548ce80ab02 virtual calls
Claus Gittinger <cg@exept.de>
parents: 9341
diff changeset
  1260
    } else {
19535
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1261
	__numArgsIncludingThis = __numArgs;
12504
c9987bb76eb6 untested long long return value
Claus Gittinger <cg@exept.de>
parents: 12503
diff changeset
  1262
# ifdef VERBOSE
19535
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1263
	if (@global(Verbose) == true) {
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1264
	    printf("codeAddress: %"_lx_"\n", (INT)codeAddress);
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1265
	}
12504
c9987bb76eb6 untested long long return value
Claus Gittinger <cg@exept.de>
parents: 12503
diff changeset
  1266
# endif
9342
e548ce80ab02 virtual calls
Claus Gittinger <cg@exept.de>
parents: 9341
diff changeset
  1267
    }
e548ce80ab02 virtual calls
Claus Gittinger <cg@exept.de>
parents: 9341
diff changeset
  1268
e548ce80ab02 virtual calls
Claus Gittinger <cg@exept.de>
parents: 9341
diff changeset
  1269
    /*
19501
4922889c4309 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 19494
diff changeset
  1270
     * 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
  1271
     */
e548ce80ab02 virtual calls
Claus Gittinger <cg@exept.de>
parents: 9341
diff changeset
  1272
    for (i=0; i<__numArgs; i++) {
19535
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1273
	void *argValuePtr;
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1274
	OBJ typeSymbol;
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1275
	OBJ arg;
9342
e548ce80ab02 virtual calls
Claus Gittinger <cg@exept.de>
parents: 9341
diff changeset
  1276
19535
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1277
	failureInfo = __mkSmallInteger(i+1);   /* in case there is one */
9465
d11885052713 rewrite & cleanup
Claus Gittinger <cg@exept.de>
parents: 9464
diff changeset
  1278
19535
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1279
	typeSymbol = __ArrayInstPtr(argTypeSymbols)->a_element[i];
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1280
	arg = __ArrayInstPtr(argumentsOrNil)->a_element[i];
9342
e548ce80ab02 virtual calls
Claus Gittinger <cg@exept.de>
parents: 9341
diff changeset
  1281
19535
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1282
	if (typeSymbol == @symbol(handle)) {
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1283
	    typeSymbol = @symbol(pointer);
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1284
	} else if (typeSymbol == @symbol(voidPointer)) {
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1285
	    typeSymbol = @symbol(pointer);
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1286
	} else if (returnTypeSymbol == @symbol(hresult)) {
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1287
	    typeSymbol = @symbol(uint32);
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1288
	}
9479
68d12a181d4a handle types; sint32 types.
ca
parents: 9466
diff changeset
  1289
19535
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1290
	if (typeSymbol == @symbol(long)) {
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1291
	    if (sizeof(long) == sizeof(int)) {
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1292
		typeSymbol = @symbol(sint);
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1293
	    } else {
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1294
		if (sizeof(long) == 4) {
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1295
		    typeSymbol = @symbol(sint32);
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1296
		} else if (sizeof(long) == 8) {
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1297
		    typeSymbol = @symbol(sint64);
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1298
		}
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1299
	    }
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1300
	}
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1301
	if (typeSymbol == @symbol(ulong)) {
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1302
	    if (sizeof(unsigned long) == sizeof(unsigned int)) {
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1303
		typeSymbol = @symbol(uint);
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1304
	    } else {
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1305
		if (sizeof(long) == 4) {
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1306
		    typeSymbol = @symbol(uint32);
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1307
		} else if (sizeof(long) == 8) {
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1308
		    typeSymbol = @symbol(uint64);
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1309
		}
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1310
	    }
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1311
	}
9342
e548ce80ab02 virtual calls
Claus Gittinger <cg@exept.de>
parents: 9341
diff changeset
  1312
19535
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1313
	if (typeSymbol == @symbol(int) || typeSymbol == @symbol(sint)) {
19931
0ea2a7e6bb41 calls without FFI
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
  1314
	    thisType = TYPE_SINT;
19535
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1315
	    if (__isSmallInteger(arg)) {
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1316
		__argValues[i].iVal = __intVal(arg);
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1317
	    } else {
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1318
		__argValues[i].iVal = __signedLongIntVal(arg);
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1319
		if (__argValues[i].iVal == 0) {
19341
2ab29dd7ec1a mingw 64bit fixes (xxLL in constants - sigh)
Claus Gittinger <cg@exept.de>
parents: 19334
diff changeset
  1320
# ifdef VERBOSE
19535
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1321
			if (@global(Verbose) == true) {
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1322
			    printf("invalidArgument: arg%d sint value out of range [%d]\n", i+1, __LINE__);
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1323
			}
19341
2ab29dd7ec1a mingw 64bit fixes (xxLL in constants - sigh)
Claus Gittinger <cg@exept.de>
parents: 19334
diff changeset
  1324
# endif
19535
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1325
		    __FAIL__(@symbol(InvalidArgument))
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1326
		}
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1327
	    }
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1328
	    argValuePtr = &(__argValues[i].iVal);
9479
68d12a181d4a handle types; sint32 types.
ca
parents: 9466
diff changeset
  1329
19535
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1330
	} else if (typeSymbol == @symbol(uint)) {
19931
0ea2a7e6bb41 calls without FFI
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
  1331
	    thisType = TYPE_UINT;
9342
e548ce80ab02 virtual calls
Claus Gittinger <cg@exept.de>
parents: 9341
diff changeset
  1332
19535
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1333
	    if (__isSmallInteger(arg)) {
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1334
		__argValues[i].iVal = __intVal(arg);
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1335
	    } else {
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1336
		__argValues[i].iVal = __unsignedLongIntVal(arg);
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1337
		if (__argValues[i].iVal == 0) {
19341
2ab29dd7ec1a mingw 64bit fixes (xxLL in constants - sigh)
Claus Gittinger <cg@exept.de>
parents: 19334
diff changeset
  1338
# ifdef VERBOSE
19535
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1339
			if (@global(Verbose) == true) {
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1340
			    printf("invalidArgument: arg%d uint value out of range [%d]\n", i+1, __LINE__);
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1341
			}
19341
2ab29dd7ec1a mingw 64bit fixes (xxLL in constants - sigh)
Claus Gittinger <cg@exept.de>
parents: 19334
diff changeset
  1342
# endif
19535
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1343
		    __FAIL__(@symbol(InvalidArgument))
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1344
		}
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1345
	    }
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1346
	    argValuePtr = &(__argValues[i].iVal);
9479
68d12a181d4a handle types; sint32 types.
ca
parents: 9466
diff changeset
  1347
19535
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1348
	} else if (typeSymbol == @symbol(uint8)) {
19931
0ea2a7e6bb41 calls without FFI
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
  1349
	    thisType = TYPE_UINT8;
19535
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1350
	    if (! __isSmallInteger(arg)) {
19341
2ab29dd7ec1a mingw 64bit fixes (xxLL in constants - sigh)
Claus Gittinger <cg@exept.de>
parents: 19334
diff changeset
  1351
# ifdef VERBOSE
19535
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1352
		if (@global(Verbose) == true) {
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1353
		    printf("invalidArgument: arg%d uint8 value out of range [%d]\n", i+1, __LINE__);
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1354
		}
19341
2ab29dd7ec1a mingw 64bit fixes (xxLL in constants - sigh)
Claus Gittinger <cg@exept.de>
parents: 19334
diff changeset
  1355
# endif
19535
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1356
		__FAIL__(@symbol(InvalidArgument))
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1357
	    }
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1358
	    __argValues[i].iVal = __intVal(arg);
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1359
	    if (((unsigned)(__argValues[i].iVal)) > 0xFF) {
19341
2ab29dd7ec1a mingw 64bit fixes (xxLL in constants - sigh)
Claus Gittinger <cg@exept.de>
parents: 19334
diff changeset
  1360
# ifdef VERBOSE
19535
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1361
		if (@global(Verbose) == true) {
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1362
		    printf("invalidArgument: arg%d uint8 value out of range [%d]\n", i+1, __LINE__);
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1363
		}
19341
2ab29dd7ec1a mingw 64bit fixes (xxLL in constants - sigh)
Claus Gittinger <cg@exept.de>
parents: 19334
diff changeset
  1364
# endif
19535
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1365
		__FAIL__(@symbol(InvalidArgument))
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1366
	    }
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1367
	    argValuePtr = &(__argValues[i].iVal);
9479
68d12a181d4a handle types; sint32 types.
ca
parents: 9466
diff changeset
  1368
19535
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1369
	} else if (typeSymbol == @symbol(sint8)) {
19931
0ea2a7e6bb41 calls without FFI
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
  1370
	    thisType = TYPE_SINT8;
19535
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1371
	    if (! __isSmallInteger(arg)) {
19341
2ab29dd7ec1a mingw 64bit fixes (xxLL in constants - sigh)
Claus Gittinger <cg@exept.de>
parents: 19334
diff changeset
  1372
# ifdef VERBOSE
19535
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1373
		if (@global(Verbose) == true) {
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1374
		    printf("invalidArgument: arg%d sint8 value out of range [%d]\n", i+1, __LINE__);
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1375
		}
19341
2ab29dd7ec1a mingw 64bit fixes (xxLL in constants - sigh)
Claus Gittinger <cg@exept.de>
parents: 19334
diff changeset
  1376
# endif
19535
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1377
		__FAIL__(@symbol(InvalidArgument))
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1378
	    }
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1379
	    __argValues[i].iVal = __intVal(arg);
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1380
	    if (((__argValues[i].iVal) < -0x80) || ((__argValues[i].iVal) > 0x7F))  {
19341
2ab29dd7ec1a mingw 64bit fixes (xxLL in constants - sigh)
Claus Gittinger <cg@exept.de>
parents: 19334
diff changeset
  1381
# ifdef VERBOSE
19535
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1382
		if (@global(Verbose) == true) {
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1383
		    printf("invalidArgument: arg%d sint8 value out of range [%d]\n", i+1, __LINE__);
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1384
		}
19341
2ab29dd7ec1a mingw 64bit fixes (xxLL in constants - sigh)
Claus Gittinger <cg@exept.de>
parents: 19334
diff changeset
  1385
# endif
19535
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1386
		__FAIL__(@symbol(InvalidArgument))
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1387
	    }
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1388
	    argValuePtr = &(__argValues[i].iVal);
9479
68d12a181d4a handle types; sint32 types.
ca
parents: 9466
diff changeset
  1389
19535
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1390
	} else if (typeSymbol == @symbol(uint16)) {
19931
0ea2a7e6bb41 calls without FFI
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
  1391
	    thisType = TYPE_UINT16;
19535
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1392
	    if (! __isSmallInteger(arg)) {
19341
2ab29dd7ec1a mingw 64bit fixes (xxLL in constants - sigh)
Claus Gittinger <cg@exept.de>
parents: 19334
diff changeset
  1393
# ifdef VERBOSE
19535
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1394
		if (@global(Verbose) == true) {
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1395
		    printf("invalidArgument: arg%d uint16 value out of range [%d]\n", i+1, __LINE__);
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1396
		}
19341
2ab29dd7ec1a mingw 64bit fixes (xxLL in constants - sigh)
Claus Gittinger <cg@exept.de>
parents: 19334
diff changeset
  1397
# endif
19535
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1398
		__FAIL__(@symbol(InvalidArgument))
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1399
	    }
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1400
	    __argValues[i].iVal = __intVal(arg);
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1401
	    if (((unsigned)(__argValues[i].iVal)) > 0xFFFF) {
19341
2ab29dd7ec1a mingw 64bit fixes (xxLL in constants - sigh)
Claus Gittinger <cg@exept.de>
parents: 19334
diff changeset
  1402
# ifdef VERBOSE
19535
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1403
		if (@global(Verbose) == true) {
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1404
		    printf("invalidArgument: arg%d uint16 value out of range [%d]\n", i+1, __LINE__);
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1405
		}
19341
2ab29dd7ec1a mingw 64bit fixes (xxLL in constants - sigh)
Claus Gittinger <cg@exept.de>
parents: 19334
diff changeset
  1406
# endif
19535
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1407
		__FAIL__(@symbol(InvalidArgument))
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1408
	    }
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1409
	    argValuePtr = &(__argValues[i].iVal);
9479
68d12a181d4a handle types; sint32 types.
ca
parents: 9466
diff changeset
  1410
19535
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1411
	} else if (typeSymbol == @symbol(sint16)) {
19931
0ea2a7e6bb41 calls without FFI
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
  1412
	    thisType = TYPE_SINT16;
19535
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1413
	    if (! __isSmallInteger(arg)) {
19341
2ab29dd7ec1a mingw 64bit fixes (xxLL in constants - sigh)
Claus Gittinger <cg@exept.de>
parents: 19334
diff changeset
  1414
# ifdef VERBOSE
19535
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1415
		if (@global(Verbose) == true) {
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1416
		    printf("invalidArgument: arg%d sint16 value out of range [%d]\n", i+1, __LINE__);
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1417
		}
19341
2ab29dd7ec1a mingw 64bit fixes (xxLL in constants - sigh)
Claus Gittinger <cg@exept.de>
parents: 19334
diff changeset
  1418
# endif
19535
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1419
		__FAIL__(@symbol(InvalidArgument))
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1420
	    }
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1421
	    __argValues[i].iVal = __intVal(arg);
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1422
	    if (((__argValues[i].iVal) < -0x8000) || ((__argValues[i].iVal) > 0x7FFF))  {
19341
2ab29dd7ec1a mingw 64bit fixes (xxLL in constants - sigh)
Claus Gittinger <cg@exept.de>
parents: 19334
diff changeset
  1423
# ifdef VERBOSE
19535
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1424
		if (@global(Verbose) == true) {
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1425
		    printf("invalidArgument: arg%d sint16 value out of range [%d]\n", i+1, __LINE__);
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1426
		}
19341
2ab29dd7ec1a mingw 64bit fixes (xxLL in constants - sigh)
Claus Gittinger <cg@exept.de>
parents: 19334
diff changeset
  1427
# endif
19535
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1428
		__FAIL__(@symbol(InvalidArgument))
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1429
	    }
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1430
	    argValuePtr = &(__argValues[i].iVal);
9479
68d12a181d4a handle types; sint32 types.
ca
parents: 9466
diff changeset
  1431
19535
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1432
	} else if (typeSymbol == @symbol(uint32)) {
19931
0ea2a7e6bb41 calls without FFI
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
  1433
	    thisType = TYPE_UINT32;
19535
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1434
	    if (__isSmallInteger(arg)) {
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1435
		__argValues[i].iVal = __intVal(arg);
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1436
	    } else {
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1437
		__argValues[i].iVal = __unsignedLongIntVal(arg);
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1438
		if (__argValues[i].iVal == 0) {
19341
2ab29dd7ec1a mingw 64bit fixes (xxLL in constants - sigh)
Claus Gittinger <cg@exept.de>
parents: 19334
diff changeset
  1439
# ifdef VERBOSE
19535
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1440
		    if (@global(Verbose) == true) {
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1441
			printf("invalidArgument: arg%d uint32 value out of range [%d]\n", i+1, __LINE__);
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1442
		    }
19341
2ab29dd7ec1a mingw 64bit fixes (xxLL in constants - sigh)
Claus Gittinger <cg@exept.de>
parents: 19334
diff changeset
  1443
# endif
19535
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1444
		    __FAIL__(@symbol(InvalidArgument))
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1445
		}
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1446
	    }
19334
0488e4bae939 mingw 64bit fixes
Claus Gittinger <cg@exept.de>
parents: 19314
diff changeset
  1447
# if __POINTER_SIZE__ == 8
19535
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1448
	    if ((__argValues[i].iVal) < 0)  {
19341
2ab29dd7ec1a mingw 64bit fixes (xxLL in constants - sigh)
Claus Gittinger <cg@exept.de>
parents: 19334
diff changeset
  1449
# ifdef VERBOSE
19535
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1450
		if (@global(Verbose) == true) {
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1451
		    printf("invalidArgument: arg%d uint32 value out of range [%d]\n", i+1, __LINE__);
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1452
		}
19341
2ab29dd7ec1a mingw 64bit fixes (xxLL in constants - sigh)
Claus Gittinger <cg@exept.de>
parents: 19334
diff changeset
  1453
# endif
19535
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1454
		__FAIL__(@symbol(InvalidArgument))
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1455
	    }
19334
0488e4bae939 mingw 64bit fixes
Claus Gittinger <cg@exept.de>
parents: 19314
diff changeset
  1456
# endif
19535
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1457
	    argValuePtr = &(__argValues[i].iVal);
19334
0488e4bae939 mingw 64bit fixes
Claus Gittinger <cg@exept.de>
parents: 19314
diff changeset
  1458
19535
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1459
	 } else if (typeSymbol == @symbol(sint32)) {
19931
0ea2a7e6bb41 calls without FFI
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
  1460
	    thisType = TYPE_SINT32;
19535
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1461
	    if (__isSmallInteger(arg)) {
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1462
		__argValues[i].iVal = __intVal(arg);
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1463
	    } else {
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1464
		__argValues[i].iVal = __signedLongIntVal(arg);
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1465
		if (__argValues[i].iVal == 0) {
19341
2ab29dd7ec1a mingw 64bit fixes (xxLL in constants - sigh)
Claus Gittinger <cg@exept.de>
parents: 19334
diff changeset
  1466
# ifdef VERBOSE
19535
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1467
		    if (@global(Verbose) == true) {
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1468
			printf("invalidArgument: arg%d sint32 value out of range [%d]\n", i+1, __LINE__);
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1469
		    }
19341
2ab29dd7ec1a mingw 64bit fixes (xxLL in constants - sigh)
Claus Gittinger <cg@exept.de>
parents: 19334
diff changeset
  1470
# endif
19535
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1471
		    __FAIL__(@symbol(InvalidArgument))
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1472
		}
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1473
	    }
19334
0488e4bae939 mingw 64bit fixes
Claus Gittinger <cg@exept.de>
parents: 19314
diff changeset
  1474
# if __POINTER_SIZE__ == 8
19535
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1475
	    if (((__argValues[i].iVal) < -0x80000000LL) || ((__argValues[i].iVal) > 0x7FFFFFFFLL))  {
19341
2ab29dd7ec1a mingw 64bit fixes (xxLL in constants - sigh)
Claus Gittinger <cg@exept.de>
parents: 19334
diff changeset
  1476
# ifdef VERBOSE
19535
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1477
		if (@global(Verbose) == true) {
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1478
		    printf("invalidArgument: arg%d sint32 value (%"_lx_") out of range [%d]\n", i+1, __argValues[i].iVal, __LINE__);
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1479
		}
19341
2ab29dd7ec1a mingw 64bit fixes (xxLL in constants - sigh)
Claus Gittinger <cg@exept.de>
parents: 19334
diff changeset
  1480
# endif
19535
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1481
		__FAIL__(@symbol(InvalidArgument))
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1482
	    }
19334
0488e4bae939 mingw 64bit fixes
Claus Gittinger <cg@exept.de>
parents: 19314
diff changeset
  1483
# endif
19535
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1484
	    argValuePtr = &(__argValues[i].iVal);
19334
0488e4bae939 mingw 64bit fixes
Claus Gittinger <cg@exept.de>
parents: 19314
diff changeset
  1485
19535
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1486
	} else if (typeSymbol == @symbol(uint64)) {
19931
0ea2a7e6bb41 calls without FFI
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
  1487
	    thisType = TYPE_UINT64;
19535
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1488
	    if (__isSmallInteger(arg)) {
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1489
		__argValues[i].iVal = __intVal(arg);
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1490
	    } else {
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1491
		__argValues[i].iVal = __unsignedLongIntVal(arg);
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1492
		if (__argValues[i].iVal == 0) {
19341
2ab29dd7ec1a mingw 64bit fixes (xxLL in constants - sigh)
Claus Gittinger <cg@exept.de>
parents: 19334
diff changeset
  1493
# ifdef VERBOSE
19535
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1494
		    if (@global(Verbose) == true) {
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1495
			printf("invalidArgument: arg%d uint64 value out of range [%d]\n", i+1, __LINE__);
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1496
		    }
19341
2ab29dd7ec1a mingw 64bit fixes (xxLL in constants - sigh)
Claus Gittinger <cg@exept.de>
parents: 19334
diff changeset
  1497
# endif
19535
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1498
		    __FAIL__(@symbol(InvalidArgument))
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1499
		}
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1500
	    }
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1501
	    argValuePtr = &(__argValues[i].iVal);
19334
0488e4bae939 mingw 64bit fixes
Claus Gittinger <cg@exept.de>
parents: 19314
diff changeset
  1502
19535
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1503
	 } else if (typeSymbol == @symbol(sint64)) {
19931
0ea2a7e6bb41 calls without FFI
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
  1504
	    thisType = TYPE_SINT64;
19535
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1505
	    if (__isSmallInteger(arg)) {
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1506
		__argValues[i].iVal = __intVal(arg);
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1507
	    } else {
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1508
		__argValues[i].iVal = __signedLongIntVal(arg);
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1509
		if (__argValues[i].iVal == 0) {
19341
2ab29dd7ec1a mingw 64bit fixes (xxLL in constants - sigh)
Claus Gittinger <cg@exept.de>
parents: 19334
diff changeset
  1510
# ifdef VERBOSE
19535
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1511
		    if (@global(Verbose) == true) {
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1512
			printf("invalidArgument: arg%d sint64 value out of range [%d]\n", i+1, __LINE__);
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1513
		    }
19341
2ab29dd7ec1a mingw 64bit fixes (xxLL in constants - sigh)
Claus Gittinger <cg@exept.de>
parents: 19334
diff changeset
  1514
# endif
19535
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1515
		    __FAIL__(@symbol(InvalidArgument))
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1516
		}
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1517
	    }
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1518
	    argValuePtr = &(__argValues[i].iVal);
9479
68d12a181d4a handle types; sint32 types.
ca
parents: 9466
diff changeset
  1519
19535
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1520
	} else if (typeSymbol == @symbol(float)) {
19931
0ea2a7e6bb41 calls without FFI
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
  1521
	    thisType = TYPE_FLOAT;
19535
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1522
	    if (__isSmallInteger(arg)) {
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1523
		__argValues[i].fVal = (float)(__intVal(arg));
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1524
	    } else if (__isFloat(arg)) {
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1525
		__argValues[i].fVal = (float)(__floatVal(arg));
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1526
	    } else if (__isShortFloat(arg)) {
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1527
		__argValues[i].fVal = (float)(__shortFloatVal(arg));
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1528
	    } else {
19341
2ab29dd7ec1a mingw 64bit fixes (xxLL in constants - sigh)
Claus Gittinger <cg@exept.de>
parents: 19334
diff changeset
  1529
# ifdef VERBOSE
19535
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1530
		if (@global(Verbose) == true) {
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1531
		    printf("invalidArgument: arg%d non float value [%d]\n", i+1, __LINE__);
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1532
		}
19341
2ab29dd7ec1a mingw 64bit fixes (xxLL in constants - sigh)
Claus Gittinger <cg@exept.de>
parents: 19334
diff changeset
  1533
# endif
19535
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1534
		__FAIL__(@symbol(InvalidArgument))
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1535
	    }
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1536
	    argValuePtr = &(__argValues[i].fVal);
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1537
	} else if (typeSymbol == @symbol(double)) {
19931
0ea2a7e6bb41 calls without FFI
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
  1538
	    thisType = TYPE_DOUBLE;
19535
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1539
	    if (__isSmallInteger(arg)) {
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1540
		__argValues[i].dVal = (double)(__intVal(arg));
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1541
	    } else if (__isFloat(arg)) {
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1542
		__argValues[i].dVal = (double)(__floatVal(arg));
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1543
	    } else if (__isShortFloat(arg)) {
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1544
		__argValues[i].dVal = (double)(__shortFloatVal(arg));
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1545
	    } else {
19341
2ab29dd7ec1a mingw 64bit fixes (xxLL in constants - sigh)
Claus Gittinger <cg@exept.de>
parents: 19334
diff changeset
  1546
# ifdef VERBOSE
19535
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1547
		if (@global(Verbose) == true) {
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1548
		    printf("invalidArgument: arg%d non double value [%d]\n", i+1, __LINE__);
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1549
		}
19341
2ab29dd7ec1a mingw 64bit fixes (xxLL in constants - sigh)
Claus Gittinger <cg@exept.de>
parents: 19334
diff changeset
  1550
# endif
19535
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1551
		__FAIL__(@symbol(InvalidArgument))
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1552
	    }
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1553
	    argValuePtr = &(__argValues[i].dVal);
9479
68d12a181d4a handle types; sint32 types.
ca
parents: 9466
diff changeset
  1554
19535
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1555
	} else if (typeSymbol == @symbol(void)) {
19931
0ea2a7e6bb41 calls without FFI
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
  1556
	    thisType = TYPE_VOID;
19535
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1557
	    argValuePtr = &null;
9479
68d12a181d4a handle types; sint32 types.
ca
parents: 9466
diff changeset
  1558
19535
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1559
	} else if (typeSymbol == @symbol(charPointer)) {
19931
0ea2a7e6bb41 calls without FFI
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
  1560
	    thisType = TYPE_POINTER;
19535
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1561
	    if (__isStringLike(arg)) {
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1562
		if (async == true) goto badArgForAsyncCall;
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1563
		__argValues[i].pointerVal = (void *)(__stringVal(arg));
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1564
	    } else if (__isBytes(arg)) {
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1565
		if (async == true) goto badArgForAsyncCall;
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1566
		__argValues[i].pointerVal = (void *)(__byteArrayVal(arg));
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1567
	    } else if (__isExternalAddressLike(arg)) {
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1568
		__argValues[i].pointerVal = (void *)(__externalAddressVal(arg));
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1569
	    } else if (__isExternalBytesLike(arg)) {
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1570
		__argValues[i].pointerVal = (void *)(__externalBytesVal(arg));
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1571
	    } else {
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1572
		if (arg == nil) {
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1573
		    __argValues[i].pointerVal = (void *)0;
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1574
		} else {
19341
2ab29dd7ec1a mingw 64bit fixes (xxLL in constants - sigh)
Claus Gittinger <cg@exept.de>
parents: 19334
diff changeset
  1575
# ifdef VERBOSE
19535
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1576
		    if (@global(Verbose) == true) {
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1577
			printf("invalidArgument: arg%d non charPointer value [%d]\n", i+1, __LINE__);
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1578
		    }
19341
2ab29dd7ec1a mingw 64bit fixes (xxLL in constants - sigh)
Claus Gittinger <cg@exept.de>
parents: 19334
diff changeset
  1579
# endif
19535
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1580
		    __FAIL__(@symbol(InvalidArgument))
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1581
		}
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1582
	    }
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1583
	    argValuePtr = &(__argValues[i].pointerVal);;
10603
da9b7ed81caf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10514
diff changeset
  1584
19535
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1585
	} else if (typeSymbol == @symbol(wcharPointer)) {
19931
0ea2a7e6bb41 calls without FFI
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
  1586
	    thisType = TYPE_POINTER;
19535
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1587
	    if (__isUnicode16String(arg)) {
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1588
		if (async == true) goto badArgForAsyncCall;
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1589
		__argValues[i].pointerVal = (void *)(__unicode16StringVal(arg));
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1590
	    } else if (__isBytes(arg)) {
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1591
		if (async == true) goto badArgForAsyncCall;
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1592
		__argValues[i].pointerVal = (void *)(__byteArrayVal(arg));
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1593
	    } else if (__isExternalAddressLike(arg)) {
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1594
		__argValues[i].pointerVal = (void *)(__externalAddressVal(arg));
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1595
	    } else if (__isExternalBytesLike(arg)) {
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1596
		__argValues[i].pointerVal = (void *)(__externalBytesVal(arg));
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1597
	    } else {
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1598
		if (arg == nil) {
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1599
		    __argValues[i].pointerVal = (void *)0;
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1600
		} else {
19341
2ab29dd7ec1a mingw 64bit fixes (xxLL in constants - sigh)
Claus Gittinger <cg@exept.de>
parents: 19334
diff changeset
  1601
# ifdef VERBOSE
19535
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1602
		    if (@global(Verbose) == true) {
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1603
			printf("invalidArgument: arg%d non wcharPointer value [%d]\n", i+1, __LINE__);
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1604
		    }
19341
2ab29dd7ec1a mingw 64bit fixes (xxLL in constants - sigh)
Claus Gittinger <cg@exept.de>
parents: 19334
diff changeset
  1605
# endif
19535
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1606
		    __FAIL__(@symbol(InvalidArgument))
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1607
		}
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1608
	    }
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1609
	    argValuePtr = &(__argValues[i].pointerVal);;
12656
e7854486b4ff wcharPointer arguments
Claus Gittinger <cg@exept.de>
parents: 12591
diff changeset
  1610
19535
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1611
	} else if (typeSymbol == @symbol(floatPointer)) {
19931
0ea2a7e6bb41 calls without FFI
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
  1612
	    thisType = TYPE_POINTER;
19535
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1613
	    if (__isBytes(arg)) {
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1614
		if (async == true) goto badArgForAsyncCall;
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1615
		__argValues[i].pointerVal = (void *)(__byteArrayVal(arg));
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1616
	    } else if (__isExternalAddressLike(arg)) {
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1617
		__argValues[i].pointerVal = (void *)(__externalAddressVal(arg));
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1618
	    } else if (__isExternalBytesLike(arg)) {
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1619
		__argValues[i].pointerVal = (void *)(__externalBytesVal(arg));
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1620
	    } else if (__isFloats(arg)) {
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1621
		char *p = (char *)(__FloatArrayInstPtr(arg)->f_element);
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1622
		int nInstBytes;
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1623
		OBJ cls;
10603
da9b7ed81caf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10514
diff changeset
  1624
19535
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1625
		if (async == true) goto badArgForAsyncCall;
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1626
		cls = __qClass(arg);
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1627
		nInstBytes = __OBJS2BYTES__(__intVal(__ClassInstPtr(cls)->c_ninstvars));
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1628
		p = p + nInstBytes;
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1629
		__argValues[i].pointerVal = p;
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1630
	    } else {
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1631
		if (arg == nil) {
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1632
		    __argValues[i].pointerVal = (void *)0;
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1633
		} else {
19341
2ab29dd7ec1a mingw 64bit fixes (xxLL in constants - sigh)
Claus Gittinger <cg@exept.de>
parents: 19334
diff changeset
  1634
# ifdef VERBOSE
19535
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1635
		    if (@global(Verbose) == true) {
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1636
			printf("invalidArgument: arg%d non floatPointer value [%d]\n", i+1, __LINE__);
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1637
		    }
19341
2ab29dd7ec1a mingw 64bit fixes (xxLL in constants - sigh)
Claus Gittinger <cg@exept.de>
parents: 19334
diff changeset
  1638
# endif
19535
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1639
		    __FAIL__(@symbol(InvalidArgument))
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1640
		}
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1641
	    }
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1642
	    argValuePtr = &(__argValues[i].pointerVal);;
10603
da9b7ed81caf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10514
diff changeset
  1643
19535
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1644
	} else if (typeSymbol == @symbol(doublePointer)) {
19931
0ea2a7e6bb41 calls without FFI
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
  1645
	    thisType = TYPE_POINTER;
19535
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1646
	    if (__isBytes(arg)) {
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1647
		if (async == true) goto badArgForAsyncCall;
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1648
		__argValues[i].pointerVal = (void *)(__byteArrayVal(arg));
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1649
	    } else if (__isExternalAddressLike(arg)) {
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1650
		__argValues[i].pointerVal = (void *)(__externalAddressVal(arg));
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1651
	    } else if (__isExternalBytesLike(arg)) {
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1652
		__argValues[i].pointerVal = (void *)(__externalBytesVal(arg));
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1653
	    } else if (__isDoubles(arg)) {
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1654
		char *p = (char *)(__DoubleArrayInstPtr(arg)->d_element);
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1655
		int nInstBytes;
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1656
		OBJ cls;
10603
da9b7ed81caf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10514
diff changeset
  1657
19535
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1658
		if (async == true) goto badArgForAsyncCall;
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1659
		cls = __qClass(arg);
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1660
		nInstBytes = __OBJS2BYTES__(__intVal(__ClassInstPtr(cls)->c_ninstvars));
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1661
		p = p + nInstBytes;
12504
c9987bb76eb6 untested long long return value
Claus Gittinger <cg@exept.de>
parents: 12503
diff changeset
  1662
# ifdef __NEED_DOUBLE_ALIGN
19535
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1663
		if ((INT)(__DoubleArrayInstPtr(arg)->d_element) & (__DOUBLE_ALIGN-1)) {
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1664
		    int delta = __DOUBLE_ALIGN - ((INT)p & (__DOUBLE_ALIGN-1));
10603
da9b7ed81caf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10514
diff changeset
  1665
19535
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1666
		    p += delta;
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1667
		}
12504
c9987bb76eb6 untested long long return value
Claus Gittinger <cg@exept.de>
parents: 12503
diff changeset
  1668
# endif
19535
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1669
		__argValues[i].pointerVal = p;
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1670
	    } else {
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1671
		if (arg == nil) {
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1672
		    __argValues[i].pointerVal = (void *)0;
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1673
		} else {
19341
2ab29dd7ec1a mingw 64bit fixes (xxLL in constants - sigh)
Claus Gittinger <cg@exept.de>
parents: 19334
diff changeset
  1674
# ifdef VERBOSE
19535
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1675
		    if (@global(Verbose) == true) {
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1676
			printf("invalidArgument: arg%d non doublePointer value [%d]\n", i+1, __LINE__);
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1677
		    }
19341
2ab29dd7ec1a mingw 64bit fixes (xxLL in constants - sigh)
Claus Gittinger <cg@exept.de>
parents: 19334
diff changeset
  1678
# endif
19535
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1679
		    __FAIL__(@symbol(InvalidArgument))
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1680
		}
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1681
	    }
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1682
	    argValuePtr = &(__argValues[i].pointerVal);;
9479
68d12a181d4a handle types; sint32 types.
ca
parents: 9466
diff changeset
  1683
19535
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1684
	} else if (typeSymbol == @symbol(pointer)) {
9524
2af286bbcac3 *** empty log message ***
ca
parents: 9519
diff changeset
  1685
commonPointerTypeArg: ;
19931
0ea2a7e6bb41 calls without FFI
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
  1686
	    thisType = TYPE_POINTER;
19535
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1687
	    if (arg == nil) {
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1688
		__argValues[i].pointerVal = NULL;
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1689
	    } else if (__isExternalAddressLike(arg)) {
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1690
		__argValues[i].pointerVal = (void *)(__externalAddressVal(arg));
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1691
	    } else if (__isExternalBytesLike(arg)) {
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1692
		__argValues[i].pointerVal = (void *)(__externalBytesVal(arg));
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1693
	    } else if (__isByteArrayLike(arg)) {
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1694
		if (async == true) goto badArgForAsyncCall;
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1695
		__argValues[i].pointerVal = (void *)(__byteArrayVal(arg));
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1696
	    } else if (__isWordArray(arg) || __isSignedWordArray(arg)
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1697
		    || __isIntegerArray(arg) || __isSignedIntegerArray(arg)) {
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1698
		if (async == true) goto badArgForAsyncCall;
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1699
		__argValues[i].pointerVal = (void *)(__integerArrayVal(arg));
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1700
	    } else if (__isFloatArray(arg)) {
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1701
		if (async == true) goto badArgForAsyncCall;
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1702
		__argValues[i].pointerVal = (void *)(__FloatArrayInstPtr(arg)->f_element);
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1703
	    } else if (__isDoubleArray(arg)) {
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1704
		if (async == true) goto badArgForAsyncCall;
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1705
		__argValues[i].pointerVal = (void *)(__DoubleArrayInstPtr(arg)->d_element);
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1706
	    } else if (__isStringLike(arg)) {
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1707
		if (async == true) {
9435
68f7e39efad7 support of asynchronous calls
ca
parents: 9418
diff changeset
  1708
badArgForAsyncCall: ;
19341
2ab29dd7ec1a mingw 64bit fixes (xxLL in constants - sigh)
Claus Gittinger <cg@exept.de>
parents: 19334
diff changeset
  1709
# ifdef VERBOSE
19535
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1710
		    if (@global(Verbose) == true) {
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1711
			printf("invalidArgument: arg%d not allowed for async call [%d]\n", i+1, __LINE__);
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1712
		    }
19341
2ab29dd7ec1a mingw 64bit fixes (xxLL in constants - sigh)
Claus Gittinger <cg@exept.de>
parents: 19334
diff changeset
  1713
# endif
19535
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1714
		    __FAIL__(@symbol(BadArgForAsyncCall))
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1715
		}
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1716
		__argValues[i].pointerVal = (void *)(__stringVal(arg));
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1717
	    } else if (__isBytes(arg) || __isWords(arg) || __isLongs(arg)) {
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1718
		char *p = (char *)(__byteArrayVal(arg));
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1719
		int nInstBytes;
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1720
		OBJ cls;
9483
3bea515ce81e *** empty log message ***
fm
parents: 9479
diff changeset
  1721
19535
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1722
		if (async == true) goto badArgForAsyncCall;
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1723
		cls = __qClass(arg);
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1724
		nInstBytes = __OBJS2BYTES__(__intVal(__ClassInstPtr(cls)->c_ninstvars));
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1725
		__argValues[i].pointerVal = p + nInstBytes;
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1726
	    } else {
19341
2ab29dd7ec1a mingw 64bit fixes (xxLL in constants - sigh)
Claus Gittinger <cg@exept.de>
parents: 19334
diff changeset
  1727
# ifdef VERBOSE
19535
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1728
		if (@global(Verbose) == true) {
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1729
		    printf("invalidArgument: arg%d non pointer value [%d]\n", i+1, __LINE__);
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1730
		}
19341
2ab29dd7ec1a mingw 64bit fixes (xxLL in constants - sigh)
Claus Gittinger <cg@exept.de>
parents: 19334
diff changeset
  1731
# endif
19535
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1732
		__FAIL__(@symbol(InvalidArgument))
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1733
	    }
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1734
	    argValuePtr = &(__argValues[i].pointerVal);;
9479
68d12a181d4a handle types; sint32 types.
ca
parents: 9466
diff changeset
  1735
19535
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1736
	} else if (typeSymbol == @symbol(bool)) {
19931
0ea2a7e6bb41 calls without FFI
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
  1737
	    thisType = TYPE_UINT;
9342
e548ce80ab02 virtual calls
Claus Gittinger <cg@exept.de>
parents: 9341
diff changeset
  1738
19535
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1739
	    if (arg == true) {
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1740
		__argValues[i].iVal = 1;
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1741
	    } else if (arg == false) {
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1742
		__argValues[i].iVal = 0;
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1743
	    } else if (__isSmallInteger(arg)) {
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1744
		__argValues[i].iVal = __intVal(arg);
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1745
	    } else {
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1746
		__argValues[i].iVal = __unsignedLongIntVal(arg);
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1747
		if (__argValues[i].iVal == 0) {
19341
2ab29dd7ec1a mingw 64bit fixes (xxLL in constants - sigh)
Claus Gittinger <cg@exept.de>
parents: 19334
diff changeset
  1748
# ifdef VERBOSE
19535
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1749
		    if (@global(Verbose) == true) {
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1750
			printf("invalidArgument: arg%d non bool value [%d]\n", i+1, __LINE__);
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1751
		    }
19341
2ab29dd7ec1a mingw 64bit fixes (xxLL in constants - sigh)
Claus Gittinger <cg@exept.de>
parents: 19334
diff changeset
  1752
# endif
19535
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1753
		    __FAIL__(@symbol(InvalidArgument))
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1754
		}
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1755
	    }
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1756
	    argValuePtr = &(__argValues[i].iVal);
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1757
	} else {
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1758
	    if (__isSymbol(typeSymbol)
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1759
	     && ((argValueClass = __GLOBAL_GET(typeSymbol)) != nil)) {
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1760
		if (! __isBehaviorLike(argValueClass)) {
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1761
		    __FAIL__(@symbol(NonBehaviorArgumentType))
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1762
		}
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1763
		if (! __qIsSubclassOfExternalAddress(argValueClass)) {
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1764
		    __FAIL__(@symbol(NonExternalAddressArgumentType))
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1765
		}
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1766
		goto commonPointerTypeArg; /* sorry */
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1767
	    } else {
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1768
		__FAIL__(@symbol(UnknownArgumentType))
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1769
	    }
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1770
	}
9342
e548ce80ab02 virtual calls
Claus Gittinger <cg@exept.de>
parents: 9341
diff changeset
  1771
19535
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1772
	__argTypes[i] = thisType;
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1773
	__argValuePointers[i] = argValuePtr;
9483
3bea515ce81e *** empty log message ***
fm
parents: 9479
diff changeset
  1774
19932
7fb01b7aff42 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 19931
diff changeset
  1775
	if ((thisType == TYPE_FLOAT) || (thisType == TYPE_DOUBLE)) {
7fb01b7aff42 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 19931
diff changeset
  1776
	    __anyFloatOrDoubleArg = 1;
7fb01b7aff42 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 19931
diff changeset
  1777
	}
12504
c9987bb76eb6 untested long long return value
Claus Gittinger <cg@exept.de>
parents: 12503
diff changeset
  1778
# ifdef VERBOSE
19535
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1779
	if (@global(Verbose) == true) {
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1780
	    printf("arg%d: %"_lx_" type:%"_lx_"\n", i+1, (INT)(__argValues[i].iVal), (INT)thisType);
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1781
	}
12504
c9987bb76eb6 untested long long return value
Claus Gittinger <cg@exept.de>
parents: 12503
diff changeset
  1782
# endif
9342
e548ce80ab02 virtual calls
Claus Gittinger <cg@exept.de>
parents: 9341
diff changeset
  1783
    }
9465
d11885052713 rewrite & cleanup
Claus Gittinger <cg@exept.de>
parents: 9464
diff changeset
  1784
    failureInfo = nil;
9342
e548ce80ab02 virtual calls
Claus Gittinger <cg@exept.de>
parents: 9341
diff changeset
  1785
9465
d11885052713 rewrite & cleanup
Claus Gittinger <cg@exept.de>
parents: 9464
diff changeset
  1786
    if (callTypeNumber == @global(CALLTYPE_API)) {
19931
0ea2a7e6bb41 calls without FFI
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
  1787
#  ifdef CALLTYPE_FFI_STDCALL
19535
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1788
	__callType = CALLTYPE_FFI_STDCALL;
19931
0ea2a7e6bb41 calls without FFI
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
  1789
#   ifdef VERBOSE
19535
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1790
	if (@global(Verbose) == true) {
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1791
	    printf("STDCALL\n");
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1792
	}
19931
0ea2a7e6bb41 calls without FFI
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
  1793
#   endif
0ea2a7e6bb41 calls without FFI
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
  1794
#  else
0ea2a7e6bb41 calls without FFI
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
  1795
	failureCode = @symbol(FFICallTypeNotSupported);
0ea2a7e6bb41 calls without FFI
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
  1796
	goto getOutOfHere;
0ea2a7e6bb41 calls without FFI
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
  1797
#  endif
9342
e548ce80ab02 virtual calls
Claus Gittinger <cg@exept.de>
parents: 9341
diff changeset
  1798
    }
19931
0ea2a7e6bb41 calls without FFI
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
  1799
0ea2a7e6bb41 calls without FFI
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
  1800
    // 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
  1801
    if (callTypeNumber == @global(CALLTYPE_V8)) {
19931
0ea2a7e6bb41 calls without FFI
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
  1802
#  ifdef CALLTYPE_FFI_V8
19535
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1803
	__callType = CALLTYPE_FFI_V8;
19931
0ea2a7e6bb41 calls without FFI
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
  1804
#  else
0ea2a7e6bb41 calls without FFI
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
  1805
	failureCode = @symbol(FFICallTypeNotSupported);
0ea2a7e6bb41 calls without FFI
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
  1806
	goto getOutOfHere;
0ea2a7e6bb41 calls without FFI
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
  1807
#  endif
9342
e548ce80ab02 virtual calls
Claus Gittinger <cg@exept.de>
parents: 9341
diff changeset
  1808
    }
19931
0ea2a7e6bb41 calls without FFI
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
  1809
9465
d11885052713 rewrite & cleanup
Claus Gittinger <cg@exept.de>
parents: 9464
diff changeset
  1810
    if (callTypeNumber == @global(CALLTYPE_V9)) {
19931
0ea2a7e6bb41 calls without FFI
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
  1811
#  ifdef CALLTYPE_FFI_V9
19535
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1812
	__callType = CALLTYPE_FFI_V9;
19931
0ea2a7e6bb41 calls without FFI
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
  1813
#  else
0ea2a7e6bb41 calls without FFI
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
  1814
	failureCode = @symbol(FFICallTypeNotSupported);
0ea2a7e6bb41 calls without FFI
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
  1815
	goto getOutOfHere;
0ea2a7e6bb41 calls without FFI
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
  1816
#  endif
9342
e548ce80ab02 virtual calls
Claus Gittinger <cg@exept.de>
parents: 9341
diff changeset
  1817
    }
19931
0ea2a7e6bb41 calls without FFI
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
  1818
9465
d11885052713 rewrite & cleanup
Claus Gittinger <cg@exept.de>
parents: 9464
diff changeset
  1819
    if (callTypeNumber == @global(CALLTYPE_UNIX64)) {
19931
0ea2a7e6bb41 calls without FFI
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
  1820
#  ifdef CALLTYPE_FFI_UNIX64
19535
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1821
	__callType = CALLTYPE_FFI_UNIX64;
19931
0ea2a7e6bb41 calls without FFI
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
  1822
#  else
0ea2a7e6bb41 calls without FFI
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
  1823
	failureCode = @symbol(FFICallTypeNotSupported);
0ea2a7e6bb41 calls without FFI
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
  1824
	goto getOutOfHere;
0ea2a7e6bb41 calls without FFI
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
  1825
#  endif
9342
e548ce80ab02 virtual calls
Claus Gittinger <cg@exept.de>
parents: 9341
diff changeset
  1826
    }
e548ce80ab02 virtual calls
Claus Gittinger <cg@exept.de>
parents: 9341
diff changeset
  1827
19931
0ea2a7e6bb41 calls without FFI
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
  1828
# ifdef HAVE_FFI
9342
e548ce80ab02 virtual calls
Claus Gittinger <cg@exept.de>
parents: 9341
diff changeset
  1829
    if (ffi_prep_cif(&__cif, __callType, __numArgsIncludingThis, __returnType, __argTypesIncludingThis) != FFI_OK) {
19535
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1830
	__FAIL__(@symbol(FFIPrepareFailed))
9342
e548ce80ab02 virtual calls
Claus Gittinger <cg@exept.de>
parents: 9341
diff changeset
  1831
    }
9463
864880338d7e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9460
diff changeset
  1832
    if (async == true) {
19931
0ea2a7e6bb41 calls without FFI
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
  1833
#  ifdef VERBOSE
19535
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1834
	if (@global(Verbose) == true) {
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1835
	    printf("async call 0x%"_lx_"\n", (INT)codeAddress);
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1836
	}
19931
0ea2a7e6bb41 calls without FFI
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
  1837
#  endif
0ea2a7e6bb41 calls without FFI
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
  1838
#  ifdef __win32__
19535
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1839
	__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
  1840
#  else
19535
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1841
	__BEGIN_INTERRUPTABLE__
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1842
	ffi_call(&__cif, codeAddress, __returnValuePointer, __argValuePointersIncludingThis);
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1843
	__END_INTERRUPTABLE__
19931
0ea2a7e6bb41 calls without FFI
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
  1844
#  endif
9435
68f7e39efad7 support of asynchronous calls
ca
parents: 9418
diff changeset
  1845
    } else {
19535
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1846
	if (unlimitedStack == true) {
19931
0ea2a7e6bb41 calls without FFI
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
  1847
#  ifdef VERBOSE
19535
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1848
	    if (@global(Verbose) == true) {
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1849
		printf("UNLIMITEDSTACKCALL call 0x%"_lx_"\n", (INT)codeAddress);
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1850
	    }
19931
0ea2a7e6bb41 calls without FFI
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
  1851
#  endif
19535
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1852
	    __UNLIMITEDSTACKCALL4__((OBJFUNC)ffi_call, (INT)(&__cif), (INT)codeAddress, (INT)__returnValuePointer, (INT)__argValuePointersIncludingThis);
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1853
	} else {
19931
0ea2a7e6bb41 calls without FFI
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
  1854
#  ifdef VERBOSE
19535
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1855
	    if (@global(Verbose) == true) {
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1856
		printf("call 0x%"_lx_"\n", (INT)codeAddress);
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1857
	    }
19931
0ea2a7e6bb41 calls without FFI
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
  1858
#  endif
19535
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1859
	    ffi_call(&__cif, codeAddress, __returnValuePointer, __argValuePointersIncludingThis);
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  1860
	}
9435
68f7e39efad7 support of asynchronous calls
ca
parents: 9418
diff changeset
  1861
    }
19931
0ea2a7e6bb41 calls without FFI
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
  1862
0ea2a7e6bb41 calls without FFI
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
  1863
# else /* NO FFI */
0ea2a7e6bb41 calls without FFI
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
  1864
0ea2a7e6bb41 calls without FFI
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
  1865
    // this is a fallback; simply assume that pointer and regular args
0ea2a7e6bb41 calls without FFI
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
  1866
    // 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
  1867
    // (pointer-) size.
0ea2a7e6bb41 calls without FFI
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
  1868
    // Also, that float/doubles are passed down in regular registers,
0ea2a7e6bb41 calls without FFI
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
  1869
    // and the return types float and double are handled diferently from ints.
0ea2a7e6bb41 calls without FFI
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
  1870
    // If that is not correct for your CPU/architecture, an ifndef is required here.
0ea2a7e6bb41 calls without FFI
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
  1871
19932
7fb01b7aff42 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 19931
diff changeset
  1872
#  if defined(__x86_64__)
7fb01b7aff42 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 19931
diff changeset
  1873
    if (__anyFloatOrDoubleArg) {
7fb01b7aff42 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 19931
diff changeset
  1874
#   ifdef VERBOSE
7fb01b7aff42 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 19931
diff changeset
  1875
	if (@global(Verbose) == true) {
7fb01b7aff42 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 19931
diff changeset
  1876
	    printf("float/double args currently not supported\n");
7fb01b7aff42 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 19931
diff changeset
  1877
	}
7fb01b7aff42 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 19931
diff changeset
  1878
#   endif
7fb01b7aff42 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 19931
diff changeset
  1879
	failureCode = @symbol(FFIDoubleArgNotSupported);
7fb01b7aff42 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 19931
diff changeset
  1880
	goto getOutOfHere;
7fb01b7aff42 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 19931
diff changeset
  1881
    }
7fb01b7aff42 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 19931
diff changeset
  1882
#  endif
7fb01b7aff42 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 19931
diff changeset
  1883
19931
0ea2a7e6bb41 calls without FFI
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
  1884
#  if !defined(SomeArchitechtureForWhichAboveIsNotTrue)
0ea2a7e6bb41 calls without FFI
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
  1885
    {
0ea2a7e6bb41 calls without FFI
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
  1886
	VOIDPTRFUNC fi = (VOIDPTRFUNC)codeAddress;
0ea2a7e6bb41 calls without FFI
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
  1887
	DOUBLEFUNC fd = (DOUBLEFUNC)codeAddress;
0ea2a7e6bb41 calls without FFI
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
  1888
0ea2a7e6bb41 calls without FFI
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
  1889
	switch (__returnType) {
0ea2a7e6bb41 calls without FFI
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
  1890
	    case TYPE_FLOAT:
0ea2a7e6bb41 calls without FFI
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
  1891
	    case TYPE_DOUBLE:
0ea2a7e6bb41 calls without FFI
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
  1892
		switch (__numArgsIncludingThis) {
0ea2a7e6bb41 calls without FFI
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
  1893
		    case 0:
0ea2a7e6bb41 calls without FFI
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
  1894
			__returnValue.dVal = (*fd)();
0ea2a7e6bb41 calls without FFI
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
  1895
			break;
0ea2a7e6bb41 calls without FFI
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
  1896
		    case 1:
0ea2a7e6bb41 calls without FFI
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
  1897
			__returnValue.dVal = (*fd)( __argValues[0].pointerVal );
0ea2a7e6bb41 calls without FFI
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
  1898
			break;
0ea2a7e6bb41 calls without FFI
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
  1899
		    case 2:
0ea2a7e6bb41 calls without FFI
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
  1900
			__returnValue.dVal = (*fd)( __argValues[0].pointerVal, __argValues[1].pointerVal );
0ea2a7e6bb41 calls without FFI
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
  1901
			break;
0ea2a7e6bb41 calls without FFI
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
  1902
		    case 3:
0ea2a7e6bb41 calls without FFI
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
  1903
			__returnValue.dVal = (*fd)( __argValues[0].pointerVal, __argValues[1].pointerVal, __argValues[2].pointerVal );
0ea2a7e6bb41 calls without FFI
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
  1904
			break;
0ea2a7e6bb41 calls without FFI
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
  1905
		    case 4:
0ea2a7e6bb41 calls without FFI
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
  1906
			__returnValue.dVal = (*fd)( __argValues[0].pointerVal, __argValues[1].pointerVal, __argValues[2].pointerVal,
0ea2a7e6bb41 calls without FFI
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
  1907
							 __argValues[3].pointerVal );
0ea2a7e6bb41 calls without FFI
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
  1908
			break;
0ea2a7e6bb41 calls without FFI
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
  1909
		    case 5:
0ea2a7e6bb41 calls without FFI
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
  1910
			__returnValue.dVal = (*fd)( __argValues[0].pointerVal, __argValues[1].pointerVal, __argValues[2].pointerVal,
0ea2a7e6bb41 calls without FFI
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
  1911
							 __argValues[3].pointerVal, __argValues[4].pointerVal );
0ea2a7e6bb41 calls without FFI
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
  1912
			break;
0ea2a7e6bb41 calls without FFI
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
  1913
		    case 6:
0ea2a7e6bb41 calls without FFI
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
  1914
			__returnValue.dVal = (*fd)( __argValues[0].pointerVal, __argValues[1].pointerVal, __argValues[2].pointerVal,
0ea2a7e6bb41 calls without FFI
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
  1915
							 __argValues[3].pointerVal, __argValues[4].pointerVal, __argValues[5].pointerVal );
0ea2a7e6bb41 calls without FFI
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
  1916
			break;
0ea2a7e6bb41 calls without FFI
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
  1917
		    case 7:
0ea2a7e6bb41 calls without FFI
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
  1918
			__returnValue.dVal = (*fd)( __argValues[0].pointerVal, __argValues[1].pointerVal, __argValues[2].pointerVal,
0ea2a7e6bb41 calls without FFI
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
  1919
							 __argValues[3].pointerVal, __argValues[4].pointerVal, __argValues[5].pointerVal,
0ea2a7e6bb41 calls without FFI
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
  1920
							 __argValues[6].pointerVal );
0ea2a7e6bb41 calls without FFI
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
  1921
			break;
0ea2a7e6bb41 calls without FFI
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
  1922
		    case 8:
0ea2a7e6bb41 calls without FFI
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
  1923
			__returnValue.dVal = (*fd)( __argValues[0].pointerVal, __argValues[1].pointerVal, __argValues[2].pointerVal,
0ea2a7e6bb41 calls without FFI
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
  1924
							 __argValues[3].pointerVal, __argValues[4].pointerVal, __argValues[5].pointerVal,
0ea2a7e6bb41 calls without FFI
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
  1925
							 __argValues[6].pointerVal, __argValues[7].pointerVal );
0ea2a7e6bb41 calls without FFI
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
  1926
			break;
0ea2a7e6bb41 calls without FFI
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
  1927
		    case 9:
0ea2a7e6bb41 calls without FFI
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
  1928
			__returnValue.dVal = (*fd)( __argValues[0].pointerVal, __argValues[1].pointerVal, __argValues[2].pointerVal,
0ea2a7e6bb41 calls without FFI
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
  1929
							 __argValues[3].pointerVal, __argValues[4].pointerVal, __argValues[5].pointerVal,
0ea2a7e6bb41 calls without FFI
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
  1930
							 __argValues[6].pointerVal, __argValues[7].pointerVal, __argValues[8].pointerVal );
0ea2a7e6bb41 calls without FFI
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
  1931
			break;
0ea2a7e6bb41 calls without FFI
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
  1932
		    case 10:
0ea2a7e6bb41 calls without FFI
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
  1933
			__returnValue.dVal = (*fd)( __argValues[0].pointerVal, __argValues[1].pointerVal, __argValues[2].pointerVal,
0ea2a7e6bb41 calls without FFI
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
  1934
							 __argValues[3].pointerVal, __argValues[4].pointerVal, __argValues[5].pointerVal,
0ea2a7e6bb41 calls without FFI
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
  1935
							 __argValues[6].pointerVal, __argValues[7].pointerVal, __argValues[8].pointerVal,
0ea2a7e6bb41 calls without FFI
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
  1936
							 __argValues[9].pointerVal );
0ea2a7e6bb41 calls without FFI
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
  1937
			break;
0ea2a7e6bb41 calls without FFI
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
  1938
		    case 11:
0ea2a7e6bb41 calls without FFI
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
  1939
			__returnValue.dVal = (*fd)( __argValues[0].pointerVal, __argValues[1].pointerVal, __argValues[2].pointerVal,
0ea2a7e6bb41 calls without FFI
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
  1940
							 __argValues[3].pointerVal, __argValues[4].pointerVal, __argValues[5].pointerVal,
0ea2a7e6bb41 calls without FFI
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
  1941
							 __argValues[6].pointerVal, __argValues[7].pointerVal, __argValues[8].pointerVal,
0ea2a7e6bb41 calls without FFI
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
  1942
							 __argValues[9].pointerVal, __argValues[10].pointerVal );
0ea2a7e6bb41 calls without FFI
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
  1943
			break;
0ea2a7e6bb41 calls without FFI
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
  1944
		    case 12:
0ea2a7e6bb41 calls without FFI
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
  1945
			__returnValue.dVal = (*fd)( __argValues[0].pointerVal, __argValues[1].pointerVal, __argValues[2].pointerVal,
0ea2a7e6bb41 calls without FFI
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
  1946
							 __argValues[3].pointerVal, __argValues[4].pointerVal, __argValues[5].pointerVal,
0ea2a7e6bb41 calls without FFI
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
  1947
							 __argValues[6].pointerVal, __argValues[7].pointerVal, __argValues[8].pointerVal,
0ea2a7e6bb41 calls without FFI
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
  1948
							 __argValues[9].pointerVal, __argValues[10].pointerVal, __argValues[11].pointerVal );
0ea2a7e6bb41 calls without FFI
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
  1949
			break;
0ea2a7e6bb41 calls without FFI
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
  1950
		    case 13:
0ea2a7e6bb41 calls without FFI
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
  1951
			__returnValue.dVal = (*fd)( __argValues[0].pointerVal, __argValues[1].pointerVal, __argValues[2].pointerVal,
0ea2a7e6bb41 calls without FFI
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
  1952
							 __argValues[3].pointerVal, __argValues[4].pointerVal, __argValues[5].pointerVal,
0ea2a7e6bb41 calls without FFI
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
  1953
							 __argValues[6].pointerVal, __argValues[7].pointerVal, __argValues[8].pointerVal,
0ea2a7e6bb41 calls without FFI
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
  1954
							 __argValues[9].pointerVal, __argValues[10].pointerVal, __argValues[11].pointerVal,
0ea2a7e6bb41 calls without FFI
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
  1955
							 __argValues[12].pointerVal );
0ea2a7e6bb41 calls without FFI
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
  1956
			break;
0ea2a7e6bb41 calls without FFI
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
  1957
		    case 14:
0ea2a7e6bb41 calls without FFI
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
  1958
			__returnValue.dVal = (*fd)( __argValues[0].pointerVal, __argValues[1].pointerVal, __argValues[2].pointerVal,
0ea2a7e6bb41 calls without FFI
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
  1959
							 __argValues[3].pointerVal, __argValues[4].pointerVal, __argValues[5].pointerVal,
0ea2a7e6bb41 calls without FFI
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
  1960
							 __argValues[6].pointerVal, __argValues[7].pointerVal, __argValues[8].pointerVal,
0ea2a7e6bb41 calls without FFI
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
  1961
							 __argValues[9].pointerVal, __argValues[10].pointerVal, __argValues[11].pointerVal,
0ea2a7e6bb41 calls without FFI
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
  1962
							 __argValues[12].pointerVal, __argValues[13].pointerVal );
0ea2a7e6bb41 calls without FFI
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
  1963
			break;
0ea2a7e6bb41 calls without FFI
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
  1964
		    case 15:
0ea2a7e6bb41 calls without FFI
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
  1965
			__returnValue.dVal = (*fd)( __argValues[0].pointerVal, __argValues[1].pointerVal, __argValues[2].pointerVal,
0ea2a7e6bb41 calls without FFI
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
  1966
							 __argValues[3].pointerVal, __argValues[4].pointerVal, __argValues[5].pointerVal,
0ea2a7e6bb41 calls without FFI
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
  1967
							 __argValues[6].pointerVal, __argValues[7].pointerVal, __argValues[8].pointerVal,
0ea2a7e6bb41 calls without FFI
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
  1968
							 __argValues[9].pointerVal, __argValues[10].pointerVal, __argValues[11].pointerVal,
0ea2a7e6bb41 calls without FFI
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
  1969
							 __argValues[12].pointerVal, __argValues[13].pointerVal, __argValues[14].pointerVal );
0ea2a7e6bb41 calls without FFI
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
  1970
			break;
0ea2a7e6bb41 calls without FFI
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
  1971
		    default:
19932
7fb01b7aff42 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 19931
diff changeset
  1972
			failureCode = @symbol(TooManyArguments);
19931
0ea2a7e6bb41 calls without FFI
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
  1973
			goto getOutOfHere;
0ea2a7e6bb41 calls without FFI
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
  1974
		}
0ea2a7e6bb41 calls without FFI
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
  1975
		break;
0ea2a7e6bb41 calls without FFI
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
  1976
0ea2a7e6bb41 calls without FFI
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
  1977
	    default:
0ea2a7e6bb41 calls without FFI
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
  1978
		switch (__numArgsIncludingThis) {
0ea2a7e6bb41 calls without FFI
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
  1979
		    case 0:
0ea2a7e6bb41 calls without FFI
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
  1980
			__returnValue.pointerVal = (*fi)();
0ea2a7e6bb41 calls without FFI
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
  1981
			break;
0ea2a7e6bb41 calls without FFI
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
  1982
		    case 1:
0ea2a7e6bb41 calls without FFI
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
  1983
			__returnValue.pointerVal = (*fi)( __argValues[0].pointerVal );
0ea2a7e6bb41 calls without FFI
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
  1984
			break;
0ea2a7e6bb41 calls without FFI
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
  1985
		    case 2:
0ea2a7e6bb41 calls without FFI
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
  1986
			__returnValue.pointerVal = (*fi)( __argValues[0].pointerVal, __argValues[1].pointerVal );
0ea2a7e6bb41 calls without FFI
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
  1987
			break;
0ea2a7e6bb41 calls without FFI
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
  1988
		    case 3:
0ea2a7e6bb41 calls without FFI
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
  1989
			__returnValue.pointerVal = (*fi)( __argValues[0].pointerVal, __argValues[1].pointerVal, __argValues[2].pointerVal );
0ea2a7e6bb41 calls without FFI
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
  1990
			break;
0ea2a7e6bb41 calls without FFI
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
  1991
		    case 4:
0ea2a7e6bb41 calls without FFI
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
  1992
			__returnValue.pointerVal = (*fi)( __argValues[0].pointerVal, __argValues[1].pointerVal, __argValues[2].pointerVal,
0ea2a7e6bb41 calls without FFI
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
  1993
							 __argValues[3].pointerVal );
0ea2a7e6bb41 calls without FFI
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
  1994
			break;
0ea2a7e6bb41 calls without FFI
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
  1995
		    case 5:
0ea2a7e6bb41 calls without FFI
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
  1996
			__returnValue.pointerVal = (*fi)( __argValues[0].pointerVal, __argValues[1].pointerVal, __argValues[2].pointerVal,
0ea2a7e6bb41 calls without FFI
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
  1997
							 __argValues[3].pointerVal, __argValues[4].pointerVal );
0ea2a7e6bb41 calls without FFI
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
  1998
			break;
0ea2a7e6bb41 calls without FFI
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
  1999
		    case 6:
0ea2a7e6bb41 calls without FFI
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
  2000
			__returnValue.pointerVal = (*fi)( __argValues[0].pointerVal, __argValues[1].pointerVal, __argValues[2].pointerVal,
0ea2a7e6bb41 calls without FFI
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
  2001
							 __argValues[3].pointerVal, __argValues[4].pointerVal, __argValues[5].pointerVal );
0ea2a7e6bb41 calls without FFI
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
  2002
			break;
0ea2a7e6bb41 calls without FFI
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
  2003
		    case 7:
0ea2a7e6bb41 calls without FFI
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
  2004
			__returnValue.pointerVal = (*fi)( __argValues[0].pointerVal, __argValues[1].pointerVal, __argValues[2].pointerVal,
0ea2a7e6bb41 calls without FFI
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
  2005
							 __argValues[3].pointerVal, __argValues[4].pointerVal, __argValues[5].pointerVal,
0ea2a7e6bb41 calls without FFI
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
  2006
							 __argValues[6].pointerVal );
0ea2a7e6bb41 calls without FFI
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
  2007
			break;
0ea2a7e6bb41 calls without FFI
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
  2008
		    case 8:
0ea2a7e6bb41 calls without FFI
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
  2009
			__returnValue.pointerVal = (*fi)( __argValues[0].pointerVal, __argValues[1].pointerVal, __argValues[2].pointerVal,
0ea2a7e6bb41 calls without FFI
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
  2010
							 __argValues[3].pointerVal, __argValues[4].pointerVal, __argValues[5].pointerVal,
0ea2a7e6bb41 calls without FFI
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
  2011
							 __argValues[6].pointerVal, __argValues[7].pointerVal );
0ea2a7e6bb41 calls without FFI
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
  2012
			break;
0ea2a7e6bb41 calls without FFI
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
  2013
		    case 9:
0ea2a7e6bb41 calls without FFI
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
  2014
			__returnValue.pointerVal = (*fi)( __argValues[0].pointerVal, __argValues[1].pointerVal, __argValues[2].pointerVal,
0ea2a7e6bb41 calls without FFI
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
  2015
							 __argValues[3].pointerVal, __argValues[4].pointerVal, __argValues[5].pointerVal,
0ea2a7e6bb41 calls without FFI
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
  2016
							 __argValues[6].pointerVal, __argValues[7].pointerVal, __argValues[8].pointerVal );
0ea2a7e6bb41 calls without FFI
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
  2017
			break;
0ea2a7e6bb41 calls without FFI
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
  2018
		    case 10:
0ea2a7e6bb41 calls without FFI
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
  2019
			__returnValue.pointerVal = (*fi)( __argValues[0].pointerVal, __argValues[1].pointerVal, __argValues[2].pointerVal,
0ea2a7e6bb41 calls without FFI
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
  2020
							 __argValues[3].pointerVal, __argValues[4].pointerVal, __argValues[5].pointerVal,
0ea2a7e6bb41 calls without FFI
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
  2021
							 __argValues[6].pointerVal, __argValues[7].pointerVal, __argValues[8].pointerVal,
0ea2a7e6bb41 calls without FFI
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
  2022
							 __argValues[9].pointerVal );
0ea2a7e6bb41 calls without FFI
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
  2023
			break;
0ea2a7e6bb41 calls without FFI
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
  2024
		    case 11:
0ea2a7e6bb41 calls without FFI
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
  2025
			__returnValue.pointerVal = (*fi)( __argValues[0].pointerVal, __argValues[1].pointerVal, __argValues[2].pointerVal,
0ea2a7e6bb41 calls without FFI
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
  2026
							 __argValues[3].pointerVal, __argValues[4].pointerVal, __argValues[5].pointerVal,
0ea2a7e6bb41 calls without FFI
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
  2027
							 __argValues[6].pointerVal, __argValues[7].pointerVal, __argValues[8].pointerVal,
0ea2a7e6bb41 calls without FFI
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
  2028
							 __argValues[9].pointerVal, __argValues[10].pointerVal );
0ea2a7e6bb41 calls without FFI
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
  2029
			break;
0ea2a7e6bb41 calls without FFI
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
  2030
		    case 12:
0ea2a7e6bb41 calls without FFI
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
  2031
			__returnValue.pointerVal = (*fi)( __argValues[0].pointerVal, __argValues[1].pointerVal, __argValues[2].pointerVal,
0ea2a7e6bb41 calls without FFI
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
  2032
							 __argValues[3].pointerVal, __argValues[4].pointerVal, __argValues[5].pointerVal,
0ea2a7e6bb41 calls without FFI
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
  2033
							 __argValues[6].pointerVal, __argValues[7].pointerVal, __argValues[8].pointerVal,
0ea2a7e6bb41 calls without FFI
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
  2034
							 __argValues[9].pointerVal, __argValues[10].pointerVal, __argValues[11].pointerVal );
0ea2a7e6bb41 calls without FFI
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
  2035
			break;
0ea2a7e6bb41 calls without FFI
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
  2036
		    case 13:
0ea2a7e6bb41 calls without FFI
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
  2037
			__returnValue.pointerVal = (*fi)( __argValues[0].pointerVal, __argValues[1].pointerVal, __argValues[2].pointerVal,
0ea2a7e6bb41 calls without FFI
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
  2038
							 __argValues[3].pointerVal, __argValues[4].pointerVal, __argValues[5].pointerVal,
0ea2a7e6bb41 calls without FFI
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
  2039
							 __argValues[6].pointerVal, __argValues[7].pointerVal, __argValues[8].pointerVal,
0ea2a7e6bb41 calls without FFI
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
  2040
							 __argValues[9].pointerVal, __argValues[10].pointerVal, __argValues[11].pointerVal,
0ea2a7e6bb41 calls without FFI
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
  2041
							 __argValues[12].pointerVal );
0ea2a7e6bb41 calls without FFI
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
  2042
			break;
0ea2a7e6bb41 calls without FFI
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
  2043
		    case 14:
0ea2a7e6bb41 calls without FFI
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
  2044
			__returnValue.pointerVal = (*fi)( __argValues[0].pointerVal, __argValues[1].pointerVal, __argValues[2].pointerVal,
0ea2a7e6bb41 calls without FFI
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
  2045
							 __argValues[3].pointerVal, __argValues[4].pointerVal, __argValues[5].pointerVal,
0ea2a7e6bb41 calls without FFI
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
  2046
							 __argValues[6].pointerVal, __argValues[7].pointerVal, __argValues[8].pointerVal,
0ea2a7e6bb41 calls without FFI
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
  2047
							 __argValues[9].pointerVal, __argValues[10].pointerVal, __argValues[11].pointerVal,
0ea2a7e6bb41 calls without FFI
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
  2048
							 __argValues[12].pointerVal, __argValues[13].pointerVal );
0ea2a7e6bb41 calls without FFI
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
  2049
			break;
0ea2a7e6bb41 calls without FFI
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
  2050
		    case 15:
0ea2a7e6bb41 calls without FFI
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
  2051
			__returnValue.pointerVal = (*fi)( __argValues[0].pointerVal, __argValues[1].pointerVal, __argValues[2].pointerVal,
0ea2a7e6bb41 calls without FFI
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
  2052
							 __argValues[3].pointerVal, __argValues[4].pointerVal, __argValues[5].pointerVal,
0ea2a7e6bb41 calls without FFI
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
  2053
							 __argValues[6].pointerVal, __argValues[7].pointerVal, __argValues[8].pointerVal,
0ea2a7e6bb41 calls without FFI
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
  2054
							 __argValues[9].pointerVal, __argValues[10].pointerVal, __argValues[11].pointerVal,
0ea2a7e6bb41 calls without FFI
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
  2055
							 __argValues[12].pointerVal, __argValues[13].pointerVal, __argValues[14].pointerVal );
0ea2a7e6bb41 calls without FFI
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
  2056
			break;
0ea2a7e6bb41 calls without FFI
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
  2057
		    default:
19932
7fb01b7aff42 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 19931
diff changeset
  2058
			failureCode = @symbol(TooManyArguments);
19931
0ea2a7e6bb41 calls without FFI
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
  2059
			goto getOutOfHere;
0ea2a7e6bb41 calls without FFI
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
  2060
		}
0ea2a7e6bb41 calls without FFI
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
  2061
	}
0ea2a7e6bb41 calls without FFI
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
  2062
    }
0ea2a7e6bb41 calls without FFI
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
  2063
#  else
0ea2a7e6bb41 calls without FFI
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
  2064
    failureCode = @symbol(FFINotSupported);
0ea2a7e6bb41 calls without FFI
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
  2065
    goto getOutOfHere;
0ea2a7e6bb41 calls without FFI
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
  2066
#  endif
0ea2a7e6bb41 calls without FFI
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
  2067
# endif
0ea2a7e6bb41 calls without FFI
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
  2068
12504
c9987bb76eb6 untested long long return value
Claus Gittinger <cg@exept.de>
parents: 12503
diff changeset
  2069
# ifdef VERBOSE
19314
698cf296ef6d mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents: 19313
diff changeset
  2070
    if (@global(Verbose) == true) {
19535
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  2071
	printf("retval is %"_ld_" (0x%"_lx_")\n", (INT)(__returnValue.iVal), (INT)(__returnValue.iVal));
19314
698cf296ef6d mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents: 19313
diff changeset
  2072
    }
12504
c9987bb76eb6 untested long long return value
Claus Gittinger <cg@exept.de>
parents: 12503
diff changeset
  2073
# endif
19314
698cf296ef6d mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents: 19313
diff changeset
  2074
11586
a3b2eef8a74c int vs. sint
Claus Gittinger <cg@exept.de>
parents: 11426
diff changeset
  2075
    if ((returnTypeSymbol == @symbol(int))
a3b2eef8a74c int vs. sint
Claus Gittinger <cg@exept.de>
parents: 11426
diff changeset
  2076
     || (returnTypeSymbol == @symbol(sint))
9479
68d12a181d4a handle types; sint32 types.
ca
parents: 9466
diff changeset
  2077
     || (returnTypeSymbol == @symbol(sint8))
68d12a181d4a handle types; sint32 types.
ca
parents: 9466
diff changeset
  2078
     || (returnTypeSymbol == @symbol(sint16))
68d12a181d4a handle types; sint32 types.
ca
parents: 9466
diff changeset
  2079
     || (returnTypeSymbol == @symbol(sint32))) {
19314
698cf296ef6d mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents: 19313
diff changeset
  2080
# ifdef VERBOSE
19535
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  2081
	if (@global(Verbose) == true) {
19931
0ea2a7e6bb41 calls without FFI
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
  2082
	    printf("return int: %"_lx_"\n", (INT)(__returnValue.iVal));
19535
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  2083
	}
19314
698cf296ef6d mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents: 19313
diff changeset
  2084
# endif
19535
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  2085
	RETURN ( __MKINT(__returnValue.iVal) );
9342
e548ce80ab02 virtual calls
Claus Gittinger <cg@exept.de>
parents: 9341
diff changeset
  2086
    }
e548ce80ab02 virtual calls
Claus Gittinger <cg@exept.de>
parents: 9341
diff changeset
  2087
    if ((returnTypeSymbol == @symbol(uint))
e548ce80ab02 virtual calls
Claus Gittinger <cg@exept.de>
parents: 9341
diff changeset
  2088
     || (returnTypeSymbol == @symbol(uint8))
e548ce80ab02 virtual calls
Claus Gittinger <cg@exept.de>
parents: 9341
diff changeset
  2089
     || (returnTypeSymbol == @symbol(uint16))
e548ce80ab02 virtual calls
Claus Gittinger <cg@exept.de>
parents: 9341
diff changeset
  2090
     || (returnTypeSymbol == @symbol(uint32))) {
19314
698cf296ef6d mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents: 19313
diff changeset
  2091
# ifdef VERBOSE
19535
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  2092
	if (@global(Verbose) == true) {
19931
0ea2a7e6bb41 calls without FFI
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
  2093
	    printf("return uint: %"_lx_"\n", (INT)(__returnValue.iVal));
19535
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  2094
	}
19314
698cf296ef6d mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents: 19313
diff changeset
  2095
# endif
19535
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  2096
	RETURN ( __MKUINT(__returnValue.iVal) );
9342
e548ce80ab02 virtual calls
Claus Gittinger <cg@exept.de>
parents: 9341
diff changeset
  2097
    }
10025
053904a63549 stc-compiled ExternalLibraryFunctions
Claus Gittinger <cg@exept.de>
parents: 9981
diff changeset
  2098
    if (returnTypeSymbol == @symbol(bool)) {
19535
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  2099
	RETURN ( __returnValue.iVal ? true : false );
9342
e548ce80ab02 virtual calls
Claus Gittinger <cg@exept.de>
parents: 9341
diff changeset
  2100
    }
e548ce80ab02 virtual calls
Claus Gittinger <cg@exept.de>
parents: 9341
diff changeset
  2101
    if (returnTypeSymbol == @symbol(float)) {
19535
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  2102
	RETURN ( __MKFLOAT(__returnValue.fVal ));
9342
e548ce80ab02 virtual calls
Claus Gittinger <cg@exept.de>
parents: 9341
diff changeset
  2103
    }
e548ce80ab02 virtual calls
Claus Gittinger <cg@exept.de>
parents: 9341
diff changeset
  2104
    if (returnTypeSymbol == @symbol(double)) {
19535
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  2105
	RETURN ( __MKFLOAT(__returnValue.dVal ));
9342
e548ce80ab02 virtual calls
Claus Gittinger <cg@exept.de>
parents: 9341
diff changeset
  2106
    }
e548ce80ab02 virtual calls
Claus Gittinger <cg@exept.de>
parents: 9341
diff changeset
  2107
    if (returnTypeSymbol == @symbol(void)) {
19535
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  2108
	RETURN ( nil );
9342
e548ce80ab02 virtual calls
Claus Gittinger <cg@exept.de>
parents: 9341
diff changeset
  2109
    }
9463
864880338d7e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9460
diff changeset
  2110
    if (returnTypeSymbol == @symbol(char)) {
19535
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  2111
	RETURN ( __MKCHARACTER(__returnValue.iVal & 0xFF) );
9463
864880338d7e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9460
diff changeset
  2112
    }
864880338d7e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9460
diff changeset
  2113
    if (returnTypeSymbol == @symbol(wchar)) {
19535
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  2114
	RETURN ( __MKUCHARACTER(__returnValue.iVal & 0xFFFF) );
12504
c9987bb76eb6 untested long long return value
Claus Gittinger <cg@exept.de>
parents: 12503
diff changeset
  2115
    }
c9987bb76eb6 untested long long return value
Claus Gittinger <cg@exept.de>
parents: 12503
diff changeset
  2116
    if (returnTypeSymbol == @symbol(sint64)) {
19356
5ca3989a13f0 bcc fixes
Claus Gittinger <cg@exept.de>
parents: 19355
diff changeset
  2117
# if (__POINTER_SIZE__ == 8)
19355
58ef1e6a54f9 fix for bcc
Claus Gittinger <cg@exept.de>
parents: 19343
diff changeset
  2118
58ef1e6a54f9 fix for bcc
Claus Gittinger <cg@exept.de>
parents: 19343
diff changeset
  2119
#  ifdef VERBOSE
19535
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  2120
	if (@global(Verbose) == true) {
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  2121
	    printf("return sint64: %"_lx_"\n", (INT)(__returnValue.longLongVal));
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  2122
	}
19355
58ef1e6a54f9 fix for bcc
Claus Gittinger <cg@exept.de>
parents: 19343
diff changeset
  2123
#  endif
19535
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  2124
	RETURN ( __MKINT(__returnValue.longLongVal) );
19314
698cf296ef6d mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents: 19313
diff changeset
  2125
# else
19355
58ef1e6a54f9 fix for bcc
Claus Gittinger <cg@exept.de>
parents: 19343
diff changeset
  2126
#  ifdef VERBOSE
19535
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  2127
	if (@global(Verbose) == true) {
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  2128
	    printf("return sint64: %lx%08lx\n", __HI32(__returnValue.longLongVal), __LO32(__returnValue.longLongVal));
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  2129
	}
19355
58ef1e6a54f9 fix for bcc
Claus Gittinger <cg@exept.de>
parents: 19343
diff changeset
  2130
#  endif
19535
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  2131
	RETURN ( __MKINT64(&__returnValue.longLongVal) );
19314
698cf296ef6d mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents: 19313
diff changeset
  2132
# endif
12504
c9987bb76eb6 untested long long return value
Claus Gittinger <cg@exept.de>
parents: 12503
diff changeset
  2133
    }
c9987bb76eb6 untested long long return value
Claus Gittinger <cg@exept.de>
parents: 12503
diff changeset
  2134
    if (returnTypeSymbol == @symbol(uint64)) {
19356
5ca3989a13f0 bcc fixes
Claus Gittinger <cg@exept.de>
parents: 19355
diff changeset
  2135
# if (__POINTER_SIZE__ == 8)
19314
698cf296ef6d mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents: 19313
diff changeset
  2136
# ifdef VERBOSE
19535
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  2137
	if (@global(Verbose) == true) {
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  2138
	    printf("return uint64: %"_lx_"\n", (unsigned INT)(__returnValue.longLongVal));
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  2139
	}
19314
698cf296ef6d mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents: 19313
diff changeset
  2140
# endif
19535
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  2141
	RETURN ( __MKUINT(__returnValue.longLongVal) );
19314
698cf296ef6d mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents: 19313
diff changeset
  2142
# else
19355
58ef1e6a54f9 fix for bcc
Claus Gittinger <cg@exept.de>
parents: 19343
diff changeset
  2143
#  ifdef VERBOSE
19535
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  2144
	if (@global(Verbose) == true) {
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  2145
	    printf("return sint64: %lx%08lx\n", __HI32(__returnValue.longLongVal), __LO32(__returnValue.longLongVal));
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  2146
	}
19355
58ef1e6a54f9 fix for bcc
Claus Gittinger <cg@exept.de>
parents: 19343
diff changeset
  2147
#  endif
19535
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  2148
	RETURN ( __MKUINT64(&__returnValue.longLongVal) );
19314
698cf296ef6d mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents: 19313
diff changeset
  2149
# endif
9463
864880338d7e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9460
diff changeset
  2150
    }
11586
a3b2eef8a74c int vs. sint
Claus Gittinger <cg@exept.de>
parents: 11426
diff changeset
  2151
12504
c9987bb76eb6 untested long long return value
Claus Gittinger <cg@exept.de>
parents: 12503
diff changeset
  2152
# ifdef VERBOSE
19314
698cf296ef6d mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents: 19313
diff changeset
  2153
    if (@global(Verbose) == true) {
19535
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  2154
	printf("return pointer: %"_lx_"\n", (INT)(__returnValue.pointerVal));
19314
698cf296ef6d mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents: 19313
diff changeset
  2155
    }
12504
c9987bb76eb6 untested long long return value
Claus Gittinger <cg@exept.de>
parents: 12503
diff changeset
  2156
# endif
9346
a95e2cf0e56f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9344
diff changeset
  2157
    if (returnTypeSymbol == @symbol(handle)) {
19535
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  2158
	returnValue = __MKEXTERNALADDRESS(__returnValue.pointerVal);
9346
a95e2cf0e56f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9344
diff changeset
  2159
    } else if (returnTypeSymbol == @symbol(pointer)) {
19535
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  2160
	returnValue = __MKEXTERNALBYTES(__returnValue.pointerVal);
10603
da9b7ed81caf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10514
diff changeset
  2161
    } else if (returnTypeSymbol == @symbol(bytePointer)) {
19535
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  2162
	returnValue = __MKEXTERNALBYTES(__returnValue.pointerVal);
9463
864880338d7e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9460
diff changeset
  2163
    } else if (returnTypeSymbol == @symbol(charPointer)) {
19535
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  2164
	returnValue = __MKSTRING(__returnValue.pointerVal);
9463
864880338d7e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9460
diff changeset
  2165
    } else if (returnTypeSymbol == @symbol(wcharPointer)) {
19535
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  2166
	returnValue = __MKU16STRING(__returnValue.pointerVal);
9342
e548ce80ab02 virtual calls
Claus Gittinger <cg@exept.de>
parents: 9341
diff changeset
  2167
    } else {
19535
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  2168
	__FAIL__(@symbol(UnknownReturnType2))
9342
e548ce80ab02 virtual calls
Claus Gittinger <cg@exept.de>
parents: 9341
diff changeset
  2169
    }
19931
0ea2a7e6bb41 calls without FFI
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
  2170
//#else /* no FFI support */
0ea2a7e6bb41 calls without FFI
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
  2171
//    failureCode = @symbol(FFINotSupported);
0ea2a7e6bb41 calls without FFI
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
  2172
//#endif /* HAVE_FFI */
0ea2a7e6bb41 calls without FFI
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
  2173
9342
e548ce80ab02 virtual calls
Claus Gittinger <cg@exept.de>
parents: 9341
diff changeset
  2174
getOutOfHere: ;
e548ce80ab02 virtual calls
Claus Gittinger <cg@exept.de>
parents: 9341
diff changeset
  2175
%}.
e548ce80ab02 virtual calls
Claus Gittinger <cg@exept.de>
parents: 9341
diff changeset
  2176
    failureCode notNil ifTrue:[
19535
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  2177
	(failureCode == #UnknownReturnType or:[ failureCode == #UnknownArgumentType ]) ifTrue:[
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  2178
	    oldReturnType := returnType.
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  2179
	    oldArgumentTypes := argumentTypes.
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  2180
	    self adjustTypes.
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  2181
	    ((oldReturnType ~= returnType) or:[oldArgumentTypes ~= argumentTypes]) ifTrue:[
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  2182
		thisContext restart
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  2183
	    ].
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  2184
	].
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  2185
	(failureCode == #BadArgForAsyncCall) ifTrue:[
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  2186
	    ^ self tryAgainWithAsyncSafeArguments:argumentsOrNil forCPPInstance:aReceiverOrNil
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  2187
	].
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  2188
	(failureCode == #FFINotSupported) ifTrue:[
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  2189
	    self primitiveFailed:'FFI support missing in this build'.
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  2190
	].
12579
516bba5b3e57 changed: #ffiTypeSymbolForType:
Claus Gittinger <cg@exept.de>
parents: 12504
diff changeset
  2191
19535
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  2192
	self primitiveFailed.   "see failureCode and failureInfo for details"
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  2193
	^ nil
9342
e548ce80ab02 virtual calls
Claus Gittinger <cg@exept.de>
parents: 9341
diff changeset
  2194
    ].
e548ce80ab02 virtual calls
Claus Gittinger <cg@exept.de>
parents: 9341
diff changeset
  2195
9483
3bea515ce81e *** empty log message ***
fm
parents: 9479
diff changeset
  2196
    returnType isSymbol ifTrue:[
19535
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  2197
	returnValueClass notNil ifTrue:[
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  2198
	    self isConstReturnValue ifTrue:[
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  2199
		returnValue changeClassTo:returnValueClass.
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  2200
		^ returnValue
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  2201
	    ].
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  2202
	    ^ returnValueClass fromExternalAddress:returnValue.
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  2203
	].
9483
3bea515ce81e *** empty log message ***
fm
parents: 9479
diff changeset
  2204
    ] ifFalse:[
19535
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  2205
	returnType isCPointer ifTrue:[
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  2206
	    returnType baseType isCStruct ifTrue:[
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  2207
		stClass := Smalltalk classNamed:returnType baseType name.
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  2208
		stClass notNil ifTrue:[
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  2209
		    self isConstReturnValue ifTrue:[
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  2210
			returnValue changeClassTo:returnValueClass.
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  2211
			^ returnValue
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  2212
		    ].
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  2213
		    ^ stClass fromExternalAddress:returnValue.
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  2214
		].
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  2215
	    ].
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  2216
	    returnType baseType isCChar ifTrue:[
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  2217
		^ returnValue stringAt:1
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  2218
	    ].
6c3365fc82bc fix for mingw ffi-calls
Claus Gittinger <cg@exept.de>
parents: 19514
diff changeset
  2219
	].
9342
e548ce80ab02 virtual calls
Claus Gittinger <cg@exept.de>
parents: 9341
diff changeset
  2220
    ].
e548ce80ab02 virtual calls
Claus Gittinger <cg@exept.de>
parents: 9341
diff changeset
  2221
e548ce80ab02 virtual calls
Claus Gittinger <cg@exept.de>
parents: 9341
diff changeset
  2222
    ^ returnValue
9463
864880338d7e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9460
diff changeset
  2223
864880338d7e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9460
diff changeset
  2224
    "Created: / 01-08-2006 / 13:56:23 / cg"
19514
7605a907a2eb #UI_ENHANCEMENT
Claus Gittinger <cg@exept.de>
parents: 19505
diff changeset
  2225
    "Modified: / 31-03-2016 / 00:03:03 / cg"
14037
Michael Beyl <mb@exept.de>
parents: 13782
diff changeset
  2226
!
Michael Beyl <mb@exept.de>
parents: 13782
diff changeset
  2227
14659
410089913ca1 allow use of the standard (system) ffi
Claus Gittinger <cg@exept.de>
parents: 14632
diff changeset
  2228
tryAgainWithAsyncSafeArguments:argumentsOrNil forCPPInstance:aReceiverOrNil
14037
Michael Beyl <mb@exept.de>
parents: 13782
diff changeset
  2229
    "invoked by the call primitive, iff GC-unsave arguments where passed to the call.
Michael Beyl <mb@exept.de>
parents: 13782
diff changeset
  2230
     Here, allocate non-movable blocks of memory and copy the arguments into them,
Michael Beyl <mb@exept.de>
parents: 13782
diff changeset
  2231
     then try the call again, copy changed values back, and release the memeory."
Michael Beyl <mb@exept.de>
parents: 13782
diff changeset
  2232
Michael Beyl <mb@exept.de>
parents: 13782
diff changeset
  2233
    |saveArguments anyBadArg result originalToSaveArgMapping|
Michael Beyl <mb@exept.de>
parents: 13782
diff changeset
  2234
Michael Beyl <mb@exept.de>
parents: 13782
diff changeset
  2235
    argumentsOrNil isNil ifTrue:[
14625
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  2236
	^ self primitiveFailed
14037
Michael Beyl <mb@exept.de>
parents: 13782
diff changeset
  2237
    ].
14506
e53548cdc24d changed: #tryAgainWithAsyncSafeArguments:forCPPInstance:
anwild
parents: 14412
diff changeset
  2238
    thisContext isRecursive ifTrue: [^self primitiveFailed].
14037
Michael Beyl <mb@exept.de>
parents: 13782
diff changeset
  2239
Michael Beyl <mb@exept.de>
parents: 13782
diff changeset
  2240
    anyBadArg := false.
Michael Beyl <mb@exept.de>
parents: 13782
diff changeset
  2241
    originalToSaveArgMapping := IdentityDictionary new.
Michael Beyl <mb@exept.de>
parents: 13782
diff changeset
  2242
14625
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  2243
    saveArguments := argumentsOrNil
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  2244
			collect:[:eachArg |
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  2245
			    |saveArg|
14037
Michael Beyl <mb@exept.de>
parents: 13782
diff changeset
  2246
14625
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  2247
			    (originalToSaveArgMapping includesKey:eachArg) ifTrue:[
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  2248
				saveArg := originalToSaveArgMapping at:eachArg
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  2249
			    ] ifFalse:[
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  2250
				eachArg isString ifTrue:[
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  2251
				    saveArg := (ExternalBytes fromString:eachArg) register.
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  2252
				    anyBadArg := true.
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  2253
				    originalToSaveArgMapping at:eachArg put:saveArg.
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  2254
				] ifFalse:[
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  2255
				    eachArg isByteCollection ifTrue:[
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  2256
					saveArg := (ExternalBytes from:eachArg) register.
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  2257
					originalToSaveArgMapping at:eachArg put:saveArg.
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  2258
					anyBadArg := true.
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  2259
				    ] ifFalse:[
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  2260
					saveArg := eachArg
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  2261
				    ]
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  2262
				].
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  2263
			    ].
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  2264
			    saveArg
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  2265
			].
14037
Michael Beyl <mb@exept.de>
parents: 13782
diff changeset
  2266
Michael Beyl <mb@exept.de>
parents: 13782
diff changeset
  2267
    anyBadArg ifFalse:[
14625
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  2268
	"avoid recursion..."
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  2269
	^ self primitiveFailed
14037
Michael Beyl <mb@exept.de>
parents: 13782
diff changeset
  2270
    ].
Michael Beyl <mb@exept.de>
parents: 13782
diff changeset
  2271
14659
410089913ca1 allow use of the standard (system) ffi
Claus Gittinger <cg@exept.de>
parents: 14632
diff changeset
  2272
    result := self invokeFFIwithArguments:saveArguments forCPPInstance:aReceiverOrNil.
14037
Michael Beyl <mb@exept.de>
parents: 13782
diff changeset
  2273
Michael Beyl <mb@exept.de>
parents: 13782
diff changeset
  2274
    "/ copy back !!
Michael Beyl <mb@exept.de>
parents: 13782
diff changeset
  2275
    originalToSaveArgMapping keysAndValuesDo:[:arg :saveArg |
14625
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  2276
	arg isSymbol ifFalse:[
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  2277
	    arg replaceFrom:1 to:(arg size) with:saveArg startingAt:1.
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  2278
	].
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  2279
	saveArg free.
14037
Michael Beyl <mb@exept.de>
parents: 13782
diff changeset
  2280
    ].
Michael Beyl <mb@exept.de>
parents: 13782
diff changeset
  2281
    ^ result.
14506
e53548cdc24d changed: #tryAgainWithAsyncSafeArguments:forCPPInstance:
anwild
parents: 14412
diff changeset
  2282
e53548cdc24d changed: #tryAgainWithAsyncSafeArguments:forCPPInstance:
anwild
parents: 14412
diff changeset
  2283
    "Modified (format): / 06-11-2012 / 10:52:41 / anwild"
9342
e548ce80ab02 virtual calls
Claus Gittinger <cg@exept.de>
parents: 9341
diff changeset
  2284
! !
e548ce80ab02 virtual calls
Claus Gittinger <cg@exept.de>
parents: 9341
diff changeset
  2285
10481
b3526180579f +isExternalLibraryFunction
fm
parents: 10440
diff changeset
  2286
!ExternalLibraryFunction methodsFor:'testing'!
b3526180579f +isExternalLibraryFunction
fm
parents: 10440
diff changeset
  2287
10603
da9b7ed81caf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10514
diff changeset
  2288
isExternalLibraryFunction
da9b7ed81caf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10514
diff changeset
  2289
    "return true, if the receiver is some kind of externalLibrary function;
da9b7ed81caf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10514
diff changeset
  2290
     true is returned here"
da9b7ed81caf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10514
diff changeset
  2291
da9b7ed81caf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10514
diff changeset
  2292
    ^true
da9b7ed81caf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10514
diff changeset
  2293
da9b7ed81caf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10514
diff changeset
  2294
    "Created: / 07-06-2007 / 10:36:40 / cg"
10481
b3526180579f +isExternalLibraryFunction
fm
parents: 10440
diff changeset
  2295
! !
b3526180579f +isExternalLibraryFunction
fm
parents: 10440
diff changeset
  2296
8533
9065c547ea75 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2297
!ExternalLibraryFunction class methodsFor:'documentation'!
9065c547ea75 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2298
19487
79d76a2de0f1 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 19483
diff changeset
  2299
version
79d76a2de0f1 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 19483
diff changeset
  2300
    ^ '$Header$'
79d76a2de0f1 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 19483
diff changeset
  2301
!
79d76a2de0f1 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 19483
diff changeset
  2302
13412
9a5f99d66cd9 Jan's changes
vrany
parents: 13337
diff changeset
  2303
version_CVS
19311
6f1d1ea6dba8 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 18240
diff changeset
  2304
    ^ '$Header$'
12436
92a968c9ca92 changed:
Claus Gittinger <cg@exept.de>
parents: 11586
diff changeset
  2305
!
92a968c9ca92 changed:
Claus Gittinger <cg@exept.de>
parents: 11586
diff changeset
  2306
13412
9a5f99d66cd9 Jan's changes
vrany
parents: 13337
diff changeset
  2307
version_SVN
19311
6f1d1ea6dba8 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 18240
diff changeset
  2308
    ^ '$ Id: ExternalLibraryFunction.st 10643 2011-06-08 21:53:07Z vranyj1  $'
8533
9065c547ea75 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2309
! !
9463
864880338d7e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9460
diff changeset
  2310
19311
6f1d1ea6dba8 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 18240
diff changeset
  2311
9463
864880338d7e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9460
diff changeset
  2312
ExternalLibraryFunction initialize!