CX Framework
Cross-platform C utility framework
Loading...
Searching...
No Matches
Callback Handles

Macros

#define callbackGetHandle(cbtype, func)   _callbackGetHandle(#cbtype, (GenericCallback)((cbtype)func))
 
#define callbackGetFunc(cbtype, handle)   ((cbtype)_callbackGetFunc(#cbtype, handle))
 

Typedefs

typedef void(* GenericCallback) ()
 Generic callback function pointer type.
 

Detailed Description

Deprecated:
This module is deprecated. Use Closures or Closure Chains instead.

Generic callback handle system for storing and retrieving function pointers with type safety.

This older system converts function pointers to integer handles that can be stored and retrieved later. It provides basic type checking by storing the function signature as a string.

Why this is deprecated:

For new code, use:

See also
Closures
Closure Chains

Macro Definition Documentation

◆ callbackGetFunc

#define callbackGetFunc (   cbtype,
  handle 
)    ((cbtype)_callbackGetFunc(#cbtype, handle))

cbtype callbackGetFunc(cbtype, handle)

Retrieve a typed function pointer from a handle.

Looks up the function pointer associated with the handle and verifies the type matches. Returns NULL if the handle is invalid or the type doesn't match.

Deprecated:
Use closures or closure chains instead.
Parameters
cbtypeExpected function pointer type
handleHandle returned by callbackGetHandle()
Returns
Function pointer cast to cbtype, or NULL if invalid/type mismatch

Definition at line 66 of file cbhandle.h.

◆ callbackGetHandle

#define callbackGetHandle (   cbtype,
  func 
)    _callbackGetHandle(#cbtype, (GenericCallback)((cbtype)func))

int callbackGetHandle(cbtype, func)

Convert a typed function pointer to an integer handle.

Stores the function pointer internally and returns a handle that can be used to retrieve it later. The function signature type is stored for basic type checking.

Deprecated:
Use closureCreate() instead to capture a callback with environment.
Parameters
cbtypeFunction pointer type (e.g., myCallbackType)
funcFunction pointer to store
Returns
Integer handle (0 if func is NULL)

Definition at line 52 of file cbhandle.h.