Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Registering Soft UDPs with an enum as the valid_type #222

Open
rbroich opened this issue Oct 13, 2024 · 0 comments
Open

Registering Soft UDPs with an enum as the valid_type #222

rbroich opened this issue Oct 13, 2024 · 0 comments

Comments

@rbroich
Copy link

rbroich commented Oct 13, 2024

I have a user defined property defined as follows in an RDL file:

enum E_FIELD_TYPE {
    FT_UNSIGNED {desc = "Unsigned integer number from 0 to 2^bits - 1";};
    FT_SIGNED {desc = "Signed number from -2^(bits-1) to 2^(bits-1) - 1";};
    FT_BOOL {desc = "Boolean value: true or false";};
};
property field_type {
    component = field;
    type = E_FIELD_TYPE;
};

A custom generator then makes use of this and everything works fine. After reading about Soft UDPs and the validation and unassigned default benefits they provide, I would like to register this property as a soft definition. Here is what I have tried so far:

class FieldTypeDefinition(UDPDefinition):
    name = "field_type"
    valid_components = {Field}
    valid_type = rdltypes.user_enum.UserEnum

This results in:

error: The property definition for the feature extension 'field_type' uses a different 'type' definition from what this tool expects

Is there any way to do this? I have thought about defining the enum in a separate file and compiling it first (rdlc.compile_file) before registering the UDP (rdlc.register_udp), but then I don't have a way to reference it from inside the FieldTypeDefinition class. I suppose creating the enum inside the class could work, but the existing_udp.valid_type != udp.valid_type rulebook entry would still complain then.

Do you have any other suggestions?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

1 participant