Cubyz icon indicating copy to clipboard operation
Cubyz copied to clipboard

Generalized vtables

Open codemob-dev opened this issue 1 month ago • 5 comments

Fixes #2211

This is a prototype, I would like feedback on if this is the right direction to go in or not.

codemob-dev avatar Nov 05 '25 17:11 codemob-dev

I made the hashmap comptime which simplifies the interface a bit.

codemob-dev avatar Nov 05 '25 20:11 codemob-dev

When you're on it, could you implement inheritance too?

Argmaster avatar Nov 05 '25 22:11 Argmaster

jk

Argmaster avatar Nov 05 '25 22:11 Argmaster

When you're on it, could you implement inheritance too?

Technically this is one-level inheritance

codemob-dev avatar Nov 05 '25 22:11 codemob-dev

How bad are the error messages (e.g. on missing or incorrect functions)?

When removing the onLoadClient function from the chest I get this error:

src/utils/meta.zig:28:8: error: VTable missing field 'onLoadClient'
       @compileError("VTable missing field '" ++ field.name ++ "'");
       ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
src/utils/meta.zig:8:53: note: called at comptime here
  const map: std.StaticStringMap(VTable) = createMap();

codemob-dev avatar Nov 07 '25 20:11 codemob-dev