Esempio n. 1
0
static void uDumpStrongRefs(FILE *fp, uObject *obj, void *base, uType *type)
{
    for (int i = 0; i < type->StrongRefCount; i++)
    {
        uObject *target = *(uObject**)((uByte*)base + type->StrongRefOffsets[i]);
        uDumpStrongRef(fp, obj, target);
    }
}
Esempio n. 2
0
static void uDumpAllStrongRefs(FILE* fp, uObject* object, void* base, uType* type)
{
    for (size_t i = 0; i < type->Refs.StrongCount; i++)
    {
        uObject* target = *(uObject**)((uint8_t*)base + type->Refs.Strong[i].Value);
        uDumpStrongRef(fp, object, target);
    }
}
Esempio n. 3
0
static void uDumpObjectAndStrongRefs(FILE *fp, uObject *obj)
{
    uType *type = obj->GetType();

    uDumpObject(fp, obj, type->TypeName);

    switch (type->TypeType)
    {
    case uTypeTypeClass:
        do
        {
	    uDumpStrongRefs(fp, obj, obj, type);
            type = type->BaseType;
        } while (type);
	    break;

    case uTypeTypeEnum:
        break;

    case uTypeTypeStruct:
    {
        uByte* valueAddr = (uByte*)obj + sizeof(uObject);
        uDumpStrongRefs(fp, obj, valueAddr, type);
	    break;
    }

    case uTypeTypeDelegate:
    {
        uDelegate *delegate = (uDelegate*)obj;
        uDumpStrongRef(fp, obj, delegate->_obj);
        uDumpStrongRef(fp, obj, delegate->_prev);
        break;
    }

    case uTypeTypeArray:
    {
        uArray *array = (uArray *)obj;
        uArrayType *arrayType = (uArrayType *)type;
        uType *elmType = arrayType->ElementType;

        switch (elmType->TypeType)
        {
            case uTypeTypeClass:
            case uTypeTypeInterface:
            case uTypeTypeDelegate:
            case uTypeTypeArray:
            {
	        for (int i = 0; i < array->_len; ++i)
		{
		    uObject *target = ((uObject **)array->_ptr)[i];
                    uDumpStrongRef(fp, obj, target);
		}
            }
            break;

            case uTypeTypeEnum:
                break;
            case uTypeTypeStruct:
            {
                for (int i = 0; i < array->_len; ++i)
                {
                    uByte *valueAddr = (uByte *)array->_ptr + i * elmType->ValueSize;
                    uDumpStrongRefs(fp, obj, valueAddr, elmType);
                }
            }
            break;

            default:
                uFatalError(XLI_FUNCTION);
            }
        }
        break;

    default:
        uFatalError(XLI_FUNCTION);
    }
}
Esempio n. 4
0
static void uDumpObjectAndStrongRefs(FILE* fp, uObject* object)
{
    uType* type = object->GetType();
    uDumpObject(fp, object, type->FullName);

    switch (type->Type)
    {
    case uTypeTypeClass:
        do
            uDumpAllStrongRefs(fp, object, object, type);
        while ((type = type->Base));
        break;

    case uTypeTypeEnum:
        break;

    case uTypeTypeStruct:
    {
        uint8_t* address = (uint8_t*)object + sizeof(uObject);
        uDumpAllStrongRefs(fp, object, address, type);
        break;
    }
    case uTypeTypeDelegate:
    {
        uDelegate* delegate = (uDelegate*)object;
        uDumpStrongRef(fp, object, delegate->_object);
        uDumpStrongRef(fp, object, delegate->_prev);
        break;
    }
    case uTypeTypeArray:
    {
        uArray* array = (uArray*)object;
        uArrayType* arrayType = (uArrayType*)type;
        uType* elmType = arrayType->ElementType;

        switch (elmType->Type)
        {
        case uTypeTypeClass:
        case uTypeTypeInterface:
        case uTypeTypeDelegate:
        case uTypeTypeArray:
            for (int i = 0; i < array->Length(); ++i)
            {
                uObject* target = ((uObject**)array->Ptr())[i];
                uDumpStrongRef(fp, object, target);
            }
            break;

        case uTypeTypeEnum:
            break;

        case uTypeTypeStruct:
            for (int i = 0; i < array->Length(); ++i)
            {
                uint8_t* address = (uint8_t*)array->Ptr() + i * elmType->ValueSize;
                uDumpAllStrongRefs(fp, object, address, elmType);
            }
            break;

        default:
            U_FATAL();
        }
        break;
    }

    default:
        U_FATAL();
    }
}