Ejemplo n.º 1
0
		public override void Commit()
		{
			IntByRef removedReferenceCount = new IntByRef();
			TraverseNewReferences(new _IVisitor4_26(this, removedReferenceCount));
			CreateNewReferences();
			ReferenceCountChanged(-removedReferenceCount.value);
		}
Ejemplo n.º 2
0
 public virtual void TestCancelledTraversalWithStartingPointInTheTree()
 {
     var visits = new IntByRef();
     var tree = CreateTree();
     Tree.Traverse(tree, new TreeInt(6), new _ICancellableVisitor4_41(visits));
     Assert.AreEqual(1, visits.value);
 }
Ejemplo n.º 3
0
 public override void Rollback()
 {
     var newReferencesCount = new IntByRef();
     TraverseNewReferences(new _IVisitor4_63(newReferencesCount));
     CreateNewReferences();
     ReferenceCountChanged(-newReferencesCount.value);
 }
		//private void AssertSingleNullTypeHandlerAspect(Type storedClass)
		//{
		//    AssertSingleTypeHandlerAspect(storedClass, typeof(IgnoreFieldsTypeHandler));
		//}

        private void AssertSingleTypeHandlerAspect(Type storedClass, Type typeHandlerClass
            )
        {
            IntByRef aspectCount = new IntByRef(0);
            ClassMetadata classMetadata = ClassMetadata(storedClass);
            classMetadata.TraverseDeclaredAspects(new _IProcedure4_51(aspectCount, typeHandlerClass
                ));
        }
Ejemplo n.º 5
0
 public int MarshalledLength()
 {
     if (VariableLength())
     {
         var length = new IntByRef(Const4.IntLength);
         Traverse(new _IVisitor4_152(length));
         return length.value;
     }
     return MarshalledLength(Size());
 }
Ejemplo n.º 6
0
		private void AssertTestRuns(int[] failingIndices)
		{
			IntByRef counter = new IntByRef();
			TestResult result = new _TestResult_29();
			new TestRunner(Iterators.Iterable(new OpaqueTestSuiteTestCase.SimpleTestSuite[] { 
				new OpaqueTestSuiteTestCase.SimpleTestSuite(counter, NumTests, failingIndices) }
				)).Run(result);
			Assert.AreEqual(NumTests, result.TestCount);
			Assert.AreEqual(failingIndices.Length, result.Failures.Count);
			Assert.AreEqual(NumTests + 2, counter.value);
		}
 public virtual void TestItemCountChanged()
 {
     var changedCount = new IntByRef();
     IBTreeStructureListener listener = new _IBTreeStructureListener_63(changedCount);
     _btree.StructureListener(listener);
     changedCount.value = 0;
     Add(42);
     Assert.AreEqual(1, changedCount.value);
     Remove(42);
     Assert.AreEqual(-1, changedCount.value);
     changedCount.value = 0;
     Remove(42);
     Assert.AreEqual(0, changedCount.value);
 }
		public virtual void TestDelete()
		{
			IntByRef deletedCount = new IntByRef();
			IBTreeStructureListener listener = new _IBTreeStructureListener_39(deletedCount);
			_btree.StructureListener(listener);
			for (int i = 0; i < BtreeNodeSize + 1; i++)
			{
				Add(i);
			}
			for (int i = 0; i < BtreeNodeSize + 1; i++)
			{
				Remove(i);
			}
			Assert.AreEqual(2, deletedCount.value);
		}
Ejemplo n.º 9
0
			public SimpleTestSuite(IntByRef counter, int numTests, int[] failingIndices) : this
				(counter, numTests, new _IClosure4_47(counter, numTests, failingIndices))
			{
			}
Ejemplo n.º 10
0
			public _IProcedure4_136(ClassMarshaller _enclosing, IntByRef processedAspectCount
				, int aspectCount, ClassMetadata classMetadata, LatinStringIO sio, DefragmentContextImpl
				 context)
			{
				this._enclosing = _enclosing;
				this.processedAspectCount = processedAspectCount;
				this.aspectCount = aspectCount;
				this.classMetadata = classMetadata;
				this.sio = sio;
				this.context = context;
			}
Ejemplo n.º 11
0
			public _IProcedure4_108(ClassMarshaller _enclosing, IntByRef len, ObjectContainerBase
				 stream)
			{
				this._enclosing = _enclosing;
				this.len = len;
				this.stream = stream;
			}
Ejemplo n.º 12
0
			public _IVisitor4_63(IntByRef newReferencesCount)
			{
				this.newReferencesCount = newReferencesCount;
			}
Ejemplo n.º 13
0
 private bool Descend1(QQuery query, string fieldName, IntByRef run)
 {
     if (run.value == 2 || i_constraints.Size() == 0)
     {
         // On the second run we are really creating a second independant
         // query network that is not joined to other higher level
         // constraints.
         // Let's see how this works out. We may need to join networks.
         run.value = 0;
         // prevent a double run of this code
         Stream().ClassCollection().AttachQueryNode(fieldName, new _IVisitor4_275(this));
     }
     CheckConstraintsEvaluationMode();
     var foundClass = new BooleanByRef(false);
     var i = IterateConstraints();
     while (i.MoveNext())
     {
         if (((QCon) i.Current).Attach(query, fieldName))
         {
             foundClass.value = true;
         }
     }
     return foundClass.value;
 }
Ejemplo n.º 14
0
 public virtual IQuery Descend(string a_field)
 {
     lock (StreamLock())
     {
         var query = new QQuery(_trans, _this, a_field);
         var run = new IntByRef(1);
         if (!Descend1(query, a_field, run))
         {
             // try to add unparented nodes on the second run,
             // if not added in the first run and a descendant
             // was not found
             if (run.value == 1)
             {
                 run.value = 2;
                 if (!Descend1(query, a_field, run))
                 {
                     new QConUnconditional(_trans, false).Attach(query, a_field);
                 }
             }
         }
         return query;
     }
 }
Ejemplo n.º 15
0
			public _IVisitor4_131(IntByRef lastEnd, IntByRef lastStart)
			{
				this.lastEnd = lastEnd;
				this.lastStart = lastStart;
			}
Ejemplo n.º 16
0
		public virtual void DebugCheckIntegrity()
		{
			IntByRef lastStart = new IntByRef();
			IntByRef lastEnd = new IntByRef();
			Traverse(new _IVisitor4_131(lastEnd, lastStart));
		}
Ejemplo n.º 17
0
			public _IVisitor4_99(IntByRef mint)
			{
				this.mint = mint;
			}
Ejemplo n.º 18
0
				public _IClosure4_47(IntByRef counter, int numTests, int[] failingIndices)
				{
					this.counter = counter;
					this.numTests = numTests;
					this.failingIndices = failingIndices;
				}
Ejemplo n.º 19
0
			private SimpleTestSuite(IntByRef counter, int numTests, IClosure4 tests) : base(tests
				)
			{
				_counter = counter;
				_numTests = numTests;
			}
Ejemplo n.º 20
0
			public _IVisitor4_26(MonitoringReferenceSystem _enclosing, IntByRef removedReferenceCount
				)
			{
				this._enclosing = _enclosing;
				this.removedReferenceCount = removedReferenceCount;
			}
Ejemplo n.º 21
0
		private void AssertStoredField(Type objectClass, string fieldName, object expectedFieldValue
			, Type expectedFieldType, bool hasIndex, bool isArray)
		{
			IStoredClass storedClass = StoredClass(objectClass);
			IStoredField[] storedFields = storedClass.GetStoredFields();
			Assert.AreEqual(1, storedFields.Length);
			IStoredField storedField = storedFields[0];
			Assert.AreEqual(fieldName, storedField.GetName());
			IStoredField storedFieldByName = storedClass.StoredField(fieldName, expectedFieldType
				);
			Assert.AreEqual(storedField, storedFieldByName);
			object item = RetrieveOnlyInstance(objectClass);
			Assert.AreEqual(expectedFieldValue, storedField.Get(item));
			IReflectClass fieldType = storedField.GetStoredType();
			Assert.AreEqual(Reflector().ForClass(expectedFieldType), fieldType);
			Assert.AreEqual(isArray, storedField.IsArray());
			if (IsMultiSession())
			{
				return;
			}
			Assert.AreEqual(hasIndex, storedField.HasIndex());
			// FIXME: test rename
			if (!hasIndex)
			{
				Assert.Expect(typeof(Exception), new _ICodeBlock_113(storedField));
			}
			else
			{
				IntByRef count = new IntByRef();
				storedField.TraverseValues(new _IVisitor4_123(count, expectedFieldValue));
				Assert.AreEqual(1, count.value);
			}
		}
			public _IVisitor4_40(IntByRef slotChangeCount)
			{
				this.slotChangeCount = slotChangeCount;
			}
		private int CountSlotChanges(IVisitable slotChanges)
		{
			IntByRef slotChangeCount = new IntByRef();
			slotChanges.Accept(new _IVisitor4_40(slotChangeCount));
			return slotChangeCount.value;
		}
Ejemplo n.º 24
0
			public _IVisitor4_123(IntByRef count, object expectedFieldValue)
			{
				this.count = count;
				this.expectedFieldValue = expectedFieldValue;
			}
Ejemplo n.º 25
0
		public virtual int MarshalledLength(ObjectContainerBase stream, ClassMetadata clazz
			)
		{
			IntByRef len = new IntByRef(stream.StringIO().ShortLength(clazz.NameToWrite()) + 
				Const4.ObjectLength + (Const4.IntLength * 2) + (Const4.IdLength));
			len.value += clazz.Index().OwnLength();
			clazz.TraverseDeclaredAspects(new _IProcedure4_108(this, len, stream));
			return len.value;
		}
Ejemplo n.º 26
0
		public virtual MarshallingBuffer CheckBlockAlignment(MarshallingContext context, 
			MarshallingBuffer precedingBuffer, IntByRef precedingLength)
		{
			_lastOffSet = Offset();
			if (DoBlockAlign())
			{
				precedingBuffer.BlockAlign(context, precedingLength.value);
			}
			if (precedingBuffer != null)
			{
				precedingLength.value += precedingBuffer.Length();
			}
			precedingBuffer = this;
			if (_children != null)
			{
				IEnumerator i = new Iterator4Impl(_children);
				while (i.MoveNext())
				{
					precedingBuffer = ((MarshallingBuffer)i.Current).CheckBlockAlignment(context, precedingBuffer
						, precedingLength);
				}
			}
			return precedingBuffer;
		}
Ejemplo n.º 27
0
		public virtual void Defrag(ClassMetadata classMetadata, LatinStringIO sio, DefragmentContextImpl
			 context, int classIndexID)
		{
			ReadName(sio, context.SourceBuffer());
			ReadName(sio, context.TargetBuffer());
			int metaClassID = 0;
			context.WriteInt(metaClassID);
			// ancestor ID
			context.CopyID();
			context.WriteInt((classMetadata.HasClassIndex() ? IndexIDForWriting(classIndexID)
				 : 0));
			int aspectCount = context.ReadInt();
			if (aspectCount > classMetadata.DeclaredAspectCount())
			{
				throw new InvalidOperationException();
			}
			IntByRef processedAspectCount = new IntByRef(0);
			classMetadata.TraverseDeclaredAspects(new _IProcedure4_136(this, processedAspectCount
				, aspectCount, classMetadata, sio, context));
		}
Ejemplo n.º 28
0
			private static ITest[] Tests(IntByRef counter, int numTests, int[] failingIndices
				)
			{
				ITest[] tests = new ITest[numTests];
				for (int i = 0; i < numTests; i++)
				{
					tests[i] = new OpaqueTestSuiteTestCase.CountingTest(counter, i + 1, Arrays4.IndexOf
						(failingIndices, i) >= 0);
				}
				return tests;
			}
Ejemplo n.º 29
0
			public _IVisitor4_152(IntByRef length)
			{
				this.length = length;
			}
Ejemplo n.º 30
0
			public CountingTest(IntByRef counter, int idx, bool fail)
			{
				_counter = counter;
				_idx = idx;
				_fail = fail;
			}