-
-
Notifications
You must be signed in to change notification settings - Fork 32.4k
Open
Labels
extension-modulesC modules in the Modules dirC modules in the Modules dirtopic-ctypestype-featureA feature request or enhancementA feature request or enhancement
Description
Feature or enhancement
Proposal:
When defining a callback with ctypes (CFUNCTYPE) it would be helpful to be able to replicate variadic functionality
for instance, take the following c code
void FormatPrintf(datap* format, char* fmt, ...) {
va_list args;
int length = 0;
va_start(args, fmt);
length = vsnprintf(NULL, 0, fmt, args);
va_end(args);
if (format->length + length > format->size) {
return;
}
va_start(args, fmt);
(void)vsnprintf(format->buffer, length, fmt, args);
va_end(args);
return;
}
Making something compatible with ctypes
@CFUNCTYPE(None, ctypes.POINTER(datap), ctypes.c_char_p, ctypes.c_variadic)
def FormatPrintf(format, fmt, variadic)
args = variadic.va_list
...
Maybe even could be handled as a pyobject list of ctypes objects as the variadic on the python side. Not sure what all the options are explicitly.
Has this already been discussed elsewhere?
No response given
Links to previous discussion of this feature:
No response
Metadata
Metadata
Assignees
Labels
extension-modulesC modules in the Modules dirC modules in the Modules dirtopic-ctypestype-featureA feature request or enhancementA feature request or enhancement