예제 #1
0
		public void Basic()
		{
			using (var array = new ArrayPtr())
			{
				Assert.IsNotNull(array);
			}
		}
		internal static int ComVecPropFromManagedVecProp(int[] hvos, int hvo, int tag, ArrayPtr rghvo, int chvoMax)
		{
			if (hvos.Length > chvoMax)
				throw new ArgumentException("The count is greater than the parameter 'chvo'.");

			MarshalEx.ArrayToNative(rghvo, chvoMax, hvos);
			return hvos.Length;
		}
예제 #3
0
		public void DisposingArrayPtrOfOwnMemoryDoesFree_1()
		{
			IntPtr arrayIntPtr;
			using (var array = new ArrayPtr(10))
			{
				arrayIntPtr = array.IntPtr;
				Marshal.WriteByte(arrayIntPtr, (byte)123);
			}
			byte b = Marshal.ReadByte(arrayIntPtr);
			Assert.AreEqual((byte)0, b, "Owned memory should have been freed");
		}
예제 #4
0
		public void DisposingArrayPtrOfNativeOwnedMemoryDoesNotFree()
		{
			var intptr = Marshal.AllocCoTaskMem(10);
			using (var array = new ArrayPtr(intptr))
			{
				Marshal.WriteByte(intptr, (byte)123);
			}

			byte b = Marshal.ReadByte(intptr);
			Assert.AreEqual((byte)123, b, "native-owned memory should not have been freed");
			Marshal.FreeCoTaskMem(intptr);
		}
예제 #5
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Perform compatibility normalization of the input string, that is, every character
		/// which has a compatibility decomposition is decomposed (recursively). This is KD
		/// normalization as defined by Unicode TR 15.
		/// </summary>
		/// ------------------------------------------------------------------------------------
		public void NormalizeKdRgch(string _rgchIn, int cchIn, ArrayPtr _rgchOut, int cchMaxOut, out int _cchOut)
		{
			throw new NotImplementedException();
		}
예제 #6
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Get line breaking properties (from enumeration LgLBP) for an array of characters.
		/// This passes an array in, and an array with the same number of elements out, to
		/// improve efficiency when properties are required for a string of characters.
		/// See <see href="www.unicode.org/unicode/reports/tr14/">www.unicode.org/unicode/reports/tr14/</see>.
		/// </summary>
		/// ------------------------------------------------------------------------------------
		public void GetLineBreakProps(string _rgchIn, int cchIn, ArrayPtr _rglbOut)
		{
			throw new NotImplementedException();
		}
		public void UnicodePropRgch(int obj, int tag, ArrayPtr _rgch, int cchMax, out int _cch)
		{
			throw new NotImplementedException();
		}
		public void VecProp(int hvo, int tag, int chvoMax, out int _chvo, ArrayPtr _rghvo)
		{
			throw new NotImplementedException();
		}
		public void AllTextSelInfo(out int _ihvoRoot, int cvlsi, ArrayPtr _rgvsli,
			out int _tagTextProp, out int _cpropPrevious, out int _ichAnchor, out int _ichEnd,
			out int _ws, out bool _fAssocPrev, out int _ihvoEnd, out ITsTextProps _pttp)
		{
			_ihvoRoot = 0;
			_tagTextProp = 0;
			_cpropPrevious = 0;
			_ichAnchor = 0;
			_ichEnd = 0;
			_ws = 0;
			_fAssocPrev = false;
			_ihvoEnd = 0;
			_pttp = null;
		}
		public void GetParaProps(int cttpMax, ArrayPtr _rgpvps, out int _cttp)
		{
			_cttp = 0;
		}
		public void GetSelectionProps(int cttpMax, ArrayPtr _rgpttp,
			ArrayPtr _rgpvps, out int _cttp)
		{
			_cttp = 0;
		}
예제 #12
0
		public void GetCharPlacement(int ichBase, IVwGraphics _vg, int ichMin, int ichLim, Rect rcSrc, Rect rcDst, bool fSkipSpace, int cxdMax, out int _cxd, ArrayPtr _rgxdLefts, ArrayPtr _rgxdRights, ArrayPtr _rgydUnderTops)
		{
			throw new System.NotImplementedException();
		}
예제 #13
0
		/// <summary>
		/// Get the full contents of the specified sequence in one go.
		/// </summary>
		/// <param name="obj">hvo</param><param name="tag">tag</param><param name="chvoMax">chvoMax</param><param name="chvo">chvo</param><param name="rghvo">rghvo</param>
		public void VecProp(int obj, int tag, int chvoMax, out int chvo, ArrayPtr rghvo)
		{
			m_cache.VecProp(obj, tag, chvoMax, out chvo, rghvo);
		}
예제 #14
0
 /// <summary></summary>
 public void GetWritingSystems(SIL.FieldWorks.Common.COMInterfaces.ArrayPtr rgws, int cws)
 {
     throw new NotImplementedException();
 }
예제 #15
0
 /// -----------------------------------------------------------------------------------
 /// <summary>
 /// Re-Allocates memory for <paramref name="nMaxSize"/> elements and returns a pointer
 /// suitable to be passed as array to a COM method.
 /// </summary>
 /// <param name="arrayPtr">Pointer with previously allocated memory</param>
 /// <param name="nMaxSize">Max. number of elements in the array</param>
 /// <typeparam name="T">Type of elements in array</typeparam>
 /// -----------------------------------------------------------------------------------
 static public void ArrayToNative <T>(ref ArrayPtr arrayPtr, int nMaxSize)
 {
     arrayPtr.Resize(nMaxSize * SizeOf(typeof(T)));
 }
예제 #16
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Convert a string to upper case. Characters that are not Ll or Lt pass through
		/// unchanged. Note that the output may be longer than the input! This function, unlike
		/// <c>get_ToUpperCh</c>, will apply multicharacter conversions if Unicode specifies them.
		/// If cchOut is zero, just return the length needed.
		/// </summary>
		/// ------------------------------------------------------------------------------------
		public void ToUpperRgch(string _rgchIn, int cchIn, ArrayPtr _rgchOut, int cchOut, out int _cchRet)
		{
			throw new NotImplementedException();
		}
예제 #17
0
 /// -----------------------------------------------------------------------------------
 /// <summary>
 /// Converts a managed array to a pointer to an unmanaged array that can
 /// be passed to a COM method.
 /// </summary>
 /// <param name="unmanagedObj">Unamanged array pointer</param>
 /// <param name="nMaxSize">Maximum size of the array</param>
 /// <param name="array">Managed array</param>
 /// <typeparam name="T">Type of elements in array</typeparam>
 /// <remarks>This method is only necessary for [out] or [in,out] arrays. For
 /// [in] arrays the .NET marshalling works.</remarks>
 /// -----------------------------------------------------------------------------------
 static public void ArrayToNative <T>(ArrayPtr unmanagedObj, int nMaxSize, T[] array)
 {
     Debug.Assert(array.Length <= nMaxSize);
     CopyElements(unmanagedObj, array);
 }
예제 #18
0
		/// <summary>
		/// This is called when we have put all we can on the current line. Sometimes we may have put too much!
		/// If so, return false, to indicate we can't finalize a line in this state, and trigger backtracking.
		/// </summary>
		private bool FinalizeLine()
		{
			Debug.Assert(m_lines.Count > 0);
			Debug.Assert(m_lines.Last().Boxes.Count() > 0);
			var lastBox = m_lines.Last().Boxes.Last() as StringBox;
			if (lastBox == null)
				return true; // for now it's always valid to break after a non-string box.
			var est = m_lineSegTypes.Last();
			// If we know that's a bad break, backtrack.
			if (est == LgEndSegmentType.kestBadBreak)
				return false;
			if (est != LgEndSegmentType.kestWsBreak)
				return true; // all other kinds of break we accept.
			// For a writing-system break, we must try to figure out whether we can break here.
			int ichMin = lastBox.IchMin;
			int length = lastBox.Segment.get_Lim(ichMin);
			int ichLast = ichMin + length - 1;
			// Enhance JohnT: MAYBE we should check for surrogate? But new surrogate pairs we can break after are unlikely.
			if (ichLast < 0)
				return false; // paranoia
			string lastChar = Fetch(ichLast, ichLast + 1);
			var cpe = LgIcuCharPropEngineClass.Create();
			byte lbp;
			using (var ptr = new ArrayPtr(1))
			{
				cpe.GetLineBreakProps(lastChar, 1, ptr);
				lbp = Marshal.ReadByte(ptr.IntPtr);
			}
			lbp &= 0x1f; // strip 'is it a space' high bit
			// If it's a space (or other character which provides a break opportunity after),
			// go ahead and break. Otherwise treat as bad break.
			if (lbp != (byte)LgLBP.klbpSP && lbp != (byte)LgLBP.klbpBA && lbp != (byte)LgLBP.klbpB2)
				return false; // can't break here, must backtrack
			return true; // stick with the break we have.
		}
		public void GetHardAndSoftCharProps(int cttpMax, ArrayPtr _rgpttpSel,
			ArrayPtr _rgpvpsSoft, out int _cttp)
		{
			_cttp = 0;
		}
예제 #20
0
		/// <summary>
		/// Get the specified range of (rendered) characters from the text source.
		/// </summary>
		string Fetch(int ichMin, int ichLim)
		{
			using (ArrayPtr ptr = new ArrayPtr(ichLim - ichMin))
			{
				m_para.Source.Fetch(ichMin, ichLim, ptr.IntPtr);
				return MarshalEx.NativeToString(ptr, ichLim - ichMin, true);
			}

		}
		public void GetHardAndSoftParaProps(int cttpMax, ITsTextProps[] _rgpttpPara,
			ArrayPtr _rgpttpHard, ArrayPtr _rgpvpsSoft, out int _cttp)
		{
			_cttp = 0;
		}
예제 #22
0
		public void GetHardAndSoftCharProps(int cttpMax, ArrayPtr _rgpttpSel, ArrayPtr _rgpvpsSoft, out int _cttp)
		{
			throw new NotImplementedException();
		}
		public void AllSelEndInfo(bool fEndPoint, out int _ihvoRoot, int cvlsi, ArrayPtr _rgvsli,
			out int _tagTextProp, out int _cpropPrevious, out int _ich, out int _ws,
			out bool _fAssocPrev, out ITsTextProps _pttp)
		{
			_ihvoRoot = 0;
			_tagTextProp = 0;
			_cpropPrevious = 0;
			if (fEndPoint)
				_ich = End;
			else
				_ich = Anchor;
			_ws = 0;
			_fAssocPrev = false;
			_pttp = null;
		}
예제 #24
0
		public void GetParaProps(int cttpMax, ArrayPtr _rgpvps, out int _cttp)
		{
			throw new NotImplementedException();
		}
		public void BinaryPropRgb(int obj, int tag, ArrayPtr _rgb, int cbMax, out int _cb)
		{
			throw new NotImplementedException();
		}
예제 #26
0
		public void GetHardAndSoftParaProps(int cttpMax, ITsTextProps[] _rgpttpPara, ArrayPtr _rgpttpHard, ArrayPtr _rgpvpsSoft, out int _cttp)
		{
			throw new NotImplementedException();
		}
		public void GetWritingSystems(ArrayPtr rgws, int cws)
		{
			throw new NotImplementedException();
		}
예제 #28
0
		public void AllTextSelInfo(out int _ihvoRoot, int cvlsi, ArrayPtr _rgvsli, out int _tagTextProp, out int _cpropPrevious, out int _ichAnchor, out int _ichEnd, out int _ws, out bool _fAssocPrev, out int _ihvoEnd, out ITsTextProps _pttp)
		{
			throw new NotImplementedException();
		}
예제 #29
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Get line break status (from combinations of values in enumeration LgLineBreakStatus)
		/// of each character in the input array.
		/// </summary>
		/// ------------------------------------------------------------------------------------
		public void GetLineBreakStatus(byte[] _rglbpIn, int cb, ArrayPtr _rglbsOut)
		{
			throw new NotImplementedException();
		}
예제 #30
0
		public void AllSelEndInfo(bool fEndPoint, out int _ihvoRoot, int cvlsi, ArrayPtr _rgvsli, out int _tagTextProp, out int _cpropPrevious, out int _ich, out int _ws, out bool _fAssocPrev, out ITsTextProps _pttp)
		{
			throw new NotImplementedException();
		}
예제 #31
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Strip diacritics. Specifically, removes all characters that have the property Lm or
		/// Mn. Note that this will not comvert a single code point that includes a diacritic to
		/// its unmodified equivalent. It is usually desireable to first perform normalization
		/// (form D or KD) before stripping diacritics.
		/// </summary>
		/// ------------------------------------------------------------------------------------
		public void StripDiacriticsRgch(string _rgchIn, int cchIn, ArrayPtr _rgchOut, int cchMaxOut, out int _cchOut)
		{
			throw new NotImplementedException();
		}
		public int get_WritingSystemsOfInterest(int cwsMax, ArrayPtr _ws)
		{
			throw new NotImplementedException();
		}
예제 #33
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// This combines the functions of <c>GetLineBreakProps</c> and <c>GetLineBreakStatus</c>,
		/// plus the ability to skip part of the string, and stop at break characters.
		/// The first two arguments define an array of characters as for <c>GetLineBreakProps</c>.
		/// The output is basically what would be produced by passing the output of
		/// that method as input to GetLineBreakStatus, with two exceptions:
		/// 1. We only want line break status info for characters from ichMin to ichLim.
		/// (A larger array is passed in because we may need to look at preceding characters
		/// to confidently know whether we can break after the char at ichMin.)
		/// 2. If we detect a character which forces a line or segment break in the range
		/// ichMin..ichLim, we stop and do not return any info about subsequent characters.
		/// Also, we set pichBreak to the index of the break character.
		/// pichBreak is set to 1 if we don't find a break character.
		/// Break characters are things like CR, LF, TAB, or the embedded object character.
		/// </summary>
		/// ------------------------------------------------------------------------------------
		public void GetLineBreakInfo(string _rgchIn, int cchIn, int ichMin, int ichLim, ArrayPtr _rglbsOut, out int _ichBreak)
		{
			throw new NotImplementedException();
		}
예제 #34
0
 public void DoOwnMemory_1()
 {
     using (var array = new ArrayPtr(10))
         Assert.AreEqual(true, array.OwnMemory, "Should own memory");
 }