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