ExternalLibraryFunction.st
author Claus Gittinger <cg@exept.de>
Wed, 02 Jan 2013 13:45:06 +0100
changeset 14625 290463096ff5
parent 14516 359e4d2234af
child 14632 6fe0dc1d5377
permissions -rw-r--r--
NEED_DOUBLE_ALIGN fix
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
9065c547ea75 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    14
ExternalFunction subclass:#ExternalLibraryFunction
9465
d11885052713 rewrite & cleanup
Claus Gittinger <cg@exept.de>
parents: 9464
diff changeset
    15
	instanceVariableNames:'flags moduleName returnType argumentTypes owningClass'
10270
897474c6c785 allow setting the dllPath
fm
parents: 10213
diff changeset
    16
	classVariableNames:'DLLPATH FLAG_VIRTUAL FLAG_NONVIRTUAL FLAG_ASYNC
897474c6c785 allow setting the dllPath
fm
parents: 10213
diff changeset
    17
		FLAG_UNLIMITEDSTACK FLAG_RETVAL_IS_CONST CALLTYPE_MASK
897474c6c785 allow setting the dllPath
fm
parents: 10213
diff changeset
    18
		CALLTYPE_API CALLTYPE_C CALLTYPE_OLE CALLTYPE_V8 CALLTYPE_V9
14103
3df000b77712 class definition
Claus Gittinger <cg@exept.de>
parents: 14037
diff changeset
    19
		CALLTYPE_UNIX64 DllMapping'
9464
157fe6ca53e6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9463
diff changeset
    20
	poolDictionaries:''
157fe6ca53e6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9463
diff changeset
    21
	category:'System-Support'
8533
9065c547ea75 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    22
!
9065c547ea75 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    23
9322
41c391bfbf03 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9321
diff changeset
    24
!ExternalLibraryFunction primitiveDefinitions!
41c391bfbf03 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9321
diff changeset
    25
%{
41c391bfbf03 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9321
diff changeset
    26
9337
ab6bbf58bf0a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9336
diff changeset
    27
#ifdef HAVE_FFI
ab6bbf58bf0a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9336
diff changeset
    28
# include <ffi.h>
9322
41c391bfbf03 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9321
diff changeset
    29
# define MAX_ARGS    128
9365
9003f8432516 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9347
diff changeset
    30
9003f8432516 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9347
diff changeset
    31
extern ffi_type *__get_ffi_type_sint();
9003f8432516 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9347
diff changeset
    32
extern ffi_type *__get_ffi_type_sint8();
9003f8432516 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9347
diff changeset
    33
extern ffi_type *__get_ffi_type_sint16();
9003f8432516 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9347
diff changeset
    34
extern ffi_type *__get_ffi_type_sint32();
9003f8432516 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9347
diff changeset
    35
extern ffi_type *__get_ffi_type_sint64();
9003f8432516 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9347
diff changeset
    36
extern ffi_type *__get_ffi_type_uint();
9003f8432516 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9347
diff changeset
    37
extern ffi_type *__get_ffi_type_uint8();
9003f8432516 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9347
diff changeset
    38
extern ffi_type *__get_ffi_type_uint16();
9003f8432516 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9347
diff changeset
    39
extern ffi_type *__get_ffi_type_uint32();
9003f8432516 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9347
diff changeset
    40
extern ffi_type *__get_ffi_type_uint64();
9003f8432516 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9347
diff changeset
    41
extern ffi_type *__get_ffi_type_float();
9003f8432516 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9347
diff changeset
    42
extern ffi_type *__get_ffi_type_double();
9003f8432516 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9347
diff changeset
    43
extern ffi_type *__get_ffi_type_void();
9003f8432516 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9347
diff changeset
    44
extern ffi_type *__get_ffi_type_pointer();
9003f8432516 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9347
diff changeset
    45
13412
9a5f99d66cd9 Jan's changes
vrany
parents: 13337
diff changeset
    46
#else
14625
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
    47
# error "HAVE_FFI not defined!"
9337
ab6bbf58bf0a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9336
diff changeset
    48
#endif
9322
41c391bfbf03 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9321
diff changeset
    49
41c391bfbf03 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9321
diff changeset
    50
%}
41c391bfbf03 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9321
diff changeset
    51
! !
41c391bfbf03 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9321
diff changeset
    52
8728
d70396dc4e96 copyright
Claus Gittinger <cg@exept.de>
parents: 8550
diff changeset
    53
!ExternalLibraryFunction class methodsFor:'documentation'!
d70396dc4e96 copyright
Claus Gittinger <cg@exept.de>
parents: 8550
diff changeset
    54
d70396dc4e96 copyright
Claus Gittinger <cg@exept.de>
parents: 8550
diff changeset
    55
copyright
d70396dc4e96 copyright
Claus Gittinger <cg@exept.de>
parents: 8550
diff changeset
    56
"
d70396dc4e96 copyright
Claus Gittinger <cg@exept.de>
parents: 8550
diff changeset
    57
 COPYRIGHT (c) 2004 by eXept Software AG
9464
157fe6ca53e6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9463
diff changeset
    58
	      All Rights Reserved
8728
d70396dc4e96 copyright
Claus Gittinger <cg@exept.de>
parents: 8550
diff changeset
    59
d70396dc4e96 copyright
Claus Gittinger <cg@exept.de>
parents: 8550
diff changeset
    60
 This software is furnished under a license and may be used
d70396dc4e96 copyright
Claus Gittinger <cg@exept.de>
parents: 8550
diff changeset
    61
 only in accordance with the terms of that license and with the
d70396dc4e96 copyright
Claus Gittinger <cg@exept.de>
parents: 8550
diff changeset
    62
 inclusion of the above copyright notice.   This software may not
d70396dc4e96 copyright
Claus Gittinger <cg@exept.de>
parents: 8550
diff changeset
    63
 be provided or otherwise made available to, or used by, any
d70396dc4e96 copyright
Claus Gittinger <cg@exept.de>
parents: 8550
diff changeset
    64
 other person.  No title to or ownership of the software is
d70396dc4e96 copyright
Claus Gittinger <cg@exept.de>
parents: 8550
diff changeset
    65
 hereby transferred.
d70396dc4e96 copyright
Claus Gittinger <cg@exept.de>
parents: 8550
diff changeset
    66
"
9322
41c391bfbf03 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9321
diff changeset
    67
!
41c391bfbf03 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9321
diff changeset
    68
9331
c26a7de1468c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9330
diff changeset
    69
documentation
c26a7de1468c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9330
diff changeset
    70
"
c26a7de1468c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9330
diff changeset
    71
    instances of me are used to interface to external library functions (as found in a dll/shared object).
c26a7de1468c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9330
diff changeset
    72
12680
b0661f4ef910 changed: #documentation
Claus Gittinger <cg@exept.de>
parents: 12657
diff changeset
    73
    Inside a method, when a special external-call pragma such as:
14625
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
    74
	<api: bool MessageBeep(uint)>
12680
b0661f4ef910 changed: #documentation
Claus Gittinger <cg@exept.de>
parents: 12657
diff changeset
    75
b0661f4ef910 changed: #documentation
Claus Gittinger <cg@exept.de>
parents: 12657
diff changeset
    76
    is encountered by the parser, the compiler generates a call via
14625
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
    77
	<correspondingExternalLibraryFunctionObject> invokeWithArguments: argumentArray.
9331
c26a7de1468c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9330
diff changeset
    78
c26a7de1468c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9330
diff changeset
    79
    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
    80
    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
    81
    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
    82
b0661f4ef910 changed: #documentation
Claus Gittinger <cg@exept.de>
parents: 12657
diff changeset
    83
    The parser supports the call-syntax of various other smalltalk dialects:
14625
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
    84
	Squeak / ST-X:
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
    85
	    <cdecl:   [async] [virtual|nonVirtual][const] returnType functionNameStringOrIndex ( argType1..argTypeN ) module: moduleName >
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
    86
	    <apicall: [async] [virtual|nonVirtual][const] returnType functionNameStringOrIndex ( argType1..argTypeN ) module: moduleName >
12680
b0661f4ef910 changed: #documentation
Claus Gittinger <cg@exept.de>
parents: 12657
diff changeset
    87
14625
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
    88
	Dolphin:
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
    89
	    <stdcall: [virtual|nonVirtual][const] returnType functionNameStringOrIndex argType1..argTypeN>
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
    90
	    <cdecl:   [virtual|nonVirtual][const] returnType functionNameStringOrIndex argType1..argTypeN>
12680
b0661f4ef910 changed: #documentation
Claus Gittinger <cg@exept.de>
parents: 12657
diff changeset
    91
14625
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
    92
	ST/V:
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
    93
	    <api: functionName argType1 .. argTypeN returnType>
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
    94
	    <ccall: functionName argType1 .. argTypeN returnType>
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
    95
	    <ole: vFunctionIndex argType1 .. argTypeN returnType>
12680
b0661f4ef910 changed: #documentation
Claus Gittinger <cg@exept.de>
parents: 12657
diff changeset
    96
14625
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
    97
	VisualWorks:
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
    98
	    <c: ...>
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
    99
	    <c: #define NAME value>
9331
c26a7de1468c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9330
diff changeset
   100
"
c26a7de1468c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9330
diff changeset
   101
!
c26a7de1468c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9330
diff changeset
   102
9322
41c391bfbf03 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9321
diff changeset
   103
example
41c391bfbf03 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9321
diff changeset
   104
"
14625
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
   105
								[exBegin]
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
   106
	|f|
14037
Michael Beyl <mb@exept.de>
parents: 13782
diff changeset
   107
14625
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
   108
	f := ExternalLibraryFunction new.
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
   109
	f beCallTypeWINAPI.
14037
Michael Beyl <mb@exept.de>
parents: 13782
diff changeset
   110
14625
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
   111
	f name:'MessageBeep'
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
   112
	  module:'user32.dll'
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
   113
	  returnType:#boolean
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
   114
	  argumentTypes:#(uint).
14037
Michael Beyl <mb@exept.de>
parents: 13782
diff changeset
   115
14625
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
   116
	f invokeWith:1.
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
   117
								[exEnd]
14037
Michael Beyl <mb@exept.de>
parents: 13782
diff changeset
   118
Michael Beyl <mb@exept.de>
parents: 13782
diff changeset
   119
  Synchronous vs. Asynchronous calls:
Michael Beyl <mb@exept.de>
parents: 13782
diff changeset
   120
14516
359e4d2234af class: ExternalLibraryFunction
Stefan Vogel <sv@exept.de>
parents: 14506
diff changeset
   121
    by default, foreign function calls are synchronous, effectively blocking the whole ST/X system
14037
Michael Beyl <mb@exept.de>
parents: 13782
diff changeset
   122
    (that is by purpose,´because most C-code is not prepared for being interrupted, and also, normal
Michael Beyl <mb@exept.de>
parents: 13782
diff changeset
   123
     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
   124
     access the data...).
14625
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
   125
    Therefore, the following will block all ST/X activity for 10 seconds
14037
Michael Beyl <mb@exept.de>
parents: 13782
diff changeset
   126
    (try interacting with the launcher while the Sleep is performing):
Michael Beyl <mb@exept.de>
parents: 13782
diff changeset
   127
14625
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
   128
								[exBegin]
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
   129
	|f|
9322
41c391bfbf03 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9321
diff changeset
   130
14625
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
   131
	f := ExternalLibraryFunction new.
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
   132
	f beCallTypeWINAPI.
14037
Michael Beyl <mb@exept.de>
parents: 13782
diff changeset
   133
14625
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
   134
	f name:'Sleep'
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
   135
	  module:'kernel32.dll'
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
   136
	  returnType:#void
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
   137
	  argumentTypes:#(uint).
14037
Michael Beyl <mb@exept.de>
parents: 13782
diff changeset
   138
14625
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
   139
	f invokeWith:10000.
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
   140
								[exEnd]
9322
41c391bfbf03 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9321
diff changeset
   141
14037
Michael Beyl <mb@exept.de>
parents: 13782
diff changeset
   142
    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
   143
    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
   144
    threads wil continue to execute.
Michael Beyl <mb@exept.de>
parents: 13782
diff changeset
   145
    (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
   146
								[exBegin]
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
   147
	|f|
14037
Michael Beyl <mb@exept.de>
parents: 13782
diff changeset
   148
14625
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
   149
	f := ExternalLibraryFunction new.
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
   150
	f beCallTypeWINAPI.
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
   151
	f beAsync.
14037
Michael Beyl <mb@exept.de>
parents: 13782
diff changeset
   152
14625
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
   153
	f name:'Sleep'
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
   154
	  module:'kernel32.dll'
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
   155
	  returnType:#void
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
   156
	  argumentTypes:#(uint).
14037
Michael Beyl <mb@exept.de>
parents: 13782
diff changeset
   157
14625
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
   158
	f invokeWith:10000.
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
   159
								[exEnd]
14037
Michael Beyl <mb@exept.de>
parents: 13782
diff changeset
   160
9322
41c391bfbf03 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9321
diff changeset
   161
"
8728
d70396dc4e96 copyright
Claus Gittinger <cg@exept.de>
parents: 8550
diff changeset
   162
! !
8533
9065c547ea75 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   163
8550
72982f85bd41 *** empty log message ***
ca
parents: 8533
diff changeset
   164
!ExternalLibraryFunction class methodsFor:'instance creation'!
72982f85bd41 *** empty log message ***
ca
parents: 8533
diff changeset
   165
9465
d11885052713 rewrite & cleanup
Claus Gittinger <cg@exept.de>
parents: 9464
diff changeset
   166
name:functionName module:moduleName returnType:returnType argumentTypes:argTypes
8550
72982f85bd41 *** empty log message ***
ca
parents: 8533
diff changeset
   167
    ^ self new
10025
053904a63549 stc-compiled ExternalLibraryFunctions
Claus Gittinger <cg@exept.de>
parents: 9981
diff changeset
   168
	name:functionName module:moduleName
053904a63549 stc-compiled ExternalLibraryFunctions
Claus Gittinger <cg@exept.de>
parents: 9981
diff changeset
   169
	returnType:returnType argumentTypes:argTypes
9465
d11885052713 rewrite & cleanup
Claus Gittinger <cg@exept.de>
parents: 9464
diff changeset
   170
d11885052713 rewrite & cleanup
Claus Gittinger <cg@exept.de>
parents: 9464
diff changeset
   171
    "Created: / 01-08-2006 / 15:19:08 / cg"
9463
864880338d7e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9460
diff changeset
   172
! !
864880338d7e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9460
diff changeset
   173
864880338d7e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9460
diff changeset
   174
!ExternalLibraryFunction class methodsFor:'class initialization'!
864880338d7e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9460
diff changeset
   175
11050
226b25e4bb97 comments
Claus Gittinger <cg@exept.de>
parents: 11013
diff changeset
   176
addToDllPath:aDirectoryPathName
226b25e4bb97 comments
Claus Gittinger <cg@exept.de>
parents: 11013
diff changeset
   177
    "can be used during initialization, to add more places for dll-loading"
226b25e4bb97 comments
Claus Gittinger <cg@exept.de>
parents: 11013
diff changeset
   178
11053
bcf4ebb25868 +removeFromDLLPath
Claus Gittinger <cg@exept.de>
parents: 11050
diff changeset
   179
    |oldPath|
bcf4ebb25868 +removeFromDLLPath
Claus Gittinger <cg@exept.de>
parents: 11050
diff changeset
   180
bcf4ebb25868 +removeFromDLLPath
Claus Gittinger <cg@exept.de>
parents: 11050
diff changeset
   181
    oldPath := self dllPath.
bcf4ebb25868 +removeFromDLLPath
Claus Gittinger <cg@exept.de>
parents: 11050
diff changeset
   182
    (oldPath includes:aDirectoryPathName) ifFalse:[
11586
a3b2eef8a74c int vs. sint
Claus Gittinger <cg@exept.de>
parents: 11426
diff changeset
   183
	self dllPath:(oldPath asOrderedCollection copyWith:aDirectoryPathName)
11053
bcf4ebb25868 +removeFromDLLPath
Claus Gittinger <cg@exept.de>
parents: 11050
diff changeset
   184
    ]
11050
226b25e4bb97 comments
Claus Gittinger <cg@exept.de>
parents: 11013
diff changeset
   185
!
226b25e4bb97 comments
Claus Gittinger <cg@exept.de>
parents: 11013
diff changeset
   186
14103
3df000b77712 class definition
Claus Gittinger <cg@exept.de>
parents: 14037
diff changeset
   187
dllMapping
3df000b77712 class definition
Claus Gittinger <cg@exept.de>
parents: 14037
diff changeset
   188
    "allows for dll's to be replaced,
3df000b77712 class definition
Claus Gittinger <cg@exept.de>
parents: 14037
diff changeset
   189
     for example, if you want to use the mozilla sqlite dll
14625
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
   190
	C:\Program Files\Mozilla Firefox\mozsqlite3.dll
14103
3df000b77712 class definition
Claus Gittinger <cg@exept.de>
parents: 14037
diff changeset
   191
     for the sqlite3, execute:
14625
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
   192
	ExternalLibraryFunction
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
   193
	    dllMapping at:'sqlite3'
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
   194
	    put: 'C:\Program Files\Mozilla Firefox\mozsqlite3.dll'
14103
3df000b77712 class definition
Claus Gittinger <cg@exept.de>
parents: 14037
diff changeset
   195
    "
3df000b77712 class definition
Claus Gittinger <cg@exept.de>
parents: 14037
diff changeset
   196
3df000b77712 class definition
Claus Gittinger <cg@exept.de>
parents: 14037
diff changeset
   197
    DllMapping isNil ifTrue:[
14625
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
   198
	DllMapping := Dictionary new.
14103
3df000b77712 class definition
Claus Gittinger <cg@exept.de>
parents: 14037
diff changeset
   199
    ].
3df000b77712 class definition
Claus Gittinger <cg@exept.de>
parents: 14037
diff changeset
   200
    ^ DllMapping
3df000b77712 class definition
Claus Gittinger <cg@exept.de>
parents: 14037
diff changeset
   201
3df000b77712 class definition
Claus Gittinger <cg@exept.de>
parents: 14037
diff changeset
   202
    "Created: / 10-04-2012 / 12:21:45 / cg"
3df000b77712 class definition
Claus Gittinger <cg@exept.de>
parents: 14037
diff changeset
   203
!
3df000b77712 class definition
Claus Gittinger <cg@exept.de>
parents: 14037
diff changeset
   204
10270
897474c6c785 allow setting the dllPath
fm
parents: 10213
diff changeset
   205
dllPath
13337
d1733931bc10 changed:
Stefan Vogel <sv@exept.de>
parents: 13334
diff changeset
   206
    ^ DLLPATH
10270
897474c6c785 allow setting the dllPath
fm
parents: 10213
diff changeset
   207
!
897474c6c785 allow setting the dllPath
fm
parents: 10213
diff changeset
   208
897474c6c785 allow setting the dllPath
fm
parents: 10213
diff changeset
   209
dllPath:aCollectionOfDirectoryPathNames
897474c6c785 allow setting the dllPath
fm
parents: 10213
diff changeset
   210
    DLLPATH := aCollectionOfDirectoryPathNames
897474c6c785 allow setting the dllPath
fm
parents: 10213
diff changeset
   211
!
897474c6c785 allow setting the dllPath
fm
parents: 10213
diff changeset
   212
9463
864880338d7e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9460
diff changeset
   213
initialize
10025
053904a63549 stc-compiled ExternalLibraryFunctions
Claus Gittinger <cg@exept.de>
parents: 9981
diff changeset
   214
    "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
   215
d1733931bc10 changed:
Stefan Vogel <sv@exept.de>
parents: 13334
diff changeset
   216
    DLLPATH isNil ifTrue:[
14625
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
   217
	DLLPATH := #('.').
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
   218
	FLAG_VIRTUAL := %{ __MKSMALLINT(__EXTL_FLAG_VIRTUAL) %}.                "/ a virtual c++ call
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
   219
	FLAG_NONVIRTUAL := %{ __MKSMALLINT(__EXTL_FLAG_NONVIRTUAL) %}.          "/ a non-virtual c++ call
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
   220
	FLAG_UNLIMITEDSTACK := %{ __MKSMALLINT(__EXTL_FLAG_UNLIMITEDSTACK) %}.  "/ unlimitedstack under unix
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
   221
	FLAG_ASYNC := %{ __MKSMALLINT(__EXTL_FLAG_ASYNC) %}.                    "/ async under win32
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
   222
	FLAG_RETVAL_IS_CONST := %{ __MKSMALLINT(__EXTL_FLAG_RETVAL_IS_CONST) %}."/ return value is not to be registered for finalization
9463
864880338d7e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9460
diff changeset
   223
14625
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
   224
	CALLTYPE_API := %{ __MKSMALLINT(__EXTL_CALLTYPE_API) %}.                "/ WINAPI-call (win32 only)
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
   225
	CALLTYPE_C := %{ __MKSMALLINT(__EXTL_CALLTYPE_C) %}.                    "/ regular C-call (the default)
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
   226
	CALLTYPE_V8 := %{ __MKSMALLINT(__EXTL_CALLTYPE_V8) %}.                  "/ v8 call (sparc only)
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
   227
	CALLTYPE_V9 := %{ __MKSMALLINT(__EXTL_CALLTYPE_V9) %}.                  "/ v9 call (sparc only)
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
   228
	CALLTYPE_UNIX64 := %{ __MKSMALLINT(__EXTL_CALLTYPE_UNIX64) %}.          "/ unix64 call (alpha only)
9463
864880338d7e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9460
diff changeset
   229
14625
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
   230
	CALLTYPE_MASK := %{ __MKSMALLINT(__EXTL_CALLTYPE_MASK) %}.
13337
d1733931bc10 changed:
Stefan Vogel <sv@exept.de>
parents: 13334
diff changeset
   231
    ].
9465
d11885052713 rewrite & cleanup
Claus Gittinger <cg@exept.de>
parents: 9464
diff changeset
   232
10025
053904a63549 stc-compiled ExternalLibraryFunctions
Claus Gittinger <cg@exept.de>
parents: 9981
diff changeset
   233
    "
053904a63549 stc-compiled ExternalLibraryFunctions
Claus Gittinger <cg@exept.de>
parents: 9981
diff changeset
   234
     self initialize
053904a63549 stc-compiled ExternalLibraryFunctions
Claus Gittinger <cg@exept.de>
parents: 9981
diff changeset
   235
    "
053904a63549 stc-compiled ExternalLibraryFunctions
Claus Gittinger <cg@exept.de>
parents: 9981
diff changeset
   236
053904a63549 stc-compiled ExternalLibraryFunctions
Claus Gittinger <cg@exept.de>
parents: 9981
diff changeset
   237
    "Modified: / 03-10-2006 / 21:27:47 / cg"
11053
bcf4ebb25868 +removeFromDLLPath
Claus Gittinger <cg@exept.de>
parents: 11050
diff changeset
   238
!
bcf4ebb25868 +removeFromDLLPath
Claus Gittinger <cg@exept.de>
parents: 11050
diff changeset
   239
bcf4ebb25868 +removeFromDLLPath
Claus Gittinger <cg@exept.de>
parents: 11050
diff changeset
   240
removeFromDllPath:aDirectoryPathName
bcf4ebb25868 +removeFromDLLPath
Claus Gittinger <cg@exept.de>
parents: 11050
diff changeset
   241
    "remove added places from dll-loading"
bcf4ebb25868 +removeFromDLLPath
Claus Gittinger <cg@exept.de>
parents: 11050
diff changeset
   242
bcf4ebb25868 +removeFromDLLPath
Claus Gittinger <cg@exept.de>
parents: 11050
diff changeset
   243
    |oldPath|
bcf4ebb25868 +removeFromDLLPath
Claus Gittinger <cg@exept.de>
parents: 11050
diff changeset
   244
bcf4ebb25868 +removeFromDLLPath
Claus Gittinger <cg@exept.de>
parents: 11050
diff changeset
   245
    oldPath := self dllPath.
bcf4ebb25868 +removeFromDLLPath
Claus Gittinger <cg@exept.de>
parents: 11050
diff changeset
   246
    self dllPath:(oldPath asOrderedCollection copyWithout:aDirectoryPathName)
bcf4ebb25868 +removeFromDLLPath
Claus Gittinger <cg@exept.de>
parents: 11050
diff changeset
   247
bcf4ebb25868 +removeFromDLLPath
Claus Gittinger <cg@exept.de>
parents: 11050
diff changeset
   248
    "
bcf4ebb25868 +removeFromDLLPath
Claus Gittinger <cg@exept.de>
parents: 11050
diff changeset
   249
     self dllPath.
11586
a3b2eef8a74c int vs. sint
Claus Gittinger <cg@exept.de>
parents: 11426
diff changeset
   250
     self addToDllPath:'C:\aaa\bbb'.
11053
bcf4ebb25868 +removeFromDLLPath
Claus Gittinger <cg@exept.de>
parents: 11050
diff changeset
   251
     self dllPath.
bcf4ebb25868 +removeFromDLLPath
Claus Gittinger <cg@exept.de>
parents: 11050
diff changeset
   252
     self removeFromDllPath:'C:\aaa\bbb'.
bcf4ebb25868 +removeFromDLLPath
Claus Gittinger <cg@exept.de>
parents: 11050
diff changeset
   253
     self dllPath.
bcf4ebb25868 +removeFromDLLPath
Claus Gittinger <cg@exept.de>
parents: 11050
diff changeset
   254
    "
8550
72982f85bd41 *** empty log message ***
ca
parents: 8533
diff changeset
   255
! !
72982f85bd41 *** empty log message ***
ca
parents: 8533
diff changeset
   256
9321
734c7c432461 not yet finished
Claus Gittinger <cg@exept.de>
parents: 8891
diff changeset
   257
!ExternalLibraryFunction class methodsFor:'constants'!
734c7c432461 not yet finished
Claus Gittinger <cg@exept.de>
parents: 8891
diff changeset
   258
734c7c432461 not yet finished
Claus Gittinger <cg@exept.de>
parents: 8891
diff changeset
   259
callTypeAPI
9463
864880338d7e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9460
diff changeset
   260
    ^ CALLTYPE_API
9321
734c7c432461 not yet finished
Claus Gittinger <cg@exept.de>
parents: 8891
diff changeset
   261
9463
864880338d7e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9460
diff changeset
   262
    "Modified: / 01-08-2006 / 13:44:41 / cg"
9435
68f7e39efad7 support of asynchronous calls
ca
parents: 9418
diff changeset
   263
!
68f7e39efad7 support of asynchronous calls
ca
parents: 9418
diff changeset
   264
9321
734c7c432461 not yet finished
Claus Gittinger <cg@exept.de>
parents: 8891
diff changeset
   265
callTypeC
9463
864880338d7e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9460
diff changeset
   266
    ^ CALLTYPE_C
9321
734c7c432461 not yet finished
Claus Gittinger <cg@exept.de>
parents: 8891
diff changeset
   267
9463
864880338d7e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9460
diff changeset
   268
    "Modified: / 01-08-2006 / 13:44:49 / cg"
9435
68f7e39efad7 support of asynchronous calls
ca
parents: 9418
diff changeset
   269
!
68f7e39efad7 support of asynchronous calls
ca
parents: 9418
diff changeset
   270
9321
734c7c432461 not yet finished
Claus Gittinger <cg@exept.de>
parents: 8891
diff changeset
   271
callTypeCDecl
9463
864880338d7e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9460
diff changeset
   272
    ^ CALLTYPE_C
9321
734c7c432461 not yet finished
Claus Gittinger <cg@exept.de>
parents: 8891
diff changeset
   273
9463
864880338d7e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9460
diff changeset
   274
    "Modified: / 01-08-2006 / 13:44:52 / cg"
9435
68f7e39efad7 support of asynchronous calls
ca
parents: 9418
diff changeset
   275
!
68f7e39efad7 support of asynchronous calls
ca
parents: 9418
diff changeset
   276
10619
dc8c965a8602 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10618
diff changeset
   277
callTypeMASK
dc8c965a8602 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10618
diff changeset
   278
    ^ CALLTYPE_MASK
dc8c965a8602 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10618
diff changeset
   279
dc8c965a8602 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10618
diff changeset
   280
    "Modified: / 01-08-2006 / 13:44:57 / cg"
dc8c965a8602 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10618
diff changeset
   281
!
dc8c965a8602 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10618
diff changeset
   282
9321
734c7c432461 not yet finished
Claus Gittinger <cg@exept.de>
parents: 8891
diff changeset
   283
callTypeOLE
9463
864880338d7e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9460
diff changeset
   284
    ^ CALLTYPE_OLE
9435
68f7e39efad7 support of asynchronous calls
ca
parents: 9418
diff changeset
   285
9463
864880338d7e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9460
diff changeset
   286
    "Modified: / 01-08-2006 / 13:44:57 / cg"
9321
734c7c432461 not yet finished
Claus Gittinger <cg@exept.de>
parents: 8891
diff changeset
   287
! !
734c7c432461 not yet finished
Claus Gittinger <cg@exept.de>
parents: 8891
diff changeset
   288
734c7c432461 not yet finished
Claus Gittinger <cg@exept.de>
parents: 8891
diff changeset
   289
!ExternalLibraryFunction methodsFor:'accessing'!
734c7c432461 not yet finished
Claus Gittinger <cg@exept.de>
parents: 8891
diff changeset
   290
734c7c432461 not yet finished
Claus Gittinger <cg@exept.de>
parents: 8891
diff changeset
   291
argumentTypes
734c7c432461 not yet finished
Claus Gittinger <cg@exept.de>
parents: 8891
diff changeset
   292
    ^ argumentTypes
9463
864880338d7e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9460
diff changeset
   293
!
864880338d7e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9460
diff changeset
   294
11426
1fccae300393 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 11053
diff changeset
   295
argumentTypesString
11586
a3b2eef8a74c int vs. sint
Claus Gittinger <cg@exept.de>
parents: 11426
diff changeset
   296
    ^ String
a3b2eef8a74c int vs. sint
Claus Gittinger <cg@exept.de>
parents: 11426
diff changeset
   297
	streamContents:[:s |
a3b2eef8a74c int vs. sint
Claus Gittinger <cg@exept.de>
parents: 11426
diff changeset
   298
	    argumentTypes do:[:eachArgType |
a3b2eef8a74c int vs. sint
Claus Gittinger <cg@exept.de>
parents: 11426
diff changeset
   299
		eachArgType printOn:s.
a3b2eef8a74c int vs. sint
Claus Gittinger <cg@exept.de>
parents: 11426
diff changeset
   300
	    ] separatedBy:[
a3b2eef8a74c int vs. sint
Claus Gittinger <cg@exept.de>
parents: 11426
diff changeset
   301
		s nextPutAll:','.
a3b2eef8a74c int vs. sint
Claus Gittinger <cg@exept.de>
parents: 11426
diff changeset
   302
	    ].
a3b2eef8a74c int vs. sint
Claus Gittinger <cg@exept.de>
parents: 11426
diff changeset
   303
	].
11426
1fccae300393 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 11053
diff changeset
   304
!
1fccae300393 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 11053
diff changeset
   305
9463
864880338d7e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9460
diff changeset
   306
beAsync
864880338d7e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9460
diff changeset
   307
    "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
   308
     Ignored under unix/linux (until those support multiple threads too)."
864880338d7e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9460
diff changeset
   309
864880338d7e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9460
diff changeset
   310
    flags := (flags ? 0) bitOr: FLAG_ASYNC.
864880338d7e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9460
diff changeset
   311
864880338d7e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9460
diff changeset
   312
    "Created: / 01-08-2006 / 13:42:38 / cg"
864880338d7e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9460
diff changeset
   313
!
864880338d7e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9460
diff changeset
   314
9465
d11885052713 rewrite & cleanup
Claus Gittinger <cg@exept.de>
parents: 9464
diff changeset
   315
beCallTypeAPI
d11885052713 rewrite & cleanup
Claus Gittinger <cg@exept.de>
parents: 9464
diff changeset
   316
    flags := (flags ? 0) bitOr: CALLTYPE_API.
d11885052713 rewrite & cleanup
Claus Gittinger <cg@exept.de>
parents: 9464
diff changeset
   317
d11885052713 rewrite & cleanup
Claus Gittinger <cg@exept.de>
parents: 9464
diff changeset
   318
    "Created: / 01-08-2006 / 15:12:40 / cg"
d11885052713 rewrite & cleanup
Claus Gittinger <cg@exept.de>
parents: 9464
diff changeset
   319
!
d11885052713 rewrite & cleanup
Claus Gittinger <cg@exept.de>
parents: 9464
diff changeset
   320
d11885052713 rewrite & cleanup
Claus Gittinger <cg@exept.de>
parents: 9464
diff changeset
   321
beCallTypeC
d11885052713 rewrite & cleanup
Claus Gittinger <cg@exept.de>
parents: 9464
diff changeset
   322
    flags := (flags ? 0) bitOr: CALLTYPE_C.
d11885052713 rewrite & cleanup
Claus Gittinger <cg@exept.de>
parents: 9464
diff changeset
   323
d11885052713 rewrite & cleanup
Claus Gittinger <cg@exept.de>
parents: 9464
diff changeset
   324
    "Created: / 01-08-2006 / 15:12:40 / cg"
d11885052713 rewrite & cleanup
Claus Gittinger <cg@exept.de>
parents: 9464
diff changeset
   325
!
d11885052713 rewrite & cleanup
Claus Gittinger <cg@exept.de>
parents: 9464
diff changeset
   326
10481
b3526180579f +isExternalLibraryFunction
fm
parents: 10440
diff changeset
   327
beCallTypeOLE
b3526180579f +isExternalLibraryFunction
fm
parents: 10440
diff changeset
   328
    flags := (flags ? 0) bitOr: FLAG_VIRTUAL.
b3526180579f +isExternalLibraryFunction
fm
parents: 10440
diff changeset
   329
b3526180579f +isExternalLibraryFunction
fm
parents: 10440
diff changeset
   330
    "Created: / 01-08-2006 / 15:12:40 / cg"
b3526180579f +isExternalLibraryFunction
fm
parents: 10440
diff changeset
   331
!
b3526180579f +isExternalLibraryFunction
fm
parents: 10440
diff changeset
   332
9465
d11885052713 rewrite & cleanup
Claus Gittinger <cg@exept.de>
parents: 9464
diff changeset
   333
beCallTypeUNIX64
d11885052713 rewrite & cleanup
Claus Gittinger <cg@exept.de>
parents: 9464
diff changeset
   334
    flags := (flags ? 0) bitOr: CALLTYPE_UNIX64.
d11885052713 rewrite & cleanup
Claus Gittinger <cg@exept.de>
parents: 9464
diff changeset
   335
d11885052713 rewrite & cleanup
Claus Gittinger <cg@exept.de>
parents: 9464
diff changeset
   336
    "Created: / 01-08-2006 / 15:13:38 / cg"
d11885052713 rewrite & cleanup
Claus Gittinger <cg@exept.de>
parents: 9464
diff changeset
   337
!
d11885052713 rewrite & cleanup
Claus Gittinger <cg@exept.de>
parents: 9464
diff changeset
   338
d11885052713 rewrite & cleanup
Claus Gittinger <cg@exept.de>
parents: 9464
diff changeset
   339
beCallTypeV8
d11885052713 rewrite & cleanup
Claus Gittinger <cg@exept.de>
parents: 9464
diff changeset
   340
    flags := (flags ? 0) bitOr: CALLTYPE_V8.
d11885052713 rewrite & cleanup
Claus Gittinger <cg@exept.de>
parents: 9464
diff changeset
   341
d11885052713 rewrite & cleanup
Claus Gittinger <cg@exept.de>
parents: 9464
diff changeset
   342
    "Created: / 01-08-2006 / 15:13:28 / cg"
d11885052713 rewrite & cleanup
Claus Gittinger <cg@exept.de>
parents: 9464
diff changeset
   343
!
d11885052713 rewrite & cleanup
Claus Gittinger <cg@exept.de>
parents: 9464
diff changeset
   344
d11885052713 rewrite & cleanup
Claus Gittinger <cg@exept.de>
parents: 9464
diff changeset
   345
beCallTypeV9
d11885052713 rewrite & cleanup
Claus Gittinger <cg@exept.de>
parents: 9464
diff changeset
   346
    flags := (flags ? 0) bitOr: CALLTYPE_V9.
d11885052713 rewrite & cleanup
Claus Gittinger <cg@exept.de>
parents: 9464
diff changeset
   347
d11885052713 rewrite & cleanup
Claus Gittinger <cg@exept.de>
parents: 9464
diff changeset
   348
    "Created: / 01-08-2006 / 15:13:31 / cg"
d11885052713 rewrite & cleanup
Claus Gittinger <cg@exept.de>
parents: 9464
diff changeset
   349
!
d11885052713 rewrite & cleanup
Claus Gittinger <cg@exept.de>
parents: 9464
diff changeset
   350
d11885052713 rewrite & cleanup
Claus Gittinger <cg@exept.de>
parents: 9464
diff changeset
   351
beCallTypeWINAPI
d11885052713 rewrite & cleanup
Claus Gittinger <cg@exept.de>
parents: 9464
diff changeset
   352
    self beCallTypeAPI
d11885052713 rewrite & cleanup
Claus Gittinger <cg@exept.de>
parents: 9464
diff changeset
   353
d11885052713 rewrite & cleanup
Claus Gittinger <cg@exept.de>
parents: 9464
diff changeset
   354
    "Modified: / 01-08-2006 / 15:14:02 / cg"
d11885052713 rewrite & cleanup
Claus Gittinger <cg@exept.de>
parents: 9464
diff changeset
   355
!
d11885052713 rewrite & cleanup
Claus Gittinger <cg@exept.de>
parents: 9464
diff changeset
   356
9525
120234adc94e const specifier (is this a good name ?)
ca
parents: 9524
diff changeset
   357
beConstReturnValue
10025
053904a63549 stc-compiled ExternalLibraryFunctions
Claus Gittinger <cg@exept.de>
parents: 9981
diff changeset
   358
    "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
   359
     (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
   360
120234adc94e const specifier (is this a good name ?)
ca
parents: 9524
diff changeset
   361
    flags := (flags ? 0) bitOr: FLAG_RETVAL_IS_CONST.
120234adc94e const specifier (is this a good name ?)
ca
parents: 9524
diff changeset
   362
120234adc94e const specifier (is this a good name ?)
ca
parents: 9524
diff changeset
   363
    "Created: / 01-08-2006 / 13:56:48 / cg"
120234adc94e const specifier (is this a good name ?)
ca
parents: 9524
diff changeset
   364
!
120234adc94e const specifier (is this a good name ?)
ca
parents: 9524
diff changeset
   365
9463
864880338d7e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9460
diff changeset
   366
beNonVirtualCPP
864880338d7e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9460
diff changeset
   367
    "specify this as a non-virtual c++-function"
864880338d7e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9460
diff changeset
   368
864880338d7e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9460
diff changeset
   369
    flags := (flags ? 0) bitOr: FLAG_NONVIRTUAL.
864880338d7e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9460
diff changeset
   370
864880338d7e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9460
diff changeset
   371
    "Created: / 01-08-2006 / 13:56:44 / cg"
864880338d7e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9460
diff changeset
   372
!
864880338d7e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9460
diff changeset
   373
864880338d7e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9460
diff changeset
   374
beUnlimitedStack
864880338d7e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9460
diff changeset
   375
    "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
   376
     for unlimited auto-sized-stack under unix/linux.
864880338d7e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9460
diff changeset
   377
     Ignored under windows."
864880338d7e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9460
diff changeset
   378
864880338d7e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9460
diff changeset
   379
    flags := (flags ? 0) bitOr: FLAG_UNLIMITEDSTACK.
864880338d7e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9460
diff changeset
   380
864880338d7e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9460
diff changeset
   381
    "Created: / 01-08-2006 / 13:41:54 / cg"
864880338d7e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9460
diff changeset
   382
!
864880338d7e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9460
diff changeset
   383
864880338d7e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9460
diff changeset
   384
beVirtualCPP
864880338d7e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9460
diff changeset
   385
    "specify this as a virtual c++-function"
864880338d7e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9460
diff changeset
   386
864880338d7e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9460
diff changeset
   387
    flags := (flags ? 0) bitOr: FLAG_VIRTUAL.
864880338d7e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9460
diff changeset
   388
864880338d7e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9460
diff changeset
   389
    "Created: / 01-08-2006 / 13:56:48 / cg"
864880338d7e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9460
diff changeset
   390
!
864880338d7e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9460
diff changeset
   391
9465
d11885052713 rewrite & cleanup
Claus Gittinger <cg@exept.de>
parents: 9464
diff changeset
   392
callTypeNumber
d11885052713 rewrite & cleanup
Claus Gittinger <cg@exept.de>
parents: 9464
diff changeset
   393
    ^ (flags ? 0) bitAnd: CALLTYPE_MASK.
d11885052713 rewrite & cleanup
Claus Gittinger <cg@exept.de>
parents: 9464
diff changeset
   394
d11885052713 rewrite & cleanup
Claus Gittinger <cg@exept.de>
parents: 9464
diff changeset
   395
    "Created: / 01-08-2006 / 15:12:10 / cg"
d11885052713 rewrite & cleanup
Claus Gittinger <cg@exept.de>
parents: 9464
diff changeset
   396
!
d11885052713 rewrite & cleanup
Claus Gittinger <cg@exept.de>
parents: 9464
diff changeset
   397
9463
864880338d7e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9460
diff changeset
   398
isAsync
864880338d7e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9460
diff changeset
   399
    "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
   400
864880338d7e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9460
diff changeset
   401
    ^ (flags ? 0) bitTest: FLAG_ASYNC.
864880338d7e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9460
diff changeset
   402
864880338d7e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9460
diff changeset
   403
    "Created: / 01-08-2006 / 13:46:53 / cg"
864880338d7e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9460
diff changeset
   404
!
864880338d7e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9460
diff changeset
   405
9519
ad18bf96758d *** empty log message ***
ca
parents: 9483
diff changeset
   406
isCPPFunction
ad18bf96758d *** empty log message ***
ca
parents: 9483
diff changeset
   407
    "is this a virtual or non-virtual c++-function ?"
ad18bf96758d *** empty log message ***
ca
parents: 9483
diff changeset
   408
ad18bf96758d *** empty log message ***
ca
parents: 9483
diff changeset
   409
    ^ (flags ? 0) bitTest: (FLAG_VIRTUAL bitOr: FLAG_NONVIRTUAL).
ad18bf96758d *** empty log message ***
ca
parents: 9483
diff changeset
   410
ad18bf96758d *** empty log message ***
ca
parents: 9483
diff changeset
   411
    "Created: / 01-08-2006 / 13:56:54 / cg"
ad18bf96758d *** empty log message ***
ca
parents: 9483
diff changeset
   412
!
ad18bf96758d *** empty log message ***
ca
parents: 9483
diff changeset
   413
9465
d11885052713 rewrite & cleanup
Claus Gittinger <cg@exept.de>
parents: 9464
diff changeset
   414
isCallTypeAPI
d11885052713 rewrite & cleanup
Claus Gittinger <cg@exept.de>
parents: 9464
diff changeset
   415
    ^ ((flags ? 0) bitAnd: CALLTYPE_MASK) == CALLTYPE_API.
d11885052713 rewrite & cleanup
Claus Gittinger <cg@exept.de>
parents: 9464
diff changeset
   416
d11885052713 rewrite & cleanup
Claus Gittinger <cg@exept.de>
parents: 9464
diff changeset
   417
    "Created: / 01-08-2006 / 15:21:16 / cg"
d11885052713 rewrite & cleanup
Claus Gittinger <cg@exept.de>
parents: 9464
diff changeset
   418
!
d11885052713 rewrite & cleanup
Claus Gittinger <cg@exept.de>
parents: 9464
diff changeset
   419
d11885052713 rewrite & cleanup
Claus Gittinger <cg@exept.de>
parents: 9464
diff changeset
   420
isCallTypeC
d11885052713 rewrite & cleanup
Claus Gittinger <cg@exept.de>
parents: 9464
diff changeset
   421
    ^ ((flags ? 0) bitAnd: CALLTYPE_MASK) == CALLTYPE_C.
d11885052713 rewrite & cleanup
Claus Gittinger <cg@exept.de>
parents: 9464
diff changeset
   422
d11885052713 rewrite & cleanup
Claus Gittinger <cg@exept.de>
parents: 9464
diff changeset
   423
    "Created: / 01-08-2006 / 15:21:23 / cg"
d11885052713 rewrite & cleanup
Claus Gittinger <cg@exept.de>
parents: 9464
diff changeset
   424
!
d11885052713 rewrite & cleanup
Claus Gittinger <cg@exept.de>
parents: 9464
diff changeset
   425
10483
79c64bcd4d29 +ole queries
fm
parents: 10481
diff changeset
   426
isCallTypeOLE
79c64bcd4d29 +ole queries
fm
parents: 10481
diff changeset
   427
    ^ ((flags ? 0) bitTest: FLAG_VIRTUAL).
79c64bcd4d29 +ole queries
fm
parents: 10481
diff changeset
   428
79c64bcd4d29 +ole queries
fm
parents: 10481
diff changeset
   429
    "Created: / 01-08-2006 / 15:21:23 / cg"
79c64bcd4d29 +ole queries
fm
parents: 10481
diff changeset
   430
!
79c64bcd4d29 +ole queries
fm
parents: 10481
diff changeset
   431
9525
120234adc94e const specifier (is this a good name ?)
ca
parents: 9524
diff changeset
   432
isConstReturnValue
10025
053904a63549 stc-compiled ExternalLibraryFunctions
Claus Gittinger <cg@exept.de>
parents: 9981
diff changeset
   433
    "is the pointer return value not to be finalized
9525
120234adc94e const specifier (is this a good name ?)
ca
parents: 9524
diff changeset
   434
     (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
   435
120234adc94e const specifier (is this a good name ?)
ca
parents: 9524
diff changeset
   436
    ^ (flags ? 0) bitTest: FLAG_RETVAL_IS_CONST.
120234adc94e const specifier (is this a good name ?)
ca
parents: 9524
diff changeset
   437
120234adc94e const specifier (is this a good name ?)
ca
parents: 9524
diff changeset
   438
    "Created: / 01-08-2006 / 13:56:48 / cg"
120234adc94e const specifier (is this a good name ?)
ca
parents: 9524
diff changeset
   439
!
120234adc94e const specifier (is this a good name ?)
ca
parents: 9524
diff changeset
   440
9463
864880338d7e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9460
diff changeset
   441
isNonVirtualCPP
864880338d7e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9460
diff changeset
   442
    "is this a non-virtual c++-function ?"
864880338d7e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9460
diff changeset
   443
864880338d7e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9460
diff changeset
   444
    ^ (flags ? 0) bitTest: FLAG_NONVIRTUAL.
864880338d7e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9460
diff changeset
   445
864880338d7e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9460
diff changeset
   446
    "Created: / 01-08-2006 / 13:56:51 / cg"
864880338d7e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9460
diff changeset
   447
!
864880338d7e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9460
diff changeset
   448
864880338d7e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9460
diff changeset
   449
isUnlimitedStack
864880338d7e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9460
diff changeset
   450
    "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
   451
     for unlimited auto-sized-stack under unix/linux.
864880338d7e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9460
diff changeset
   452
     Ignored under windows."
864880338d7e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9460
diff changeset
   453
864880338d7e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9460
diff changeset
   454
    ^ (flags ? 0) bitTest: FLAG_UNLIMITEDSTACK.
864880338d7e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9460
diff changeset
   455
864880338d7e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9460
diff changeset
   456
    "Created: / 01-08-2006 / 14:17:07 / cg"
864880338d7e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9460
diff changeset
   457
!
864880338d7e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9460
diff changeset
   458
864880338d7e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9460
diff changeset
   459
isVirtualCPP
864880338d7e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9460
diff changeset
   460
    "is this a virtual c++-function ?"
864880338d7e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9460
diff changeset
   461
864880338d7e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9460
diff changeset
   462
    ^ (flags ? 0) bitTest: FLAG_VIRTUAL.
864880338d7e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9460
diff changeset
   463
864880338d7e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9460
diff changeset
   464
    "Created: / 01-08-2006 / 13:56:54 / cg"
10483
79c64bcd4d29 +ole queries
fm
parents: 10481
diff changeset
   465
!
79c64bcd4d29 +ole queries
fm
parents: 10481
diff changeset
   466
11426
1fccae300393 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 11053
diff changeset
   467
moduleName
1fccae300393 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 11053
diff changeset
   468
    ^ moduleName
1fccae300393 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 11053
diff changeset
   469
!
1fccae300393 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 11053
diff changeset
   470
10484
29039d89239d + returnType
fm
parents: 10483
diff changeset
   471
returnType
29039d89239d + returnType
fm
parents: 10483
diff changeset
   472
    ^ returnType
29039d89239d + returnType
fm
parents: 10483
diff changeset
   473
!
29039d89239d + returnType
fm
parents: 10483
diff changeset
   474
10483
79c64bcd4d29 +ole queries
fm
parents: 10481
diff changeset
   475
vtableIndex
79c64bcd4d29 +ole queries
fm
parents: 10481
diff changeset
   476
    name isNumber ifFalse:[^ nil].
79c64bcd4d29 +ole queries
fm
parents: 10481
diff changeset
   477
    ^ name.
9321
734c7c432461 not yet finished
Claus Gittinger <cg@exept.de>
parents: 8891
diff changeset
   478
! !
734c7c432461 not yet finished
Claus Gittinger <cg@exept.de>
parents: 8891
diff changeset
   479
8891
c30a030ff5ec more FFI (foreign function interface) support - still incomplete
Stefan Vogel <sv@exept.de>
parents: 8728
diff changeset
   480
!ExternalLibraryFunction methodsFor:'invoking'!
c30a030ff5ec more FFI (foreign function interface) support - still incomplete
Stefan Vogel <sv@exept.de>
parents: 8728
diff changeset
   481
c30a030ff5ec more FFI (foreign function interface) support - still incomplete
Stefan Vogel <sv@exept.de>
parents: 8728
diff changeset
   482
invoke
9321
734c7c432461 not yet finished
Claus Gittinger <cg@exept.de>
parents: 8891
diff changeset
   483
    self hasCode ifFalse:[
11586
a3b2eef8a74c int vs. sint
Claus Gittinger <cg@exept.de>
parents: 11426
diff changeset
   484
	self prepareInvoke.
8891
c30a030ff5ec more FFI (foreign function interface) support - still incomplete
Stefan Vogel <sv@exept.de>
parents: 8728
diff changeset
   485
    ].
10440
b643af58f8bf invoking without arguments
fm
parents: 10279
diff changeset
   486
    ^ self invokeFFIWithArguments:nil
8891
c30a030ff5ec more FFI (foreign function interface) support - still incomplete
Stefan Vogel <sv@exept.de>
parents: 8728
diff changeset
   487
!
c30a030ff5ec more FFI (foreign function interface) support - still incomplete
Stefan Vogel <sv@exept.de>
parents: 8728
diff changeset
   488
9347
31adc57e6954 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9346
diff changeset
   489
invokeCPPVirtualOn:anInstance
9341
719fcf48695b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9340
diff changeset
   490
    self hasCode ifFalse:[
11586
a3b2eef8a74c int vs. sint
Claus Gittinger <cg@exept.de>
parents: 11426
diff changeset
   491
	self prepareInvoke.
9341
719fcf48695b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9340
diff changeset
   492
    ].
10440
b643af58f8bf invoking without arguments
fm
parents: 10279
diff changeset
   493
    ^ self invokeCPPVirtualFFIOn:anInstance withArguments:nil
9341
719fcf48695b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9340
diff changeset
   494
!
719fcf48695b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9340
diff changeset
   495
9347
31adc57e6954 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9346
diff changeset
   496
invokeCPPVirtualOn:instance with:arg
9341
719fcf48695b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9340
diff changeset
   497
    self hasCode ifFalse:[
10025
053904a63549 stc-compiled ExternalLibraryFunctions
Claus Gittinger <cg@exept.de>
parents: 9981
diff changeset
   498
	self prepareInvoke.
9341
719fcf48695b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9340
diff changeset
   499
    ].
9347
31adc57e6954 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9346
diff changeset
   500
    ^ self invokeCPPVirtualFFIOn:instance withArguments:(Array with:arg)
9341
719fcf48695b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9340
diff changeset
   501
!
719fcf48695b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9340
diff changeset
   502
9347
31adc57e6954 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9346
diff changeset
   503
invokeCPPVirtualOn:instance with:arg1 with:arg2
9341
719fcf48695b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9340
diff changeset
   504
    self hasCode ifFalse:[
10025
053904a63549 stc-compiled ExternalLibraryFunctions
Claus Gittinger <cg@exept.de>
parents: 9981
diff changeset
   505
	self prepareInvoke.
9341
719fcf48695b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9340
diff changeset
   506
    ].
9347
31adc57e6954 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9346
diff changeset
   507
    ^ self invokeCPPVirtualFFIOn:instance withArguments:(Array with:arg1 with:arg2)
9341
719fcf48695b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9340
diff changeset
   508
!
719fcf48695b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9340
diff changeset
   509
9347
31adc57e6954 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9346
diff changeset
   510
invokeCPPVirtualOn:instance with:arg1 with:arg2 with:arg3
9341
719fcf48695b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9340
diff changeset
   511
    self hasCode ifFalse:[
10025
053904a63549 stc-compiled ExternalLibraryFunctions
Claus Gittinger <cg@exept.de>
parents: 9981
diff changeset
   512
	self prepareInvoke.
9341
719fcf48695b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9340
diff changeset
   513
    ].
9347
31adc57e6954 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9346
diff changeset
   514
    ^ 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
   515
!
719fcf48695b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9340
diff changeset
   516
9347
31adc57e6954 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9346
diff changeset
   517
invokeCPPVirtualOn:instance with:arg1 with:arg2 with:arg3 with:arg4
9341
719fcf48695b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9340
diff changeset
   518
    self hasCode ifFalse:[
10025
053904a63549 stc-compiled ExternalLibraryFunctions
Claus Gittinger <cg@exept.de>
parents: 9981
diff changeset
   519
	self prepareInvoke.
9341
719fcf48695b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9340
diff changeset
   520
    ].
9347
31adc57e6954 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9346
diff changeset
   521
    ^ 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
   522
!
719fcf48695b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9340
diff changeset
   523
10481
b3526180579f +isExternalLibraryFunction
fm
parents: 10440
diff changeset
   524
invokeCPPVirtualOn:instance withArguments:args
b3526180579f +isExternalLibraryFunction
fm
parents: 10440
diff changeset
   525
    self hasCode ifFalse:[
11586
a3b2eef8a74c int vs. sint
Claus Gittinger <cg@exept.de>
parents: 11426
diff changeset
   526
	self prepareInvoke.
10481
b3526180579f +isExternalLibraryFunction
fm
parents: 10440
diff changeset
   527
    ].
b3526180579f +isExternalLibraryFunction
fm
parents: 10440
diff changeset
   528
    ^ self invokeCPPVirtualFFIOn:instance withArguments:args
b3526180579f +isExternalLibraryFunction
fm
parents: 10440
diff changeset
   529
!
b3526180579f +isExternalLibraryFunction
fm
parents: 10440
diff changeset
   530
8891
c30a030ff5ec more FFI (foreign function interface) support - still incomplete
Stefan Vogel <sv@exept.de>
parents: 8728
diff changeset
   531
invokeWith:arg
9321
734c7c432461 not yet finished
Claus Gittinger <cg@exept.de>
parents: 8891
diff changeset
   532
    self hasCode ifFalse:[
9464
157fe6ca53e6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9463
diff changeset
   533
	self prepareInvoke.
9321
734c7c432461 not yet finished
Claus Gittinger <cg@exept.de>
parents: 8891
diff changeset
   534
    ].
734c7c432461 not yet finished
Claus Gittinger <cg@exept.de>
parents: 8891
diff changeset
   535
    ^ self invokeFFIWithArguments:(Array with:arg)
734c7c432461 not yet finished
Claus Gittinger <cg@exept.de>
parents: 8891
diff changeset
   536
!
8891
c30a030ff5ec more FFI (foreign function interface) support - still incomplete
Stefan Vogel <sv@exept.de>
parents: 8728
diff changeset
   537
9321
734c7c432461 not yet finished
Claus Gittinger <cg@exept.de>
parents: 8891
diff changeset
   538
invokeWith:arg1 with:arg2
734c7c432461 not yet finished
Claus Gittinger <cg@exept.de>
parents: 8891
diff changeset
   539
    self hasCode ifFalse:[
9464
157fe6ca53e6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9463
diff changeset
   540
	self prepareInvoke.
8891
c30a030ff5ec more FFI (foreign function interface) support - still incomplete
Stefan Vogel <sv@exept.de>
parents: 8728
diff changeset
   541
    ].
9321
734c7c432461 not yet finished
Claus Gittinger <cg@exept.de>
parents: 8891
diff changeset
   542
    ^ self invokeFFIWithArguments:(Array with:arg1 with:arg2)
734c7c432461 not yet finished
Claus Gittinger <cg@exept.de>
parents: 8891
diff changeset
   543
!
734c7c432461 not yet finished
Claus Gittinger <cg@exept.de>
parents: 8891
diff changeset
   544
734c7c432461 not yet finished
Claus Gittinger <cg@exept.de>
parents: 8891
diff changeset
   545
invokeWith:arg1 with:arg2 with:arg3
734c7c432461 not yet finished
Claus Gittinger <cg@exept.de>
parents: 8891
diff changeset
   546
    self hasCode ifFalse:[
9464
157fe6ca53e6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9463
diff changeset
   547
	self prepareInvoke.
9321
734c7c432461 not yet finished
Claus Gittinger <cg@exept.de>
parents: 8891
diff changeset
   548
    ].
734c7c432461 not yet finished
Claus Gittinger <cg@exept.de>
parents: 8891
diff changeset
   549
    ^ self invokeFFIWithArguments:(Array with:arg1 with:arg2 with:arg3)
734c7c432461 not yet finished
Claus Gittinger <cg@exept.de>
parents: 8891
diff changeset
   550
!
8891
c30a030ff5ec more FFI (foreign function interface) support - still incomplete
Stefan Vogel <sv@exept.de>
parents: 8728
diff changeset
   551
9321
734c7c432461 not yet finished
Claus Gittinger <cg@exept.de>
parents: 8891
diff changeset
   552
invokeWith:arg1 with:arg2 with:arg3 with:arg4
734c7c432461 not yet finished
Claus Gittinger <cg@exept.de>
parents: 8891
diff changeset
   553
    self hasCode ifFalse:[
9464
157fe6ca53e6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9463
diff changeset
   554
	self prepareInvoke.
9321
734c7c432461 not yet finished
Claus Gittinger <cg@exept.de>
parents: 8891
diff changeset
   555
    ].
734c7c432461 not yet finished
Claus Gittinger <cg@exept.de>
parents: 8891
diff changeset
   556
    ^ self invokeFFIWithArguments:(Array with:arg1 with:arg2 with:arg3 with:arg4)
734c7c432461 not yet finished
Claus Gittinger <cg@exept.de>
parents: 8891
diff changeset
   557
!
8891
c30a030ff5ec more FFI (foreign function interface) support - still incomplete
Stefan Vogel <sv@exept.de>
parents: 8728
diff changeset
   558
9321
734c7c432461 not yet finished
Claus Gittinger <cg@exept.de>
parents: 8891
diff changeset
   559
invokeWithArguments:argArray
734c7c432461 not yet finished
Claus Gittinger <cg@exept.de>
parents: 8891
diff changeset
   560
    self hasCode ifFalse:[
10025
053904a63549 stc-compiled ExternalLibraryFunctions
Claus Gittinger <cg@exept.de>
parents: 9981
diff changeset
   561
	self prepareInvoke.
9321
734c7c432461 not yet finished
Claus Gittinger <cg@exept.de>
parents: 8891
diff changeset
   562
    ].
9465
d11885052713 rewrite & cleanup
Claus Gittinger <cg@exept.de>
parents: 9464
diff changeset
   563
    ^ self invokeFFIwithArguments:argArray forCPPInstance:nil
d11885052713 rewrite & cleanup
Claus Gittinger <cg@exept.de>
parents: 9464
diff changeset
   564
d11885052713 rewrite & cleanup
Claus Gittinger <cg@exept.de>
parents: 9464
diff changeset
   565
    "Modified: / 01-08-2006 / 16:04:08 / cg"
9321
734c7c432461 not yet finished
Claus Gittinger <cg@exept.de>
parents: 8891
diff changeset
   566
! !
734c7c432461 not yet finished
Claus Gittinger <cg@exept.de>
parents: 8891
diff changeset
   567
734c7c432461 not yet finished
Claus Gittinger <cg@exept.de>
parents: 8891
diff changeset
   568
!ExternalLibraryFunction methodsFor:'printing'!
734c7c432461 not yet finished
Claus Gittinger <cg@exept.de>
parents: 8891
diff changeset
   569
734c7c432461 not yet finished
Claus Gittinger <cg@exept.de>
parents: 8891
diff changeset
   570
printOn:aStream
734c7c432461 not yet finished
Claus Gittinger <cg@exept.de>
parents: 8891
diff changeset
   571
    aStream nextPutAll:'<'.
9465
d11885052713 rewrite & cleanup
Claus Gittinger <cg@exept.de>
parents: 9464
diff changeset
   572
    self isCallTypeAPI ifTrue:[
14625
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
   573
	'API:' printOn:aStream.
9465
d11885052713 rewrite & cleanup
Claus Gittinger <cg@exept.de>
parents: 9464
diff changeset
   574
    ] ifFalse:[
14625
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
   575
	self isCallTypeOLE ifTrue:[
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
   576
	    'OLE:' printOn:aStream.
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
   577
	] ifFalse:[
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
   578
	    self isCallTypeC ifTrue:[
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
   579
		'C:' printOn:aStream.
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
   580
	    ] ifFalse:[
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
   581
		self error.
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
   582
	    ].
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
   583
	].
9465
d11885052713 rewrite & cleanup
Claus Gittinger <cg@exept.de>
parents: 9464
diff changeset
   584
    ].
9321
734c7c432461 not yet finished
Claus Gittinger <cg@exept.de>
parents: 8891
diff changeset
   585
    aStream nextPutAll:' '.
734c7c432461 not yet finished
Claus Gittinger <cg@exept.de>
parents: 8891
diff changeset
   586
    name printOn:aStream.
9465
d11885052713 rewrite & cleanup
Claus Gittinger <cg@exept.de>
parents: 9464
diff changeset
   587
    moduleName notNil ifTrue:[
14625
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
   588
	aStream nextPutAll:' module:'.
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
   589
	moduleName printOn:aStream.
9465
d11885052713 rewrite & cleanup
Claus Gittinger <cg@exept.de>
parents: 9464
diff changeset
   590
    ].
9321
734c7c432461 not yet finished
Claus Gittinger <cg@exept.de>
parents: 8891
diff changeset
   591
    aStream nextPutAll:'>'.
9465
d11885052713 rewrite & cleanup
Claus Gittinger <cg@exept.de>
parents: 9464
diff changeset
   592
14356
d0e1264c11fe changed: #printOn:
Claus Gittinger <cg@exept.de>
parents: 14103
diff changeset
   593
    "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
   594
! !
c30a030ff5ec more FFI (foreign function interface) support - still incomplete
Stefan Vogel <sv@exept.de>
parents: 8728
diff changeset
   595
c30a030ff5ec more FFI (foreign function interface) support - still incomplete
Stefan Vogel <sv@exept.de>
parents: 8728
diff changeset
   596
!ExternalLibraryFunction methodsFor:'private'!
c30a030ff5ec more FFI (foreign function interface) support - still incomplete
Stefan Vogel <sv@exept.de>
parents: 8728
diff changeset
   597
10213
31717eee6fb2 changed #ffiTypeSymbolForType:
fm
parents: 10025
diff changeset
   598
adjustTypes
31717eee6fb2 changed #ffiTypeSymbolForType:
fm
parents: 10025
diff changeset
   599
    argumentTypes notNil ifTrue:[
31717eee6fb2 changed #ffiTypeSymbolForType:
fm
parents: 10025
diff changeset
   600
	argumentTypes := argumentTypes collect:[:argType | self ffiTypeSymbolForType:argType].
31717eee6fb2 changed #ffiTypeSymbolForType:
fm
parents: 10025
diff changeset
   601
    ].
31717eee6fb2 changed #ffiTypeSymbolForType:
fm
parents: 10025
diff changeset
   602
    returnType := self ffiTypeSymbolForType:returnType.
31717eee6fb2 changed #ffiTypeSymbolForType:
fm
parents: 10025
diff changeset
   603
!
31717eee6fb2 changed #ffiTypeSymbolForType:
fm
parents: 10025
diff changeset
   604
8891
c30a030ff5ec more FFI (foreign function interface) support - still incomplete
Stefan Vogel <sv@exept.de>
parents: 8728
diff changeset
   605
linkToModule
c30a030ff5ec more FFI (foreign function interface) support - still incomplete
Stefan Vogel <sv@exept.de>
parents: 8728
diff changeset
   606
    "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
   607
     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
   608
9465
d11885052713 rewrite & cleanup
Claus Gittinger <cg@exept.de>
parents: 9464
diff changeset
   609
    |handle moduleNameUsed functionName|
8891
c30a030ff5ec more FFI (foreign function interface) support - still incomplete
Stefan Vogel <sv@exept.de>
parents: 8728
diff changeset
   610
10481
b3526180579f +isExternalLibraryFunction
fm
parents: 10440
diff changeset
   611
    name isNumber ifTrue:[
14625
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
   612
	self isCPPFunction ifTrue:[
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
   613
	    "/ no need to load a dll.
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
   614
	    ^ self
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
   615
	]
10481
b3526180579f +isExternalLibraryFunction
fm
parents: 10440
diff changeset
   616
    ].
b3526180579f +isExternalLibraryFunction
fm
parents: 10440
diff changeset
   617
13782
1994fe87f21e comment/format in: #linkToModule
Claus Gittinger <cg@exept.de>
parents: 13412
diff changeset
   618
    "/ 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
   619
    "/ instead, the class provides the libraryName...
9465
d11885052713 rewrite & cleanup
Claus Gittinger <cg@exept.de>
parents: 9464
diff changeset
   620
    (moduleNameUsed := moduleName) isNil ifTrue:[
14625
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
   621
	owningClass isNil ifTrue:[
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
   622
	    self error:'Missing moduleName'.
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
   623
	].
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
   624
	moduleNameUsed := owningClass theNonMetaclass libraryName asSymbol.
9321
734c7c432461 not yet finished
Claus Gittinger <cg@exept.de>
parents: 8891
diff changeset
   625
    ].
11586
a3b2eef8a74c int vs. sint
Claus Gittinger <cg@exept.de>
parents: 11426
diff changeset
   626
    moduleHandle isNil ifTrue:[
14625
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
   627
	handle := self loadLibrary:moduleNameUsed.
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
   628
	handle isNil ifTrue:[
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
   629
	    self error:('Cannot find or load dll/module: "%1"' bindWith: moduleNameUsed).
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
   630
	].
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
   631
	moduleHandle := handle.
8891
c30a030ff5ec more FFI (foreign function interface) support - still incomplete
Stefan Vogel <sv@exept.de>
parents: 8728
diff changeset
   632
    ].
9341
719fcf48695b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9340
diff changeset
   633
    name isNumber ifFalse:[
14625
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
   634
	functionName := name.
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
   635
	(moduleHandle getFunctionAddress:functionName into:self) isNil ifTrue:[
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
   636
	    functionName := ('_', functionName) asSymbol.
9418
df5d2576402d resolve function - if function with name not exists add an underscore in front and retry
ca
parents: 9399
diff changeset
   637
14625
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
   638
	    (moduleHandle getFunctionAddress:functionName into:self) isNil ifTrue:[
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
   639
		moduleHandle := nil.
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
   640
		self error:'Missing function: ', name, ' in module: ', moduleNameUsed.
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
   641
	    ].
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
   642
	].
9321
734c7c432461 not yet finished
Claus Gittinger <cg@exept.de>
parents: 8891
diff changeset
   643
    ].
9392
11914531960a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9386
diff changeset
   644
14103
3df000b77712 class definition
Claus Gittinger <cg@exept.de>
parents: 14037
diff changeset
   645
    "Modified: / 10-04-2012 / 12:12:44 / cg"
9321
734c7c432461 not yet finished
Claus Gittinger <cg@exept.de>
parents: 8891
diff changeset
   646
!
734c7c432461 not yet finished
Claus Gittinger <cg@exept.de>
parents: 8891
diff changeset
   647
10270
897474c6c785 allow setting the dllPath
fm
parents: 10213
diff changeset
   648
loadLibrary:dllName
12436
92a968c9ca92 changed:
Claus Gittinger <cg@exept.de>
parents: 11586
diff changeset
   649
    |handle nameString filename|
10279
60c42983fdd4 first test whether the dllName is the complete filename
ca
parents: 10270
diff changeset
   650
14103
3df000b77712 class definition
Claus Gittinger <cg@exept.de>
parents: 14037
diff changeset
   651
    filename := dllName.
3df000b77712 class definition
Claus Gittinger <cg@exept.de>
parents: 14037
diff changeset
   652
    DllMapping notNil ifTrue:[
14625
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
   653
	filename := DllMapping at:filename ifAbsent:[ filename ]
14103
3df000b77712 class definition
Claus Gittinger <cg@exept.de>
parents: 14037
diff changeset
   654
    ].
3df000b77712 class definition
Claus Gittinger <cg@exept.de>
parents: 14037
diff changeset
   655
3df000b77712 class definition
Claus Gittinger <cg@exept.de>
parents: 14037
diff changeset
   656
    filename := filename asFilename.
12436
92a968c9ca92 changed:
Claus Gittinger <cg@exept.de>
parents: 11586
diff changeset
   657
    nameString := filename name.
10279
60c42983fdd4 first test whether the dllName is the complete filename
ca
parents: 10270
diff changeset
   658
12937
7d5f512fb14a changed: #loadLibrary:
Stefan Vogel <sv@exept.de>
parents: 12680
diff changeset
   659
    "try to load, maybe the system knows where to find the dll"
7d5f512fb14a changed: #loadLibrary:
Stefan Vogel <sv@exept.de>
parents: 12680
diff changeset
   660
    handle := ObjectFileLoader loadDynamicObject:filename.
7d5f512fb14a changed: #loadLibrary:
Stefan Vogel <sv@exept.de>
parents: 12680
diff changeset
   661
    handle notNil ifTrue:[^ handle ].
7d5f512fb14a changed: #loadLibrary:
Stefan Vogel <sv@exept.de>
parents: 12680
diff changeset
   662
12436
92a968c9ca92 changed:
Claus Gittinger <cg@exept.de>
parents: 11586
diff changeset
   663
    filename isAbsolute ifFalse:[
14625
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
   664
	"First ask the class defining the ExternalFunction for the location of the dlls ..."
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
   665
	owningClass notNil ifTrue:[
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
   666
	    owningClass dllPath do:[:eachDirectory |
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
   667
		handle := ObjectFileLoader
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
   668
			    loadDynamicObject:(eachDirectory asFilename construct:nameString) pathName.
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
   669
		handle notNil ifTrue:[^ handle ].
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
   670
	    ].
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
   671
	].
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
   672
	".. then ask the system"
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
   673
	self class dllPath do:[:eachDirectory |
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
   674
	    handle := ObjectFileLoader
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
   675
			loadDynamicObject:(eachDirectory asFilename construct:nameString) pathName.
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
   676
	    handle notNil ifTrue:[^ handle ].
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
   677
	].
10279
60c42983fdd4 first test whether the dllName is the complete filename
ca
parents: 10270
diff changeset
   678
    ].
10270
897474c6c785 allow setting the dllPath
fm
parents: 10213
diff changeset
   679
12436
92a968c9ca92 changed:
Claus Gittinger <cg@exept.de>
parents: 11586
diff changeset
   680
    filename suffix isEmpty ifTrue:[
14625
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
   681
	"/ try again with the OS-specific dll-extension
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
   682
	^ self loadLibrary:(filename withSuffix:ObjectFileLoader sharedLibrarySuffix)
10270
897474c6c785 allow setting the dllPath
fm
parents: 10213
diff changeset
   683
    ].
12436
92a968c9ca92 changed:
Claus Gittinger <cg@exept.de>
parents: 11586
diff changeset
   684
10270
897474c6c785 allow setting the dllPath
fm
parents: 10213
diff changeset
   685
    ^ nil
14103
3df000b77712 class definition
Claus Gittinger <cg@exept.de>
parents: 14037
diff changeset
   686
3df000b77712 class definition
Claus Gittinger <cg@exept.de>
parents: 14037
diff changeset
   687
    "Modified: / 10-04-2012 / 12:21:06 / cg"
10270
897474c6c785 allow setting the dllPath
fm
parents: 10213
diff changeset
   688
!
897474c6c785 allow setting the dllPath
fm
parents: 10213
diff changeset
   689
9321
734c7c432461 not yet finished
Claus Gittinger <cg@exept.de>
parents: 8891
diff changeset
   690
prepareInvoke
10270
897474c6c785 allow setting the dllPath
fm
parents: 10213
diff changeset
   691
    (moduleHandle isNil or:[self hasCode not]) ifTrue:[
12450
c6d60bdca435 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 12449
diff changeset
   692
	self linkToModule.
c6d60bdca435 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 12449
diff changeset
   693
	self adjustTypes.
8891
c30a030ff5ec more FFI (foreign function interface) support - still incomplete
Stefan Vogel <sv@exept.de>
parents: 8728
diff changeset
   694
    ].
c30a030ff5ec more FFI (foreign function interface) support - still incomplete
Stefan Vogel <sv@exept.de>
parents: 8728
diff changeset
   695
! !
c30a030ff5ec more FFI (foreign function interface) support - still incomplete
Stefan Vogel <sv@exept.de>
parents: 8728
diff changeset
   696
8550
72982f85bd41 *** empty log message ***
ca
parents: 8533
diff changeset
   697
!ExternalLibraryFunction methodsFor:'private-accessing'!
72982f85bd41 *** empty log message ***
ca
parents: 8533
diff changeset
   698
9327
9c15276d61e3 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9324
diff changeset
   699
ffiTypeSymbolForType:aType
10025
053904a63549 stc-compiled ExternalLibraryFunctions
Claus Gittinger <cg@exept.de>
parents: 9981
diff changeset
   700
    "map type to one of the ffi-supported ones:
14625
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
   701
	sint8, sint16, sint32, sint64
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
   702
	uint8, uint16, uint32, uint64
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
   703
	bool void pointer handle
10025
053904a63549 stc-compiled ExternalLibraryFunctions
Claus Gittinger <cg@exept.de>
parents: 9981
diff changeset
   704
    "
053904a63549 stc-compiled ExternalLibraryFunctions
Claus Gittinger <cg@exept.de>
parents: 9981
diff changeset
   705
053904a63549 stc-compiled ExternalLibraryFunctions
Claus Gittinger <cg@exept.de>
parents: 9981
diff changeset
   706
    aType == #sint8           ifTrue:[^ aType ].
053904a63549 stc-compiled ExternalLibraryFunctions
Claus Gittinger <cg@exept.de>
parents: 9981
diff changeset
   707
    aType == #sint16          ifTrue:[^ aType ].
053904a63549 stc-compiled ExternalLibraryFunctions
Claus Gittinger <cg@exept.de>
parents: 9981
diff changeset
   708
    aType == #sint32          ifTrue:[^ aType ].
053904a63549 stc-compiled ExternalLibraryFunctions
Claus Gittinger <cg@exept.de>
parents: 9981
diff changeset
   709
    aType == #sint64          ifTrue:[^ aType ].
053904a63549 stc-compiled ExternalLibraryFunctions
Claus Gittinger <cg@exept.de>
parents: 9981
diff changeset
   710
    aType == #uint8           ifTrue:[^ aType ].
053904a63549 stc-compiled ExternalLibraryFunctions
Claus Gittinger <cg@exept.de>
parents: 9981
diff changeset
   711
    aType == #uint16          ifTrue:[^ aType ].
053904a63549 stc-compiled ExternalLibraryFunctions
Claus Gittinger <cg@exept.de>
parents: 9981
diff changeset
   712
    aType == #uint32          ifTrue:[^ aType ].
053904a63549 stc-compiled ExternalLibraryFunctions
Claus Gittinger <cg@exept.de>
parents: 9981
diff changeset
   713
    aType == #uint64          ifTrue:[^ aType ].
053904a63549 stc-compiled ExternalLibraryFunctions
Claus Gittinger <cg@exept.de>
parents: 9981
diff changeset
   714
    aType == #double          ifTrue:[^ aType ].
053904a63549 stc-compiled ExternalLibraryFunctions
Claus Gittinger <cg@exept.de>
parents: 9981
diff changeset
   715
    aType == #float           ifTrue:[^ aType ].
053904a63549 stc-compiled ExternalLibraryFunctions
Claus Gittinger <cg@exept.de>
parents: 9981
diff changeset
   716
    aType == #char            ifTrue:[^ aType ].
053904a63549 stc-compiled ExternalLibraryFunctions
Claus Gittinger <cg@exept.de>
parents: 9981
diff changeset
   717
    aType == #void            ifTrue:[^ aType ].
053904a63549 stc-compiled ExternalLibraryFunctions
Claus Gittinger <cg@exept.de>
parents: 9981
diff changeset
   718
    aType == #bool            ifTrue:[^ aType ].
053904a63549 stc-compiled ExternalLibraryFunctions
Claus Gittinger <cg@exept.de>
parents: 9981
diff changeset
   719
    aType == #pointer         ifTrue:[^ aType ].
12657
7da296a8eeb6 changed: #ffiTypeSymbolForType:
Claus Gittinger <cg@exept.de>
parents: 12656
diff changeset
   720
    aType == #charPointer     ifTrue:[^ aType ].
7da296a8eeb6 changed: #ffiTypeSymbolForType:
Claus Gittinger <cg@exept.de>
parents: 12656
diff changeset
   721
    aType == #wcharPointer    ifTrue:[^ aType ].
10025
053904a63549 stc-compiled ExternalLibraryFunctions
Claus Gittinger <cg@exept.de>
parents: 9981
diff changeset
   722
053904a63549 stc-compiled ExternalLibraryFunctions
Claus Gittinger <cg@exept.de>
parents: 9981
diff changeset
   723
    aType == #int8            ifTrue:[^ #sint8 ].
053904a63549 stc-compiled ExternalLibraryFunctions
Claus Gittinger <cg@exept.de>
parents: 9981
diff changeset
   724
    aType == #int16           ifTrue:[^ #sint16 ].
053904a63549 stc-compiled ExternalLibraryFunctions
Claus Gittinger <cg@exept.de>
parents: 9981
diff changeset
   725
    aType == #int32           ifTrue:[^ #sint32 ].
053904a63549 stc-compiled ExternalLibraryFunctions
Claus Gittinger <cg@exept.de>
parents: 9981
diff changeset
   726
    aType == #int64           ifTrue:[^ #sint64 ].
12450
c6d60bdca435 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 12449
diff changeset
   727
c6d60bdca435 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 12449
diff changeset
   728
    aType == #voidPointer         ifTrue:[^ #pointer ].
c6d60bdca435 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 12449
diff changeset
   729
    aType == #uint8Pointer        ifTrue:[^ #pointer ].
12449
ca958524b42f comment/format in: #prepareInvoke
Claus Gittinger <cg@exept.de>
parents: 12436
diff changeset
   730
    aType == #voidPointerPointer  ifTrue:[^ #pointer ].
10025
053904a63549 stc-compiled ExternalLibraryFunctions
Claus Gittinger <cg@exept.de>
parents: 9981
diff changeset
   731
10213
31717eee6fb2 changed #ffiTypeSymbolForType:
fm
parents: 10025
diff changeset
   732
    aType == #short           ifTrue:[^ #sint16 ].
11586
a3b2eef8a74c int vs. sint
Claus Gittinger <cg@exept.de>
parents: 11426
diff changeset
   733
    aType == #long            ifTrue:[^ #long ].
a3b2eef8a74c int vs. sint
Claus Gittinger <cg@exept.de>
parents: 11426
diff changeset
   734
    aType == #int             ifTrue:[^ #int ].
a3b2eef8a74c int vs. sint
Claus Gittinger <cg@exept.de>
parents: 11426
diff changeset
   735
    aType == #uint            ifTrue:[^ #uint ].
10025
053904a63549 stc-compiled ExternalLibraryFunctions
Claus Gittinger <cg@exept.de>
parents: 9981
diff changeset
   736
    aType == #ushort          ifTrue:[^ #uint16 ].
053904a63549 stc-compiled ExternalLibraryFunctions
Claus Gittinger <cg@exept.de>
parents: 9981
diff changeset
   737
    aType == #unsignedShort   ifTrue:[^ #uint16 ].
11586
a3b2eef8a74c int vs. sint
Claus Gittinger <cg@exept.de>
parents: 11426
diff changeset
   738
    aType == #ulong           ifTrue:[^ #ulong ].
a3b2eef8a74c int vs. sint
Claus Gittinger <cg@exept.de>
parents: 11426
diff changeset
   739
    aType == #unsignedLong    ifTrue:[^ #ulong ].
10025
053904a63549 stc-compiled ExternalLibraryFunctions
Claus Gittinger <cg@exept.de>
parents: 9981
diff changeset
   740
    aType == #uchar           ifTrue:[^ #uint8 ].
053904a63549 stc-compiled ExternalLibraryFunctions
Claus Gittinger <cg@exept.de>
parents: 9981
diff changeset
   741
    aType == #unsignedChar    ifTrue:[^ #uint8 ].
053904a63549 stc-compiled ExternalLibraryFunctions
Claus Gittinger <cg@exept.de>
parents: 9981
diff changeset
   742
    aType == #byte            ifTrue:[^ #uint8 ].
053904a63549 stc-compiled ExternalLibraryFunctions
Claus Gittinger <cg@exept.de>
parents: 9981
diff changeset
   743
    aType == #dword           ifTrue:[^ #uint32 ].
10213
31717eee6fb2 changed #ffiTypeSymbolForType:
fm
parents: 10025
diff changeset
   744
    aType == #sdword          ifTrue:[^ #sint32 ].
10025
053904a63549 stc-compiled ExternalLibraryFunctions
Claus Gittinger <cg@exept.de>
parents: 9981
diff changeset
   745
    aType == #word            ifTrue:[^ #uint16 ].
10213
31717eee6fb2 changed #ffiTypeSymbolForType:
fm
parents: 10025
diff changeset
   746
    aType == #sword           ifTrue:[^ #sint16 ].
12503
cb1a875c3d63 changed: #ffiTypeSymbolForType:
Claus Gittinger <cg@exept.de>
parents: 12474
diff changeset
   747
    aType == #longlong        ifTrue:[^ #sint64 ].
12450
c6d60bdca435 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 12449
diff changeset
   748
    aType == #longLong        ifTrue:[^ #sint64 ].
12503
cb1a875c3d63 changed: #ffiTypeSymbolForType:
Claus Gittinger <cg@exept.de>
parents: 12474
diff changeset
   749
    aType == #ulonglong       ifTrue:[^ #uint64 ].
12450
c6d60bdca435 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 12449
diff changeset
   750
    aType == #ulongLong       ifTrue:[^ #uint64 ].
10025
053904a63549 stc-compiled ExternalLibraryFunctions
Claus Gittinger <cg@exept.de>
parents: 9981
diff changeset
   751
    aType == #handle          ifTrue:[^ #pointer ].
053904a63549 stc-compiled ExternalLibraryFunctions
Claus Gittinger <cg@exept.de>
parents: 9981
diff changeset
   752
    aType == #lpstr           ifTrue:[^ #charPointer ].
053904a63549 stc-compiled ExternalLibraryFunctions
Claus Gittinger <cg@exept.de>
parents: 9981
diff changeset
   753
    aType == #hresult         ifTrue:[^ #uint32 ].
053904a63549 stc-compiled ExternalLibraryFunctions
Claus Gittinger <cg@exept.de>
parents: 9981
diff changeset
   754
    aType == #boolean         ifTrue:[^ #bool ].
053904a63549 stc-compiled ExternalLibraryFunctions
Claus Gittinger <cg@exept.de>
parents: 9981
diff changeset
   755
    aType == #ulongReturn     ifTrue:[^ #uint32 ].    "/ TODO - care for 64bit machines
053904a63549 stc-compiled ExternalLibraryFunctions
Claus Gittinger <cg@exept.de>
parents: 9981
diff changeset
   756
    aType == #none            ifTrue:[^ #void ].
053904a63549 stc-compiled ExternalLibraryFunctions
Claus Gittinger <cg@exept.de>
parents: 9981
diff changeset
   757
    aType == #struct          ifTrue:[^ #pointer ].
053904a63549 stc-compiled ExternalLibraryFunctions
Claus Gittinger <cg@exept.de>
parents: 9981
diff changeset
   758
    aType == #structIn        ifTrue:[^ #pointer ].
053904a63549 stc-compiled ExternalLibraryFunctions
Claus Gittinger <cg@exept.de>
parents: 9981
diff changeset
   759
    aType == #structOut       ifTrue:[^ #pointer ].
10981
29c7d48f7560 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10674
diff changeset
   760
    aType == #unsigned        ifTrue:[^ #uint ].
10025
053904a63549 stc-compiled ExternalLibraryFunctions
Claus Gittinger <cg@exept.de>
parents: 9981
diff changeset
   761
053904a63549 stc-compiled ExternalLibraryFunctions
Claus Gittinger <cg@exept.de>
parents: 9981
diff changeset
   762
    (aType isString or:[aType isSymbol]) ifFalse:[
14625
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
   763
	CType isNil ifTrue:[
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
   764
	    self error:'unknown type'.
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
   765
	].
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
   766
	^ aType typeSymbol.
9483
3bea515ce81e *** empty log message ***
fm
parents: 9479
diff changeset
   767
    ].
3bea515ce81e *** empty log message ***
fm
parents: 9479
diff changeset
   768
12579
516bba5b3e57 changed: #ffiTypeSymbolForType:
Claus Gittinger <cg@exept.de>
parents: 12504
diff changeset
   769
    (aType endsWith:'*') ifTrue:[
14625
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
   770
	^ #pointer.
12579
516bba5b3e57 changed: #ffiTypeSymbolForType:
Claus Gittinger <cg@exept.de>
parents: 12504
diff changeset
   771
    ].
12449
ca958524b42f comment/format in: #prepareInvoke
Claus Gittinger <cg@exept.de>
parents: 12436
diff changeset
   772
    (aType endsWith:'Pointer') ifTrue:[
14625
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
   773
	^ #pointer.
12449
ca958524b42f comment/format in: #prepareInvoke
Claus Gittinger <cg@exept.de>
parents: 12436
diff changeset
   774
    ].
10025
053904a63549 stc-compiled ExternalLibraryFunctions
Claus Gittinger <cg@exept.de>
parents: 9981
diff changeset
   775
    ^ aType
10625
892203aae858 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10619
diff changeset
   776
892203aae858 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10619
diff changeset
   777
    "Modified: / 14-06-2007 / 17:21:42 / cg"
9322
41c391bfbf03 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9321
diff changeset
   778
!
41c391bfbf03 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9321
diff changeset
   779
9466
73333f358696 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9465
diff changeset
   780
name:functionNameOrVirtualIndex module:aModuleName returnType:aReturnType argumentTypes:argTypes
73333f358696 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9465
diff changeset
   781
    name := functionNameOrVirtualIndex.
73333f358696 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9465
diff changeset
   782
    functionNameOrVirtualIndex isNumber ifTrue:[
10025
053904a63549 stc-compiled ExternalLibraryFunctions
Claus Gittinger <cg@exept.de>
parents: 9981
diff changeset
   783
	self beVirtualCPP.
9466
73333f358696 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9465
diff changeset
   784
    ].
8891
c30a030ff5ec more FFI (foreign function interface) support - still incomplete
Stefan Vogel <sv@exept.de>
parents: 8728
diff changeset
   785
    moduleName := aModuleName.
c30a030ff5ec more FFI (foreign function interface) support - still incomplete
Stefan Vogel <sv@exept.de>
parents: 8728
diff changeset
   786
    returnType := aReturnType.
c30a030ff5ec more FFI (foreign function interface) support - still incomplete
Stefan Vogel <sv@exept.de>
parents: 8728
diff changeset
   787
    argumentTypes := argTypes.
9465
d11885052713 rewrite & cleanup
Claus Gittinger <cg@exept.de>
parents: 9464
diff changeset
   788
d11885052713 rewrite & cleanup
Claus Gittinger <cg@exept.de>
parents: 9464
diff changeset
   789
    "Created: / 01-08-2006 / 15:19:52 / cg"
9466
73333f358696 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9465
diff changeset
   790
    "Modified: / 02-08-2006 / 17:20:13 / cg"
9465
d11885052713 rewrite & cleanup
Claus Gittinger <cg@exept.de>
parents: 9464
diff changeset
   791
!
d11885052713 rewrite & cleanup
Claus Gittinger <cg@exept.de>
parents: 9464
diff changeset
   792
11426
1fccae300393 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 11053
diff changeset
   793
owningClass
1fccae300393 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 11053
diff changeset
   794
    ^ owningClass
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
9465
d11885052713 rewrite & cleanup
Claus Gittinger <cg@exept.de>
parents: 9464
diff changeset
   797
owningClass:aClass
d11885052713 rewrite & cleanup
Claus Gittinger <cg@exept.de>
parents: 9464
diff changeset
   798
    owningClass := aClass.
d11885052713 rewrite & cleanup
Claus Gittinger <cg@exept.de>
parents: 9464
diff changeset
   799
d11885052713 rewrite & cleanup
Claus Gittinger <cg@exept.de>
parents: 9464
diff changeset
   800
    "Created: / 01-08-2006 / 15:22:50 / cg"
10603
da9b7ed81caf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10514
diff changeset
   801
!
da9b7ed81caf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10514
diff changeset
   802
11586
a3b2eef8a74c int vs. sint
Claus Gittinger <cg@exept.de>
parents: 11426
diff changeset
   803
setModuleName:aModuleName
10603
da9b7ed81caf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10514
diff changeset
   804
    aModuleName ~= moduleName ifTrue:[
11586
a3b2eef8a74c int vs. sint
Claus Gittinger <cg@exept.de>
parents: 11426
diff changeset
   805
	self code:nil.
a3b2eef8a74c int vs. sint
Claus Gittinger <cg@exept.de>
parents: 11426
diff changeset
   806
	moduleHandle := nil.
a3b2eef8a74c int vs. sint
Claus Gittinger <cg@exept.de>
parents: 11426
diff changeset
   807
	moduleName := aModuleName.
10603
da9b7ed81caf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10514
diff changeset
   808
    ].
da9b7ed81caf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10514
diff changeset
   809
da9b7ed81caf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10514
diff changeset
   810
    "Created: / 07-06-2007 / 10:20:17 / cg"
8550
72982f85bd41 *** empty log message ***
ca
parents: 8533
diff changeset
   811
! !
72982f85bd41 *** empty log message ***
ca
parents: 8533
diff changeset
   812
9342
e548ce80ab02 virtual calls
Claus Gittinger <cg@exept.de>
parents: 9341
diff changeset
   813
!ExternalLibraryFunction methodsFor:'private-invoking'!
e548ce80ab02 virtual calls
Claus Gittinger <cg@exept.de>
parents: 9341
diff changeset
   814
9347
31adc57e6954 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9346
diff changeset
   815
invokeCPPVirtualFFIOn:instance withArguments:arguments
9463
864880338d7e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9460
diff changeset
   816
    ^ self invokeFFIwithArguments:arguments forCPPInstance:instance
864880338d7e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9460
diff changeset
   817
864880338d7e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9460
diff changeset
   818
    "Modified: / 01-08-2006 / 13:55:30 / cg"
9342
e548ce80ab02 virtual calls
Claus Gittinger <cg@exept.de>
parents: 9341
diff changeset
   819
!
e548ce80ab02 virtual calls
Claus Gittinger <cg@exept.de>
parents: 9341
diff changeset
   820
9347
31adc57e6954 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9346
diff changeset
   821
invokeFFIWithArguments:arguments
9463
864880338d7e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9460
diff changeset
   822
    ^ self invokeFFIwithArguments:arguments forCPPInstance:nil
864880338d7e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9460
diff changeset
   823
864880338d7e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9460
diff changeset
   824
    "Modified: / 01-08-2006 / 13:55:35 / cg"
9347
31adc57e6954 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9346
diff changeset
   825
!
31adc57e6954 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9346
diff changeset
   826
10440
b643af58f8bf invoking without arguments
fm
parents: 10279
diff changeset
   827
invokeFFIwithArguments:argumentsOrNil forCPPInstance:aCPlusPlusObjectOrNil
10025
053904a63549 stc-compiled ExternalLibraryFunctions
Claus Gittinger <cg@exept.de>
parents: 9981
diff changeset
   828
    |argTypeSymbols returnTypeSymbol failureCode failureInfo returnValue stClass vtOffset
12579
516bba5b3e57 changed: #ffiTypeSymbolForType:
Claus Gittinger <cg@exept.de>
parents: 12504
diff changeset
   829
     virtual async unlimitedStack callTypeNumber returnValueClass argValueClass
516bba5b3e57 changed: #ffiTypeSymbolForType:
Claus Gittinger <cg@exept.de>
parents: 12504
diff changeset
   830
     oldReturnType oldArgumentTypes
516bba5b3e57 changed: #ffiTypeSymbolForType:
Claus Gittinger <cg@exept.de>
parents: 12504
diff changeset
   831
    |
9342
e548ce80ab02 virtual calls
Claus Gittinger <cg@exept.de>
parents: 9341
diff changeset
   832
10025
053904a63549 stc-compiled ExternalLibraryFunctions
Claus Gittinger <cg@exept.de>
parents: 9981
diff changeset
   833
    argTypeSymbols := argumentTypes.
053904a63549 stc-compiled ExternalLibraryFunctions
Claus Gittinger <cg@exept.de>
parents: 9981
diff changeset
   834
    returnTypeSymbol := returnType.
9346
a95e2cf0e56f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9344
diff changeset
   835
10025
053904a63549 stc-compiled ExternalLibraryFunctions
Claus Gittinger <cg@exept.de>
parents: 9981
diff changeset
   836
    virtual := self isVirtualCPP.
9524
2af286bbcac3 *** empty log message ***
ca
parents: 9519
diff changeset
   837
    (virtual "or:[self isNonVirtualCPP]") ifTrue:[
14625
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
   838
	aCPlusPlusObjectOrNil isNil ifTrue:[
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
   839
	    "/ must have a c++ object instance
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
   840
	    self primitiveFailed.
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
   841
	].
9463
864880338d7e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9460
diff changeset
   842
14625
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
   843
	"/ and it must be a kind of ExternalStructure !!
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
   844
	(aCPlusPlusObjectOrNil isKindOf:ExternalStructure) ifFalse:[
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
   845
	    self primitiveFailed.
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
   846
	].
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
   847
	virtual ifTrue:[
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
   848
	    vtOffset := name.
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
   849
	    (vtOffset between:0 and:10000) ifFalse:[
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
   850
		self primitiveFailed.
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
   851
	    ]
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
   852
	].
9463
864880338d7e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9460
diff changeset
   853
    ] ifFalse:[
14625
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
   854
	aCPlusPlusObjectOrNil notNil ifTrue:[
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
   855
	    "/ must NOT have a c++ object instance
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
   856
	    self primitiveFailed.
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
   857
	].
9342
e548ce80ab02 virtual calls
Claus Gittinger <cg@exept.de>
parents: 9341
diff changeset
   858
    ].
9463
864880338d7e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9460
diff changeset
   859
    async := self isAsync.
864880338d7e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9460
diff changeset
   860
    unlimitedStack := self isUnlimitedStack.
9465
d11885052713 rewrite & cleanup
Claus Gittinger <cg@exept.de>
parents: 9464
diff changeset
   861
    callTypeNumber := self callTypeNumber.
10512
5a01829213ab *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10484
diff changeset
   862
    "/ Transcript show:name; show:' async:'; showCR:async.
9342
e548ce80ab02 virtual calls
Claus Gittinger <cg@exept.de>
parents: 9341
diff changeset
   863
9459
6cd520c582b3 change from unlimited to big stack, to allow for interrupts to be handled
ca
parents: 9436
diff changeset
   864
%{  /* STACK: 100000 */
10025
053904a63549 stc-compiled ExternalLibraryFunctions
Claus Gittinger <cg@exept.de>
parents: 9981
diff changeset
   865
#ifdef HAVE_FFI
12504
c9987bb76eb6 untested long long return value
Claus Gittinger <cg@exept.de>
parents: 12503
diff changeset
   866
# ifdef __GNUC__
c9987bb76eb6 untested long long return value
Claus Gittinger <cg@exept.de>
parents: 12503
diff changeset
   867
#  define HAS_LONGLONG
c9987bb76eb6 untested long long return value
Claus Gittinger <cg@exept.de>
parents: 12503
diff changeset
   868
# endif
c9987bb76eb6 untested long long return value
Claus Gittinger <cg@exept.de>
parents: 12503
diff changeset
   869
# if defined(__BORLANDC__) || defined(__VISUALC__)
c9987bb76eb6 untested long long return value
Claus Gittinger <cg@exept.de>
parents: 12503
diff changeset
   870
#  define HAS_INT64
c9987bb76eb6 untested long long return value
Claus Gittinger <cg@exept.de>
parents: 12503
diff changeset
   871
# endif
c9987bb76eb6 untested long long return value
Claus Gittinger <cg@exept.de>
parents: 12503
diff changeset
   872
9342
e548ce80ab02 virtual calls
Claus Gittinger <cg@exept.de>
parents: 9341
diff changeset
   873
    ffi_cif __cif;
e548ce80ab02 virtual calls
Claus Gittinger <cg@exept.de>
parents: 9341
diff changeset
   874
    ffi_type *__argTypesIncludingThis[MAX_ARGS+1];
e548ce80ab02 virtual calls
Claus Gittinger <cg@exept.de>
parents: 9341
diff changeset
   875
    ffi_type **__argTypes = __argTypesIncludingThis;
e548ce80ab02 virtual calls
Claus Gittinger <cg@exept.de>
parents: 9341
diff changeset
   876
    ffi_type *__returnType = NULL;
12504
c9987bb76eb6 untested long long return value
Claus Gittinger <cg@exept.de>
parents: 12503
diff changeset
   877
9342
e548ce80ab02 virtual calls
Claus Gittinger <cg@exept.de>
parents: 9341
diff changeset
   878
    union u {
14625
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
   879
	int iVal;
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
   880
	float fVal;
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
   881
	double dVal;
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
   882
	void *pointerVal;
12504
c9987bb76eb6 untested long long return value
Claus Gittinger <cg@exept.de>
parents: 12503
diff changeset
   883
# if defined(HAS_LONGLONG)
14625
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
   884
	long long longLongVal;
12504
c9987bb76eb6 untested long long return value
Claus Gittinger <cg@exept.de>
parents: 12503
diff changeset
   885
# else
c9987bb76eb6 untested long long return value
Claus Gittinger <cg@exept.de>
parents: 12503
diff changeset
   886
#  ifdef HAS_INT64
14625
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
   887
	__int64__ longLongVal;
12504
c9987bb76eb6 untested long long return value
Claus Gittinger <cg@exept.de>
parents: 12503
diff changeset
   888
#  else
14625
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
   889
	struct ll { long low; long hi; } longLongVal;
12504
c9987bb76eb6 untested long long return value
Claus Gittinger <cg@exept.de>
parents: 12503
diff changeset
   890
#  endif
c9987bb76eb6 untested long long return value
Claus Gittinger <cg@exept.de>
parents: 12503
diff changeset
   891
# endif
9342
e548ce80ab02 virtual calls
Claus Gittinger <cg@exept.de>
parents: 9341
diff changeset
   892
    };
e548ce80ab02 virtual calls
Claus Gittinger <cg@exept.de>
parents: 9341
diff changeset
   893
    union u __argValuesIncludingThis[MAX_ARGS+1];
e548ce80ab02 virtual calls
Claus Gittinger <cg@exept.de>
parents: 9341
diff changeset
   894
    union u *__argValues = __argValuesIncludingThis;
e548ce80ab02 virtual calls
Claus Gittinger <cg@exept.de>
parents: 9341
diff changeset
   895
    union u __returnValue;
e548ce80ab02 virtual calls
Claus Gittinger <cg@exept.de>
parents: 9341
diff changeset
   896
    void *__argValuePointersIncludingThis[MAX_ARGS+1];
e548ce80ab02 virtual calls
Claus Gittinger <cg@exept.de>
parents: 9341
diff changeset
   897
    void **__argValuePointers = __argValuePointersIncludingThis;
e548ce80ab02 virtual calls
Claus Gittinger <cg@exept.de>
parents: 9341
diff changeset
   898
    void *__returnValuePointer;
e548ce80ab02 virtual calls
Claus Gittinger <cg@exept.de>
parents: 9341
diff changeset
   899
    int __numArgs, __numArgsIncludingThis;
e548ce80ab02 virtual calls
Claus Gittinger <cg@exept.de>
parents: 9341
diff changeset
   900
    static int null = 0;
e548ce80ab02 virtual calls
Claus Gittinger <cg@exept.de>
parents: 9341
diff changeset
   901
    int i;
e548ce80ab02 virtual calls
Claus Gittinger <cg@exept.de>
parents: 9341
diff changeset
   902
    ffi_abi __callType = FFI_DEFAULT_ABI;
e548ce80ab02 virtual calls
Claus Gittinger <cg@exept.de>
parents: 9341
diff changeset
   903
    VOIDFUNC codeAddress = (VOIDFUNC)__INST(code_);
10440
b643af58f8bf invoking without arguments
fm
parents: 10279
diff changeset
   904
    int __numArgsWanted;
12579
516bba5b3e57 changed: #ffiTypeSymbolForType:
Claus Gittinger <cg@exept.de>
parents: 12504
diff changeset
   905
12504
c9987bb76eb6 untested long long return value
Claus Gittinger <cg@exept.de>
parents: 12503
diff changeset
   906
#   define __FAIL__(fcode) \
10603
da9b7ed81caf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10514
diff changeset
   907
    { \
14625
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
   908
	failureCode = fcode; goto getOutOfHere; \
10603
da9b7ed81caf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10514
diff changeset
   909
    }
9342
e548ce80ab02 virtual calls
Claus Gittinger <cg@exept.de>
parents: 9341
diff changeset
   910
10440
b643af58f8bf invoking without arguments
fm
parents: 10279
diff changeset
   911
    if (argumentsOrNil == nil) {
14625
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
   912
	__numArgs = 0;
10440
b643af58f8bf invoking without arguments
fm
parents: 10279
diff changeset
   913
    } else if (__isArray(argumentsOrNil)) {
14625
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
   914
	__numArgs = __arraySize(argumentsOrNil);
9342
e548ce80ab02 virtual calls
Claus Gittinger <cg@exept.de>
parents: 9341
diff changeset
   915
    } else {
14625
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
   916
	__FAIL__(@symbol(BadArgumentVector))
10440
b643af58f8bf invoking without arguments
fm
parents: 10279
diff changeset
   917
    }
b643af58f8bf invoking without arguments
fm
parents: 10279
diff changeset
   918
    if (argTypeSymbols == nil) {
14625
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
   919
	__numArgsWanted = 0;
10440
b643af58f8bf invoking without arguments
fm
parents: 10279
diff changeset
   920
    } else if (__isArray(argTypeSymbols)) {
14625
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
   921
	__numArgsWanted = __arraySize(argTypeSymbols);
10440
b643af58f8bf invoking without arguments
fm
parents: 10279
diff changeset
   922
    } else {
14625
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
   923
	__FAIL__(@symbol(BadArgumentTypeVector))
10440
b643af58f8bf invoking without arguments
fm
parents: 10279
diff changeset
   924
    }
b643af58f8bf invoking without arguments
fm
parents: 10279
diff changeset
   925
b643af58f8bf invoking without arguments
fm
parents: 10279
diff changeset
   926
    if (__numArgs != __numArgsWanted) {
14625
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
   927
	__FAIL__(@symbol(ArgumentCountMismatch))
9342
e548ce80ab02 virtual calls
Claus Gittinger <cg@exept.de>
parents: 9341
diff changeset
   928
    }
e548ce80ab02 virtual calls
Claus Gittinger <cg@exept.de>
parents: 9341
diff changeset
   929
    if (__numArgs > MAX_ARGS) {
14625
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
   930
	__FAIL__(@symbol(TooManyArguments))
9342
e548ce80ab02 virtual calls
Claus Gittinger <cg@exept.de>
parents: 9341
diff changeset
   931
    }
e548ce80ab02 virtual calls
Claus Gittinger <cg@exept.de>
parents: 9341
diff changeset
   932
e548ce80ab02 virtual calls
Claus Gittinger <cg@exept.de>
parents: 9341
diff changeset
   933
    /*
e548ce80ab02 virtual calls
Claus Gittinger <cg@exept.de>
parents: 9341
diff changeset
   934
     * validate the return type
e548ce80ab02 virtual calls
Claus Gittinger <cg@exept.de>
parents: 9341
diff changeset
   935
     */
e548ce80ab02 virtual calls
Claus Gittinger <cg@exept.de>
parents: 9341
diff changeset
   936
    __returnValuePointer = &__returnValue;
9479
68d12a181d4a handle types; sint32 types.
ca
parents: 9466
diff changeset
   937
9483
3bea515ce81e *** empty log message ***
fm
parents: 9479
diff changeset
   938
    if (returnTypeSymbol == @symbol(voidPointer)) {
14625
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
   939
	returnTypeSymbol = @symbol(handle);
9483
3bea515ce81e *** empty log message ***
fm
parents: 9479
diff changeset
   940
    }
9479
68d12a181d4a handle types; sint32 types.
ca
parents: 9466
diff changeset
   941
9342
e548ce80ab02 virtual calls
Claus Gittinger <cg@exept.de>
parents: 9341
diff changeset
   942
    if (returnTypeSymbol == @symbol(int)) {
14625
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
   943
	__returnType = __get_ffi_type_sint();
9342
e548ce80ab02 virtual calls
Claus Gittinger <cg@exept.de>
parents: 9341
diff changeset
   944
    } else if (returnTypeSymbol == @symbol(uint)) {
14625
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
   945
	__returnType = __get_ffi_type_uint();
9479
68d12a181d4a handle types; sint32 types.
ca
parents: 9466
diff changeset
   946
    } else if (returnTypeSymbol == @symbol(uint8)) {
14625
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
   947
	__returnType = __get_ffi_type_uint8();
9479
68d12a181d4a handle types; sint32 types.
ca
parents: 9466
diff changeset
   948
    } else if (returnTypeSymbol == @symbol(uint16)) {
14625
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
   949
	__returnType = __get_ffi_type_uint16();
9479
68d12a181d4a handle types; sint32 types.
ca
parents: 9466
diff changeset
   950
    } else if (returnTypeSymbol == @symbol(uint32)) {
14625
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
   951
	__returnType = __get_ffi_type_uint32();
9479
68d12a181d4a handle types; sint32 types.
ca
parents: 9466
diff changeset
   952
    } else if (returnTypeSymbol == @symbol(uint64)) {
14625
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
   953
	__returnType = __get_ffi_type_uint64();
9479
68d12a181d4a handle types; sint32 types.
ca
parents: 9466
diff changeset
   954
68d12a181d4a handle types; sint32 types.
ca
parents: 9466
diff changeset
   955
    } else if (returnTypeSymbol == @symbol(sint)) {
14625
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
   956
	__returnType = __get_ffi_type_sint();
9479
68d12a181d4a handle types; sint32 types.
ca
parents: 9466
diff changeset
   957
    } else if (returnTypeSymbol == @symbol(sint8)) {
14625
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
   958
	__returnType = __get_ffi_type_sint8();
9479
68d12a181d4a handle types; sint32 types.
ca
parents: 9466
diff changeset
   959
    } else if (returnTypeSymbol == @symbol(sint16)) {
14625
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
   960
	__returnType = __get_ffi_type_sint16();
9479
68d12a181d4a handle types; sint32 types.
ca
parents: 9466
diff changeset
   961
    } else if (returnTypeSymbol == @symbol(sint32)) {
14625
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
   962
	__returnType = __get_ffi_type_sint32();
9479
68d12a181d4a handle types; sint32 types.
ca
parents: 9466
diff changeset
   963
    } else if (returnTypeSymbol == @symbol(sint64)) {
14625
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
   964
	__returnType = __get_ffi_type_sint64();
9479
68d12a181d4a handle types; sint32 types.
ca
parents: 9466
diff changeset
   965
9342
e548ce80ab02 virtual calls
Claus Gittinger <cg@exept.de>
parents: 9341
diff changeset
   966
    } else if (returnTypeSymbol == @symbol(long)) {
14625
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
   967
	if (sizeof(long) == 4) {
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
   968
	   returnTypeSymbol = @symbol(sint32);
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
   969
	   __returnType = __get_ffi_type_sint32();
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
   970
	} else if (sizeof(long) == 8) {
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
   971
	   returnTypeSymbol = @symbol(sint64);
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
   972
	   __returnType = __get_ffi_type_sint64();
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
   973
	} else {
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
   974
	    __FAIL__(@symbol(UnknownReturnType))
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
   975
	}
9479
68d12a181d4a handle types; sint32 types.
ca
parents: 9466
diff changeset
   976
9342
e548ce80ab02 virtual calls
Claus Gittinger <cg@exept.de>
parents: 9341
diff changeset
   977
    } else if (returnTypeSymbol == @symbol(ulong)) {
14625
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
   978
	if (sizeof(long) == 4) {
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
   979
	   returnTypeSymbol = @symbol(uint32);
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
   980
	   __returnType = __get_ffi_type_uint32();
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
   981
	}else if (sizeof(long) == 8) {
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
   982
	   returnTypeSymbol = @symbol(uint64);
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
   983
	   __returnType = __get_ffi_type_uint64();
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
   984
	} else {
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
   985
	    __FAIL__(@symbol(UnknownReturnType))
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
   986
	}
9479
68d12a181d4a handle types; sint32 types.
ca
parents: 9466
diff changeset
   987
10025
053904a63549 stc-compiled ExternalLibraryFunctions
Claus Gittinger <cg@exept.de>
parents: 9981
diff changeset
   988
    } else if (returnTypeSymbol == @symbol(bool)) {
14625
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
   989
	__returnType = __get_ffi_type_uint();
9479
68d12a181d4a handle types; sint32 types.
ca
parents: 9466
diff changeset
   990
9342
e548ce80ab02 virtual calls
Claus Gittinger <cg@exept.de>
parents: 9341
diff changeset
   991
    } else if (returnTypeSymbol == @symbol(float)) {
14625
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
   992
	__returnType = __get_ffi_type_float();
9342
e548ce80ab02 virtual calls
Claus Gittinger <cg@exept.de>
parents: 9341
diff changeset
   993
    } else if (returnTypeSymbol == @symbol(double)) {
14625
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
   994
	__returnType = __get_ffi_type_double();
9479
68d12a181d4a handle types; sint32 types.
ca
parents: 9466
diff changeset
   995
9342
e548ce80ab02 virtual calls
Claus Gittinger <cg@exept.de>
parents: 9341
diff changeset
   996
    } else if (returnTypeSymbol == @symbol(void)) {
14625
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
   997
	__returnType = __get_ffi_type_void();
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
   998
	__returnValuePointer = NULL;
11586
a3b2eef8a74c int vs. sint
Claus Gittinger <cg@exept.de>
parents: 11426
diff changeset
   999
    } else if ((returnTypeSymbol == @symbol(pointer))
14625
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  1000
	       || (returnTypeSymbol == @symbol(handle))
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  1001
	       || (returnTypeSymbol == @symbol(charPointer))
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  1002
	       || (returnTypeSymbol == @symbol(bytePointer))
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  1003
	       || (returnTypeSymbol == @symbol(floatPointer))
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  1004
	       || (returnTypeSymbol == @symbol(doublePointer))
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  1005
	       || (returnTypeSymbol == @symbol(intPointer))
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  1006
	       || (returnTypeSymbol == @symbol(shortPointer))
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  1007
	       || (returnTypeSymbol == @symbol(wcharPointer))) {
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  1008
	__returnType = __get_ffi_type_pointer();
9342
e548ce80ab02 virtual calls
Claus Gittinger <cg@exept.de>
parents: 9341
diff changeset
  1009
    } else {
14625
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  1010
	if (__isSymbol(returnTypeSymbol)
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  1011
	 && ((returnValueClass = __GLOBAL_GET(returnTypeSymbol)) != nil)) {
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  1012
	    if (! __isBehaviorLike(returnValueClass)) {
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  1013
		__FAIL__(@symbol(NonBehaviorReturnType))
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  1014
	    }
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  1015
	    if (! __qIsSubclassOfExternalAddress(returnValueClass)) {
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  1016
		__FAIL__(@symbol(NonExternalAddressReturnType))
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  1017
	    }
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  1018
	    __returnType = __get_ffi_type_pointer();
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  1019
	    returnTypeSymbol = @symbol(pointer);
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  1020
	} else {
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  1021
	    __FAIL__(@symbol(UnknownReturnType))
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  1022
	}
9342
e548ce80ab02 virtual calls
Claus Gittinger <cg@exept.de>
parents: 9341
diff changeset
  1023
    }
e548ce80ab02 virtual calls
Claus Gittinger <cg@exept.de>
parents: 9341
diff changeset
  1024
e548ce80ab02 virtual calls
Claus Gittinger <cg@exept.de>
parents: 9341
diff changeset
  1025
    /*
e548ce80ab02 virtual calls
Claus Gittinger <cg@exept.de>
parents: 9341
diff changeset
  1026
     * validate the c++ object
e548ce80ab02 virtual calls
Claus Gittinger <cg@exept.de>
parents: 9341
diff changeset
  1027
     */
e548ce80ab02 virtual calls
Claus Gittinger <cg@exept.de>
parents: 9341
diff changeset
  1028
    if (aCPlusPlusObjectOrNil != nil) {
14625
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  1029
	struct cPlusPlusInstance {
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  1030
	    void **vTable;
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  1031
	};
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  1032
	struct cPlusPlusInstance *inst;
9342
e548ce80ab02 virtual calls
Claus Gittinger <cg@exept.de>
parents: 9341
diff changeset
  1033
14625
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  1034
	if (__isExternalAddressLike(aCPlusPlusObjectOrNil)) {
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  1035
	    inst = (void *)(__externalAddressVal(aCPlusPlusObjectOrNil));
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  1036
	} else if (__isExternalBytesLike(aCPlusPlusObjectOrNil)) {
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  1037
	    inst = (void *)(__externalBytesVal(aCPlusPlusObjectOrNil));
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  1038
	} else {
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  1039
	    __FAIL__(@symbol(InvalidInstance))
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  1040
	}
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  1041
	__argValues[0].pointerVal = inst;
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  1042
	__argValuePointersIncludingThis[0] = &(__argValues[0]);
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  1043
	__argTypes[0] = __get_ffi_type_pointer();
9342
e548ce80ab02 virtual calls
Claus Gittinger <cg@exept.de>
parents: 9341
diff changeset
  1044
14625
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  1045
	__argValuePointers = &__argValuePointersIncludingThis[1];
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  1046
	__argTypes = &__argTypesIncludingThis[1];
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  1047
	__argValues = &__argValuesIncludingThis[1];
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  1048
	__numArgsIncludingThis = __numArgs + 1;
9347
31adc57e6954 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9346
diff changeset
  1049
14625
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  1050
	if (virtual == true) {
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  1051
	    if (! __isSmallInteger(vtOffset)) {
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  1052
		__FAIL__(@symbol(InvalidVTableIndex))
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  1053
	    }
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  1054
	    codeAddress = inst->vTable[__intVal(vtOffset)];
12504
c9987bb76eb6 untested long long return value
Claus Gittinger <cg@exept.de>
parents: 12503
diff changeset
  1055
# ifdef VERBOSE
14625
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  1056
	    printf("virtual codeAddress: %x\n", codeAddress);
12504
c9987bb76eb6 untested long long return value
Claus Gittinger <cg@exept.de>
parents: 12503
diff changeset
  1057
# endif
14625
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  1058
	}
9342
e548ce80ab02 virtual calls
Claus Gittinger <cg@exept.de>
parents: 9341
diff changeset
  1059
    } else {
14625
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  1060
	__numArgsIncludingThis = __numArgs;
12504
c9987bb76eb6 untested long long return value
Claus Gittinger <cg@exept.de>
parents: 12503
diff changeset
  1061
# ifdef VERBOSE
14625
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  1062
	printf("codeAddress: %x\n", codeAddress);
12504
c9987bb76eb6 untested long long return value
Claus Gittinger <cg@exept.de>
parents: 12503
diff changeset
  1063
# endif
9342
e548ce80ab02 virtual calls
Claus Gittinger <cg@exept.de>
parents: 9341
diff changeset
  1064
    }
e548ce80ab02 virtual calls
Claus Gittinger <cg@exept.de>
parents: 9341
diff changeset
  1065
e548ce80ab02 virtual calls
Claus Gittinger <cg@exept.de>
parents: 9341
diff changeset
  1066
    /*
e548ce80ab02 virtual calls
Claus Gittinger <cg@exept.de>
parents: 9341
diff changeset
  1067
     * validate all arg types and setup arg-buffers
e548ce80ab02 virtual calls
Claus Gittinger <cg@exept.de>
parents: 9341
diff changeset
  1068
     */
e548ce80ab02 virtual calls
Claus Gittinger <cg@exept.de>
parents: 9341
diff changeset
  1069
    for (i=0; i<__numArgs; i++) {
14625
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  1070
	ffi_type *thisType;
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  1071
	void *argValuePtr;
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  1072
	OBJ typeSymbol;
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  1073
	OBJ arg;
9342
e548ce80ab02 virtual calls
Claus Gittinger <cg@exept.de>
parents: 9341
diff changeset
  1074
14625
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  1075
	failureInfo = __mkSmallInteger(i+1);   /* in case there is one */
9465
d11885052713 rewrite & cleanup
Claus Gittinger <cg@exept.de>
parents: 9464
diff changeset
  1076
14625
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  1077
	typeSymbol = __ArrayInstPtr(argTypeSymbols)->a_element[i];
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  1078
	arg = __ArrayInstPtr(argumentsOrNil)->a_element[i];
9342
e548ce80ab02 virtual calls
Claus Gittinger <cg@exept.de>
parents: 9341
diff changeset
  1079
14625
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  1080
	if (typeSymbol == @symbol(handle)) {
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  1081
	    typeSymbol = @symbol(pointer);
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  1082
	} else if (typeSymbol == @symbol(voidPointer)) {
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  1083
	    typeSymbol = @symbol(pointer);
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  1084
	}
9479
68d12a181d4a handle types; sint32 types.
ca
parents: 9466
diff changeset
  1085
14625
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  1086
	if (typeSymbol == @symbol(long)) {
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  1087
	    if (sizeof(long) == sizeof(int)) {
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  1088
		typeSymbol = @symbol(sint);
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  1089
	    } else {
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  1090
		if (sizeof(long) == 4) {
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  1091
		    typeSymbol = @symbol(sint32);
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  1092
		} else if (sizeof(long) == 8) {
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  1093
		    typeSymbol = @symbol(sint64);
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  1094
		}
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  1095
	    }
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  1096
	}
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  1097
	if (typeSymbol == @symbol(ulong)) {
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  1098
	    if (sizeof(unsigned long) == sizeof(unsigned int)) {
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  1099
		typeSymbol = @symbol(uint);
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  1100
	    } else {
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  1101
		if (sizeof(long) == 4) {
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  1102
		    typeSymbol = @symbol(uint32);
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  1103
		} else if (sizeof(long) == 8) {
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  1104
		    typeSymbol = @symbol(uint64);
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  1105
		}
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  1106
	    }
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  1107
	}
9342
e548ce80ab02 virtual calls
Claus Gittinger <cg@exept.de>
parents: 9341
diff changeset
  1108
14625
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  1109
	if (typeSymbol == @symbol(int) || typeSymbol == @symbol(sint)) {
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  1110
	    thisType = __get_ffi_type_sint();
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  1111
	    if (__isSmallInteger(arg)) {
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  1112
		__argValues[i].iVal = __intVal(arg);
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  1113
	    } else {
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  1114
		__argValues[i].iVal = __signedLongIntVal(arg);
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  1115
		if (__argValues[i].iVal == 0) {
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  1116
		    __FAIL__(@symbol(InvalidArgument))
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  1117
		}
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  1118
	    }
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  1119
	    argValuePtr = &(__argValues[i].iVal);
9479
68d12a181d4a handle types; sint32 types.
ca
parents: 9466
diff changeset
  1120
14625
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  1121
	} else if (typeSymbol == @symbol(uint)) {
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  1122
	    thisType = __get_ffi_type_uint();
9342
e548ce80ab02 virtual calls
Claus Gittinger <cg@exept.de>
parents: 9341
diff changeset
  1123
14625
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  1124
	    if (__isSmallInteger(arg)) {
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  1125
		__argValues[i].iVal = __intVal(arg);
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  1126
	    } else {
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  1127
		__argValues[i].iVal = __unsignedLongIntVal(arg);
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  1128
		if (__argValues[i].iVal == 0) {
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  1129
		    __FAIL__(@symbol(InvalidArgument))
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  1130
		}
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  1131
	    }
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  1132
	    argValuePtr = &(__argValues[i].iVal);
9479
68d12a181d4a handle types; sint32 types.
ca
parents: 9466
diff changeset
  1133
14625
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  1134
	} else if (typeSymbol == @symbol(uint8)) {
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  1135
	    thisType = __get_ffi_type_uint8();
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  1136
	    if (! __isSmallInteger(arg)) {
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  1137
		__FAIL__(@symbol(InvalidArgument))
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  1138
	    }
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  1139
	    __argValues[i].iVal = __intVal(arg);
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  1140
	    if (((unsigned)(__argValues[i].iVal)) > 0xFF) {
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  1141
		__FAIL__(@symbol(InvalidArgument))
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  1142
	    }
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  1143
	    argValuePtr = &(__argValues[i].iVal);
9479
68d12a181d4a handle types; sint32 types.
ca
parents: 9466
diff changeset
  1144
14625
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  1145
	} else if (typeSymbol == @symbol(sint8)) {
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  1146
	    thisType = __get_ffi_type_sint8();
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  1147
	    if (! __isSmallInteger(arg)) {
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  1148
		__FAIL__(@symbol(InvalidArgument))
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  1149
	    }
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  1150
	    __argValues[i].iVal = __intVal(arg);
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  1151
	    if (((__argValues[i].iVal) < -0x80) || ((__argValues[i].iVal) > 0x7F))  {
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  1152
		__FAIL__(@symbol(InvalidArgument))
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  1153
	    }
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  1154
	    argValuePtr = &(__argValues[i].iVal);
9479
68d12a181d4a handle types; sint32 types.
ca
parents: 9466
diff changeset
  1155
14625
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  1156
	} else if (typeSymbol == @symbol(uint16)) {
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  1157
	    thisType = __get_ffi_type_uint16();
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  1158
	    if (! __isSmallInteger(arg)) {
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  1159
		__FAIL__(@symbol(InvalidArgument))
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  1160
	    }
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  1161
	    __argValues[i].iVal = __intVal(arg);
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  1162
	    if (((unsigned)(__argValues[i].iVal)) > 0xFFFF) {
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  1163
		__FAIL__(@symbol(InvalidArgument))
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  1164
	    }
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  1165
	    argValuePtr = &(__argValues[i].iVal);
9479
68d12a181d4a handle types; sint32 types.
ca
parents: 9466
diff changeset
  1166
14625
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  1167
	} else if (typeSymbol == @symbol(sint16)) {
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  1168
	    thisType = __get_ffi_type_sint16();
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  1169
	    if (! __isSmallInteger(arg)) {
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  1170
		__FAIL__(@symbol(InvalidArgument))
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  1171
	    }
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  1172
	    __argValues[i].iVal = __intVal(arg);
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  1173
	    if (((__argValues[i].iVal) < -0x8000) || ((__argValues[i].iVal) > 0x7FFF))  {
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  1174
		__FAIL__(@symbol(InvalidArgument))
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  1175
	    }
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  1176
	    argValuePtr = &(__argValues[i].iVal);
9479
68d12a181d4a handle types; sint32 types.
ca
parents: 9466
diff changeset
  1177
14625
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  1178
	} else if ((typeSymbol == @symbol(uint32)) || (typeSymbol == @symbol(sint32))) {
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  1179
	    thisType = __get_ffi_type_uint32();
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  1180
	    if (__isSmallInteger(arg)) {
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  1181
		__argValues[i].iVal = __intVal(arg);
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  1182
	    } else {
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  1183
		__argValues[i].iVal = __unsignedLongIntVal(arg);
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  1184
		if (__argValues[i].iVal == 0) {
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  1185
		    __FAIL__(@symbol(InvalidArgument))
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  1186
		}
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  1187
	    }
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  1188
	    argValuePtr = &(__argValues[i].iVal);
9479
68d12a181d4a handle types; sint32 types.
ca
parents: 9466
diff changeset
  1189
14625
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  1190
	} else if (typeSymbol == @symbol(float)) {
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  1191
	    thisType = __get_ffi_type_float();
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  1192
	    if (__isSmallInteger(arg)) {
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  1193
		__argValues[i].fVal = (float)(__intVal(arg));
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  1194
	    } else if (__isFloat(arg)) {
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  1195
		__argValues[i].fVal = (float)(__floatVal(arg));
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  1196
	    } else if (__isShortFloat(arg)) {
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  1197
		__argValues[i].fVal = (float)(__shortFloatVal(arg));
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  1198
	    } else {
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  1199
		__FAIL__(@symbol(InvalidArgument))
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  1200
	    }
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  1201
	    argValuePtr = &(__argValues[i].fVal);
9479
68d12a181d4a handle types; sint32 types.
ca
parents: 9466
diff changeset
  1202
14625
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  1203
	} else if (typeSymbol == @symbol(double)) {
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  1204
	    thisType = __get_ffi_type_double();
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  1205
	    if (__isSmallInteger(arg)) {
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  1206
		__argValues[i].dVal = (double)(__intVal(arg));
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  1207
	    } else if (__isFloat(arg)) {
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  1208
		__argValues[i].dVal = (double)(__floatVal(arg));
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  1209
	    } else if (__isShortFloat(arg)) {
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  1210
		__argValues[i].dVal = (double)(__shortFloatVal(arg));
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  1211
	    } else {
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  1212
		__FAIL__(@symbol(InvalidArgument))
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  1213
	    }
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  1214
	    argValuePtr = &(__argValues[i].dVal);
9479
68d12a181d4a handle types; sint32 types.
ca
parents: 9466
diff changeset
  1215
14625
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  1216
	} else if (typeSymbol == @symbol(void)) {
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  1217
	    thisType = __get_ffi_type_void();
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  1218
	    argValuePtr = &null;
9479
68d12a181d4a handle types; sint32 types.
ca
parents: 9466
diff changeset
  1219
14625
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  1220
	} else if (typeSymbol == @symbol(charPointer)) {
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  1221
	    thisType = __get_ffi_type_pointer();
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  1222
	    if (__isStringLike(arg)) {
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  1223
		if (async == true) goto badArgForAsyncCall;
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  1224
		__argValues[i].pointerVal = (void *)(__stringVal(arg));
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  1225
	    } else if (__isBytes(arg)) {
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  1226
		if (async == true) goto badArgForAsyncCall;
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  1227
		__argValues[i].pointerVal = (void *)(__byteArrayVal(arg));
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  1228
	    } else if (__isExternalAddressLike(arg)) {
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  1229
		__argValues[i].pointerVal = (void *)(__externalAddressVal(arg));
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  1230
	    } else if (__isExternalBytesLike(arg)) {
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  1231
		__argValues[i].pointerVal = (void *)(__externalBytesVal(arg));
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  1232
	    } else {
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  1233
		if (arg == nil) {
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  1234
		    __argValues[i].pointerVal = (void *)0;
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  1235
		} else {
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  1236
		    __FAIL__(@symbol(InvalidArgument))
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  1237
		}
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  1238
	    }
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  1239
	    argValuePtr = &(__argValues[i].pointerVal);;
10603
da9b7ed81caf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10514
diff changeset
  1240
14625
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  1241
	} else if (typeSymbol == @symbol(wcharPointer)) {
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  1242
	    thisType = __get_ffi_type_pointer();
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  1243
	    if (__isUnicode16String(arg)) {
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  1244
		if (async == true) goto badArgForAsyncCall;
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  1245
		__argValues[i].pointerVal = (void *)(__unicode16StringVal(arg));
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  1246
	    } else if (__isBytes(arg)) {
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  1247
		if (async == true) goto badArgForAsyncCall;
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  1248
		__argValues[i].pointerVal = (void *)(__byteArrayVal(arg));
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  1249
	    } else if (__isExternalAddressLike(arg)) {
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  1250
		__argValues[i].pointerVal = (void *)(__externalAddressVal(arg));
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  1251
	    } else if (__isExternalBytesLike(arg)) {
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  1252
		__argValues[i].pointerVal = (void *)(__externalBytesVal(arg));
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  1253
	    } else {
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  1254
		if (arg == nil) {
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  1255
		    __argValues[i].pointerVal = (void *)0;
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  1256
		} else {
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  1257
		    __FAIL__(@symbol(InvalidArgument))
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  1258
		}
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  1259
	    }
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  1260
	    argValuePtr = &(__argValues[i].pointerVal);;
12656
e7854486b4ff wcharPointer arguments
Claus Gittinger <cg@exept.de>
parents: 12591
diff changeset
  1261
14625
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  1262
	} else if (typeSymbol == @symbol(floatPointer)) {
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  1263
	    thisType = __get_ffi_type_pointer();
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  1264
	    if (__isBytes(arg)) {
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  1265
		if (async == true) goto badArgForAsyncCall;
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  1266
		__argValues[i].pointerVal = (void *)(__byteArrayVal(arg));
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  1267
	    } else if (__isExternalAddressLike(arg)) {
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  1268
		__argValues[i].pointerVal = (void *)(__externalAddressVal(arg));
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  1269
	    } else if (__isExternalBytesLike(arg)) {
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  1270
		__argValues[i].pointerVal = (void *)(__externalBytesVal(arg));
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  1271
	    } else if (__isFloats(arg)) {
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  1272
		char *p = (char *)(__FloatArrayInstPtr(arg)->f_element);
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  1273
		int nInstBytes;
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  1274
		OBJ cls;
10603
da9b7ed81caf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10514
diff changeset
  1275
14625
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  1276
		if (async == true) goto badArgForAsyncCall;
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  1277
		cls = __qClass(arg);
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  1278
		nInstBytes = __OBJS2BYTES__(__intVal(__ClassInstPtr(cls)->c_ninstvars));
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  1279
		p = p + nInstBytes;
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  1280
		__argValues[i].pointerVal = p;
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  1281
	    } else {
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  1282
		if (arg == nil) {
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  1283
		    __argValues[i].pointerVal = (void *)0;
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  1284
		} else {
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  1285
		    __FAIL__(@symbol(InvalidArgument))
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  1286
		}
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  1287
	    }
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  1288
	    argValuePtr = &(__argValues[i].pointerVal);;
10603
da9b7ed81caf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10514
diff changeset
  1289
14625
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  1290
	} else if (typeSymbol == @symbol(doublePointer)) {
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  1291
	    thisType = __get_ffi_type_pointer();
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  1292
	    if (__isBytes(arg)) {
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  1293
		if (async == true) goto badArgForAsyncCall;
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  1294
		__argValues[i].pointerVal = (void *)(__byteArrayVal(arg));
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  1295
	    } else if (__isExternalAddressLike(arg)) {
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  1296
		__argValues[i].pointerVal = (void *)(__externalAddressVal(arg));
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  1297
	    } else if (__isExternalBytesLike(arg)) {
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  1298
		__argValues[i].pointerVal = (void *)(__externalBytesVal(arg));
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  1299
	    } else if (__isDoubles(arg)) {
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  1300
		char *p = (char *)(__DoubleArrayInstPtr(arg)->d_element);
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  1301
		int nInstBytes;
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  1302
		OBJ cls;
10603
da9b7ed81caf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10514
diff changeset
  1303
14625
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  1304
		if (async == true) goto badArgForAsyncCall;
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  1305
		cls = __qClass(arg);
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  1306
		nInstBytes = __OBJS2BYTES__(__intVal(__ClassInstPtr(cls)->c_ninstvars));
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  1307
		p = p + nInstBytes;
12504
c9987bb76eb6 untested long long return value
Claus Gittinger <cg@exept.de>
parents: 12503
diff changeset
  1308
# ifdef __NEED_DOUBLE_ALIGN
14625
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  1309
		if ((INT)(__DoubleArrayInstPtr(arg)->d_element) & (__DOUBLE_ALIGN-1)) {
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  1310
		    int delta = __DOUBLE_ALIGN - ((INT)p & (__DOUBLE_ALIGN-1));
10603
da9b7ed81caf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10514
diff changeset
  1311
14625
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  1312
		    p += delta;
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  1313
		}
12504
c9987bb76eb6 untested long long return value
Claus Gittinger <cg@exept.de>
parents: 12503
diff changeset
  1314
# endif
14625
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  1315
		__argValues[i].pointerVal = p;
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  1316
	    } else {
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  1317
		if (arg == nil) {
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  1318
		    __argValues[i].pointerVal = (void *)0;
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  1319
		} else {
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  1320
		    __FAIL__(@symbol(InvalidArgument))
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  1321
		}
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  1322
	    }
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  1323
	    argValuePtr = &(__argValues[i].pointerVal);;
9479
68d12a181d4a handle types; sint32 types.
ca
parents: 9466
diff changeset
  1324
14625
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  1325
	} else if (typeSymbol == @symbol(pointer)) {
9524
2af286bbcac3 *** empty log message ***
ca
parents: 9519
diff changeset
  1326
commonPointerTypeArg: ;
14625
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  1327
	    thisType = __get_ffi_type_pointer();
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  1328
	    if (arg == nil) {
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  1329
		__argValues[i].pointerVal = NULL;
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  1330
	    } else if (__isExternalAddressLike(arg)) {
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  1331
		__argValues[i].pointerVal = (void *)(__externalAddressVal(arg));
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  1332
	    } else if (__isExternalBytesLike(arg)) {
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  1333
		__argValues[i].pointerVal = (void *)(__externalBytesVal(arg));
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  1334
	    } else if (__isByteArrayLike(arg)) {
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  1335
		if (async == true) goto badArgForAsyncCall;
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  1336
		__argValues[i].pointerVal = (void *)(__byteArrayVal(arg));
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  1337
	    } else if (__isWordArray(arg) || __isSignedWordArray(arg)
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  1338
		    || __isIntegerArray(arg) || __isSignedIntegerArray(arg)) {
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  1339
		if (async == true) goto badArgForAsyncCall;
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  1340
		__argValues[i].pointerVal = (void *)(__integerArrayVal(arg));
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  1341
	    } else if (__isFloatArray(arg)) {
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  1342
		if (async == true) goto badArgForAsyncCall;
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  1343
		__argValues[i].pointerVal = (void *)(__FloatArrayInstPtr(arg)->f_element);
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  1344
	    } else if (__isDoubleArray(arg)) {
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  1345
		if (async == true) goto badArgForAsyncCall;
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  1346
		__argValues[i].pointerVal = (void *)(__DoubleArrayInstPtr(arg)->d_element);
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  1347
	    } else if (__isStringLike(arg)) {
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  1348
		if (async == true) {
9435
68f7e39efad7 support of asynchronous calls
ca
parents: 9418
diff changeset
  1349
badArgForAsyncCall: ;
14625
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  1350
		    __FAIL__(@symbol(BadArgForAsyncCall))
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  1351
		}
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  1352
		__argValues[i].pointerVal = (void *)(__stringVal(arg));
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  1353
	    } else if (__isBytes(arg) || __isWords(arg) || __isLongs(arg)) {
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  1354
		char *p = (char *)(__byteArrayVal(arg));
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  1355
		int nInstBytes;
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  1356
		OBJ cls;
9483
3bea515ce81e *** empty log message ***
fm
parents: 9479
diff changeset
  1357
14625
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  1358
		if (async == true) goto badArgForAsyncCall;
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  1359
		cls = __qClass(arg);
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  1360
		nInstBytes = __OBJS2BYTES__(__intVal(__ClassInstPtr(cls)->c_ninstvars));
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  1361
		__argValues[i].pointerVal = p + nInstBytes;
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  1362
	    } else {
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  1363
		__FAIL__(@symbol(InvalidArgument))
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  1364
	    }
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  1365
	    argValuePtr = &(__argValues[i].pointerVal);;
9479
68d12a181d4a handle types; sint32 types.
ca
parents: 9466
diff changeset
  1366
14625
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  1367
	} else if (typeSymbol == @symbol(bool)) {
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  1368
	    thisType = __get_ffi_type_uint();
9342
e548ce80ab02 virtual calls
Claus Gittinger <cg@exept.de>
parents: 9341
diff changeset
  1369
14625
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  1370
	    if (arg == true) {
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  1371
		__argValues[i].iVal = 1;
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  1372
	    } else if (arg == false) {
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  1373
		__argValues[i].iVal = 0;
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  1374
	    } else if (__isSmallInteger(arg)) {
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  1375
		__argValues[i].iVal = __intVal(arg);
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  1376
	    } else {
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  1377
		__argValues[i].iVal = __unsignedLongIntVal(arg);
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  1378
		if (__argValues[i].iVal == 0) {
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  1379
		    __FAIL__(@symbol(InvalidArgument))
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  1380
		}
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  1381
	    }
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  1382
	    argValuePtr = &(__argValues[i].iVal);
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  1383
	} else {
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  1384
	    if (__isSymbol(typeSymbol)
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  1385
	     && ((argValueClass = __GLOBAL_GET(typeSymbol)) != nil)) {
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  1386
		if (! __isBehaviorLike(argValueClass)) {
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  1387
		    __FAIL__(@symbol(NonBehaviorArgumentType))
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  1388
		}
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  1389
		if (! __qIsSubclassOfExternalAddress(argValueClass)) {
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  1390
		    __FAIL__(@symbol(NonExternalAddressArgumentType))
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  1391
		}
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  1392
		goto commonPointerTypeArg; /* sorry */
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  1393
	    } else {
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  1394
		__FAIL__(@symbol(UnknownArgumentType))
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  1395
	    }
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  1396
	}
9342
e548ce80ab02 virtual calls
Claus Gittinger <cg@exept.de>
parents: 9341
diff changeset
  1397
14625
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  1398
	__argTypes[i] = thisType;
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  1399
	__argValuePointers[i] = argValuePtr;
9483
3bea515ce81e *** empty log message ***
fm
parents: 9479
diff changeset
  1400
12504
c9987bb76eb6 untested long long return value
Claus Gittinger <cg@exept.de>
parents: 12503
diff changeset
  1401
# ifdef VERBOSE
14625
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  1402
	printf("arg%d: %x\n", i, __argValues[i].iVal);
12504
c9987bb76eb6 untested long long return value
Claus Gittinger <cg@exept.de>
parents: 12503
diff changeset
  1403
# endif
9342
e548ce80ab02 virtual calls
Claus Gittinger <cg@exept.de>
parents: 9341
diff changeset
  1404
    }
9465
d11885052713 rewrite & cleanup
Claus Gittinger <cg@exept.de>
parents: 9464
diff changeset
  1405
    failureInfo = nil;
9342
e548ce80ab02 virtual calls
Claus Gittinger <cg@exept.de>
parents: 9341
diff changeset
  1406
e548ce80ab02 virtual calls
Claus Gittinger <cg@exept.de>
parents: 9341
diff changeset
  1407
    __callType = FFI_DEFAULT_ABI;
e548ce80ab02 virtual calls
Claus Gittinger <cg@exept.de>
parents: 9341
diff changeset
  1408
12504
c9987bb76eb6 untested long long return value
Claus Gittinger <cg@exept.de>
parents: 12503
diff changeset
  1409
# ifdef CALLTYPE_FFI_STDCALL
9465
d11885052713 rewrite & cleanup
Claus Gittinger <cg@exept.de>
parents: 9464
diff changeset
  1410
    if (callTypeNumber == @global(CALLTYPE_API)) {
14625
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  1411
	__callType = CALLTYPE_FFI_STDCALL;
9342
e548ce80ab02 virtual calls
Claus Gittinger <cg@exept.de>
parents: 9341
diff changeset
  1412
    }
12504
c9987bb76eb6 untested long long return value
Claus Gittinger <cg@exept.de>
parents: 12503
diff changeset
  1413
# endif
c9987bb76eb6 untested long long return value
Claus Gittinger <cg@exept.de>
parents: 12503
diff changeset
  1414
# ifdef CALLTYPE_FFI_V8
9465
d11885052713 rewrite & cleanup
Claus Gittinger <cg@exept.de>
parents: 9464
diff changeset
  1415
    if (callTypeNumber == @global(CALLTYPE_V8)) {
14625
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  1416
	__callType = CALLTYPE_FFI_V8;
9342
e548ce80ab02 virtual calls
Claus Gittinger <cg@exept.de>
parents: 9341
diff changeset
  1417
    }
12504
c9987bb76eb6 untested long long return value
Claus Gittinger <cg@exept.de>
parents: 12503
diff changeset
  1418
# endif
c9987bb76eb6 untested long long return value
Claus Gittinger <cg@exept.de>
parents: 12503
diff changeset
  1419
# ifdef CALLTYPE_FFI_V9
9465
d11885052713 rewrite & cleanup
Claus Gittinger <cg@exept.de>
parents: 9464
diff changeset
  1420
    if (callTypeNumber == @global(CALLTYPE_V9)) {
14625
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  1421
	__callType = CALLTYPE_FFI_V9;
9342
e548ce80ab02 virtual calls
Claus Gittinger <cg@exept.de>
parents: 9341
diff changeset
  1422
    }
12504
c9987bb76eb6 untested long long return value
Claus Gittinger <cg@exept.de>
parents: 12503
diff changeset
  1423
# endif
c9987bb76eb6 untested long long return value
Claus Gittinger <cg@exept.de>
parents: 12503
diff changeset
  1424
# ifdef CALLTYPE_FFI_UNIX64
9465
d11885052713 rewrite & cleanup
Claus Gittinger <cg@exept.de>
parents: 9464
diff changeset
  1425
    if (callTypeNumber == @global(CALLTYPE_UNIX64)) {
14625
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  1426
	__callType = CALLTYPE_FFI_UNIX64;
9342
e548ce80ab02 virtual calls
Claus Gittinger <cg@exept.de>
parents: 9341
diff changeset
  1427
    }
12504
c9987bb76eb6 untested long long return value
Claus Gittinger <cg@exept.de>
parents: 12503
diff changeset
  1428
# endif
9342
e548ce80ab02 virtual calls
Claus Gittinger <cg@exept.de>
parents: 9341
diff changeset
  1429
e548ce80ab02 virtual calls
Claus Gittinger <cg@exept.de>
parents: 9341
diff changeset
  1430
    if (ffi_prep_cif(&__cif, __callType, __numArgsIncludingThis, __returnType, __argTypesIncludingThis) != FFI_OK) {
14625
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  1431
	__FAIL__(@symbol(FFIPrepareFailed))
9342
e548ce80ab02 virtual calls
Claus Gittinger <cg@exept.de>
parents: 9341
diff changeset
  1432
    }
9463
864880338d7e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9460
diff changeset
  1433
    if (async == true) {
12504
c9987bb76eb6 untested long long return value
Claus Gittinger <cg@exept.de>
parents: 12503
diff changeset
  1434
# ifdef VERBOSE
14625
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  1435
	printf("async call 0x%x\n", codeAddress);
12504
c9987bb76eb6 untested long long return value
Claus Gittinger <cg@exept.de>
parents: 12503
diff changeset
  1436
# endif
c9987bb76eb6 untested long long return value
Claus Gittinger <cg@exept.de>
parents: 12503
diff changeset
  1437
# ifdef WIN32
14625
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  1438
	__STX_C_CALL4( "ffi_call", ffi_call, &__cif, codeAddress, __returnValuePointer, __argValuePointersIncludingThis);
12504
c9987bb76eb6 untested long long return value
Claus Gittinger <cg@exept.de>
parents: 12503
diff changeset
  1439
# else
14625
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  1440
	__BEGIN_INTERRUPTABLE__
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  1441
	ffi_call(&__cif, codeAddress, __returnValuePointer, __argValuePointersIncludingThis);
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  1442
	__END_INTERRUPTABLE__
12504
c9987bb76eb6 untested long long return value
Claus Gittinger <cg@exept.de>
parents: 12503
diff changeset
  1443
# endif
9435
68f7e39efad7 support of asynchronous calls
ca
parents: 9418
diff changeset
  1444
    } else {
14625
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  1445
	if (unlimitedStack == true) {
12504
c9987bb76eb6 untested long long return value
Claus Gittinger <cg@exept.de>
parents: 12503
diff changeset
  1446
# ifdef VERBOSE
14625
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  1447
	    printf("UNLIMITEDSTACKCALL call 0x%x\n", codeAddress);
12504
c9987bb76eb6 untested long long return value
Claus Gittinger <cg@exept.de>
parents: 12503
diff changeset
  1448
# endif
c9987bb76eb6 untested long long return value
Claus Gittinger <cg@exept.de>
parents: 12503
diff changeset
  1449
# if 0
14625
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  1450
	    __UNLIMITEDSTACKCALL__(ffi_call, &__cif, codeAddress, __returnValuePointer, __argValuePointersIncludingThis);
12504
c9987bb76eb6 untested long long return value
Claus Gittinger <cg@exept.de>
parents: 12503
diff changeset
  1451
# endif
14625
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  1452
	} else {
12504
c9987bb76eb6 untested long long return value
Claus Gittinger <cg@exept.de>
parents: 12503
diff changeset
  1453
# ifdef VERBOSE
14625
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  1454
	    printf("call 0x%x\n", codeAddress);
12504
c9987bb76eb6 untested long long return value
Claus Gittinger <cg@exept.de>
parents: 12503
diff changeset
  1455
# endif
14625
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  1456
	    ffi_call(&__cif, codeAddress, __returnValuePointer, __argValuePointersIncludingThis);
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  1457
	}
9435
68f7e39efad7 support of asynchronous calls
ca
parents: 9418
diff changeset
  1458
    }
12504
c9987bb76eb6 untested long long return value
Claus Gittinger <cg@exept.de>
parents: 12503
diff changeset
  1459
# ifdef VERBOSE
9524
2af286bbcac3 *** empty log message ***
ca
parents: 9519
diff changeset
  1460
    printf("retval is %d (0x%x)\n", __returnValue.iVal, __returnValue.iVal);
12504
c9987bb76eb6 untested long long return value
Claus Gittinger <cg@exept.de>
parents: 12503
diff changeset
  1461
# endif
11586
a3b2eef8a74c int vs. sint
Claus Gittinger <cg@exept.de>
parents: 11426
diff changeset
  1462
    if ((returnTypeSymbol == @symbol(int))
a3b2eef8a74c int vs. sint
Claus Gittinger <cg@exept.de>
parents: 11426
diff changeset
  1463
     || (returnTypeSymbol == @symbol(sint))
9479
68d12a181d4a handle types; sint32 types.
ca
parents: 9466
diff changeset
  1464
     || (returnTypeSymbol == @symbol(sint8))
68d12a181d4a handle types; sint32 types.
ca
parents: 9466
diff changeset
  1465
     || (returnTypeSymbol == @symbol(sint16))
68d12a181d4a handle types; sint32 types.
ca
parents: 9466
diff changeset
  1466
     || (returnTypeSymbol == @symbol(sint32))) {
14625
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  1467
	RETURN ( __MKINT(__returnValue.iVal) );
9342
e548ce80ab02 virtual calls
Claus Gittinger <cg@exept.de>
parents: 9341
diff changeset
  1468
    }
e548ce80ab02 virtual calls
Claus Gittinger <cg@exept.de>
parents: 9341
diff changeset
  1469
    if ((returnTypeSymbol == @symbol(uint))
e548ce80ab02 virtual calls
Claus Gittinger <cg@exept.de>
parents: 9341
diff changeset
  1470
     || (returnTypeSymbol == @symbol(uint8))
e548ce80ab02 virtual calls
Claus Gittinger <cg@exept.de>
parents: 9341
diff changeset
  1471
     || (returnTypeSymbol == @symbol(uint16))
e548ce80ab02 virtual calls
Claus Gittinger <cg@exept.de>
parents: 9341
diff changeset
  1472
     || (returnTypeSymbol == @symbol(uint32))) {
14625
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  1473
	RETURN ( __MKUINT(__returnValue.iVal) );
9342
e548ce80ab02 virtual calls
Claus Gittinger <cg@exept.de>
parents: 9341
diff changeset
  1474
    }
10025
053904a63549 stc-compiled ExternalLibraryFunctions
Claus Gittinger <cg@exept.de>
parents: 9981
diff changeset
  1475
    if (returnTypeSymbol == @symbol(bool)) {
14625
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  1476
	RETURN ( __returnValue.iVal ? true : false );
9342
e548ce80ab02 virtual calls
Claus Gittinger <cg@exept.de>
parents: 9341
diff changeset
  1477
    }
e548ce80ab02 virtual calls
Claus Gittinger <cg@exept.de>
parents: 9341
diff changeset
  1478
    if (returnTypeSymbol == @symbol(float)) {
14625
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  1479
	RETURN ( __MKFLOAT(__returnValue.fVal ));
9342
e548ce80ab02 virtual calls
Claus Gittinger <cg@exept.de>
parents: 9341
diff changeset
  1480
    }
e548ce80ab02 virtual calls
Claus Gittinger <cg@exept.de>
parents: 9341
diff changeset
  1481
    if (returnTypeSymbol == @symbol(double)) {
14625
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  1482
	RETURN ( __MKFLOAT(__returnValue.dVal ));
9342
e548ce80ab02 virtual calls
Claus Gittinger <cg@exept.de>
parents: 9341
diff changeset
  1483
    }
e548ce80ab02 virtual calls
Claus Gittinger <cg@exept.de>
parents: 9341
diff changeset
  1484
    if (returnTypeSymbol == @symbol(void)) {
14625
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  1485
	RETURN ( nil );
9342
e548ce80ab02 virtual calls
Claus Gittinger <cg@exept.de>
parents: 9341
diff changeset
  1486
    }
9463
864880338d7e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9460
diff changeset
  1487
    if (returnTypeSymbol == @symbol(char)) {
14625
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  1488
	RETURN ( __MKCHARACTER(__returnValue.iVal & 0xFF) );
9463
864880338d7e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9460
diff changeset
  1489
    }
864880338d7e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9460
diff changeset
  1490
    if (returnTypeSymbol == @symbol(wchar)) {
14625
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  1491
	RETURN ( __MKUCHARACTER(__returnValue.iVal & 0xFFFF) );
12504
c9987bb76eb6 untested long long return value
Claus Gittinger <cg@exept.de>
parents: 12503
diff changeset
  1492
    }
c9987bb76eb6 untested long long return value
Claus Gittinger <cg@exept.de>
parents: 12503
diff changeset
  1493
    if (returnTypeSymbol == @symbol(sint64)) {
14625
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  1494
	RETURN ( __MKINT64(&__returnValue.longLongVal) );
12504
c9987bb76eb6 untested long long return value
Claus Gittinger <cg@exept.de>
parents: 12503
diff changeset
  1495
    }
c9987bb76eb6 untested long long return value
Claus Gittinger <cg@exept.de>
parents: 12503
diff changeset
  1496
    if (returnTypeSymbol == @symbol(uint64)) {
14625
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  1497
	RETURN ( __MKUINT64(&__returnValue.longLongVal) );
9463
864880338d7e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9460
diff changeset
  1498
    }
11586
a3b2eef8a74c int vs. sint
Claus Gittinger <cg@exept.de>
parents: 11426
diff changeset
  1499
12504
c9987bb76eb6 untested long long return value
Claus Gittinger <cg@exept.de>
parents: 12503
diff changeset
  1500
# ifdef VERBOSE
11586
a3b2eef8a74c int vs. sint
Claus Gittinger <cg@exept.de>
parents: 11426
diff changeset
  1501
    printf("%x\n", __returnValue.pointerVal);
12504
c9987bb76eb6 untested long long return value
Claus Gittinger <cg@exept.de>
parents: 12503
diff changeset
  1502
# endif
9346
a95e2cf0e56f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9344
diff changeset
  1503
    if (returnTypeSymbol == @symbol(handle)) {
14625
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  1504
	returnValue = __MKEXTERNALADDRESS(__returnValue.pointerVal);
9346
a95e2cf0e56f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9344
diff changeset
  1505
    } else if (returnTypeSymbol == @symbol(pointer)) {
14625
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  1506
	returnValue = __MKEXTERNALBYTES(__returnValue.pointerVal);
10603
da9b7ed81caf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10514
diff changeset
  1507
    } else if (returnTypeSymbol == @symbol(bytePointer)) {
14625
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  1508
	returnValue = __MKEXTERNALBYTES(__returnValue.pointerVal);
9463
864880338d7e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9460
diff changeset
  1509
    } else if (returnTypeSymbol == @symbol(charPointer)) {
14625
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  1510
	returnValue = __MKSTRING(__returnValue.pointerVal);
9463
864880338d7e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9460
diff changeset
  1511
    } else if (returnTypeSymbol == @symbol(wcharPointer)) {
14625
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  1512
	returnValue = __MKU16STRING(__returnValue.pointerVal);
9342
e548ce80ab02 virtual calls
Claus Gittinger <cg@exept.de>
parents: 9341
diff changeset
  1513
    } else {
14625
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  1514
	__FAIL__(@symbol(UnknownReturnType2))
9342
e548ce80ab02 virtual calls
Claus Gittinger <cg@exept.de>
parents: 9341
diff changeset
  1515
    }
10603
da9b7ed81caf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10514
diff changeset
  1516
#else /* no FFI support */
10618
343d0bf4646a Now can compile even #ifndef HAVE_FFI
Stefan Vogel <sv@exept.de>
parents: 10614
diff changeset
  1517
    failureCode = @symbol(FFINotSupported);
10603
da9b7ed81caf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10514
diff changeset
  1518
#endif /* HAVE_FFI */
9342
e548ce80ab02 virtual calls
Claus Gittinger <cg@exept.de>
parents: 9341
diff changeset
  1519
getOutOfHere: ;
e548ce80ab02 virtual calls
Claus Gittinger <cg@exept.de>
parents: 9341
diff changeset
  1520
%}.
e548ce80ab02 virtual calls
Claus Gittinger <cg@exept.de>
parents: 9341
diff changeset
  1521
    failureCode notNil ifTrue:[
14625
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  1522
	(failureCode == #UnknownReturnType or:[ failureCode == #UnknownArgumentType ]) ifTrue:[
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  1523
	    oldReturnType := returnType.
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  1524
	    oldArgumentTypes := argumentTypes.
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  1525
	    self adjustTypes.
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  1526
	    ((oldReturnType ~= returnType) or:[oldArgumentTypes ~= argumentTypes]) ifTrue:[
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  1527
		thisContext restart
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  1528
	    ].
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  1529
	].
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  1530
	(failureCode == #BadArgForAsyncCall) ifTrue:[
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  1531
	    ^ self tryAgainWithAsyncSafeArguments:argumentsOrNil forCPPInstance:aCPlusPlusObjectOrNil
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  1532
	].
12579
516bba5b3e57 changed: #ffiTypeSymbolForType:
Claus Gittinger <cg@exept.de>
parents: 12504
diff changeset
  1533
14625
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  1534
	self primitiveFailed.   "see failureCode and failureInfo for details"
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  1535
	^ nil
9342
e548ce80ab02 virtual calls
Claus Gittinger <cg@exept.de>
parents: 9341
diff changeset
  1536
    ].
e548ce80ab02 virtual calls
Claus Gittinger <cg@exept.de>
parents: 9341
diff changeset
  1537
9483
3bea515ce81e *** empty log message ***
fm
parents: 9479
diff changeset
  1538
    returnType isSymbol ifTrue:[
14625
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  1539
	returnValueClass notNil ifTrue:[
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  1540
	    self isConstReturnValue ifTrue:[
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  1541
		returnValue changeClassTo:returnValueClass.
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  1542
		^ returnValue
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  1543
	    ].
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  1544
	    ^ returnValueClass fromExternalAddress:returnValue.
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  1545
	].
9483
3bea515ce81e *** empty log message ***
fm
parents: 9479
diff changeset
  1546
    ] ifFalse:[
14625
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  1547
	returnType isCPointer ifTrue:[
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  1548
	    returnType baseType isCStruct ifTrue:[
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  1549
		stClass := Smalltalk classNamed:returnType baseType name.
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  1550
		stClass notNil ifTrue:[
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  1551
		    self isConstReturnValue ifTrue:[
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  1552
			returnValue changeClassTo:returnValueClass.
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  1553
			^ returnValue
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  1554
		    ].
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  1555
		    ^ stClass fromExternalAddress:returnValue.
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  1556
		].
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  1557
	    ].
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  1558
	    returnType baseType isCChar ifTrue:[
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  1559
		^ returnValue stringAt:1
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  1560
	    ].
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  1561
	].
9342
e548ce80ab02 virtual calls
Claus Gittinger <cg@exept.de>
parents: 9341
diff changeset
  1562
    ].
e548ce80ab02 virtual calls
Claus Gittinger <cg@exept.de>
parents: 9341
diff changeset
  1563
e548ce80ab02 virtual calls
Claus Gittinger <cg@exept.de>
parents: 9341
diff changeset
  1564
    ^ returnValue
9463
864880338d7e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9460
diff changeset
  1565
864880338d7e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9460
diff changeset
  1566
    "Created: / 01-08-2006 / 13:56:23 / cg"
10603
da9b7ed81caf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10514
diff changeset
  1567
    "Modified: / 11-06-2007 / 01:50:36 / cg"
14037
Michael Beyl <mb@exept.de>
parents: 13782
diff changeset
  1568
!
Michael Beyl <mb@exept.de>
parents: 13782
diff changeset
  1569
Michael Beyl <mb@exept.de>
parents: 13782
diff changeset
  1570
tryAgainWithAsyncSafeArguments:argumentsOrNil forCPPInstance:aCPlusPlusObjectOrNil
Michael Beyl <mb@exept.de>
parents: 13782
diff changeset
  1571
    "invoked by the call primitive, iff GC-unsave arguments where passed to the call.
Michael Beyl <mb@exept.de>
parents: 13782
diff changeset
  1572
     Here, allocate non-movable blocks of memory and copy the arguments into them,
Michael Beyl <mb@exept.de>
parents: 13782
diff changeset
  1573
     then try the call again, copy changed values back, and release the memeory."
Michael Beyl <mb@exept.de>
parents: 13782
diff changeset
  1574
Michael Beyl <mb@exept.de>
parents: 13782
diff changeset
  1575
    |saveArguments anyBadArg result originalToSaveArgMapping|
Michael Beyl <mb@exept.de>
parents: 13782
diff changeset
  1576
Michael Beyl <mb@exept.de>
parents: 13782
diff changeset
  1577
    argumentsOrNil isNil ifTrue:[
14625
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  1578
	^ self primitiveFailed
14037
Michael Beyl <mb@exept.de>
parents: 13782
diff changeset
  1579
    ].
14506
e53548cdc24d changed: #tryAgainWithAsyncSafeArguments:forCPPInstance:
anwild
parents: 14412
diff changeset
  1580
    thisContext isRecursive ifTrue: [^self primitiveFailed].
14037
Michael Beyl <mb@exept.de>
parents: 13782
diff changeset
  1581
Michael Beyl <mb@exept.de>
parents: 13782
diff changeset
  1582
    anyBadArg := false.
Michael Beyl <mb@exept.de>
parents: 13782
diff changeset
  1583
    originalToSaveArgMapping := IdentityDictionary new.
Michael Beyl <mb@exept.de>
parents: 13782
diff changeset
  1584
14625
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  1585
    saveArguments := argumentsOrNil
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  1586
			collect:[:eachArg |
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  1587
			    |saveArg|
14037
Michael Beyl <mb@exept.de>
parents: 13782
diff changeset
  1588
14625
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  1589
			    (originalToSaveArgMapping includesKey:eachArg) ifTrue:[
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  1590
				saveArg := originalToSaveArgMapping at:eachArg
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  1591
			    ] ifFalse:[
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  1592
				eachArg isString ifTrue:[
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  1593
				    saveArg := (ExternalBytes fromString:eachArg) register.
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  1594
				    anyBadArg := true.
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  1595
				    originalToSaveArgMapping at:eachArg put:saveArg.
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  1596
				] ifFalse:[
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  1597
				    eachArg isByteCollection ifTrue:[
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  1598
					saveArg := (ExternalBytes from:eachArg) register.
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  1599
					originalToSaveArgMapping at:eachArg put:saveArg.
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  1600
					anyBadArg := true.
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  1601
				    ] ifFalse:[
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  1602
					saveArg := eachArg
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  1603
				    ]
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  1604
				].
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  1605
			    ].
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  1606
			    saveArg
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  1607
			].
14037
Michael Beyl <mb@exept.de>
parents: 13782
diff changeset
  1608
Michael Beyl <mb@exept.de>
parents: 13782
diff changeset
  1609
    anyBadArg ifFalse:[
14625
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  1610
	"avoid recursion..."
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  1611
	^ self primitiveFailed
14037
Michael Beyl <mb@exept.de>
parents: 13782
diff changeset
  1612
    ].
Michael Beyl <mb@exept.de>
parents: 13782
diff changeset
  1613
Michael Beyl <mb@exept.de>
parents: 13782
diff changeset
  1614
    result := self invokeFFIwithArguments:saveArguments forCPPInstance:aCPlusPlusObjectOrNil.
Michael Beyl <mb@exept.de>
parents: 13782
diff changeset
  1615
Michael Beyl <mb@exept.de>
parents: 13782
diff changeset
  1616
    "/ copy back !!
Michael Beyl <mb@exept.de>
parents: 13782
diff changeset
  1617
    originalToSaveArgMapping keysAndValuesDo:[:arg :saveArg |
14625
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  1618
	arg isSymbol ifFalse:[
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  1619
	    arg replaceFrom:1 to:(arg size) with:saveArg startingAt:1.
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  1620
	].
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  1621
	saveArg free.
14037
Michael Beyl <mb@exept.de>
parents: 13782
diff changeset
  1622
    ].
Michael Beyl <mb@exept.de>
parents: 13782
diff changeset
  1623
    ^ result.
14506
e53548cdc24d changed: #tryAgainWithAsyncSafeArguments:forCPPInstance:
anwild
parents: 14412
diff changeset
  1624
e53548cdc24d changed: #tryAgainWithAsyncSafeArguments:forCPPInstance:
anwild
parents: 14412
diff changeset
  1625
    "Modified (format): / 06-11-2012 / 10:52:41 / anwild"
9342
e548ce80ab02 virtual calls
Claus Gittinger <cg@exept.de>
parents: 9341
diff changeset
  1626
! !
e548ce80ab02 virtual calls
Claus Gittinger <cg@exept.de>
parents: 9341
diff changeset
  1627
10481
b3526180579f +isExternalLibraryFunction
fm
parents: 10440
diff changeset
  1628
!ExternalLibraryFunction methodsFor:'testing'!
b3526180579f +isExternalLibraryFunction
fm
parents: 10440
diff changeset
  1629
10603
da9b7ed81caf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10514
diff changeset
  1630
isExternalLibraryFunction
da9b7ed81caf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10514
diff changeset
  1631
    "return true, if the receiver is some kind of externalLibrary function;
da9b7ed81caf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10514
diff changeset
  1632
     true is returned here"
da9b7ed81caf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10514
diff changeset
  1633
da9b7ed81caf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10514
diff changeset
  1634
    ^true
da9b7ed81caf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10514
diff changeset
  1635
da9b7ed81caf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10514
diff changeset
  1636
    "Created: / 07-06-2007 / 10:36:40 / cg"
10481
b3526180579f +isExternalLibraryFunction
fm
parents: 10440
diff changeset
  1637
! !
b3526180579f +isExternalLibraryFunction
fm
parents: 10440
diff changeset
  1638
8533
9065c547ea75 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1639
!ExternalLibraryFunction class methodsFor:'documentation'!
9065c547ea75 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1640
13412
9a5f99d66cd9 Jan's changes
vrany
parents: 13337
diff changeset
  1641
version_CVS
14625
290463096ff5 NEED_DOUBLE_ALIGN fix
Claus Gittinger <cg@exept.de>
parents: 14516
diff changeset
  1642
    ^ '$Header: /cvs/stx/stx/libbasic/ExternalLibraryFunction.st,v 1.91 2013-01-02 12:45:06 cg Exp $'
12436
92a968c9ca92 changed:
Claus Gittinger <cg@exept.de>
parents: 11586
diff changeset
  1643
!
92a968c9ca92 changed:
Claus Gittinger <cg@exept.de>
parents: 11586
diff changeset
  1644
13412
9a5f99d66cd9 Jan's changes
vrany
parents: 13337
diff changeset
  1645
version_SVN
13782
1994fe87f21e comment/format in: #linkToModule
Claus Gittinger <cg@exept.de>
parents: 13412
diff changeset
  1646
    ^ '§ Id: ExternalLibraryFunction.st 10643 2011-06-08 21:53:07Z vranyj1  §'
8533
9065c547ea75 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1647
! !
9463
864880338d7e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9460
diff changeset
  1648
864880338d7e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9460
diff changeset
  1649
ExternalLibraryFunction initialize!