public void Populate(string name, SharedObject so)
 {
     this.so_name.Text = so.Name;
     this.so_size.Text = so.FileSize.ToString();
     this.so_encoding.Text = so.AMFEncoding.ToString();
     this.rawView.Text = so.ToString();
 }
Exemple #2
0
		public override bool equivalent(SharedObject obj) 
		{
			if (base.equivalent(obj)) 
			{
				ATermBlob peer = (ATermBlob) obj;
				return peer.getBlobData() == data;
			}
			return false;
		}
		   public override bool equivalent(SharedObject obj) 
		   {
			   if (base.equivalent(obj)) 
			   {
				   ATermPlaceholder peer = (ATermPlaceholder) obj;
				   return peer.getPlaceholder() == type;
			   }
			   return false;
		   }
Exemple #4
0
		public override bool equivalent(SharedObject obj) 
		{
			if (base.equivalent(obj)) 
			{
				ATermInt peer = (ATermInt) obj;
				return peer.getInt() == value;
			}
			return false;
		}
Exemple #5
0
		public override bool equivalent(SharedObject obj) 
		{
			try 
			{
				AFun peer = (AFun) obj;
				return peer.getName() == name
					&& peer.getArity() == arity
					&& peer.isQuoted() == _isQuoted;
			} 
			catch (InvalidCastException) 
			{
				return false;
			}
		}
Exemple #6
0
        public void runTest(bool useLock)
        {
            var sharedObject = new SharedObject(useLock);

            var threadWork1 = new Work(sharedObject, useLock);
            var newThread1 = new System.Threading.Thread(threadWork1, "Thread 1");

            var threadWork2 = new Work(sharedObject, useLock);
            var newThread2 = new System.Threading.Thread(threadWork2, "Thread 2");

            newThread1.Start();
            newThread2.Start();

            newThread1.Join();
            newThread2.Join();

            AssertEquals(sharedObject.Counter, 2);
        }
Exemple #7
0
		public override bool equivalent(SharedObject obj) 
		{
			if(base.equivalent(obj)) 
			{
				ATermAppl peer = (ATermAppl) obj;
				if (peer.getAFun().equals(fun)) 
				{
					for (int i=0; i<args.Length; i++) 
					{
						if (!peer.getArgument(i).equals(args[i])) 
						{
							return false;
						}
					}
					return true;
				}
			}
			return false;
		}
    void UpdateWithNativePlugin()
    {
        SharedObject shared = new SharedObject ();

        // Set up the current configuration.
        shared.fftPointNumber = fftPointNumberForBands [(int)bandType];
        shared.bandType = (int)bandType;

        // Run the native plug-in.
        UnityAudioBridge_Update (ref shared);

        // Count the number of bands.
        var bandCount = 0;
        while (shared.bandLevels[bandCount] <= 0.0f) {
            bandCount++;
        }

        // Reallocate the arrays if it needs.
        if (levels == null || levels.Length != bandCount) {
            levels = new float[bandCount];
            meanLevels = new float[bandCount];
        }

        // Retrieve the result.
        var filter = Mathf.Exp (-sensibility * Time.deltaTime);
        for (var i = 0; i < bandCount; i++) {
            levels [i] = shared.bandLevels [i];
            meanLevels [i] = levels [i] - (levels [i] - meanLevels [i]) * filter;
        }
    }
 /// <summary>
 /// 
 /// </summary>
 private UserControl AddPropertyPanel(SharedObject element)
 {
     return new panelSharedObject();
 }
 /// <summary>
 /// 
 /// </summary>
 private void tab_Select(string imagekey, string p, SharedObject element)
 {
     tabPage.Text = element.Name;
     tabPage.ImageKey = imagekey;
     tabPage.Controls.Clear();
     UserControl panel = AddPropertyPanel(element);
     if (panel != null)
     {
         panel.Dock = DockStyle.Fill;
         tabPage.Controls.Add(panel);
         ((panelSharedObject)panel).Populate(p, element);
     }
 }
Exemple #11
0
		public override bool equivalent(SharedObject obj) 
		{
			if (base.equivalent(obj)) 
			{
				ATermList peer = (ATermList) obj;
				if (peer.getLength() == length) 
				{
					return peer.getFirst().Equals(first) && peer.getNext().Equals(next);
				}
			}
			return false;
		}
Exemple #12
0
 public override void OnReset()
 {
     targetValue = null;
     targetVariable = null;
 }
		public virtual SharedObject build(SharedObject prototype) 
		{
			nbCall++;
	
			SharedObject foundObj;
			Entry[] tab = table;
			int hash = prototype.GetHashCode();
			int index = hashKey(hash);

			for (Entry e = tab[index], prev = null; e != null; e = e.next) 
			{
				foundObj = (SharedObject) e.Target;
				if (foundObj == null) 
				{
					// Found a reference to a garbage collected term
					// remove it to speed up lookups.
					if (prev != null) 
					{
						prev.next = e.next;
						e.Target = null; //clear();
					}
					else 
					{
						tab[index] = e.next;
						e.Target = null; // .clear();
					}
					nbRemoved++;
					tableSize[index]--;
				}
				else 
				{
					// Found a reference
					nbFoundReference++;
		
					if (prototype.equivalent(foundObj)) 
					{    
						nbFoundExactReference++;

						// swap the found object
						if (prev != null && (e.value - tab[index].value > 5)) 
						{
							nbSwapEntry++;
							prev.next = e.next;
							e.next = tab[index];
							tab[index] = e;
						}
						e.value++;
						return foundObj;
					}
					else 
					{
						// create or lookup collision
						nbProjectionCollision++;
						if (foundObj.GetHashCode() == hash) 
						{
							nbHashingCollision++;
						}
					}

					prev = e;
				}
			}

			// No similar SharedObject found, so build a new one
			int count = nbAdd - nbRemoved;
			if (false && count < minThreshold) 
			{
				//System.out.println("count = " + count + " < tminThreshold = " + minThreshold);
				decreaseCapacity();
				tab = table;
				index = hashKey(hash);
			}
			else if (count >= maxThreshold) 
			{
				/*
				 * Very simple strategy:
				 *  - try a cleanup
				 *  - rehash next time
				 */
				if (!cleanupDone) 
				{
					cleanupDone = true;
					System.GC.Collect();
					cleanup();
				}
				else 
				{
					cleanupDone = false;
					increaseCapacity();
					tab = table;
					index = hashKey(hash);
				}
			}

			foundObj = prototype.duplicate();
			if (prototype is SharedObjectWithID) 
			{
				((SharedObjectWithID) foundObj).setUniqueIdentifier(getFreshId());
			}
			tab[index] = new Entry(foundObj, tab[index]);
			nbAdd++;
			tableSize[index]++;
    
			return foundObj;
		}
 public override void OnReset()
 {
     variable = null;
     compareTo = null;
 }
 static extern int UnityAudioBridge_Update(ref SharedObject shared);
 static int UnityAudioBridge_Update(ref SharedObject shared)
 {
     // Make dummy spectrum.
     shared.bandLevels = new float[32];
     var bandCount = middleFrequenciesForBands [shared.bandType].Length;
     for (var i = 0; i < 32; i++) {
         shared.bandLevels [i] = (i < bandCount) ? -100.0f : 1.0f;
     }
     return 0;
 }
 /// <summary>
 /// 
 /// </summary>
 private void OpenSharedObject(string filename)
 {
     try
     {
         currentFile = filename;
         currentSol = Reader.Parse(filename);
         tabControl.Visible = true;
     }
     catch (Exception e)
     {
         MessageBox.Show(e.Message, "Error while parsing the shared object.", MessageBoxButtons.OK, MessageBoxIcon.Error);
         return;
     }
     reloadToolStripMenuItem.Enabled = true;
     PopulateTree(currentSol);
 }
Exemple #18
0
 public override void OnReset()
 {
     targetGameObject = null;
     clip = null;
     volumeScale = 1;
 }
 /// <summary>
 /// 
 /// </summary>
 private void CloseSharedObject()
 {
     if (currentSol != null)
     {
         EmptyTree();
         currentSol = null;
     }
     currentFile = null;
     reloadToolStripMenuItem.Enabled = false;
     tabControl.Visible = false;
     toolStripStatusLabel.Text = "Ready.";
 }
Exemple #20
0
 public Work(SharedObject sharedObject, bool useLock)
 {
     _sharedObject = sharedObject;
     _useLock = useLock;
 }
        /// <summary>
        /// 
        /// </summary>
        private void PopulateTree(SharedObject obj)
        {
            this.treeView.Nodes.Clear();
            this.treeView.BeginUpdate();

            TreeNode rootnode = new TreeNode(currentSol.Name);
            rootnode.Tag = currentSol;
            rootnode.ImageKey = "shared_object";
            rootnode.SelectedImageKey = "shared_object";
            treeView.Nodes.Add(rootnode);

            TreeNode datanode = new TreeNode("data");
            AssignImage(datanode, (IAMFBase)obj.Data);
            datanode.Tag = currentSol.Data;

            foreach (string key in ((Dictionary<string,object>)obj.Data.Source).Keys)
            {
                Dictionary<string, object> data = (Dictionary<string, object>)obj.Data.Source;
                TreeNode node = new TreeNode(key);
                AssignImage(node, (AMFBase)data[key]);
                node.Tag = ((Dictionary<string, object>)obj.Data.Source)[key];
                PopulateTree(node, ((Dictionary<string, object>)obj.Data.Source)[key]);
                datanode.Nodes.Add(node);
            }
            rootnode.Nodes.Add(datanode);
            this.treeView.EndUpdate();
            toolStripStatusLabel.Text = "Name: " + currentSol.Name + "  |  Size: " + currentSol.FileSize + " bytes  |  AMF encoding: " + currentSol.AMFEncoding;
            this.treeView.SelectedNode = rootnode;

        }