LumaPictures / pymel

Python in Maya Done Right
Other
479 stars 130 forks source link

Add special handling for "undo" arguments #419

Open pmolodo opened 5 years ago

pmolodo commented 5 years ago

Currently, api method arguments are classified as either "in" or "out"* (via "direction"). However, some arguments - ie, MAnimCurveChange / MDgModifier / MDagModifier args - aren't really either in or out, but are just used to record undo information. We currently have special handling for MAnimCurveChange, but we do it through a lot of special case checks. Would like to genericize this work, and use it to also handle MDgModifier and MDagModifier args.

One way to do this would be to mark these args' direction as "undo" (and not "in" or "out"), and this would trigger special handling. If we go this route, would like to not write this into the api cache itself, but automatically applied by by some sort of getter or processing function. (Eventually, would like a class to handle all cache queries, to provide a centralized place for this sort of processing. For instance, factories._getApiOverrideNameAndData would go there). This way, we'd have an untainted "record" of what the maya docs said the arg type was.

Would also like to be able to handle args of these three types that don't have a default value - right now, because they're not in factories.ApiTypeRegister, the wrapping mechanisms assume they don't know how to handle them, and so will only wrap these funcs if they provide a default. Would like to address this by adding them to ApiTypeRegister somehow, but may end up being easier to special-case "undo" arg types.

*Technically, there are some that are also in/out, but I think we currently ignore those.