Skip to content

Commit

Permalink
Merge pull request #2 from nvlukasz/external-source-support
Browse files Browse the repository at this point in the history
Fix error when external types are used as function arguments
  • Loading branch information
massimim authored Apr 26, 2024
2 parents 047eee4 + 9bcc683 commit bd52acc
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions warp/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -4239,6 +4239,10 @@ def type_is_generic_scalar(t):
return t in (Scalar, Float, Int)


def type_is_external(t):
return hasattr(t, "_type_") and issubclass(t._type_, ctypes.Structure)


def type_matches_template(arg_type, template_type):
"""Check if an argument type matches a template.
Expand Down Expand Up @@ -4394,6 +4398,9 @@ def get_type_code(arg_type):
return f"m{dim_code0}{dim_code1}{dtype_code}"
else:
raise TypeError("Invalid vector/matrix dimensionality")
# !!!
elif type_is_external(arg_type):
return arg_type.__name__
else:
# simple type
type_code = simple_type_codes.get(arg_type)
Expand Down

0 comments on commit bd52acc

Please sign in to comment.