-
Notifications
You must be signed in to change notification settings - Fork 32
TypeConversion2
Laeeth Isharc edited this page Mar 19, 2015
·
1 revision
It is frequently useful to extend Pyd's type conversion mechanisms. The usual way to do this is to wrap classes or structs. Pyd has two additional mechanisms for more complex situations.
This allows the user to define a function for returning a D type to Python. The dg may be either a function pointer or a delegate. The argument to the function pointer is of the type to convert. The return type of the function pointer can be any convertible type.
This allows the user to define a function for converting a Python object to a D type. The dg may be either a function pointer or a delegate. The argument to the function pointer can be any convertible type. The return type of the function pointer is the type to convert.
Conversion functions defined with either of the above functions only take effect if Pyd's regular type conversion mechanisms fail. This would usually happen if a wrapped function returns or has a parameter of some un-wrapped class or struct type.
And in Python: