Add support for defining variadic callbacks via ctypes
Nessuno ha ancora preso questa issue.
- Lingua principale
- Python
- Stelle
- 77.2k
- Fork
- 35.9k
- Metriche di merge delle PR
- Metriche PR in attesa
Descrizione
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
Guida per i contributori
Apri la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Direzione di ricerca
Inizia dal punto di ingresso del callback ctypes CFUNCTYPE e dall’esempio di callback variadico in C nell’issue. Chiarisci la rappresentazione e il comportamento supportati per gli argomenti variadici, quindi determina quali test sono necessari per dimostrare che la definizione e l’invocazione di un callback di questo tipo funzionano.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- c, python
- Ambito
- api
- Tipo di issue
- Funzionalità
- Difficoltà
- 5/5
- Tempo stimato
- Più di una settimana
- Stato di attività
- Ferma
- Chiarezza
- Da chiarire
- Idoneità per principianti
- 30/100