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