The weight generating functions associated with convolutional codes (CCs) are based on state space realizations or the weight adjacency matrices (WAMs). The MacWilliams identity for CCs on the WAMs was first established by Gluesing- Luerssen and Schneider in the case of minimal encoders, and generalized by Forney. We consider this problem in the viewpoint of constraint codes and obtain a simple and direct proof of this MacWilliams identity in the case of minimal encoders. For our purpose, we choose a different representation for the exact weight generating function (EWGF) of a block code, by defining it as a linear combination of orthonormal vectors in Dirac bra-ket notation. This representation provides great flexibility so that general split weight generating functions and their MacWilliams identities can be easily obtained from the MacWilliams identity for EWGFs. As a result, we also obtain the MacWilliams identity for the input-parity weight adjacency matrices of a systematic convolutional code and its dual. Finally, paralleling the development of the classical case, we establish the MacWilliams identity for quantum convolutional codes.