eXept Software AG Logo

Smalltalk/X Webserver

Documentation of class 'ExternalLibraryFunction':

Home

everywhere
www.exept.de
for:
[back]

Class: ExternalLibraryFunction


Inheritance:

   Object
   |
   +--ExecutableFunction
      |
      +--ExternalFunction
         |
         +--ExternalLibraryFunction

Package:
stx:libbasic
Category:
System-Support
Version:
rev: 1.78 date: 2010/02/02 15:44:48
user: cg
file: ExternalLibraryFunction.st directory: libbasic
module: stx stc-classLibrary: libbasic

Description:


instances of me are used to interface to external library functions (as found in a dll/shared object).

Inside a method, when a special external-call pragma such as:
    <api: bool MessageBeep(uint)>

is encountered by the parser, the compiler generates a call via
    <correspondingExternalLibraryFunctionObject> invokeWithArguments: argumentArray.

In the invoke method, the library is checked to be loaded (and loaded if not already),
the arguments are converted to C and pushed onto the C-stack, the function is called,
and finally, the return value is converted back from C to a smalltalk object.

The parser supports the call-syntax of various other smalltalk dialects:
    Squeak / ST-X:
        <cdecl:   [async] [virtual|nonVirtual][const] returnType functionNameStringOrIndex ( argType1..argTypeN ) module: moduleName > 
        <apicall: [async] [virtual|nonVirtual][const] returnType functionNameStringOrIndex ( argType1..argTypeN ) module: moduleName >

    Dolphin:
        <stdcall: [virtual|nonVirtual][const] returnType functionNameStringOrIndex argType1..argTypeN>
        <cdecl:   [virtual|nonVirtual][const] returnType functionNameStringOrIndex argType1..argTypeN> 

    ST/V:
        <api: functionName argType1 .. argTypeN returnType> 
        <ccall: functionName argType1 .. argTypeN returnType> 
        <ole: vFunctionIndex argType1 .. argTypeN returnType>

    VisualWorks:
        <c: ...>
        <c: #define NAME value>


Class protocol:

class initialization
o  addToDllPath: aDirectoryPathName
can be used during initialization, to add more places for dll-loading

o  dllPath

o  dllPath: aCollectionOfDirectoryPathNames

o  initialize
using inline access to corresponding c--defines to avoid duplicate places of knowledge

o  removeFromDllPath: aDirectoryPathName
remove added places from dll-loading

constants
o  callTypeAPI

o  callTypeC

o  callTypeCDecl

o  callTypeMASK

o  callTypeOLE

instance creation
o  name: functionName module: moduleName returnType: returnType argumentTypes: argTypes


Instance protocol:

accessing
o  argumentTypes

o  argumentTypesString

o  beAsync
let this execute in a separate thread, in par with the other execution thread(s).
Ignored under unix/linux (until those support multiple threads too).

o  beCallTypeAPI

o  beCallTypeC

o  beCallTypeOLE

o  beCallTypeUNIX64

o  beCallTypeV8

o  beCallTypeV9

o  beCallTypeWINAPI

o  beConstReturnValue
specify that a pointer return value is not to be finalized
(i.e. points to static data or data which is freed by c)

o  beNonVirtualCPP
specify this as a non-virtual c++-function

o  beUnlimitedStack
let this execute on the c-stack (as opposed to the thread-stack)
for unlimited auto-sized-stack under unix/linux.
Ignored under windows.

o  beVirtualCPP
specify this as a virtual c++-function

o  callTypeNumber

o  isAsync
is this executed in a separate thread, in par with the other execution thread(s) ?

o  isCPPFunction
is this a virtual or non-virtual c++-function ?

o  isCallTypeAPI

o  isCallTypeC

o  isCallTypeOLE

o  isConstReturnValue
is the pointer return value not to be finalized
(i.e. points to static data or data which is freed by c)

o  isNonVirtualCPP
is this a non-virtual c++-function ?

o  isUnlimitedStack
will this execute on the c-stack (as opposed to the thread-stack)
for unlimited auto-sized-stack under unix/linux.
Ignored under windows.

o  isVirtualCPP
is this a virtual c++-function ?

o  moduleName

o  returnType

o  vtableIndex

invoking
o  invoke

o  invokeCPPVirtualOn: anInstance

o  invokeCPPVirtualOn: instance with: arg

o  invokeCPPVirtualOn: instance with: arg1 with: arg2

o  invokeCPPVirtualOn: instance with: arg1 with: arg2 with: arg3

o  invokeCPPVirtualOn: instance with: arg1 with: arg2 with: arg3 with: arg4

o  invokeCPPVirtualOn: instance withArguments: args

o  invokeWith: arg

o  invokeWith: arg1 with: arg2

o  invokeWith: arg1 with: arg2 with: arg3

o  invokeWith: arg1 with: arg2 with: arg3 with: arg4

o  invokeWithArguments: argArray

printing
o  printOn: aStream

private
o  adjustTypes

o  linkToModule
link this function to the external module.
I.e. retrieve the module handle and the code pointer.

o  loadLibrary: dllName

o  prepareInvoke

private-accessing
o  ffiTypeSymbolForType: aType
map type to one of the ffi-supported ones:
sint8, sint16, sint32, sint64
uint8, uint16, uint32, uint64
bool void pointer handle

o  name: functionNameOrVirtualIndex module: aModuleName returnType: aReturnType argumentTypes: argTypes

o  owningClass

o  owningClass: aClass

o  setModuleName: aModuleName

private-invoking
o  invokeCPPVirtualFFIOn: instance withArguments: arguments

o  invokeFFIWithArguments: arguments

o  invokeFFIwithArguments: argumentsOrNil forCPPInstance: aCPlusPlusObjectOrNil

testing
o  isExternalLibraryFunction
return true, if the receiver is some kind of externalLibrary function;
true is returned here



ST/X 6.1.1; WebServer 1.620 at exept:8081; Wed, 23 May 2012 09:07:42 GMT