Platforms to show: All Mac Windows Linux Cross-Platform
DeclareFunctionMBS class
Type | Topic | Plugin | Version | macOS | Windows | Linux | iOS | Targets |
class | DynamicDeclares | MBS Util Plugin | 20.3 | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes | All |
Compared to built-in declares in Xojo, those functions allow a much more dynamic calling of functions with various calling conventions.
We have
- more dynamic
- the possibility to define declares at runtime
- more calling conventions
- support for variable arguments in C (dots in argument list)
- thread safe callbacks with DeclareCallBackMBS class.
- 18 properties
- property CallCount as Integer
- property CallMode as Integer
- property FunctionPtr as Ptr
- property Name as String
- property ParameterCount as Integer
- property Parameters as Dictionary
- property Signature as String
- property SignatureParameters as String
- property SignatureReturn as String
- property StackSize as Integer
- property Tag as Variant
- property ParameterBoolean(Index as Integer) as Boolean
- property ParameterDouble(Index as Integer) as Double
- property ParameterInteger(Index as Integer) as Int64
- property ParameterPointer(Index as Integer) as Ptr
- property ParameterSingle(Index as Integer) as Single
- property ParameterString(Index as Integer) as String
- property ParameterValue(Index as Integer) as Variant
- 6 methods
- method ClearParameters
- method Constructor(Signature as String, FunctionPtr as Ptr)
- method Invoke as Variant
- method Invoke(Parameters() as Variant) as Variant
- method SetParameters(paramArray Parameters as Variant)
- method SetParameters(Parameters() as Variant)
- 49 constants
Call Modes
Constant | Value | Description |
---|---|---|
kCallModeARM | "A" |
ARM calling |
kCallModeARMThumb | "a" |
ARM calling in thumb mode |
kCallModeCArm64 | 22 |
C arm64 call (AArch64) |
kCallModeCArmArmhf | 30 |
C arm call (arm hardfloat - e.g. raspberry pi) |
kCallModeCDecl | "c" |
x86 specific CDecl |
kCallModeCDefault | 0 |
C default function call for current platform |
kCallModeCDefaultThis | 99 |
C default function call for current platform with this pointer. |
kCallModeCEllipsis | 100 |
C ellipsis function call (named arguments (before ’...’)) |
kCallModeCEllipsisVarargs | 101 |
C ellipsis function call (variable/unnamed arguments (after ’...’)) |
kCallModeCX64Win64 | 7 |
C x64 Windows standard call |
kCallModeCX86Cdecl | 1 |
C x86 platforms standard call |
kCallModeCX86Win32FastGnu | 4 |
C x86 Windows GCC fast call |
kCallModeCX86Win32FastMs | 3 |
C x86 Windows Microsoft fast call |
kCallModeCX86Win32Std | 2 |
C x86 Windows standard call |
kCallModeCX86Win32This | 70 |
C ellipsis function call (variable/unnamed arguments (after ’...’)) |
kCallModeCX86Win32ThisGnu | 1 |
C x86 Windows GCC this call |
kCallModeCX86Win32ThisMs | 5 |
C x86 Windows Microsoft this call |
kCallModeDefault | ":" |
Default calling conv (platform native) |
kCallModeEllipsisVarargs | "." |
C ellipsis function call (variable/unnamed arguments (after ’...’)) |
kCallModeSysCall | "$" |
SysCall mode |
kCallModeSysDefault | 200 |
C default syscall for current platform |
kCallModeSysX64SyscallSysV | 204 |
C syscall for x64 System V platforms |
kCallModeSysX86Int80HBSD | 202 |
C syscall for x86 BSD platforms |
kCallModeSysX86Int80HLinux | 201 |
C syscall for x86 Linux |
kCallModeThisCallGNU | "#" |
x86 specific, GNU C++ this calls are cdecl, but keep specific sig char for clarity. |
Calling Conventions
Constant | Value | Description |
---|---|---|
kCallModeEllipsis | "e" |
C ellipsis function call |
kCallModeFastCallGNU | "f" |
C x86 Windows GCC fast call |
kCallModeFastCallMS | "F" |
C x86 Windows Microsoft fast call |
kCallModePrefix | "_" |
The character to indicate that next character in the signature is a calling convention prefix. |
kCallModeStdCall | "s" |
C x86 Windows standard call |
kCallModeThisCallMS | "+" |
C x86 Windows Microsoft this call |
Types
Constant | Value | Description |
---|---|---|
kTypeBool | "B" |
bool |
kTypeChar | "c" |
char, 8 bit signed byte |
kTypeDouble | "d" |
Double, 64-bit and 8 bytes big. |
kTypeEndArg | ")" |
end of arguments symbol. |
kTypeFloat | "f" |
Single, 32-bit and 4 bytes big. |
kTypeInt | "i" |
32-bit signed integer. |
kTypeInt64 | "l" |
64-bit signed integer. |
kTypeLong | "j" |
32/64-bit signed integer. 64-bit only for MacOS and Linux in 64-bit application. Always 32-bit on Windows. |
kTypePtr | "p" |
Pointer. Maybe a reference to an object or array. |
kTypeShort | "s" |
16-bit signed integer. |
kTypeString | "Z" |
C String with zero byte as terminator. |
kTypeStruct | "T" |
Structure |
kTypeUnsignedChar | "C" |
8 bit unsigned byte |
kTypeUnsignedInt | "I" |
32-bit unsigned integer. |
kTypeUnsignedInt64 | "L" |
64-bit unsigned integer. |
kTypeUnsignedLong | "J" |
32/64-bit unsigned integer. 64-bit only for MacOS and Linux in 64-bit application. Always 32-bit on Windows. |
kTypeUnsignedShort | "S" |
16-bit unsigned integer. |
kTypeVoid | "v" |
Nothing to return. |
This class has no sub classes.
Some examples using this class:
Blog Entries
- MBS Xojo Plugins, version 24.1pr1
- News from the MBS Xojo Plugins Version 20.3
- MonkeyBread Software Releases the MBS Xojo Plugins in version 20.3
- Dynamic Declare for Xojo
- MBS Xojo Plugins, version 20.3pr1
Release notes
- Version 24.1
- Added new kCallMode* constants for DeclareFunctionMBS class.
- Version 20.3
- Added DeclareCallBackMBS, DeclareLibraryMBS and DeclareFunctionMBS classes.
The items on this page are in the following plugins: MBS Util Plugin.
DeclareCallBackMBS - DeclareLibraryMBS