tudortimi / constraints

Reusable constraints
Apache License 2.0
3 stars 1 forks source link

Add possibility to customize contents of `pre_randomize` #9

Closed tudortimi closed 1 year ago

tudortimi commented 1 year ago

The constraints_utils macro has to implement pre_randomize(), in order to insert constraints. There are cases, though, where the user would like to also add code to pre_randomize(). Something like the following might be ok:

`constraints_utils_begin(some_type)
  `constraints_utils_pre_randomize_begin
    // statement 0
    // statement 1
  `constraints_utils_pre_randomize_end
`constraints_utils_end

The statements between the pre_randomize_begin/end macros should be added to the implementation of pre_randomize.

tudortimi commented 1 year ago

One question that remains is how to handled super.pre_randomize(). Shall the default contents of pre_randomize_begin/end contain a call to super.pre_randomize()?

tudortimi commented 1 year ago

Actually, it might be a better idea to stop using pre_randomize() all-together. We might be able to do it by creating a dummy rand object inside the class and using that object's pre_randomize() as a callback to handle global/instance constraints.

tudortimi commented 1 year ago

Fixed in #11