ExternalLibraryFunction.st
author Stefan Vogel <sv@exept.de>
Thu, 02 Aug 2007 12:00:58 +0200
changeset 10674 400b8823c2df
parent 10625 892203aae858
child 10981 29c7d48f7560
permissions -rw-r--r--
changed #invokeFFIwithArguments:forCPPInstance: - handle long type correctly
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
8728
d70396dc4e96 copyright
Claus Gittinger <cg@exept.de>
parents: 8550
diff changeset
     1
"
d70396dc4e96 copyright
Claus Gittinger <cg@exept.de>
parents: 8550
diff changeset
     2
 COPYRIGHT (c) 2004 by eXept Software AG
9464
157fe6ca53e6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9463
diff changeset
     3
	      All Rights Reserved
8728
d70396dc4e96 copyright
Claus Gittinger <cg@exept.de>
parents: 8550
diff changeset
     4
d70396dc4e96 copyright
Claus Gittinger <cg@exept.de>
parents: 8550
diff changeset
     5
 This software is furnished under a license and may be used
d70396dc4e96 copyright
Claus Gittinger <cg@exept.de>
parents: 8550
diff changeset
     6
 only in accordance with the terms of that license and with the
d70396dc4e96 copyright
Claus Gittinger <cg@exept.de>
parents: 8550
diff changeset
     7
 inclusion of the above copyright notice.   This software may not
d70396dc4e96 copyright
Claus Gittinger <cg@exept.de>
parents: 8550
diff changeset
     8
 be provided or otherwise made available to, or used by, any
d70396dc4e96 copyright
Claus Gittinger <cg@exept.de>
parents: 8550
diff changeset
     9
 other person.  No title to or ownership of the software is
d70396dc4e96 copyright
Claus Gittinger <cg@exept.de>
parents: 8550
diff changeset
    10
 hereby transferred.
d70396dc4e96 copyright
Claus Gittinger <cg@exept.de>
parents: 8550
diff changeset
    11
"
8533
9065c547ea75 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    12
"{ Package: 'stx:libbasic' }"
9065c547ea75 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    13
9065c547ea75 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    14
ExternalFunction subclass:#ExternalLibraryFunction
9465
d11885052713 rewrite & cleanup
Claus Gittinger <cg@exept.de>
parents: 9464
diff changeset
    15
	instanceVariableNames:'flags moduleName returnType argumentTypes owningClass'
10270
897474c6c785 allow setting the dllPath
fm
parents: 10213
diff changeset
    16
	classVariableNames:'DLLPATH FLAG_VIRTUAL FLAG_NONVIRTUAL FLAG_ASYNC
897474c6c785 allow setting the dllPath
fm
parents: 10213
diff changeset
    17
		FLAG_UNLIMITEDSTACK FLAG_RETVAL_IS_CONST CALLTYPE_MASK
897474c6c785 allow setting the dllPath
fm
parents: 10213
diff changeset
    18
		CALLTYPE_API CALLTYPE_C CALLTYPE_OLE CALLTYPE_V8 CALLTYPE_V9
897474c6c785 allow setting the dllPath
fm
parents: 10213
diff changeset
    19
		CALLTYPE_UNIX64'
9464
157fe6ca53e6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9463
diff changeset
    20
	poolDictionaries:''
157fe6ca53e6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9463
diff changeset
    21
	category:'System-Support'
8533
9065c547ea75 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    22
!
9065c547ea75 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    23
9322
41c391bfbf03 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9321
diff changeset
    24
!ExternalLibraryFunction primitiveDefinitions!
41c391bfbf03 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9321
diff changeset
    25
%{
41c391bfbf03 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9321
diff changeset
    26
9337
ab6bbf58bf0a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9336
diff changeset
    27
#ifdef HAVE_FFI
ab6bbf58bf0a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9336
diff changeset
    28
# include <ffi.h>
9322
41c391bfbf03 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9321
diff changeset
    29
# define MAX_ARGS    128
9365
9003f8432516 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9347
diff changeset
    30
9003f8432516 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9347
diff changeset
    31
extern ffi_type *__get_ffi_type_sint();
9003f8432516 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9347
diff changeset
    32
extern ffi_type *__get_ffi_type_sint8();
9003f8432516 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9347
diff changeset
    33
extern ffi_type *__get_ffi_type_sint16();
9003f8432516 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9347
diff changeset
    34
extern ffi_type *__get_ffi_type_sint32();
9003f8432516 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9347
diff changeset
    35
extern ffi_type *__get_ffi_type_sint64();
9003f8432516 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9347
diff changeset
    36
extern ffi_type *__get_ffi_type_uint();
9003f8432516 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9347
diff changeset
    37
extern ffi_type *__get_ffi_type_uint8();
9003f8432516 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9347
diff changeset
    38
extern ffi_type *__get_ffi_type_uint16();
9003f8432516 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9347
diff changeset
    39
extern ffi_type *__get_ffi_type_uint32();
9003f8432516 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9347
diff changeset
    40
extern ffi_type *__get_ffi_type_uint64();
9003f8432516 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9347
diff changeset
    41
extern ffi_type *__get_ffi_type_float();
9003f8432516 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9347
diff changeset
    42
extern ffi_type *__get_ffi_type_double();
9003f8432516 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9347
diff changeset
    43
extern ffi_type *__get_ffi_type_void();
9003f8432516 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9347
diff changeset
    44
extern ffi_type *__get_ffi_type_pointer();
9003f8432516 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9347
diff changeset
    45
9337
ab6bbf58bf0a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9336
diff changeset
    46
#endif
9322
41c391bfbf03 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9321
diff changeset
    47
41c391bfbf03 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9321
diff changeset
    48
%}
41c391bfbf03 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9321
diff changeset
    49
! !
41c391bfbf03 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9321
diff changeset
    50
8728
d70396dc4e96 copyright
Claus Gittinger <cg@exept.de>
parents: 8550
diff changeset
    51
!ExternalLibraryFunction class methodsFor:'documentation'!
d70396dc4e96 copyright
Claus Gittinger <cg@exept.de>
parents: 8550
diff changeset
    52
d70396dc4e96 copyright
Claus Gittinger <cg@exept.de>
parents: 8550
diff changeset
    53
copyright
d70396dc4e96 copyright
Claus Gittinger <cg@exept.de>
parents: 8550
diff changeset
    54
"
d70396dc4e96 copyright
Claus Gittinger <cg@exept.de>
parents: 8550
diff changeset
    55
 COPYRIGHT (c) 2004 by eXept Software AG
9464
157fe6ca53e6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9463
diff changeset
    56
	      All Rights Reserved
8728
d70396dc4e96 copyright
Claus Gittinger <cg@exept.de>
parents: 8550
diff changeset
    57
d70396dc4e96 copyright
Claus Gittinger <cg@exept.de>
parents: 8550
diff changeset
    58
 This software is furnished under a license and may be used
d70396dc4e96 copyright
Claus Gittinger <cg@exept.de>
parents: 8550
diff changeset
    59
 only in accordance with the terms of that license and with the
d70396dc4e96 copyright
Claus Gittinger <cg@exept.de>
parents: 8550
diff changeset
    60
 inclusion of the above copyright notice.   This software may not
d70396dc4e96 copyright
Claus Gittinger <cg@exept.de>
parents: 8550
diff changeset
    61
 be provided or otherwise made available to, or used by, any
d70396dc4e96 copyright
Claus Gittinger <cg@exept.de>
parents: 8550
diff changeset
    62
 other person.  No title to or ownership of the software is
d70396dc4e96 copyright
Claus Gittinger <cg@exept.de>
parents: 8550
diff changeset
    63
 hereby transferred.
d70396dc4e96 copyright
Claus Gittinger <cg@exept.de>
parents: 8550
diff changeset
    64
"
9322
41c391bfbf03 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9321
diff changeset
    65
!
41c391bfbf03 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9321
diff changeset
    66
9331
c26a7de1468c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9330
diff changeset
    67
documentation
c26a7de1468c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9330
diff changeset
    68
"
c26a7de1468c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9330
diff changeset
    69
    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
    70
    When a special external-call pragma such as:
9464
157fe6ca53e6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9463
diff changeset
    71
	<api: bool MessageBeep(uint)>
9331
c26a7de1468c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9330
diff changeset
    72
c26a7de1468c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9330
diff changeset
    73
    is encountered by the parser in a method, the compiler generates a call via
9464
157fe6ca53e6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9463
diff changeset
    74
	<correspondingExternalLibraryFunctionObject> invokeWithArguments: argumentArray.
9331
c26a7de1468c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9330
diff changeset
    75
c26a7de1468c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9330
diff changeset
    76
    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
    77
    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
    78
    and finally, the return value is converted back from C to a smalltalk object.
c26a7de1468c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9330
diff changeset
    79
"
c26a7de1468c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9330
diff changeset
    80
!
c26a7de1468c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9330
diff changeset
    81
9322
41c391bfbf03 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9321
diff changeset
    82
example
41c391bfbf03 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9321
diff changeset
    83
"
9464
157fe6ca53e6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9463
diff changeset
    84
								[exBegin]
157fe6ca53e6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9463
diff changeset
    85
	|f|
9322
41c391bfbf03 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9321
diff changeset
    86
9464
157fe6ca53e6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9463
diff changeset
    87
	f := ExternalLibraryFunction new.
157fe6ca53e6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9463
diff changeset
    88
	f name:'MessageBeep'
157fe6ca53e6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9463
diff changeset
    89
	  module:'user32.dll'
157fe6ca53e6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9463
diff changeset
    90
	  callType:#WINAPI
157fe6ca53e6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9463
diff changeset
    91
	  returnType:#boolean
157fe6ca53e6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9463
diff changeset
    92
	  argumentTypes:#(uint).
9322
41c391bfbf03 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9321
diff changeset
    93
9464
157fe6ca53e6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9463
diff changeset
    94
	f invokeWith:1.
157fe6ca53e6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9463
diff changeset
    95
								[exEnd]
9322
41c391bfbf03 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9321
diff changeset
    96
"
8728
d70396dc4e96 copyright
Claus Gittinger <cg@exept.de>
parents: 8550
diff changeset
    97
! !
8533
9065c547ea75 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    98
8550
72982f85bd41 *** empty log message ***
ca
parents: 8533
diff changeset
    99
!ExternalLibraryFunction class methodsFor:'instance creation'!
72982f85bd41 *** empty log message ***
ca
parents: 8533
diff changeset
   100
9465
d11885052713 rewrite & cleanup
Claus Gittinger <cg@exept.de>
parents: 9464
diff changeset
   101
name:functionName module:moduleName returnType:returnType argumentTypes:argTypes
8550
72982f85bd41 *** empty log message ***
ca
parents: 8533
diff changeset
   102
    ^ self new
10025
053904a63549 stc-compiled ExternalLibraryFunctions
Claus Gittinger <cg@exept.de>
parents: 9981
diff changeset
   103
	name:functionName module:moduleName
053904a63549 stc-compiled ExternalLibraryFunctions
Claus Gittinger <cg@exept.de>
parents: 9981
diff changeset
   104
	returnType:returnType argumentTypes:argTypes
9465
d11885052713 rewrite & cleanup
Claus Gittinger <cg@exept.de>
parents: 9464
diff changeset
   105
d11885052713 rewrite & cleanup
Claus Gittinger <cg@exept.de>
parents: 9464
diff changeset
   106
    "Created: / 01-08-2006 / 15:19:08 / cg"
9463
864880338d7e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9460
diff changeset
   107
! !
864880338d7e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9460
diff changeset
   108
864880338d7e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9460
diff changeset
   109
!ExternalLibraryFunction class methodsFor:'class initialization'!
864880338d7e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9460
diff changeset
   110
10270
897474c6c785 allow setting the dllPath
fm
parents: 10213
diff changeset
   111
dllPath
897474c6c785 allow setting the dllPath
fm
parents: 10213
diff changeset
   112
    ^ DLLPATH ? #( '.' )
897474c6c785 allow setting the dllPath
fm
parents: 10213
diff changeset
   113
!
897474c6c785 allow setting the dllPath
fm
parents: 10213
diff changeset
   114
897474c6c785 allow setting the dllPath
fm
parents: 10213
diff changeset
   115
dllPath:aCollectionOfDirectoryPathNames
897474c6c785 allow setting the dllPath
fm
parents: 10213
diff changeset
   116
    DLLPATH := aCollectionOfDirectoryPathNames
897474c6c785 allow setting the dllPath
fm
parents: 10213
diff changeset
   117
!
897474c6c785 allow setting the dllPath
fm
parents: 10213
diff changeset
   118
9463
864880338d7e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9460
diff changeset
   119
initialize
10025
053904a63549 stc-compiled ExternalLibraryFunctions
Claus Gittinger <cg@exept.de>
parents: 9981
diff changeset
   120
    "using inline access to corresponding c--defines to avoid duplicate places of knowledge"
053904a63549 stc-compiled ExternalLibraryFunctions
Claus Gittinger <cg@exept.de>
parents: 9981
diff changeset
   121
    FLAG_VIRTUAL := %{ __MKSMALLINT(__EXTL_FLAG_VIRTUAL) %}.                "/ a virtual c++ call
053904a63549 stc-compiled ExternalLibraryFunctions
Claus Gittinger <cg@exept.de>
parents: 9981
diff changeset
   122
    FLAG_NONVIRTUAL := %{ __MKSMALLINT(__EXTL_FLAG_NONVIRTUAL) %}.          "/ a non-virtual c++ call
053904a63549 stc-compiled ExternalLibraryFunctions
Claus Gittinger <cg@exept.de>
parents: 9981
diff changeset
   123
    FLAG_UNLIMITEDSTACK := %{ __MKSMALLINT(__EXTL_FLAG_UNLIMITEDSTACK) %}.  "/ unlimitedstack under unix
053904a63549 stc-compiled ExternalLibraryFunctions
Claus Gittinger <cg@exept.de>
parents: 9981
diff changeset
   124
    FLAG_ASYNC := %{ __MKSMALLINT(__EXTL_FLAG_ASYNC) %}.                    "/ async under win32
053904a63549 stc-compiled ExternalLibraryFunctions
Claus Gittinger <cg@exept.de>
parents: 9981
diff changeset
   125
    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
   126
10025
053904a63549 stc-compiled ExternalLibraryFunctions
Claus Gittinger <cg@exept.de>
parents: 9981
diff changeset
   127
    CALLTYPE_API := %{ __MKSMALLINT(__EXTL_CALLTYPE_API) %}.                "/ WINAPI-call (win32 only)
053904a63549 stc-compiled ExternalLibraryFunctions
Claus Gittinger <cg@exept.de>
parents: 9981
diff changeset
   128
    CALLTYPE_C := %{ __MKSMALLINT(__EXTL_CALLTYPE_C) %}.                    "/ regular C-call (the default)
053904a63549 stc-compiled ExternalLibraryFunctions
Claus Gittinger <cg@exept.de>
parents: 9981
diff changeset
   129
    CALLTYPE_V8 := %{ __MKSMALLINT(__EXTL_CALLTYPE_V8) %}.                  "/ v8 call (sparc only)
053904a63549 stc-compiled ExternalLibraryFunctions
Claus Gittinger <cg@exept.de>
parents: 9981
diff changeset
   130
    CALLTYPE_V9 := %{ __MKSMALLINT(__EXTL_CALLTYPE_V9) %}.                  "/ v9 call (sparc only)
053904a63549 stc-compiled ExternalLibraryFunctions
Claus Gittinger <cg@exept.de>
parents: 9981
diff changeset
   131
    CALLTYPE_UNIX64 := %{ __MKSMALLINT(__EXTL_CALLTYPE_UNIX64) %}.          "/ unix64 call (alpha only)
9463
864880338d7e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9460
diff changeset
   132
10025
053904a63549 stc-compiled ExternalLibraryFunctions
Claus Gittinger <cg@exept.de>
parents: 9981
diff changeset
   133
    CALLTYPE_MASK := %{ __MKSMALLINT(__EXTL_CALLTYPE_MASK) %}.
9465
d11885052713 rewrite & cleanup
Claus Gittinger <cg@exept.de>
parents: 9464
diff changeset
   134
10025
053904a63549 stc-compiled ExternalLibraryFunctions
Claus Gittinger <cg@exept.de>
parents: 9981
diff changeset
   135
    "
053904a63549 stc-compiled ExternalLibraryFunctions
Claus Gittinger <cg@exept.de>
parents: 9981
diff changeset
   136
     self initialize
053904a63549 stc-compiled ExternalLibraryFunctions
Claus Gittinger <cg@exept.de>
parents: 9981
diff changeset
   137
    "
053904a63549 stc-compiled ExternalLibraryFunctions
Claus Gittinger <cg@exept.de>
parents: 9981
diff changeset
   138
053904a63549 stc-compiled ExternalLibraryFunctions
Claus Gittinger <cg@exept.de>
parents: 9981
diff changeset
   139
    "Modified: / 03-10-2006 / 21:27:47 / cg"
8550
72982f85bd41 *** empty log message ***
ca
parents: 8533
diff changeset
   140
! !
72982f85bd41 *** empty log message ***
ca
parents: 8533
diff changeset
   141
9321
734c7c432461 not yet finished
Claus Gittinger <cg@exept.de>
parents: 8891
diff changeset
   142
!ExternalLibraryFunction class methodsFor:'constants'!
734c7c432461 not yet finished
Claus Gittinger <cg@exept.de>
parents: 8891
diff changeset
   143
734c7c432461 not yet finished
Claus Gittinger <cg@exept.de>
parents: 8891
diff changeset
   144
callTypeAPI
9463
864880338d7e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9460
diff changeset
   145
    ^ CALLTYPE_API
9321
734c7c432461 not yet finished
Claus Gittinger <cg@exept.de>
parents: 8891
diff changeset
   146
9463
864880338d7e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9460
diff changeset
   147
    "Modified: / 01-08-2006 / 13:44:41 / cg"
9435
68f7e39efad7 support of asynchronous calls
ca
parents: 9418
diff changeset
   148
!
68f7e39efad7 support of asynchronous calls
ca
parents: 9418
diff changeset
   149
9321
734c7c432461 not yet finished
Claus Gittinger <cg@exept.de>
parents: 8891
diff changeset
   150
callTypeC
9463
864880338d7e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9460
diff changeset
   151
    ^ CALLTYPE_C
9321
734c7c432461 not yet finished
Claus Gittinger <cg@exept.de>
parents: 8891
diff changeset
   152
9463
864880338d7e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9460
diff changeset
   153
    "Modified: / 01-08-2006 / 13:44:49 / cg"
9435
68f7e39efad7 support of asynchronous calls
ca
parents: 9418
diff changeset
   154
!
68f7e39efad7 support of asynchronous calls
ca
parents: 9418
diff changeset
   155
9321
734c7c432461 not yet finished
Claus Gittinger <cg@exept.de>
parents: 8891
diff changeset
   156
callTypeCDecl
9463
864880338d7e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9460
diff changeset
   157
    ^ CALLTYPE_C
9321
734c7c432461 not yet finished
Claus Gittinger <cg@exept.de>
parents: 8891
diff changeset
   158
9463
864880338d7e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9460
diff changeset
   159
    "Modified: / 01-08-2006 / 13:44:52 / cg"
9435
68f7e39efad7 support of asynchronous calls
ca
parents: 9418
diff changeset
   160
!
68f7e39efad7 support of asynchronous calls
ca
parents: 9418
diff changeset
   161
10619
dc8c965a8602 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10618
diff changeset
   162
callTypeMASK
dc8c965a8602 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10618
diff changeset
   163
    ^ CALLTYPE_MASK
dc8c965a8602 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10618
diff changeset
   164
dc8c965a8602 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10618
diff changeset
   165
    "Modified: / 01-08-2006 / 13:44:57 / cg"
dc8c965a8602 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10618
diff changeset
   166
!
dc8c965a8602 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10618
diff changeset
   167
9321
734c7c432461 not yet finished
Claus Gittinger <cg@exept.de>
parents: 8891
diff changeset
   168
callTypeOLE
9463
864880338d7e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9460
diff changeset
   169
    ^ CALLTYPE_OLE
9435
68f7e39efad7 support of asynchronous calls
ca
parents: 9418
diff changeset
   170
9463
864880338d7e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9460
diff changeset
   171
    "Modified: / 01-08-2006 / 13:44:57 / cg"
9321
734c7c432461 not yet finished
Claus Gittinger <cg@exept.de>
parents: 8891
diff changeset
   172
! !
734c7c432461 not yet finished
Claus Gittinger <cg@exept.de>
parents: 8891
diff changeset
   173
734c7c432461 not yet finished
Claus Gittinger <cg@exept.de>
parents: 8891
diff changeset
   174
!ExternalLibraryFunction methodsFor:'accessing'!
734c7c432461 not yet finished
Claus Gittinger <cg@exept.de>
parents: 8891
diff changeset
   175
734c7c432461 not yet finished
Claus Gittinger <cg@exept.de>
parents: 8891
diff changeset
   176
argumentTypes
734c7c432461 not yet finished
Claus Gittinger <cg@exept.de>
parents: 8891
diff changeset
   177
    ^ argumentTypes
9463
864880338d7e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9460
diff changeset
   178
!
864880338d7e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9460
diff changeset
   179
864880338d7e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9460
diff changeset
   180
beAsync
864880338d7e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9460
diff changeset
   181
    "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
   182
     Ignored under unix/linux (until those support multiple threads too)."
864880338d7e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9460
diff changeset
   183
864880338d7e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9460
diff changeset
   184
    flags := (flags ? 0) bitOr: FLAG_ASYNC.
864880338d7e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9460
diff changeset
   185
864880338d7e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9460
diff changeset
   186
    "Created: / 01-08-2006 / 13:42:38 / cg"
864880338d7e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9460
diff changeset
   187
!
864880338d7e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9460
diff changeset
   188
9465
d11885052713 rewrite & cleanup
Claus Gittinger <cg@exept.de>
parents: 9464
diff changeset
   189
beCallTypeAPI
d11885052713 rewrite & cleanup
Claus Gittinger <cg@exept.de>
parents: 9464
diff changeset
   190
    flags := (flags ? 0) bitOr: CALLTYPE_API.
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:12:40 / cg"
d11885052713 rewrite & cleanup
Claus Gittinger <cg@exept.de>
parents: 9464
diff changeset
   193
!
d11885052713 rewrite & cleanup
Claus Gittinger <cg@exept.de>
parents: 9464
diff changeset
   194
d11885052713 rewrite & cleanup
Claus Gittinger <cg@exept.de>
parents: 9464
diff changeset
   195
beCallTypeC
d11885052713 rewrite & cleanup
Claus Gittinger <cg@exept.de>
parents: 9464
diff changeset
   196
    flags := (flags ? 0) bitOr: CALLTYPE_C.
d11885052713 rewrite & cleanup
Claus Gittinger <cg@exept.de>
parents: 9464
diff changeset
   197
d11885052713 rewrite & cleanup
Claus Gittinger <cg@exept.de>
parents: 9464
diff changeset
   198
    "Created: / 01-08-2006 / 15:12:40 / cg"
d11885052713 rewrite & cleanup
Claus Gittinger <cg@exept.de>
parents: 9464
diff changeset
   199
!
d11885052713 rewrite & cleanup
Claus Gittinger <cg@exept.de>
parents: 9464
diff changeset
   200
10481
b3526180579f +isExternalLibraryFunction
fm
parents: 10440
diff changeset
   201
beCallTypeOLE
b3526180579f +isExternalLibraryFunction
fm
parents: 10440
diff changeset
   202
    flags := (flags ? 0) bitOr: FLAG_VIRTUAL.
b3526180579f +isExternalLibraryFunction
fm
parents: 10440
diff changeset
   203
b3526180579f +isExternalLibraryFunction
fm
parents: 10440
diff changeset
   204
    "Created: / 01-08-2006 / 15:12:40 / cg"
b3526180579f +isExternalLibraryFunction
fm
parents: 10440
diff changeset
   205
!
b3526180579f +isExternalLibraryFunction
fm
parents: 10440
diff changeset
   206
9465
d11885052713 rewrite & cleanup
Claus Gittinger <cg@exept.de>
parents: 9464
diff changeset
   207
beCallTypeUNIX64
d11885052713 rewrite & cleanup
Claus Gittinger <cg@exept.de>
parents: 9464
diff changeset
   208
    flags := (flags ? 0) bitOr: CALLTYPE_UNIX64.
d11885052713 rewrite & cleanup
Claus Gittinger <cg@exept.de>
parents: 9464
diff changeset
   209
d11885052713 rewrite & cleanup
Claus Gittinger <cg@exept.de>
parents: 9464
diff changeset
   210
    "Created: / 01-08-2006 / 15:13:38 / cg"
d11885052713 rewrite & cleanup
Claus Gittinger <cg@exept.de>
parents: 9464
diff changeset
   211
!
d11885052713 rewrite & cleanup
Claus Gittinger <cg@exept.de>
parents: 9464
diff changeset
   212
d11885052713 rewrite & cleanup
Claus Gittinger <cg@exept.de>
parents: 9464
diff changeset
   213
beCallTypeV8
d11885052713 rewrite & cleanup
Claus Gittinger <cg@exept.de>
parents: 9464
diff changeset
   214
    flags := (flags ? 0) bitOr: CALLTYPE_V8.
d11885052713 rewrite & cleanup
Claus Gittinger <cg@exept.de>
parents: 9464
diff changeset
   215
d11885052713 rewrite & cleanup
Claus Gittinger <cg@exept.de>
parents: 9464
diff changeset
   216
    "Created: / 01-08-2006 / 15:13:28 / cg"
d11885052713 rewrite & cleanup
Claus Gittinger <cg@exept.de>
parents: 9464
diff changeset
   217
!
d11885052713 rewrite & cleanup
Claus Gittinger <cg@exept.de>
parents: 9464
diff changeset
   218
d11885052713 rewrite & cleanup
Claus Gittinger <cg@exept.de>
parents: 9464
diff changeset
   219
beCallTypeV9
d11885052713 rewrite & cleanup
Claus Gittinger <cg@exept.de>
parents: 9464
diff changeset
   220
    flags := (flags ? 0) bitOr: CALLTYPE_V9.
d11885052713 rewrite & cleanup
Claus Gittinger <cg@exept.de>
parents: 9464
diff changeset
   221
d11885052713 rewrite & cleanup
Claus Gittinger <cg@exept.de>
parents: 9464
diff changeset
   222
    "Created: / 01-08-2006 / 15:13:31 / cg"
d11885052713 rewrite & cleanup
Claus Gittinger <cg@exept.de>
parents: 9464
diff changeset
   223
!
d11885052713 rewrite & cleanup
Claus Gittinger <cg@exept.de>
parents: 9464
diff changeset
   224
d11885052713 rewrite & cleanup
Claus Gittinger <cg@exept.de>
parents: 9464
diff changeset
   225
beCallTypeWINAPI
d11885052713 rewrite & cleanup
Claus Gittinger <cg@exept.de>
parents: 9464
diff changeset
   226
    self beCallTypeAPI
d11885052713 rewrite & cleanup
Claus Gittinger <cg@exept.de>
parents: 9464
diff changeset
   227
d11885052713 rewrite & cleanup
Claus Gittinger <cg@exept.de>
parents: 9464
diff changeset
   228
    "Modified: / 01-08-2006 / 15:14:02 / cg"
d11885052713 rewrite & cleanup
Claus Gittinger <cg@exept.de>
parents: 9464
diff changeset
   229
!
d11885052713 rewrite & cleanup
Claus Gittinger <cg@exept.de>
parents: 9464
diff changeset
   230
9525
120234adc94e const specifier (is this a good name ?)
ca
parents: 9524
diff changeset
   231
beConstReturnValue
10025
053904a63549 stc-compiled ExternalLibraryFunctions
Claus Gittinger <cg@exept.de>
parents: 9981
diff changeset
   232
    "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
   233
     (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
   234
120234adc94e const specifier (is this a good name ?)
ca
parents: 9524
diff changeset
   235
    flags := (flags ? 0) bitOr: FLAG_RETVAL_IS_CONST.
120234adc94e const specifier (is this a good name ?)
ca
parents: 9524
diff changeset
   236
120234adc94e const specifier (is this a good name ?)
ca
parents: 9524
diff changeset
   237
    "Created: / 01-08-2006 / 13:56:48 / cg"
120234adc94e const specifier (is this a good name ?)
ca
parents: 9524
diff changeset
   238
!
120234adc94e const specifier (is this a good name ?)
ca
parents: 9524
diff changeset
   239
9463
864880338d7e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9460
diff changeset
   240
beNonVirtualCPP
864880338d7e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9460
diff changeset
   241
    "specify this as a non-virtual c++-function"
864880338d7e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9460
diff changeset
   242
864880338d7e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9460
diff changeset
   243
    flags := (flags ? 0) bitOr: FLAG_NONVIRTUAL.
864880338d7e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9460
diff changeset
   244
864880338d7e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9460
diff changeset
   245
    "Created: / 01-08-2006 / 13:56:44 / cg"
864880338d7e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9460
diff changeset
   246
!
864880338d7e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9460
diff changeset
   247
864880338d7e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9460
diff changeset
   248
beUnlimitedStack
864880338d7e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9460
diff changeset
   249
    "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
   250
     for unlimited auto-sized-stack under unix/linux.
864880338d7e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9460
diff changeset
   251
     Ignored under windows."
864880338d7e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9460
diff changeset
   252
864880338d7e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9460
diff changeset
   253
    flags := (flags ? 0) bitOr: FLAG_UNLIMITEDSTACK.
864880338d7e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9460
diff changeset
   254
864880338d7e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9460
diff changeset
   255
    "Created: / 01-08-2006 / 13:41:54 / cg"
864880338d7e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9460
diff changeset
   256
!
864880338d7e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9460
diff changeset
   257
864880338d7e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9460
diff changeset
   258
beVirtualCPP
864880338d7e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9460
diff changeset
   259
    "specify this as a virtual c++-function"
864880338d7e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9460
diff changeset
   260
864880338d7e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9460
diff changeset
   261
    flags := (flags ? 0) bitOr: FLAG_VIRTUAL.
864880338d7e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9460
diff changeset
   262
864880338d7e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9460
diff changeset
   263
    "Created: / 01-08-2006 / 13:56:48 / cg"
864880338d7e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9460
diff changeset
   264
!
864880338d7e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9460
diff changeset
   265
9465
d11885052713 rewrite & cleanup
Claus Gittinger <cg@exept.de>
parents: 9464
diff changeset
   266
callTypeNumber
d11885052713 rewrite & cleanup
Claus Gittinger <cg@exept.de>
parents: 9464
diff changeset
   267
    ^ (flags ? 0) bitAnd: CALLTYPE_MASK.
d11885052713 rewrite & cleanup
Claus Gittinger <cg@exept.de>
parents: 9464
diff changeset
   268
d11885052713 rewrite & cleanup
Claus Gittinger <cg@exept.de>
parents: 9464
diff changeset
   269
    "Created: / 01-08-2006 / 15:12:10 / cg"
d11885052713 rewrite & cleanup
Claus Gittinger <cg@exept.de>
parents: 9464
diff changeset
   270
!
d11885052713 rewrite & cleanup
Claus Gittinger <cg@exept.de>
parents: 9464
diff changeset
   271
9463
864880338d7e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9460
diff changeset
   272
isAsync
864880338d7e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9460
diff changeset
   273
    "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
   274
864880338d7e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9460
diff changeset
   275
    ^ (flags ? 0) bitTest: FLAG_ASYNC.
864880338d7e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9460
diff changeset
   276
864880338d7e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9460
diff changeset
   277
    "Created: / 01-08-2006 / 13:46:53 / cg"
864880338d7e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9460
diff changeset
   278
!
864880338d7e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9460
diff changeset
   279
9519
ad18bf96758d *** empty log message ***
ca
parents: 9483
diff changeset
   280
isCPPFunction
ad18bf96758d *** empty log message ***
ca
parents: 9483
diff changeset
   281
    "is this a virtual or non-virtual c++-function ?"
ad18bf96758d *** empty log message ***
ca
parents: 9483
diff changeset
   282
ad18bf96758d *** empty log message ***
ca
parents: 9483
diff changeset
   283
    ^ (flags ? 0) bitTest: (FLAG_VIRTUAL bitOr: FLAG_NONVIRTUAL).
ad18bf96758d *** empty log message ***
ca
parents: 9483
diff changeset
   284
ad18bf96758d *** empty log message ***
ca
parents: 9483
diff changeset
   285
    "Created: / 01-08-2006 / 13:56:54 / cg"
ad18bf96758d *** empty log message ***
ca
parents: 9483
diff changeset
   286
!
ad18bf96758d *** empty log message ***
ca
parents: 9483
diff changeset
   287
9465
d11885052713 rewrite & cleanup
Claus Gittinger <cg@exept.de>
parents: 9464
diff changeset
   288
isCallTypeAPI
d11885052713 rewrite & cleanup
Claus Gittinger <cg@exept.de>
parents: 9464
diff changeset
   289
    ^ ((flags ? 0) bitAnd: CALLTYPE_MASK) == CALLTYPE_API.
d11885052713 rewrite & cleanup
Claus Gittinger <cg@exept.de>
parents: 9464
diff changeset
   290
d11885052713 rewrite & cleanup
Claus Gittinger <cg@exept.de>
parents: 9464
diff changeset
   291
    "Created: / 01-08-2006 / 15:21:16 / cg"
d11885052713 rewrite & cleanup
Claus Gittinger <cg@exept.de>
parents: 9464
diff changeset
   292
!
d11885052713 rewrite & cleanup
Claus Gittinger <cg@exept.de>
parents: 9464
diff changeset
   293
d11885052713 rewrite & cleanup
Claus Gittinger <cg@exept.de>
parents: 9464
diff changeset
   294
isCallTypeC
d11885052713 rewrite & cleanup
Claus Gittinger <cg@exept.de>
parents: 9464
diff changeset
   295
    ^ ((flags ? 0) bitAnd: CALLTYPE_MASK) == CALLTYPE_C.
d11885052713 rewrite & cleanup
Claus Gittinger <cg@exept.de>
parents: 9464
diff changeset
   296
d11885052713 rewrite & cleanup
Claus Gittinger <cg@exept.de>
parents: 9464
diff changeset
   297
    "Created: / 01-08-2006 / 15:21:23 / cg"
d11885052713 rewrite & cleanup
Claus Gittinger <cg@exept.de>
parents: 9464
diff changeset
   298
!
d11885052713 rewrite & cleanup
Claus Gittinger <cg@exept.de>
parents: 9464
diff changeset
   299
10483
79c64bcd4d29 +ole queries
fm
parents: 10481
diff changeset
   300
isCallTypeOLE
79c64bcd4d29 +ole queries
fm
parents: 10481
diff changeset
   301
    ^ ((flags ? 0) bitTest: FLAG_VIRTUAL).
79c64bcd4d29 +ole queries
fm
parents: 10481
diff changeset
   302
79c64bcd4d29 +ole queries
fm
parents: 10481
diff changeset
   303
    "Created: / 01-08-2006 / 15:21:23 / cg"
79c64bcd4d29 +ole queries
fm
parents: 10481
diff changeset
   304
!
79c64bcd4d29 +ole queries
fm
parents: 10481
diff changeset
   305
9525
120234adc94e const specifier (is this a good name ?)
ca
parents: 9524
diff changeset
   306
isConstReturnValue
10025
053904a63549 stc-compiled ExternalLibraryFunctions
Claus Gittinger <cg@exept.de>
parents: 9981
diff changeset
   307
    "is the pointer return value not to be finalized
9525
120234adc94e const specifier (is this a good name ?)
ca
parents: 9524
diff changeset
   308
     (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
   309
120234adc94e const specifier (is this a good name ?)
ca
parents: 9524
diff changeset
   310
    ^ (flags ? 0) bitTest: FLAG_RETVAL_IS_CONST.
120234adc94e const specifier (is this a good name ?)
ca
parents: 9524
diff changeset
   311
120234adc94e const specifier (is this a good name ?)
ca
parents: 9524
diff changeset
   312
    "Created: / 01-08-2006 / 13:56:48 / cg"
120234adc94e const specifier (is this a good name ?)
ca
parents: 9524
diff changeset
   313
!
120234adc94e const specifier (is this a good name ?)
ca
parents: 9524
diff changeset
   314
9463
864880338d7e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9460
diff changeset
   315
isNonVirtualCPP
864880338d7e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9460
diff changeset
   316
    "is this a non-virtual c++-function ?"
864880338d7e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9460
diff changeset
   317
864880338d7e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9460
diff changeset
   318
    ^ (flags ? 0) bitTest: FLAG_NONVIRTUAL.
864880338d7e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9460
diff changeset
   319
864880338d7e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9460
diff changeset
   320
    "Created: / 01-08-2006 / 13:56:51 / cg"
864880338d7e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9460
diff changeset
   321
!
864880338d7e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9460
diff changeset
   322
864880338d7e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9460
diff changeset
   323
isUnlimitedStack
864880338d7e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9460
diff changeset
   324
    "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
   325
     for unlimited auto-sized-stack under unix/linux.
864880338d7e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9460
diff changeset
   326
     Ignored under windows."
864880338d7e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9460
diff changeset
   327
864880338d7e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9460
diff changeset
   328
    ^ (flags ? 0) bitTest: FLAG_UNLIMITEDSTACK.
864880338d7e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9460
diff changeset
   329
864880338d7e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9460
diff changeset
   330
    "Created: / 01-08-2006 / 14:17:07 / cg"
864880338d7e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9460
diff changeset
   331
!
864880338d7e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9460
diff changeset
   332
864880338d7e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9460
diff changeset
   333
isVirtualCPP
864880338d7e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9460
diff changeset
   334
    "is this a virtual c++-function ?"
864880338d7e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9460
diff changeset
   335
864880338d7e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9460
diff changeset
   336
    ^ (flags ? 0) bitTest: FLAG_VIRTUAL.
864880338d7e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9460
diff changeset
   337
864880338d7e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9460
diff changeset
   338
    "Created: / 01-08-2006 / 13:56:54 / cg"
10483
79c64bcd4d29 +ole queries
fm
parents: 10481
diff changeset
   339
!
79c64bcd4d29 +ole queries
fm
parents: 10481
diff changeset
   340
10484
29039d89239d + returnType
fm
parents: 10483
diff changeset
   341
returnType
29039d89239d + returnType
fm
parents: 10483
diff changeset
   342
    ^ returnType
29039d89239d + returnType
fm
parents: 10483
diff changeset
   343
!
29039d89239d + returnType
fm
parents: 10483
diff changeset
   344
10483
79c64bcd4d29 +ole queries
fm
parents: 10481
diff changeset
   345
vtableIndex
79c64bcd4d29 +ole queries
fm
parents: 10481
diff changeset
   346
    name isNumber ifFalse:[^ nil].
79c64bcd4d29 +ole queries
fm
parents: 10481
diff changeset
   347
    ^ name.
9321
734c7c432461 not yet finished
Claus Gittinger <cg@exept.de>
parents: 8891
diff changeset
   348
! !
734c7c432461 not yet finished
Claus Gittinger <cg@exept.de>
parents: 8891
diff changeset
   349
8891
c30a030ff5ec more FFI (foreign function interface) support - still incomplete
Stefan Vogel <sv@exept.de>
parents: 8728
diff changeset
   350
!ExternalLibraryFunction methodsFor:'invoking'!
c30a030ff5ec more FFI (foreign function interface) support - still incomplete
Stefan Vogel <sv@exept.de>
parents: 8728
diff changeset
   351
c30a030ff5ec more FFI (foreign function interface) support - still incomplete
Stefan Vogel <sv@exept.de>
parents: 8728
diff changeset
   352
invoke
9321
734c7c432461 not yet finished
Claus Gittinger <cg@exept.de>
parents: 8891
diff changeset
   353
    self hasCode ifFalse:[
10440
b643af58f8bf invoking without arguments
fm
parents: 10279
diff changeset
   354
        self prepareInvoke.
8891
c30a030ff5ec more FFI (foreign function interface) support - still incomplete
Stefan Vogel <sv@exept.de>
parents: 8728
diff changeset
   355
    ].
10440
b643af58f8bf invoking without arguments
fm
parents: 10279
diff changeset
   356
    ^ self invokeFFIWithArguments:nil
8891
c30a030ff5ec more FFI (foreign function interface) support - still incomplete
Stefan Vogel <sv@exept.de>
parents: 8728
diff changeset
   357
!
c30a030ff5ec more FFI (foreign function interface) support - still incomplete
Stefan Vogel <sv@exept.de>
parents: 8728
diff changeset
   358
9347
31adc57e6954 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9346
diff changeset
   359
invokeCPPVirtualOn:anInstance
9341
719fcf48695b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9340
diff changeset
   360
    self hasCode ifFalse:[
10440
b643af58f8bf invoking without arguments
fm
parents: 10279
diff changeset
   361
        self prepareInvoke.
9341
719fcf48695b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9340
diff changeset
   362
    ].
10440
b643af58f8bf invoking without arguments
fm
parents: 10279
diff changeset
   363
    ^ self invokeCPPVirtualFFIOn:anInstance withArguments:nil
9341
719fcf48695b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9340
diff changeset
   364
!
719fcf48695b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9340
diff changeset
   365
9347
31adc57e6954 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9346
diff changeset
   366
invokeCPPVirtualOn:instance with:arg
9341
719fcf48695b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9340
diff changeset
   367
    self hasCode ifFalse:[
10025
053904a63549 stc-compiled ExternalLibraryFunctions
Claus Gittinger <cg@exept.de>
parents: 9981
diff changeset
   368
	self prepareInvoke.
9341
719fcf48695b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9340
diff changeset
   369
    ].
9347
31adc57e6954 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9346
diff changeset
   370
    ^ self invokeCPPVirtualFFIOn:instance withArguments:(Array with:arg)
9341
719fcf48695b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9340
diff changeset
   371
!
719fcf48695b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9340
diff changeset
   372
9347
31adc57e6954 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9346
diff changeset
   373
invokeCPPVirtualOn:instance with:arg1 with:arg2
9341
719fcf48695b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9340
diff changeset
   374
    self hasCode ifFalse:[
10025
053904a63549 stc-compiled ExternalLibraryFunctions
Claus Gittinger <cg@exept.de>
parents: 9981
diff changeset
   375
	self prepareInvoke.
9341
719fcf48695b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9340
diff changeset
   376
    ].
9347
31adc57e6954 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9346
diff changeset
   377
    ^ self invokeCPPVirtualFFIOn:instance withArguments:(Array with:arg1 with:arg2)
9341
719fcf48695b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9340
diff changeset
   378
!
719fcf48695b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9340
diff changeset
   379
9347
31adc57e6954 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9346
diff changeset
   380
invokeCPPVirtualOn:instance with:arg1 with:arg2 with:arg3
9341
719fcf48695b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9340
diff changeset
   381
    self hasCode ifFalse:[
10025
053904a63549 stc-compiled ExternalLibraryFunctions
Claus Gittinger <cg@exept.de>
parents: 9981
diff changeset
   382
	self prepareInvoke.
9341
719fcf48695b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9340
diff changeset
   383
    ].
9347
31adc57e6954 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9346
diff changeset
   384
    ^ 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
   385
!
719fcf48695b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9340
diff changeset
   386
9347
31adc57e6954 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9346
diff changeset
   387
invokeCPPVirtualOn:instance with:arg1 with:arg2 with:arg3 with:arg4
9341
719fcf48695b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9340
diff changeset
   388
    self hasCode ifFalse:[
10025
053904a63549 stc-compiled ExternalLibraryFunctions
Claus Gittinger <cg@exept.de>
parents: 9981
diff changeset
   389
	self prepareInvoke.
9341
719fcf48695b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9340
diff changeset
   390
    ].
9347
31adc57e6954 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9346
diff changeset
   391
    ^ 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
   392
!
719fcf48695b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9340
diff changeset
   393
10481
b3526180579f +isExternalLibraryFunction
fm
parents: 10440
diff changeset
   394
invokeCPPVirtualOn:instance withArguments:args
b3526180579f +isExternalLibraryFunction
fm
parents: 10440
diff changeset
   395
    self hasCode ifFalse:[
b3526180579f +isExternalLibraryFunction
fm
parents: 10440
diff changeset
   396
        self prepareInvoke.
b3526180579f +isExternalLibraryFunction
fm
parents: 10440
diff changeset
   397
    ].
b3526180579f +isExternalLibraryFunction
fm
parents: 10440
diff changeset
   398
    ^ self invokeCPPVirtualFFIOn:instance withArguments:args
b3526180579f +isExternalLibraryFunction
fm
parents: 10440
diff changeset
   399
!
b3526180579f +isExternalLibraryFunction
fm
parents: 10440
diff changeset
   400
8891
c30a030ff5ec more FFI (foreign function interface) support - still incomplete
Stefan Vogel <sv@exept.de>
parents: 8728
diff changeset
   401
invokeWith:arg
9321
734c7c432461 not yet finished
Claus Gittinger <cg@exept.de>
parents: 8891
diff changeset
   402
    self hasCode ifFalse:[
9464
157fe6ca53e6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9463
diff changeset
   403
	self prepareInvoke.
9321
734c7c432461 not yet finished
Claus Gittinger <cg@exept.de>
parents: 8891
diff changeset
   404
    ].
734c7c432461 not yet finished
Claus Gittinger <cg@exept.de>
parents: 8891
diff changeset
   405
    ^ self invokeFFIWithArguments:(Array with:arg)
734c7c432461 not yet finished
Claus Gittinger <cg@exept.de>
parents: 8891
diff changeset
   406
!
8891
c30a030ff5ec more FFI (foreign function interface) support - still incomplete
Stefan Vogel <sv@exept.de>
parents: 8728
diff changeset
   407
9321
734c7c432461 not yet finished
Claus Gittinger <cg@exept.de>
parents: 8891
diff changeset
   408
invokeWith:arg1 with:arg2
734c7c432461 not yet finished
Claus Gittinger <cg@exept.de>
parents: 8891
diff changeset
   409
    self hasCode ifFalse:[
9464
157fe6ca53e6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9463
diff changeset
   410
	self prepareInvoke.
8891
c30a030ff5ec more FFI (foreign function interface) support - still incomplete
Stefan Vogel <sv@exept.de>
parents: 8728
diff changeset
   411
    ].
9321
734c7c432461 not yet finished
Claus Gittinger <cg@exept.de>
parents: 8891
diff changeset
   412
    ^ self invokeFFIWithArguments:(Array with:arg1 with:arg2)
734c7c432461 not yet finished
Claus Gittinger <cg@exept.de>
parents: 8891
diff changeset
   413
!
734c7c432461 not yet finished
Claus Gittinger <cg@exept.de>
parents: 8891
diff changeset
   414
734c7c432461 not yet finished
Claus Gittinger <cg@exept.de>
parents: 8891
diff changeset
   415
invokeWith:arg1 with:arg2 with:arg3
734c7c432461 not yet finished
Claus Gittinger <cg@exept.de>
parents: 8891
diff changeset
   416
    self hasCode ifFalse:[
9464
157fe6ca53e6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9463
diff changeset
   417
	self prepareInvoke.
9321
734c7c432461 not yet finished
Claus Gittinger <cg@exept.de>
parents: 8891
diff changeset
   418
    ].
734c7c432461 not yet finished
Claus Gittinger <cg@exept.de>
parents: 8891
diff changeset
   419
    ^ self invokeFFIWithArguments:(Array with:arg1 with:arg2 with:arg3)
734c7c432461 not yet finished
Claus Gittinger <cg@exept.de>
parents: 8891
diff changeset
   420
!
8891
c30a030ff5ec more FFI (foreign function interface) support - still incomplete
Stefan Vogel <sv@exept.de>
parents: 8728
diff changeset
   421
9321
734c7c432461 not yet finished
Claus Gittinger <cg@exept.de>
parents: 8891
diff changeset
   422
invokeWith:arg1 with:arg2 with:arg3 with:arg4
734c7c432461 not yet finished
Claus Gittinger <cg@exept.de>
parents: 8891
diff changeset
   423
    self hasCode ifFalse:[
9464
157fe6ca53e6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9463
diff changeset
   424
	self prepareInvoke.
9321
734c7c432461 not yet finished
Claus Gittinger <cg@exept.de>
parents: 8891
diff changeset
   425
    ].
734c7c432461 not yet finished
Claus Gittinger <cg@exept.de>
parents: 8891
diff changeset
   426
    ^ self invokeFFIWithArguments:(Array with:arg1 with:arg2 with:arg3 with:arg4)
734c7c432461 not yet finished
Claus Gittinger <cg@exept.de>
parents: 8891
diff changeset
   427
!
8891
c30a030ff5ec more FFI (foreign function interface) support - still incomplete
Stefan Vogel <sv@exept.de>
parents: 8728
diff changeset
   428
9321
734c7c432461 not yet finished
Claus Gittinger <cg@exept.de>
parents: 8891
diff changeset
   429
invokeWithArguments:argArray
734c7c432461 not yet finished
Claus Gittinger <cg@exept.de>
parents: 8891
diff changeset
   430
    self hasCode ifFalse:[
10025
053904a63549 stc-compiled ExternalLibraryFunctions
Claus Gittinger <cg@exept.de>
parents: 9981
diff changeset
   431
	self prepareInvoke.
9321
734c7c432461 not yet finished
Claus Gittinger <cg@exept.de>
parents: 8891
diff changeset
   432
    ].
9465
d11885052713 rewrite & cleanup
Claus Gittinger <cg@exept.de>
parents: 9464
diff changeset
   433
    ^ self invokeFFIwithArguments:argArray forCPPInstance:nil
d11885052713 rewrite & cleanup
Claus Gittinger <cg@exept.de>
parents: 9464
diff changeset
   434
d11885052713 rewrite & cleanup
Claus Gittinger <cg@exept.de>
parents: 9464
diff changeset
   435
    "Modified: / 01-08-2006 / 16:04:08 / cg"
9321
734c7c432461 not yet finished
Claus Gittinger <cg@exept.de>
parents: 8891
diff changeset
   436
! !
734c7c432461 not yet finished
Claus Gittinger <cg@exept.de>
parents: 8891
diff changeset
   437
734c7c432461 not yet finished
Claus Gittinger <cg@exept.de>
parents: 8891
diff changeset
   438
!ExternalLibraryFunction methodsFor:'printing'!
734c7c432461 not yet finished
Claus Gittinger <cg@exept.de>
parents: 8891
diff changeset
   439
734c7c432461 not yet finished
Claus Gittinger <cg@exept.de>
parents: 8891
diff changeset
   440
printOn:aStream
734c7c432461 not yet finished
Claus Gittinger <cg@exept.de>
parents: 8891
diff changeset
   441
    aStream nextPutAll:'<'.
9465
d11885052713 rewrite & cleanup
Claus Gittinger <cg@exept.de>
parents: 9464
diff changeset
   442
    self isCallTypeAPI ifTrue:[
10025
053904a63549 stc-compiled ExternalLibraryFunctions
Claus Gittinger <cg@exept.de>
parents: 9981
diff changeset
   443
	'API:' printOn:aStream.
9465
d11885052713 rewrite & cleanup
Claus Gittinger <cg@exept.de>
parents: 9464
diff changeset
   444
    ] ifFalse:[
10025
053904a63549 stc-compiled ExternalLibraryFunctions
Claus Gittinger <cg@exept.de>
parents: 9981
diff changeset
   445
	'C:' printOn:aStream.
9465
d11885052713 rewrite & cleanup
Claus Gittinger <cg@exept.de>
parents: 9464
diff changeset
   446
    ].
9321
734c7c432461 not yet finished
Claus Gittinger <cg@exept.de>
parents: 8891
diff changeset
   447
    aStream nextPutAll:' '.
734c7c432461 not yet finished
Claus Gittinger <cg@exept.de>
parents: 8891
diff changeset
   448
    name printOn:aStream.
9465
d11885052713 rewrite & cleanup
Claus Gittinger <cg@exept.de>
parents: 9464
diff changeset
   449
    moduleName notNil ifTrue:[
10025
053904a63549 stc-compiled ExternalLibraryFunctions
Claus Gittinger <cg@exept.de>
parents: 9981
diff changeset
   450
	aStream nextPutAll:' module:'.
053904a63549 stc-compiled ExternalLibraryFunctions
Claus Gittinger <cg@exept.de>
parents: 9981
diff changeset
   451
	moduleName printOn:aStream.
9465
d11885052713 rewrite & cleanup
Claus Gittinger <cg@exept.de>
parents: 9464
diff changeset
   452
    ].
9321
734c7c432461 not yet finished
Claus Gittinger <cg@exept.de>
parents: 8891
diff changeset
   453
    aStream nextPutAll:'>'.
9465
d11885052713 rewrite & cleanup
Claus Gittinger <cg@exept.de>
parents: 9464
diff changeset
   454
d11885052713 rewrite & cleanup
Claus Gittinger <cg@exept.de>
parents: 9464
diff changeset
   455
    "Modified: / 01-08-2006 / 15:21:42 / cg"
8891
c30a030ff5ec more FFI (foreign function interface) support - still incomplete
Stefan Vogel <sv@exept.de>
parents: 8728
diff changeset
   456
! !
c30a030ff5ec more FFI (foreign function interface) support - still incomplete
Stefan Vogel <sv@exept.de>
parents: 8728
diff changeset
   457
c30a030ff5ec more FFI (foreign function interface) support - still incomplete
Stefan Vogel <sv@exept.de>
parents: 8728
diff changeset
   458
!ExternalLibraryFunction methodsFor:'private'!
c30a030ff5ec more FFI (foreign function interface) support - still incomplete
Stefan Vogel <sv@exept.de>
parents: 8728
diff changeset
   459
10213
31717eee6fb2 changed #ffiTypeSymbolForType:
fm
parents: 10025
diff changeset
   460
adjustTypes
31717eee6fb2 changed #ffiTypeSymbolForType:
fm
parents: 10025
diff changeset
   461
    argumentTypes notNil ifTrue:[
31717eee6fb2 changed #ffiTypeSymbolForType:
fm
parents: 10025
diff changeset
   462
	argumentTypes := argumentTypes collect:[:argType | self ffiTypeSymbolForType:argType].
31717eee6fb2 changed #ffiTypeSymbolForType:
fm
parents: 10025
diff changeset
   463
    ].
31717eee6fb2 changed #ffiTypeSymbolForType:
fm
parents: 10025
diff changeset
   464
    returnType := self ffiTypeSymbolForType:returnType.
31717eee6fb2 changed #ffiTypeSymbolForType:
fm
parents: 10025
diff changeset
   465
!
31717eee6fb2 changed #ffiTypeSymbolForType:
fm
parents: 10025
diff changeset
   466
8891
c30a030ff5ec more FFI (foreign function interface) support - still incomplete
Stefan Vogel <sv@exept.de>
parents: 8728
diff changeset
   467
linkToModule
c30a030ff5ec more FFI (foreign function interface) support - still incomplete
Stefan Vogel <sv@exept.de>
parents: 8728
diff changeset
   468
    "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
   469
     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
   470
9465
d11885052713 rewrite & cleanup
Claus Gittinger <cg@exept.de>
parents: 9464
diff changeset
   471
    |handle moduleNameUsed functionName|
8891
c30a030ff5ec more FFI (foreign function interface) support - still incomplete
Stefan Vogel <sv@exept.de>
parents: 8728
diff changeset
   472
10481
b3526180579f +isExternalLibraryFunction
fm
parents: 10440
diff changeset
   473
    name isNumber ifTrue:[
b3526180579f +isExternalLibraryFunction
fm
parents: 10440
diff changeset
   474
        self isCPPFunction ifTrue:[
b3526180579f +isExternalLibraryFunction
fm
parents: 10440
diff changeset
   475
            "/ no need to load a dll.   
b3526180579f +isExternalLibraryFunction
fm
parents: 10440
diff changeset
   476
            ^ self
b3526180579f +isExternalLibraryFunction
fm
parents: 10440
diff changeset
   477
        ]
b3526180579f +isExternalLibraryFunction
fm
parents: 10440
diff changeset
   478
    ].
b3526180579f +isExternalLibraryFunction
fm
parents: 10440
diff changeset
   479
9465
d11885052713 rewrite & cleanup
Claus Gittinger <cg@exept.de>
parents: 9464
diff changeset
   480
    (moduleNameUsed := moduleName) isNil ifTrue:[
10270
897474c6c785 allow setting the dllPath
fm
parents: 10213
diff changeset
   481
        owningClass isNil ifTrue:[
897474c6c785 allow setting the dllPath
fm
parents: 10213
diff changeset
   482
            self error:'Missing moduleName'.
10481
b3526180579f +isExternalLibraryFunction
fm
parents: 10440
diff changeset
   483
        ].   
10270
897474c6c785 allow setting the dllPath
fm
parents: 10213
diff changeset
   484
        moduleNameUsed := owningClass theNonMetaclass libraryName asSymbol.
9321
734c7c432461 not yet finished
Claus Gittinger <cg@exept.de>
parents: 8891
diff changeset
   485
    ].
10270
897474c6c785 allow setting the dllPath
fm
parents: 10213
diff changeset
   486
    moduleHandle isNil ifTrue:[ 
897474c6c785 allow setting the dllPath
fm
parents: 10213
diff changeset
   487
        handle := self loadLibrary:moduleNameUsed.
897474c6c785 allow setting the dllPath
fm
parents: 10213
diff changeset
   488
        handle isNil ifTrue:[
897474c6c785 allow setting the dllPath
fm
parents: 10213
diff changeset
   489
            self error:'Cannot load module: ', moduleNameUsed.
897474c6c785 allow setting the dllPath
fm
parents: 10213
diff changeset
   490
        ].
897474c6c785 allow setting the dllPath
fm
parents: 10213
diff changeset
   491
        moduleHandle := handle.
8891
c30a030ff5ec more FFI (foreign function interface) support - still incomplete
Stefan Vogel <sv@exept.de>
parents: 8728
diff changeset
   492
    ].
9341
719fcf48695b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9340
diff changeset
   493
    name isNumber ifFalse:[
10270
897474c6c785 allow setting the dllPath
fm
parents: 10213
diff changeset
   494
        functionName := name.
897474c6c785 allow setting the dllPath
fm
parents: 10213
diff changeset
   495
        (moduleHandle getFunctionAddress:functionName into:self) isNil ifTrue:[
897474c6c785 allow setting the dllPath
fm
parents: 10213
diff changeset
   496
            functionName := ('_', functionName) asSymbol.
9418
df5d2576402d resolve function - if function with name not exists add an underscore in front and retry
ca
parents: 9399
diff changeset
   497
10270
897474c6c785 allow setting the dllPath
fm
parents: 10213
diff changeset
   498
            (moduleHandle getFunctionAddress:functionName into:self) isNil ifTrue:[
897474c6c785 allow setting the dllPath
fm
parents: 10213
diff changeset
   499
                moduleHandle := nil.
897474c6c785 allow setting the dllPath
fm
parents: 10213
diff changeset
   500
                self error:'Missing function: ', name, ' in module: ', moduleNameUsed.
897474c6c785 allow setting the dllPath
fm
parents: 10213
diff changeset
   501
            ].
897474c6c785 allow setting the dllPath
fm
parents: 10213
diff changeset
   502
        ].
9321
734c7c432461 not yet finished
Claus Gittinger <cg@exept.de>
parents: 8891
diff changeset
   503
    ].
9392
11914531960a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9386
diff changeset
   504
9465
d11885052713 rewrite & cleanup
Claus Gittinger <cg@exept.de>
parents: 9464
diff changeset
   505
    "Modified: / 01-08-2006 / 16:24:14 / cg"
9321
734c7c432461 not yet finished
Claus Gittinger <cg@exept.de>
parents: 8891
diff changeset
   506
!
734c7c432461 not yet finished
Claus Gittinger <cg@exept.de>
parents: 8891
diff changeset
   507
10270
897474c6c785 allow setting the dllPath
fm
parents: 10213
diff changeset
   508
loadLibrary:dllName
10279
60c42983fdd4 first test whether the dllName is the complete filename
ca
parents: 10270
diff changeset
   509
    |handle filename|
60c42983fdd4 first test whether the dllName is the complete filename
ca
parents: 10270
diff changeset
   510
60c42983fdd4 first test whether the dllName is the complete filename
ca
parents: 10270
diff changeset
   511
    filename := dllName asFilename.
60c42983fdd4 first test whether the dllName is the complete filename
ca
parents: 10270
diff changeset
   512
60c42983fdd4 first test whether the dllName is the complete filename
ca
parents: 10270
diff changeset
   513
    filename exists ifTrue:[
60c42983fdd4 first test whether the dllName is the complete filename
ca
parents: 10270
diff changeset
   514
        handle := ObjectFileLoader
60c42983fdd4 first test whether the dllName is the complete filename
ca
parents: 10270
diff changeset
   515
                    loadDynamicObject:(filename pathName).
60c42983fdd4 first test whether the dllName is the complete filename
ca
parents: 10270
diff changeset
   516
        handle notNil ifTrue:[^ handle ].
60c42983fdd4 first test whether the dllName is the complete filename
ca
parents: 10270
diff changeset
   517
    ].
10270
897474c6c785 allow setting the dllPath
fm
parents: 10213
diff changeset
   518
897474c6c785 allow setting the dllPath
fm
parents: 10213
diff changeset
   519
    self class dllPath do:[:eachDirectory |
897474c6c785 allow setting the dllPath
fm
parents: 10213
diff changeset
   520
        handle := ObjectFileLoader
897474c6c785 allow setting the dllPath
fm
parents: 10213
diff changeset
   521
                    loadDynamicObject:(eachDirectory asFilename construct:dllName) pathName.
897474c6c785 allow setting the dllPath
fm
parents: 10213
diff changeset
   522
        handle notNil ifTrue:[^ handle ].
897474c6c785 allow setting the dllPath
fm
parents: 10213
diff changeset
   523
    ].
897474c6c785 allow setting the dllPath
fm
parents: 10213
diff changeset
   524
    ^ nil
897474c6c785 allow setting the dllPath
fm
parents: 10213
diff changeset
   525
!
897474c6c785 allow setting the dllPath
fm
parents: 10213
diff changeset
   526
9321
734c7c432461 not yet finished
Claus Gittinger <cg@exept.de>
parents: 8891
diff changeset
   527
prepareInvoke
10270
897474c6c785 allow setting the dllPath
fm
parents: 10213
diff changeset
   528
    (moduleHandle isNil or:[self hasCode not]) ifTrue:[
897474c6c785 allow setting the dllPath
fm
parents: 10213
diff changeset
   529
        self linkToModule.
897474c6c785 allow setting the dllPath
fm
parents: 10213
diff changeset
   530
        self adjustTypes.
8891
c30a030ff5ec more FFI (foreign function interface) support - still incomplete
Stefan Vogel <sv@exept.de>
parents: 8728
diff changeset
   531
    ].
c30a030ff5ec more FFI (foreign function interface) support - still incomplete
Stefan Vogel <sv@exept.de>
parents: 8728
diff changeset
   532
! !
c30a030ff5ec more FFI (foreign function interface) support - still incomplete
Stefan Vogel <sv@exept.de>
parents: 8728
diff changeset
   533
8550
72982f85bd41 *** empty log message ***
ca
parents: 8533
diff changeset
   534
!ExternalLibraryFunction methodsFor:'private-accessing'!
72982f85bd41 *** empty log message ***
ca
parents: 8533
diff changeset
   535
9327
9c15276d61e3 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9324
diff changeset
   536
ffiTypeSymbolForType:aType
10025
053904a63549 stc-compiled ExternalLibraryFunctions
Claus Gittinger <cg@exept.de>
parents: 9981
diff changeset
   537
    "map type to one of the ffi-supported ones:
10213
31717eee6fb2 changed #ffiTypeSymbolForType:
fm
parents: 10025
diff changeset
   538
        sint8, sint16, sint32, sint64
31717eee6fb2 changed #ffiTypeSymbolForType:
fm
parents: 10025
diff changeset
   539
        uint8, uint16, uint32, uint64
31717eee6fb2 changed #ffiTypeSymbolForType:
fm
parents: 10025
diff changeset
   540
        bool void handle
10025
053904a63549 stc-compiled ExternalLibraryFunctions
Claus Gittinger <cg@exept.de>
parents: 9981
diff changeset
   541
    "
053904a63549 stc-compiled ExternalLibraryFunctions
Claus Gittinger <cg@exept.de>
parents: 9981
diff changeset
   542
9340
df61c7e20801 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9339
diff changeset
   543
    |t|
9322
41c391bfbf03 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9321
diff changeset
   544
10025
053904a63549 stc-compiled ExternalLibraryFunctions
Claus Gittinger <cg@exept.de>
parents: 9981
diff changeset
   545
    aType == #sint8           ifTrue:[^ aType ].
053904a63549 stc-compiled ExternalLibraryFunctions
Claus Gittinger <cg@exept.de>
parents: 9981
diff changeset
   546
    aType == #sint16          ifTrue:[^ aType ].
053904a63549 stc-compiled ExternalLibraryFunctions
Claus Gittinger <cg@exept.de>
parents: 9981
diff changeset
   547
    aType == #sint32          ifTrue:[^ aType ].
053904a63549 stc-compiled ExternalLibraryFunctions
Claus Gittinger <cg@exept.de>
parents: 9981
diff changeset
   548
    aType == #sint64          ifTrue:[^ aType ].
053904a63549 stc-compiled ExternalLibraryFunctions
Claus Gittinger <cg@exept.de>
parents: 9981
diff changeset
   549
    aType == #uint8           ifTrue:[^ aType ].
053904a63549 stc-compiled ExternalLibraryFunctions
Claus Gittinger <cg@exept.de>
parents: 9981
diff changeset
   550
    aType == #uint16          ifTrue:[^ aType ].
053904a63549 stc-compiled ExternalLibraryFunctions
Claus Gittinger <cg@exept.de>
parents: 9981
diff changeset
   551
    aType == #uint32          ifTrue:[^ aType ].
053904a63549 stc-compiled ExternalLibraryFunctions
Claus Gittinger <cg@exept.de>
parents: 9981
diff changeset
   552
    aType == #uint64          ifTrue:[^ aType ].
053904a63549 stc-compiled ExternalLibraryFunctions
Claus Gittinger <cg@exept.de>
parents: 9981
diff changeset
   553
    aType == #double          ifTrue:[^ aType ].
053904a63549 stc-compiled ExternalLibraryFunctions
Claus Gittinger <cg@exept.de>
parents: 9981
diff changeset
   554
    aType == #float           ifTrue:[^ aType ].
053904a63549 stc-compiled ExternalLibraryFunctions
Claus Gittinger <cg@exept.de>
parents: 9981
diff changeset
   555
    aType == #char            ifTrue:[^ aType ].
053904a63549 stc-compiled ExternalLibraryFunctions
Claus Gittinger <cg@exept.de>
parents: 9981
diff changeset
   556
    aType == #void            ifTrue:[^ aType ].
053904a63549 stc-compiled ExternalLibraryFunctions
Claus Gittinger <cg@exept.de>
parents: 9981
diff changeset
   557
    aType == #bool            ifTrue:[^ aType ].
053904a63549 stc-compiled ExternalLibraryFunctions
Claus Gittinger <cg@exept.de>
parents: 9981
diff changeset
   558
    aType == #pointer         ifTrue:[^ aType ].
053904a63549 stc-compiled ExternalLibraryFunctions
Claus Gittinger <cg@exept.de>
parents: 9981
diff changeset
   559
053904a63549 stc-compiled ExternalLibraryFunctions
Claus Gittinger <cg@exept.de>
parents: 9981
diff changeset
   560
    aType == #int8            ifTrue:[^ #sint8 ].
053904a63549 stc-compiled ExternalLibraryFunctions
Claus Gittinger <cg@exept.de>
parents: 9981
diff changeset
   561
    aType == #int16           ifTrue:[^ #sint16 ].
053904a63549 stc-compiled ExternalLibraryFunctions
Claus Gittinger <cg@exept.de>
parents: 9981
diff changeset
   562
    aType == #int32           ifTrue:[^ #sint32 ].
053904a63549 stc-compiled ExternalLibraryFunctions
Claus Gittinger <cg@exept.de>
parents: 9981
diff changeset
   563
    aType == #int64           ifTrue:[^ #sint64 ].
053904a63549 stc-compiled ExternalLibraryFunctions
Claus Gittinger <cg@exept.de>
parents: 9981
diff changeset
   564
    aType == #voidPointer     ifTrue:[^ #pointer ].
10625
892203aae858 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10619
diff changeset
   565
    aType == #uint8Pointer    ifTrue:[^ #pointer ].
10025
053904a63549 stc-compiled ExternalLibraryFunctions
Claus Gittinger <cg@exept.de>
parents: 9981
diff changeset
   566
10213
31717eee6fb2 changed #ffiTypeSymbolForType:
fm
parents: 10025
diff changeset
   567
    aType == #short           ifTrue:[^ #sint16 ].
31717eee6fb2 changed #ffiTypeSymbolForType:
fm
parents: 10025
diff changeset
   568
    aType == #long            ifTrue:[^ #long ].      
31717eee6fb2 changed #ffiTypeSymbolForType:
fm
parents: 10025
diff changeset
   569
    aType == #int             ifTrue:[^ #int ].       
10025
053904a63549 stc-compiled ExternalLibraryFunctions
Claus Gittinger <cg@exept.de>
parents: 9981
diff changeset
   570
    aType == #ushort          ifTrue:[^ #uint16 ].
053904a63549 stc-compiled ExternalLibraryFunctions
Claus Gittinger <cg@exept.de>
parents: 9981
diff changeset
   571
    aType == #unsignedShort   ifTrue:[^ #uint16 ].
10213
31717eee6fb2 changed #ffiTypeSymbolForType:
fm
parents: 10025
diff changeset
   572
    aType == #ulong           ifTrue:[^ #ulong ].    
31717eee6fb2 changed #ffiTypeSymbolForType:
fm
parents: 10025
diff changeset
   573
    aType == #unsignedLong    ifTrue:[^ #ulong ].   
10025
053904a63549 stc-compiled ExternalLibraryFunctions
Claus Gittinger <cg@exept.de>
parents: 9981
diff changeset
   574
    aType == #uchar           ifTrue:[^ #uint8 ].
053904a63549 stc-compiled ExternalLibraryFunctions
Claus Gittinger <cg@exept.de>
parents: 9981
diff changeset
   575
    aType == #unsignedChar    ifTrue:[^ #uint8 ].
053904a63549 stc-compiled ExternalLibraryFunctions
Claus Gittinger <cg@exept.de>
parents: 9981
diff changeset
   576
    aType == #byte            ifTrue:[^ #uint8 ].
053904a63549 stc-compiled ExternalLibraryFunctions
Claus Gittinger <cg@exept.de>
parents: 9981
diff changeset
   577
    aType == #dword           ifTrue:[^ #uint32 ].
10213
31717eee6fb2 changed #ffiTypeSymbolForType:
fm
parents: 10025
diff changeset
   578
    aType == #sdword          ifTrue:[^ #sint32 ].
10025
053904a63549 stc-compiled ExternalLibraryFunctions
Claus Gittinger <cg@exept.de>
parents: 9981
diff changeset
   579
    aType == #word            ifTrue:[^ #uint16 ].
10213
31717eee6fb2 changed #ffiTypeSymbolForType:
fm
parents: 10025
diff changeset
   580
    aType == #sword           ifTrue:[^ #sint16 ].
10025
053904a63549 stc-compiled ExternalLibraryFunctions
Claus Gittinger <cg@exept.de>
parents: 9981
diff changeset
   581
    aType == #handle          ifTrue:[^ #pointer ].
053904a63549 stc-compiled ExternalLibraryFunctions
Claus Gittinger <cg@exept.de>
parents: 9981
diff changeset
   582
    aType == #lpstr           ifTrue:[^ #charPointer ].
053904a63549 stc-compiled ExternalLibraryFunctions
Claus Gittinger <cg@exept.de>
parents: 9981
diff changeset
   583
    aType == #hresult         ifTrue:[^ #uint32 ].
053904a63549 stc-compiled ExternalLibraryFunctions
Claus Gittinger <cg@exept.de>
parents: 9981
diff changeset
   584
    aType == #boolean         ifTrue:[^ #bool ].
053904a63549 stc-compiled ExternalLibraryFunctions
Claus Gittinger <cg@exept.de>
parents: 9981
diff changeset
   585
    aType == #ulongReturn     ifTrue:[^ #uint32 ].    "/ TODO - care for 64bit machines
053904a63549 stc-compiled ExternalLibraryFunctions
Claus Gittinger <cg@exept.de>
parents: 9981
diff changeset
   586
    aType == #none            ifTrue:[^ #void ].
053904a63549 stc-compiled ExternalLibraryFunctions
Claus Gittinger <cg@exept.de>
parents: 9981
diff changeset
   587
    aType == #struct          ifTrue:[^ #pointer ].
053904a63549 stc-compiled ExternalLibraryFunctions
Claus Gittinger <cg@exept.de>
parents: 9981
diff changeset
   588
    aType == #structIn        ifTrue:[^ #pointer ].
053904a63549 stc-compiled ExternalLibraryFunctions
Claus Gittinger <cg@exept.de>
parents: 9981
diff changeset
   589
    aType == #structOut       ifTrue:[^ #pointer ].
10614
1950ab5c9214 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10603
diff changeset
   590
    aType == #uint8Pointer    ifTrue:[^ #pointer ].
10025
053904a63549 stc-compiled ExternalLibraryFunctions
Claus Gittinger <cg@exept.de>
parents: 9981
diff changeset
   591
053904a63549 stc-compiled ExternalLibraryFunctions
Claus Gittinger <cg@exept.de>
parents: 9981
diff changeset
   592
    (aType isString or:[aType isSymbol]) ifFalse:[
10213
31717eee6fb2 changed #ffiTypeSymbolForType:
fm
parents: 10025
diff changeset
   593
        CType isNil ifTrue:[
31717eee6fb2 changed #ffiTypeSymbolForType:
fm
parents: 10025
diff changeset
   594
            self error:'unknown type'.
31717eee6fb2 changed #ffiTypeSymbolForType:
fm
parents: 10025
diff changeset
   595
        ].
31717eee6fb2 changed #ffiTypeSymbolForType:
fm
parents: 10025
diff changeset
   596
        ^ aType typeSymbol.
9483
3bea515ce81e *** empty log message ***
fm
parents: 9479
diff changeset
   597
    ].
3bea515ce81e *** empty log message ***
fm
parents: 9479
diff changeset
   598
10025
053904a63549 stc-compiled ExternalLibraryFunctions
Claus Gittinger <cg@exept.de>
parents: 9981
diff changeset
   599
    ^ aType
10625
892203aae858 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10619
diff changeset
   600
892203aae858 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10619
diff changeset
   601
    "Modified: / 14-06-2007 / 17:21:42 / cg"
9322
41c391bfbf03 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9321
diff changeset
   602
!
41c391bfbf03 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9321
diff changeset
   603
9466
73333f358696 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9465
diff changeset
   604
name:functionNameOrVirtualIndex module:aModuleName returnType:aReturnType argumentTypes:argTypes
73333f358696 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9465
diff changeset
   605
    name := functionNameOrVirtualIndex.
73333f358696 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9465
diff changeset
   606
    functionNameOrVirtualIndex isNumber ifTrue:[
10025
053904a63549 stc-compiled ExternalLibraryFunctions
Claus Gittinger <cg@exept.de>
parents: 9981
diff changeset
   607
	self beVirtualCPP.
9466
73333f358696 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9465
diff changeset
   608
    ].
8891
c30a030ff5ec more FFI (foreign function interface) support - still incomplete
Stefan Vogel <sv@exept.de>
parents: 8728
diff changeset
   609
    moduleName := aModuleName.
c30a030ff5ec more FFI (foreign function interface) support - still incomplete
Stefan Vogel <sv@exept.de>
parents: 8728
diff changeset
   610
    returnType := aReturnType.
c30a030ff5ec more FFI (foreign function interface) support - still incomplete
Stefan Vogel <sv@exept.de>
parents: 8728
diff changeset
   611
    argumentTypes := argTypes.
9465
d11885052713 rewrite & cleanup
Claus Gittinger <cg@exept.de>
parents: 9464
diff changeset
   612
d11885052713 rewrite & cleanup
Claus Gittinger <cg@exept.de>
parents: 9464
diff changeset
   613
    "Created: / 01-08-2006 / 15:19:52 / cg"
9466
73333f358696 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9465
diff changeset
   614
    "Modified: / 02-08-2006 / 17:20:13 / cg"
9465
d11885052713 rewrite & cleanup
Claus Gittinger <cg@exept.de>
parents: 9464
diff changeset
   615
!
d11885052713 rewrite & cleanup
Claus Gittinger <cg@exept.de>
parents: 9464
diff changeset
   616
d11885052713 rewrite & cleanup
Claus Gittinger <cg@exept.de>
parents: 9464
diff changeset
   617
owningClass:aClass
d11885052713 rewrite & cleanup
Claus Gittinger <cg@exept.de>
parents: 9464
diff changeset
   618
    owningClass := aClass.
d11885052713 rewrite & cleanup
Claus Gittinger <cg@exept.de>
parents: 9464
diff changeset
   619
d11885052713 rewrite & cleanup
Claus Gittinger <cg@exept.de>
parents: 9464
diff changeset
   620
    "Created: / 01-08-2006 / 15:22:50 / cg"
10603
da9b7ed81caf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10514
diff changeset
   621
!
da9b7ed81caf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10514
diff changeset
   622
da9b7ed81caf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10514
diff changeset
   623
setModuleName:aModuleName 
da9b7ed81caf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10514
diff changeset
   624
    aModuleName ~= moduleName ifTrue:[
da9b7ed81caf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10514
diff changeset
   625
        self code:nil.
da9b7ed81caf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10514
diff changeset
   626
        moduleHandle := nil.
da9b7ed81caf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10514
diff changeset
   627
        moduleName := aModuleName.
da9b7ed81caf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10514
diff changeset
   628
    ].
da9b7ed81caf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10514
diff changeset
   629
da9b7ed81caf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10514
diff changeset
   630
    "Created: / 07-06-2007 / 10:20:17 / cg"
8550
72982f85bd41 *** empty log message ***
ca
parents: 8533
diff changeset
   631
! !
72982f85bd41 *** empty log message ***
ca
parents: 8533
diff changeset
   632
9342
e548ce80ab02 virtual calls
Claus Gittinger <cg@exept.de>
parents: 9341
diff changeset
   633
!ExternalLibraryFunction methodsFor:'private-invoking'!
e548ce80ab02 virtual calls
Claus Gittinger <cg@exept.de>
parents: 9341
diff changeset
   634
9347
31adc57e6954 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9346
diff changeset
   635
invokeCPPVirtualFFIOn:instance withArguments:arguments
9463
864880338d7e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9460
diff changeset
   636
    ^ self invokeFFIwithArguments:arguments forCPPInstance:instance
864880338d7e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9460
diff changeset
   637
864880338d7e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9460
diff changeset
   638
    "Modified: / 01-08-2006 / 13:55:30 / cg"
9342
e548ce80ab02 virtual calls
Claus Gittinger <cg@exept.de>
parents: 9341
diff changeset
   639
!
e548ce80ab02 virtual calls
Claus Gittinger <cg@exept.de>
parents: 9341
diff changeset
   640
9347
31adc57e6954 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9346
diff changeset
   641
invokeFFIWithArguments:arguments
9463
864880338d7e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9460
diff changeset
   642
    ^ self invokeFFIwithArguments:arguments forCPPInstance:nil
864880338d7e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9460
diff changeset
   643
864880338d7e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9460
diff changeset
   644
    "Modified: / 01-08-2006 / 13:55:35 / cg"
9347
31adc57e6954 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9346
diff changeset
   645
!
31adc57e6954 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9346
diff changeset
   646
10440
b643af58f8bf invoking without arguments
fm
parents: 10279
diff changeset
   647
invokeFFIwithArguments:argumentsOrNil forCPPInstance:aCPlusPlusObjectOrNil
10025
053904a63549 stc-compiled ExternalLibraryFunctions
Claus Gittinger <cg@exept.de>
parents: 9981
diff changeset
   648
    |argTypeSymbols returnTypeSymbol failureCode failureInfo returnValue stClass vtOffset
9524
2af286bbcac3 *** empty log message ***
ca
parents: 9519
diff changeset
   649
     virtual async unlimitedStack callTypeNumber returnValueClass argValueClass|
9342
e548ce80ab02 virtual calls
Claus Gittinger <cg@exept.de>
parents: 9341
diff changeset
   650
10025
053904a63549 stc-compiled ExternalLibraryFunctions
Claus Gittinger <cg@exept.de>
parents: 9981
diff changeset
   651
    argTypeSymbols := argumentTypes.
053904a63549 stc-compiled ExternalLibraryFunctions
Claus Gittinger <cg@exept.de>
parents: 9981
diff changeset
   652
    returnTypeSymbol := returnType.
9346
a95e2cf0e56f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9344
diff changeset
   653
10025
053904a63549 stc-compiled ExternalLibraryFunctions
Claus Gittinger <cg@exept.de>
parents: 9981
diff changeset
   654
    virtual := self isVirtualCPP.
9524
2af286bbcac3 *** empty log message ***
ca
parents: 9519
diff changeset
   655
    (virtual "or:[self isNonVirtualCPP]") ifTrue:[
10440
b643af58f8bf invoking without arguments
fm
parents: 10279
diff changeset
   656
        aCPlusPlusObjectOrNil isNil ifTrue:[
b643af58f8bf invoking without arguments
fm
parents: 10279
diff changeset
   657
            "/ must have a c++ object instance
b643af58f8bf invoking without arguments
fm
parents: 10279
diff changeset
   658
            self primitiveFailed.
b643af58f8bf invoking without arguments
fm
parents: 10279
diff changeset
   659
        ].
9463
864880338d7e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9460
diff changeset
   660
10440
b643af58f8bf invoking without arguments
fm
parents: 10279
diff changeset
   661
        "/ and it must be a kind of ExternalStructure !!
b643af58f8bf invoking without arguments
fm
parents: 10279
diff changeset
   662
        (aCPlusPlusObjectOrNil isKindOf:ExternalStructure) ifFalse:[
b643af58f8bf invoking without arguments
fm
parents: 10279
diff changeset
   663
            self primitiveFailed.
b643af58f8bf invoking without arguments
fm
parents: 10279
diff changeset
   664
        ].
b643af58f8bf invoking without arguments
fm
parents: 10279
diff changeset
   665
        virtual ifTrue:[
b643af58f8bf invoking without arguments
fm
parents: 10279
diff changeset
   666
            vtOffset := name.
b643af58f8bf invoking without arguments
fm
parents: 10279
diff changeset
   667
            (vtOffset between:0 and:10000) ifFalse:[
b643af58f8bf invoking without arguments
fm
parents: 10279
diff changeset
   668
                self primitiveFailed.
b643af58f8bf invoking without arguments
fm
parents: 10279
diff changeset
   669
            ]
b643af58f8bf invoking without arguments
fm
parents: 10279
diff changeset
   670
        ].
9463
864880338d7e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9460
diff changeset
   671
    ] ifFalse:[
10440
b643af58f8bf invoking without arguments
fm
parents: 10279
diff changeset
   672
        aCPlusPlusObjectOrNil notNil ifTrue:[
b643af58f8bf invoking without arguments
fm
parents: 10279
diff changeset
   673
            "/ must NOT have a c++ object instance
b643af58f8bf invoking without arguments
fm
parents: 10279
diff changeset
   674
            self primitiveFailed.
b643af58f8bf invoking without arguments
fm
parents: 10279
diff changeset
   675
        ].
9342
e548ce80ab02 virtual calls
Claus Gittinger <cg@exept.de>
parents: 9341
diff changeset
   676
    ].
9463
864880338d7e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9460
diff changeset
   677
    async := self isAsync.
864880338d7e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9460
diff changeset
   678
    unlimitedStack := self isUnlimitedStack.
9465
d11885052713 rewrite & cleanup
Claus Gittinger <cg@exept.de>
parents: 9464
diff changeset
   679
    callTypeNumber := self callTypeNumber.
10512
5a01829213ab *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10484
diff changeset
   680
    "/ Transcript show:name; show:' async:'; showCR:async.
9342
e548ce80ab02 virtual calls
Claus Gittinger <cg@exept.de>
parents: 9341
diff changeset
   681
9459
6cd520c582b3 change from unlimited to big stack, to allow for interrupts to be handled
ca
parents: 9436
diff changeset
   682
%{  /* STACK: 100000 */
10025
053904a63549 stc-compiled ExternalLibraryFunctions
Claus Gittinger <cg@exept.de>
parents: 9981
diff changeset
   683
#ifdef HAVE_FFI
9342
e548ce80ab02 virtual calls
Claus Gittinger <cg@exept.de>
parents: 9341
diff changeset
   684
    ffi_cif __cif;
e548ce80ab02 virtual calls
Claus Gittinger <cg@exept.de>
parents: 9341
diff changeset
   685
    ffi_type *__argTypesIncludingThis[MAX_ARGS+1];
e548ce80ab02 virtual calls
Claus Gittinger <cg@exept.de>
parents: 9341
diff changeset
   686
    ffi_type **__argTypes = __argTypesIncludingThis;
e548ce80ab02 virtual calls
Claus Gittinger <cg@exept.de>
parents: 9341
diff changeset
   687
    ffi_type *__returnType = NULL;
e548ce80ab02 virtual calls
Claus Gittinger <cg@exept.de>
parents: 9341
diff changeset
   688
    union u {
10440
b643af58f8bf invoking without arguments
fm
parents: 10279
diff changeset
   689
        int iVal;
b643af58f8bf invoking without arguments
fm
parents: 10279
diff changeset
   690
        float fVal;
b643af58f8bf invoking without arguments
fm
parents: 10279
diff changeset
   691
        double dVal;
b643af58f8bf invoking without arguments
fm
parents: 10279
diff changeset
   692
        void *pointerVal;
9342
e548ce80ab02 virtual calls
Claus Gittinger <cg@exept.de>
parents: 9341
diff changeset
   693
    };
e548ce80ab02 virtual calls
Claus Gittinger <cg@exept.de>
parents: 9341
diff changeset
   694
    union u __argValuesIncludingThis[MAX_ARGS+1];
e548ce80ab02 virtual calls
Claus Gittinger <cg@exept.de>
parents: 9341
diff changeset
   695
    union u *__argValues = __argValuesIncludingThis;
e548ce80ab02 virtual calls
Claus Gittinger <cg@exept.de>
parents: 9341
diff changeset
   696
    union u __returnValue;
e548ce80ab02 virtual calls
Claus Gittinger <cg@exept.de>
parents: 9341
diff changeset
   697
    void *__argValuePointersIncludingThis[MAX_ARGS+1];
e548ce80ab02 virtual calls
Claus Gittinger <cg@exept.de>
parents: 9341
diff changeset
   698
    void **__argValuePointers = __argValuePointersIncludingThis;
e548ce80ab02 virtual calls
Claus Gittinger <cg@exept.de>
parents: 9341
diff changeset
   699
    void *__returnValuePointer;
e548ce80ab02 virtual calls
Claus Gittinger <cg@exept.de>
parents: 9341
diff changeset
   700
    int __numArgs, __numArgsIncludingThis;
e548ce80ab02 virtual calls
Claus Gittinger <cg@exept.de>
parents: 9341
diff changeset
   701
    static int null = 0;
e548ce80ab02 virtual calls
Claus Gittinger <cg@exept.de>
parents: 9341
diff changeset
   702
    int i;
e548ce80ab02 virtual calls
Claus Gittinger <cg@exept.de>
parents: 9341
diff changeset
   703
    ffi_abi __callType = FFI_DEFAULT_ABI;
e548ce80ab02 virtual calls
Claus Gittinger <cg@exept.de>
parents: 9341
diff changeset
   704
    VOIDFUNC codeAddress = (VOIDFUNC)__INST(code_);
10440
b643af58f8bf invoking without arguments
fm
parents: 10279
diff changeset
   705
    int __numArgsWanted;
10603
da9b7ed81caf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10514
diff changeset
   706
#define __FAIL__(fcode) \
da9b7ed81caf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10514
diff changeset
   707
    { \
da9b7ed81caf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10514
diff changeset
   708
        failureCode = fcode; goto getOutOfHere; \
da9b7ed81caf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10514
diff changeset
   709
    }
9342
e548ce80ab02 virtual calls
Claus Gittinger <cg@exept.de>
parents: 9341
diff changeset
   710
10440
b643af58f8bf invoking without arguments
fm
parents: 10279
diff changeset
   711
    if (argumentsOrNil == nil) {
b643af58f8bf invoking without arguments
fm
parents: 10279
diff changeset
   712
        __numArgs = 0;
b643af58f8bf invoking without arguments
fm
parents: 10279
diff changeset
   713
    } else if (__isArray(argumentsOrNil)) {
b643af58f8bf invoking without arguments
fm
parents: 10279
diff changeset
   714
        __numArgs = __arraySize(argumentsOrNil);
9342
e548ce80ab02 virtual calls
Claus Gittinger <cg@exept.de>
parents: 9341
diff changeset
   715
    } else {
10603
da9b7ed81caf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10514
diff changeset
   716
        __FAIL__(@symbol(BadArgumentVector))
10440
b643af58f8bf invoking without arguments
fm
parents: 10279
diff changeset
   717
    }
b643af58f8bf invoking without arguments
fm
parents: 10279
diff changeset
   718
    if (argTypeSymbols == nil) {
b643af58f8bf invoking without arguments
fm
parents: 10279
diff changeset
   719
        __numArgsWanted = 0;
b643af58f8bf invoking without arguments
fm
parents: 10279
diff changeset
   720
    } else if (__isArray(argTypeSymbols)) {
b643af58f8bf invoking without arguments
fm
parents: 10279
diff changeset
   721
        __numArgsWanted = __arraySize(argTypeSymbols);
b643af58f8bf invoking without arguments
fm
parents: 10279
diff changeset
   722
    } else {
10603
da9b7ed81caf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10514
diff changeset
   723
        __FAIL__(@symbol(BadArgumentTypeVector))
10440
b643af58f8bf invoking without arguments
fm
parents: 10279
diff changeset
   724
    }
b643af58f8bf invoking without arguments
fm
parents: 10279
diff changeset
   725
b643af58f8bf invoking without arguments
fm
parents: 10279
diff changeset
   726
    if (__numArgs != __numArgsWanted) {
10603
da9b7ed81caf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10514
diff changeset
   727
        __FAIL__(@symbol(ArgumentCountMismatch))
9342
e548ce80ab02 virtual calls
Claus Gittinger <cg@exept.de>
parents: 9341
diff changeset
   728
    }
e548ce80ab02 virtual calls
Claus Gittinger <cg@exept.de>
parents: 9341
diff changeset
   729
    if (__numArgs > MAX_ARGS) {
10603
da9b7ed81caf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10514
diff changeset
   730
        __FAIL__(@symbol(TooManyArguments))
9342
e548ce80ab02 virtual calls
Claus Gittinger <cg@exept.de>
parents: 9341
diff changeset
   731
    }
e548ce80ab02 virtual calls
Claus Gittinger <cg@exept.de>
parents: 9341
diff changeset
   732
e548ce80ab02 virtual calls
Claus Gittinger <cg@exept.de>
parents: 9341
diff changeset
   733
    /*
e548ce80ab02 virtual calls
Claus Gittinger <cg@exept.de>
parents: 9341
diff changeset
   734
     * validate the return type
e548ce80ab02 virtual calls
Claus Gittinger <cg@exept.de>
parents: 9341
diff changeset
   735
     */
e548ce80ab02 virtual calls
Claus Gittinger <cg@exept.de>
parents: 9341
diff changeset
   736
    __returnValuePointer = &__returnValue;
9479
68d12a181d4a handle types; sint32 types.
ca
parents: 9466
diff changeset
   737
9483
3bea515ce81e *** empty log message ***
fm
parents: 9479
diff changeset
   738
    if (returnTypeSymbol == @symbol(voidPointer)) {
10440
b643af58f8bf invoking without arguments
fm
parents: 10279
diff changeset
   739
        returnTypeSymbol = @symbol(handle);
9483
3bea515ce81e *** empty log message ***
fm
parents: 9479
diff changeset
   740
    }
9479
68d12a181d4a handle types; sint32 types.
ca
parents: 9466
diff changeset
   741
9342
e548ce80ab02 virtual calls
Claus Gittinger <cg@exept.de>
parents: 9341
diff changeset
   742
    if (returnTypeSymbol == @symbol(int)) {
10440
b643af58f8bf invoking without arguments
fm
parents: 10279
diff changeset
   743
        __returnType = __get_ffi_type_sint();
9342
e548ce80ab02 virtual calls
Claus Gittinger <cg@exept.de>
parents: 9341
diff changeset
   744
    } else if (returnTypeSymbol == @symbol(uint)) {
10440
b643af58f8bf invoking without arguments
fm
parents: 10279
diff changeset
   745
        __returnType = __get_ffi_type_uint();
9479
68d12a181d4a handle types; sint32 types.
ca
parents: 9466
diff changeset
   746
    } else if (returnTypeSymbol == @symbol(uint8)) {
10440
b643af58f8bf invoking without arguments
fm
parents: 10279
diff changeset
   747
        __returnType = __get_ffi_type_uint8();
9479
68d12a181d4a handle types; sint32 types.
ca
parents: 9466
diff changeset
   748
    } else if (returnTypeSymbol == @symbol(uint16)) {
10440
b643af58f8bf invoking without arguments
fm
parents: 10279
diff changeset
   749
        __returnType = __get_ffi_type_uint16();
9479
68d12a181d4a handle types; sint32 types.
ca
parents: 9466
diff changeset
   750
    } else if (returnTypeSymbol == @symbol(uint32)) {
10440
b643af58f8bf invoking without arguments
fm
parents: 10279
diff changeset
   751
        __returnType = __get_ffi_type_uint32();
9479
68d12a181d4a handle types; sint32 types.
ca
parents: 9466
diff changeset
   752
    } else if (returnTypeSymbol == @symbol(uint64)) {
10440
b643af58f8bf invoking without arguments
fm
parents: 10279
diff changeset
   753
        __returnType = __get_ffi_type_uint64();
9479
68d12a181d4a handle types; sint32 types.
ca
parents: 9466
diff changeset
   754
68d12a181d4a handle types; sint32 types.
ca
parents: 9466
diff changeset
   755
    } else if (returnTypeSymbol == @symbol(sint)) {
10440
b643af58f8bf invoking without arguments
fm
parents: 10279
diff changeset
   756
        __returnType = __get_ffi_type_sint();
9479
68d12a181d4a handle types; sint32 types.
ca
parents: 9466
diff changeset
   757
    } else if (returnTypeSymbol == @symbol(sint8)) {
10440
b643af58f8bf invoking without arguments
fm
parents: 10279
diff changeset
   758
        __returnType = __get_ffi_type_sint8();
9479
68d12a181d4a handle types; sint32 types.
ca
parents: 9466
diff changeset
   759
    } else if (returnTypeSymbol == @symbol(sint16)) {
10440
b643af58f8bf invoking without arguments
fm
parents: 10279
diff changeset
   760
        __returnType = __get_ffi_type_sint16();
9479
68d12a181d4a handle types; sint32 types.
ca
parents: 9466
diff changeset
   761
    } else if (returnTypeSymbol == @symbol(sint32)) {
10440
b643af58f8bf invoking without arguments
fm
parents: 10279
diff changeset
   762
        __returnType = __get_ffi_type_sint32();
9479
68d12a181d4a handle types; sint32 types.
ca
parents: 9466
diff changeset
   763
    } else if (returnTypeSymbol == @symbol(sint64)) {
10440
b643af58f8bf invoking without arguments
fm
parents: 10279
diff changeset
   764
        __returnType = __get_ffi_type_sint64();
9479
68d12a181d4a handle types; sint32 types.
ca
parents: 9466
diff changeset
   765
9342
e548ce80ab02 virtual calls
Claus Gittinger <cg@exept.de>
parents: 9341
diff changeset
   766
    } else if (returnTypeSymbol == @symbol(long)) {
10440
b643af58f8bf invoking without arguments
fm
parents: 10279
diff changeset
   767
        if (sizeof(long) == 4) {
b643af58f8bf invoking without arguments
fm
parents: 10279
diff changeset
   768
           returnTypeSymbol = @symbol(sint32);
b643af58f8bf invoking without arguments
fm
parents: 10279
diff changeset
   769
           __returnType = __get_ffi_type_sint32();
b643af58f8bf invoking without arguments
fm
parents: 10279
diff changeset
   770
        } else if (sizeof(long) == 8) {
b643af58f8bf invoking without arguments
fm
parents: 10279
diff changeset
   771
           returnTypeSymbol = @symbol(sint64);
b643af58f8bf invoking without arguments
fm
parents: 10279
diff changeset
   772
           __returnType = __get_ffi_type_sint64();
b643af58f8bf invoking without arguments
fm
parents: 10279
diff changeset
   773
        } else {
10603
da9b7ed81caf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10514
diff changeset
   774
            __FAIL__(@symbol(UnknownReturnType))
10440
b643af58f8bf invoking without arguments
fm
parents: 10279
diff changeset
   775
        }
9479
68d12a181d4a handle types; sint32 types.
ca
parents: 9466
diff changeset
   776
9342
e548ce80ab02 virtual calls
Claus Gittinger <cg@exept.de>
parents: 9341
diff changeset
   777
    } else if (returnTypeSymbol == @symbol(ulong)) {
10440
b643af58f8bf invoking without arguments
fm
parents: 10279
diff changeset
   778
        if (sizeof(long) == 4) {
b643af58f8bf invoking without arguments
fm
parents: 10279
diff changeset
   779
           returnTypeSymbol = @symbol(uint32);
b643af58f8bf invoking without arguments
fm
parents: 10279
diff changeset
   780
           __returnType = __get_ffi_type_uint32();
b643af58f8bf invoking without arguments
fm
parents: 10279
diff changeset
   781
        }else if (sizeof(long) == 8) {
b643af58f8bf invoking without arguments
fm
parents: 10279
diff changeset
   782
           returnTypeSymbol = @symbol(uint64);
b643af58f8bf invoking without arguments
fm
parents: 10279
diff changeset
   783
           __returnType = __get_ffi_type_uint64();
b643af58f8bf invoking without arguments
fm
parents: 10279
diff changeset
   784
        } else {
10603
da9b7ed81caf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10514
diff changeset
   785
            __FAIL__(@symbol(UnknownReturnType))
10440
b643af58f8bf invoking without arguments
fm
parents: 10279
diff changeset
   786
        }
9479
68d12a181d4a handle types; sint32 types.
ca
parents: 9466
diff changeset
   787
10025
053904a63549 stc-compiled ExternalLibraryFunctions
Claus Gittinger <cg@exept.de>
parents: 9981
diff changeset
   788
    } else if (returnTypeSymbol == @symbol(bool)) {
10440
b643af58f8bf invoking without arguments
fm
parents: 10279
diff changeset
   789
        __returnType = __get_ffi_type_uint();
9479
68d12a181d4a handle types; sint32 types.
ca
parents: 9466
diff changeset
   790
9342
e548ce80ab02 virtual calls
Claus Gittinger <cg@exept.de>
parents: 9341
diff changeset
   791
    } else if (returnTypeSymbol == @symbol(float)) {
10440
b643af58f8bf invoking without arguments
fm
parents: 10279
diff changeset
   792
        __returnType = __get_ffi_type_float();
9342
e548ce80ab02 virtual calls
Claus Gittinger <cg@exept.de>
parents: 9341
diff changeset
   793
    } else if (returnTypeSymbol == @symbol(double)) {
10440
b643af58f8bf invoking without arguments
fm
parents: 10279
diff changeset
   794
        __returnType = __get_ffi_type_double();
9479
68d12a181d4a handle types; sint32 types.
ca
parents: 9466
diff changeset
   795
9342
e548ce80ab02 virtual calls
Claus Gittinger <cg@exept.de>
parents: 9341
diff changeset
   796
    } else if (returnTypeSymbol == @symbol(void)) {
10440
b643af58f8bf invoking without arguments
fm
parents: 10279
diff changeset
   797
        __returnType = __get_ffi_type_void();
b643af58f8bf invoking without arguments
fm
parents: 10279
diff changeset
   798
        __returnValuePointer = NULL;
10603
da9b7ed81caf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10514
diff changeset
   799
    } else if ((returnTypeSymbol == @symbol(pointer)) 
da9b7ed81caf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10514
diff changeset
   800
               || (returnTypeSymbol == @symbol(handle))
da9b7ed81caf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10514
diff changeset
   801
               || (returnTypeSymbol == @symbol(charPointer))
da9b7ed81caf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10514
diff changeset
   802
               || (returnTypeSymbol == @symbol(bytePointer))
da9b7ed81caf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10514
diff changeset
   803
               || (returnTypeSymbol == @symbol(floatPointer))
da9b7ed81caf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10514
diff changeset
   804
               || (returnTypeSymbol == @symbol(doublePointer))
da9b7ed81caf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10514
diff changeset
   805
               || (returnTypeSymbol == @symbol(intPointer))
da9b7ed81caf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10514
diff changeset
   806
               || (returnTypeSymbol == @symbol(shortPointer))
da9b7ed81caf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10514
diff changeset
   807
               || (returnTypeSymbol == @symbol(wcharPointer))) {
10440
b643af58f8bf invoking without arguments
fm
parents: 10279
diff changeset
   808
        __returnType = __get_ffi_type_pointer();
9342
e548ce80ab02 virtual calls
Claus Gittinger <cg@exept.de>
parents: 9341
diff changeset
   809
    } else {
10440
b643af58f8bf invoking without arguments
fm
parents: 10279
diff changeset
   810
        if (__isSymbol(returnTypeSymbol)
b643af58f8bf invoking without arguments
fm
parents: 10279
diff changeset
   811
         && ((returnValueClass = __GLOBAL_GET(returnTypeSymbol)) != nil)) {
b643af58f8bf invoking without arguments
fm
parents: 10279
diff changeset
   812
            if (! __isBehaviorLike(returnValueClass)) {
10603
da9b7ed81caf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10514
diff changeset
   813
                __FAIL__(@symbol(NonBehaviorReturnType))
10440
b643af58f8bf invoking without arguments
fm
parents: 10279
diff changeset
   814
            }
b643af58f8bf invoking without arguments
fm
parents: 10279
diff changeset
   815
            if (! __qIsSubclassOfExternalAddress(returnValueClass)) {
10603
da9b7ed81caf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10514
diff changeset
   816
                __FAIL__(@symbol(NonExternalAddressReturnType))
10440
b643af58f8bf invoking without arguments
fm
parents: 10279
diff changeset
   817
            }
b643af58f8bf invoking without arguments
fm
parents: 10279
diff changeset
   818
            __returnType = __get_ffi_type_pointer();
b643af58f8bf invoking without arguments
fm
parents: 10279
diff changeset
   819
            returnTypeSymbol = @symbol(pointer);
b643af58f8bf invoking without arguments
fm
parents: 10279
diff changeset
   820
        } else {
10603
da9b7ed81caf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10514
diff changeset
   821
            __FAIL__(@symbol(UnknownReturnType))
10440
b643af58f8bf invoking without arguments
fm
parents: 10279
diff changeset
   822
        }
9342
e548ce80ab02 virtual calls
Claus Gittinger <cg@exept.de>
parents: 9341
diff changeset
   823
    }
e548ce80ab02 virtual calls
Claus Gittinger <cg@exept.de>
parents: 9341
diff changeset
   824
e548ce80ab02 virtual calls
Claus Gittinger <cg@exept.de>
parents: 9341
diff changeset
   825
    /*
e548ce80ab02 virtual calls
Claus Gittinger <cg@exept.de>
parents: 9341
diff changeset
   826
     * validate the c++ object
e548ce80ab02 virtual calls
Claus Gittinger <cg@exept.de>
parents: 9341
diff changeset
   827
     */
e548ce80ab02 virtual calls
Claus Gittinger <cg@exept.de>
parents: 9341
diff changeset
   828
    if (aCPlusPlusObjectOrNil != nil) {
10440
b643af58f8bf invoking without arguments
fm
parents: 10279
diff changeset
   829
        struct cPlusPlusInstance {
b643af58f8bf invoking without arguments
fm
parents: 10279
diff changeset
   830
            void **vTable;
b643af58f8bf invoking without arguments
fm
parents: 10279
diff changeset
   831
        };
b643af58f8bf invoking without arguments
fm
parents: 10279
diff changeset
   832
        struct cPlusPlusInstance *inst;
9342
e548ce80ab02 virtual calls
Claus Gittinger <cg@exept.de>
parents: 9341
diff changeset
   833
10440
b643af58f8bf invoking without arguments
fm
parents: 10279
diff changeset
   834
        if (__isExternalAddressLike(aCPlusPlusObjectOrNil)) {
b643af58f8bf invoking without arguments
fm
parents: 10279
diff changeset
   835
            inst = (void *)(__externalAddressVal(aCPlusPlusObjectOrNil));
b643af58f8bf invoking without arguments
fm
parents: 10279
diff changeset
   836
        } else if (__isExternalBytesLike(aCPlusPlusObjectOrNil)) {
b643af58f8bf invoking without arguments
fm
parents: 10279
diff changeset
   837
            inst = (void *)(__externalBytesVal(aCPlusPlusObjectOrNil));
b643af58f8bf invoking without arguments
fm
parents: 10279
diff changeset
   838
        } else {
10603
da9b7ed81caf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10514
diff changeset
   839
            __FAIL__(@symbol(InvalidInstance))
10440
b643af58f8bf invoking without arguments
fm
parents: 10279
diff changeset
   840
        }
b643af58f8bf invoking without arguments
fm
parents: 10279
diff changeset
   841
        __argValues[0].pointerVal = inst;
b643af58f8bf invoking without arguments
fm
parents: 10279
diff changeset
   842
        __argValuePointersIncludingThis[0] = &(__argValues[0]);
b643af58f8bf invoking without arguments
fm
parents: 10279
diff changeset
   843
        __argTypes[0] = __get_ffi_type_pointer();
9342
e548ce80ab02 virtual calls
Claus Gittinger <cg@exept.de>
parents: 9341
diff changeset
   844
10440
b643af58f8bf invoking without arguments
fm
parents: 10279
diff changeset
   845
        __argValuePointers = &__argValuePointersIncludingThis[1];
b643af58f8bf invoking without arguments
fm
parents: 10279
diff changeset
   846
        __argTypes = &__argTypesIncludingThis[1];
b643af58f8bf invoking without arguments
fm
parents: 10279
diff changeset
   847
        __argValues = &__argValuesIncludingThis[1];
b643af58f8bf invoking without arguments
fm
parents: 10279
diff changeset
   848
        __numArgsIncludingThis = __numArgs + 1;
9347
31adc57e6954 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9346
diff changeset
   849
10440
b643af58f8bf invoking without arguments
fm
parents: 10279
diff changeset
   850
        if (virtual == true) {
b643af58f8bf invoking without arguments
fm
parents: 10279
diff changeset
   851
            if (! __isSmallInteger(vtOffset)) {
10603
da9b7ed81caf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10514
diff changeset
   852
                __FAIL__(@symbol(InvalidVTableIndex))
10440
b643af58f8bf invoking without arguments
fm
parents: 10279
diff changeset
   853
            }
b643af58f8bf invoking without arguments
fm
parents: 10279
diff changeset
   854
            codeAddress = inst->vTable[__intVal(vtOffset)];
9464
157fe6ca53e6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9463
diff changeset
   855
#ifdef VERBOSE
10440
b643af58f8bf invoking without arguments
fm
parents: 10279
diff changeset
   856
            printf("virtual codeAddress: %x\n", codeAddress);
9464
157fe6ca53e6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9463
diff changeset
   857
#endif
10440
b643af58f8bf invoking without arguments
fm
parents: 10279
diff changeset
   858
        }
9342
e548ce80ab02 virtual calls
Claus Gittinger <cg@exept.de>
parents: 9341
diff changeset
   859
    } else {
10440
b643af58f8bf invoking without arguments
fm
parents: 10279
diff changeset
   860
        __numArgsIncludingThis = __numArgs;
9524
2af286bbcac3 *** empty log message ***
ca
parents: 9519
diff changeset
   861
#ifdef VERBOSE
10440
b643af58f8bf invoking without arguments
fm
parents: 10279
diff changeset
   862
        printf("codeAddress: %x\n", codeAddress);
9524
2af286bbcac3 *** empty log message ***
ca
parents: 9519
diff changeset
   863
#endif
9342
e548ce80ab02 virtual calls
Claus Gittinger <cg@exept.de>
parents: 9341
diff changeset
   864
    }
e548ce80ab02 virtual calls
Claus Gittinger <cg@exept.de>
parents: 9341
diff changeset
   865
e548ce80ab02 virtual calls
Claus Gittinger <cg@exept.de>
parents: 9341
diff changeset
   866
    /*
e548ce80ab02 virtual calls
Claus Gittinger <cg@exept.de>
parents: 9341
diff changeset
   867
     * validate all arg types and setup arg-buffers
e548ce80ab02 virtual calls
Claus Gittinger <cg@exept.de>
parents: 9341
diff changeset
   868
     */
e548ce80ab02 virtual calls
Claus Gittinger <cg@exept.de>
parents: 9341
diff changeset
   869
    for (i=0; i<__numArgs; i++) {
10440
b643af58f8bf invoking without arguments
fm
parents: 10279
diff changeset
   870
        ffi_type *thisType;
b643af58f8bf invoking without arguments
fm
parents: 10279
diff changeset
   871
        void *argValuePtr;
b643af58f8bf invoking without arguments
fm
parents: 10279
diff changeset
   872
        OBJ typeSymbol;
b643af58f8bf invoking without arguments
fm
parents: 10279
diff changeset
   873
        OBJ arg;
9342
e548ce80ab02 virtual calls
Claus Gittinger <cg@exept.de>
parents: 9341
diff changeset
   874
10440
b643af58f8bf invoking without arguments
fm
parents: 10279
diff changeset
   875
        failureInfo = __mkSmallInteger(i+1);   /* in case there is one */
9465
d11885052713 rewrite & cleanup
Claus Gittinger <cg@exept.de>
parents: 9464
diff changeset
   876
10440
b643af58f8bf invoking without arguments
fm
parents: 10279
diff changeset
   877
        typeSymbol = __ArrayInstPtr(argTypeSymbols)->a_element[i];
b643af58f8bf invoking without arguments
fm
parents: 10279
diff changeset
   878
        arg = __ArrayInstPtr(argumentsOrNil)->a_element[i];
9342
e548ce80ab02 virtual calls
Claus Gittinger <cg@exept.de>
parents: 9341
diff changeset
   879
10440
b643af58f8bf invoking without arguments
fm
parents: 10279
diff changeset
   880
        if (typeSymbol == @symbol(handle)) {
b643af58f8bf invoking without arguments
fm
parents: 10279
diff changeset
   881
            typeSymbol = @symbol(pointer);
b643af58f8bf invoking without arguments
fm
parents: 10279
diff changeset
   882
        } else if (typeSymbol == @symbol(voidPointer)) {
b643af58f8bf invoking without arguments
fm
parents: 10279
diff changeset
   883
            typeSymbol = @symbol(pointer);
b643af58f8bf invoking without arguments
fm
parents: 10279
diff changeset
   884
        }
9479
68d12a181d4a handle types; sint32 types.
ca
parents: 9466
diff changeset
   885
10440
b643af58f8bf invoking without arguments
fm
parents: 10279
diff changeset
   886
        if (typeSymbol == @symbol(long)) {
b643af58f8bf invoking without arguments
fm
parents: 10279
diff changeset
   887
            if (sizeof(long) == sizeof(int)) {
b643af58f8bf invoking without arguments
fm
parents: 10279
diff changeset
   888
                typeSymbol = @symbol(sint);
b643af58f8bf invoking without arguments
fm
parents: 10279
diff changeset
   889
            } else {
b643af58f8bf invoking without arguments
fm
parents: 10279
diff changeset
   890
                if (sizeof(long) == 4) {
b643af58f8bf invoking without arguments
fm
parents: 10279
diff changeset
   891
                    typeSymbol = @symbol(sint32);
b643af58f8bf invoking without arguments
fm
parents: 10279
diff changeset
   892
                } else if (sizeof(long) == 8) {
b643af58f8bf invoking without arguments
fm
parents: 10279
diff changeset
   893
                    typeSymbol = @symbol(sint64);
b643af58f8bf invoking without arguments
fm
parents: 10279
diff changeset
   894
                }
b643af58f8bf invoking without arguments
fm
parents: 10279
diff changeset
   895
            }
b643af58f8bf invoking without arguments
fm
parents: 10279
diff changeset
   896
        }
b643af58f8bf invoking without arguments
fm
parents: 10279
diff changeset
   897
        if (typeSymbol == @symbol(ulong)) {
b643af58f8bf invoking without arguments
fm
parents: 10279
diff changeset
   898
            if (sizeof(unsigned long) == sizeof(unsigned int)) {
b643af58f8bf invoking without arguments
fm
parents: 10279
diff changeset
   899
                typeSymbol = @symbol(uint);
b643af58f8bf invoking without arguments
fm
parents: 10279
diff changeset
   900
            } else {
b643af58f8bf invoking without arguments
fm
parents: 10279
diff changeset
   901
                if (sizeof(long) == 4) {
b643af58f8bf invoking without arguments
fm
parents: 10279
diff changeset
   902
                    typeSymbol = @symbol(uint32);
b643af58f8bf invoking without arguments
fm
parents: 10279
diff changeset
   903
                } else if (sizeof(long) == 8) {
b643af58f8bf invoking without arguments
fm
parents: 10279
diff changeset
   904
                    typeSymbol = @symbol(uint64);
b643af58f8bf invoking without arguments
fm
parents: 10279
diff changeset
   905
                }
b643af58f8bf invoking without arguments
fm
parents: 10279
diff changeset
   906
            }
b643af58f8bf invoking without arguments
fm
parents: 10279
diff changeset
   907
        }
9342
e548ce80ab02 virtual calls
Claus Gittinger <cg@exept.de>
parents: 9341
diff changeset
   908
10674
400b8823c2df changed #invokeFFIwithArguments:forCPPInstance:
Stefan Vogel <sv@exept.de>
parents: 10625
diff changeset
   909
        if (typeSymbol == @symbol(int) || typeSymbol == @symbol(sint)) {
10440
b643af58f8bf invoking without arguments
fm
parents: 10279
diff changeset
   910
            thisType = __get_ffi_type_sint();
b643af58f8bf invoking without arguments
fm
parents: 10279
diff changeset
   911
            if (__isSmallInteger(arg)) {
b643af58f8bf invoking without arguments
fm
parents: 10279
diff changeset
   912
                __argValues[i].iVal = __intVal(arg);
b643af58f8bf invoking without arguments
fm
parents: 10279
diff changeset
   913
            } else {
b643af58f8bf invoking without arguments
fm
parents: 10279
diff changeset
   914
                __argValues[i].iVal = __signedLongIntVal(arg);
b643af58f8bf invoking without arguments
fm
parents: 10279
diff changeset
   915
                if (__argValues[i].iVal == 0) {
10603
da9b7ed81caf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10514
diff changeset
   916
                    __FAIL__(@symbol(InvalidArgument))
10440
b643af58f8bf invoking without arguments
fm
parents: 10279
diff changeset
   917
                }
b643af58f8bf invoking without arguments
fm
parents: 10279
diff changeset
   918
            }
b643af58f8bf invoking without arguments
fm
parents: 10279
diff changeset
   919
            argValuePtr = &(__argValues[i].iVal);
9479
68d12a181d4a handle types; sint32 types.
ca
parents: 9466
diff changeset
   920
10440
b643af58f8bf invoking without arguments
fm
parents: 10279
diff changeset
   921
        } else if (typeSymbol == @symbol(uint)) {
b643af58f8bf invoking without arguments
fm
parents: 10279
diff changeset
   922
            thisType = __get_ffi_type_uint();
9342
e548ce80ab02 virtual calls
Claus Gittinger <cg@exept.de>
parents: 9341
diff changeset
   923
10440
b643af58f8bf invoking without arguments
fm
parents: 10279
diff changeset
   924
            if (__isSmallInteger(arg)) {
b643af58f8bf invoking without arguments
fm
parents: 10279
diff changeset
   925
                __argValues[i].iVal = __intVal(arg);
b643af58f8bf invoking without arguments
fm
parents: 10279
diff changeset
   926
            } else {
b643af58f8bf invoking without arguments
fm
parents: 10279
diff changeset
   927
                __argValues[i].iVal = __unsignedLongIntVal(arg);
b643af58f8bf invoking without arguments
fm
parents: 10279
diff changeset
   928
                if (__argValues[i].iVal == 0) {
10603
da9b7ed81caf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10514
diff changeset
   929
                    __FAIL__(@symbol(InvalidArgument))
10440
b643af58f8bf invoking without arguments
fm
parents: 10279
diff changeset
   930
                }
b643af58f8bf invoking without arguments
fm
parents: 10279
diff changeset
   931
            }
b643af58f8bf invoking without arguments
fm
parents: 10279
diff changeset
   932
            argValuePtr = &(__argValues[i].iVal);
9479
68d12a181d4a handle types; sint32 types.
ca
parents: 9466
diff changeset
   933
10440
b643af58f8bf invoking without arguments
fm
parents: 10279
diff changeset
   934
        } else if (typeSymbol == @symbol(uint8)) {
b643af58f8bf invoking without arguments
fm
parents: 10279
diff changeset
   935
            thisType = __get_ffi_type_uint8();
b643af58f8bf invoking without arguments
fm
parents: 10279
diff changeset
   936
            if (! __isSmallInteger(arg)) {
10603
da9b7ed81caf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10514
diff changeset
   937
                __FAIL__(@symbol(InvalidArgument))
10440
b643af58f8bf invoking without arguments
fm
parents: 10279
diff changeset
   938
            }
b643af58f8bf invoking without arguments
fm
parents: 10279
diff changeset
   939
            __argValues[i].iVal = __intVal(arg);
b643af58f8bf invoking without arguments
fm
parents: 10279
diff changeset
   940
            if (((unsigned)(__argValues[i].iVal)) > 0xFF) {
10603
da9b7ed81caf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10514
diff changeset
   941
                __FAIL__(@symbol(InvalidArgument))
10440
b643af58f8bf invoking without arguments
fm
parents: 10279
diff changeset
   942
            }
b643af58f8bf invoking without arguments
fm
parents: 10279
diff changeset
   943
            argValuePtr = &(__argValues[i].iVal);
9479
68d12a181d4a handle types; sint32 types.
ca
parents: 9466
diff changeset
   944
10440
b643af58f8bf invoking without arguments
fm
parents: 10279
diff changeset
   945
        } else if (typeSymbol == @symbol(sint8)) {
b643af58f8bf invoking without arguments
fm
parents: 10279
diff changeset
   946
            thisType = __get_ffi_type_sint8();
b643af58f8bf invoking without arguments
fm
parents: 10279
diff changeset
   947
            if (! __isSmallInteger(arg)) {
10603
da9b7ed81caf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10514
diff changeset
   948
                __FAIL__(@symbol(InvalidArgument))
10440
b643af58f8bf invoking without arguments
fm
parents: 10279
diff changeset
   949
            }
b643af58f8bf invoking without arguments
fm
parents: 10279
diff changeset
   950
            __argValues[i].iVal = __intVal(arg);
b643af58f8bf invoking without arguments
fm
parents: 10279
diff changeset
   951
            if (((__argValues[i].iVal) < -0x80) || ((__argValues[i].iVal) > 0x7F))  {
10603
da9b7ed81caf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10514
diff changeset
   952
                __FAIL__(@symbol(InvalidArgument))
10440
b643af58f8bf invoking without arguments
fm
parents: 10279
diff changeset
   953
            }
b643af58f8bf invoking without arguments
fm
parents: 10279
diff changeset
   954
            argValuePtr = &(__argValues[i].iVal);
9479
68d12a181d4a handle types; sint32 types.
ca
parents: 9466
diff changeset
   955
10440
b643af58f8bf invoking without arguments
fm
parents: 10279
diff changeset
   956
        } else if (typeSymbol == @symbol(uint16)) {
b643af58f8bf invoking without arguments
fm
parents: 10279
diff changeset
   957
            thisType = __get_ffi_type_uint16();
b643af58f8bf invoking without arguments
fm
parents: 10279
diff changeset
   958
            if (! __isSmallInteger(arg)) {
10603
da9b7ed81caf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10514
diff changeset
   959
                __FAIL__(@symbol(InvalidArgument))
10440
b643af58f8bf invoking without arguments
fm
parents: 10279
diff changeset
   960
            }
b643af58f8bf invoking without arguments
fm
parents: 10279
diff changeset
   961
            __argValues[i].iVal = __intVal(arg);
b643af58f8bf invoking without arguments
fm
parents: 10279
diff changeset
   962
            if (((unsigned)(__argValues[i].iVal)) > 0xFFFF) {
10603
da9b7ed81caf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10514
diff changeset
   963
                __FAIL__(@symbol(InvalidArgument))
10440
b643af58f8bf invoking without arguments
fm
parents: 10279
diff changeset
   964
            }
b643af58f8bf invoking without arguments
fm
parents: 10279
diff changeset
   965
            argValuePtr = &(__argValues[i].iVal);
9479
68d12a181d4a handle types; sint32 types.
ca
parents: 9466
diff changeset
   966
10440
b643af58f8bf invoking without arguments
fm
parents: 10279
diff changeset
   967
        } else if (typeSymbol == @symbol(sint16)) {
b643af58f8bf invoking without arguments
fm
parents: 10279
diff changeset
   968
            thisType = __get_ffi_type_sint16();
b643af58f8bf invoking without arguments
fm
parents: 10279
diff changeset
   969
            if (! __isSmallInteger(arg)) {
10603
da9b7ed81caf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10514
diff changeset
   970
                __FAIL__(@symbol(InvalidArgument))
10440
b643af58f8bf invoking without arguments
fm
parents: 10279
diff changeset
   971
            }
b643af58f8bf invoking without arguments
fm
parents: 10279
diff changeset
   972
            __argValues[i].iVal = __intVal(arg);
b643af58f8bf invoking without arguments
fm
parents: 10279
diff changeset
   973
            if (((__argValues[i].iVal) < -0x8000) || ((__argValues[i].iVal) > 0x7FFF))  {
10603
da9b7ed81caf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10514
diff changeset
   974
                __FAIL__(@symbol(InvalidArgument))
10440
b643af58f8bf invoking without arguments
fm
parents: 10279
diff changeset
   975
            }
b643af58f8bf invoking without arguments
fm
parents: 10279
diff changeset
   976
            argValuePtr = &(__argValues[i].iVal);
9479
68d12a181d4a handle types; sint32 types.
ca
parents: 9466
diff changeset
   977
10440
b643af58f8bf invoking without arguments
fm
parents: 10279
diff changeset
   978
        } else if ((typeSymbol == @symbol(uint32)) || (typeSymbol == @symbol(sint32))) {
b643af58f8bf invoking without arguments
fm
parents: 10279
diff changeset
   979
            thisType = __get_ffi_type_uint32();
b643af58f8bf invoking without arguments
fm
parents: 10279
diff changeset
   980
            if (__isSmallInteger(arg)) {
b643af58f8bf invoking without arguments
fm
parents: 10279
diff changeset
   981
                __argValues[i].iVal = __intVal(arg);
b643af58f8bf invoking without arguments
fm
parents: 10279
diff changeset
   982
            } else {
b643af58f8bf invoking without arguments
fm
parents: 10279
diff changeset
   983
                __argValues[i].iVal = __unsignedLongIntVal(arg);
b643af58f8bf invoking without arguments
fm
parents: 10279
diff changeset
   984
                if (__argValues[i].iVal == 0) {
10603
da9b7ed81caf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10514
diff changeset
   985
                    __FAIL__(@symbol(InvalidArgument))
10440
b643af58f8bf invoking without arguments
fm
parents: 10279
diff changeset
   986
                }
b643af58f8bf invoking without arguments
fm
parents: 10279
diff changeset
   987
            }
b643af58f8bf invoking without arguments
fm
parents: 10279
diff changeset
   988
            argValuePtr = &(__argValues[i].iVal);
9479
68d12a181d4a handle types; sint32 types.
ca
parents: 9466
diff changeset
   989
10440
b643af58f8bf invoking without arguments
fm
parents: 10279
diff changeset
   990
        } else if (typeSymbol == @symbol(float)) {
b643af58f8bf invoking without arguments
fm
parents: 10279
diff changeset
   991
            thisType = __get_ffi_type_float();
b643af58f8bf invoking without arguments
fm
parents: 10279
diff changeset
   992
            if (__isSmallInteger(arg)) {
b643af58f8bf invoking without arguments
fm
parents: 10279
diff changeset
   993
                __argValues[i].fVal = (float)(__intVal(arg));
b643af58f8bf invoking without arguments
fm
parents: 10279
diff changeset
   994
            } else if (__isFloat(arg)) {
b643af58f8bf invoking without arguments
fm
parents: 10279
diff changeset
   995
                __argValues[i].fVal = (float)(__floatVal(arg));
b643af58f8bf invoking without arguments
fm
parents: 10279
diff changeset
   996
            } else if (__isShortFloat(arg)) {
b643af58f8bf invoking without arguments
fm
parents: 10279
diff changeset
   997
                __argValues[i].fVal = (float)(__shortFloatVal(arg));
b643af58f8bf invoking without arguments
fm
parents: 10279
diff changeset
   998
            } else {
10603
da9b7ed81caf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10514
diff changeset
   999
                __FAIL__(@symbol(InvalidArgument))
10440
b643af58f8bf invoking without arguments
fm
parents: 10279
diff changeset
  1000
            }
b643af58f8bf invoking without arguments
fm
parents: 10279
diff changeset
  1001
            argValuePtr = &(__argValues[i].fVal);
9479
68d12a181d4a handle types; sint32 types.
ca
parents: 9466
diff changeset
  1002
10440
b643af58f8bf invoking without arguments
fm
parents: 10279
diff changeset
  1003
        } else if (typeSymbol == @symbol(double)) {
b643af58f8bf invoking without arguments
fm
parents: 10279
diff changeset
  1004
            thisType = __get_ffi_type_double();
b643af58f8bf invoking without arguments
fm
parents: 10279
diff changeset
  1005
            if (__isSmallInteger(arg)) {
b643af58f8bf invoking without arguments
fm
parents: 10279
diff changeset
  1006
                __argValues[i].dVal = (double)(__intVal(arg));
b643af58f8bf invoking without arguments
fm
parents: 10279
diff changeset
  1007
            } else if (__isFloat(arg)) {
b643af58f8bf invoking without arguments
fm
parents: 10279
diff changeset
  1008
                __argValues[i].dVal = (double)(__floatVal(arg));
b643af58f8bf invoking without arguments
fm
parents: 10279
diff changeset
  1009
            } else if (__isShortFloat(arg)) {
b643af58f8bf invoking without arguments
fm
parents: 10279
diff changeset
  1010
                __argValues[i].dVal = (double)(__shortFloatVal(arg));
b643af58f8bf invoking without arguments
fm
parents: 10279
diff changeset
  1011
            } else {
10603
da9b7ed81caf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10514
diff changeset
  1012
                __FAIL__(@symbol(InvalidArgument))
10440
b643af58f8bf invoking without arguments
fm
parents: 10279
diff changeset
  1013
            }
b643af58f8bf invoking without arguments
fm
parents: 10279
diff changeset
  1014
            argValuePtr = &(__argValues[i].dVal);
9479
68d12a181d4a handle types; sint32 types.
ca
parents: 9466
diff changeset
  1015
10440
b643af58f8bf invoking without arguments
fm
parents: 10279
diff changeset
  1016
        } else if (typeSymbol == @symbol(void)) {
b643af58f8bf invoking without arguments
fm
parents: 10279
diff changeset
  1017
            thisType = __get_ffi_type_void();
b643af58f8bf invoking without arguments
fm
parents: 10279
diff changeset
  1018
            argValuePtr = &null;
9479
68d12a181d4a handle types; sint32 types.
ca
parents: 9466
diff changeset
  1019
10440
b643af58f8bf invoking without arguments
fm
parents: 10279
diff changeset
  1020
        } else if (typeSymbol == @symbol(charPointer)) {
b643af58f8bf invoking without arguments
fm
parents: 10279
diff changeset
  1021
            thisType = __get_ffi_type_pointer();
b643af58f8bf invoking without arguments
fm
parents: 10279
diff changeset
  1022
            if (__isString(arg) || __isSymbol(arg)) {
b643af58f8bf invoking without arguments
fm
parents: 10279
diff changeset
  1023
                if (async == true) goto badArgForAsyncCall;
b643af58f8bf invoking without arguments
fm
parents: 10279
diff changeset
  1024
                __argValues[i].pointerVal = (void *)(__stringVal(arg));
10512
5a01829213ab *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10484
diff changeset
  1025
            } else if (__isBytes(arg)) {
5a01829213ab *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10484
diff changeset
  1026
                if (async == true) goto badArgForAsyncCall;
5a01829213ab *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10484
diff changeset
  1027
                __argValues[i].pointerVal = (void *)(__byteArrayVal(arg));
10514
d79947992c91 allow externalBytes as charPointer argument
Claus Gittinger <cg@exept.de>
parents: 10512
diff changeset
  1028
            } else if (__isExternalAddressLike(arg)) {
d79947992c91 allow externalBytes as charPointer argument
Claus Gittinger <cg@exept.de>
parents: 10512
diff changeset
  1029
                __argValues[i].pointerVal = (void *)(__externalAddressVal(arg));
d79947992c91 allow externalBytes as charPointer argument
Claus Gittinger <cg@exept.de>
parents: 10512
diff changeset
  1030
            } else if (__isExternalBytesLike(arg)) {
d79947992c91 allow externalBytes as charPointer argument
Claus Gittinger <cg@exept.de>
parents: 10512
diff changeset
  1031
                __argValues[i].pointerVal = (void *)(__externalBytesVal(arg));
10440
b643af58f8bf invoking without arguments
fm
parents: 10279
diff changeset
  1032
            } else {
10512
5a01829213ab *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10484
diff changeset
  1033
                if (arg == nil) {
5a01829213ab *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10484
diff changeset
  1034
                    __argValues[i].pointerVal = (void *)0;
10440
b643af58f8bf invoking without arguments
fm
parents: 10279
diff changeset
  1035
                } else {
10603
da9b7ed81caf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10514
diff changeset
  1036
                    __FAIL__(@symbol(InvalidArgument))
da9b7ed81caf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10514
diff changeset
  1037
                }
da9b7ed81caf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10514
diff changeset
  1038
            }
da9b7ed81caf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10514
diff changeset
  1039
            argValuePtr = &(__argValues[i].pointerVal);;
da9b7ed81caf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10514
diff changeset
  1040
da9b7ed81caf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10514
diff changeset
  1041
        } else if (typeSymbol == @symbol(floatPointer)) {
da9b7ed81caf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10514
diff changeset
  1042
            thisType = __get_ffi_type_pointer();
da9b7ed81caf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10514
diff changeset
  1043
            if (__isBytes(arg)) {
da9b7ed81caf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10514
diff changeset
  1044
                if (async == true) goto badArgForAsyncCall;
da9b7ed81caf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10514
diff changeset
  1045
                __argValues[i].pointerVal = (void *)(__byteArrayVal(arg));
da9b7ed81caf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10514
diff changeset
  1046
            } else if (__isExternalAddressLike(arg)) {
da9b7ed81caf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10514
diff changeset
  1047
                __argValues[i].pointerVal = (void *)(__externalAddressVal(arg));
da9b7ed81caf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10514
diff changeset
  1048
            } else if (__isExternalBytesLike(arg)) {
da9b7ed81caf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10514
diff changeset
  1049
                __argValues[i].pointerVal = (void *)(__externalBytesVal(arg));
da9b7ed81caf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10514
diff changeset
  1050
            } else if (__isFloats(arg)) {
da9b7ed81caf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10514
diff changeset
  1051
                char *p = (char *)(__FloatArrayInstPtr(arg)->f_element);
da9b7ed81caf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10514
diff changeset
  1052
                int nInstBytes;
da9b7ed81caf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10514
diff changeset
  1053
                OBJ cls;
da9b7ed81caf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10514
diff changeset
  1054
da9b7ed81caf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10514
diff changeset
  1055
                if (async == true) goto badArgForAsyncCall;
da9b7ed81caf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10514
diff changeset
  1056
                cls = __qClass(arg);
da9b7ed81caf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10514
diff changeset
  1057
                nInstBytes = __OBJS2BYTES__(__intVal(__ClassInstPtr(cls)->c_ninstvars));
da9b7ed81caf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10514
diff changeset
  1058
                p = p + nInstBytes;
da9b7ed81caf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10514
diff changeset
  1059
                __argValues[i].pointerVal = p;
da9b7ed81caf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10514
diff changeset
  1060
            } else {
da9b7ed81caf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10514
diff changeset
  1061
                if (arg == nil) {
da9b7ed81caf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10514
diff changeset
  1062
                    __argValues[i].pointerVal = (void *)0;
da9b7ed81caf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10514
diff changeset
  1063
                } else {
da9b7ed81caf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10514
diff changeset
  1064
                    __FAIL__(@symbol(InvalidArgument))
da9b7ed81caf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10514
diff changeset
  1065
                }
da9b7ed81caf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10514
diff changeset
  1066
            }
da9b7ed81caf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10514
diff changeset
  1067
            argValuePtr = &(__argValues[i].pointerVal);;
da9b7ed81caf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10514
diff changeset
  1068
da9b7ed81caf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10514
diff changeset
  1069
        } else if (typeSymbol == @symbol(doublePointer)) {
da9b7ed81caf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10514
diff changeset
  1070
            thisType = __get_ffi_type_pointer();
da9b7ed81caf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10514
diff changeset
  1071
            if (__isBytes(arg)) {
da9b7ed81caf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10514
diff changeset
  1072
                if (async == true) goto badArgForAsyncCall;
da9b7ed81caf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10514
diff changeset
  1073
                __argValues[i].pointerVal = (void *)(__byteArrayVal(arg));
da9b7ed81caf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10514
diff changeset
  1074
            } else if (__isExternalAddressLike(arg)) {
da9b7ed81caf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10514
diff changeset
  1075
                __argValues[i].pointerVal = (void *)(__externalAddressVal(arg));
da9b7ed81caf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10514
diff changeset
  1076
            } else if (__isExternalBytesLike(arg)) {
da9b7ed81caf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10514
diff changeset
  1077
                __argValues[i].pointerVal = (void *)(__externalBytesVal(arg));
da9b7ed81caf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10514
diff changeset
  1078
            } else if (__isDoubles(arg)) {
da9b7ed81caf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10514
diff changeset
  1079
                char *p = (char *)(__DoubleArrayInstPtr(arg)->d_element);
da9b7ed81caf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10514
diff changeset
  1080
                int nInstBytes;
da9b7ed81caf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10514
diff changeset
  1081
                OBJ cls;
da9b7ed81caf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10514
diff changeset
  1082
da9b7ed81caf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10514
diff changeset
  1083
                if (async == true) goto badArgForAsyncCall;
da9b7ed81caf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10514
diff changeset
  1084
                cls = __qClass(arg);
da9b7ed81caf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10514
diff changeset
  1085
                nInstBytes = __OBJS2BYTES__(__intVal(__ClassInstPtr(cls)->c_ninstvars));
da9b7ed81caf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10514
diff changeset
  1086
                p = p + nInstBytes;
da9b7ed81caf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10514
diff changeset
  1087
#ifdef __NEED_DOUBLE_ALIGN
da9b7ed81caf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10514
diff changeset
  1088
                if ((INT)pFirst & (__DOUBLE_ALIGN-1)) {
da9b7ed81caf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10514
diff changeset
  1089
                    int delta = __DOUBLE_ALIGN - ((INT)p & (__DOUBLE_ALIGN-1));
da9b7ed81caf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10514
diff changeset
  1090
da9b7ed81caf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10514
diff changeset
  1091
                    p += delta;
da9b7ed81caf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10514
diff changeset
  1092
                }
da9b7ed81caf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10514
diff changeset
  1093
#endif
da9b7ed81caf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10514
diff changeset
  1094
                __argValues[i].pointerVal = p;
da9b7ed81caf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10514
diff changeset
  1095
            } else {
da9b7ed81caf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10514
diff changeset
  1096
                if (arg == nil) {
da9b7ed81caf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10514
diff changeset
  1097
                    __argValues[i].pointerVal = (void *)0;
da9b7ed81caf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10514
diff changeset
  1098
                } else {
da9b7ed81caf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10514
diff changeset
  1099
                    __FAIL__(@symbol(InvalidArgument))
10440
b643af58f8bf invoking without arguments
fm
parents: 10279
diff changeset
  1100
                }
b643af58f8bf invoking without arguments
fm
parents: 10279
diff changeset
  1101
            }
b643af58f8bf invoking without arguments
fm
parents: 10279
diff changeset
  1102
            argValuePtr = &(__argValues[i].pointerVal);;
9479
68d12a181d4a handle types; sint32 types.
ca
parents: 9466
diff changeset
  1103
10440
b643af58f8bf invoking without arguments
fm
parents: 10279
diff changeset
  1104
        } else if (typeSymbol == @symbol(pointer)) {
9524
2af286bbcac3 *** empty log message ***
ca
parents: 9519
diff changeset
  1105
commonPointerTypeArg: ;
10440
b643af58f8bf invoking without arguments
fm
parents: 10279
diff changeset
  1106
            thisType = __get_ffi_type_pointer();
b643af58f8bf invoking without arguments
fm
parents: 10279
diff changeset
  1107
            if (arg == nil) {
b643af58f8bf invoking without arguments
fm
parents: 10279
diff changeset
  1108
                __argValues[i].pointerVal = NULL;
b643af58f8bf invoking without arguments
fm
parents: 10279
diff changeset
  1109
            } else if (__isExternalAddressLike(arg)) {
b643af58f8bf invoking without arguments
fm
parents: 10279
diff changeset
  1110
                __argValues[i].pointerVal = (void *)(__externalAddressVal(arg));
b643af58f8bf invoking without arguments
fm
parents: 10279
diff changeset
  1111
            } else if (__isExternalBytesLike(arg)) {
b643af58f8bf invoking without arguments
fm
parents: 10279
diff changeset
  1112
                __argValues[i].pointerVal = (void *)(__externalBytesVal(arg));
b643af58f8bf invoking without arguments
fm
parents: 10279
diff changeset
  1113
            } else if (__isByteArray(arg)) {
b643af58f8bf invoking without arguments
fm
parents: 10279
diff changeset
  1114
                if (async == true) goto badArgForAsyncCall;
b643af58f8bf invoking without arguments
fm
parents: 10279
diff changeset
  1115
                __argValues[i].pointerVal = (void *)(__byteArrayVal(arg));
b643af58f8bf invoking without arguments
fm
parents: 10279
diff changeset
  1116
            } else if (__isFloatArray(arg)) {
b643af58f8bf invoking without arguments
fm
parents: 10279
diff changeset
  1117
                if (async == true) goto badArgForAsyncCall;
b643af58f8bf invoking without arguments
fm
parents: 10279
diff changeset
  1118
                __argValues[i].pointerVal = (void *)(__FloatArrayInstPtr(arg)->f_element);
b643af58f8bf invoking without arguments
fm
parents: 10279
diff changeset
  1119
            } else if (__isDoubleArray(arg)) {
b643af58f8bf invoking without arguments
fm
parents: 10279
diff changeset
  1120
                if (async == true) goto badArgForAsyncCall;
b643af58f8bf invoking without arguments
fm
parents: 10279
diff changeset
  1121
                __argValues[i].pointerVal = (void *)(__DoubleArrayInstPtr(arg)->d_element);
b643af58f8bf invoking without arguments
fm
parents: 10279
diff changeset
  1122
            } else if (__isString(arg) || __isSymbol(arg)) {
b643af58f8bf invoking without arguments
fm
parents: 10279
diff changeset
  1123
                if (async == true) {
9435
68f7e39efad7 support of asynchronous calls
ca
parents: 9418
diff changeset
  1124
badArgForAsyncCall: ;
10603
da9b7ed81caf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10514
diff changeset
  1125
                    __FAIL__(@symbol(BadArgForAsyncCall))
10440
b643af58f8bf invoking without arguments
fm
parents: 10279
diff changeset
  1126
                }
b643af58f8bf invoking without arguments
fm
parents: 10279
diff changeset
  1127
                __argValues[i].pointerVal = (void *)(__stringVal(arg));
b643af58f8bf invoking without arguments
fm
parents: 10279
diff changeset
  1128
            } else if (__isBytes(arg)) {
b643af58f8bf invoking without arguments
fm
parents: 10279
diff changeset
  1129
                char *p = (char *)(__byteArrayVal(arg));
b643af58f8bf invoking without arguments
fm
parents: 10279
diff changeset
  1130
                int nInstBytes;
b643af58f8bf invoking without arguments
fm
parents: 10279
diff changeset
  1131
                OBJ cls;
9483
3bea515ce81e *** empty log message ***
fm
parents: 9479
diff changeset
  1132
10512
5a01829213ab *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10484
diff changeset
  1133
                if (async == true) goto badArgForAsyncCall;
10440
b643af58f8bf invoking without arguments
fm
parents: 10279
diff changeset
  1134
                cls = __qClass(arg);
b643af58f8bf invoking without arguments
fm
parents: 10279
diff changeset
  1135
                nInstBytes = __OBJS2BYTES__(__intVal(__ClassInstPtr(cls)->c_ninstvars));
b643af58f8bf invoking without arguments
fm
parents: 10279
diff changeset
  1136
                __argValues[i].pointerVal = p + nInstBytes;
b643af58f8bf invoking without arguments
fm
parents: 10279
diff changeset
  1137
            } else {
10603
da9b7ed81caf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10514
diff changeset
  1138
                __FAIL__(@symbol(InvalidArgument))
10440
b643af58f8bf invoking without arguments
fm
parents: 10279
diff changeset
  1139
            }
b643af58f8bf invoking without arguments
fm
parents: 10279
diff changeset
  1140
            argValuePtr = &(__argValues[i].pointerVal);;
9479
68d12a181d4a handle types; sint32 types.
ca
parents: 9466
diff changeset
  1141
10440
b643af58f8bf invoking without arguments
fm
parents: 10279
diff changeset
  1142
        } else if (typeSymbol == @symbol(bool)) {
b643af58f8bf invoking without arguments
fm
parents: 10279
diff changeset
  1143
            thisType = __get_ffi_type_uint();
9342
e548ce80ab02 virtual calls
Claus Gittinger <cg@exept.de>
parents: 9341
diff changeset
  1144
10440
b643af58f8bf invoking without arguments
fm
parents: 10279
diff changeset
  1145
            if (arg == true) {
b643af58f8bf invoking without arguments
fm
parents: 10279
diff changeset
  1146
                __argValues[i].iVal = 1;
b643af58f8bf invoking without arguments
fm
parents: 10279
diff changeset
  1147
            } else if (arg == false) {
b643af58f8bf invoking without arguments
fm
parents: 10279
diff changeset
  1148
                __argValues[i].iVal = 0;
b643af58f8bf invoking without arguments
fm
parents: 10279
diff changeset
  1149
            } else if (__isSmallInteger(arg)) {
b643af58f8bf invoking without arguments
fm
parents: 10279
diff changeset
  1150
                __argValues[i].iVal = __intVal(arg);
b643af58f8bf invoking without arguments
fm
parents: 10279
diff changeset
  1151
            } else {
b643af58f8bf invoking without arguments
fm
parents: 10279
diff changeset
  1152
                __argValues[i].iVal = __unsignedLongIntVal(arg);
b643af58f8bf invoking without arguments
fm
parents: 10279
diff changeset
  1153
                if (__argValues[i].iVal == 0) {
10603
da9b7ed81caf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10514
diff changeset
  1154
                    __FAIL__(@symbol(InvalidArgument))
10440
b643af58f8bf invoking without arguments
fm
parents: 10279
diff changeset
  1155
                }
b643af58f8bf invoking without arguments
fm
parents: 10279
diff changeset
  1156
            }
b643af58f8bf invoking without arguments
fm
parents: 10279
diff changeset
  1157
            argValuePtr = &(__argValues[i].iVal);
b643af58f8bf invoking without arguments
fm
parents: 10279
diff changeset
  1158
        } else {
b643af58f8bf invoking without arguments
fm
parents: 10279
diff changeset
  1159
            if (__isSymbol(typeSymbol)
b643af58f8bf invoking without arguments
fm
parents: 10279
diff changeset
  1160
             && ((argValueClass = __GLOBAL_GET(typeSymbol)) != nil)) {
b643af58f8bf invoking without arguments
fm
parents: 10279
diff changeset
  1161
                if (! __isBehaviorLike(argValueClass)) {
10603
da9b7ed81caf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10514
diff changeset
  1162
                    __FAIL__(@symbol(NonBehaviorArgumentType))
10440
b643af58f8bf invoking without arguments
fm
parents: 10279
diff changeset
  1163
                }
b643af58f8bf invoking without arguments
fm
parents: 10279
diff changeset
  1164
                if (! __qIsSubclassOfExternalAddress(argValueClass)) {
10603
da9b7ed81caf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10514
diff changeset
  1165
                    __FAIL__(@symbol(NonExternalAddressArgumentType))
10440
b643af58f8bf invoking without arguments
fm
parents: 10279
diff changeset
  1166
                }
b643af58f8bf invoking without arguments
fm
parents: 10279
diff changeset
  1167
                goto commonPointerTypeArg; /* sorry */
b643af58f8bf invoking without arguments
fm
parents: 10279
diff changeset
  1168
            } else {
10603
da9b7ed81caf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10514
diff changeset
  1169
                __FAIL__(@symbol(UnknownArgumentType))
10440
b643af58f8bf invoking without arguments
fm
parents: 10279
diff changeset
  1170
            }
b643af58f8bf invoking without arguments
fm
parents: 10279
diff changeset
  1171
        }
9342
e548ce80ab02 virtual calls
Claus Gittinger <cg@exept.de>
parents: 9341
diff changeset
  1172
10440
b643af58f8bf invoking without arguments
fm
parents: 10279
diff changeset
  1173
        __argTypes[i] = thisType;
b643af58f8bf invoking without arguments
fm
parents: 10279
diff changeset
  1174
        __argValuePointers[i] = argValuePtr;
9483
3bea515ce81e *** empty log message ***
fm
parents: 9479
diff changeset
  1175
9524
2af286bbcac3 *** empty log message ***
ca
parents: 9519
diff changeset
  1176
#ifdef VERBOSE
10440
b643af58f8bf invoking without arguments
fm
parents: 10279
diff changeset
  1177
        printf("arg%d: %x\n", i, __argValues[i].iVal);
9524
2af286bbcac3 *** empty log message ***
ca
parents: 9519
diff changeset
  1178
#endif
9342
e548ce80ab02 virtual calls
Claus Gittinger <cg@exept.de>
parents: 9341
diff changeset
  1179
    }
9465
d11885052713 rewrite & cleanup
Claus Gittinger <cg@exept.de>
parents: 9464
diff changeset
  1180
    failureInfo = nil;
9342
e548ce80ab02 virtual calls
Claus Gittinger <cg@exept.de>
parents: 9341
diff changeset
  1181
e548ce80ab02 virtual calls
Claus Gittinger <cg@exept.de>
parents: 9341
diff changeset
  1182
    __callType = FFI_DEFAULT_ABI;
e548ce80ab02 virtual calls
Claus Gittinger <cg@exept.de>
parents: 9341
diff changeset
  1183
e548ce80ab02 virtual calls
Claus Gittinger <cg@exept.de>
parents: 9341
diff changeset
  1184
#ifdef CALLTYPE_FFI_STDCALL
9465
d11885052713 rewrite & cleanup
Claus Gittinger <cg@exept.de>
parents: 9464
diff changeset
  1185
    if (callTypeNumber == @global(CALLTYPE_API)) {
10440
b643af58f8bf invoking without arguments
fm
parents: 10279
diff changeset
  1186
        __callType = CALLTYPE_FFI_STDCALL;
9342
e548ce80ab02 virtual calls
Claus Gittinger <cg@exept.de>
parents: 9341
diff changeset
  1187
    }
e548ce80ab02 virtual calls
Claus Gittinger <cg@exept.de>
parents: 9341
diff changeset
  1188
#endif
e548ce80ab02 virtual calls
Claus Gittinger <cg@exept.de>
parents: 9341
diff changeset
  1189
#ifdef CALLTYPE_FFI_V8
9465
d11885052713 rewrite & cleanup
Claus Gittinger <cg@exept.de>
parents: 9464
diff changeset
  1190
    if (callTypeNumber == @global(CALLTYPE_V8)) {
10440
b643af58f8bf invoking without arguments
fm
parents: 10279
diff changeset
  1191
        __callType = CALLTYPE_FFI_V8;
9342
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
#endif
e548ce80ab02 virtual calls
Claus Gittinger <cg@exept.de>
parents: 9341
diff changeset
  1194
#ifdef CALLTYPE_FFI_V9
9465
d11885052713 rewrite & cleanup
Claus Gittinger <cg@exept.de>
parents: 9464
diff changeset
  1195
    if (callTypeNumber == @global(CALLTYPE_V9)) {
10440
b643af58f8bf invoking without arguments
fm
parents: 10279
diff changeset
  1196
        __callType = CALLTYPE_FFI_V9;
9342
e548ce80ab02 virtual calls
Claus Gittinger <cg@exept.de>
parents: 9341
diff changeset
  1197
    }
e548ce80ab02 virtual calls
Claus Gittinger <cg@exept.de>
parents: 9341
diff changeset
  1198
#endif
e548ce80ab02 virtual calls
Claus Gittinger <cg@exept.de>
parents: 9341
diff changeset
  1199
#ifdef CALLTYPE_FFI_UNIX64
9465
d11885052713 rewrite & cleanup
Claus Gittinger <cg@exept.de>
parents: 9464
diff changeset
  1200
    if (callTypeNumber == @global(CALLTYPE_UNIX64)) {
10440
b643af58f8bf invoking without arguments
fm
parents: 10279
diff changeset
  1201
        __callType = CALLTYPE_FFI_UNIX64;
9342
e548ce80ab02 virtual calls
Claus Gittinger <cg@exept.de>
parents: 9341
diff changeset
  1202
    }
e548ce80ab02 virtual calls
Claus Gittinger <cg@exept.de>
parents: 9341
diff changeset
  1203
#endif
e548ce80ab02 virtual calls
Claus Gittinger <cg@exept.de>
parents: 9341
diff changeset
  1204
e548ce80ab02 virtual calls
Claus Gittinger <cg@exept.de>
parents: 9341
diff changeset
  1205
    if (ffi_prep_cif(&__cif, __callType, __numArgsIncludingThis, __returnType, __argTypesIncludingThis) != FFI_OK) {
10603
da9b7ed81caf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10514
diff changeset
  1206
        __FAIL__(@symbol(FFIPrepareFailed))
9342
e548ce80ab02 virtual calls
Claus Gittinger <cg@exept.de>
parents: 9341
diff changeset
  1207
    }
9463
864880338d7e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9460
diff changeset
  1208
    if (async == true) {
9524
2af286bbcac3 *** empty log message ***
ca
parents: 9519
diff changeset
  1209
#ifdef VERBOSE
10440
b643af58f8bf invoking without arguments
fm
parents: 10279
diff changeset
  1210
        printf("async call 0x%x\n", codeAddress);
9524
2af286bbcac3 *** empty log message ***
ca
parents: 9519
diff changeset
  1211
#endif
9436
388724e908e3 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9435
diff changeset
  1212
#ifdef WIN32
10440
b643af58f8bf invoking without arguments
fm
parents: 10279
diff changeset
  1213
        __STX_C_CALL4( "ffi_call", ffi_call, &__cif, codeAddress, __returnValuePointer, __argValuePointersIncludingThis);
9436
388724e908e3 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9435
diff changeset
  1214
#else
10440
b643af58f8bf invoking without arguments
fm
parents: 10279
diff changeset
  1215
        __BEGIN_INTERRUPTABLE__
b643af58f8bf invoking without arguments
fm
parents: 10279
diff changeset
  1216
        ffi_call(&__cif, codeAddress, __returnValuePointer, __argValuePointersIncludingThis);
b643af58f8bf invoking without arguments
fm
parents: 10279
diff changeset
  1217
        __END_INTERRUPTABLE__
9436
388724e908e3 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9435
diff changeset
  1218
#endif
9435
68f7e39efad7 support of asynchronous calls
ca
parents: 9418
diff changeset
  1219
    } else {
10440
b643af58f8bf invoking without arguments
fm
parents: 10279
diff changeset
  1220
        if (unlimitedStack == true) {
9524
2af286bbcac3 *** empty log message ***
ca
parents: 9519
diff changeset
  1221
#ifdef VERBOSE
10440
b643af58f8bf invoking without arguments
fm
parents: 10279
diff changeset
  1222
            printf("UNLIMITEDSTACKCALL call 0x%x\n", codeAddress);
9524
2af286bbcac3 *** empty log message ***
ca
parents: 9519
diff changeset
  1223
#endif
9463
864880338d7e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9460
diff changeset
  1224
#if 0
10440
b643af58f8bf invoking without arguments
fm
parents: 10279
diff changeset
  1225
            __UNLIMITEDSTACKCALL__(ffi_call, &__cif, codeAddress, __returnValuePointer, __argValuePointersIncludingThis);
9463
864880338d7e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9460
diff changeset
  1226
#endif
10440
b643af58f8bf invoking without arguments
fm
parents: 10279
diff changeset
  1227
        } else {
9524
2af286bbcac3 *** empty log message ***
ca
parents: 9519
diff changeset
  1228
#ifdef VERBOSE
10440
b643af58f8bf invoking without arguments
fm
parents: 10279
diff changeset
  1229
            printf("call 0x%x\n", codeAddress);
9524
2af286bbcac3 *** empty log message ***
ca
parents: 9519
diff changeset
  1230
#endif
10440
b643af58f8bf invoking without arguments
fm
parents: 10279
diff changeset
  1231
            ffi_call(&__cif, codeAddress, __returnValuePointer, __argValuePointersIncludingThis);
b643af58f8bf invoking without arguments
fm
parents: 10279
diff changeset
  1232
        }
9435
68f7e39efad7 support of asynchronous calls
ca
parents: 9418
diff changeset
  1233
    }
9524
2af286bbcac3 *** empty log message ***
ca
parents: 9519
diff changeset
  1234
#ifdef VERBOSE
2af286bbcac3 *** empty log message ***
ca
parents: 9519
diff changeset
  1235
    printf("retval is %d (0x%x)\n", __returnValue.iVal, __returnValue.iVal);
2af286bbcac3 *** empty log message ***
ca
parents: 9519
diff changeset
  1236
#endif
9479
68d12a181d4a handle types; sint32 types.
ca
parents: 9466
diff changeset
  1237
    if ((returnTypeSymbol == @symbol(sint))
68d12a181d4a handle types; sint32 types.
ca
parents: 9466
diff changeset
  1238
     || (returnTypeSymbol == @symbol(sint8))
68d12a181d4a handle types; sint32 types.
ca
parents: 9466
diff changeset
  1239
     || (returnTypeSymbol == @symbol(sint16))
68d12a181d4a handle types; sint32 types.
ca
parents: 9466
diff changeset
  1240
     || (returnTypeSymbol == @symbol(sint32))) {
10440
b643af58f8bf invoking without arguments
fm
parents: 10279
diff changeset
  1241
        RETURN ( __MKINT(__returnValue.iVal) );
9342
e548ce80ab02 virtual calls
Claus Gittinger <cg@exept.de>
parents: 9341
diff changeset
  1242
    }
e548ce80ab02 virtual calls
Claus Gittinger <cg@exept.de>
parents: 9341
diff changeset
  1243
    if ((returnTypeSymbol == @symbol(uint))
e548ce80ab02 virtual calls
Claus Gittinger <cg@exept.de>
parents: 9341
diff changeset
  1244
     || (returnTypeSymbol == @symbol(uint8))
e548ce80ab02 virtual calls
Claus Gittinger <cg@exept.de>
parents: 9341
diff changeset
  1245
     || (returnTypeSymbol == @symbol(uint16))
e548ce80ab02 virtual calls
Claus Gittinger <cg@exept.de>
parents: 9341
diff changeset
  1246
     || (returnTypeSymbol == @symbol(uint32))) {
10440
b643af58f8bf invoking without arguments
fm
parents: 10279
diff changeset
  1247
        RETURN ( __MKUINT(__returnValue.iVal) );
9342
e548ce80ab02 virtual calls
Claus Gittinger <cg@exept.de>
parents: 9341
diff changeset
  1248
    }
10025
053904a63549 stc-compiled ExternalLibraryFunctions
Claus Gittinger <cg@exept.de>
parents: 9981
diff changeset
  1249
    if (returnTypeSymbol == @symbol(bool)) {
10440
b643af58f8bf invoking without arguments
fm
parents: 10279
diff changeset
  1250
        RETURN ( __returnValue.iVal ? true : false );
9342
e548ce80ab02 virtual calls
Claus Gittinger <cg@exept.de>
parents: 9341
diff changeset
  1251
    }
e548ce80ab02 virtual calls
Claus Gittinger <cg@exept.de>
parents: 9341
diff changeset
  1252
    if (returnTypeSymbol == @symbol(float)) {
10440
b643af58f8bf invoking without arguments
fm
parents: 10279
diff changeset
  1253
        RETURN ( __MKFLOAT(__returnValue.fVal ));
9342
e548ce80ab02 virtual calls
Claus Gittinger <cg@exept.de>
parents: 9341
diff changeset
  1254
    }
e548ce80ab02 virtual calls
Claus Gittinger <cg@exept.de>
parents: 9341
diff changeset
  1255
    if (returnTypeSymbol == @symbol(double)) {
10440
b643af58f8bf invoking without arguments
fm
parents: 10279
diff changeset
  1256
        RETURN ( __MKFLOAT(__returnValue.dVal ));
9342
e548ce80ab02 virtual calls
Claus Gittinger <cg@exept.de>
parents: 9341
diff changeset
  1257
    }
e548ce80ab02 virtual calls
Claus Gittinger <cg@exept.de>
parents: 9341
diff changeset
  1258
    if (returnTypeSymbol == @symbol(void)) {
10440
b643af58f8bf invoking without arguments
fm
parents: 10279
diff changeset
  1259
        RETURN ( nil );
9342
e548ce80ab02 virtual calls
Claus Gittinger <cg@exept.de>
parents: 9341
diff changeset
  1260
    }
9463
864880338d7e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9460
diff changeset
  1261
    if (returnTypeSymbol == @symbol(char)) {
10440
b643af58f8bf invoking without arguments
fm
parents: 10279
diff changeset
  1262
        RETURN ( __MKCHARACTER(__returnValue.iVal & 0xFF) );
9463
864880338d7e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9460
diff changeset
  1263
    }
864880338d7e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9460
diff changeset
  1264
    if (returnTypeSymbol == @symbol(wchar)) {
10440
b643af58f8bf invoking without arguments
fm
parents: 10279
diff changeset
  1265
        RETURN ( __MKUCHARACTER(__returnValue.iVal & 0xFFFF) );
9463
864880338d7e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9460
diff changeset
  1266
    }
10614
1950ab5c9214 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10603
diff changeset
  1267
printf("%x\n", __returnValue.pointerVal);
9346
a95e2cf0e56f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9344
diff changeset
  1268
    if (returnTypeSymbol == @symbol(handle)) {
10440
b643af58f8bf invoking without arguments
fm
parents: 10279
diff changeset
  1269
        returnValue = __MKEXTERNALADDRESS(__returnValue.pointerVal);
9346
a95e2cf0e56f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9344
diff changeset
  1270
    } else if (returnTypeSymbol == @symbol(pointer)) {
10440
b643af58f8bf invoking without arguments
fm
parents: 10279
diff changeset
  1271
        returnValue = __MKEXTERNALBYTES(__returnValue.pointerVal);
10603
da9b7ed81caf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10514
diff changeset
  1272
    } else if (returnTypeSymbol == @symbol(bytePointer)) {
da9b7ed81caf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10514
diff changeset
  1273
        returnValue = __MKEXTERNALBYTES(__returnValue.pointerVal);
9463
864880338d7e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9460
diff changeset
  1274
    } else if (returnTypeSymbol == @symbol(charPointer)) {
10440
b643af58f8bf invoking without arguments
fm
parents: 10279
diff changeset
  1275
        returnValue = __MKSTRING(__returnValue.pointerVal);
9463
864880338d7e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9460
diff changeset
  1276
    } else if (returnTypeSymbol == @symbol(wcharPointer)) {
10440
b643af58f8bf invoking without arguments
fm
parents: 10279
diff changeset
  1277
        returnValue = __MKU16STRING(__returnValue.pointerVal);
9342
e548ce80ab02 virtual calls
Claus Gittinger <cg@exept.de>
parents: 9341
diff changeset
  1278
    } else {
10603
da9b7ed81caf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10514
diff changeset
  1279
        __FAIL__(@symbol(UnknownReturnType2))
9342
e548ce80ab02 virtual calls
Claus Gittinger <cg@exept.de>
parents: 9341
diff changeset
  1280
    }
10603
da9b7ed81caf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10514
diff changeset
  1281
#else /* no FFI support */
10618
343d0bf4646a Now can compile even #ifndef HAVE_FFI
Stefan Vogel <sv@exept.de>
parents: 10614
diff changeset
  1282
    failureCode = @symbol(FFINotSupported);
10603
da9b7ed81caf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10514
diff changeset
  1283
#endif /* HAVE_FFI */
9342
e548ce80ab02 virtual calls
Claus Gittinger <cg@exept.de>
parents: 9341
diff changeset
  1284
getOutOfHere: ;
e548ce80ab02 virtual calls
Claus Gittinger <cg@exept.de>
parents: 9341
diff changeset
  1285
%}.
e548ce80ab02 virtual calls
Claus Gittinger <cg@exept.de>
parents: 9341
diff changeset
  1286
    failureCode notNil ifTrue:[
10603
da9b7ed81caf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10514
diff changeset
  1287
        self primitiveFailed.   "see failureCode and failureInfo for details"
10440
b643af58f8bf invoking without arguments
fm
parents: 10279
diff changeset
  1288
        ^ nil
9342
e548ce80ab02 virtual calls
Claus Gittinger <cg@exept.de>
parents: 9341
diff changeset
  1289
    ].
e548ce80ab02 virtual calls
Claus Gittinger <cg@exept.de>
parents: 9341
diff changeset
  1290
9483
3bea515ce81e *** empty log message ***
fm
parents: 9479
diff changeset
  1291
    returnType isSymbol ifTrue:[
10440
b643af58f8bf invoking without arguments
fm
parents: 10279
diff changeset
  1292
        returnValueClass notNil ifTrue:[
b643af58f8bf invoking without arguments
fm
parents: 10279
diff changeset
  1293
            self isConstReturnValue ifTrue:[
b643af58f8bf invoking without arguments
fm
parents: 10279
diff changeset
  1294
                returnValue changeClassTo:returnValueClass.
b643af58f8bf invoking without arguments
fm
parents: 10279
diff changeset
  1295
                ^ returnValue
b643af58f8bf invoking without arguments
fm
parents: 10279
diff changeset
  1296
            ].
b643af58f8bf invoking without arguments
fm
parents: 10279
diff changeset
  1297
            ^ returnValueClass fromExternalAddress:returnValue.
b643af58f8bf invoking without arguments
fm
parents: 10279
diff changeset
  1298
        ].
9483
3bea515ce81e *** empty log message ***
fm
parents: 9479
diff changeset
  1299
    ] ifFalse:[
10440
b643af58f8bf invoking without arguments
fm
parents: 10279
diff changeset
  1300
        returnType isCPointer ifTrue:[
b643af58f8bf invoking without arguments
fm
parents: 10279
diff changeset
  1301
            returnType baseType isCStruct ifTrue:[
b643af58f8bf invoking without arguments
fm
parents: 10279
diff changeset
  1302
                stClass := Smalltalk classNamed:returnType baseType name.
b643af58f8bf invoking without arguments
fm
parents: 10279
diff changeset
  1303
                stClass notNil ifTrue:[
b643af58f8bf invoking without arguments
fm
parents: 10279
diff changeset
  1304
                    self isConstReturnValue ifTrue:[
b643af58f8bf invoking without arguments
fm
parents: 10279
diff changeset
  1305
                        returnValue changeClassTo:returnValueClass.
b643af58f8bf invoking without arguments
fm
parents: 10279
diff changeset
  1306
                        ^ returnValue
b643af58f8bf invoking without arguments
fm
parents: 10279
diff changeset
  1307
                    ].
b643af58f8bf invoking without arguments
fm
parents: 10279
diff changeset
  1308
                    ^ stClass fromExternalAddress:returnValue.
b643af58f8bf invoking without arguments
fm
parents: 10279
diff changeset
  1309
                ].
b643af58f8bf invoking without arguments
fm
parents: 10279
diff changeset
  1310
            ].
b643af58f8bf invoking without arguments
fm
parents: 10279
diff changeset
  1311
            returnType baseType isCChar ifTrue:[
b643af58f8bf invoking without arguments
fm
parents: 10279
diff changeset
  1312
                ^ returnValue stringAt:1
b643af58f8bf invoking without arguments
fm
parents: 10279
diff changeset
  1313
            ].
b643af58f8bf invoking without arguments
fm
parents: 10279
diff changeset
  1314
        ].
9342
e548ce80ab02 virtual calls
Claus Gittinger <cg@exept.de>
parents: 9341
diff changeset
  1315
    ].
e548ce80ab02 virtual calls
Claus Gittinger <cg@exept.de>
parents: 9341
diff changeset
  1316
e548ce80ab02 virtual calls
Claus Gittinger <cg@exept.de>
parents: 9341
diff changeset
  1317
    ^ returnValue
9463
864880338d7e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9460
diff changeset
  1318
864880338d7e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9460
diff changeset
  1319
    "Created: / 01-08-2006 / 13:56:23 / cg"
10603
da9b7ed81caf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10514
diff changeset
  1320
    "Modified: / 11-06-2007 / 01:50:36 / cg"
9342
e548ce80ab02 virtual calls
Claus Gittinger <cg@exept.de>
parents: 9341
diff changeset
  1321
! !
e548ce80ab02 virtual calls
Claus Gittinger <cg@exept.de>
parents: 9341
diff changeset
  1322
10481
b3526180579f +isExternalLibraryFunction
fm
parents: 10440
diff changeset
  1323
!ExternalLibraryFunction methodsFor:'testing'!
b3526180579f +isExternalLibraryFunction
fm
parents: 10440
diff changeset
  1324
10603
da9b7ed81caf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10514
diff changeset
  1325
isExternalLibraryFunction
da9b7ed81caf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10514
diff changeset
  1326
    "return true, if the receiver is some kind of externalLibrary function;
da9b7ed81caf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10514
diff changeset
  1327
     true is returned here"
da9b7ed81caf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10514
diff changeset
  1328
da9b7ed81caf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10514
diff changeset
  1329
    ^true
da9b7ed81caf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10514
diff changeset
  1330
da9b7ed81caf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10514
diff changeset
  1331
    "Created: / 07-06-2007 / 10:36:40 / cg"
10481
b3526180579f +isExternalLibraryFunction
fm
parents: 10440
diff changeset
  1332
! !
b3526180579f +isExternalLibraryFunction
fm
parents: 10440
diff changeset
  1333
8533
9065c547ea75 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1334
!ExternalLibraryFunction class methodsFor:'documentation'!
9065c547ea75 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1335
9065c547ea75 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1336
version
10674
400b8823c2df changed #invokeFFIwithArguments:forCPPInstance:
Stefan Vogel <sv@exept.de>
parents: 10625
diff changeset
  1337
    ^ '$Header: /cvs/stx/stx/libbasic/ExternalLibraryFunction.st,v 1.60 2007-08-02 10:00:58 stefan Exp $'
8533
9065c547ea75 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1338
! !
9463
864880338d7e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9460
diff changeset
  1339
864880338d7e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9460
diff changeset
  1340
ExternalLibraryFunction initialize!