microsoft / pxt-arcade

Arcade game editor based on Microsoft MakeCode
https://arcade.makecode.com
MIT License
477 stars 206 forks source link

add PXT v-table to C++ classes #1436

Open mmoskal opened 4 years ago

mmoskal commented 4 years ago

Describe the bug The following program:

game.consoleOverlay.setVisible(true)
const p = pins.pinByCfg(DAL.CFG_PIN_A0)
console.log(`a0 ${p} ${pins.A0}`)

prints a0 undefined undefined on hardware despite the pin being defined.

The more problematic thing is:

const v1 = pins.A0.digitalRead() // works
const v2 = (pins.A0 as any).digitalRead() // doesn't work

This is more of a problem in micro:bit since there is more classes implemented in C++.

mmoskal commented 4 years ago

This is because Pins don't have a vtable.

The following codal classes don't have vtable:

and following our classes (which are easier to fix):