Allow using Unifex enums and structs in NIF/Cnode state#120
Conversation
|
|
||
| @spec_name_sufix ".spec.exs" | ||
| @generated_dir_name "_generated" | ||
| @types_header_sufix "_types_definitions" |
There was a problem hiding this comment.
| @types_header_sufix "_types_definitions" | |
| @types_header_suffix "_types" |
typo in suffix + I think _types is sufficient
mat-hek
left a comment
There was a problem hiding this comment.
The goal is that this works: membraneframework/membrane_av1_plugin@master...mf/unifex
Collapse the two tie headers introduced in c2a9153 / 4bcbdc7 back into a single `_generated/<name>.h` that includes both `<interface>/<name>.h` and `<interface>/<name>_types.h`. Document the typedef-include-struct pattern users follow to put custom types in their state. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Noarkhh
left a comment
There was a problem hiding this comment.
I found a bug where you now can't use user-defined enums in user-defined structs. It all stems from the casing - structs use snake case, and enums use camel case (we could discuss unifying that). Changes introduced in this PR make it so the following definitions in .spec.ex file:
type my_enum :: :a | :b
type my_struct :: %MyStruct{enum_field: my_enum}get translated to the following C definitions:
enum MyEnum_t { MY_ENUM_A, MY_ENUM_B };
typedef enum MyEnum_t MyEnum;
struct my_struct_t {
my_enum enum_field;
};
typedef struct my_struct_t my_struct;which don't work, since there's no type my_enum
| """ | ||
| end | ||
|
|
||
| defp pargma_and_includes() do |
There was a problem hiding this comment.
| defp pargma_and_includes() do | |
| defp pragma_and_includes() do |
| ~g""" | ||
| #ifdef #{generator.identification_constant()} | ||
| #include "#{generator.interface_io_name()}/#{name}.h" | ||
| #include "#{generator.interface_io_name()}/#{types_header_filename}" |
There was a problem hiding this comment.
My LSP complains when this include is below the other one, since the types are used inside it. I also think it makes more sense, but it's not necessary
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
closes membraneframework/membrane_core#1130