bytecodealliance / bytecodealliance/wit-bindgen

Suggest: generate `drop`, `new` and `rep` for aliased handle types

Aperta
#763 1 commento 0 reazioni 0 assegnatari Vedi su GitHub
gen-c
Lingua principale
Rust
Stelle
1.5k
Fork
286
Merge medio
6h 32m
PR unite (30g)
19

Descrizione

In `tests/codegen/resource-alias.wit`, we generate handle types for each alias.

```C
typedef exports_my_resources_e1_own_x_t exports_my_resources_e2_own_x_t;

typedef exports_my_resources_e1_borrow_x_t exports_my_resources_e2_borrow_x_t;
```

However, we only generate helper functions for `e1`, not for `e2`.

```C
extern void exports_my_resources_e1_x_drop_own(exports_my_resources_e1_own_x_t handle);
extern void exports_my_resources_e1_x_drop_borrow(exports_my_resources_e1_own_x_t handle);
extern exports_my_resources_e1_own_x_t exports_my_resources_e1_x_new(exports_my_resources_e1_x_t *rep);
extern exports_my_resources_e1_x_t* exports_my_resources_e1_x_rep(exports_my_resources_e1_own_x_t handle);
void exports_my_resources_e1_x_destructor(exports_my_resources_e1_x_t *rep);

```

If feels pretty strange from user perspectives that even though we are working inside interface `e2`, but we have to call functions with interface name `e1` to create `own` and `borrow` handle types.

Suggestion: we generate the same set of helper functions for aliased handle types.

Thoughts? @alexcrichton @dicej

Guida per i contributori

Nessuna guida per i contributori indicizzata per questo repository

Direzione di ricerca

Inizia da tests/codegen/resource-alias.wit e ispeziona le dichiarazioni C generate per gli alias e1 ed e2. Confronta le funzioni helper generate per ciascuna interfaccia. Il lavoro è completato quando gli aliased handle types ricevono le stesse funzioni helper drop, new, rep e destructor con il nome dell’interfaccia e2.

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

Valutazione

Stack tecnologico
c, rust
Ambito
tooling
Tipo di issue
Funzionalità
Difficoltà
3/5
Tempo stimato
1-2 giorni
Stato di attività
Ferma
Chiarezza
Abbastanza chiara
Idoneità per principianti
45/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.