| 6768 | } |
| 6769 | |
| 6770 | asCDataType asCBuilder::ModifyDataTypeFromNode(const asCDataType &type, asCScriptNode *node, asCScriptCode *file, asETypeModifiers *inOutFlags, bool *autoHandle) |
| 6771 | { |
| 6772 | asCDataType dt = type; |
| 6773 | |
| 6774 | if( inOutFlags ) *inOutFlags = asTM_NONE; |
| 6775 | |
| 6776 | // Is the argument sent by reference? |
| 6777 | asCScriptNode *n = node->firstChild; |
| 6778 | if( n && n->tokenType == ttAmp ) |
| 6779 | { |
| 6780 | if (dt.GetTokenType() == ttVoid) |
| 6781 | { |
| 6782 | asCString msg; |
| 6783 | msg.Format(TXT_TYPE_s_CANNOT_BE_REFERENCE, type.Format(0).AddressOf()); |
| 6784 | WriteError(msg, file, node->firstChild); |
| 6785 | return dt; |
| 6786 | } |
| 6787 | |
| 6788 | dt.MakeReference(true); |
| 6789 | n = n->next; |
| 6790 | |
| 6791 | if( n ) |
| 6792 | { |
| 6793 | if( inOutFlags ) |
| 6794 | { |
| 6795 | if( n->tokenType == ttIn ) |
| 6796 | *inOutFlags = asTM_INREF; |
| 6797 | else if( n->tokenType == ttOut ) |
| 6798 | *inOutFlags = asTM_OUTREF; |
| 6799 | else if( n->tokenType == ttInOut ) |
| 6800 | *inOutFlags = asTM_INOUTREF; |
| 6801 | else |
| 6802 | asASSERT(false); |
| 6803 | } |
| 6804 | |
| 6805 | n = n->next; |
| 6806 | } |
| 6807 | else |
| 6808 | { |
| 6809 | if( inOutFlags ) |
| 6810 | *inOutFlags = asTM_INOUTREF; // ttInOut |
| 6811 | } |
| 6812 | |
| 6813 | if( !engine->ep.allowUnsafeReferences && |
| 6814 | inOutFlags && *inOutFlags == asTM_INOUTREF && |
| 6815 | !(dt.GetTypeInfo() && (dt.GetTypeInfo()->flags & asOBJ_TEMPLATE_SUBTYPE)) ) |
| 6816 | { |
| 6817 | // Verify that the base type support &inout parameter types |
| 6818 | if( !dt.IsObject() || dt.IsObjectHandle() || |
| 6819 | !((dt.GetTypeInfo()->flags & asOBJ_NOCOUNT) || (CastToObjectType(dt.GetTypeInfo())->beh.addref && CastToObjectType(dt.GetTypeInfo())->beh.release)) ) |
| 6820 | WriteError(TXT_ONLY_OBJECTS_MAY_USE_REF_INOUT, file, node->firstChild); |
| 6821 | } |
| 6822 | } |
| 6823 | |
| 6824 | if( autoHandle ) *autoHandle = false; |
| 6825 | |
| 6826 | if( n && n->tokenType == ttPlus ) |
| 6827 | { |
no test coverage detected