internal unsafe DBCSCodePageEncoding(SerializationInfo info, StreamingContext context) : base(0)
 {
     this.mapBytesToUnicode = null;
     this.mapUnicodeToBytes = null;
     this.mapCodePageCached = null;
     throw new ArgumentNullException("this");
 }
        private LZ77()
        {
            _dataAddr = Marshal.AllocHGlobal((0x1000 + 0x10000 + 0x10000) * 2);

            _Next = (ushort*)_dataAddr;
            _First = _Next + WindowLength;
            _Last = _First + 0x10000;
        }
 static unsafe CharUnicodeInfo()
 {
     UnicodeDataHeader* headerPtr = (UnicodeDataHeader*) s_pDataTable;
     s_pCategoryLevel1Index = (ushort*) (s_pDataTable + headerPtr->OffsetToCategoriesIndex);
     s_pCategoriesValue = s_pDataTable + ((byte*) headerPtr->OffsetToCategoriesValue);
     s_pNumericLevel1Index = (ushort*) (s_pDataTable + headerPtr->OffsetToNumbericIndex);
     s_pNumericValues = s_pDataTable + ((byte*) headerPtr->OffsetToNumbericValue);
     s_pDigitValues = (DigitValues*) (s_pDataTable + headerPtr->OffsetToDigitValue);
     nativeInitTable(s_pDataTable);
 }
 static unsafe CharUnicodeInfo()
 {
     UnicodeDataHeader* pDataTable = (UnicodeDataHeader*) m_pDataTable;
     m_pCategoryLevel1Index = (ushort*) (m_pDataTable + pDataTable->OffsetToCategoriesIndex);
     m_pCategoriesValue = m_pDataTable + ((byte*) pDataTable->OffsetToCategoriesValue);
     m_pNumericLevel1Index = (ushort*) (m_pDataTable + pDataTable->OffsetToNumbericIndex);
     m_pNumericValues = m_pDataTable + ((byte*) pDataTable->OffsetToNumbericValue);
     m_pDigitValues = (DigitValues*) (m_pDataTable + pDataTable->OffsetToDigitValue);
     nativeInitTable(m_pDataTable);
 }
 public SNESGraphicsDecoder(LibsnesApi api, SnesColors.ColorType pal)
 {
     this.api = api;
     colortable = SnesColors.GetLUT(pal);
     IntPtr block = (IntPtr)api.QUERY_get_memory_data(LibsnesApi.SNES_MEMORY.VRAM);
     vram = (byte*)block;
     vram16 = (ushort*)block;
     block = (IntPtr)api.QUERY_get_memory_data(LibsnesApi.SNES_MEMORY.CGRAM);
     cgram = (ushort*)block;
     block = (IntPtr)api.QUERY_get_memory_data(LibsnesApi.SNES_MEMORY.OAM);
     oam = (byte*)block;
 }
		public RippleModel (Size screenSize, int meshFactor, int touchRadius, Size textureSize)
		{
			Console.WriteLine ("New RippleModel");
			this.screenSize = screenSize;
			this.meshFactor = meshFactor;
			this.touchRadius = touchRadius;
			poolWidth = screenSize.Width/meshFactor;
			poolHeight = screenSize.Height/meshFactor;
        
			if ((float)screenSize.Height/screenSize.Width < (float)textureSize.Width/textureSize.Height){
				texCoordFactorS = (float)(textureSize.Height*screenSize.Height)/(screenSize.Width*textureSize.Width);            
				texCoordOffsetS = (1 - texCoordFactorS)/2f;
				
				texCoordFactorT = 1;
				texCoordOffsetT = 0;
			} else {
				texCoordFactorS = 1;
				texCoordOffsetS = 0;            
				
				texCoordFactorT = (float)(screenSize.Width*textureSize.Width)/(textureSize.Height*screenSize.Height);
				texCoordOffsetT = (1 - texCoordFactorT)/2f;
			}
			
			rippleCoeff = new float [touchRadius*2+1, touchRadius*2+1];
			
			// +2 for padding the border
			rippleSource = new float [poolWidth+2, poolHeight+2];
			rippleDest = new float [poolWidth+2, poolHeight+2];
			
			unsafe {
				int poolsize2 = poolWidth*poolHeight*2;
				rippleVertices = (float *)Marshal.AllocHGlobal (poolsize2 * sizeof(float));
				rippleTexCoords = (float *)Marshal.AllocHGlobal(poolsize2 * sizeof(float));
				rippleIndicies = (ushort *)Marshal.AllocHGlobal((poolHeight-1)*(poolWidth*2+2)*sizeof(ushort));
			}
			
			InitRippleCoef ();
			InitMesh ();
		}
		/// <summary>
		/// Creates a new CudaRegisteredHostMemory_ushort from an existing IntPtr. IntPtr must be page size aligned (4KBytes)!
		/// </summary>
		/// <param name="hostPointer">must be page size aligned (4KBytes)</param>
		/// <param name="size">In elements</param>
		public CudaRegisteredHostMemory_ushort(IntPtr hostPointer, SizeT size)
		{
			_intPtr = hostPointer;
			_size = size;
			_typeSize = (SizeT)Marshal.SizeOf(typeof(ushort));
			_ptr = (ushort*)_intPtr;
		}
 private void ReAllocGlyphBuffers(int newGlyphCapacity)
 {
     Glyphs = (ushort*)Memory.ReAlloc(Glyphs, newGlyphCapacity * sizeof(ushort));
     GlyphVisualAttributes = (SCRIPT_VISATTR*)Memory.ReAlloc(GlyphVisualAttributes, newGlyphCapacity * sizeof(SCRIPT_VISATTR));
     GlyphAdvanceWidths = (int*)Memory.ReAlloc(GlyphAdvanceWidths, newGlyphCapacity * sizeof(int));
     GlyphOffsets = (GOFFSET*)Memory.ReAlloc(GlyphOffsets, newGlyphCapacity * sizeof(GOFFSET));
 }
 public int Bind([NativeTypeName("LPOLESTR")] ushort *szName, [NativeTypeName("ULONG")] uint lHashVal, [NativeTypeName("WORD")] ushort wFlags, ITypeInfo **ppTInfo, DESCKIND *pDescKind, BINDPTR *pBindPtr)
 {
     return(((delegate * unmanaged <ITypeComp *, ushort *, uint, ushort, ITypeInfo **, DESCKIND *, BINDPTR *, int>)(lpVtbl[3]))((ITypeComp *)Unsafe.AsPointer(ref this), szName, lHashVal, wFlags, ppTInfo, pDescKind, pBindPtr));
 }
 /// <summary>
 /// Canvas üzerinde çizim yapılmaya başlamadan önce mutlaka çağırılmalıdır. Çizim bitip
 /// ekrana yapıştırmak istediğimiz zaman da <b>EndDrawing()</b> çağırılmalıdır.
 /// </summary>
 /// <seealso cref="EndDrawing()"/>
 public void BeginDrawing()
 {
     m_bitmapData = m_bitmap.LockBits(m_bitmapRect, ImageLockMode.ReadWrite, PixelFormat.Format16bppRgb565);
     m_DIBImage = (ushort*)m_bitmapData.Scan0;
     m_bmpStride = m_bitmapData.Stride;
 }
        private unsafe void ProcessDepthFrameData(IntPtr depthFrameData, uint depthFrameDataSize, ushort minDepth, ushort maxDepth)
        {
          
            
            // depth frame data is a 16 bit value
            this.frameData = (ushort*)depthFrameData;

            

            // convert depth to a visual representation
            for (int i = 0; i < (int)(depthFrameDataSize / this.depthFrameDescription.BytesPerPixel); ++i)
            {
                // Get the depth for this pixel
                ushort depth = frameData[i];

                // To convert to a byte, we're mapping the depth value to the byte range.
                // Values outside the reliable depth range are mapped to 0 (black).
                this.depthPixels[i] = (byte)(depth >= minDepth && depth <= maxDepth ? (depth / MapDepthToByte) : 0);
            }
        }
 public int BindType([NativeTypeName("LPOLESTR")] ushort *szName, [NativeTypeName("ULONG")] uint lHashVal, ITypeInfo **ppTInfo, ITypeComp **ppTComp)
 {
     return(((delegate * unmanaged <ITypeComp *, ushort *, uint, ITypeInfo **, ITypeComp **, int>)(lpVtbl[4]))((ITypeComp *)Unsafe.AsPointer(ref this), szName, lHashVal, ppTInfo, ppTComp));
 }
 public static extern BOOL PathIsSlowW([NativeTypeName("LPCWSTR")] ushort *pszFile, [NativeTypeName("DWORD")] uint dwAttr);
 public static extern void PathQualify([NativeTypeName("PWSTR")] ushort *psz);
 public HRESULT hasFeature([NativeTypeName("BSTR")] ushort *feature, [NativeTypeName("BSTR")] ushort *version, [NativeTypeName("VARIANT_BOOL *")] short *hasFeature)
 {
     return(((delegate * unmanaged <IXMLDOMImplementation *, ushort *, ushort *, short *, int>)(lpVtbl[7]))((IXMLDOMImplementation *)Unsafe.AsPointer(ref this), feature, version, hasFeature));
 }
Exemple #16
0
 public int SetSource([NativeTypeName("BSTR")] ushort *pUrl)
 {
     return(((delegate * unmanaged <IMFMediaSharingEngine *, ushort *, int>)(lpVtbl[6]))((IMFMediaSharingEngine *)Unsafe.AsPointer(ref this), pUrl));
 }
Exemple #17
0
 public int CanPlayType([NativeTypeName("BSTR")] ushort *type, MF_MEDIA_ENGINE_CANPLAY *pAnswer)
 {
     return(((delegate * unmanaged <IMFMediaSharingEngine *, ushort *, MF_MEDIA_ENGINE_CANPLAY *, int>)(lpVtbl[13]))((IMFMediaSharingEngine *)Unsafe.AsPointer(ref this), type, pAnswer));
 }
 public int GenerateRequest([NativeTypeName("LPCWSTR")] ushort *initDataType, [NativeTypeName("const BYTE *")] byte *initData, [NativeTypeName("DWORD")] uint initDataSize)
 {
     return(((delegate * unmanaged <IMFContentDecryptionModuleSession *, ushort *, byte *, uint, int>)(lpVtbl[7]))((IMFContentDecryptionModuleSession *)Unsafe.AsPointer(ref this), initDataType, initData, initDataSize));
 }
 public int Load([NativeTypeName("LPCWSTR")] ushort *sessionId, [NativeTypeName("BOOL *")] int *loaded)
 {
     return(((delegate * unmanaged <IMFContentDecryptionModuleSession *, ushort *, int *, int>)(lpVtbl[6]))((IMFContentDecryptionModuleSession *)Unsafe.AsPointer(ref this), sessionId, loaded));
 }
Exemple #20
0
 public HRESULT SetName([NativeTypeName("LPCWSTR")] ushort *Name)
 {
     return(((delegate * unmanaged <ID3D12ProtectedSession *, ushort *, int>)(lpVtbl[6]))((ID3D12ProtectedSession *)Unsafe.AsPointer(ref this), Name));
 }
Exemple #21
0
 //
 // This exists so that I don't have to mark GetNumericValue as being unsafe.
 // The transition from safe to unsafe is something that we don't want untrusted code
 // to have to do.
 //
 internal unsafe static double InternalGetNumericValue(char ch)
 {
     //
     // If we haven't get the unsafe pointers to the numeric table before, do it now.
     //            
     if (m_pNumericDataTable == null) {
         m_pNumericDataTable = nativeGetNumericDataTable();
         m_pNumericLevel2WordOffset = nativeGetNumericLevel2Offset();
         m_pNumericFloatData = nativeGetNumericFloatData();
     }
     // Get the level 2 item from the highest 8 bit (8 - 15) of ch.
     byte index1 = m_pNumericDataTable[ch >> 8];
     // Get the level 2 WORD offset from the 4 - 7 bit of ch.  This provides the base offset of the level 3 table.
     // The offset is referred to an float item in m_pNumericFloatData.
     // Note that & has the lower precedence than addition, so don't forget the parathesis.            
     ushort offset = m_pNumericLevel2WordOffset[(index1 << 4) + ((ch >> 4) & 0x000f)];
     // Get the result from the 0 -3 bit of ch.
     return (m_pNumericFloatData[offset + (ch & 0x000f)]);
 }
 public static extern HPSXA SHCreatePropSheetExtArray(HKEY hKey, [NativeTypeName("PCWSTR")] ushort *pszSubKey, uint max_iface);
        //
        // m_bUseUserOverride indicates that if we need to check for user-override values for this CultureInfo instance.
        // For the user default culture of the system, user can choose to override some of the values
        // associated with that culture.  For example, the default short-date format for en-US is
        // "M/d/yyyy", however, one may change it to "dd/MM/yyyy" from the Regional Option in
        // the control panel.
        // So when a CultureInfo is created, one can specify if the create CultureInfo should check
        // for user-override values, or should always get the default values.
        //
        //
        // AVOID USING P/INVOKE IN THIS CODEPATH.
        // AVOID USING P/INVOKE IN THIS CODEPATH.
        // AVOID USING P/INVOKE IN THIS CODEPATH.
        //
        // P/Invoke will cause COM to be initialized and sets the thread apartment model. Since CultureInfo is used early in the CLR process,
        // this will prevent Loader from having a chance to look at the executable and setting the apartment model to the one the application wants.



        //
        // Search order for creating a culture.
        //

        /*
           First, search by name
                if this is a known culture name from culture.nlp, and it is an alternative sort name (such as de-DE_phoneb)
                {
                    Get the name from the LANGID by removing the sort ID (so the name becomes de-DE). 
                    This is the name used for search replacment culture.
                }
                
                Check if this specified name has a custom/replacement culture file.
                if there is a custom/replacement culture file
                {
                    // This is a custom culture, or a replacement culture.
                    return; [CUSTOM/REPLACEMENT CULTURE (.NET CULTURE/SYNTHETIC CULTURE) FOUND BY NAME]
                }
                From culture.nlp, check if tihs is a vlid culture name
                if this is a valid culture name
                {
                    // This is a .NET culture.
                    return; [NON-REPLACEMENT .NET CULTURE FOUND BY NAME]
                }
                Check if this is a valid name from synthetic culture
                if this is a valid synthetic culture name
                {
                    // This is a synthetic culture. Set the cultureID, so we will
                    // create it when we search by LCID later.
                    // [SYNTHETIC CULTURE FOUND BY NAME]
                } else
                {
                    throw exception;    [INVALID NAME]
                }
           Then Search by LCID
                we'll come here only if the lcid is filled with synthetic culture Id.
                    // This is synthetic culture.
                    Get the name for this LANGID of this synthetic LCID.
                    if there is a replacement culture for this LCID by checking name.
                    {
                        Use it and return the replacement culture for synthetic culture.
                        return;  [REPLACEMENT SYNTHETIC CULTURE]
                    }
                    Init and return the synthetic culture.  
                    return;  [NON-REPLACEMENT SYNTHETIC CULTURE]
                    
                }
                otherwise throw exception
                
        */
        //
        // * IMPORTANT * cultureName should be in lower case.
        //
        private unsafe CultureTableRecord(String cultureName, bool useUserOverride)
        {
            BCLDebug.Assert(cultureName != null, "[CultureTableRecord::ctor] cultureName should be valid.");
            
            int cultureID = 0;
        
            // Special case for invariant name
            if (cultureName.Length == 0)
            {
                useUserOverride = false;
                cultureID = CultureInfo.LOCALE_INVARIANT;
            }

            this.m_bUseUserOverride = useUserOverride;

            // We prefer to look up by name (if available)
            int iDataItem = -1;
            if (cultureName.Length > 0)
            {
                // Check if this is an alternative sort name.
                String defaultTableActualName;
                int defaultTableCultureID;
                string name = cultureName;
                int defaultTableDataItem = CultureTable.Default.GetDataItemFromCultureName(name, out defaultTableCultureID, out defaultTableActualName);
                if (defaultTableDataItem >= 0 && 
                    (CultureInfo.GetSortID(defaultTableCultureID) > 0 || defaultTableCultureID == SPANISH_TRADITIONAL_SORT))
                {
                    String replacmentCultureName;

                    int nonSortId;
                    if (defaultTableCultureID == SPANISH_TRADITIONAL_SORT)
                        nonSortId = SPANISH_INTERNATIONAL_SORT;
                    else
                        nonSortId = CultureInfo.GetLangID(defaultTableCultureID);
                        
                    // This is an alternative sort culture.
                    if (CultureTable.Default.GetDataItemFromCultureID(nonSortId, out replacmentCultureName) >= 0)
                    {                                                                                
                        // This is the replacement culture name for an alternative sort.
                        name = ValidateCulturePieceToLower(replacmentCultureName, "cultureName", MAXSIZE_FULLTAGNAME);
                    }                        
                }

                // If the compatibility flag is defined and culture is replacemet culture then we don't 
                // open the custom culture file. instead we'll try to get framework/OS culture.
                if (!Environment.GetCompatibilityFlag(CompatibilityFlag.DisableReplacementCustomCulture) ||
                    IsCustomCultureId(defaultTableCultureID))
                {

                    // we always try the replacement custom cultures first.
                    //  Before call this function, call ValidateCulturePieceToLower() to verify
                    //  that the name does not contain illegal characters (such as "." or backslash.
                    m_CultureTable = GetCustomCultureTable(name);
                }
                
                if (m_CultureTable != null)
                {
                    //
                    // [CUSTOM/REPLACEMENT CULTURE (.NET CULTURE/SYNTHETIC CULTURE) FOUND BY NAME]
                    //
                    iDataItem = this.m_CultureTable.GetDataItemFromCultureName(name, out this.m_ActualCultureID, out this.m_ActualName);
                    if (defaultTableDataItem >= 0)
                    {
                        // This is a replacment culture (since defaultTableDataItem >= 0), use the default ID/Name from the table.
                        // For de-DE_phoneb, this will set the the actualCultureID to be 0x10407, instead of the LCID for replacment cutlure 0x0407.
                        this.m_ActualCultureID = defaultTableCultureID;
                        this.m_ActualName = defaultTableActualName;
                    }                    
                }

                if (iDataItem < 0 && defaultTableDataItem >= 0)
                {
                    //
                    // [NON-REPLACEMENT .NET CULTURE FOUND BY NAME] 
                    //
                    this.m_CultureTable = CultureTable.Default;
                    this.m_ActualCultureID = defaultTableCultureID;
                    this.m_ActualName = defaultTableActualName;
                    iDataItem = defaultTableDataItem;
                }

            }

            // If we couldn't get it by name, try culture ID.
            if (iDataItem < 0 && cultureID > 0)
            {
                if (cultureID == CultureInfo.LOCALE_INVARIANT)
                {
                    // Special case for the Invariant culture.
                    iDataItem = CultureTable.Default.GetDataItemFromCultureID(cultureID, out this.m_ActualName);
                    if (iDataItem > 0) 
                    {
                        m_ActualCultureID   = cultureID;
                        m_CultureTable      = CultureTable.Default;
                    }
                }
            }

            // If we found one, use it and return
            if (iDataItem >= 0)
            {
                // Found it, use it
                this.m_pData = (CultureTableData*)(this.m_CultureTable.m_pItemData +
                    this.m_CultureTable.m_itemSize * iDataItem);
                this.m_pPool = this.m_CultureTable.m_pDataPool;
                // Use name & ID from the file ('cept spanish traditional, which has to stay the same)
                this.m_CultureName = this.SNAME;
                this.m_CultureID = (m_ActualCultureID == SPANISH_TRADITIONAL_SORT) ? m_ActualCultureID : this.ILANGUAGE;

                        
                return;
            }

            // Error, if we have a name throw that name
            if (cultureName != null)
                throw new ArgumentException(
                    String.Format(
                        CultureInfo.CurrentCulture,
                        Environment.GetResourceString("Argument_InvalidCultureName"), cultureName), "name");

            // No name, throw the LCID
            throw new ArgumentException(
                String.Format(
                    CultureInfo.CurrentCulture,
                    Environment.GetResourceString("Argument_CultureNotSupported"), cultureID), "culture");
        }
 public static extern BOOL SHOpenPropSheetW([NativeTypeName("LPCWSTR")] ushort *pszCaption, [NativeTypeName("HKEY []")] HKEY *ahkeys, uint ckeys, [NativeTypeName("const CLSID *")] Guid *pclsidDefault, IDataObject *pdtobj, IShellBrowser *psb, [NativeTypeName("LPCWSTR")] ushort *pStartPage);
        [System.Security.SecurityCritical]  // auto-generated
        protected override unsafe void LoadManagedCodePage()
        {
            // Should be loading OUR code page
            Contract.Assert(pCodePage->CodePage == this.dataTableCodePage,
                "[DBCSCodePageEncoding.LoadManagedCodePage]Expected to load data table code page");

            // Make sure we're really a 1 byte code page
            if (pCodePage->ByteCount != 2)
                throw new NotSupportedException(
                    Environment.GetResourceString("NotSupported_NoCodepageData", CodePage));
            // Remember our unknown bytes & chars
            bytesUnknown = pCodePage->ByteReplace;
            charUnknown = pCodePage->UnicodeReplace;

            // Need to make sure the fallback buffer's fallback char is correct
            if (this.DecoderFallback.IsMicrosoftBestFitFallback)
            {
                ((InternalDecoderBestFitFallback)(this.DecoderFallback)).cReplacement = charUnknown;
            }

            // Is our replacement bytesUnknown a single or double byte character?
            byteCountUnknown = 1;
            if (bytesUnknown > 0xff)
                byteCountUnknown++;

            // We use fallback encoder, which uses ?, which so far all of our tables do as well
            Contract.Assert(bytesUnknown == 0x3f,
                "[DBCSCodePageEncoding.LoadManagedCodePage]Expected 0x3f (?) as unknown byte character");

            // Get our mapped section (bytes to allocate = 2 bytes per 65536 Unicode chars + 2 bytes per 65536 DBCS chars)
            // Plus 4 byte to remember CP # when done loading it. (Don't want to get IA64 or anything out of alignment)
            byte *pMemorySection = GetSharedMemory(65536 * 2 * 2 + 4 + this.iExtraBytes);
            
            mapBytesToUnicode = (char*)pMemorySection;
            mapUnicodeToBytes = (ushort*)(pMemorySection + 65536 * 2);
            mapCodePageCached = (int*)(pMemorySection + 65536 * 2 * 2 + this.iExtraBytes);

            // If its cached (& filled in) we don't have to do anything else
            if (*mapCodePageCached != 0)
            {
                Contract.Assert(((*mapCodePageCached == this.dataTableCodePage && this.bFlagDataTable) ||
                    (*mapCodePageCached == this.CodePage && !this.bFlagDataTable)),
                    "[DBCSCodePageEncoding.LoadManagedCodePage]Expected mapped section cached page flag to be set to data table or regular code page.");

                // Special case for GB18030 because it mangles its own code page after this function
                if ((*mapCodePageCached != this.dataTableCodePage && this.bFlagDataTable) ||
                    (*mapCodePageCached != this.CodePage && !this.bFlagDataTable))
                    throw new OutOfMemoryException(
                        Environment.GetResourceString("Arg_OutOfMemoryException"));

                // If its cached (& filled in) we don't have to do anything else
                return;
            }

            // Need to read our data file and fill in our section.
            // WARNING: Multiple code pieces could do this at once (so we don't have to lock machine-wide)
            //          so be careful here.  Only stick legal values in here, don't stick temporary values.

            // Move to the beginning of the data section
            char* pData = (char*)&(pCodePage->FirstDataWord);

            // We start at bytes position 0
            int bytePosition = 0;
            int useBytes = 0;

            while (bytePosition < 0x10000)
            {
                // Get the next byte
                char input = *pData;
                pData++;

                // build our table:
                if (input == 1)
                {
                    // Use next data as our byte position
                    bytePosition = (int)(*pData);
                    pData++;
                    continue;
                }
                else if (input < 0x20 && input > 0)
                {
                    // Advance input characters
                    bytePosition += input;
                    continue;
                }
                else if (input == 0xFFFF)
                {
                    // Same as our bytePosition
                    useBytes = bytePosition;
                    input = unchecked((char)bytePosition);
                }
                else if (input == LEAD_BYTE_CHAR) // 0xfffe
                {
                    // Lead byte mark
                    Contract.Assert(bytePosition < 0x100, "[DBCSCodePageEncoding.LoadManagedCodePage]expected lead byte to be < 0x100");
                    useBytes = bytePosition;
                    // input stays 0xFFFE
                }
                else if (input == UNICODE_REPLACEMENT_CHAR)
                {
                    // Replacement char is already done
                    bytePosition++;
                    continue;
                }
                else
                {
                    // Use this character
                    useBytes = bytePosition;
                    // input == input;
                }

                // We may need to clean up the selected character & position
                if (CleanUpBytes(ref useBytes))
                {
                    // Use this selected character at the selected position, don't do this if not supposed to.
                   if (input != LEAD_BYTE_CHAR)
                    {
                        // Don't do this for lead byte marks.
                        mapUnicodeToBytes[input] = unchecked((ushort)useBytes);
                    }
                    mapBytesToUnicode[useBytes] = input;
                }
                bytePosition++;
            }

            // See if we have any clean up junk to do
            CleanUpEndBytes(mapBytesToUnicode);

            // We're done with our mapped section, set our flag so others don't have to rebuild table.
            // We only do this if we're flagging(using) the data table as our primary mechanism
            if (this.bFlagDataTable)
                *mapCodePageCached = this.dataTableCodePage;
        }
 public static extern uint SoftwareUpdateMessageBox(HWND hWnd, [NativeTypeName("PCWSTR")] ushort *pszDistUnit, [NativeTypeName("DWORD")] uint dwFlags, [NativeTypeName("LPSOFTDISTINFO")] SOFTDISTINFO *psdi);
Exemple #27
0
		public static readonly bool IsReady = true; // always

		static Normalization ()
		{
			fixed (byte* tmp = propsArr) {
				props = tmp;
			}
			fixed (int* tmp = mappedCharsArr) {
				mappedChars = tmp;
			}
			fixed (short* tmp = charMapIndexArr) {
				charMapIndex = tmp;
			}
			fixed (short* tmp = helperIndexArr) {
				helperIndex = tmp;
			}
			fixed (ushort* tmp = mapIdxToCompositeArr) {
				mapIdxToComposite = tmp;
			}
			fixed (byte* tmp = combiningClassArr) {
				combiningClass = tmp;
			}
		}
Exemple #28
0
        private unsafe void RenderImDrawData(DrawData *draw_data)
        {
            // Rendering
            int display_w, display_h;

            display_w = _nativeWindow.Width;
            display_h = _nativeWindow.Height;

            Vector4 clear_color = new Vector4(114f / 255f, 144f / 255f, 154f / 255f, 1.0f);

            GL.Viewport(0, 0, display_w, display_h);
            GL.ClearColor(clear_color.X, clear_color.Y, clear_color.Z, clear_color.W);
            GL.Clear(ClearBufferMask.ColorBufferBit);

            // We are using the OpenGL fixed pipeline to make the example code simpler to read!
            // Setup render state: alpha-blending enabled, no face culling, no depth testing, scissor enabled, vertex/texcoord/color pointers.
            GL.GetInteger(GetPName.TextureBinding2D, out int last_texture);
            GL.PushAttrib(AttribMask.EnableBit | AttribMask.ColorBufferBit | AttribMask.TransformBit);
            GL.Enable(EnableCap.Blend);
            GL.BlendFunc(BlendingFactorSrc.SrcAlpha, BlendingFactorDest.OneMinusSrcAlpha);
            GL.Disable(EnableCap.CullFace);
            GL.Disable(EnableCap.DepthTest);
            GL.Enable(EnableCap.ScissorTest);
            GL.EnableClientState(ArrayCap.VertexArray);
            GL.EnableClientState(ArrayCap.TextureCoordArray);
            GL.EnableClientState(ArrayCap.ColorArray);
            GL.Enable(EnableCap.Texture2D);

            GL.UseProgram(0);

            // Handle cases of screen coordinates != from framebuffer coordinates (e.g. retina displays)
            IO io = ImGui.GetIO();

            ImGui.ScaleClipRects(draw_data, io.DisplayFramebufferScale);

            // Setup orthographic projection matrix
            GL.MatrixMode(MatrixMode.Projection);
            GL.PushMatrix();
            GL.LoadIdentity();
            GL.Ortho(
                0.0f,
                io.DisplaySize.X / io.DisplayFramebufferScale.X,
                io.DisplaySize.Y / io.DisplayFramebufferScale.Y,
                0.0f,
                -1.0f,
                1.0f);
            GL.MatrixMode(MatrixMode.Modelview);
            GL.PushMatrix();
            GL.LoadIdentity();

            // Render command lists

            for (int n = 0; n < draw_data->CmdListsCount; n++)
            {
                NativeDrawList *cmd_list   = draw_data->CmdLists[n];
                byte *          vtx_buffer = (byte *)cmd_list->VtxBuffer.Data;
                ushort *        idx_buffer = (ushort *)cmd_list->IdxBuffer.Data;

                DrawVert vert0 = *((DrawVert *)vtx_buffer);
                DrawVert vert1 = *(((DrawVert *)vtx_buffer) + 1);
                DrawVert vert2 = *(((DrawVert *)vtx_buffer) + 2);

                GL.VertexPointer(2, VertexPointerType.Float, sizeof(DrawVert), new IntPtr(vtx_buffer + DrawVert.PosOffset));
                GL.TexCoordPointer(2, TexCoordPointerType.Float, sizeof(DrawVert), new IntPtr(vtx_buffer + DrawVert.UVOffset));
                GL.ColorPointer(4, ColorPointerType.UnsignedByte, sizeof(DrawVert), new IntPtr(vtx_buffer + DrawVert.ColOffset));

                for (int cmd_i = 0; cmd_i < cmd_list->CmdBuffer.Size; cmd_i++)
                {
                    DrawCmd *pcmd = &(((DrawCmd *)cmd_list->CmdBuffer.Data)[cmd_i]);
                    if (pcmd->UserCallback != IntPtr.Zero)
                    {
                        throw new NotImplementedException();
                    }
                    else
                    {
                        GL.BindTexture(TextureTarget.Texture2D, pcmd->TextureId.ToInt32());
                        GL.Scissor(
                            (int)pcmd->ClipRect.X,
                            (int)(io.DisplaySize.Y - pcmd->ClipRect.W),
                            (int)(pcmd->ClipRect.Z - pcmd->ClipRect.X),
                            (int)(pcmd->ClipRect.W - pcmd->ClipRect.Y));
                        ushort[] indices = new ushort[pcmd->ElemCount];
                        for (int i = 0; i < indices.Length; i++)
                        {
                            indices[i] = idx_buffer[i];
                        }
                        GL.DrawElements(PrimitiveType.Triangles, (int)pcmd->ElemCount, DrawElementsType.UnsignedShort, new IntPtr(idx_buffer));
                    }
                    idx_buffer += pcmd->ElemCount;
                }
            }

            // Restore modified state
            GL.DisableClientState(ArrayCap.ColorArray);
            GL.DisableClientState(ArrayCap.TextureCoordArray);
            GL.DisableClientState(ArrayCap.VertexArray);
            GL.BindTexture(TextureTarget.Texture2D, last_texture);
            GL.MatrixMode(MatrixMode.Modelview);
            GL.PopMatrix();
            GL.MatrixMode(MatrixMode.Projection);
            GL.PopMatrix();
            GL.PopAttrib();

            _graphicsContext.SwapBuffers();
        }
        [System.Security.SecuritySafeCritical]  // auto-generated
        unsafe static bool InitTable() {

            // Go to native side and get pointer to the native table
            byte * pDataTable = GlobalizationAssembly.GetGlobalizationResourceBytePtr(typeof(CharUnicodeInfo).Assembly, UNICODE_INFO_FILE_NAME);

            UnicodeDataHeader* mainHeader = (UnicodeDataHeader*)pDataTable;

            // Set up the native pointer to different part of the tables.
            s_pCategoryLevel1Index = (ushort*) (pDataTable + mainHeader->OffsetToCategoriesIndex);
            s_pCategoriesValue = (byte*) (pDataTable + mainHeader->OffsetToCategoriesValue);
            s_pNumericLevel1Index = (ushort*) (pDataTable + mainHeader->OffsetToNumbericIndex);
            s_pNumericValues = (byte*) (pDataTable + mainHeader->OffsetToNumbericValue);
            s_pDigitValues = (DigitValues*) (pDataTable + mainHeader->OffsetToDigitValue);

            return true;
        }
 public int CreateMediaKeySystemAccess([NativeTypeName("BSTR")] ushort *keySystem, [NativeTypeName("IPropertyStore **")] IPropertyStore **ppSupportedConfigurationsArray, [NativeTypeName("UINT")] uint uSize, [NativeTypeName("IMFMediaKeySystemAccess **")] IMFMediaKeySystemAccess **ppKeyAccess)
 {
     return(((delegate * unmanaged <IMFMediaEngineClassFactory3 *, ushort *, IPropertyStore **, uint, IMFMediaKeySystemAccess **, int>)(lpVtbl[3]))((IMFMediaEngineClassFactory3 *)Unsafe.AsPointer(ref this), keySystem, ppSupportedConfigurationsArray, uSize, ppKeyAccess));
 }
 private void InitializeGlyphBuffers()
 {
     GlyphCapacity = 0;
     Glyphs = null;
     GlyphVisualAttributes = null;
     GlyphAdvanceWidths = null;
     GlyphOffsets = null;
 }
        //[CanBeNull]
        public Bitmap Draw(out Rectangle cropRectangle, BackgroundWorker worker)
        {
            cropRectangle = Rectangle.Empty;
            try
            {
                //byte[] convertedBlocks = Level.blocks;
                //for (ushort x = 0; x < Level.width; x++)
                //    for (ushort y = 0; y < Level.depth; y++)
                //        for (ushort z = 0; z < Level.height; z++)
                //            convertedBlocks[Level.PosToInt(x, y, z)] = Block.Convert(Level.GetTile(x, y, z));
                ushort[] tmpb = new ushort[Level.blocks.Length];
                for (int i = 0; i < Level.blocks.Length; ++i)
                    tmpb[i] = (ushort)(Level.blocks[i] == Block.air ? (ushort)0 : Level.blocks[i]);

                    fixed (ushort* bpx = tmpb)
                    {
                        fixed (ushort* tp = Tiles)
                        {
                            fixed (ushort* stp = ShadowTiles)
                            {
                                bp = bpx;
                                while (z < Level.depth)
                                {
                                    block = GetBlock(x, y, z);
                                    if (block != 0)
                                    {

                                        switch (Rot)
                                        {
                                            case 0: ctp = (z >= Level.shadows[x, y] ? tp : stp); break;
                                            case 1: ctp = (z >= Level.shadows[dimX1 - y, x] ? tp : stp); break;
                                            case 2: ctp = (z >= Level.shadows[dimX1 - x, dimY1 - y] ? tp : stp); break;
                                            case 3: ctp = (z >= Level.shadows[y, dimY1 - x] ? tp : stp); break;
                                        }

                                        int blockRight, blockLeft, blockUp;

                                        if (x != (Rot == 1 || Rot == 3 ? dimY1 : dimX1)) blockRight = GetBlock(x + 1, y, z);
                                        else blockRight = 0;
                                        if (y != (Rot == 1 || Rot == 3 ? dimX1 : dimY1)) blockLeft = GetBlock(x, y + 1, z);
                                        else blockLeft = 0;
                                        if (z != Level.depth - 1) blockUp = GetBlock(x, y, z + 1);
                                        else blockUp = 0;

                                        if (blockUp == 0 || blockLeft == 0 || blockRight == 0 || // air
                                            blockUp == 8 || blockLeft == 8 || blockRight == 8 || // water
                                            blockUp == 9 || blockLeft == 9 || blockRight == 9 || // water
                                            (block != 20 && (blockUp == 20 || blockLeft == 20 || blockRight == 20)) || // glass
                                            blockUp == 18 || blockLeft == 18 || blockRight == 18 || // foliage
                                            blockLeft == 44 || blockRight == 44 || // step

                                            blockUp == 10 || blockLeft == 10 || blockRight == 10 || // lava
                                            blockUp == 11 || blockLeft == 11 || blockRight == 11 || // lava

                                            blockUp == 37 || blockLeft == 37 || blockRight == 37 || // flower
                                            blockUp == 38 || blockLeft == 38 || blockRight == 38 || // flower
                                            blockUp == 6 || blockLeft == 6 || blockRight == 6 || // tree
                                            blockUp == 39 || blockLeft == 39 || blockRight == 39 || // mushroom
                                            blockUp == 40 || blockLeft == 40 || blockRight == 40) // mushroom
                                            BlendTile();
                                    }

                                    x++;
                                    if (x == (Rot == 1 || Rot == 3 ? dimY : dimX))
                                    {
                                        y++;
                                        x = 0;
                                    }
                                    if (y == (Rot == 1 || Rot == 3 ? dimX : dimY))
                                    {
                                        z++;
                                        y = 0;
                                        if (worker != null && z % 4 == 0)
                                        {
                                            if (worker.CancellationPending) return null;
                                            worker.ReportProgress((z * 100) / Level.depth);
                                        }
                                    }
                                }
                            }
                        }
                    }

                int xMin = 0, xMax = imageWidth - 1, yMin = 0, yMax = imageHeight - 1;
                bool cont = true;
                int offset;

                // find left bound (xMin)
                for (x = 0; cont && x < imageWidth; x++)
                {
                    offset = x * 4 + 3;
                    for (y = 0; y < imageHeight; y++)
                    {
                        if (image[offset] > 0)
                        {
                            xMin = x;
                            cont = false;
                            break;
                        }
                        offset += imageStride;
                    }
                }

                if (worker != null && worker.CancellationPending) return null;

                // find top bound (yMin)
                cont = true;
                for (y = 0; cont && y < imageHeight; y++)
                {
                    offset = imageStride * y + xMin * 4 + 3;
                    for (x = xMin; x < imageWidth; x++)
                    {
                        if (image[offset] > 0)
                        {
                            yMin = y;
                            cont = false;
                            break;
                        }
                        offset += 4;
                    }
                }

                if (worker != null && worker.CancellationPending) return null;

                // find right bound (xMax)
                cont = true;
                for (x = imageWidth - 1; cont && x >= xMin; x--)
                {
                    offset = x * 4 + 3 + yMin * imageStride;
                    for (y = yMin; y < imageHeight; y++)
                    {
                        if (image[offset] > 0)
                        {
                            xMax = x + 1;
                            cont = false;
                            break;
                        }
                        offset += imageStride;
                    }
                }

                if (worker != null && worker.CancellationPending) return null;

                // find bottom bound (yMax)
                cont = true;
                for (y = imageHeight - 1; cont && y >= yMin; y--)
                {
                    offset = imageStride * y + 3 + xMin * 4;
                    for (x = xMin; x < xMax; x++)
                    {
                        if (image[offset] > 0)
                        {
                            yMax = y + 1;
                            cont = false;
                            break;
                        }
                        offset += 4;
                    }
                }

                cropRectangle = new Rectangle(Math.Max(0, xMin - 2),
                                               Math.Max(0, yMin - 2),
                                               Math.Min(imageBmp.Width, xMax - xMin + 4),
                                               Math.Min(imageBmp.Height, yMax - yMin + 4));
                return imageBmp;
            }
            finally
            {
                imageBmp.UnlockBits(imageData);
                if (worker != null && worker.CancellationPending && imageBmp != null)
                {
                    try
                    {
                        imageBmp.Dispose();
                    }
                    catch (ObjectDisposedException) { }
                }
            }
        }
        private void FreeGlyphBuffers()
        {
            GlyphCapacity = 0;

            if (Glyphs != null)
            {
                Memory.Free(Glyphs);
                Glyphs = null;
            }

            if (GlyphVisualAttributes != null)
            {
                Memory.Free(GlyphVisualAttributes);
                GlyphVisualAttributes = null;
            }

            if (GlyphAdvanceWidths != null)
            {
                Memory.Free(GlyphAdvanceWidths);
                GlyphAdvanceWidths = null;
            }

            if (GlyphOffsets != null)
            {
                Memory.Free(GlyphOffsets);
                GlyphOffsets = null;
            }
        }
Exemple #34
0
 public void DrawText([NativeTypeName("const WCHAR *")] ushort * @string, [NativeTypeName("UINT32")] uint stringLength, IDWriteTextFormat *textFormat, [NativeTypeName("const D2D1_RECT_F *")] D2D_RECT_F *layoutRect, ID2D1Brush *defaultFillBrush, D2D1_DRAW_TEXT_OPTIONS options = D2D1_DRAW_TEXT_OPTIONS_NONE, DWRITE_MEASURING_MODE measuringMode = DWRITE_MEASURING_MODE_NATURAL)
 {
     ((delegate * unmanaged <ID2D1DCRenderTarget *, ushort *, uint, IDWriteTextFormat *, D2D_RECT_F *, ID2D1Brush *, D2D1_DRAW_TEXT_OPTIONS, DWRITE_MEASURING_MODE, void>)(lpVtbl[27]))((ID2D1DCRenderTarget *)Unsafe.AsPointer(ref this), @string, stringLength, textFormat, layoutRect, defaultFillBrush, options, measuringMode);
 }
 public HRESULT SetDescription([NativeTypeName("LPOLESTR")] ushort *szDescription)
 {
     return(((delegate * unmanaged <ICreateErrorInfo *, ushort *, int>)(lpVtbl[5]))((ICreateErrorInfo *)Unsafe.AsPointer(ref this), szDescription));
 }
 public HRESULT CreateFromText([NativeTypeName("long")] int lFlags, [NativeTypeName("BSTR")] ushort *strText, [NativeTypeName("ULONG")] uint uObjTextFormat, IWbemContext *pCtx, IWbemClassObject **pNewObj)
 {
     return(((delegate * unmanaged <IWbemObjectTextSrc *, int, ushort *, uint, IWbemContext *, IWbemClassObject **, int>)(lpVtbl[4]))((IWbemObjectTextSrc *)Unsafe.AsPointer(ref this), lFlags, strText, uObjTextFormat, pCtx, pNewObj));
 }
Exemple #37
0
 public ShortImage(int width, int height, IntPtr dataIntPtr)
     : base(width, height, dataIntPtr, sizeof(short))
 {
     data = (ushort*)dataIntPtr.ToPointer();
 }
 public HRESULT SetHelpFile([NativeTypeName("LPOLESTR")] ushort *szHelpFile)
 {
     return(((delegate * unmanaged <ICreateErrorInfo *, ushort *, int>)(lpVtbl[6]))((ICreateErrorInfo *)Unsafe.AsPointer(ref this), szHelpFile));
 }
 internal unsafe DBCSCodePageEncoding(int codePage, int dataCodePage) : base(codePage, dataCodePage)
 {
     this.mapBytesToUnicode = null;
     this.mapUnicodeToBytes = null;
     this.mapCodePageCached = null;
 }
Exemple #40
0
        public unsafe Frame(ushort[] palette, BinaryReader bin, bool flip)
        {
            int xCenter = bin.ReadInt16();
            int yCenter = bin.ReadInt16();

            int width  = bin.ReadUInt16();
            int height = bin.ReadUInt16();

            Bitmap     bmp = new Bitmap(width, height, PixelFormat.Format16bppArgb1555);
            BitmapData bd  = bmp.LockBits(new Rectangle(0, 0, width, height), ImageLockMode.WriteOnly, PixelFormat.Format16bppArgb1555);

            ushort *line  = (ushort *)bd.Scan0;
            int     delta = bd.Stride >> 1;

            int header;

            int xBase = xCenter - 0x200;
            int yBase = (yCenter + height) - 0x200;

            if (!flip)
            {
                line += xBase;
                line += (yBase * delta);

                while ((header = bin.ReadInt32()) != 0x7FFF7FFF)
                {
                    header ^= DoubleXor;

                    ushort *cur = line + ((((header >> 12) & 0x3FF) * delta) + ((header >> 22) & 0x3FF));
                    ushort *end = cur + (header & 0xFFF);

                    while (cur < end)
                    {
                        *cur++ = palette[bin.ReadByte()];
                    }
                }
            }
            else
            {
                line -= xBase - width + 1;
                line += (yBase * delta);

                while ((header = bin.ReadInt32()) != 0x7FFF7FFF)
                {
                    header ^= DoubleXor;

                    ushort *cur = line + ((((header >> 12) & 0x3FF) * delta) - ((header >> 22) & 0x3FF));
                    ushort *end = cur - (header & 0xFFF);

                    while (cur > end)
                    {
                        *cur-- = palette[bin.ReadByte()];
                    }
                }

                xCenter = width - xCenter;
            }

            bmp.UnlockBits(bd);

            m_Center = new Point(xCenter, yCenter);
            m_Bitmap = bmp;
        }
 protected override unsafe void LoadManagedCodePage()
 {
     if (base.pCodePage.ByteCount != 2)
     {
         throw new NotSupportedException(Environment.GetResourceString("NotSupported_NoCodepageData", new object[] { this.CodePage }));
     }
     this.bytesUnknown = base.pCodePage.ByteReplace;
     this.charUnknown = base.pCodePage.UnicodeReplace;
     if (base.DecoderFallback.IsMicrosoftBestFitFallback)
     {
         ((InternalDecoderBestFitFallback) base.DecoderFallback).cReplacement = this.charUnknown;
     }
     this.byteCountUnknown = 1;
     if (this.bytesUnknown > 0xff)
     {
         this.byteCountUnknown++;
     }
     byte* sharedMemory = base.GetSharedMemory(0x40004 + base.iExtraBytes);
     this.mapBytesToUnicode = (char*) sharedMemory;
     this.mapUnicodeToBytes = (ushort*) (sharedMemory + 0x20000);
     this.mapCodePageCached = (int*) ((sharedMemory + 0x40000) + base.iExtraBytes);
     if (this.mapCodePageCached[0] != 0)
     {
         if (((this.mapCodePageCached[0] != base.dataTableCodePage) && base.bFlagDataTable) || ((this.mapCodePageCached[0] != this.CodePage) && !base.bFlagDataTable))
         {
             throw new OutOfMemoryException(Environment.GetResourceString("Arg_OutOfMemoryException"));
         }
     }
     else
     {
         char* chPtr = (char*) &base.pCodePage.FirstDataWord;
         int num = 0;
         int bytes = 0;
         while (num < 0x10000)
         {
             char index = chPtr[0];
             chPtr++;
             if (index == '\x0001')
             {
                 num = chPtr[0];
                 chPtr++;
             }
             else
             {
                 if ((index < ' ') && (index > '\0'))
                 {
                     num += index;
                     continue;
                 }
                 if (index == 0xffff)
                 {
                     bytes = num;
                     index = (char) num;
                 }
                 else if (index == 0xfffe)
                 {
                     bytes = num;
                 }
                 else
                 {
                     if (index == 0xfffd)
                     {
                         num++;
                         continue;
                     }
                     bytes = num;
                 }
                 if (this.CleanUpBytes(ref bytes))
                 {
                     if (index != 0xfffe)
                     {
                         this.mapUnicodeToBytes[index] = (ushort) bytes;
                     }
                     this.mapBytesToUnicode[bytes] = index;
                 }
                 num++;
             }
         }
         this.CleanUpEndBytes(this.mapBytesToUnicode);
         if (base.bFlagDataTable)
         {
             this.mapCodePageCached[0] = base.dataTableCodePage;
         }
     }
 }
 public int SetName([NativeTypeName("LPCWSTR")] ushort *Name)
 {
     return(((delegate * unmanaged <ID3D12VideoProcessCommandList *, ushort *, int>)(lpVtbl[6]))((ID3D12VideoProcessCommandList *)Unsafe.AsPointer(ref this), Name));
 }
Exemple #43
0
 //We need to allocate the underlying table that provides us with the information that we
 //use.  We allocate this once in the class initializer and then we don't need to worry 
 //about it again.  
 //
 //with AppDomains active, the static initializer is no longer good enough to ensure that only one
 //thread is ever in the native code at a given time.                                          
 unsafe static CharacterInfo() {
     lock(typeof(CharacterInfo)) {
         //NativeInitTable checks if an instance of the table has already been allocated, so
         //this initializer is idempotent once we guarantee that threads are only in here
         //one at a time.
         nativeInitTable();
         m_pDataTable = nativeGetCategoryDataTable();
         m_pLevel2WordOffset = nativeGetCategoryLevel2Offset();            
     }
 }
 public HRESULT RegisterThreadsEx([NativeTypeName("DWORD *")] uint *pdwTaskIndex, [NativeTypeName("LPCWSTR")] ushort *wszClassName, [NativeTypeName("LONG")] int lBasePriority)
 {
     return(((delegate * unmanaged <IMFRealTimeClientEx *, uint *, ushort *, int, int>)(lpVtbl[3]))((IMFRealTimeClientEx *)Unsafe.AsPointer(ref this), pdwTaskIndex, wszClassName, lBasePriority));
 }
        //
        // This constructor used only to create a Framework culture. it doesn't create custom 
        // culture nor synthetic culture.
        // This is used when requesting the native calendar name for a custom culture with 
        // empty string native calendar name.
        //
        internal unsafe CultureTableRecord(int cultureId, bool useUserOverride)
        {
            this.m_bUseUserOverride = useUserOverride;
            
            int defaultTableDataItem = CultureTable.Default.GetDataItemFromCultureID(cultureId, out m_ActualName);
            if (defaultTableDataItem < 0)
            {
                throw new ArgumentException(
                    String.Format(
                        CultureInfo.CurrentCulture,
                        Environment.GetResourceString("Argument_CultureNotSupported"), cultureId), "culture");
            }
            
            m_ActualCultureID   = cultureId;
            m_CultureTable      = CultureTable.Default;
            
            m_pData = (CultureTableData*)(m_CultureTable.m_pItemData + m_CultureTable.m_itemSize * defaultTableDataItem);
            m_pPool = m_CultureTable.m_pDataPool;
            
            m_CultureName = SNAME;
            m_CultureID = (cultureId == SPANISH_TRADITIONAL_SORT) ? cultureId : ILANGUAGE;

            BCLDebug.Assert(!IsCustomCulture , "[CultureTableRecord::ctor] we shouldn't have custom culture.");
            BCLDebug.Assert(!IsSynthetic, "[CultureTableRecord::ctor] we shouldn't have synthetic culture.");
        }
Exemple #46
0
        bool Handle_SIG(eMessage msg)
        {
            switch (msg)
            {
            default:
                return(false);

            case eMessage.eMessage_SIG_video_refresh:
            {
                int width  = comm->width;
                int height = comm->height;
                if (video_refresh != null)
                {
                    video_refresh((int *)comm->ptr, width, height);
                }
                break;
            }

            case eMessage.eMessage_SIG_input_poll:
                break;

            case eMessage.eMessage_SIG_input_state:
            {
                int port   = comm->port;
                int device = comm->device;
                int index  = comm->index;
                int id     = (int)comm->id;
                if (input_state != null)
                {
                    comm->value = input_state(port, device, index, id);
                }
                break;
            }

            case eMessage.eMessage_SIG_input_notify:
            {
                if (input_notify != null)
                {
                    input_notify(comm->index);
                }
                break;
            }

            case eMessage.eMessage_SIG_audio_flush:
            {
                uint nsamples = comm->size;

                if (audio_sample != null)
                {
                    ushort *audiobuffer = ((ushort *)comm->ptr);
                    for (uint i = 0; i < nsamples;)
                    {
                        ushort left  = audiobuffer[i++];
                        ushort right = audiobuffer[i++];
                        audio_sample(left, right);
                    }
                }

                break;
            }

            case eMessage.eMessage_SIG_path_request:
            {
                int    slot = comm->slot;
                string hint = comm->GetAscii();
                string ret  = hint;
                if (pathRequest != null)
                {
                    hint = pathRequest(slot, hint);
                }
                SetAscii(hint);
                break;
            }

            case eMessage.eMessage_SIG_trace_callback:
            {
                if (traceCallback != null)
                {
                    traceCallback(comm->GetAscii());
                }
                break;
            }

            case eMessage.eMessage_SIG_allocSharedMemory:
            {
                var name = comm->GetAscii();
                var size = comm->size;

                if (SharedMemoryBlocks.ContainsKey(name))
                {
                    throw new InvalidOperationException("Re-defined a shared memory block. Check bsnes init/shutdown code. Block name: " + name);
                }

                //try reusing existing block; dispose it if it exists and if the size doesnt match
                SharedMemoryBlock smb = null;
                if (DeallocatedMemoryBlocks.ContainsKey(name))
                {
                    smb = DeallocatedMemoryBlocks[name];
                    DeallocatedMemoryBlocks.Remove(name);
                    if (smb.Size != size)
                    {
                        smb.Dispose();
                        smb = null;
                    }
                }

                //allocate a new block if we have to
                if (smb == null)
                {
                    smb           = new SharedMemoryBlock();
                    smb.Name      = name;
                    smb.Size      = (int)size;
                    smb.BlockName = InstanceName + smb.Name;
                    smb.Allocate();
                }

                comm->ptr = smb.Ptr;
                SharedMemoryBlocks[smb.Name] = smb;
                CopyString(smb.BlockName);
                break;
            }

            case eMessage.eMessage_SIG_freeSharedMemory:
            {
                foreach (var block in SharedMemoryBlocks.Values)
                {
                    if (block.Ptr == comm->ptr)
                    {
                        DeallocatedMemoryBlocks[block.Name] = block;
                        SharedMemoryBlocks.Remove(block.Name);
                        break;
                    }
                }
                break;
            }
            }             //switch(msg)

            Message(eMessage.eMessage_Resume);
            return(true);
        }
        //
        // this constructor will create the CultureTableRecord object and point to the 
        // culture table at the slot dataItem.
        //

        private unsafe CultureTableRecord(string regionName, int dataItem, bool useUserOverride)
        {
            BCLDebug.Assert(regionName != null && regionName.Length > 0,
                "[CultureTableRecord.CultureTableRecord(regionName,bool)]Expected non-null/empty name");

            BCLDebug.Assert(dataItem > 0, "[CultureTableRecord.CultureTableRecord(regionName, dataItem, bool)] dataItem > 0 should be true.");

            // Assuming it works we'll want these
            this.m_bUseUserOverride = useUserOverride;
            this.m_CultureName = regionName;
            this.m_CultureTable = CultureTable.Default;

            // Found it, use it
            this.m_pData = (CultureTableData*)(this.m_CultureTable.m_pItemData +
                this.m_CultureTable.m_itemSize * dataItem);
            this.m_pPool = this.m_CultureTable.m_pDataPool;

            // Use ID from the file
            this.m_CultureID = this.ILANGUAGE;
        }
Exemple #48
0
 public int Load([NativeTypeName("LPCOLESTR")] ushort *pszFileName, [NativeTypeName("const AM_MEDIA_TYPE *")] AM_MEDIA_TYPE *pmt)
 {
     return(((delegate * unmanaged <IFileSourceFilter *, ushort *, AM_MEDIA_TYPE *, int>)(lpVtbl[3]))((IFileSourceFilter *)Unsafe.AsPointer(ref this), pszFileName, pmt));
 }
    static unsafe void InitStaticIndexArrays()
    {
        // - Each row takes (2 + 2 * MESH_WIDTH indices)
        //   - Thats 2 to start the triangle strip then 2 indices to add 2 triangles
        //     per mesh quad.
        // - We have MESH_HEIGHT rows
        // - It takes one extra index for linking between rows (MESH_HEIGHT - 1)
        // - A 2 x 3 mesh == 20 indices...

        n_static_indices = (uint)((2 + 2 * MESH_WIDTH) * MESH_HEIGHT + (MESH_HEIGHT - 1));
        static_indices = (ushort *)Marshal.AllocHGlobal ((int)(sizeof (ushort) * n_static_indices));
        ushort *i = static_indices;

        // NB: front facing == anti-clockwise winding
        i[0] = MeshIndex (0, 0);
        i[1] = MeshIndex (0, 1);
        i += 2;

        bool right_dir = true;

        for (int y = 0; y < MESH_HEIGHT; y++) {
            for (int x = 0; x < MESH_WIDTH; x++) {
                // Add 2 triangles per mesh quad...
                if (right_dir) {
                    i[0] = MeshIndex (x + 1, y);
                    i[1] = MeshIndex (x + 1, y + 1);
                } else {
                    i[0] = MeshIndex (MESH_WIDTH - x - 1, y);
                    i[1] = MeshIndex (MESH_WIDTH - x - 1, y + 1);
                }
                i += 2;
            }

            // Link rows...
            if (y == (MESH_HEIGHT - 1)) {
                break;
            }

            if (right_dir) {
                i[0] = MeshIndex (MESH_WIDTH, y + 1);
                i[1] = MeshIndex (MESH_WIDTH, y + 1);
                i[2] = MeshIndex (MESH_WIDTH, y + 2);
            } else {
                i[0] = MeshIndex (0, y + 1);
                i[1] = MeshIndex (0, y + 1);
                i[2] = MeshIndex (0, y + 2);
            }

            i += 3;
            right_dir = !right_dir;
        }
    }
 public static extern DL_STATUS LinearRead(byte *aucData,
                                           ushort linear_address,
                                           ushort data_len,
                                           ushort *bytes_written,
                                           byte auth_mode,
                                           byte key_index);
        //We need to allocate the underlying table that provides us with the information that we
        //use.  We allocate this once in the class initializer and then we don't need to worry
        //about it again.
        //
        unsafe static CharUnicodeInfo() {
            m_pDataTable = GlobalizationAssembly.GetGlobalizationResourceBytePtr(typeof(CharUnicodeInfo).Assembly, UNICODE_INFO_FILE_NAME);
            UnicodeDataHeader* mainHeader = (UnicodeDataHeader*)m_pDataTable;

            // Set up the native pointer to different part of the tables.
            m_pCategoryLevel1Index = (ushort*) (m_pDataTable + mainHeader->OffsetToCategoriesIndex);
            m_pCategoriesValue = (byte*) (m_pDataTable + mainHeader->OffsetToCategoriesValue);
            m_pNumericLevel1Index = (ushort*) (m_pDataTable + mainHeader->OffsetToNumbericIndex);
            m_pNumericValues = (byte*) (m_pDataTable + mainHeader->OffsetToNumbericValue);
            m_pDigitValues = (DigitValues*) (m_pDataTable + mainHeader->OffsetToDigitValue);

            // Go to native side to make sure the native CharacterInfoTable pointer in the native side is initialized.
            nativeInitTable(m_pDataTable);
        }
 public static extern DL_STATUS LinearRead_AKM1(byte *aucData,
                                                ushort linear_address,
                                                ushort data_len,
                                                ushort *bytes_written,
                                                byte key_mode);
Exemple #53
0
		public LZ4()
		{
			_hashtable64K = (ushort*)Marshal.AllocHGlobal(HASH64K_TABLESIZE*sizeof (ushort)).ToPointer();
			_hashtable = (uint*)Marshal.AllocHGlobal(HASH_TABLESIZE * sizeof(uint)).ToPointer();
		}
 public static extern DL_STATUS LinearWrite_AKM2(byte *aucData,
                                                 ushort linear_address,
                                                 ushort data_len,
                                                 ushort *bytes_written,
                                                 byte auth_mode);
Exemple #55
0
		static Normalization ()
		{
			IntPtr p1, p2, p3, p4, p5, p6;
			lock (forLock) {
				load_normalization_resource (out p1, out p2, out p3, out p4, out p5, out p6);
				props = (byte*) p1;
				mappedChars = (int*) p2;
				charMapIndex = (short*) p3;
				helperIndex = (short*) p4;
				mapIdxToComposite = (ushort*) p5;
				combiningClass = (byte*) p6;
			}

			isReady = true;
		}
 public static extern DL_STATUS LinearWrite_PK(byte *aucData,
                                               ushort linear_address,
                                               ushort data_len,
                                               ushort *bytes_written,
                                               byte key_mode,
                                               byte *pk_key);
Exemple #57
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="GpuState"></param>
        private unsafe void _Prim(GpuStateStruct* GpuState, GuPrimitiveType PrimitiveType, ushort VertexCount)
        {
            //if (PrimitiveType == GuPrimitiveType.TriangleStrip) VertexCount++;

            //Console.WriteLine("Prim: {0}, {1}", PrimitiveType, VertexCount);
            this.GpuState = GpuState;

            //Console.WriteLine("--------------------------------------------------------");
            VertexType = GpuState->VertexState.Type;

            ReadVertexDelegate ReadVertex = ReadVertex_Void;
            VertexReader.SetVertexTypeStruct(
                VertexType,
                (byte*)Memory.PspAddressToPointerSafe(GpuState->GetAddressRelativeToBaseOffset(GpuState->VertexAddress), 0)
            );

            #if DEBUG_VERTEX_TYPE
            try
            {
                if (!File.Exists("VertexType_" + VertexType.Value))
                {
                    File.WriteAllBytes(
                        "VertexType_" + VertexType.Value,
                        PointerUtils.PointerToByteArray((byte*)Memory.PspAddressToPointerSafe(GpuState->VertexAddress), 16 * 1024)
                    );
                    File.WriteAllText(
                        "VertexType_" + VertexType.Value + "_str",
                        VertexCount + "," + PrimitiveType + "\n" +
                        VertexType.ToString()
                    );
                    OutputVertexInfoStream = File.OpenWrite("VertexType_" + VertexType.Value + "_list");
                }
            }
            catch
            {
            }
            #endif
            //IndexReader.SetVertexTypeStruct(VertexType, VertexCount, (byte*)Memory.PspAddressToPointerSafe(GpuState->IndexAddress));

            uint TotalVerticesWithoutMorphing = VertexCount;

            //Console.Error.WriteLine("GpuState->IndexAddress: {0:X}", GpuState->IndexAddress);

            // Invalid
            /*
            if (GpuState->IndexAddress == 0xFFFFFFFF)
            {
                //Debug.Fail("Invalid IndexAddress");
                throw (new Exception("Invalid IndexAddress == 0xFFFFFFFF"));
            }
            */

            void* IndexPointer = null;
            if (VertexType.Index != VertexTypeStruct.IndexEnum.Void)
            {
                IndexPointer = Memory.PspAddressToPointerSafe(GpuState->GetAddressRelativeToBaseOffset(GpuState->IndexAddress), 0);
            }

            //Console.Error.WriteLine(VertexType.Index);
            switch (VertexType.Index)
            {
                case VertexTypeStruct.IndexEnum.Void:
                    break;
                case VertexTypeStruct.IndexEnum.Byte:
                    ReadVertex = ReadVertex_Byte;
                    IndexListByte = (byte *)IndexPointer;
                    TotalVerticesWithoutMorphing = 0;
                    for (int n = 0; n < VertexCount; n++)
                    {
                        if (TotalVerticesWithoutMorphing < IndexListByte[n]) TotalVerticesWithoutMorphing = IndexListByte[n];
                    }
                    break;
                case VertexTypeStruct.IndexEnum.Short:
                    ReadVertex = ReadVertex_Short;
                    IndexListShort = (ushort*)IndexPointer;
                    TotalVerticesWithoutMorphing = 0;
                    //VertexCount--;
                    for (int n = 0; n < VertexCount; n++)
                    {
                        //Console.Error.WriteLine(IndexListShort[n]);
                        if (TotalVerticesWithoutMorphing < IndexListShort[n]) TotalVerticesWithoutMorphing = IndexListShort[n];
                    }
                    break;
                default:
                    throw (new NotImplementedException());
            }
            TotalVerticesWithoutMorphing++;

            //Console.WriteLine(TotalVerticesWithoutMorphing);

            int MorpingVertexCount = (int)VertexType.MorphingVertexCount + 1;
            int z = 0;
            VertexInfo TempVertexInfo;

            float* Morphs = &GpuState->MorphingState.MorphWeight0;

            //for (int n = 0; n < MorpingVertexCount; n++) Console.Write("{0}, ", Morphs[n]); Console.WriteLine("");

            //int VertexInfoFloatCount = (sizeof(Color4F) + sizeof(Vector3F) * 3) / sizeof(float);
            int VertexInfoFloatCount = (sizeof(VertexInfo)) / sizeof(float);
            fixed (VertexInfo* VerticesPtr = Vertices)
            {
            #if true
                if (MorpingVertexCount == 1)
                {
                    VertexReader.ReadVertices(0, VerticesPtr, (int)TotalVerticesWithoutMorphing);
                }
                else
                {
                    var ComponentsIn = (float*)&TempVertexInfo;
                    for (int n = 0; n < TotalVerticesWithoutMorphing; n++)
                    {
                        var ComponentsOut = (float*)&VerticesPtr[n];
                        for (int cc = 0; cc < VertexInfoFloatCount; cc++) ComponentsOut[cc] = 0;
                        for (int m = 0; m < MorpingVertexCount; m++)
                        {
                            VertexReader.ReadVertex(z++, &TempVertexInfo);
                            for (int cc = 0; cc < VertexInfoFloatCount; cc++) ComponentsOut[cc] += ComponentsIn[cc] * Morphs[m];
                        }
                        VerticesPtr[n].Normal = VerticesPtr[n].Normal.Normalize();
                    }
                }
            #else
                var ComponentsIn = (float*)&TempVertexInfo;
                for (int n = 0; n < TotalVerticesWithoutMorphing; n++)
                {
                    if (MorpingVertexCount == 1)
                    {
                        VertexReader.ReadVertex(z++, &TempVertexInfo);
                        VerticesPtr[n] = TempVertexInfo;
                        //VertexReader.ReadVertices(0, VerticesPtr, TotalVerticesWithoutMorphing);
                    }
                    else
                    {
                        var ComponentsOut = (float*)&VerticesPtr[n];
                        for (int cc = 0; cc < VertexInfoFloatCount; cc++) ComponentsOut[cc] = 0;
                        for (int m = 0; m < MorpingVertexCount; m++)
                        {
                            VertexReader.ReadVertex(z++, &TempVertexInfo);
                            for (int cc = 0; cc < VertexInfoFloatCount; cc++) ComponentsOut[cc] += ComponentsIn[cc] * Morphs[m];
                        }
                    }
                }
            #endif
            }

            //VertexType.Texture == VertexTypeStruct.TextureEnum.Byte
            //return;
            //PrepareRead(GpuState);

            PrepareStateCommon(GpuState);

            if (GpuState->ClearingMode)
            {
                PrepareStateClear(GpuState);
            }
            else
            {
                PrepareStateDraw(GpuState);
            }

            PrepareStateMatrix(GpuState);

            //GL.Enable(EnableCap.Blend);

            /*
            if (CurrentTexture != null)
            {
                if (CurrentTexture.TextureHash == 0x2202293873)
                {
                    Console.Error.WriteLine(CurrentTexture);
                    Console.Error.WriteLine(VertexCount);
                }
            }
            */

            _CaptureStartPrimitive(PrimitiveType, GpuState->GetAddressRelativeToBaseOffset(GpuState->VertexAddress), VertexCount, ref VertexType);

            // DRAW ACTUALLY
            {
                //uint VertexSize = GpuState->VertexState.Type.GetVertexSize();

                //byte* VertexPtr = (byte*)Memory.PspAddressToPointerSafe(GpuState->VertexAddress);

                //Console.WriteLine(VertexSize);

                var BeginMode = default(BeginMode);

                switch (PrimitiveType)
                {
                    case GuPrimitiveType.Lines: BeginMode = BeginMode.Lines; break;
                    case GuPrimitiveType.LineStrip: BeginMode = BeginMode.LineStrip; break;
                    case GuPrimitiveType.Triangles: BeginMode = BeginMode.Triangles; break;
                    case GuPrimitiveType.Points: BeginMode = BeginMode.Points; break;
                    case GuPrimitiveType.TriangleFan: BeginMode = BeginMode.TriangleFan; break;
                    case GuPrimitiveType.TriangleStrip: BeginMode = BeginMode.TriangleStrip; break;
                    case GuPrimitiveType.Sprites: BeginMode = BeginMode.Quads; break;
                    default: throw (new NotImplementedException("Not implemented PrimitiveType:'" + PrimitiveType + "'"));
                }

                if (PrimitiveType == GuPrimitiveType.Sprites)
                {
                    GL.Disable(EnableCap.CullFace);
                }

                //Console.WriteLine(BeginMode);

                //lock (GpuLock)
                {
                    //Console.Error.WriteLine("GL.Begin : Thread : {0}", Thread.CurrentThread.ManagedThreadId);
                    GL.Begin(BeginMode);
                    {
                        if (PrimitiveType == GuPrimitiveType.Sprites)
                        {
                            GL.Disable(EnableCap.CullFace);
                            for (int n = 0; n < VertexCount; n += 2)
                            {
                                VertexInfo V1, V2, V3, V4;

                                ReadVertex(n + 0, &V1);
                                ReadVertex(n + 1, &V3);
                                {
                                    //if (GpuState->ClearingMode) Console.WriteLine("{0} - {1}", VertexInfoTopLeft, VertexInfoBottomRight);

                                    var Color = V3.Color;
                                    var TZ = V1.Texture.Z;
                                    var PZ = V1.Position.Z;
                                    var NZ = V1.Normal.Z;

                                    V2 = new VertexInfo()
                                    {
                                        Texture = new Vector3F(V3.Texture.X, V1.Texture.Y, TZ),
                                        Position = new Vector3F(V3.Position.X, V1.Position.Y, PZ),
                                        Normal = new Vector3F(V3.Normal.X, V1.Normal.Y, NZ),
                                    };

                                    V4 = new VertexInfo()
                                    {
                                        Texture = new Vector3F(V1.Texture.X, V3.Texture.Y, TZ),
                                        Position = new Vector3(V1.Position.X, V3.Position.Y, PZ),
                                        Normal = new Vector3F(V1.Normal.X, V3.Normal.Y, NZ),
                                    };

                                    V4.Color = V3.Color = V2.Color = V1.Color = Color;
                                    V4.Position.Z = V3.Position.Z = V2.Position.Z = V1.Position.Z = PZ;
                                    V4.Normal.Z = V3.Normal.Z = V2.Normal.Z = V1.Normal.Z = NZ;
                                    V4.Texture.Z = V3.Texture.Z = V2.Texture.Z = V1.Texture.Z = NZ;
                                }
                                PutVertex(ref V1, ref VertexType);
                                PutVertex(ref V2, ref VertexType);
                                PutVertex(ref V3, ref VertexType);
                                PutVertex(ref V4, ref VertexType);
                            }
                        }
                        else
                        {
                            VertexInfo VertexInfo;
                            //Console.Error.WriteLine("{0} : {1} : {2}", BeginMode, VertexCount, VertexType.Index);
                            for (int n = 0; n < VertexCount; n++)
                            {
                                ReadVertex(n, &VertexInfo);
                                PutVertex(ref VertexInfo, ref VertexType);
                            }
                        }
                    }
                    GL.End();
                }
            }

            _CaptureEndPrimitive();

            //Console.WriteLine(VertexCount);

            //PrepareWrite(GpuState);

            #if DEBUG_VERTEX_TYPE
            if (OutputVertexInfoStream != null)
            {
                OutputVertexInfoStream.Close();
                OutputVertexInfoStream = null;
            }
            #endif
        }
Exemple #58
0
 public HRESULT put_clear([NativeTypeName("BSTR")] ushort *v)
 {
     return(((delegate * unmanaged <IHTMLBlockElement *, ushort *, int>)(lpVtbl[7]))((IHTMLBlockElement *)Unsafe.AsPointer(ref this), v));
 }
        [System.Security.SecurityCritical]  // auto-generated
        protected override unsafe void LoadManagedCodePage()
        {
            fixed (byte* pBytes = m_codePageHeader)
            {
                CodePageHeader* pCodePage = (CodePageHeader*)pBytes;

                // Should be loading OUR code page
                Debug.Assert(pCodePage->CodePage == dataTableCodePage,
                    "[DBCSCodePageEncoding.LoadManagedCodePage]Expected to load data table code page");

                // Make sure we're really a 1-byte code page
                if (pCodePage->ByteCount != 2)
                    throw new NotSupportedException(SR.Format(SR.NotSupported_NoCodepageData, CodePage));
                // Remember our unknown bytes & chars
                _bytesUnknown = pCodePage->ByteReplace;
                charUnknown = pCodePage->UnicodeReplace;

                // Need to make sure the fallback buffer's fallback char is correct
                if (DecoderFallback is InternalDecoderBestFitFallback)
                {
                    ((InternalDecoderBestFitFallback)(DecoderFallback)).cReplacement = charUnknown;
                }

                // Is our replacement bytesUnknown a single or double byte character?
                _byteCountUnknown = 1;
                if (_bytesUnknown > 0xff)
                    _byteCountUnknown++;

                // We use fallback encoder, which uses ?, which so far all of our tables do as well
                Debug.Assert(_bytesUnknown == 0x3f,
                    "[DBCSCodePageEncoding.LoadManagedCodePage]Expected 0x3f (?) as unknown byte character");

                // Get our mapped section (bytes to allocate = 2 bytes per 65536 Unicode chars + 2 bytes per 65536 DBCS chars)
                // Plus 4 byte to remember CP # when done loading it. (Don't want to get IA64 or anything out of alignment)
                byte* pNativeMemory = GetNativeMemory(65536 * 2 * 2 + 4 + iExtraBytes);

                mapBytesToUnicode = (char*)pNativeMemory;
                mapUnicodeToBytes = (ushort*)(pNativeMemory + 65536 * 2);

                // Need to read our data file and fill in our section.
                // WARNING: Multiple code pieces could do this at once (so we don't have to lock machine-wide)
                //          so be careful here.  Only stick legal values in here, don't stick temporary values.

                // Move to the beginning of the data section

                byte[] buffer = new byte[m_dataSize];
                lock (s_streamLock)
                {
                    s_codePagesEncodingDataStream.Seek(m_firstDataWordOffset, SeekOrigin.Begin);
                    s_codePagesEncodingDataStream.Read(buffer, 0, m_dataSize);
                }

                fixed (byte* pBuffer = buffer)
                {
                    char* pData = (char*)pBuffer;

                    // We start at bytes position 0
                    int bytePosition = 0;
                    int useBytes = 0;

                    while (bytePosition < 0x10000)
                    {
                        // Get the next byte
                        char input = *pData;
                        pData++;

                        // build our table:
                        if (input == 1)
                        {
                            // Use next data as our byte position
                            bytePosition = (int)(*pData);
                            pData++;
                            continue;
                        }
                        else if (input < 0x20 && input > 0)
                        {
                            // Advance input characters
                            bytePosition += input;
                            continue;
                        }
                        else if (input == 0xFFFF)
                        {
                            // Same as our bytePosition
                            useBytes = bytePosition;
                            input = unchecked((char)bytePosition);
                        }
                        else if (input == LEAD_BYTE_CHAR) // 0xfffe
                        {
                            // Lead byte mark
                            Debug.Assert(bytePosition < 0x100, "[DBCSCodePageEncoding.LoadManagedCodePage]expected lead byte to be < 0x100");
                            useBytes = bytePosition;
                            // input stays 0xFFFE
                        }
                        else if (input == UNICODE_REPLACEMENT_CHAR)
                        {
                            // Replacement char is already done
                            bytePosition++;
                            continue;
                        }
                        else
                        {
                            // Use this character
                            useBytes = bytePosition;
                            // input == input;
                        }

                        // We may need to clean up the selected character & position
                        if (CleanUpBytes(ref useBytes))
                        {
                            // Use this selected character at the selected position, don't do this if not supposed to.
                            if (input != LEAD_BYTE_CHAR)
                            {
                                // Don't do this for lead byte marks.
                                mapUnicodeToBytes[input] = unchecked((ushort)useBytes);
                            }
                            mapBytesToUnicode[useBytes] = input;
                        }
                        bytePosition++;
                    }
                }

                // See if we have any clean up to do
                CleanUpEndBytes(mapBytesToUnicode);
            }
        }
Exemple #60
0
 public extern static int ResolveLocaleName(
     ushort *lpNameToResolve,
     ushort *lpLocaleName,
     int cchLocaleName);