[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Dotgnu-pnet-commits] CVS: pnetlib/runtime/System/Globalization _I18NCul
From: |
Rhys Weatherley <address@hidden> |
Subject: |
[Dotgnu-pnet-commits] CVS: pnetlib/runtime/System/Globalization _I18NCultureHandler.cs,NONE,1.1 CompareInfo.cs,1.4,1.5 CultureInfo.cs,1.10,1.11 DateTimeFormatInfo.cs,1.3,1.4 NumberFormatInfo.cs,1.6,1.7 |
Date: |
Wed, 13 Nov 2002 22:17:12 -0500 |
Update of /cvsroot/dotgnu-pnet/pnetlib/runtime/System/Globalization
In directory subversions:/tmp/cvs-serv14846/runtime/System/Globalization
Modified Files:
CompareInfo.cs CultureInfo.cs DateTimeFormatInfo.cs
NumberFormatInfo.cs
Added Files:
_I18NCultureHandler.cs
Log Message:
Add some more I18N support to defer the rest of the CultureInfo functionality
to the I18N plugin layer.
--- NEW FILE ---
/*
* _I18NCultureHandler.cs - Implementation of the
* "System.Globalization._I18NCultureHandler" class.
*
* Copyright (C) 2002 Southern Storm Software, Pty Ltd.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
namespace System.Globalization
{
using System.Text;
// This class exists to allow us to query culture information from
// the I18N plugin infrastructure. It must not be used in application
// programs.
public abstract class _I18NCultureHandler
{
// Get the compare information for this culture.
// Returns NULL to use invariant fallbacks.
public CompareInfo CultureCompareInfo
{
get
{
return null;
}
}
// Get the date time format information for this culture.
// Returns NULL to use invariant fallbacks.
public DateTimeFormatInfo CultureDateTimeFormatInfo
{
get
{
return null;
}
}
// Get the number format information for this culture.
// Returns NULL to use invariant fallbacks.
public NumberFormatInfo CultureNumberFormatInfo
{
get
{
return null;
}
}
// Get the text information for this culture.
// Returns NULL to use invariant fallbacks.
public TextInfo CultureTextInfo
{
get
{
return null;
}
}
// Get the default calendar for this culture.
// Returns NULL to use the standard Gregorian calendar.
public Calendar CultureCalendar
{
get
{
return null;
}
}
// Get a list of other calendars for the culture.
public Calendar[] CultureOtherCalendars
{
get
{
return new Calendar [0];
}
}
// Get the culture handler for a specific culture.
internal static _I18NCultureHandler GetCultureHandler(int culture)
{
Object obj = Encoding.InvokeI18N("GetCulture",
culture);
if(obj == null)
{
// Try the neutral culture instead.
obj = Encoding.InvokeI18N("GetCulture",
culture & 0x03FF);
}
return (_I18NCultureHandler)obj;
}
}; // class _I18NCultureHandler
}; // namespace System.Globalization
Index: CompareInfo.cs
===================================================================
RCS file:
/cvsroot/dotgnu-pnet/pnetlib/runtime/System/Globalization/CompareInfo.cs,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -r1.4 -r1.5
*** CompareInfo.cs 14 Nov 2002 01:51:19 -0000 1.4
--- CompareInfo.cs 14 Nov 2002 03:17:10 -0000 1.5
***************
*** 24,28 ****
using System.Reflection;
- using System.Text;
using System.Runtime.Serialization;
--- 24,27 ----
***************
*** 45,72 ****
}
! // Get the comparison information for a specific culture.
! public static CompareInfo GetCompareInfo(int culture)
{
! Object info;
! info = Encoding.InvokeI18N("GetCompareInfo",
culture);
! if(info == null)
{
! // Try the neutral culture instead.
! info = Encoding.InvokeI18N
! ("GetCompareInfo", culture &
0x00FF);
! if(info == null)
{
! // Return the invariant culture
information.
! lock(typeof(CompareInfo))
{
! if(invariantCompare ==
null)
! {
!
invariantCompare = new CompareInfo(0x007F);
! }
! return invariantCompare;
}
}
}
! return (CompareInfo)info;
}
public static CompareInfo GetCompareInfo(String culture)
--- 44,82 ----
}
! // Get the invariant CompareInfo object.
! internal static CompareInfo InvariantCompareInfo
{
! get
{
! lock(typeof(CompareInfo))
{
! if(invariantCompare == null)
{
! invariantCompare = new
CompareInfo(0x007F);
}
+ return invariantCompare;
}
}
! }
!
! // Get the comparison information for a specific culture.
! public static CompareInfo GetCompareInfo(int culture)
! {
! _I18NCultureHandler handler;
! CompareInfo info;
!
! // Find the culture-specific handler.
! handler =
_I18NCultureHandler.GetCultureHandler(culture);
! if(handler != null)
! {
! info = handler.CultureCompareInfo;
! if(info != null)
! {
! return info;
! }
! }
!
! // Return the invariant culture information.
! return InvariantCompareInfo;
}
public static CompareInfo GetCompareInfo(String culture)
Index: CultureInfo.cs
===================================================================
RCS file:
/cvsroot/dotgnu-pnet/pnetlib/runtime/System/Globalization/CultureInfo.cs,v
retrieving revision 1.10
retrieving revision 1.11
diff -C2 -r1.10 -r1.11
*** CultureInfo.cs 14 Nov 2002 01:51:19 -0000 1.10
--- CultureInfo.cs 14 Nov 2002 03:17:10 -0000 1.11
***************
*** 24,27 ****
--- 24,29 ----
using System;
using System.Private;
+ using System.Runtime.CompilerServices;
+ using System.Text;
public class CultureInfo : ICloneable, IFormatProvider
***************
*** 30,33 ****
--- 32,36 ----
// Cached culture objects.
private static CultureInfo invariantCulture;
+ private static CultureInfo currentCulture;
// Internal state.
***************
*** 36,42 ****
private bool readOnly;
private Calendar calendar;
private NumberFormatInfo numberFormat;
private DateTimeFormatInfo dateTimeFormat;
! private TextInfo textInfo=null;
// Culture identifier for "es-ES" with traditional sort rules.
--- 39,49 ----
private bool readOnly;
private Calendar calendar;
+ private Calendar[] otherCalendars;
private NumberFormatInfo numberFormat;
+ private CompareInfo compareInfo;
private DateTimeFormatInfo dateTimeFormat;
! private TextInfo textInfo;
! private bool userOverride;
! private _I18NCultureHandler handler;
// Culture identifier for "es-ES" with traditional sort rules.
***************
*** 80,84 ****
cultureName =
CultureNameTable.GetNameInfoByID(culture);
}
! InitCulture();
}
public CultureInfo(String name, bool useUserOverride)
--- 87,92 ----
cultureName =
CultureNameTable.GetNameInfoByID(culture);
}
! userOverride = useUserOverride;
! handler =
_I18NCultureHandler.GetCultureHandler(cultureID);
}
public CultureInfo(String name, bool useUserOverride)
***************
*** 90,139 ****
cultureName =
CultureNameTable.GetNameInfoByName(name);
cultureID = cultureName.cultureID;
! InitCulture();
! }
!
! // Initialize the platform-specific culture routines.
! private void InitCulture()
! {
! #if false
! CultureName newName;
!
! // Attempt to get an exact match.
! handle =
CultureMethods.GetCulture(cultureName.name,
!
cultureID);
! if(handle != IntPtr.Zero)
! {
! return;
! }
!
! // Attempt to get the neutral version of the
culture.
! if((cultureID & ~0x03FF) != 0)
! {
! newName =
CultureNameTable.GetNameInfoByID
! (cultureID & 0x03FF);
! handle = CultureMethods.GetCulture
! (newName.name,
newName.cultureID);
! if(handle != IntPtr.Zero)
! {
! return;
! }
! }
!
! // Attempt to get the default country for the
culture.
! if((cultureID & ~0x03FF) != 0x0400 && cultureID
!= 0x0C0A)
! {
! newName =
CultureNameTable.GetNameInfoByID
! ((cultureID & 0x03FF) | 0x0400);
! handle = CultureMethods.GetCulture
! (newName.name,
newName.cultureID);
! if(handle != IntPtr.Zero)
! {
! return;
! }
! }
!
! // The system does not support the specified
culture.
! throw new
ArgumentException(_("Arg_InvalidCulture"));
! #endif
}
--- 98,103 ----
cultureName =
CultureNameTable.GetNameInfoByName(name);
cultureID = cultureName.cultureID;
! userOverride = useUserOverride;
! handler =
_I18NCultureHandler.GetCultureHandler(cultureID);
}
***************
*** 156,189 ****
}
// Get the current culture object for the running thread.
- [TODO]
public static CultureInfo CurrentCulture
{
get
{
! // TODO.
! return InvariantCulture;
}
}
// Get the current UI culture object for the running thread.
- [TODO]
public static CultureInfo CurrentUICulture
{
get
{
! // TODO.
! return null;
}
}
// Get the installed UI culture object for the system.
- [TODO]
public static CultureInfo InstalledUICulture
{
get
{
! // TODO.
! return null;
}
}
--- 120,173 ----
}
+ // Get the current culture identifier from the runtime engine.
+ [MethodImpl(MethodImplOptions.InternalCall)]
+ extern private static int InternalCultureID();
+
// Get the current culture object for the running thread.
public static CultureInfo CurrentCulture
{
get
{
! lock(typeof(CultureInfo))
! {
! if(currentCulture != null)
! {
! return currentCulture;
! }
! int id = InternalCultureID();
! if(id == 0 ||
!
_I18NCultureHandler.GetCultureHandler(id) == null)
! {
! currentCulture =
InvariantCulture;
! }
! else
! {
! currentCulture = new
CultureInfo(id);
! currentCulture.readOnly
= true;
! }
! return currentCulture;
! }
}
}
// Get the current UI culture object for the running thread.
public static CultureInfo CurrentUICulture
{
get
{
! // Just use the current culture, since
most platforms
! // do not distinguish between UI and
non-UI cultures.
! return CurrentCulture;
}
}
// Get the installed UI culture object for the system.
public static CultureInfo InstalledUICulture
{
get
{
! // Just use the current culture, since
most platforms
! // do not distinguish between UI and
non-UI cultures.
! return CurrentCulture;
}
}
***************
*** 197,205 ****
// Get the list of all cultures supported by this system.
- [TODO]
public static CultureInfo[] GetCultures(CultureTypes types)
{
! // TODO
! return new CultureInfo [0];
}
--- 181,201 ----
// Get the list of all cultures supported by this system.
public static CultureInfo[] GetCultures(CultureTypes types)
{
! Object obj = Encoding.InvokeI18N("GetCultures",
types);
! if(obj != null)
! {
! return (CultureInfo[])obj;
! }
! else if((types & CultureTypes.NeutralCultures)
!= 0)
! {
! CultureInfo[] cultures = new
CultureInfo [1];
! cultures[0] = InvariantCulture;
! return cultures;
! }
! else
! {
! return new CultureInfo [0];
! }
}
***************
*** 224,228 ****
// Get the default calendar that is used by the culture.
- [TODO]
public virtual Calendar Calendar
{
--- 220,223 ----
***************
*** 231,240 ****
lock(this)
{
! if(calendar != null)
{
! return calendar;
}
- // TODO: handle non-Gregorian
calendars.
- calendar = new
GregorianCalendar();
return calendar;
}
--- 226,244 ----
lock(this)
{
! if(calendar == null)
{
! if(handler != null)
! {
! calendar =
handler.CultureCalendar;
! if(calendar ==
null)
! {
!
calendar = new GregorianCalendar();
! }
! }
! else
! {
! calendar = new
GregorianCalendar();
! }
}
return calendar;
}
***************
*** 247,251 ****
get
{
! return
CompareInfo.GetCompareInfo(cultureID);
}
}
--- 251,274 ----
get
{
! lock(this)
! {
! if(compareInfo == null)
! {
! if(handler != null)
! {
! compareInfo =
handler.CultureCompareInfo;
! if(compareInfo
== null)
! {
!
compareInfo =
!
CompareInfo.InvariantCompareInfo;
! }
! }
! else
! {
! compareInfo =
CompareInfo.InvariantCompareInfo;
! }
! }
! return compareInfo;
! }
}
}
***************
*** 264,272 ****
return
DateTimeFormatInfo.InvariantInfo;
}
else
{
! dateTimeFormat = new
DateTimeFormatInfo(this);
}
}
return dateTimeFormat;
}
--- 287,310 ----
return
DateTimeFormatInfo.InvariantInfo;
}
+ else if(handler != null)
+ {
+ dateTimeFormat =
handler.CultureDateTimeFormatInfo;
+ if(dateTimeFormat ==
null)
+ {
+ dateTimeFormat
= new DateTimeFormatInfo();
+ }
+ }
else
{
! dateTimeFormat = new
DateTimeFormatInfo();
}
}
+ if(readOnly)
+ {
+ // Wrap up the date/time
formatting information
+ // to make it read-only like
the culture.
+ dateTimeFormat =
DateTimeFormatInfo.ReadOnly
+ (dateTimeFormat);
+ }
return dateTimeFormat;
}
***************
*** 364,372 ****
return
NumberFormatInfo.InvariantInfo;
}
else
{
! numberFormat = new
NumberFormatInfo(this);
}
}
return numberFormat;
}
--- 402,425 ----
return
NumberFormatInfo.InvariantInfo;
}
+ else if(handler != null)
+ {
+ numberFormat =
handler.CultureNumberFormatInfo;
+ if(numberFormat == null)
+ {
+ numberFormat =
new NumberFormatInfo();
+ }
+ }
else
{
! numberFormat = new
NumberFormatInfo();
}
}
+ if(readOnly)
+ {
+ // Wrap up the number
formatting information
+ // to make it read-only like
the culture.
+ numberFormat =
NumberFormatInfo.ReadOnly
+ (numberFormat);
+ }
return numberFormat;
}
***************
*** 387,397 ****
// Get the optional calendars for this instance.
- [TODO]
public virtual Calendar[] OptionalCalendars
{
get
{
! // TODO
! return new Calendar [0];
}
}
--- 440,462 ----
// Get the optional calendars for this instance.
public virtual Calendar[] OptionalCalendars
{
get
{
! lock(this)
! {
! if(otherCalendars == null)
! {
! if(handler != null)
! {
! otherCalendars
= handler.CultureOtherCalendars;
! }
! else
! {
! otherCalendars
= new Calendar [0];
! }
! }
! return otherCalendars;
! }
}
}
***************
*** 414,472 ****
// Get the text writing system associated with this culture.
- [TODO]
public virtual TextInfo TextInfo
{
get
{
! if(this.textInfo==null)
{
! this.textInfo=new TextInfo();
}
- // TODO
- return this.textInfo;
}
}
// Get the 3-letter ISO language name for this culture.
- [TODO]
public virtual String ThreeLetterISOLanguageName
{
get
{
! // TODO
! return null;
}
}
// Get the 3-letter Windows language name for this culture.
- [TODO]
public virtual String ThreeLetterWindowsLanguageName
{
get
{
! // TODO
! return null;
}
}
// Get the 2-letter ISO language name for this culture.
- [TODO]
public virtual String TwoLetterISOLanguageName
{
get
{
! // TODO
! return null;
}
}
// Determine if this culture is configured for user overrides.
- [TODO]
public virtual bool UseUserOverride
{
get
{
! // TODO
! return false;
}
}
--- 479,541 ----
// Get the text writing system associated with this culture.
public virtual TextInfo TextInfo
{
get
{
! lock(this)
{
! if(textInfo == null)
! {
! if(handler != null)
! {
! textInfo =
handler.CultureTextInfo;
! if(textInfo ==
null)
! {
!
textInfo = new TextInfo();
! }
! }
! else
! {
! textInfo = new
TextInfo();
! }
! }
! return textInfo;
}
}
}
// Get the 3-letter ISO language name for this culture.
public virtual String ThreeLetterISOLanguageName
{
get
{
! return cultureName.threeLetterISOName;
}
}
// Get the 3-letter Windows language name for this culture.
public virtual String ThreeLetterWindowsLanguageName
{
get
{
! return
cultureName.threeLetterWindowsName;
}
}
// Get the 2-letter ISO language name for this culture.
public virtual String TwoLetterISOLanguageName
{
get
{
! return cultureName.twoLetterISOName;
}
}
// Determine if this culture is configured for user overrides.
public virtual bool UseUserOverride
{
get
{
! return userOverride;
}
}
***************
*** 492,500 ****
// Map a culture name to an identifier.
- [TODO]
internal static int MapNameToID(String name)
{
! // TODO
! return 0x007F;
}
--- 561,569 ----
// Map a culture name to an identifier.
internal static int MapNameToID(String name)
{
! CultureName cultureName =
!
CultureNameTable.GetNameInfoByName(name);
! return cultureName.cultureID;
}
Index: DateTimeFormatInfo.cs
===================================================================
RCS file:
/cvsroot/dotgnu-pnet/pnetlib/runtime/System/Globalization/DateTimeFormatInfo.cs,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -r1.3 -r1.4
*** DateTimeFormatInfo.cs 20 Dec 2001 10:11:39 -0000 1.3
--- DateTimeFormatInfo.cs 14 Nov 2002 03:17:10 -0000 1.4
***************
*** 98,111 ****
}
- // Internal constructor for getting information from a culture.
- [TODO]
- internal DateTimeFormatInfo(CultureInfo culture)
- : this()
- {
- // We currently have the invariant defaults
loaded.
- // Call the runtime engine to get
culture-specific data.
- // TODO
- }
-
// Get the invariant date time format information.
public static DateTimeFormatInfo InvariantInfo
--- 98,101 ----
Index: NumberFormatInfo.cs
===================================================================
RCS file:
/cvsroot/dotgnu-pnet/pnetlib/runtime/System/Globalization/NumberFormatInfo.cs,v
retrieving revision 1.6
retrieving revision 1.7
diff -C2 -r1.6 -r1.7
*** NumberFormatInfo.cs 24 Jan 2002 23:43:25 -0000 1.6
--- NumberFormatInfo.cs 14 Nov 2002 03:17:10 -0000 1.7
***************
*** 619,633 ****
}
- // Internal constructor that is used to load the contents
- // of a culture-specific set of number formatting rules.
- [TODO]
- internal NumberFormatInfo(CultureInfo culture)
- : this()
- {
- // We currently have the invariant defaults
loaded.
- // Call the runtime engine to get
culture-specific data.
- // TODO
- }
-
// Implementation of the ICloneable interface.
public Object Clone()
--- 619,622 ----
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Dotgnu-pnet-commits] CVS: pnetlib/runtime/System/Globalization _I18NCultureHandler.cs,NONE,1.1 CompareInfo.cs,1.4,1.5 CultureInfo.cs,1.10,1.11 DateTimeFormatInfo.cs,1.3,1.4 NumberFormatInfo.cs,1.6,1.7,
Rhys Weatherley <address@hidden> <=