Platforms to show: All Mac Windows Linux Cross-Platform
DeclareCallBackMBS class
Type | Topic | Plugin | Version | macOS | Windows | Linux | iOS | Targets |
class | DynamicDeclares | MBS Util Plugin | 20.3 | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes | All |
Allows you to dynamically create callback functions.
Pass the function pointer to a C function which later calls back your callback.
Please make sure this callback object stays alive, e.g. stored in a global property. When the object is released and the callback later invoked, the application will crash.
When you code sign on macOS, you may need to use the entitlement for just-in-time compiler and for unsigned executable memory, e.g. the com.apple.security.cs.allow-unsigned-executable-memory entitlement.
- event Callback(Parameters() as Variant) as Variant
- 12 properties
- property AllowAsync as Boolean
- property CallCount as Integer
- property FunctionPtr as Ptr
- property Name as String
- property ParameterCount as Integer
- property Signature as String
- property SignatureParameters as String
- property SignatureReturn as String
- property Tag as Variant
- property ParameterCFRetain(Index as Integer) as Boolean
- property ParameterCopyString(Index as Integer) as Boolean
- property ParameterNSRetain(Index as Integer) as Boolean
- 2 methods
- method Constructor(Signature as String)
- method ParameterType(Index as Integer) as String
- 31 constants
Call Modes
Constant | Value | Description |
---|---|---|
kCallModeARM | "A" |
ARM calling |
kCallModeARMThumb | "a" |
ARM calling in thumb mode |
kCallModeCDecl | "c" |
x86 specific CDecl |
kCallModeDefault | ":" |
Default calling conv (platform native) |
kCallModeEllipsisVarargs | "." |
C ellipsis function call (variable/unnamed arguments (after ’...’)) |
kCallModeSysCall | "$" |
SysCall mode |
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.
Blog Entries
- MBS Xojo Plugins, version 21.2pr1
- MonkeyBread Software Releases the MBS Xojo Plugins in version 21.1
- MBS Xojo Plugins, version 21.1pr7
- 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
Xojo Developer Magazine
- 21.1, page 28: News from MBS Xojo Plugins, What's up with MonkeyBread Software by Stefanie Juchmes
- 19.3, page 10: News
Release notes
- Version 21.2
- Rewrote DeclareCallBackMBS with a thread safe queue for asynchron mode.
- Version 21.1
- Improved DeclareCallBackMBS class to handle asynchronously dispatch on Windows and Linux.
- Version 20.3
- Added DeclareCallBackMBS, DeclareLibraryMBS and DeclareFunctionMBS classes.
Some examples using this class:
Some related classes:
The items on this page are in the following plugins: MBS Util Plugin.
DDEStringPairMBS - DeclareFunctionMBS
