@@ -689,7 +689,7 @@ def acceptPreformatted(self, node, memo):
689689 acceptUnaryMinus = makeNodePreformattedExpr ('-' + FS .l )
690690 acceptUnaryPlus = makeNodePreformattedExpr ('+' + FS .l )
691691
692- def acceptCastExpr (self , node , memo ): # problem?
692+ def acceptCastExpr (self , node , memo ):
693693 """ Accept and process a cast expression. """
694694 # If the type of casting is a primitive type,
695695 # then do the cast, else drop it.
@@ -699,12 +699,21 @@ def acceptCastExpr(self, node, memo): # problem?
699699 typeName = typeIdent .text
700700 if typeIdent .type == tokens .QUALIFIED_TYPE_IDENT :
701701 typeName = typeIdent .firstChild ().text
702-
702+
703703 if typeName in tokens .primitiveTypeNames :
704704 # Cast using the primitive type constructor
705705 self .fs = typeName + '(' + FS .r + ')'
706706 else :
707- self .fs = FS .r
707+ mode = self .config .last ('objCastMode' )
708+ if mode == 'drop' :
709+ # Use drop policy
710+ self .fs = FS .r
711+ elif mode == 'ctor' :
712+ # Make constructor
713+ self .fs = FS .l + '(' + FS .r + ')'
714+ else :
715+ warn ('Couldn\' t perform cast operation. ' + typeName + \
716+ ' is not a primitive and objCastMode in the config file has wrong value.' )
708717 self .left , self .right = visitors = factory (parent = self ), factory (parent = self )
709718 self .zipWalk (node .children , visitors , memo )
710719
0 commit comments