bytecodealliance / wasmtime-cpp

Apache License 2.0
86 stars 18 forks source link

Add an X macro for `ValKind` processing #43

Closed PragmaTwice closed 1 year ago

PragmaTwice commented 1 year ago

In the previous code, there are repeated instances of switch case code related to ValKind, which makes the code redundant and difficult to maintain.

In this PR, I have created an X macro WASMTIME_FOR_EACH_VAL_KIND to store this information centrally and expand it during processing.

About X macro: https://en.wikipedia.org/wiki/X_macro

alexcrichton commented 1 year ago

Thanks! Would it be possible to take the name of the macro as an argument rather than assuming the name X works? (I've never seen this pattern before myself)

PragmaTwice commented 1 year ago

Would it be possible to take the name of the macro as an argument rather than assuming the name X works?

Sure! Done.