[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Dotgnu-pnet-commits] CVS: pnetlib/Basic ErrObject.cs,1.1,1.2 Informati
From: |
Rhys Weatherley <address@hidden> |
Subject: |
[Dotgnu-pnet-commits] CVS: pnetlib/Basic ErrObject.cs,1.1,1.2 Information.cs,1.1,1.2 |
Date: |
Wed, 21 May 2003 22:24:11 -0400 |
Update of /cvsroot/dotgnu-pnet/pnetlib/Basic
In directory subversions:/tmp/cvs-serv5930/Basic
Modified Files:
ErrObject.cs Information.cs
Log Message:
Implement missing TODO's in the VB support library, primarily in the
CompilerServices namespace.
Index: ErrObject.cs
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnetlib/Basic/ErrObject.cs,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -r1.1 -r1.2
*** ErrObject.cs 16 May 2003 05:35:00 -0000 1.1
--- ErrObject.cs 22 May 2003 02:24:09 -0000 1.2
***************
*** 27,30 ****
--- 27,31 ----
using System.ComponentModel;
using System.Runtime.InteropServices;
+ using Microsoft.VisualBasic.CompilerServices;
public sealed class ErrObject
***************
*** 64,68 ****
// Raise a particular error.
- [TODO]
public void Raise(int Number,
[Optional] [DefaultValue(null)]
Object Source,
--- 65,68 ----
***************
*** 71,75 ****
[Optional] [DefaultValue(null)]
Object HelpContext)
{
! // TODO
}
--- 71,89 ----
[Optional] [DefaultValue(null)]
Object HelpContext)
{
! if(Number == 0)
! {
! throw new ArgumentException
! (S._("VB_InvalidErrorNumber"),
"Number");
! }
! this.Number = Number;
! this.Source = StringType.FromObject(Source);
! this.Description =
StringType.FromObject(Description);
! this.HelpFile = StringType.FromObject(HelpFile);
! this.HelpContext =
IntegerType.FromObject(HelpContext);
! this.exception = CreateExceptionFromNumber
! (Number, this.Description);
! this.exception.Source = this.Source;
! this.exception.HelpLink = this.HelpFile;
! throw this.exception;
}
***************
*** 136,140 ****
// Get a standard number for an exception.
! private static int GetNumberForException(Exception exception)
{
if(exception is OverflowException)
--- 150,154 ----
// Get a standard number for an exception.
! internal static int GetNumberForException(Exception exception)
{
if(exception is OverflowException)
***************
*** 147,151 ****
}
if(exception is IndexOutOfRangeException ||
! exception is RankException)
{
return 9;
--- 161,166 ----
}
if(exception is IndexOutOfRangeException ||
! exception is RankException ||
! exception is ArrayTypeMismatchException)
{
return 9;
***************
*** 173,176 ****
--- 188,195 ----
}
}
+ if(exception is StackOverflowException)
+ {
+ return 28;
+ }
if(exception is DllNotFoundException ||
exception is FileNotFoundException)
***************
*** 182,185 ****
--- 201,208 ----
return 57;
}
+ if(exception is EndOfStreamException)
+ {
+ return 62;
+ }
if(exception is DirectoryNotFoundException)
{
***************
*** 202,205 ****
--- 225,232 ----
return 429;
}
+ if(exception is MissingFieldException)
+ {
+ return 422;
+ }
if(exception is MissingMemberException)
{
***************
*** 216,219 ****
--- 243,317 ----
return 5;
}
+
+ // Convert a number into an exception.
+ internal static Exception CreateExceptionFromNumber
+ (int number, String message)
+ {
+ switch(number)
+ {
+ case 3: case 20: case 94: case 100:
+ return new
InvalidOperationException(message);
+
+ case 5: case 446: case 448: case 449:
+ return new
ArgumentException(message);
+
+ case 6:
+ return new
OverflowException(message);
+
+ case 7: case 14:
+ return new
OutOfMemoryException(message);
+
+ case 9:
+ return new
IndexOutOfRangeException(message);
+
+ case 11:
+ return new
DivideByZeroException(message);
+
+ case 13:
+ return new
InvalidCastException(message);
+
+ case 28:
+ return new
StackOverflowException(message);
+
+ case 48: case 429:
+ return new
TypeLoadException(message);
+
+ case 52: case 54: case 55: case 57:
case 58:
+ case 59: case 61: case 63: case 67:
case 68:
+ case 70: case 71: case 74: case 75:
+ return new IOException(message);
+
+ case 53: case 432:
+ return new
FileNotFoundException(message);
+
+ case 62:
+ return new
EndOfStreamException(message);
+
+ case 76:
+ return new
DirectoryNotFoundException(message);
+
+ case 91:
+ return new
NullReferenceException(message);
+
+ case 99:
+ return new
SEHException(message);
+
+ case 422:
+ return new
MissingFieldException(message);
+
+ case 438:
+ return new
MissingMemberException(message);
+
+ case 453:
+ return new
EntryPointNotFoundException(message);
+
+ case 458:
+ return new
InvalidOleVariantTypeException(message);
+
+ default:
+ return new Exception(message);
+ }
+ }
+
// Get or set the error's number.
Index: Information.cs
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnetlib/Basic/Information.cs,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -r1.1 -r1.2
*** Information.cs 16 May 2003 05:35:00 -0000 1.1
--- Information.cs 22 May 2003 02:24:09 -0000 1.2
***************
*** 24,29 ****
--- 24,32 ----
using System;
+ using System.Reflection;
+ using System.Globalization;
using System.ComponentModel;
using System.Runtime.InteropServices;
+ using System.Text;
using Microsoft.VisualBasic.CompilerServices;
***************
*** 93,100 ****
return (VarName == null);
}
- [TODO]
public static bool IsNumeric(Object VarName)
{
! // TODO
return false;
}
--- 96,130 ----
return (VarName == null);
}
public static bool IsNumeric(Object VarName)
{
! IConvertible ic = (VarName as IConvertible);
! if(ic != null)
! {
! switch(ic.GetTypeCode())
! {
! case TypeCode.Boolean:
! case TypeCode.Byte:
! case TypeCode.Int16:
! case TypeCode.Int32:
! case TypeCode.Int64:
! case TypeCode.Single:
! case TypeCode.Double:
! case TypeCode.Decimal: return
true;
!
! case TypeCode.String:
! {
! try
! {
!
DoubleType.Parse(ic.ToString(null));
! return true;
! }
! catch(Exception e)
! {
! // If we cannot
parse, then it isn't numeric.
! }
! }
! break;
! }
! }
return false;
}
***************
*** 105,142 ****
// Get the lower bound of an array.
- [TODO]
public static int LBound
(Array Array, [Optional] [DefaultValue(1)] int
Rank)
{
! // TODO
! return 1;
}
! // Convert a color value into a QB color value.
! [TODO]
public static int QBColor(int Color)
{
! // TODO
! return Color;
}
// Build a color value from RGB values.
- [TODO]
public static int RGB(int Red, int Green, int Blue)
{
! // TODO
! return 0;
}
// Get the system type name from a VB type name.
- [TODO]
public static String SystemTypeName(String VbName)
{
! // TODO
! return VbName;
}
// Get the type name for an object.
- [TODO]
public static String TypeName(Object VarName)
{
--- 135,236 ----
// Get the lower bound of an array.
public static int LBound
(Array Array, [Optional] [DefaultValue(1)] int
Rank)
{
! if(Array == null)
! {
! throw new
ArgumentNullException("Array");
! }
! else if(Rank < 1 || Rank > Array.Rank)
! {
! throw new
RankException(S._("VB_InvalidRank"));
! }
! else
! {
! return Array.GetLowerBound(Rank - 1);
! }
}
! // Table that maps QB color indexes into RGB values.
! private static int[] qbColors =
! {0x000000, 0x800000, 0x008000, 0x808000,
! 0x000080, 0x800080, 0x008080, 0xC0C0C0,
! 0x808080, 0xFF0000, 0x00FF00, 0xFFFF00,
! 0x0000FF, 0xFF00FF, 0x00FFFF, 0xFFFFFF};
!
! // Convert a QB color index into an RGB value.
public static int QBColor(int Color)
{
! if(Color < 0 || Color > 15)
! {
! throw new ArgumentException
! (S._("VB_InvalidColorIndex"),
"Color");
! }
! else
! {
! return qbColors[Color];
! }
}
// Build a color value from RGB values.
public static int RGB(int Red, int Green, int Blue)
{
! // Validate the parameters.
! if(Red < 0)
! {
! throw new ArgumentException
! (S._("VB_NonNegative"), "Red");
! }
! else if(Red > 255)
! {
! Red = 255;
! }
! if(Green < 0)
! {
! throw new ArgumentException
! (S._("VB_NonNegative"),
"Green");
! }
! else if(Green > 255)
! {
! Green = 255;
! }
! if(Blue < 0)
! {
! throw new ArgumentException
! (S._("VB_NonNegative"), "Blue");
! }
! else if(Blue > 255)
! {
! Blue = 255;
! }
!
! // Build the final color value.
! return (Blue << 16) | (Green << 8) | Red;
}
// Get the system type name from a VB type name.
public static String SystemTypeName(String VbName)
{
! VbName = (VbName.Trim()).ToLower
! (CultureInfo.InvariantCulture);
! switch(VbName)
! {
! case "boolean": return
"System.Boolean";
! case "char": return
"System.Char";
! case "byte": return
"System.Byte";
! case "short": return
"System.Int16";
! case "integer": return
"System.Int32";
! case "long": return
"System.Int64";
! case "single": return
"System.Single";
! case "double": return
"System.Double";
! case "date": return
"System.DateTime";
! case "decimal": return
"System.Decimal";
! case "string": return
"System.String";
! case "object": return
"System.Object";
! }
! return null;
}
// Get the type name for an object.
public static String TypeName(Object VarName)
{
***************
*** 147,178 ****
else
{
! // TODO
! return null;
}
}
// Get the upper bound of an array.
- [TODO]
public static int UBound
(Array Array, [Optional] [DefaultValue(1)] int
Rank)
{
! // TODO
! return 1;
}
// Get the variant type for an object.
! [TODO]
public static VariantType VarType(Object VarName)
{
! // TODO
! return VariantType.Empty;
}
// Convert a system type name into a VB type name.
- [TODO]
public static String VbTypeName(String UrtName)
{
! // TODO
! return UrtName;
}
--- 241,391 ----
else
{
! StringBuilder builder = new
StringBuilder();
! Utils.AppendType(builder,
VarName.GetType());
! return builder.ToString();
}
}
// Get the upper bound of an array.
public static int UBound
(Array Array, [Optional] [DefaultValue(1)] int
Rank)
{
! if(Array == null)
! {
! throw new
ArgumentNullException("Array");
! }
! else if(Rank < 1 || Rank > Array.Rank)
! {
! throw new
RankException(S._("VB_InvalidRank"));
! }
! else
! {
! return Array.GetUpperBound(Rank - 1);
! }
}
// Get the variant type for an object.
! private static VariantType VarTypeForType(Type type)
! {
! if(type.IsArray)
! {
! VariantType vtype =
VarTypeForType(type.GetElementType());
! if((vtype & VariantType.Array) != 0)
! {
! // Array of array is
transformed into array of object.
! return VariantType.Array |
VariantType.Object;
! }
! else
! {
! return VariantType.Array |
vtype;
! }
! }
! else if(type.IsEnum)
! {
! // Report the underlying type for
enumerations.
! return
VarTypeForType(Enum.GetUnderlyingType(type));
! }
! if(type == typeof(bool))
! {
! return VariantType.Boolean;
! }
! else if(type == typeof(char))
! {
! return VariantType.Char;
! }
! else if(type == typeof(byte))
! {
! return VariantType.Byte;
! }
! else if(type == typeof(short))
! {
! return VariantType.Short;
! }
! else if(type == typeof(int))
! {
! return VariantType.Integer;
! }
! else if(type == typeof(long))
! {
! return VariantType.Long;
! }
! else if(type == typeof(float))
! {
! return VariantType.Single;
! }
! else if(type == typeof(double))
! {
! return VariantType.Double;
! }
! else if(type == typeof(Decimal))
! {
! return VariantType.Decimal;
! }
! else if(type == typeof(String))
! {
! return VariantType.String;
! }
! else if(type == typeof(DateTime))
! {
! return VariantType.Date;
! }
! else if(type == typeof(DBNull))
! {
! return VariantType.Null;
! }
! else if(type == typeof(Missing) ||
!
typeof(Exception).IsAssignableFrom(type))
! {
! return VariantType.Error;
! }
! else if(type.IsValueType)
! {
! return VariantType.UserDefinedType;
! }
! else
! {
! return VariantType.Object;
! }
! }
public static VariantType VarType(Object VarName)
{
! if(VarName == null)
! {
! return VariantType.Object;
! }
! else
! {
! return
VarTypeForType(VarName.GetType());
! }
}
// Convert a system type name into a VB type name.
public static String VbTypeName(String UrtName)
{
! // Normalize the name.
! UrtName = (UrtName.Trim()).ToLower
! (CultureInfo.InvariantCulture);
! if(UrtName.StartsWith("system."))
! {
! UrtName = UrtName.Substring(7);
! }
!
! // Check for known runtime engine types with VB
equivalents.
! switch(UrtName)
! {
! case "boolean": return
"Boolean";
! case "char": return "Char";
! case "byte": return "Byte";
! case "int16": return "Short";
! case "int32": return
"Integer";
! case "int64": return "Long";
! case "single": return "Single";
! case "double": return "Double";
! case "object": return "Object";
! case "string": return "String";
! case "datetime": return "Date";
! case "decimal": return
"Decimal";
! }
! return null;
}
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Dotgnu-pnet-commits] CVS: pnetlib/Basic ErrObject.cs,1.1,1.2 Information.cs,1.1,1.2,
Rhys Weatherley <address@hidden> <=
- Prev by Date:
[Dotgnu-pnet-commits] CVS: pnet/cscc/java java_defs.tc,1.1,1.2 java_semantics.tc,1.1,1.2
- Next by Date:
[Dotgnu-pnet-commits] CVS: pnetlib ChangeLog,1.906,1.907
- Previous by thread:
[Dotgnu-pnet-commits] CVS: pnet/cscc/java java_defs.tc,1.1,1.2 java_semantics.tc,1.1,1.2
- Next by thread:
[Dotgnu-pnet-commits] CVS: pnetlib ChangeLog,1.906,1.907
- Index(es):