Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

Typed callables vs Cppia MemReference

Aperta
#1,365 2 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
4/5
Tempo stimato
3-5 giorni
Idoneità per principianti
35/100
Tipo di issue
Bug
Chiarezza
Da chiarire
Stato di attività
Tranquilla
Stack tecnologico
cpp
Ambito
backend

Direzione di ricerca

Inizia leggendo issue #1321 e pull request #1324, quindi ripercorri le modifiche di cppia mem-reference descritte in questo issue. Riproduci i casi di callable tipizzato che coinvolgono Int, Float e Dynamic attraverso il confine di cppia; il lavoro è completato quando i casi di callable compatibili non richiedono più di disabilitare object mem references e superano i test pertinenti.

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

Descrizione

As part of the typed callables work I had to disable cppia mem references in two places to get all the tests passing, this was due to an unfortunate edge case involving haxe functions.

E.g. Haxe is perfectly happy to treat the following signatures as compatible without any user casting or manual wrapping.

Int->Void = Dynamic->Void
Float->Void = Int->Void

Without cppia this is all fine as the new callable types constructor deals with all this mangling, but with cppia there are a few annoying edge cases. Cppia erases all objects to hx::Object*, so when you pass an object like hx::ObjectPtr<hx::Callable<Int->Void>> from haxe into cppia it gets erased to just a object pointer. But this also means if you pass in a Haxe compatible hx::ObjectPtr<hx::Callable<Dynamic->Void>> it will also be erased to hx::Object* and the mem reference setter will just replace the pointer. The problems then start to occur when we try and pull that function object out of cppia and back into cpp. The pointer will be blindly reinterpreted to the original hx::ObjectPtr<hx::Callable<Int->Void>> (or whatever haxe deems the expression to be) which will cause a memory access violation if that pointer holds the one where Dynamic is the argument as they're incompatible types. Previously this would "just work" as all function closures invoked dynamically.

The other edge case surrounding passing these odd compatible callables over the cppia boundary is that you can end up with a callable object pointer in cpp holding a pointer to a hx::CppiaClosure which does not inherit a callable type, again this is due to pointers being reinterpreted by mem reference instead of going through the required callable constructor.

I still have a screenshot of this second one since it was fixed in a follow up merge.

Image

https://github.com/HaxeFoundation/hxcpp/issues/1321
https://github.com/HaxeFoundation/hxcpp/pull/1324

Hopefully this makes sense, I'm not massively familiar with cppia so I found the easiest fix was to disable mem references for objects which is obviously not great. I'll try and remember to dig out some concrete examples of both of these.

Pinging @hughsando since he asked about it in a commit message.

Lingua principale
C++
Stelle
330
Fork
230
Merge medio
1g 6h
PR unite (30g)
9

Preparare l'ambiente

Questo progetto non fornisce container di sviluppo, Dockerfile né guida per i contributori, quindi l'ambiente è a tuo carico: parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.

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 HaxeFoundation/hxcpp

Tutte le issue di HaxeFoundation/hxcpp

Issue simili

Altre issue su C++

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.