Define variable-length array type for C

Aperta
#191 6 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
5/5
Tempo stimato
Più di una settimana
Idoneità per principianti
18/100
Tipo di issue
Funzionalità
Chiarezza
Da chiarire
Stato di attività
Ferma
Stack tecnologico
c, python
Ambito
backend

Direzione di ricerca

The issue proposes --no-static-arrays and a user-supplied vector protocol, but names no implementation files or tests. Start by locating the C code-generation templates and deserialization routines, then assess how generated array types are represented. Done would require an agreed design and implementation for variable-length arrays; the issue leaves that design open.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

feature

This is a proposal to allow generation of a variable-length array type in C leaving the implementation up to the user.

For example, the standard Quaternion type:


typedef struct
{
    /// saturated float32[4] wxyz
    float wxyz[4];
} uavcan_si_unit_angle_Quaternion_1_0;

when using the proposed language option of `--no-static-arrays' could be generated like this:

typedef struct
{
    /// saturated float32[4] wxyz
    float* wxyz;
    size_t wxyz_len;
} uavcan_si_unit_angle_Quaternion_1_0;

An alternative, that would be more complex but would require less unsafe pointer magic, is to create a Vector protocol. Something like this:

typedef NunavutVectorType_Float
{
    float* data;
    size_t length;
    size_t max_length;
    bool (*resize)(NunavutVectorType_Float*, size_t);
} NunavutVector_Float;

extern NunavutVector_Float* init_nunavut_vector_float(NunavutVector_Float*);

NunavutVector_Float then must be supplied by the user (the linker will enforce this) and the user must provide the resize method which will be called by deserialization routines when Nunavut needs more memory.

This is a half-baked proposal to encourage a discussion. Please comment.

Lingua principale
Python
Stelle
48
Fork
26
Merge medio
1g 18h
PR unite (30g)
9

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di OpenCyphal/nunavut

Tutte le issue di OpenCyphal/nunavut

Issue simili

Altre issue su Python

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.