Exemple #1
0
        //index from an imaginary array composed of native objects followed by managed objects.
        public static ObjectData FromUnifiedObjectIndex(CachedSnapshot snapshot, int index)
        {
            int iNative = snapshot.UnifiedObjectIndexToNativeObjectIndex(index);

            if (iNative >= 0)
            {
                return(FromNativeObjectIndex(snapshot, iNative));
            }

            int iManaged = snapshot.UnifiedObjectIndexToManagedObjectIndex(index);

            if (iManaged >= 0)
            {
                return(FromManagedObjectIndex(snapshot, iManaged));
            }

            return(ObjectData.invalid);
        }
        static void AddupRawRefCount(CachedSnapshot snapshot)
        {
            for (long i = 0; i != snapshot.connections.Count; ++i)
            {
                int iManagedTo = snapshot.UnifiedObjectIndexToManagedObjectIndex(snapshot.connections.to[i]);
                if (iManagedTo >= 0)
                {
                    var obj = snapshot.CrawledData.ManagedObjects[iManagedTo];
                    ++obj.RefCount;
                    snapshot.CrawledData.ManagedObjects[iManagedTo] = obj;
                    continue;
                }

                int iNativeTo = snapshot.UnifiedObjectIndexToNativeObjectIndex(snapshot.connections.to[i]);
                if (iNativeTo >= 0)
                {
                    ++snapshot.nativeObjects.refcount[iNativeTo];
                    continue;
                }
            }
        }
Exemple #3
0
        public ObjectReferenceTable(Database.Schema schema, SnapshotObjectDataFormatter formatter, CachedSnapshot snapshot, ManagedData crawledData, ObjectData obj, ObjectMetaType metaType)
            : base(schema, formatter, snapshot, crawledData, metaType)
        {
            m_Object     = obj;
            m_References = ObjectConnection.GetAllObjectConnectingTo(snapshot, obj);
#if DEBUG_VALIDATION
            int toUnifiedIndex = m_Object.GetUnifiedObjectIndex(snapshot);
            var toManagedIndex = snapshot.UnifiedObjectIndexToManagedObjectIndex(toUnifiedIndex);

            for (int k = 0; k != m_References.Length; ++k)
            {
                var oFrom = m_References[k];

                switch (oFrom.dataType)
                {
                case ObjectDataType.ReferenceArray:
                case ObjectDataType.ReferenceObject:
                case ObjectDataType.Value:
                    if (oFrom.m_Parent != null)
                    {
                        oFrom = oFrom.m_Parent.obj;
                    }
                    break;
                }

                bool connectionFound = false;
                switch (oFrom.dataType)
                {
                case ObjectDataType.Global:
                {
                    if (snapshot.HasGlobalConnection(toManagedIndex))
                    {
                        connectionFound = true;
                    }
                }
                break;

                case ObjectDataType.Type:
                {
                    if (snapshot.HasManagedTypeConnection(oFrom.managedTypeIndex, toManagedIndex))
                    {
                        connectionFound = true;
                    }
                }
                break;

                case ObjectDataType.Array:
                case ObjectDataType.BoxedValue:
                case ObjectDataType.Object:
                {
                    if (snapshot.HasObjectConnection(oFrom.GetUnifiedObjectIndex(snapshot), toUnifiedIndex))
                    {
                        connectionFound = true;
                        break;
                    }
                }
                break;

                case ObjectDataType.NativeObject:
                {
                    if (snapshot.HasObjectConnection(oFrom.GetUnifiedObjectIndex(snapshot), toUnifiedIndex))
                    {
                        connectionFound = true;
                        break;
                    }
                }
                break;
                }
                if (!connectionFound)
                {
                    UnityEngine.Debug.LogError("Connection not found, index =" + k);
                }
            }
#endif
            InitObjectList();
        }