Skip to content

add custom swig typemap for C++ enums that does value checks #3276

Description

@stevengj

e.g. when passing enums like direction or boundary_side to functions like fields::set_boundary, right now SWIG just does static_cast from an integer value (int), which performs no checks and could result in a crash if the user passes something invalid.

A simple solution would be to just add SWIG typemaps for these enum types that checks whether the value is in range and otherwise throws ValueError or something.

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions