Jump to content

  • Log In with Google      Sign In   
  • Create Account


- - - - -

Determining Autohandle Support


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
2 replies to this topic

#1 Jason Goepel   Members   -  Reputation: 365

Like
0Likes
Like

Posted 11 September 2013 - 08:49 AM

I accidentally attempted to use an Autohandle for a type before registering that type.  The result is that in the following code dt.GetObjectType() returns 0.  Accessing 0->flags produces an access violation.

 

as_builder.cpp: line 4619

if( n && n->tokenType == ttPlus )
{
    // Autohandles are not supported for types with NOCOUNT
    if( dt.GetObjectType()->flags & asOBJ_NOCOUNT )
        WriteError(TXT_AUTOHANDLE_CANNOT_BE_USED_FOR_NOCOUNT, file, node->firstChild);

    if( autoHandle ) *autoHandle = true;
}

This is because the following call to CreateDataTypeFromNode failed to find a type for the unregistered handle, and it returned [ttInt]

 

as_builder.cpp: line 962

// Scoped reference types are allowed to use handle when returned from application functions
func->returnType = CreateDataTypeFromNode(node->firstChild, &source, objType ? objType->nameSpace : ns, true, objType);
func->returnType = ModifyDataTypeFromNode(func->returnType, node->firstChild->next, &source, 0, &autoHandle);
if( autoHandle && (!func->returnType.IsObjectHandle() || func->returnType.IsReference()) )
    return asINVALID_DECLARATION;

To correct the error, I was able to either test for an error condition earlier:

// Scoped reference types are allowed to use handle when returned from application functions
func->returnType = CreateDataTypeFromNode(node->firstChild, &source, objType ? objType->nameSpace : ns, true, objType);
if( numErrors > 0 || numWarnings > 0 )
    return asINVALID_DECLARATION;
func->returnType = ModifyDataTypeFromNode(func->returnType, node->firstChild->next, &source, 0, &autoHandle);
if( autoHandle && (!func->returnType.IsObjectHandle() || func->returnType.IsReference()) )
    return asINVALID_DECLARATION;

Or test for a null asCObjectType*:

if( n && n->tokenType == ttPlus )
{
    asCObjectType *ot = dt.GetObjectType();

    // Autohandles are not supported for primitive types
    if( ot == nullptr )
        WriteError("Autohandles are not supported for primitive types.", file, node->firstChild);

    // Autohandles are not supported for types with NOCOUNT
    else if( dt.GetObjectType()->flags & asOBJ_NOCOUNT )
        WriteError(TXT_AUTOHANDLE_CANNOT_BE_USED_FOR_NOCOUNT, file, node->firstChild);

    if( autoHandle ) *autoHandle = true;
}


Sponsor:

#2 Andreas Jonsson   Moderators   -  Reputation: 3196

Like
0Likes
Like

Posted 11 September 2013 - 10:37 AM

Thanks. I'll have this corrected.

 

Regards,

Andreas


AngelCode.com - game development and more - Reference DB - game developer references
AngelScript - free scripting library - BMFont - free bitmap font generator - Tower - free puzzle game

#3 Andreas Jonsson   Moderators   -  Reputation: 3196

Like
0Likes
Like

Posted 15 September 2013 - 10:39 AM

I've fixed this in revision 1723.

 

Thanks,

Andreas


AngelCode.com - game development and more - Reference DB - game developer references
AngelScript - free scripting library - BMFont - free bitmap font generator - Tower - free puzzle game




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS