edit: $/Dev10/feature/vs_langs01/Merlin/Main/Languages/Ruby/Libraries.LCA_RESTRICTED/Initializer.Generated.cs;C436555 File: Initializer.Generated.cs =================================================================== --- $/Dev10/feature/vs_langs01/Merlin/Main/Languages/Ruby/Libraries.LCA_RESTRICTED/Initializer.Generated.cs;C436555 (server) 5/13/2008 8:53 AM +++ Shelved Change: $/Dev10/feature/vs_langs01/Merlin/Main/Languages/Ruby/Libraries.LCA_RESTRICTED/Initializer.Generated.cs;sockets-1 @@ -22,7 +22,7 @@ // Skipped primitive: __ClassSingleton // Skipped primitive: __MainSingleton - Ruby.Builtins.RubyModule def40 = DefineGlobalModule("Comparable", typeof(Ruby.Builtins.Comparable), new System.Action(LoadComparable_Instance), null, Ruby.Builtins.RubyModule.EmptyArray); + Ruby.Builtins.RubyModule def38 = DefineGlobalModule("Comparable", typeof(Ruby.Builtins.Comparable), new System.Action(LoadComparable_Instance), null, Ruby.Builtins.RubyModule.EmptyArray); Ruby.Builtins.RubyModule def11 = DefineGlobalModule("Digest", typeof(Ruby.StandardLibrary.Digest), null, new System.Action(LoadDigest_Class), Ruby.Builtins.RubyModule.EmptyArray); Ruby.Builtins.RubyModule def14 = DefineModule("Digest::Instance", typeof(Ruby.StandardLibrary.Digest.Instance), new System.Action(LoadDigest__Instance_Instance), null, Ruby.Builtins.RubyModule.EmptyArray); Ruby.Builtins.RubyModule def28 = DefineGlobalModule("Enumerable", typeof(Ruby.Builtins.Enumerable), new System.Action(LoadEnumerable_Instance), null, Ruby.Builtins.RubyModule.EmptyArray); @@ -32,7 +32,7 @@ DefineClass("Microsoft::Scripting::Actions::TypeTracker", typeof(Microsoft.Scripting.Actions.TypeTracker), typeof(Ruby.Runtime.TypeTrackerOps), new System.Action(LoadMicrosoft__Scripting__Actions__TypeTracker_Instance), null, classRef0, Ruby.Builtins.RubyModule.EmptyArray, null); Ruby.Builtins.RubyModule def16 = DefineGlobalModule("OpenSSL", typeof(Ruby.StandardLibrary.OpenSSL), null, null, Ruby.Builtins.RubyModule.EmptyArray); Ruby.Builtins.RubyModule def17 = DefineModule("OpenSSL::Digest", typeof(Ruby.StandardLibrary.OpenSSL.DigestFactory), null, null, Ruby.Builtins.RubyModule.EmptyArray); - Ruby.Builtins.RubyModule def36 = DefineGlobalModule("Precision", typeof(Ruby.Builtins.Precision), new System.Action(LoadPrecision_Instance), new System.Action(LoadPrecision_Class), Ruby.Builtins.RubyModule.EmptyArray); + Ruby.Builtins.RubyModule def35 = DefineGlobalModule("Precision", typeof(Ruby.Builtins.Precision), new System.Action(LoadPrecision_Instance), new System.Action(LoadPrecision_Class), Ruby.Builtins.RubyModule.EmptyArray); DefineClass("System::Type", typeof(System.Type), typeof(Ruby.Runtime.TypeOps), new System.Action(LoadSystem__Type_Instance), null, classRef2, Ruby.Builtins.RubyModule.EmptyArray, null); Ruby.Builtins.RubyModule def20 = DefineGlobalModule("Zlib", typeof(Ruby.StandardLibrary.Zlib), new System.Action(LoadZlib_Instance), null, Ruby.Builtins.RubyModule.EmptyArray); // Skipped primitive: __ClassSingletonSingleton @@ -43,11 +43,11 @@ object def2 = DefineSingleton(new System.Action(Load__Singleton_EnvironmentSingletonOps_Instance), null, new Ruby.Builtins.RubyModule[] {def28, }); #endif // Skipped primitive: Object - Ruby.Builtins.RubyModule def34 = DefineModule("System::Collections::Generic::IDictionary", typeof(System.Collections.Generic.IDictionary), new System.Action(LoadSystem__Collections__Generic__IDictionary_Instance), null, new Ruby.Builtins.RubyModule[] {def28, }); - Ruby.Builtins.RubyModule def47 = DefineModule("System::Collections::IEnumerable", typeof(System.Collections.IEnumerable), new System.Action(LoadSystem__Collections__IEnumerable_Instance), null, new Ruby.Builtins.RubyModule[] {def28, }); - Ruby.Builtins.RubyModule def42 = DefineModule("System::Collections::IList", typeof(System.Collections.IList), new System.Action(LoadSystem__Collections__IList_Instance), null, new Ruby.Builtins.RubyModule[] {def28, }); - DefineModule("System::IComparable", typeof(System.IComparable), new System.Action(LoadSystem__IComparable_Instance), null, new Ruby.Builtins.RubyModule[] {def40, }); - DefineGlobalClass("Time", typeof(System.DateTime), typeof(Ruby.Builtins.TimeOps), new System.Action(LoadTime_Instance), new System.Action(LoadTime_Class), classRef1, new Ruby.Builtins.RubyModule[] {def40, }, new System.Delegate[] { + Ruby.Builtins.RubyModule def33 = DefineModule("System::Collections::Generic::IDictionary", typeof(System.Collections.Generic.IDictionary), new System.Action(LoadSystem__Collections__Generic__IDictionary_Instance), null, new Ruby.Builtins.RubyModule[] {def28, }); + DefineModule("System::Collections::IEnumerable", typeof(System.Collections.IEnumerable), new System.Action(LoadSystem__Collections__IEnumerable_Instance), null, new Ruby.Builtins.RubyModule[] {def28, }); + Ruby.Builtins.RubyModule def40 = DefineModule("System::Collections::IList", typeof(System.Collections.IList), new System.Action(LoadSystem__Collections__IList_Instance), null, new Ruby.Builtins.RubyModule[] {def28, }); + Ruby.Builtins.RubyModule def47 = DefineModule("System::IComparable", typeof(System.IComparable), new System.Action(LoadSystem__IComparable_Instance), null, new Ruby.Builtins.RubyModule[] {def38, }); + DefineGlobalClass("Time", typeof(System.DateTime), typeof(Ruby.Builtins.TimeOps), new System.Action(LoadTime_Instance), new System.Action(LoadTime_Class), classRef1, new Ruby.Builtins.RubyModule[] {def38, }, new System.Delegate[] { new Microsoft.Scripting.Utils.Function(Ruby.Builtins.TimeOps.Create), }); DefineGlobalClass("Array", typeof(Ruby.Builtins.RubyArray), typeof(Ruby.Builtins.ArrayOps), new System.Action(LoadArray_Instance), new System.Action(LoadArray_Class), Context.ObjectClass, new Ruby.Builtins.RubyModule[] {def28, }, new System.Delegate[] { @@ -63,7 +63,7 @@ DefineGlobalClass("ClrString", typeof(System.String), typeof(Ruby.Builtins.StringOps), new System.Action(LoadClrString_Instance), null, Context.ObjectClass, new Ruby.Builtins.RubyModule[] {def47, }, null); Ruby.Builtins.RubyClass def13 = DefineClass("Digest::Class", typeof(Ruby.StandardLibrary.Digest.Class), null, null, new System.Action(LoadDigest__Class_Class), Context.ObjectClass, new Ruby.Builtins.RubyModule[] {def14, }, null); DefineGlobalClass("Dir", typeof(Ruby.Builtins.RubyDir), null, new System.Action(LoadDir_Instance), new System.Action(LoadDir_Class), Context.ObjectClass, new Ruby.Builtins.RubyModule[] {def28, }, null); - Ruby.Builtins.RubyClass def41 = Context.ExceptionClass = DefineGlobalClass("Exception", typeof(System.Exception), typeof(Ruby.Builtins.ExceptionOps), new System.Action(LoadException_Instance), new System.Action(LoadException_Class), Context.ObjectClass, Ruby.Builtins.RubyModule.EmptyArray, new System.Delegate[] { + Ruby.Builtins.RubyClass def39 = Context.ExceptionClass = DefineGlobalClass("Exception", typeof(System.Exception), typeof(Ruby.Builtins.ExceptionOps), new System.Action(LoadException_Instance), new System.Action(LoadException_Class), Context.ObjectClass, Ruby.Builtins.RubyModule.EmptyArray, new System.Delegate[] { new Microsoft.Scripting.Utils.Function(Ruby.Builtins.ExceptionOps.Factory), }); Context.FalseClass = DefineGlobalClass("FalseClass", typeof(Ruby.Builtins.FalseClass), null, new System.Action(LoadFalseClass_Instance), null, Context.ObjectClass, Ruby.Builtins.RubyModule.EmptyArray, null); @@ -71,7 +71,7 @@ new Microsoft.Scripting.Utils.Function(Ruby.Builtins.HashOps.Hash), new Microsoft.Scripting.Utils.Function(Ruby.Builtins.HashOps.Hash), }); - Ruby.Builtins.RubyClass def29 = DefineGlobalClass("IO", typeof(Ruby.Builtins.RubyIO), typeof(Ruby.Builtins.RubyIOOps), new System.Action(LoadIO_Instance), new System.Action(LoadIO_Class), Context.ObjectClass, Ruby.Builtins.RubyModule.EmptyArray, new System.Delegate[] { + Ruby.Builtins.RubyClass def41 = DefineGlobalClass("IO", typeof(Ruby.Builtins.RubyIO), typeof(Ruby.Builtins.RubyIOOps), new System.Action(LoadIO_Instance), new System.Action(LoadIO_Class), Context.ObjectClass, Ruby.Builtins.RubyModule.EmptyArray, new System.Delegate[] { new Microsoft.Scripting.Utils.Function(Ruby.Builtins.RubyIOOps.CreateIO), new Microsoft.Scripting.Utils.Function(Ruby.Builtins.RubyIOOps.CreateIO), new Microsoft.Scripting.Utils.Function(Ruby.Builtins.RubyIOOps.CreateIO), @@ -80,7 +80,7 @@ DefineGlobalClass("Method", typeof(Ruby.Builtins.RubyMethod), typeof(Ruby.Builtins.MethodOps), new System.Action(LoadMethod_Instance), null, Context.ObjectClass, Ruby.Builtins.RubyModule.EmptyArray, null); // Skipped primitive: Module Context.NilClass = DefineGlobalClass("NilClass", typeof(Microsoft.Scripting.None), typeof(Ruby.Builtins.NilClassOps), new System.Action(LoadNilClass_Instance), null, Context.ObjectClass, Ruby.Builtins.RubyModule.EmptyArray, null); - Ruby.Builtins.RubyClass def35 = DefineGlobalClass("Numeric", typeof(Ruby.Builtins.Numeric), null, new System.Action(LoadNumeric_Instance), null, Context.ObjectClass, new Ruby.Builtins.RubyModule[] {def40, }, null); + Ruby.Builtins.RubyClass def34 = DefineGlobalClass("Numeric", typeof(Ruby.Builtins.Numeric), null, new System.Action(LoadNumeric_Instance), null, Context.ObjectClass, new Ruby.Builtins.RubyModule[] {def38, }, null); Ruby.Builtins.RubyClass def18 = DefineClass("OpenSSL::Digest::Digest", typeof(Ruby.StandardLibrary.OpenSSL.DigestFactory.Digest), null, new System.Action(LoadOpenSSL__Digest__Digest_Instance), null, Context.ObjectClass, Ruby.Builtins.RubyModule.EmptyArray, null); Ruby.Builtins.RubyClass def19 = DefineClass("OpenSSL::HMAC", typeof(Ruby.StandardLibrary.OpenSSL.HMAC), null, null, new System.Action(LoadOpenSSL__HMAC_Class), Context.ObjectClass, Ruby.Builtins.RubyModule.EmptyArray, null); DefineGlobalClass("Proc", typeof(Ruby.Builtins.Proc), typeof(Ruby.Builtins.ProcOps), new System.Action(LoadProc_Instance), null, Context.ObjectClass, Ruby.Builtins.RubyModule.EmptyArray, new System.Delegate[] { @@ -99,7 +99,7 @@ new Microsoft.Scripting.Utils.Function(Ruby.Builtins.RegexpOps.Create), new Microsoft.Scripting.Utils.Function(Ruby.Builtins.RegexpOps.Create), }); - DefineGlobalClass("String", typeof(Ruby.Builtins.MutableString), typeof(Ruby.Builtins.MutableStringOps), new System.Action(LoadString_Instance), null, Context.ObjectClass, new Ruby.Builtins.RubyModule[] {def28, def40, }, new System.Delegate[] { + DefineGlobalClass("String", typeof(Ruby.Builtins.MutableString), typeof(Ruby.Builtins.MutableStringOps), new System.Action(LoadString_Instance), null, Context.ObjectClass, new Ruby.Builtins.RubyModule[] {def28, def38, }, new System.Delegate[] { new Microsoft.Scripting.Utils.Function(Ruby.Builtins.MutableStringOps.Create), new Microsoft.Scripting.Utils.Function(Ruby.Builtins.MutableStringOps.Create), }); @@ -114,27 +114,27 @@ Ruby.Builtins.RubyClass def22 = DefineClass("Zlib::GzipFile", typeof(Ruby.StandardLibrary.Zlib.GZipFile), null, null, null, Context.ObjectClass, Ruby.Builtins.RubyModule.EmptyArray, null); Ruby.Builtins.RubyClass def26 = DefineClass("Zlib::ZStream", typeof(Ruby.StandardLibrary.Zlib.ZStream), null, new System.Action(LoadZlib__ZStream_Instance), null, Context.ObjectClass, Ruby.Builtins.RubyModule.EmptyArray, null); #if !SILVERLIGHT - Ruby.Builtins.RubyClass def37 = DefineGlobalClass("BasicSocket", typeof(Ruby.Builtins.BasicSocket), null, new System.Action(LoadBasicSocket_Instance), null, def29, Ruby.Builtins.RubyModule.EmptyArray, null); + Ruby.Builtins.RubyClass def42 = DefineGlobalClass("BasicSocket", typeof(Ruby.StandardLibrary.RubyBasicSocket), null, new System.Action(LoadBasicSocket_Instance), new System.Action(LoadBasicSocket_Class), def41, Ruby.Builtins.RubyModule.EmptyArray, null); #endif // Skipped primitive: Class Ruby.Builtins.RubyClass def12 = DefineClass("Digest::Base", typeof(Ruby.StandardLibrary.Digest.Base), null, new System.Action(LoadDigest__Base_Instance), null, def13, Ruby.Builtins.RubyModule.EmptyArray, null); - DefineGlobalClass("File", typeof(Ruby.Builtins.RubyFile), typeof(Ruby.Builtins.RubyFileOps), new System.Action(LoadFile_Instance), new System.Action(LoadFile_Class), def29, Ruby.Builtins.RubyModule.EmptyArray, new System.Delegate[] { + DefineGlobalClass("File", typeof(Ruby.Builtins.RubyFile), typeof(Ruby.Builtins.RubyFileOps), new System.Action(LoadFile_Instance), new System.Action(LoadFile_Class), def41, Ruby.Builtins.RubyModule.EmptyArray, new System.Delegate[] { new Microsoft.Scripting.Utils.Function(Ruby.Builtins.RubyFileOps.CreateIO), new Microsoft.Scripting.Utils.Function(Ruby.Builtins.RubyFileOps.CreateIO), }); - DefineGlobalClass("Float", typeof(System.Double), typeof(Ruby.Builtins.FloatOps), new System.Action(LoadFloat_Instance), new System.Action(LoadFloat_Class), def35, new Ruby.Builtins.RubyModule[] {def36, }, null); - Ruby.Builtins.RubyClass def27 = DefineGlobalClass("Integer", typeof(Ruby.Builtins.Integer), null, new System.Action(LoadInteger_Instance), new System.Action(LoadInteger_Class), def35, new Ruby.Builtins.RubyModule[] {def36, }, null); - DefineGlobalClass("NoMemoryError", typeof(Ruby.Builtins.NoMemoryError), null, null, null, def41, Ruby.Builtins.RubyModule.EmptyArray, null); - Ruby.Builtins.RubyClass def38 = DefineGlobalClass("ScriptError", typeof(Ruby.Builtins.ScriptError), typeof(Ruby.Builtins.ScriptErrorOps), null, null, def41, Ruby.Builtins.RubyModule.EmptyArray, new System.Delegate[] { + DefineGlobalClass("Float", typeof(System.Double), typeof(Ruby.Builtins.FloatOps), new System.Action(LoadFloat_Instance), new System.Action(LoadFloat_Class), def34, new Ruby.Builtins.RubyModule[] {def35, }, null); + Ruby.Builtins.RubyClass def27 = DefineGlobalClass("Integer", typeof(Ruby.Builtins.Integer), null, new System.Action(LoadInteger_Instance), new System.Action(LoadInteger_Class), def34, new Ruby.Builtins.RubyModule[] {def35, }, null); + DefineGlobalClass("NoMemoryError", typeof(Ruby.Builtins.NoMemoryError), null, null, null, def39, Ruby.Builtins.RubyModule.EmptyArray, null); + Ruby.Builtins.RubyClass def36 = DefineGlobalClass("ScriptError", typeof(Ruby.Builtins.ScriptError), typeof(Ruby.Builtins.ScriptErrorOps), null, null, def39, Ruby.Builtins.RubyModule.EmptyArray, new System.Delegate[] { new Microsoft.Scripting.Utils.Function(Ruby.Builtins.ScriptErrorOps.Factory), }); - Ruby.Builtins.RubyClass def39 = Context.StandardErrorClass = DefineGlobalClass("StandardError", typeof(System.SystemException), typeof(Ruby.Builtins.SystemExceptionOps), null, null, def41, Ruby.Builtins.RubyModule.EmptyArray, new System.Delegate[] { + Ruby.Builtins.RubyClass def37 = Context.StandardErrorClass = DefineGlobalClass("StandardError", typeof(System.SystemException), typeof(Ruby.Builtins.SystemExceptionOps), null, null, def39, Ruby.Builtins.RubyModule.EmptyArray, new System.Delegate[] { new Microsoft.Scripting.Utils.Function(Ruby.Builtins.SystemExceptionOps.Factory), }); - DefineGlobalClass("SystemExit", typeof(Ruby.Builtins.SystemExit), typeof(Ruby.Builtins.SystemExitOps), new System.Action(LoadSystemExit_Instance), null, def41, Ruby.Builtins.RubyModule.EmptyArray, new System.Delegate[] { + DefineGlobalClass("SystemExit", typeof(Ruby.Builtins.SystemExit), typeof(Ruby.Builtins.SystemExitOps), new System.Action(LoadSystemExit_Instance), null, def39, Ruby.Builtins.RubyModule.EmptyArray, new System.Delegate[] { new Microsoft.Scripting.Utils.Function(Ruby.Builtins.SystemExitOps.Factory), }); - DefineGlobalClass("SystemStackError", typeof(Ruby.Builtins.SystemStackError), typeof(Ruby.Builtins.SystemStackErrorOps), null, null, def41, Ruby.Builtins.RubyModule.EmptyArray, new System.Delegate[] { + DefineGlobalClass("SystemStackError", typeof(Ruby.Builtins.SystemStackError), typeof(Ruby.Builtins.SystemStackErrorOps), null, null, def39, Ruby.Builtins.RubyModule.EmptyArray, new System.Delegate[] { new Microsoft.Scripting.Utils.Function(Ruby.Builtins.SystemStackErrorOps.Factory), }); Ruby.Builtins.RubyClass def24 = DefineClass("Zlib::GzipReader", typeof(Ruby.StandardLibrary.Zlib.GZipReader), null, new System.Action(LoadZlib__GzipReader_Instance), new System.Action(LoadZlib__GzipReader_Class), def22, Ruby.Builtins.RubyModule.EmptyArray, new System.Delegate[] { @@ -144,7 +144,7 @@ new Microsoft.Scripting.Utils.Function(Ruby.StandardLibrary.Zlib.Inflate.Initialize), new Microsoft.Scripting.Utils.Function(Ruby.StandardLibrary.Zlib.Inflate.Initialize), }); - DefineGlobalClass("ArgumentError", typeof(System.ArgumentException), typeof(Ruby.Builtins.ArgumentErrorOps), new System.Action(LoadArgumentError_Instance), null, def39, Ruby.Builtins.RubyModule.EmptyArray, new System.Delegate[] { + DefineGlobalClass("ArgumentError", typeof(System.ArgumentException), typeof(Ruby.Builtins.ArgumentErrorOps), new System.Action(LoadArgumentError_Instance), null, def37, Ruby.Builtins.RubyModule.EmptyArray, new System.Delegate[] { new Microsoft.Scripting.Utils.Function(Ruby.Builtins.ArgumentErrorOps.Factory), }); DefineGlobalClass("Bignum", typeof(Microsoft.Scripting.Math.BigInteger), typeof(Ruby.Builtins.BignumOps), new System.Action(LoadBignum_Instance), null, def27, Ruby.Builtins.RubyModule.EmptyArray, null); @@ -152,72 +152,86 @@ Ruby.Builtins.RubyClass def15 = DefineClass("Digest::MD5", typeof(Ruby.StandardLibrary.Digest.MD5), null, null, null, def12, Ruby.Builtins.RubyModule.EmptyArray, null); #endif DefineGlobalClass("Fixnum", typeof(System.Int32), typeof(Ruby.Builtins.FixnumOps), new System.Action(LoadFixnum_Instance), new System.Action(LoadFixnum_Class), def27, Ruby.Builtins.RubyModule.EmptyArray, null); - DefineGlobalClass("IndexError", typeof(System.IndexOutOfRangeException), typeof(Ruby.Builtins.IndexErrorOps), null, null, def39, Ruby.Builtins.RubyModule.EmptyArray, new System.Delegate[] { + DefineGlobalClass("IndexError", typeof(System.IndexOutOfRangeException), typeof(Ruby.Builtins.IndexErrorOps), null, null, def37, Ruby.Builtins.RubyModule.EmptyArray, new System.Delegate[] { new Microsoft.Scripting.Utils.Function(Ruby.Builtins.IndexErrorOps.Factory), }); - Ruby.Builtins.RubyClass def31 = DefineGlobalClass("IOError", typeof(System.IO.IOException), typeof(Ruby.Builtins.IOErrorOps), null, null, def39, Ruby.Builtins.RubyModule.EmptyArray, new System.Delegate[] { + Ruby.Builtins.RubyClass def30 = DefineGlobalClass("IOError", typeof(System.IO.IOException), typeof(Ruby.Builtins.IOErrorOps), null, null, def37, Ruby.Builtins.RubyModule.EmptyArray, new System.Delegate[] { new Microsoft.Scripting.Utils.Function(Ruby.Builtins.IOErrorOps.Factory), }); #if !SILVERLIGHT - Ruby.Builtins.RubyClass def44 = DefineGlobalClass("IPSocket", typeof(Ruby.Builtins.IPSocket), null, new System.Action(LoadIPSocket_Instance), new System.Action(LoadIPSocket_Class), def37, Ruby.Builtins.RubyModule.EmptyArray, null); + Ruby.Builtins.RubyClass def44 = DefineGlobalClass("IPSocket", typeof(Ruby.StandardLibrary.IPSocket), null, new System.Action(LoadIPSocket_Instance), new System.Action(LoadIPSocket_Class), def42, Ruby.Builtins.RubyModule.EmptyArray, null); #endif - DefineGlobalClass("LoadError", typeof(Ruby.Builtins.LoadError), typeof(Ruby.Builtins.LoadErrorOps), null, null, def38, Ruby.Builtins.RubyModule.EmptyArray, new System.Delegate[] { + DefineGlobalClass("LoadError", typeof(Ruby.Builtins.LoadError), typeof(Ruby.Builtins.LoadErrorOps), null, null, def36, Ruby.Builtins.RubyModule.EmptyArray, new System.Delegate[] { new Microsoft.Scripting.Utils.Function(Ruby.Builtins.LoadErrorOps.Factory), }); - DefineGlobalClass("LocalJumpError", typeof(Ruby.Builtins.LocalJumpError), typeof(Ruby.Builtins.LocalJumpErrorOps), null, null, def39, Ruby.Builtins.RubyModule.EmptyArray, new System.Delegate[] { + DefineGlobalClass("LocalJumpError", typeof(Ruby.Builtins.LocalJumpError), typeof(Ruby.Builtins.LocalJumpErrorOps), null, null, def37, Ruby.Builtins.RubyModule.EmptyArray, new System.Delegate[] { new Microsoft.Scripting.Utils.Function(Ruby.Builtins.LocalJumpErrorOps.Factory), }); - Ruby.Builtins.RubyClass def46 = DefineGlobalClass("NameError", typeof(System.MemberAccessException), typeof(Ruby.Builtins.NameErrorOps), null, null, def39, Ruby.Builtins.RubyModule.EmptyArray, new System.Delegate[] { + Ruby.Builtins.RubyClass def46 = DefineGlobalClass("NameError", typeof(System.MemberAccessException), typeof(Ruby.Builtins.NameErrorOps), null, null, def37, Ruby.Builtins.RubyModule.EmptyArray, new System.Delegate[] { new Microsoft.Scripting.Utils.Function(Ruby.Builtins.NameErrorOps.Factory), }); - DefineGlobalClass("NotImplementedError", typeof(Ruby.Builtins.NotImplementedError), typeof(Ruby.Builtins.NotImplementedErrorOps), null, null, def38, Ruby.Builtins.RubyModule.EmptyArray, new System.Delegate[] { + DefineGlobalClass("NotImplementedError", typeof(Ruby.Builtins.NotImplementedError), typeof(Ruby.Builtins.NotImplementedErrorOps), null, null, def36, Ruby.Builtins.RubyModule.EmptyArray, new System.Delegate[] { new Microsoft.Scripting.Utils.Function(Ruby.Builtins.NotImplementedErrorOps.Factory), }); - Ruby.Builtins.RubyClass def33 = DefineGlobalClass("RangeError", typeof(System.ArgumentOutOfRangeException), typeof(Ruby.Builtins.RangeErrorOps), new System.Action(LoadRangeError_Instance), null, def39, Ruby.Builtins.RubyModule.EmptyArray, new System.Delegate[] { + Ruby.Builtins.RubyClass def32 = DefineGlobalClass("RangeError", typeof(System.ArgumentOutOfRangeException), typeof(Ruby.Builtins.RangeErrorOps), new System.Action(LoadRangeError_Instance), null, def37, Ruby.Builtins.RubyModule.EmptyArray, new System.Delegate[] { new Microsoft.Scripting.Utils.Function(Ruby.Builtins.RangeErrorOps.Factory), }); - DefineGlobalClass("RegexpError", typeof(Ruby.Builtins.RegexpError), typeof(Ruby.Builtins.RegexpErrorOps), null, null, def39, Ruby.Builtins.RubyModule.EmptyArray, new System.Delegate[] { + DefineGlobalClass("RegexpError", typeof(Ruby.Builtins.RegexpError), typeof(Ruby.Builtins.RegexpErrorOps), null, null, def37, Ruby.Builtins.RubyModule.EmptyArray, new System.Delegate[] { new Microsoft.Scripting.Utils.Function(Ruby.Builtins.RegexpErrorOps.Factory), }); - Ruby.Builtins.RubyClass def45 = DefineGlobalClass("RuntimeError", typeof(Ruby.Builtins.RuntimeError), null, null, null, def39, Ruby.Builtins.RubyModule.EmptyArray, null); - DefineGlobalClass("SecurityError", typeof(System.Security.SecurityException), typeof(Ruby.Builtins.SecurityErrorOps), null, null, def39, Ruby.Builtins.RubyModule.EmptyArray, new System.Delegate[] { + Ruby.Builtins.RubyClass def45 = DefineGlobalClass("RuntimeError", typeof(Ruby.Builtins.RuntimeError), null, null, null, def37, Ruby.Builtins.RubyModule.EmptyArray, null); + DefineGlobalClass("SecurityError", typeof(System.Security.SecurityException), typeof(Ruby.Builtins.SecurityErrorOps), null, null, def37, Ruby.Builtins.RubyModule.EmptyArray, new System.Delegate[] { new Microsoft.Scripting.Utils.Function(Ruby.Builtins.SecurityErrorOps.Factory), }); - DefineGlobalClass("SyntaxError", typeof(Ruby.Builtins.SyntaxError), typeof(Ruby.Builtins.SyntaxErrorOps), null, null, def38, Ruby.Builtins.RubyModule.EmptyArray, new System.Delegate[] { + #if !SILVERLIGHT + DefineGlobalClass("Socket", typeof(Ruby.StandardLibrary.RubySocket), null, new System.Action(LoadSocket_Instance), new System.Action(LoadSocket_Class), def42, Ruby.Builtins.RubyModule.EmptyArray, null); + #endif + #if !SILVERLIGHT + DefineGlobalClass("SocketError", typeof(System.Net.Sockets.SocketException), typeof(Ruby.StandardLibrary.SocketErrorOps), new System.Action(LoadSocketError_Instance), null, def37, Ruby.Builtins.RubyModule.EmptyArray, new System.Delegate[] { + new Microsoft.Scripting.Utils.Function(Ruby.StandardLibrary.SocketErrorOps.Factory), + }); + #endif + DefineGlobalClass("SyntaxError", typeof(Ruby.Builtins.SyntaxError), typeof(Ruby.Builtins.SyntaxErrorOps), null, null, def36, Ruby.Builtins.RubyModule.EmptyArray, new System.Delegate[] { new Microsoft.Scripting.Utils.Function(Ruby.Builtins.SyntaxErrorOps.Factory), }); - Ruby.Builtins.RubyClass def32 = DefineGlobalClass("SystemCallError", typeof(System.Runtime.InteropServices.ExternalException), typeof(Ruby.Builtins.SystemCallErrorOps), null, null, def39, Ruby.Builtins.RubyModule.EmptyArray, new System.Delegate[] { + Ruby.Builtins.RubyClass def31 = DefineGlobalClass("SystemCallError", typeof(System.Runtime.InteropServices.ExternalException), typeof(Ruby.Builtins.SystemCallErrorOps), null, null, def37, Ruby.Builtins.RubyModule.EmptyArray, new System.Delegate[] { new Microsoft.Scripting.Utils.Function(Ruby.Builtins.SystemCallErrorOps.Factory), }); - DefineGlobalClass("ThreadError", typeof(Ruby.Builtins.ThreadError), null, null, null, def39, Ruby.Builtins.RubyModule.EmptyArray, null); - DefineGlobalClass("TypeError", typeof(System.InvalidOperationException), typeof(Ruby.Builtins.TypeErrorOps), null, null, def39, Ruby.Builtins.RubyModule.EmptyArray, new System.Delegate[] { + DefineGlobalClass("ThreadError", typeof(Ruby.Builtins.ThreadError), null, null, null, def37, Ruby.Builtins.RubyModule.EmptyArray, null); + DefineGlobalClass("TypeError", typeof(System.InvalidOperationException), typeof(Ruby.Builtins.TypeErrorOps), null, null, def37, Ruby.Builtins.RubyModule.EmptyArray, new System.Delegate[] { new Microsoft.Scripting.Utils.Function(Ruby.Builtins.TypeErrorOps.Factory), }); - DefineGlobalClass("ZeroDivisionError", typeof(System.DivideByZeroException), typeof(Ruby.Builtins.ZeroDivisionErrorOps), null, null, def39, Ruby.Builtins.RubyModule.EmptyArray, new System.Delegate[] { + DefineGlobalClass("ZeroDivisionError", typeof(System.DivideByZeroException), typeof(Ruby.Builtins.ZeroDivisionErrorOps), null, null, def37, Ruby.Builtins.RubyModule.EmptyArray, new System.Delegate[] { new Microsoft.Scripting.Utils.Function(Ruby.Builtins.ZeroDivisionErrorOps.Factory), }); - DefineGlobalClass("EOFError", typeof(Ruby.Builtins.EOFError), null, null, null, def31, Ruby.Builtins.RubyModule.EmptyArray, null); - Ruby.Builtins.RubyClass def4 = DefineClass("Errno::EACCES", typeof(Ruby.Builtins.Errno.AccessError), null, null, null, def32, Ruby.Builtins.RubyModule.EmptyArray, null); - Ruby.Builtins.RubyClass def5 = DefineClass("Errno::EBADF", typeof(Ruby.Builtins.Errno.BadFileDescriptorError), null, null, null, def32, Ruby.Builtins.RubyModule.EmptyArray, null); - Ruby.Builtins.RubyClass def6 = DefineClass("Errno::EDOM", typeof(Ruby.Builtins.Errno.DomainError), null, null, null, def32, Ruby.Builtins.RubyModule.EmptyArray, null); - Ruby.Builtins.RubyClass def7 = DefineClass("Errno::EEXIST", typeof(Ruby.Builtins.Errno.ExistError), null, null, null, def32, Ruby.Builtins.RubyModule.EmptyArray, null); - Ruby.Builtins.RubyClass def8 = DefineClass("Errno::EINVAL", typeof(Ruby.Builtins.Errno.InvalidError), null, null, null, def32, Ruby.Builtins.RubyModule.EmptyArray, null); - Ruby.Builtins.RubyClass def9 = DefineClass("Errno::ENOENT", typeof(Ruby.Builtins.Errno.NoEntryError), null, null, null, def32, Ruby.Builtins.RubyModule.EmptyArray, null); - Ruby.Builtins.RubyClass def10 = DefineClass("Errno::ENOTDIR", typeof(Ruby.Builtins.Errno.NotDirectoryError), null, null, null, def32, Ruby.Builtins.RubyModule.EmptyArray, null); - DefineGlobalClass("FloatDomainError", typeof(Ruby.Builtins.FloatDomainError), null, null, null, def33, Ruby.Builtins.RubyModule.EmptyArray, null); + DefineGlobalClass("EOFError", typeof(Ruby.Builtins.EOFError), null, null, null, def30, Ruby.Builtins.RubyModule.EmptyArray, null); + Ruby.Builtins.RubyClass def4 = DefineClass("Errno::EACCES", typeof(Ruby.Builtins.Errno.AccessError), null, null, null, def31, Ruby.Builtins.RubyModule.EmptyArray, null); + Ruby.Builtins.RubyClass def5 = DefineClass("Errno::EBADF", typeof(Ruby.Builtins.Errno.BadFileDescriptorError), null, null, null, def31, Ruby.Builtins.RubyModule.EmptyArray, null); + Ruby.Builtins.RubyClass def6 = DefineClass("Errno::EDOM", typeof(Ruby.Builtins.Errno.DomainError), null, null, null, def31, Ruby.Builtins.RubyModule.EmptyArray, null); + Ruby.Builtins.RubyClass def7 = DefineClass("Errno::EEXIST", typeof(Ruby.Builtins.Errno.ExistError), null, null, null, def31, Ruby.Builtins.RubyModule.EmptyArray, null); + Ruby.Builtins.RubyClass def8 = DefineClass("Errno::EINVAL", typeof(Ruby.Builtins.Errno.InvalidError), null, null, null, def31, Ruby.Builtins.RubyModule.EmptyArray, null); + Ruby.Builtins.RubyClass def9 = DefineClass("Errno::ENOENT", typeof(Ruby.Builtins.Errno.NoEntryError), null, null, null, def31, Ruby.Builtins.RubyModule.EmptyArray, null); + Ruby.Builtins.RubyClass def10 = DefineClass("Errno::ENOTDIR", typeof(Ruby.Builtins.Errno.NotDirectoryError), null, null, null, def31, Ruby.Builtins.RubyModule.EmptyArray, null); + DefineGlobalClass("FloatDomainError", typeof(Ruby.Builtins.FloatDomainError), null, null, null, def32, Ruby.Builtins.RubyModule.EmptyArray, null); DefineGlobalClass("NoMethodError", typeof(System.MissingMethodException), typeof(Ruby.Builtins.NoMethodErrorOps), new System.Action(LoadNoMethodError_Instance), null, def46, Ruby.Builtins.RubyModule.EmptyArray, new System.Delegate[] { new Microsoft.Scripting.Utils.Function(Ruby.Builtins.NoMethodErrorOps.Factory), }); #if !SILVERLIGHT - Ruby.Builtins.RubyClass def43 = DefineGlobalClass("TCPSocket", typeof(Ruby.Builtins.TCPSocket), null, new System.Action(LoadTCPSocket_Instance), new System.Action(LoadTCPSocket_Class), def44, Ruby.Builtins.RubyModule.EmptyArray, new System.Delegate[] { - new Microsoft.Scripting.Utils.Function(Ruby.Builtins.TCPSocket.CreateTCPSocket), + Ruby.Builtins.RubyClass def43 = DefineGlobalClass("TCPSocket", typeof(Ruby.StandardLibrary.TCPSocket), null, null, new System.Action(LoadTCPSocket_Class), def44, Ruby.Builtins.RubyModule.EmptyArray, new System.Delegate[] { + new Microsoft.Scripting.Utils.Function(Ruby.StandardLibrary.TCPSocket.CreateTCPSocket), }); #endif + #if !SILVERLIGHT + DefineGlobalClass("UDPSocket", typeof(Ruby.StandardLibrary.UDPSocket), null, new System.Action(LoadUDPSocket_Instance), null, def44, Ruby.Builtins.RubyModule.EmptyArray, new System.Delegate[] { + new Microsoft.Scripting.Utils.Function(Ruby.StandardLibrary.UDPSocket.CreateUDPSocket), + new Microsoft.Scripting.Utils.Function(Ruby.StandardLibrary.UDPSocket.CreateUDPSocket), + }); + #endif Ruby.Builtins.RubyClass def21 = DefineClass("Zlib::DataError", typeof(Ruby.StandardLibrary.Zlib.DataError), null, null, null, def45, Ruby.Builtins.RubyModule.EmptyArray, null); Ruby.Builtins.RubyClass def23 = DefineClass("Zlib::GzipFile::Error", typeof(Ruby.StandardLibrary.Zlib.GZipFile.Error), null, null, null, def45, Ruby.Builtins.RubyModule.EmptyArray, null); #if !SILVERLIGHT - DefineGlobalClass("TCPServer", typeof(Ruby.Builtins.TCPServer), null, new System.Action(LoadTCPServer_Instance), null, def43, Ruby.Builtins.RubyModule.EmptyArray, new System.Delegate[] { - new Microsoft.Scripting.Utils.Function(Ruby.Builtins.TCPServer.CreateTCPServer), + DefineGlobalClass("TCPServer", typeof(Ruby.StandardLibrary.TCPServer), null, new System.Action(LoadTCPServer_Instance), null, def43, Ruby.Builtins.RubyModule.EmptyArray, new System.Delegate[] { + new Microsoft.Scripting.Utils.Function(Ruby.StandardLibrary.TCPServer.CreateTCPServer), }); #endif def11.SetConstant("Instance", def14); @@ -384,29 +398,73 @@ private void LoadBasicSocket_Instance(Ruby.Builtins.RubyModule/*!*/ module) { module.DefineMethod("close_read", 0x9, new System.Delegate[] { - new System.Action(Ruby.Builtins.BasicSocket.CloseRead), + new Microsoft.Scripting.Utils.Action(Ruby.StandardLibrary.RubyBasicSocket.CloseRead), }); module.DefineMethod("close_write", 0x9, new System.Delegate[] { - new System.Action(Ruby.Builtins.BasicSocket.CloseWrite), + new Microsoft.Scripting.Utils.Action(Ruby.StandardLibrary.RubyBasicSocket.CloseWrite), }); + module.DefineMethod("getpeername", 0x9, new System.Delegate[] { + new Microsoft.Scripting.Utils.Function(Ruby.StandardLibrary.RubyBasicSocket.GetPeerName), + }); + + module.DefineMethod("getsockname", 0x9, new System.Delegate[] { + new Microsoft.Scripting.Utils.Function(Ruby.StandardLibrary.RubyBasicSocket.GetSocketName), + }); + + module.DefineMethod("getsockopt", 0x9, new System.Delegate[] { + new Microsoft.Scripting.Utils.Function(Ruby.StandardLibrary.RubyBasicSocket.GetSocketOption), + }); + module.DefineMethod("recv", 0x9, new System.Delegate[] { - new Microsoft.Scripting.Utils.Function(Ruby.Builtins.BasicSocket.Receive), + new Microsoft.Scripting.Utils.Function(Ruby.StandardLibrary.RubyBasicSocket.Receive), + new Microsoft.Scripting.Utils.Function(Ruby.StandardLibrary.RubyBasicSocket.Receive), }); + module.DefineMethod("recv_nonblock", 0x9, new System.Delegate[] { + new Microsoft.Scripting.Utils.Function(Ruby.StandardLibrary.RubyBasicSocket.ReceiveNonBlocking), + new Microsoft.Scripting.Utils.Function(Ruby.StandardLibrary.RubyBasicSocket.ReceiveNonBlocking), + }); + module.DefineMethod("send", 0x9, new System.Delegate[] { - new Microsoft.Scripting.Utils.Function(Ruby.Builtins.BasicSocket.Send), + new Microsoft.Scripting.Utils.Function(Ruby.StandardLibrary.RubyBasicSocket.Send), + new Microsoft.Scripting.Utils.Function(Ruby.StandardLibrary.RubyBasicSocket.Send), }); + module.DefineMethod("setsockopt", 0x9, new System.Delegate[] { + new Microsoft.Scripting.Utils.Action(Ruby.StandardLibrary.RubyBasicSocket.SetSocketOption), + new Microsoft.Scripting.Utils.Action(Ruby.StandardLibrary.RubyBasicSocket.SetSocketOption), + new Microsoft.Scripting.Utils.Action(Ruby.StandardLibrary.RubyBasicSocket.SetSocketOption), + }); + module.DefineMethod("shutdown", 0x9, new System.Delegate[] { - new Microsoft.Scripting.Utils.Function(Ruby.Builtins.BasicSocket.ShutDown), - new Microsoft.Scripting.Utils.Function(Ruby.Builtins.BasicSocket.ShutDown), + new Microsoft.Scripting.Utils.Function(Ruby.StandardLibrary.RubyBasicSocket.Shutdown), + new Microsoft.Scripting.Utils.Function(Ruby.StandardLibrary.RubyBasicSocket.Shutdown), + new Microsoft.Scripting.Utils.Function(Ruby.StandardLibrary.RubyBasicSocket.Shutdown), }); } #endif + #if !SILVERLIGHT + private void LoadBasicSocket_Class(Ruby.Builtins.RubyModule/*!*/ module) { + + module.DefineMethod("do_not_reverse_lookup", 0x11, new System.Delegate[] { + new Microsoft.Scripting.Utils.Function(Ruby.StandardLibrary.RubyBasicSocket.GetDoNotReverseLookup), + }); + + module.DefineMethod("do_not_reverse_lookup=", 0x11, new System.Delegate[] { + new Microsoft.Scripting.Utils.Action(Ruby.StandardLibrary.RubyBasicSocket.SetDoNotReverseLookup), + }); + + module.DefineMethod("for_fd", 0x11, new System.Delegate[] { + new Microsoft.Scripting.Utils.Function(Ruby.StandardLibrary.RubyBasicSocket.ForFileDescriptor), + }); + + } + #endif + private void LoadBignum_Instance(Ruby.Builtins.RubyModule/*!*/ module) { module.DefineMethod("-", 0x9, new System.Delegate[] { @@ -1767,13 +1825,18 @@ private void LoadIPSocket_Instance(Ruby.Builtins.RubyModule/*!*/ module) { module.DefineMethod("addr", 0x9, new System.Delegate[] { - new Microsoft.Scripting.Utils.Function(Ruby.Builtins.IPSocket.GetAddress), + new Microsoft.Scripting.Utils.Function(Ruby.StandardLibrary.IPSocket.GetLocalAddress), }); module.DefineMethod("peeraddr", 0x9, new System.Delegate[] { - new Microsoft.Scripting.Utils.Function(Ruby.Builtins.IPSocket.GetPeerAddress), + new Microsoft.Scripting.Utils.Function(Ruby.StandardLibrary.IPSocket.GetPeerAddress), }); + module.DefineMethod("recvfrom", 0x9, new System.Delegate[] { + new Microsoft.Scripting.Utils.Function(Ruby.StandardLibrary.IPSocket.ReceiveFrom), + new Microsoft.Scripting.Utils.Function(Ruby.StandardLibrary.IPSocket.ReceiveFrom), + }); + } #endif @@ -1781,7 +1844,7 @@ private void LoadIPSocket_Class(Ruby.Builtins.RubyModule/*!*/ module) { module.DefineMethod("getaddress", 0x11, new System.Delegate[] { - new Microsoft.Scripting.Utils.Function(Ruby.Builtins.IPSocket.GetAddress), + new Microsoft.Scripting.Utils.Function(Ruby.StandardLibrary.IPSocket.GetAddress), }); } @@ -3026,6 +3089,271 @@ } + #if !SILVERLIGHT + private void LoadSocket_Instance(Ruby.Builtins.RubyModule/*!*/ module) { + module.SetConstant("AF_APPLETALK", Ruby.StandardLibrary.RubySocket.AF_APPLETALK); + module.SetConstant("AF_ATM", Ruby.StandardLibrary.RubySocket.AF_ATM); + module.SetConstant("AF_CCITT", Ruby.StandardLibrary.RubySocket.AF_CCITT); + module.SetConstant("AF_CHAOS", Ruby.StandardLibrary.RubySocket.AF_CHAOS); + module.SetConstant("AF_DATAKIT", Ruby.StandardLibrary.RubySocket.AF_DATAKIT); + module.SetConstant("AF_DLI", Ruby.StandardLibrary.RubySocket.AF_DLI); + module.SetConstant("AF_ECMA", Ruby.StandardLibrary.RubySocket.AF_ECMA); + module.SetConstant("AF_HYLINK", Ruby.StandardLibrary.RubySocket.AF_HYLINK); + module.SetConstant("AF_IMPLINK", Ruby.StandardLibrary.RubySocket.AF_IMPLINK); + module.SetConstant("AF_INET", Ruby.StandardLibrary.RubySocket.AF_INET); + module.SetConstant("AF_IPX", Ruby.StandardLibrary.RubySocket.AF_IPX); + module.SetConstant("AF_ISO", Ruby.StandardLibrary.RubySocket.AF_ISO); + module.SetConstant("AF_LAT", Ruby.StandardLibrary.RubySocket.AF_LAT); + module.SetConstant("AF_MAX", Ruby.StandardLibrary.RubySocket.AF_MAX); + module.SetConstant("AF_NETBIOS", Ruby.StandardLibrary.RubySocket.AF_NETBIOS); + module.SetConstant("AF_NS", Ruby.StandardLibrary.RubySocket.AF_NS); + module.SetConstant("AF_OSI", Ruby.StandardLibrary.RubySocket.AF_OSI); + module.SetConstant("AF_PUP", Ruby.StandardLibrary.RubySocket.AF_PUP); + module.SetConstant("AF_SNA", Ruby.StandardLibrary.RubySocket.AF_SNA); + module.SetConstant("AF_UNIX", Ruby.StandardLibrary.RubySocket.AF_UNIX); + module.SetConstant("AF_UNSPEC", Ruby.StandardLibrary.RubySocket.AF_UNSPEC); + module.SetConstant("AI_ADDRCONFIG", Ruby.StandardLibrary.RubySocket.AI_ADDRCONFIG); + module.SetConstant("AI_ALL", Ruby.StandardLibrary.RubySocket.AI_ALL); + module.SetConstant("AI_CANONNAME", Ruby.StandardLibrary.RubySocket.AI_CANONNAME); + module.SetConstant("AI_DEFAULT", Ruby.StandardLibrary.RubySocket.AI_DEFAULT); + module.SetConstant("AI_MASK", Ruby.StandardLibrary.RubySocket.AI_MASK); + module.SetConstant("AI_NUMERICHOST", Ruby.StandardLibrary.RubySocket.AI_NUMERICHOST); + module.SetConstant("AI_PASSIVE", Ruby.StandardLibrary.RubySocket.AI_PASSIVE); + module.SetConstant("AI_V4MAPPED", Ruby.StandardLibrary.RubySocket.AI_V4MAPPED); + module.SetConstant("AI_V4MAPPED_CFG", Ruby.StandardLibrary.RubySocket.AI_V4MAPPED_CFG); + module.SetConstant("EAI_ADDRFAMILY", Ruby.StandardLibrary.RubySocket.EAI_ADDRFAMILY); + module.SetConstant("EAI_AGAIN", Ruby.StandardLibrary.RubySocket.EAI_AGAIN); + module.SetConstant("EAI_BADFLAGS", Ruby.StandardLibrary.RubySocket.EAI_BADFLAGS); + module.SetConstant("EAI_BADHINTS", Ruby.StandardLibrary.RubySocket.EAI_BADHINTS); + module.SetConstant("EAI_FAIL", Ruby.StandardLibrary.RubySocket.EAI_FAIL); + module.SetConstant("EAI_FAMILY", Ruby.StandardLibrary.RubySocket.EAI_FAMILY); + module.SetConstant("EAI_MAX", Ruby.StandardLibrary.RubySocket.EAI_MAX); + module.SetConstant("EAI_MEMORY", Ruby.StandardLibrary.RubySocket.EAI_MEMORY); + module.SetConstant("EAI_NODATA", Ruby.StandardLibrary.RubySocket.EAI_NODATA); + module.SetConstant("EAI_NONAME", Ruby.StandardLibrary.RubySocket.EAI_NONAME); + module.SetConstant("EAI_PROTOCOL", Ruby.StandardLibrary.RubySocket.EAI_PROTOCOL); + module.SetConstant("EAI_SERVICE", Ruby.StandardLibrary.RubySocket.EAI_SERVICE); + module.SetConstant("EAI_SOCKTYPE", Ruby.StandardLibrary.RubySocket.EAI_SOCKTYPE); + module.SetConstant("EAI_SYSTEM", Ruby.StandardLibrary.RubySocket.EAI_SYSTEM); + module.SetConstant("INADDR_ALLHOSTS_GROUP", Ruby.StandardLibrary.RubySocket.INADDR_ALLHOSTS_GROUP); + module.SetConstant("INADDR_ANY", Ruby.StandardLibrary.RubySocket.INADDR_ANY); + module.SetConstant("INADDR_BROADCAST", Ruby.StandardLibrary.RubySocket.INADDR_BROADCAST); + module.SetConstant("INADDR_LOOPBACK", Ruby.StandardLibrary.RubySocket.INADDR_LOOPBACK); + module.SetConstant("INADDR_MAX_LOCAL_GROUP", Ruby.StandardLibrary.RubySocket.INADDR_MAX_LOCAL_GROUP); + module.SetConstant("INADDR_NONE", Ruby.StandardLibrary.RubySocket.INADDR_NONE); + module.SetConstant("INADDR_UNSPEC_GROUP", Ruby.StandardLibrary.RubySocket.INADDR_UNSPEC_GROUP); + module.SetConstant("IPPORT_RESERVED", Ruby.StandardLibrary.RubySocket.IPPORT_RESERVED); + module.SetConstant("IPPORT_USERRESERVED", Ruby.StandardLibrary.RubySocket.IPPORT_USERRESERVED); + module.SetConstant("IPPROTO_GGP", Ruby.StandardLibrary.RubySocket.IPPROTO_GGP); + module.SetConstant("IPPROTO_ICMP", Ruby.StandardLibrary.RubySocket.IPPROTO_ICMP); + module.SetConstant("IPPROTO_IDP", Ruby.StandardLibrary.RubySocket.IPPROTO_IDP); + module.SetConstant("IPPROTO_IGMP", Ruby.StandardLibrary.RubySocket.IPPROTO_IGMP); + module.SetConstant("IPPROTO_IP", Ruby.StandardLibrary.RubySocket.IPPROTO_IP); + module.SetConstant("IPPROTO_MAX", Ruby.StandardLibrary.RubySocket.IPPROTO_MAX); + module.SetConstant("IPPROTO_ND", Ruby.StandardLibrary.RubySocket.IPPROTO_ND); + module.SetConstant("IPPROTO_PUP", Ruby.StandardLibrary.RubySocket.IPPROTO_PUP); + module.SetConstant("IPPROTO_RAW", Ruby.StandardLibrary.RubySocket.IPPROTO_RAW); + module.SetConstant("IPPROTO_TCP", Ruby.StandardLibrary.RubySocket.IPPROTO_TCP); + module.SetConstant("IPPROTO_UDP", Ruby.StandardLibrary.RubySocket.IPPROTO_UDP); + module.SetConstant("MSG_DONTROUTE", Ruby.StandardLibrary.RubySocket.MSG_DONTROUTE); + module.SetConstant("MSG_OOB", Ruby.StandardLibrary.RubySocket.MSG_OOB); + module.SetConstant("MSG_PEEK", Ruby.StandardLibrary.RubySocket.MSG_PEEK); + module.SetConstant("NI_DGRAM", Ruby.StandardLibrary.RubySocket.NI_DGRAM); + module.SetConstant("NI_MAXHOST", Ruby.StandardLibrary.RubySocket.NI_MAXHOST); + module.SetConstant("NI_MAXSERV", Ruby.StandardLibrary.RubySocket.NI_MAXSERV); + module.SetConstant("NI_NAMEREQD", Ruby.StandardLibrary.RubySocket.NI_NAMEREQD); + module.SetConstant("NI_NOFQDN", Ruby.StandardLibrary.RubySocket.NI_NOFQDN); + module.SetConstant("NI_NUMERICHOST", Ruby.StandardLibrary.RubySocket.NI_NUMERICHOST); + module.SetConstant("NI_NUMERICSERV", Ruby.StandardLibrary.RubySocket.NI_NUMERICSERV); + module.SetConstant("PF_APPLETALK", Ruby.StandardLibrary.RubySocket.PF_APPLETALK); + module.SetConstant("PF_ATM", Ruby.StandardLibrary.RubySocket.PF_ATM); + module.SetConstant("PF_CCITT", Ruby.StandardLibrary.RubySocket.PF_CCITT); + module.SetConstant("PF_CHAOS", Ruby.StandardLibrary.RubySocket.PF_CHAOS); + module.SetConstant("PF_DATAKIT", Ruby.StandardLibrary.RubySocket.PF_DATAKIT); + module.SetConstant("PF_DLI", Ruby.StandardLibrary.RubySocket.PF_DLI); + module.SetConstant("PF_ECMA", Ruby.StandardLibrary.RubySocket.PF_ECMA); + module.SetConstant("PF_HYLINK", Ruby.StandardLibrary.RubySocket.PF_HYLINK); + module.SetConstant("PF_IMPLINK", Ruby.StandardLibrary.RubySocket.PF_IMPLINK); + module.SetConstant("PF_INET", Ruby.StandardLibrary.RubySocket.PF_INET); + module.SetConstant("PF_IPX", Ruby.StandardLibrary.RubySocket.PF_IPX); + module.SetConstant("PF_ISO", Ruby.StandardLibrary.RubySocket.PF_ISO); + module.SetConstant("PF_LAT", Ruby.StandardLibrary.RubySocket.PF_LAT); + module.SetConstant("PF_MAX", Ruby.StandardLibrary.RubySocket.PF_MAX); + module.SetConstant("PF_NS", Ruby.StandardLibrary.RubySocket.PF_NS); + module.SetConstant("PF_OSI", Ruby.StandardLibrary.RubySocket.PF_OSI); + module.SetConstant("PF_PUP", Ruby.StandardLibrary.RubySocket.PF_PUP); + module.SetConstant("PF_SNA", Ruby.StandardLibrary.RubySocket.PF_SNA); + module.SetConstant("PF_UNIX", Ruby.StandardLibrary.RubySocket.PF_UNIX); + module.SetConstant("PF_UNSPEC", Ruby.StandardLibrary.RubySocket.PF_UNSPEC); + module.SetConstant("SHUT_RD", Ruby.StandardLibrary.RubySocket.SHUT_RD); + module.SetConstant("SHUT_RDWR", Ruby.StandardLibrary.RubySocket.SHUT_RDWR); + module.SetConstant("SHUT_WR", Ruby.StandardLibrary.RubySocket.SHUT_WR); + module.SetConstant("SO_ACCEPTCONN", Ruby.StandardLibrary.RubySocket.SO_ACCEPTCONN); + module.SetConstant("SO_BROADCAST", Ruby.StandardLibrary.RubySocket.SO_BROADCAST); + module.SetConstant("SO_DEBUG", Ruby.StandardLibrary.RubySocket.SO_DEBUG); + module.SetConstant("SO_DONTROUTE", Ruby.StandardLibrary.RubySocket.SO_DONTROUTE); + module.SetConstant("SO_ERROR", Ruby.StandardLibrary.RubySocket.SO_ERROR); + module.SetConstant("SO_KEEPALIVE", Ruby.StandardLibrary.RubySocket.SO_KEEPALIVE); + module.SetConstant("SO_LINGER", Ruby.StandardLibrary.RubySocket.SO_LINGER); + module.SetConstant("SO_OOBINLINE", Ruby.StandardLibrary.RubySocket.SO_OOBINLINE); + module.SetConstant("SO_RCVBUF", Ruby.StandardLibrary.RubySocket.SO_RCVBUF); + module.SetConstant("SO_RCVLOWAT", Ruby.StandardLibrary.RubySocket.SO_RCVLOWAT); + module.SetConstant("SO_RCVTIMEO", Ruby.StandardLibrary.RubySocket.SO_RCVTIMEO); + module.SetConstant("SO_REUSEADDR", Ruby.StandardLibrary.RubySocket.SO_REUSEADDR); + module.SetConstant("SO_SNDBUF", Ruby.StandardLibrary.RubySocket.SO_SNDBUF); + module.SetConstant("SO_SNDLOWAT", Ruby.StandardLibrary.RubySocket.SO_SNDLOWAT); + module.SetConstant("SO_SNDTIMEO", Ruby.StandardLibrary.RubySocket.SO_SNDTIMEO); + module.SetConstant("SO_TYPE", Ruby.StandardLibrary.RubySocket.SO_TYPE); + module.SetConstant("SO_USELOOPBACK", Ruby.StandardLibrary.RubySocket.SO_USELOOPBACK); + module.SetConstant("SOCK_DGRAM", Ruby.StandardLibrary.RubySocket.SOCK_DGRAM); + module.SetConstant("SOCK_RAW", Ruby.StandardLibrary.RubySocket.SOCK_RAW); + module.SetConstant("SOCK_RDM", Ruby.StandardLibrary.RubySocket.SOCK_RDM); + module.SetConstant("SOCK_SEQPACKET", Ruby.StandardLibrary.RubySocket.SOCK_SEQPACKET); + module.SetConstant("SOCK_STREAM", Ruby.StandardLibrary.RubySocket.SOCK_STREAM); + module.SetConstant("SOL_SOCKET", Ruby.StandardLibrary.RubySocket.SOL_SOCKET); + module.SetConstant("TCP_NODELAY", Ruby.StandardLibrary.RubySocket.TCP_NODELAY); + + } + #endif + + #if !SILVERLIGHT + private void LoadSocket_Class(Ruby.Builtins.RubyModule/*!*/ module) { + module.SetConstant("AF_APPLETALK", Ruby.StandardLibrary.RubySocket.AF_APPLETALK); + module.SetConstant("AF_ATM", Ruby.StandardLibrary.RubySocket.AF_ATM); + module.SetConstant("AF_CCITT", Ruby.StandardLibrary.RubySocket.AF_CCITT); + module.SetConstant("AF_CHAOS", Ruby.StandardLibrary.RubySocket.AF_CHAOS); + module.SetConstant("AF_DATAKIT", Ruby.StandardLibrary.RubySocket.AF_DATAKIT); + module.SetConstant("AF_DLI", Ruby.StandardLibrary.RubySocket.AF_DLI); + module.SetConstant("AF_ECMA", Ruby.StandardLibrary.RubySocket.AF_ECMA); + module.SetConstant("AF_HYLINK", Ruby.StandardLibrary.RubySocket.AF_HYLINK); + module.SetConstant("AF_IMPLINK", Ruby.StandardLibrary.RubySocket.AF_IMPLINK); + module.SetConstant("AF_INET", Ruby.StandardLibrary.RubySocket.AF_INET); + module.SetConstant("AF_IPX", Ruby.StandardLibrary.RubySocket.AF_IPX); + module.SetConstant("AF_ISO", Ruby.StandardLibrary.RubySocket.AF_ISO); + module.SetConstant("AF_LAT", Ruby.StandardLibrary.RubySocket.AF_LAT); + module.SetConstant("AF_MAX", Ruby.StandardLibrary.RubySocket.AF_MAX); + module.SetConstant("AF_NETBIOS", Ruby.StandardLibrary.RubySocket.AF_NETBIOS); + module.SetConstant("AF_NS", Ruby.StandardLibrary.RubySocket.AF_NS); + module.SetConstant("AF_OSI", Ruby.StandardLibrary.RubySocket.AF_OSI); + module.SetConstant("AF_PUP", Ruby.StandardLibrary.RubySocket.AF_PUP); + module.SetConstant("AF_SNA", Ruby.StandardLibrary.RubySocket.AF_SNA); + module.SetConstant("AF_UNIX", Ruby.StandardLibrary.RubySocket.AF_UNIX); + module.SetConstant("AF_UNSPEC", Ruby.StandardLibrary.RubySocket.AF_UNSPEC); + module.SetConstant("AI_ADDRCONFIG", Ruby.StandardLibrary.RubySocket.AI_ADDRCONFIG); + module.SetConstant("AI_ALL", Ruby.StandardLibrary.RubySocket.AI_ALL); + module.SetConstant("AI_CANONNAME", Ruby.StandardLibrary.RubySocket.AI_CANONNAME); + module.SetConstant("AI_DEFAULT", Ruby.StandardLibrary.RubySocket.AI_DEFAULT); + module.SetConstant("AI_MASK", Ruby.StandardLibrary.RubySocket.AI_MASK); + module.SetConstant("AI_NUMERICHOST", Ruby.StandardLibrary.RubySocket.AI_NUMERICHOST); + module.SetConstant("AI_PASSIVE", Ruby.StandardLibrary.RubySocket.AI_PASSIVE); + module.SetConstant("AI_V4MAPPED", Ruby.StandardLibrary.RubySocket.AI_V4MAPPED); + module.SetConstant("AI_V4MAPPED_CFG", Ruby.StandardLibrary.RubySocket.AI_V4MAPPED_CFG); + module.SetConstant("EAI_ADDRFAMILY", Ruby.StandardLibrary.RubySocket.EAI_ADDRFAMILY); + module.SetConstant("EAI_AGAIN", Ruby.StandardLibrary.RubySocket.EAI_AGAIN); + module.SetConstant("EAI_BADFLAGS", Ruby.StandardLibrary.RubySocket.EAI_BADFLAGS); + module.SetConstant("EAI_BADHINTS", Ruby.StandardLibrary.RubySocket.EAI_BADHINTS); + module.SetConstant("EAI_FAIL", Ruby.StandardLibrary.RubySocket.EAI_FAIL); + module.SetConstant("EAI_FAMILY", Ruby.StandardLibrary.RubySocket.EAI_FAMILY); + module.SetConstant("EAI_MAX", Ruby.StandardLibrary.RubySocket.EAI_MAX); + module.SetConstant("EAI_MEMORY", Ruby.StandardLibrary.RubySocket.EAI_MEMORY); + module.SetConstant("EAI_NODATA", Ruby.StandardLibrary.RubySocket.EAI_NODATA); + module.SetConstant("EAI_NONAME", Ruby.StandardLibrary.RubySocket.EAI_NONAME); + module.SetConstant("EAI_PROTOCOL", Ruby.StandardLibrary.RubySocket.EAI_PROTOCOL); + module.SetConstant("EAI_SERVICE", Ruby.StandardLibrary.RubySocket.EAI_SERVICE); + module.SetConstant("EAI_SOCKTYPE", Ruby.StandardLibrary.RubySocket.EAI_SOCKTYPE); + module.SetConstant("EAI_SYSTEM", Ruby.StandardLibrary.RubySocket.EAI_SYSTEM); + module.SetConstant("INADDR_ALLHOSTS_GROUP", Ruby.StandardLibrary.RubySocket.INADDR_ALLHOSTS_GROUP); + module.SetConstant("INADDR_ANY", Ruby.StandardLibrary.RubySocket.INADDR_ANY); + module.SetConstant("INADDR_BROADCAST", Ruby.StandardLibrary.RubySocket.INADDR_BROADCAST); + module.SetConstant("INADDR_LOOPBACK", Ruby.StandardLibrary.RubySocket.INADDR_LOOPBACK); + module.SetConstant("INADDR_MAX_LOCAL_GROUP", Ruby.StandardLibrary.RubySocket.INADDR_MAX_LOCAL_GROUP); + module.SetConstant("INADDR_NONE", Ruby.StandardLibrary.RubySocket.INADDR_NONE); + module.SetConstant("INADDR_UNSPEC_GROUP", Ruby.StandardLibrary.RubySocket.INADDR_UNSPEC_GROUP); + module.SetConstant("IPPORT_RESERVED", Ruby.StandardLibrary.RubySocket.IPPORT_RESERVED); + module.SetConstant("IPPORT_USERRESERVED", Ruby.StandardLibrary.RubySocket.IPPORT_USERRESERVED); + module.SetConstant("IPPROTO_GGP", Ruby.StandardLibrary.RubySocket.IPPROTO_GGP); + module.SetConstant("IPPROTO_ICMP", Ruby.StandardLibrary.RubySocket.IPPROTO_ICMP); + module.SetConstant("IPPROTO_IDP", Ruby.StandardLibrary.RubySocket.IPPROTO_IDP); + module.SetConstant("IPPROTO_IGMP", Ruby.StandardLibrary.RubySocket.IPPROTO_IGMP); + module.SetConstant("IPPROTO_IP", Ruby.StandardLibrary.RubySocket.IPPROTO_IP); + module.SetConstant("IPPROTO_MAX", Ruby.StandardLibrary.RubySocket.IPPROTO_MAX); + module.SetConstant("IPPROTO_ND", Ruby.StandardLibrary.RubySocket.IPPROTO_ND); + module.SetConstant("IPPROTO_PUP", Ruby.StandardLibrary.RubySocket.IPPROTO_PUP); + module.SetConstant("IPPROTO_RAW", Ruby.StandardLibrary.RubySocket.IPPROTO_RAW); + module.SetConstant("IPPROTO_TCP", Ruby.StandardLibrary.RubySocket.IPPROTO_TCP); + module.SetConstant("IPPROTO_UDP", Ruby.StandardLibrary.RubySocket.IPPROTO_UDP); + module.SetConstant("MSG_DONTROUTE", Ruby.StandardLibrary.RubySocket.MSG_DONTROUTE); + module.SetConstant("MSG_OOB", Ruby.StandardLibrary.RubySocket.MSG_OOB); + module.SetConstant("MSG_PEEK", Ruby.StandardLibrary.RubySocket.MSG_PEEK); + module.SetConstant("NI_DGRAM", Ruby.StandardLibrary.RubySocket.NI_DGRAM); + module.SetConstant("NI_MAXHOST", Ruby.StandardLibrary.RubySocket.NI_MAXHOST); + module.SetConstant("NI_MAXSERV", Ruby.StandardLibrary.RubySocket.NI_MAXSERV); + module.SetConstant("NI_NAMEREQD", Ruby.StandardLibrary.RubySocket.NI_NAMEREQD); + module.SetConstant("NI_NOFQDN", Ruby.StandardLibrary.RubySocket.NI_NOFQDN); + module.SetConstant("NI_NUMERICHOST", Ruby.StandardLibrary.RubySocket.NI_NUMERICHOST); + module.SetConstant("NI_NUMERICSERV", Ruby.StandardLibrary.RubySocket.NI_NUMERICSERV); + module.SetConstant("PF_APPLETALK", Ruby.StandardLibrary.RubySocket.PF_APPLETALK); + module.SetConstant("PF_ATM", Ruby.StandardLibrary.RubySocket.PF_ATM); + module.SetConstant("PF_CCITT", Ruby.StandardLibrary.RubySocket.PF_CCITT); + module.SetConstant("PF_CHAOS", Ruby.StandardLibrary.RubySocket.PF_CHAOS); + module.SetConstant("PF_DATAKIT", Ruby.StandardLibrary.RubySocket.PF_DATAKIT); + module.SetConstant("PF_DLI", Ruby.StandardLibrary.RubySocket.PF_DLI); + module.SetConstant("PF_ECMA", Ruby.StandardLibrary.RubySocket.PF_ECMA); + module.SetConstant("PF_HYLINK", Ruby.StandardLibrary.RubySocket.PF_HYLINK); + module.SetConstant("PF_IMPLINK", Ruby.StandardLibrary.RubySocket.PF_IMPLINK); + module.SetConstant("PF_INET", Ruby.StandardLibrary.RubySocket.PF_INET); + module.SetConstant("PF_IPX", Ruby.StandardLibrary.RubySocket.PF_IPX); + module.SetConstant("PF_ISO", Ruby.StandardLibrary.RubySocket.PF_ISO); + module.SetConstant("PF_LAT", Ruby.StandardLibrary.RubySocket.PF_LAT); + module.SetConstant("PF_MAX", Ruby.StandardLibrary.RubySocket.PF_MAX); + module.SetConstant("PF_NS", Ruby.StandardLibrary.RubySocket.PF_NS); + module.SetConstant("PF_OSI", Ruby.StandardLibrary.RubySocket.PF_OSI); + module.SetConstant("PF_PUP", Ruby.StandardLibrary.RubySocket.PF_PUP); + module.SetConstant("PF_SNA", Ruby.StandardLibrary.RubySocket.PF_SNA); + module.SetConstant("PF_UNIX", Ruby.StandardLibrary.RubySocket.PF_UNIX); + module.SetConstant("PF_UNSPEC", Ruby.StandardLibrary.RubySocket.PF_UNSPEC); + module.SetConstant("SHUT_RD", Ruby.StandardLibrary.RubySocket.SHUT_RD); + module.SetConstant("SHUT_RDWR", Ruby.StandardLibrary.RubySocket.SHUT_RDWR); + module.SetConstant("SHUT_WR", Ruby.StandardLibrary.RubySocket.SHUT_WR); + module.SetConstant("SO_ACCEPTCONN", Ruby.StandardLibrary.RubySocket.SO_ACCEPTCONN); + module.SetConstant("SO_BROADCAST", Ruby.StandardLibrary.RubySocket.SO_BROADCAST); + module.SetConstant("SO_DEBUG", Ruby.StandardLibrary.RubySocket.SO_DEBUG); + module.SetConstant("SO_DONTROUTE", Ruby.StandardLibrary.RubySocket.SO_DONTROUTE); + module.SetConstant("SO_ERROR", Ruby.StandardLibrary.RubySocket.SO_ERROR); + module.SetConstant("SO_KEEPALIVE", Ruby.StandardLibrary.RubySocket.SO_KEEPALIVE); + module.SetConstant("SO_LINGER", Ruby.StandardLibrary.RubySocket.SO_LINGER); + module.SetConstant("SO_OOBINLINE", Ruby.StandardLibrary.RubySocket.SO_OOBINLINE); + module.SetConstant("SO_RCVBUF", Ruby.StandardLibrary.RubySocket.SO_RCVBUF); + module.SetConstant("SO_RCVLOWAT", Ruby.StandardLibrary.RubySocket.SO_RCVLOWAT); + module.SetConstant("SO_RCVTIMEO", Ruby.StandardLibrary.RubySocket.SO_RCVTIMEO); + module.SetConstant("SO_REUSEADDR", Ruby.StandardLibrary.RubySocket.SO_REUSEADDR); + module.SetConstant("SO_SNDBUF", Ruby.StandardLibrary.RubySocket.SO_SNDBUF); + module.SetConstant("SO_SNDLOWAT", Ruby.StandardLibrary.RubySocket.SO_SNDLOWAT); + module.SetConstant("SO_SNDTIMEO", Ruby.StandardLibrary.RubySocket.SO_SNDTIMEO); + module.SetConstant("SO_TYPE", Ruby.StandardLibrary.RubySocket.SO_TYPE); + module.SetConstant("SO_USELOOPBACK", Ruby.StandardLibrary.RubySocket.SO_USELOOPBACK); + module.SetConstant("SOCK_DGRAM", Ruby.StandardLibrary.RubySocket.SOCK_DGRAM); + module.SetConstant("SOCK_RAW", Ruby.StandardLibrary.RubySocket.SOCK_RAW); + module.SetConstant("SOCK_RDM", Ruby.StandardLibrary.RubySocket.SOCK_RDM); + module.SetConstant("SOCK_SEQPACKET", Ruby.StandardLibrary.RubySocket.SOCK_SEQPACKET); + module.SetConstant("SOCK_STREAM", Ruby.StandardLibrary.RubySocket.SOCK_STREAM); + module.SetConstant("SOL_SOCKET", Ruby.StandardLibrary.RubySocket.SOL_SOCKET); + module.SetConstant("TCP_NODELAY", Ruby.StandardLibrary.RubySocket.TCP_NODELAY); + + module.DefineMethod("getaddrinfo", 0x11, new System.Delegate[] { + new Microsoft.Scripting.Utils.Function(Ruby.StandardLibrary.RubySocket.GetAddressInfo), + }); + + } + #endif + + #if !SILVERLIGHT + private void LoadSocketError_Instance(Ruby.Builtins.RubyModule/*!*/ module) { + + module.HideMethod("message"); + } + #endif + private void LoadString_Instance(Ruby.Builtins.RubyModule/*!*/ module) { module.DefineMethod("%", 0x9, new System.Delegate[] { @@ -4263,19 +4591,21 @@ private void LoadTCPServer_Instance(Ruby.Builtins.RubyModule/*!*/ module) { module.DefineMethod("accept", 0x9, new System.Delegate[] { - new Microsoft.Scripting.Utils.Function(Ruby.Builtins.TCPServer.Accept), + new Microsoft.Scripting.Utils.Function(Ruby.StandardLibrary.TCPServer.Accept), }); - } - #endif - - #if !SILVERLIGHT - private void LoadTCPSocket_Instance(Ruby.Builtins.RubyModule/*!*/ module) { + module.DefineMethod("accept_nonblock", 0x9, new System.Delegate[] { + new Microsoft.Scripting.Utils.Function(Ruby.StandardLibrary.TCPServer.AcceptNonBlocking), + }); - module.DefineMethod("recvfrom", 0x9, new System.Delegate[] { - new Microsoft.Scripting.Utils.Function(Ruby.Builtins.TCPSocket.ReceiveFrom), + module.DefineMethod("listen", 0x9, new System.Delegate[] { + new Microsoft.Scripting.Utils.Action(Ruby.StandardLibrary.TCPServer.Listen), }); + module.DefineMethod("sysaccept", 0x9, new System.Delegate[] { + new Microsoft.Scripting.Utils.Function(Ruby.StandardLibrary.TCPServer.SysAccept), + }); + } #endif @@ -4283,7 +4613,7 @@ private void LoadTCPSocket_Class(Ruby.Builtins.RubyModule/*!*/ module) { module.DefineMethod("gethostbyname", 0x11, new System.Delegate[] { - new Microsoft.Scripting.Utils.Function(Ruby.Builtins.TCPSocket.GetHostByName), + new Microsoft.Scripting.Utils.Function(Ruby.StandardLibrary.TCPSocket.GetHostByName), }); } @@ -4508,6 +4838,31 @@ } + #if !SILVERLIGHT + private void LoadUDPSocket_Instance(Ruby.Builtins.RubyModule/*!*/ module) { + + module.DefineMethod("bind", 0x9, new System.Delegate[] { + new Microsoft.Scripting.Utils.Function(Ruby.StandardLibrary.UDPSocket.Bind), + }); + + module.DefineMethod("connect", 0x9, new System.Delegate[] { + new Microsoft.Scripting.Utils.Function(Ruby.StandardLibrary.UDPSocket.Connect), + }); + + module.DefineMethod("recvfrom_nonblock", 0x9, new System.Delegate[] { + new Microsoft.Scripting.Utils.Function(Ruby.StandardLibrary.UDPSocket.ReceiveFromNonBlocking), + new Microsoft.Scripting.Utils.Function(Ruby.StandardLibrary.UDPSocket.ReceiveFromNonBlocking), + }); + + module.DefineMethod("send", 0x9, new System.Delegate[] { + new Microsoft.Scripting.Utils.Function(Ruby.StandardLibrary.UDPSocket.Send), + new Microsoft.Scripting.Utils.Function(Ruby.StandardLibrary.UDPSocket.Send), + new Microsoft.Scripting.Utils.Function(Ruby.StandardLibrary.UDPSocket.Send), + }); + + } + #endif + private void LoadUnboundMethod_Instance(Ruby.Builtins.RubyModule/*!*/ module) { module.DefineMethod("==", 0x9, new System.Delegate[] { =================================================================== edit: $/Dev10/feature/vs_langs01/Merlin/Main/Languages/Ruby/Libraries.LCA_RESTRICTED/IronRuby.Libraries.csproj;C435539 File: IronRuby.Libraries.csproj =================================================================== --- $/Dev10/feature/vs_langs01/Merlin/Main/Languages/Ruby/Libraries.LCA_RESTRICTED/IronRuby.Libraries.csproj;C435539 (server) 5/13/2008 8:53 AM +++ Shelved Change: $/Dev10/feature/vs_langs01/Merlin/Main/Languages/Ruby/Libraries.LCA_RESTRICTED/IronRuby.Libraries.csproj;sockets-1 @@ -107,7 +107,6 @@ - @@ -128,6 +127,14 @@ + + + + + + + + @@ -140,6 +147,10 @@ False $(SilverlightSdkPath)\System.dll + + False + $(SilverlightSdkPath)\System.Net.dll + =================================================================== edit: $/Dev10/feature/vs_langs01/Merlin/Main/Languages/Ruby/Libraries.LCA_RESTRICTED/Protocols.cs;C435539 File: Protocols.cs =================================================================== --- $/Dev10/feature/vs_langs01/Merlin/Main/Languages/Ruby/Libraries.LCA_RESTRICTED/Protocols.cs;C435539 (server) 5/13/2008 8:53 AM +++ Shelved Change: $/Dev10/feature/vs_langs01/Merlin/Main/Languages/Ruby/Libraries.LCA_RESTRICTED/Protocols.cs;sockets-1 @@ -601,5 +601,19 @@ #endregion + #region Security + public static void CheckSafeLevel(CodeContext/*!*/ context, int level) { + RubyExecutionContext ec = RubyUtils.GetExecutionContext(context); + if (level <= ec.CurrentSafeLevel) { + throw RubyExceptions.CreateSecurityError("Insecure operation at level " + ec.CurrentSafeLevel); + } + } + public static void CheckSafeLevel(CodeContext/*!*/ context, int level, string method) { + RubyExecutionContext ec = RubyUtils.GetExecutionContext(context); + if (level <= ec.CurrentSafeLevel) { + throw RubyExceptions.CreateSecurityError(String.Format("Insecure operation {0} at level {1}", method, ec.CurrentSafeLevel)); + } + } + #endregion } } =================================================================== edit: $/Dev10/feature/vs_langs01/Merlin/Main/Languages/Ruby/Libraries.LCA_RESTRICTED/Builtins/FileOps.cs;C436237 File: FileOps.cs =================================================================== --- $/Dev10/feature/vs_langs01/Merlin/Main/Languages/Ruby/Libraries.LCA_RESTRICTED/Builtins/FileOps.cs;C436237 (server) 5/13/2008 9:09 AM +++ Shelved Change: $/Dev10/feature/vs_langs01/Merlin/Main/Languages/Ruby/Libraries.LCA_RESTRICTED/Builtins/FileOps.cs;sockets-1 @@ -183,7 +183,7 @@ [RubyMethod("file?", RubyMethodAttributes.PublicSingleton)] public static bool IsAFile(object self/*!*/, [NotNull]MutableString/*!*/ path) { - return File.Exists(path); + return File.Exists(path.ConvertToString()); } [RubyMethod("file?", RubyMethodAttributes.PublicSingleton)] =================================================================== delete: $/Dev10/feature/vs_langs01/Merlin/Main/Languages/Ruby/Libraries.LCA_RESTRICTED/Builtins/Socket.cs;C417565 File: Socket.cs =================================================================== --- $/Dev10/feature/vs_langs01/Merlin/Main/Languages/Ruby/Libraries.LCA_RESTRICTED/Builtins/Socket.cs;C417565 (server) 5/13/2008 8:53 AM +++ [no target file] @@ -1,375 +1,0 @@ -/* **************************************************************************** - * - * Copyright (c) Microsoft Corporation. - * - * This source code is subject to terms and conditions of the Microsoft Public License. A - * copy of the license can be found in the License.html file at the root of this distribution. If - * you cannot locate the Microsoft Public License, please send an email to - * ironruby@microsoft.com. By using this source code in any fashion, you are agreeing to be bound - * by the terms of the Microsoft Public License. - * - * You must not remove this notice, or any other, from this software. - * - * - * ***************************************************************************/ - -#if !SILVERLIGHT // sockets - -using System; -using System.Collections.Generic; -using System.Diagnostics; -using System.Net; -using System.Net.Sockets; -using System.Reflection; -using System.Runtime.InteropServices; -using Microsoft.Scripting; -using Microsoft.Scripting.Actions; -using Microsoft.Scripting.Ast; -using Microsoft.Scripting.Utils; -using Ruby.Runtime; -using Microsoft.Scripting.Runtime; - -// TODO: all of these classes should be in the 'socket' library -// but we don't have support for that yet -namespace Ruby.Builtins { - - // TODO: this won't work at all with the existing RubyIO implementation until I implement a proxy class that wraps Socket in a Stream - // TODO: i think that stream should do all of the IO mode checking and throw where appropriate ... in the case of sockets, only - // the socket class knows whether it can read or write from a given socket - the IOMode flags don't exist at all ... - - internal class SocketStream : System.IO.Stream { - public SocketStream(/*!*/Socket s) { - _socket = s; - } - - private long _pos = 0; - private byte _lastByteRead; - private bool _peeked = false; - private List _internalWriteBuffer = new List(); - internal readonly Socket/*!*/ _socket; - - public override bool CanRead { - get { return true; } - } - - public override bool CanSeek { - get { return false; } - } - - public override bool CanWrite { - get { return true; } - } - - public override void Flush() { - byte[] bufferedData = _internalWriteBuffer.ToArray(); - int bytesSent = _socket.Send(bufferedData); - if (bytesSent < bufferedData.Length) { - // TODO: Resend the rest - } - _internalWriteBuffer.Clear(); - } - - public override long Length { - get { throw new Exception("The method or operation is not implemented."); } - } - - public override long Position { - get { - return _pos; - } - set { - long diff = _pos - value; - if (diff == 1) { - _peeked = true; - } - - _pos = value; - } - } - - public override int Read(byte[] buffer, int offset, int count) { - int bytesToRead = _peeked ? count - 1 : count; - byte[] readBuffer = new byte[bytesToRead]; - long oldPos = _pos; - - if (bytesToRead > 0) { - int bytesRead = _socket.Receive(readBuffer, bytesToRead, SocketFlags.None); - _pos += bytesRead; - } - - if (_peeked) { - // Put the byte we've already peeked at the beginning of the buffer - buffer[offset] = _lastByteRead; - // Put the rest of the data afterwards - Array.Copy(readBuffer, 0, buffer, offset + 1, count - 1); - _pos += 1; - _peeked = false; - } - else { - Array.Copy(readBuffer, 0, buffer, offset, count); - } - - int totalBytesRead = (int)(_pos - oldPos); - if (totalBytesRead > 0) { - _lastByteRead = buffer[totalBytesRead - 1]; - } - - return totalBytesRead; - } - - public override long Seek(long offset, System.IO.SeekOrigin origin) { - throw new Exception("The method or operation is not implemented."); - } - - public override void SetLength(long value) { - throw new Exception("The method or operation is not implemented."); - } - - public override void Write(byte[] buffer, int offset, int count) { - for (int i = offset; i < offset + count; i++) { - _internalWriteBuffer.Add(buffer[i]); - if (buffer[i] == '\n') { - Flush(); - } - } - } - } - - [RubyClass("BasicSocket", BuildConfig = "!SILVERLIGHT")] - public abstract class BasicSocket : RubyIO, IDisposable { - - private readonly Socket/*!*/ _socket; - - protected Socket/*!*/ Socket { - get { return _socket; } - } - - protected BasicSocket(RubyExecutionContext/*!*/ context, Socket/*!*/ socket) - : base(context, new SocketStream(socket), "r+") { - Assert.NotNull(socket); - _socket = socket; - } - - [RubyMethod("close_read")] - public static void CloseRead(BasicSocket/*!*/ self) { - self.Socket.Shutdown(SocketShutdown.Receive); - } - - [RubyMethod("close_write")] - public static void CloseWrite(BasicSocket/*!*/ self) { - self.Socket.Shutdown(SocketShutdown.Send); - } - - [RubyMethod("recv")] - public static MutableString/*!*/ Receive(BasicSocket/*!*/ self, int len, [Optional]int flags) { - byte[] buffer = new byte[len]; - int bytes = self.Socket.Receive(buffer, (SocketFlags)flags); - return new MutableString(buffer, 0, bytes); - } - - [RubyMethod("send")] - public static int Send(BasicSocket/*!*/ self, MutableString/*!*/ data, int flags) { - return self.Socket.Send(data.ToByteArray(), (SocketFlags)flags); - } - - [RubyMethod("shutdown")] - public static int ShutDown(BasicSocket/*!*/ self) { - return ShutDown(self, 2); - } - - [RubyMethod("shutdown")] - public static int ShutDown(BasicSocket/*!*/ self, int how) { - self.Socket.Shutdown((SocketShutdown)how); - return 0; - } - - // to support using(BasicSocket) { ... } - void IDisposable.Dispose() { - _socket.Shutdown(SocketShutdown.Both); - _socket.Close(); - } - - #region common helpers - - /// - /// Conversion protocol for converting a port name/number to a port number - /// - protected static int ConverToPort(CodeContext/*!*/ context, object port) { - // conversion protocol: if it's a Fixnum, return it - // otherwise, convert to string & then convert the result to a Fixnum - if (port is int) { - return (int)port; - } - - MutableString str = Protocols.CastToString(context, port); - - // try special port name mappings - // TODO: are there more of these? - switch (str) { - case "ftp": - return 21; - case "http": - return 80; - } - - int result; - Protocols.IntegerAsFixnum(MutableStringOps.ToInteger(context, str), out result); - return result; - } - - - - #endregion - } - - [RubyClass("IPSocket", BuildConfig = "!SILVERLIGHT")] - public abstract class IPSocket : BasicSocket { - protected IPSocket(RubyExecutionContext/*!*/ context, Socket/*!*/ socket) - : base(context, socket) { - } - - [RubyMethod("getaddress", RubyMethodAttributes.PublicSingleton)] - public static string GetAddress(IPSocket/*!*/ self, MutableString hostName) { - return Dns.GetHostEntry(hostName).AddressList[0].ToString(); - } - - - [RubyMethod("addr")] - public static object GetAddress(IPSocket/*!*/ self) { - return GetAddressFromEndPoint(self.Socket.LocalEndPoint); - } - - [RubyMethod("peeraddr")] - public static object GetPeerAddress(IPSocket/*!*/ self) { - return GetAddressFromEndPoint(self.Socket.RemoteEndPoint); - } - - public static RubyArray/*!*/ GetAddressFromEndPoint(EndPoint endPoint) { - RubyArray result = ArrayOps.CreateArray(); - IPEndPoint ep = (IPEndPoint)endPoint; - - result.Add(new MutableString(AddressFamilyToString(ep.AddressFamily))); - result.Add(ep.Port); - result.Add(new MutableString(System.Net.Dns.GetHostEntry(ep.Address).HostName)); - result.Add(new MutableString(ep.Address.ToString())); - return result; - } - - internal static string AddressFamilyToString(AddressFamily af) { - // for the most part we can just use the upper-cased AddressFamily name - // of the enum value, but for some types we need to explicitly map the - // correct names - switch (af) { - case AddressFamily.InterNetwork: return "AF_INET"; - case AddressFamily.DataLink: return "AF_DLI"; - case AddressFamily.HyperChannel: return "AF_HYLINK"; - case AddressFamily.Banyan: return "AF_BAN"; - case AddressFamily.InterNetworkV6: return "AF_INET6"; - case AddressFamily.Ieee12844: return "AF_12844"; - case AddressFamily.NetworkDesigners: return "AF_NETDES"; - default: - string name = Enum.GetName(typeof(AddressFamily), af); - return (name != null) ? - "AF_" + name.ToUpper() : - "unknown:" + ((int)af).ToString(); - } - } - } - - [RubyClass("TCPSocket", BuildConfig = "!SILVERLIGHT")] - public class TCPSocket : IPSocket { - - public TCPSocket(RubyExecutionContext/*!*/ context, Socket/*!*/ socket) - : base(context, socket) { - } - - [RubyMethod("gethostbyname", RubyMethodAttributes.PublicSingleton)] - public static RubyArray/*!*/ GetHostByName(object self, MutableString hostName) { - RubyArray result = new RubyArray(); - IPHostEntry hostEntry = Dns.GetHostEntry(hostName); - result.Add(hostName); - - RubyArray aliases = new RubyArray(hostEntry.Aliases.Length); - foreach (string alias in hostEntry.Aliases) { - aliases.Add(new MutableString(alias)); - } - result.Add(aliases); - - result.Add((int)hostEntry.AddressList[0].AddressFamily); - result.Add(new MutableString(hostEntry.AddressList[0].ToString())); - return result; - } - - [RubyConstructor] - public static TCPSocket/*!*/ CreateTCPSocket(CodeContext/*!*/ context, object remoteHost, object remotePort, [Optional]object localHost, [Optional]object localPort) { - // TODO: handle localHost, localPort & any other args - - MutableString hostname = Protocols.CastToString(context, remoteHost); - int port = ConverToPort(context, remotePort); - - Socket socket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp); - socket.Connect(hostname, port); - - return new TCPSocket(RubyUtils.GetExecutionContext(context), socket); - } - - [RubyMethod("recvfrom")] - public static RubyArray/*!*/ ReceiveFrom(TCPSocket/*!*/ self, int len, [Optional] int flags) { - byte[] buffer = new byte[len]; - len = self.Socket.Receive(buffer, len, (SocketFlags)flags); - - RubyArray result = ArrayOps.CreateArray(); - result.Add(new MutableString(buffer, 0, len)); - result.Add(null); - return result; - } - } - - [RubyClass("TCPServer", BuildConfig = "!SILVERLIGHT")] - public class TCPServer : TCPSocket { - - public TCPServer(RubyExecutionContext/*!*/ context, Socket/*!*/ socket) - : base(context, socket) { - } - - [RubyConstructor] - public static TCPServer/*!*/ CreateTCPServer(CodeContext/*!*/ context, [Optional]object hostname, object port) { - IPAddress listeningInterface = null; - if (hostname == Missing.Value) { - listeningInterface = new IPAddress(0); - } else { - string hostnameStr = Protocols.CastToString(context, hostname).ToString(); - // try to parse it as an IP address first - if (!IPAddress.TryParse(hostnameStr, out listeningInterface)) { - - // look up the host IP from DNS - IPHostEntry hostEntry = Dns.GetHostEntry(hostnameStr); - foreach (IPAddress address in hostEntry.AddressList) { - if (address.AddressFamily == AddressFamily.InterNetwork) { - listeningInterface = address; - break; - } - } - if (listeningInterface == null) { - // TODO: do we need to support any other address family types? - // (presumably should support at least IPv6) - throw new NotImplementedException("TODO: non-inet addresses"); - } - } - Assert.NotNull(listeningInterface); - } - - Socket socket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp); - socket.Bind(new IPEndPoint(listeningInterface, ConverToPort(context, port))); - socket.Listen(10); - return new TCPServer(RubyUtils.GetExecutionContext(context), socket); - } - - [RubyMethod("accept")] - public static TCPSocket/*!*/ Accept(CodeContext/*!*/ context, TCPServer/*!*/ self) { - return new TCPSocket(RubyUtils.GetExecutionContext(context), self.Socket.Accept()); - } - } -} - -#endif =================================================================== add: $/Dev10/feature/vs_langs01/Merlin/Main/Languages/Ruby/Libraries.LCA_RESTRICTED/socket/BasicSocket.cs File: BasicSocket.cs =================================================================== --- [no source file] +++ Shelved Change: $/Dev10/feature/vs_langs01/Merlin/Main/Languages/Ruby/Libraries.LCA_RESTRICTED/socket/BasicSocket.cs;sockets-1 @@ -1,0 +1,532 @@ +?#if !SILVERLIGHT +using System; +using System.Collections.Generic; +using System.Net; +using System.Net.Sockets; +using Microsoft.Scripting.Runtime; +using Ruby.Builtins; +using Ruby.Runtime; + +namespace Ruby.StandardLibrary { + [RubyClass("BasicSocket", BuildConfig = "!SILVERLIGHT")] + public abstract class RubyBasicSocket : RubyIO { + private static bool _doNotReverseLookup = false; + public static bool DoNotReverseLookup { + get { return _doNotReverseLookup; } + set { + _doNotReverseLookup = value; } + } + + private Socket/*!*/ _socket; + + /// + /// Create a new RubyBasicSocket from a specified stream and mode + /// + protected RubyBasicSocket(CodeContext/*!*/ context, Socket/*!*/ socket) + : base(RubyUtils.GetExecutionContext(context), new SocketStream(socket), "r+") { + _socket = socket; + } + + protected internal Socket Socket { + get { return this._socket; } + } + + #region Public Singleton Methods + /// + /// Returns the value of the global reverse lookup flag. + /// + [RubyMethod("do_not_reverse_lookup", RubyMethodAttributes.PublicSingleton)] + public static bool GetDoNotReverseLookup(CodeContext/*!*/ context, RubyClass/*!*/ klass) { + // TODO : Are there threading issues? + return RubyBasicSocket.DoNotReverseLookup; + } + /// + /// Sets the value of the global reverse lookup flag. + /// If set to true, queries on remote addresses will return the numeric address but not the host name. + /// Defaults to false. + /// + [RubyMethod("do_not_reverse_lookup=", RubyMethodAttributes.PublicSingleton)] + public static void SetDoNotReverseLookup(CodeContext/*!*/ context, RubyClass/*!*/ klass, bool value) { + Protocols.CheckSafeLevel(context, 4); + // TODO : Are there threading issues? + RubyBasicSocket.DoNotReverseLookup = value; + } + /// + /// Wraps an already open file descriptor into a socket object. + /// + /// The corresponding socket + [RubyMethod("for_fd", RubyMethodAttributes.PublicSingleton)] + public static RubyBasicSocket/*!*/ ForFileDescriptor(CodeContext/*!*/ context, RubyClass/*!*/ klass, object fileDescriptor) { + return (RubyBasicSocket)RubyUtils.GetExecutionContext(context).GetDescriptor((int)Protocols.CastToInteger(context, fileDescriptor)); + } + #endregion + #region Public Instance Methods + [RubyMethod("close_read")] + public static void CloseRead(CodeContext/*!*/ context, RubyBasicSocket/*!*/ self) { + CheckSecurity(context, self, "can't close socket"); + // TODO: It would be nice to alter the SocketStream to be WriteOnly here + self.Socket.Shutdown(SocketShutdown.Receive); + } + [RubyMethod("close_write")] + public static void CloseWrite(CodeContext/*!*/ context, RubyBasicSocket/*!*/ self) { + CheckSecurity(context, self, "can't close socket"); + // TODO: It would be nice to alter the SocketStream to be ReadOnly here + self.Socket.Shutdown(SocketShutdown.Send); + } + [RubyMethod("shutdown")] + public static int Shutdown(CodeContext/*!*/ context, RubyBasicSocket/*!*/ self) { + return Shutdown(context, self, 2); + } + [RubyMethod("shutdown")] + public static int Shutdown(CodeContext/*!*/ context, RubyBasicSocket/*!*/ self, object/*Numeric*/ how) { + int iHow = 2; + if (how != null) { + iHow = Protocols.CastToFixnum(context, how); + } + return Shutdown(context, self, iHow); + } + [RubyMethod("shutdown")] + public static int Shutdown(CodeContext/*!*/ context, RubyBasicSocket/*!*/ self, int how) { + CheckSecurity(context, self, "can't shutdown socket"); + if (how < 0 || 2 < how) { + throw RubyExceptions.CreateArgumentError("`how' should be either 0, 1, 2"); + } + self.Socket.Shutdown((SocketShutdown)how); + return 0; + } + [RubyMethod("setsockopt")] + public static void SetSocketOption(CodeContext/*!*/ context, RubyBasicSocket/*!*/ self, object/*Numeric*/ level, object/*Numeric*/ optname, int value) { + Protocols.CheckSafeLevel(context, 2, "setsockopt"); + int iLevel = Protocols.CastToFixnum(context, level); + int iOptname = Protocols.CastToFixnum(context, optname); + self.Socket.SetSocketOption((SocketOptionLevel)iLevel, (SocketOptionName)iOptname, value); + } + [RubyMethod("setsockopt")] + public static void SetSocketOption(CodeContext/*!*/ context, RubyBasicSocket/*!*/ self, object/*Numeric*/ level, object/*Numeric*/ optname, bool value) { + Protocols.CheckSafeLevel(context, 2, "setsockopt"); + int iLevel = Protocols.CastToFixnum(context, level); + int iOptname = Protocols.CastToFixnum(context, optname); + self.Socket.SetSocketOption((SocketOptionLevel)iLevel, (SocketOptionName)iOptname, value); + } + [RubyMethod("setsockopt")] + public static void SetSocketOption(CodeContext/*!*/ context, RubyBasicSocket/*!*/ self, object/*Numeric*/ level, object/*Numeric*/ optname, object value) { + Protocols.CheckSafeLevel(context, 2, "setsockopt"); + MutableString strValue = Protocols.CastToString(context, value); + int iLevel = Protocols.CastToFixnum(context, Protocols.ConvertToInteger(context, level)); + int iOptname = Protocols.CastToFixnum(context, Protocols.ConvertToInteger(context, optname)); + self.Socket.SetSocketOption((SocketOptionLevel)iLevel, (SocketOptionName)iOptname, strValue.ConvertToBytes()); + } + [RubyMethod("getsockopt")] + public static MutableString GetSocketOption(CodeContext/*!*/ context, RubyBasicSocket/*!*/ self, object/*Numeric*/ level, object/*Numeric*/ optname) { + Protocols.CheckSafeLevel(context, 2, "getsockopt"); + int iLevel = Protocols.CastToFixnum(context, Protocols.ConvertToInteger(context, level)); + int iOptname = Protocols.CastToFixnum(context, Protocols.ConvertToInteger(context, optname)); + byte[] value = self.Socket.GetSocketOption((SocketOptionLevel)iLevel, (SocketOptionName)iOptname, 4); + return MutableString.CreateBinary(value, value.Length); + } + [RubyMethod("getsockname")] + public static MutableString GetSocketName(RubyBasicSocket/*!*/ self) { + SocketAddress addr = self.Socket.LocalEndPoint.Serialize(); + byte[] bytes = new byte[addr.Size]; + for(int i=0; i= 4 && ec.IsObjectTainted(self)) { + throw RubyExceptions.CreateSecurityError("Insecure: " + message); + } + } + + internal static RubyArray/*!*/ GetAddressArray(EndPoint endPoint) { + RubyArray result = ArrayOps.CreateArray(4); + + IPEndPoint ep = (IPEndPoint)endPoint; + + result.Add(MutableString.Create(AddressFamilyToString(ep.AddressFamily))); + result.Add(ep.Port); + if (DoNotReverseLookup) { + result.Add(MutableString.Create(ep.Address.ToString())); + } else { + // TODO: MRI returns localhost rather than the local machine name here + result.Add(MutableString.Create(System.Net.Dns.GetHostEntry(ep.Address).HostName)); + } + result.Add(MutableString.Create(ep.Address.ToString())); + return result; + } + + private static string AddressFamilyToString(AddressFamily af) { + // for the most part we can just use the upper-cased AddressFamily name + // of the enum value, but for some types we need to explicitly map the + // correct names + switch (af) { + case AddressFamily.InterNetwork: return "AF_INET"; + case AddressFamily.DataLink: return "AF_DLI"; + case AddressFamily.HyperChannel: return "AF_HYLINK"; + case AddressFamily.Banyan: return "AF_BAN"; + case AddressFamily.InterNetworkV6: return "AF_INET6"; + case AddressFamily.Ieee12844: return "AF_12844"; + case AddressFamily.NetworkDesigners: return "AF_NETDES"; + default: + string name = Enum.GetName(typeof(AddressFamily), af); + return (name != null) ? + "AF_" + name.ToUpper() : + "unknown:" + ((int)af).ToString(); + } + } + + internal static SocketFlags ConvertToSocketFlag(CodeContext/*!*/ context, object flags) { + if (flags == null) { + return SocketFlags.None; + } + return (SocketFlags)Protocols.CastToFixnum(context, flags); + } + + internal static AddressFamily ConvertToAddressFamily(CodeContext/*!*/ context, object family) { + // Default is AF_INET + if (family == null) { + return AddressFamily.InterNetwork; + } + // If it is a Fixnum then assume it is just the constant value + if (family is int) { + return (AddressFamily)(int)family; + } + // Convert to a string (using to_str) and then look up the value + MutableString strFamily = Protocols.CastToString(context, family); + foreach (AddressFamilyName name in FamilyNames) { + if (name.Name == strFamily) { + return name.Family; + } + } + // Convert to a Fixnum (using to_i) and hope it is a valid AddressFamily constant + return (AddressFamily)Protocols.CastToFixnum(context, strFamily); + } + + + internal static MutableString ConvertToHostString(CodeContext/*!*/ context, object hostname) { + if (hostname == null) { + return null; + } + if (hostname is MutableString) { + MutableString strHostname = (MutableString)hostname; + // Special cases + if (strHostname.IsEmpty) { + strHostname = MutableString.Create("0.0.0.0"); + } else if (strHostname.ConvertToString() == "") { + strHostname = MutableString.Create("255.255.255.255"); + } + return strHostname; + } + int iHostname; + if (Protocols.IntegerAsFixnum(hostname, out iHostname)) { + // Ruby uses Little Endian whereas .NET uses Big Endian IP values + byte[] bytes = new byte[4]; + for (int i = 3; i >= 0; --i) { + bytes[i] = (byte)(iHostname & 0xff); + iHostname >>= 8; + } + return MutableString.Create(new System.Net.IPAddress(bytes).ToString()); + } + return Protocols.CastToString(context, hostname); + } + + internal static int ConvertToPortNum(CodeContext/*!*/ context, object port) { + // conversion protocol: if it's a Fixnum, return it + // otherwise, convert to string & then convert the result to a Fixnum + if (port is int) { + return (int)port; + } + + MutableString str = Protocols.CastToString(context, port); + + foreach (PortName name in PortNames) { + if (name.Name == str) { + return name.Port; + } + } + + int result; + Protocols.IntegerAsFixnum(Protocols.ConvertToInteger(context, str), out result); + return result; + } + + class AddressFamilyName { + MutableString _name; + AddressFamily _family; + public MutableString Name { get { return _name; } } + public AddressFamily Family { get { return _family; } } + public AddressFamilyName(string name, AddressFamily family) { + _name = MutableString.Create(name); + _family = family; + } + } + + static List FamilyNames = new List(new AddressFamilyName[] { + new AddressFamilyName("AF_INET", AddressFamily.InterNetwork), + new AddressFamilyName("AF_UNIX", AddressFamily.Unix), + //new AddressFamilyName("AF_AX25", AddressFamily.Ax), + new AddressFamilyName("AF_IPX", AddressFamily.Ipx), + new AddressFamilyName("AF_APPLETALK", AddressFamily.AppleTalk), + new AddressFamilyName("AF_UNSPEC", AddressFamily.Unspecified), + new AddressFamilyName("AF_INET6", AddressFamily.InterNetworkV6), + //new AddressFamilyName("AF_LOCAL", AddressFamily.Local), + new AddressFamilyName("AF_IMPLINK", AddressFamily.ImpLink), + new AddressFamilyName("AF_PUP", AddressFamily.Pup), + new AddressFamilyName("AF_CHAOS", AddressFamily.Chaos), + new AddressFamilyName("AF_NS", AddressFamily.NS), + new AddressFamilyName("AF_ISO", AddressFamily.Iso), + new AddressFamilyName("AF_OSI", AddressFamily.Osi), + new AddressFamilyName("AF_ECMA", AddressFamily.Ecma), + new AddressFamilyName("AF_DATAKIT", AddressFamily.DataKit), + new AddressFamilyName("AF_CCITT", AddressFamily.Ccitt), + new AddressFamilyName("AF_SNA", AddressFamily.Sna), + new AddressFamilyName("AF_DEC", AddressFamily.DecNet), + new AddressFamilyName("AF_DLI", AddressFamily.DataLink), + new AddressFamilyName("AF_LAT", AddressFamily.Lat), + new AddressFamilyName("AF_HYLINK", AddressFamily.HyperChannel), + //new AddressFamilyName("AF_ROUTE", AddressFamily.Route), + //new AddressFamilyName("AF_LINK", AddressFamily.Link), + //new AddressFamilyName("AF_COIP", AddressFamily.Coip), + //new AddressFamilyName("AF_CNT", AddressFamily.Cnt), + //new AddressFamilyName("AF_SIP", AddressFamily.Sip), + //new AddressFamilyName("AF_NDRV", AddressFamily.Nrdv), + //new AddressFamilyName("AF_ISDN", AddressFamily.Isdn), + //new AddressFamilyName("AF_NATM", AddressFamily.NATM), + //new AddressFamilyName("AF_SYSTEM", AddressFamily.System), + new AddressFamilyName("AF_NETBIOS", AddressFamily.NetBios), + //new AddressFamilyName("AF_PPP", AddressFamily.Ppp), + new AddressFamilyName("AF_ATM", AddressFamily.Atm), + //new AddressFamilyName("AF_NETGRAPH", AddressFamily.Netgraph), + new AddressFamilyName("AF_MAX", AddressFamily.Max), + //new AddressFamilyName("AF_E164", AddressFamily.E164), + }); + + class PortName { + int _port; + public int Port { get { return _port; } } + MutableString _protocol; + public MutableString Protocol { get { return _protocol; } } + MutableString _name; + public MutableString Name { get { return _name; } } + public PortName(int port, string protocol, string name) { + _port = port; + _protocol = MutableString.Create(protocol); + _name = MutableString.Create(name); + } + } + + static List PortNames = new List(new PortName[] { + new PortName(7, "tcp", "echo"), + new PortName(7, "udp", "echo"), + new PortName(9, "tcp", "discard"), + new PortName(9, "udp", "discard"), + new PortName(11, "tcp", "systat"), + new PortName(11, "udp", "systat"), + new PortName(13, "tcp", "daytime"), + new PortName(13, "udp", "daytime"), + new PortName(15, "tcp", "netstat"), + new PortName(17, "tcp", "qotd"), + new PortName(17, "udp", "qotd"), + new PortName(19, "tcp", "chargen"), + new PortName(19, "udp", "chargen"), + new PortName(20, "tcp", "ftp-data"), + new PortName(21, "tcp", "ftp"), + new PortName(23, "tcp", "telnet"), + new PortName(25, "tcp", "smtp"), + new PortName(37, "tcp", "time"), + new PortName(37, "udp", "time"), + new PortName(39, "udp", "rlp"), + new PortName(42, "tcp", "name"), + new PortName(42, "udp", "name"), + new PortName(43, "tcp", "whois"), + new PortName(53, "tcp", "domain"), + new PortName(53, "udp", "domain"), + new PortName(53, "tcp", "nameserver"), + new PortName(53, "udp", "nameserver"), + new PortName(57, "tcp", "mtp"), + new PortName(67, "udp", "bootp"), + new PortName(69, "udp", "tftp"), + new PortName(77, "tcp", "rje"), + new PortName(79, "tcp", "finger"), + new PortName(87, "tcp", "link"), + new PortName(95, "tcp", "supdup"), + new PortName(101, "tcp", "hostnames"), + new PortName(102, "tcp", "iso-tsap"), + new PortName(103, "tcp", "dictionary"), + new PortName(103, "tcp", "x400"), + new PortName(104, "tcp", "x400-snd"), + new PortName(105, "tcp", "csnet-ns"), + new PortName(109, "tcp", "pop"), + new PortName(109, "tcp", "pop2"), + new PortName(110, "tcp", "pop3"), + new PortName(111, "tcp", "portmap"), + new PortName(111, "udp", "portmap"), + new PortName(111, "tcp", "sunrpc"), + new PortName(111, "udp", "sunrpc"), + new PortName(113, "tcp", "auth"), + new PortName(115, "tcp", "sftp"), + new PortName(117, "tcp", "path"), + new PortName(117, "tcp", "uucp-path"), + new PortName(119, "tcp", "nntp"), + new PortName(123, "udp", "ntp"), + new PortName(137, "udp", "nbname"), + new PortName(138, "udp", "nbdatagram"), + new PortName(139, "tcp", "nbsession"), + new PortName(144, "tcp", "NeWS"), + new PortName(153, "tcp", "sgmp"), + new PortName(158, "tcp", "tcprepo"), + new PortName(161, "tcp", "snmp"), + new PortName(162, "tcp", "snmp-trap"), + new PortName(170, "tcp", "print-srv"), + new PortName(175, "tcp", "vmnet"), + new PortName(315, "udp", "load"), + new PortName(400, "tcp", "vmnet0"), + new PortName(500, "udp", "sytek"), + new PortName(512, "udp", "biff"), + new PortName(512, "tcp", "exec"), + new PortName(513, "tcp", "login"), + new PortName(513, "udp", "who"), + new PortName(514, "tcp", "shell"), + new PortName(514, "udp", "syslog"), + new PortName(515, "tcp", "printer"), + new PortName(517, "udp", "talk"), + new PortName(518, "udp", "ntalk"), + new PortName(520, "tcp", "efs"), + new PortName(520, "udp", "route"), + new PortName(525, "udp", "timed"), + new PortName(526, "tcp", "tempo"), + new PortName(530, "tcp", "courier"), + new PortName(531, "tcp", "conference"), + new PortName(531, "udp", "rvd-control"), + new PortName(532, "tcp", "netnews"), + new PortName(533, "udp", "netwall"), + new PortName(540, "tcp", "uucp"), + new PortName(543, "tcp", "klogin"), + new PortName(544, "tcp", "kshell"), + new PortName(550, "udp", "new-rwho"), + new PortName(556, "tcp", "remotefs"), + new PortName(560, "udp", "rmonitor"), + new PortName(561, "udp", "monitor"), + new PortName(600, "tcp", "garcon"), + new PortName(601, "tcp", "maitrd"), + new PortName(602, "tcp", "busboy"), + new PortName(700, "udp", "acctmaster"), + new PortName(701, "udp", "acctslave"), + new PortName(702, "udp", "acct"), + new PortName(703, "udp", "acctlogin"), + new PortName(704, "udp", "acctprinter"), + new PortName(704, "udp", "elcsd"), + new PortName(705, "udp", "acctinfo"), + new PortName(706, "udp", "acctslave2"), + new PortName(707, "udp", "acctdisk"), + new PortName(750, "tcp", "kerberos"), + new PortName(750, "udp", "kerberos"), + new PortName(751, "tcp", "kerberos_master"), + new PortName(751, "udp", "kerberos_master"), + new PortName(752, "udp", "passwd_server"), + new PortName(753, "udp", "userreg_server"), + new PortName(754, "tcp", "krb_prop"), + new PortName(888, "tcp", "erlogin"), + new PortName(1109, "tcp", "kpop"), + new PortName(1167, "udp", "phone"), + new PortName(1524, "tcp", "ingreslock"), + new PortName(1666, "udp", "maze"), + new PortName(2049, "udp", "nfs"), + new PortName(2053, "tcp", "knetd"), + new PortName(2105, "tcp", "eklogin"), + new PortName(5555, "tcp", "rmt"), + new PortName(5556, "tcp", "mtb"), + new PortName(9535, "tcp", "man"), + new PortName(9536, "tcp", "w"), + new PortName(9537, "tcp", "mantst"), + new PortName(10000, "tcp", "bnews"), + new PortName(10000, "udp", "rscs0"), + new PortName(10001, "tcp", "queue"), + new PortName(10001, "udp", "rscs1"), + new PortName(10002, "tcp", "poker"), + new PortName(10002, "udp", "rscs2"), + new PortName(10003, "tcp", "gateway"), + new PortName(10003, "udp", "rscs3"), + new PortName(10004, "tcp", "remp"), + new PortName(10004, "udp", "rscs4"), + new PortName(10005, "udp", "rscs5"), + new PortName(10006, "udp", "rscs6"), + new PortName(10007, "udp", "rscs7"), + new PortName(10008, "udp", "rscs8"), + new PortName(10009, "udp", "rscs9"), + new PortName(10010, "udp", "rscsa"), + new PortName(10011, "udp", "rscsb"), + new PortName(10012, "tcp", "qmaster"), + new PortName(10012, "udp", "qmaster") + }); + #endregion + } +} +#endif \ No newline at end of file =================================================================== add: $/Dev10/feature/vs_langs01/Merlin/Main/Languages/Ruby/Libraries.LCA_RESTRICTED/socket/IPSocket.cs File: IPSocket.cs =================================================================== --- [no source file] +++ Shelved Change: $/Dev10/feature/vs_langs01/Merlin/Main/Languages/Ruby/Libraries.LCA_RESTRICTED/socket/IPSocket.cs;sockets-1 @@ -1,0 +1,67 @@ +?#if !SILVERLIGHT + +using System.Net; +using System.Net.Sockets; +using Microsoft.Scripting.Runtime; +using Ruby.Builtins; +using Ruby.Runtime; + +namespace Ruby.StandardLibrary { + [RubyClass("IPSocket", BuildConfig = "!SILVERLIGHT")] + public abstract class IPSocket : RubyBasicSocket { + + public IPSocket(CodeContext/*!*/ context, Socket/*!*/ socket) + : base(context, socket) { + } + + #region Public Singleton Methods + [RubyMethod("getaddress", RubyMethodAttributes.PublicSingleton)] + public static MutableString/*!*/ GetAddress(CodeContext/*!*/ context, RubyClass/*!*/ self, object hostname) { + return GetAddressInternal(context, hostname); + } + internal static MutableString/*!*/ GetAddressInternal(CodeContext/*!*/ context, object hostname) { + // Ruby raises a SocketError rather than the NullReferenceException thrown by .NET + if (hostname == null) { + throw new SocketException((int)SocketError.HostNotFound); + } + MutableString strHostname = ConvertToHostString(context, hostname); + // If it is an IP address already then just pass it back + IPAddress address; + if ( IPAddress.TryParse(strHostname.ConvertToString(), out address) ) { + return strHostname; + } + // Lookup the host IP address via DNS + return MutableString.Create(Dns.GetHostAddresses(strHostname.ConvertToString())[0].ToString()); + } + #endregion + + + #region Public Instance Methods + [RubyMethod("addr")] + public static RubyArray/*!*/ GetLocalAddress(IPSocket/*!*/ self) { + return GetAddressArray(self.Socket.LocalEndPoint); + } + + [RubyMethod("peeraddr")] + public static object/*!*/ GetPeerAddress(IPSocket/*!*/ self) { + return GetAddressArray(self.Socket.RemoteEndPoint); + } + + [RubyMethod("recvfrom")] + public static RubyArray/*!*/ ReceiveFrom(CodeContext/*!*/ context, IPSocket/*!*/ self, int length) { + return ReceiveFrom(context, self, length, null); + } + [RubyMethod("recvfrom")] + public static RubyArray/*!*/ ReceiveFrom(CodeContext/*!*/ context, IPSocket/*!*/ self, int length, object/*Numeric*/ flags) { + SocketFlags sFlags = ConvertToSocketFlag(context, flags); + byte[] buffer = new byte[length]; + EndPoint fromEP = new IPEndPoint(IPAddress.Any, 0); + int received = self.Socket.ReceiveFrom(buffer, sFlags, ref fromEP); + MutableString str = MutableString.CreateBinary(buffer, received); + RubyUtils.GetExecutionContext(context).TaintObject(str); + return RubyOps.MakeArray2(str, GetAddressArray(fromEP)); + } + #endregion + } +} +#endif \ No newline at end of file =================================================================== add: $/Dev10/feature/vs_langs01/Merlin/Main/Languages/Ruby/Libraries.LCA_RESTRICTED/socket/Socket.cs File: Socket.cs =================================================================== --- [no source file] +++ Shelved Change: $/Dev10/feature/vs_langs01/Merlin/Main/Languages/Ruby/Libraries.LCA_RESTRICTED/socket/Socket.cs;sockets-1 @@ -1,0 +1,351 @@ +?#if !SILVERLIGHT + +using System; +using System.Net.Sockets; +using Microsoft.Scripting; +using Microsoft.Scripting.Runtime; +using Ruby.Builtins; +using Ruby.Runtime; + +namespace Ruby.StandardLibrary { + [RubyClass("Socket", BuildConfig = "!SILVERLIGHT")] + public class RubySocket : RubyBasicSocket { + + public RubySocket(CodeContext/*!*/ context, MutableString/*!*/ domain, MutableString/*!*/ socketType, MutableString/*!*/ protocolType) + : base(context, CreateSocket(context, domain, socketType, protocolType)) { + } + + private static Socket/*!*/ CreateSocket(CodeContext/*!*/ context, MutableString/*!*/ domain, MutableString/*!*/ type, object/*Numeric*/ protocol) { + RubyExecutionContext ec = RubyUtils.GetExecutionContext(context); + RubyClass rubySocketClass = ec.GetClass(typeof(Ruby.StandardLibrary.RubySocket)); + + AddressFamily addressFamily = (AddressFamily)RubyUtils.GetConstant(context, rubySocketClass, SymbolTable.StringToId(domain.ConvertToString()), true); + ProtocolType protocolType = (ProtocolType)(Protocols.CastToFixnum(context, protocol)); + SocketType socketType = (SocketType)RubyUtils.GetConstant(context, rubySocketClass, SymbolTable.StringToId(domain.ConvertToString()), true); + return new Socket(addressFamily, socketType, protocolType); + } + + #region Public Singleton Methods + [RubyMethod("getaddrinfo", RubyMethodAttributes.PublicSingleton)] + public static RubyArray GetAddressInfo(CodeContext/*!*/ context, RubyClass/*!*/ klass, object hostname, object port, object family, object socktype, object protocol, object flags) { + MutableString strHostname = ConvertToHostString(context, hostname); + int iPort = ConvertToPortNum(context, port); + // TODO: By the way, this method needs to look at BasicSocket.DoNotReverseLookup + throw new NotImplementedException(); + } + //[RubyMethod("gethostbyaddr", RubyMethodAttributes.PublicSingleton)] + //[RubyMethod("gethostbyname", RubyMethodAttributes.PublicSingleton)] + //[RubyMethod("gethostname", RubyMethodAttributes.PublicSingleton)] + //[RubyMethod("getnameinfo", RubyMethodAttributes.PublicSingleton)] + //[RubyMethod("getservbyname", RubyMethodAttributes.PublicSingleton)] + //[RubyMethod("pack_sockaddr_in", RubyMethodAttributes.PublicSingleton)] + //[RubyMethod("pair", RubyMethodAttributes.PublicSingleton)] + //[RubyMethod("sockaddr_in", RubyMethodAttributes.PublicSingleton)] + //[RubyMethod("socketpair", RubyMethodAttributes.PublicSingleton)] + //[RubyMethod("unpack_sockaddr_in", RubyMethodAttributes.PublicSingleton)] + //public static RubyArray UnpackSockAddressIn(MutableString/*!*/ address) { + //} + #endregion + + #region Public Instance Methods + //[RubyMethod("accept")] + //[RubyMethod("accept_nonblock")] + //[RubyMethod("bind")] + //[RubyMethod("connect")] + //[RubyMethod("connect_nonblock")] + //[RubyMethod("listen")] + //[RubyMethod("recvfrom")] - uses DoNotReverseLookup + //[RubyMethod("recvfrom_nonblock")] - uses DoNotReverseLookup + //[RubyMethod("sysaccept")] + //public static RubyArray SysAccept() { + //} + #endregion + + #region Constants + + #region Address Family + + [RubyConstant] + public const int AF_APPLETALK = (int)AddressFamily.AppleTalk; + [RubyConstant] + public const int AF_ATM = (int)AddressFamily.Atm; + [RubyConstant] + public const int AF_CCITT = (int)AddressFamily.Ccitt; + [RubyConstant] + public const int AF_CHAOS = (int)AddressFamily.Chaos; + [RubyConstant] + public const int AF_DATAKIT = (int)AddressFamily.DataKit; + [RubyConstant] + public const int AF_DLI = (int)AddressFamily.DataLink; + [RubyConstant] + public const int AF_ECMA = (int)AddressFamily.Ecma; + [RubyConstant] + public const int AF_HYLINK = (int)AddressFamily.HyperChannel; + [RubyConstant] + public const int AF_IMPLINK = (int)AddressFamily.ImpLink; + [RubyConstant] + public const int AF_IPX = (int)AddressFamily.Ipx; + [RubyConstant] + public const int AF_ISO = (int)AddressFamily.Iso; + [RubyConstant] + public const int AF_LAT = (int)AddressFamily.Lat; + [RubyConstant] + public const int AF_MAX = (int)AddressFamily.Max; + [RubyConstant] + public const int AF_NETBIOS = (int)AddressFamily.NetBios; + [RubyConstant] + public const int AF_NS = (int)AddressFamily.NS; + [RubyConstant] + public const int AF_OSI = (int)AddressFamily.Osi; + [RubyConstant] + public const int AF_PUP = (int)AddressFamily.Pup; + [RubyConstant] + public const int AF_SNA = (int)AddressFamily.Sna; + [RubyConstant] + public const int AF_UNIX = (int)AddressFamily.Unix; + [RubyConstant] + public const int AF_UNSPEC = (int)AddressFamily.Unspecified; + [RubyConstant] + public const int AF_INET = (int)AddressFamily.InterNetwork; + #endregion + + #region Flag Options for GetAddressInfo + [RubyConstant] + public const int AI_PASSIVE = 1; + [RubyConstant] + public const int AI_CANONNAME = 2; + [RubyConstant] + public const int AI_NUMERICHOST = 4; + [RubyConstant] + public const int AI_MASK = (AI_PASSIVE | AI_CANONNAME | AI_NUMERICHOST); + + [RubyConstant] + public const int AI_ALL = 0x00000100; + [RubyConstant] + public const int AI_V4MAPPED_CFG = 0x00000200; + [RubyConstant] + public const int AI_ADDRCONFIG = 0x00000400; + [RubyConstant] + public const int AI_V4MAPPED = 0x00000800; + [RubyConstant] + public const int AI_DEFAULT = (AI_V4MAPPED_CFG | AI_ADDRCONFIG); + #endregion + + #region Error Return Codes from GetAddressInfo + [RubyConstant] + public const int EAI_ADDRFAMILY = 1; + [RubyConstant] + public const int EAI_AGAIN = 2; + [RubyConstant] + public const int EAI_BADFLAGS = 3; + [RubyConstant] + public const int EAI_BADHINTS = 12; + [RubyConstant] + public const int EAI_FAIL = 4; + [RubyConstant] + public const int EAI_FAMILY = 5; + [RubyConstant] + public const int EAI_MAX = 14; + [RubyConstant] + public const int EAI_MEMORY = 6; + [RubyConstant] + public const int EAI_NODATA = 7; + [RubyConstant] + public const int EAI_NONAME = 8; + [RubyConstant] + public const int EAI_PROTOCOL = 13; + [RubyConstant] + public const int EAI_SERVICE = 9; + [RubyConstant] + public const int EAI_SOCKTYPE = 10; + [RubyConstant] + public const int EAI_SYSTEM = 11; + #endregion + + #region + [RubyConstant] + public const uint INADDR_ALLHOSTS_GROUP = 0xe0000001; + [RubyConstant] + public const int INADDR_ANY = 0; + [RubyConstant] + public const uint INADDR_BROADCAST = 0xffffffff; + [RubyConstant] + public const int INADDR_LOOPBACK = 0x7F000001; + [RubyConstant] + public const uint INADDR_MAX_LOCAL_GROUP = 0xe00000ff; + [RubyConstant] + public const uint INADDR_NONE = 0xffffffff; + [RubyConstant] + public const uint INADDR_UNSPEC_GROUP = 0xe0000000; + #endregion + + #region IP Protocol Constants + [RubyConstant] + public const int IPPORT_RESERVED = 1024; + [RubyConstant] + public const int IPPORT_USERRESERVED = 5000; + [RubyConstant] + public const int IPPROTO_GGP = 3; + [RubyConstant] + public const int IPPROTO_ICMP = 1; + [RubyConstant] + public const int IPPROTO_IDP = 22; + [RubyConstant] + public const int IPPROTO_IGMP = 2; + [RubyConstant] + public const int IPPROTO_IP = 0; + [RubyConstant] + public const int IPPROTO_MAX = 256; + [RubyConstant] + public const int IPPROTO_ND = 77; + [RubyConstant] + public const int IPPROTO_PUP = 12; + [RubyConstant] + public const int IPPROTO_RAW = 255; + [RubyConstant] + public const int IPPROTO_TCP = 6; + [RubyConstant] + public const int IPPROTO_UDP = 17; + #endregion + + #region Message Options + [RubyConstant] + public const int MSG_DONTROUTE = 4; + [RubyConstant] + public const int MSG_OOB = 1; + [RubyConstant] + public const int MSG_PEEK = 2; + [RubyConstant] + #endregion + + #region Name Info + public const int NI_DGRAM = 16; + [RubyConstant] + public const int NI_MAXHOST = 1025; + [RubyConstant] + public const int NI_MAXSERV = 32; + [RubyConstant] + public const int NI_NAMEREQD = 4; + [RubyConstant] + public const int NI_NOFQDN = 1; + [RubyConstant] + public const int NI_NUMERICHOST = 2; + [RubyConstant] + public const int NI_NUMERICSERV = 8; + #endregion + + #region Protocol Family + [RubyConstant] + public const int PF_APPLETALK = (int)ProtocolFamily.AppleTalk; + [RubyConstant] + public const int PF_ATM = (int)ProtocolFamily.Atm; + [RubyConstant] + public const int PF_CCITT = (int)ProtocolFamily.Ccitt; + [RubyConstant] + public const int PF_CHAOS = (int)ProtocolFamily.Chaos; + [RubyConstant] + public const int PF_DATAKIT = (int)ProtocolFamily.DataKit; + [RubyConstant] + public const int PF_DLI = (int)ProtocolFamily.DataLink; + [RubyConstant] + public const int PF_ECMA = (int)ProtocolFamily.Ecma; + [RubyConstant] + public const int PF_HYLINK = (int)ProtocolFamily.HyperChannel; + [RubyConstant] + public const int PF_IMPLINK = (int)ProtocolFamily.ImpLink; + [RubyConstant] + public const int PF_IPX = (int)ProtocolFamily.Ipx; + [RubyConstant] + public const int PF_ISO = (int)ProtocolFamily.Iso; + [RubyConstant] + public const int PF_LAT = (int)ProtocolFamily.Lat; + [RubyConstant] + public const int PF_MAX = (int)ProtocolFamily.Max; + [RubyConstant] + public const int PF_NS = (int)ProtocolFamily.NS; + [RubyConstant] + public const int PF_OSI = (int)ProtocolFamily.Osi; + [RubyConstant] + public const int PF_PUP = (int)ProtocolFamily.Pup; + [RubyConstant] + public const int PF_SNA = (int)ProtocolFamily.Sna; + [RubyConstant] + public const int PF_UNIX = (int)ProtocolFamily.Unix; + [RubyConstant] + public const int PF_UNSPEC = (int)ProtocolFamily.Unspecified; + [RubyConstant] + public const int PF_INET = (int)ProtocolFamily.InterNetwork; + #endregion + + #region Socket Shutdown + [RubyConstant] + public const int SHUT_RD = (int)SocketShutdown.Receive; + [RubyConstant] + public const int SHUT_RDWR = (int)SocketShutdown.Both; + [RubyConstant] + public const int SHUT_WR = (int)SocketShutdown.Send; + #endregion + + #region Socket Type + + [RubyConstant] + public const int SOCK_DGRAM = (int)SocketType.Dgram; + [RubyConstant] + public const int SOCK_RAW = (int)SocketType.Raw; + [RubyConstant] + public const int SOCK_RDM = (int)SocketType.Rdm; + [RubyConstant] + public const int SOCK_SEQPACKET = (int)SocketType.Seqpacket; + [RubyConstant] + public const int SOCK_STREAM = (int)SocketType.Stream; + #endregion + + [RubyConstant] + public const int SOL_SOCKET = 65535; + + #region Socket Option + + [RubyConstant] + public const int SO_ACCEPTCONN = (int)SocketOptionName.AcceptConnection; + [RubyConstant] + public const int SO_BROADCAST = (int)SocketOptionName.Broadcast; + [RubyConstant] + public const int SO_DEBUG = (int)SocketOptionName.Debug; + [RubyConstant] + public const int SO_DONTROUTE = (int)SocketOptionName.DontRoute; + [RubyConstant] + public const int SO_ERROR = (int)SocketOptionName.Error; + [RubyConstant] + public const int SO_KEEPALIVE = (int)SocketOptionName.KeepAlive; + [RubyConstant] + public const int SO_OOBINLINE = (int)SocketOptionName.OutOfBandInline; + [RubyConstant] + public const int SO_RCVLOWAT = (int)SocketOptionName.ReceiveLowWater; + [RubyConstant] + public const int SO_REUSEADDR = (int)SocketOptionName.ReuseAddress; + [RubyConstant] + public const int SO_SNDLOWAT = (int)SocketOptionName.SendLowWater; + [RubyConstant] + public const int SO_SNDTIMEO = (int)SocketOptionName.SendTimeout; + [RubyConstant] + public const int SO_TYPE = (int)SocketOptionName.Type; + [RubyConstant] + public const int SO_USELOOPBACK = (int)SocketOptionName.UseLoopback; + + [RubyConstant] + public const int SO_LINGER = (int)SocketOptionName.Linger; + [RubyConstant] + public const int SO_RCVBUF = (int)SocketOptionName.ReceiveBuffer; + [RubyConstant] + public const int SO_RCVTIMEO = (int)SocketOptionName.ReceiveTimeout; + [RubyConstant] + public const int SO_SNDBUF = (int)SocketOptionName.SendBuffer; + + #endregion + + [RubyConstant] + public const int TCP_NODELAY = 1; + #endregion + } +} +#endif \ No newline at end of file =================================================================== add: $/Dev10/feature/vs_langs01/Merlin/Main/Languages/Ruby/Libraries.LCA_RESTRICTED/socket/SocketError.cs File: SocketError.cs =================================================================== --- [no source file] +++ Shelved Change: $/Dev10/feature/vs_langs01/Merlin/Main/Languages/Ruby/Libraries.LCA_RESTRICTED/socket/SocketError.cs;sockets-1 @@ -1,0 +1,21 @@ +?#if !SILVERLIGHT + +using System; +using System.Net.Sockets; +using System.Runtime.InteropServices; +using Ruby.Builtins; + +namespace Ruby.StandardLibrary { + [RubyClass("SocketError", BuildConfig = "!SILVERLIGHT", Extends = typeof(SocketException), Inherits = typeof(SystemException))] + [HideMethod("message")] // SocketException overrides Message so we have to hide it here + public static class SocketErrorOps { + [RubyConstructor] + public static SocketException/*!*/ Factory([Optional]MutableString message) { + SocketException x = new SocketException(0); + ExceptionOps.InitializeException(x, MutableString.Create(ExceptionOps.MakeMessage(null, "SocketError"))); + return x; + } + } +} + +#endif \ No newline at end of file =================================================================== add: $/Dev10/feature/vs_langs01/Merlin/Main/Languages/Ruby/Libraries.LCA_RESTRICTED/socket/SocketStream.cs File: SocketStream.cs =================================================================== --- [no source file] +++ Shelved Change: $/Dev10/feature/vs_langs01/Merlin/Main/Languages/Ruby/Libraries.LCA_RESTRICTED/socket/SocketStream.cs;sockets-1 @@ -1,0 +1,110 @@ +?#if !SILVERLIGHT + +using System; +using System.Collections.Generic; +using System.Net.Sockets; + +namespace Ruby.StandardLibrary { + internal class SocketStream : System.IO.Stream { + public SocketStream(/*!*/Socket s) { + _socket = s; + } + + private long _pos = 0; + private byte _lastByteRead; + private bool _peeked = false; + private List _internalWriteBuffer = new List(); + internal readonly Socket/*!*/ _socket; + + public override bool CanRead { + get { return true; } + } + + public override bool CanSeek { + get { return false; } + } + + public override bool CanWrite { + get { return true; } + } + + public override void Close() { + base.Close(); + _socket.Close(); + } + + public override void Flush() { + byte[] bufferedData = _internalWriteBuffer.ToArray(); + int bytesSent = _socket.Send(bufferedData); + if (bytesSent < bufferedData.Length) { + // TODO: Resend the rest + } + _internalWriteBuffer.Clear(); + } + + public override long Length { + get { throw new Exception("The method or operation is not implemented."); } + } + + public override long Position { + get { + return _pos; + } + set { + long diff = _pos - value; + if (diff == 1) { + _peeked = true; + } + + _pos = value; + } + } + + public override int Read(byte[] buffer, int offset, int count) { + int bytesToRead = _peeked ? count - 1 : count; + byte[] readBuffer = new byte[bytesToRead]; + long oldPos = _pos; + + if (bytesToRead > 0) { + int bytesRead = _socket.Receive(readBuffer, bytesToRead, SocketFlags.None); + _pos += bytesRead; + } + + if (_peeked) { + // Put the byte we've already peeked at the beginning of the buffer + buffer[offset] = _lastByteRead; + // Put the rest of the data afterwards + Array.Copy(readBuffer, 0, buffer, offset + 1, count - 1); + _pos += 1; + _peeked = false; + } else { + Array.Copy(readBuffer, 0, buffer, offset, count); + } + + int totalBytesRead = (int)(_pos - oldPos); + if (totalBytesRead > 0) { + _lastByteRead = buffer[totalBytesRead - 1]; + } + + return totalBytesRead; + } + + public override long Seek(long offset, System.IO.SeekOrigin origin) { + throw new NotSupportedException("The method or operation is not implemented."); + } + + public override void SetLength(long value) { + throw new NotSupportedException("The method or operation is not implemented."); + } + + public override void Write(byte[] buffer, int offset, int count) { + for (int i = offset; i < offset + count; i++) { + _internalWriteBuffer.Add(buffer[i]); + if (buffer[i] == '\n') { + Flush(); + } + } + } + } +} +#endif \ No newline at end of file =================================================================== add: $/Dev10/feature/vs_langs01/Merlin/Main/Languages/Ruby/Libraries.LCA_RESTRICTED/socket/TCPServer.cs File: TCPServer.cs =================================================================== --- [no source file] +++ Shelved Change: $/Dev10/feature/vs_langs01/Merlin/Main/Languages/Ruby/Libraries.LCA_RESTRICTED/socket/TCPServer.cs;sockets-1 @@ -1,0 +1,80 @@ +?#if !SILVERLIGHT + +using System; +using System.Net; +using System.Net.Sockets; +using System.Reflection; +using System.Runtime.InteropServices; +using Microsoft.Scripting.Runtime; +using Microsoft.Scripting.Utils; +using Ruby.Builtins; +using Ruby.Runtime; + +namespace Ruby.StandardLibrary { + [RubyClass("TCPServer", BuildConfig = "!SILVERLIGHT")] + public class TCPServer : TCPSocket { + public TCPServer(CodeContext/*!*/ context, Socket/*!*/ socket) : base(context, socket) { + } + + [RubyConstructor] + public static TCPServer/*!*/ CreateTCPServer(CodeContext/*!*/ context, [Optional]object hostname, object port) { + IPAddress listeningInterface = null; + if (hostname == Missing.Value) { + listeningInterface = new IPAddress(0); + } else { + string hostnameStr = Protocols.CastToString(context, hostname).ConvertToString(); + // try to parse it as an IP address first + if (!IPAddress.TryParse(hostnameStr, out listeningInterface)) { + + // look up the host IP from DNS + IPHostEntry hostEntry = Dns.GetHostEntry(hostnameStr); + foreach (IPAddress address in hostEntry.AddressList) { + if (address.AddressFamily == AddressFamily.InterNetwork) { + listeningInterface = address; + break; + } + } + if (listeningInterface == null) { + // TODO: do we need to support any other address family types? + // (presumably should support at least IPv6) + throw new NotImplementedException("TODO: non-inet addresses"); + } + } + Assert.NotNull(listeningInterface); + } + + Socket socket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp); + socket.Bind(new IPEndPoint(listeningInterface, ConvertToPortNum(context, port))); + socket.Listen(10); + return new TCPServer(context, socket); + } + + [RubyMethod("accept")] + public static TCPSocket/*!*/ Accept(CodeContext/*!*/ context, TCPServer/*!*/ self) { + return new TCPSocket(context, self.Socket.Accept()); + } + + [RubyMethod("accept_nonblock")] + public static TCPSocket/*!*/ AcceptNonBlocking(CodeContext/*!*/ context, TCPServer/*!*/ self) { + bool blocking = self.Socket.Blocking; + try { + self.Socket.Blocking = false; + return Accept(context, self); + } finally { + // Reset the blocking + self.Socket.Blocking = blocking; + } + } + + [RubyMethod("sysaccept")] + public static int SysAccept(CodeContext/*!*/ context, TCPServer/*!*/ self) { + return Accept(context, self).FileDescriptor; + } + + [RubyMethod("listen")] + public static void Listen(CodeContext/*!*/ context, TCPServer/*!*/ self, int backlog) { + self.Socket.Listen(backlog); + } + } +} +#endif \ No newline at end of file =================================================================== add: $/Dev10/feature/vs_langs01/Merlin/Main/Languages/Ruby/Libraries.LCA_RESTRICTED/socket/TCPSocket.cs File: TCPSocket.cs =================================================================== --- [no source file] +++ Shelved Change: $/Dev10/feature/vs_langs01/Merlin/Main/Languages/Ruby/Libraries.LCA_RESTRICTED/socket/TCPSocket.cs;sockets-1 @@ -1,0 +1,58 @@ +?#if !SILVERLIGHT + +using System.Net; +using System.Net.Sockets; +using Microsoft.Scripting.Runtime; +using Ruby.Builtins; +using Ruby.Runtime; + +namespace Ruby.StandardLibrary { + [RubyClass("TCPSocket", BuildConfig = "!SILVERLIGHT")] + public class TCPSocket : IPSocket { + public TCPSocket(CodeContext/*!*/ context, Socket/*!*/ socket) + : base(context, socket) { + } + + [RubyMethod("gethostbyname", RubyMethodAttributes.PublicSingleton)] + public static RubyArray/*!*/ GetHostByName(CodeContext/*!*/ context, RubyClass/*!*/ klass, object hostName) { + MutableString strHostName = ConvertToHostString(context, hostName); + + if (strHostName == null) { + throw new SocketException(); + } + + RubyArray result = new RubyArray(4); + IPHostEntry hostEntry = Dns.GetHostEntry(hostName.ToString()); + // Canonical Hostname + result.Add(MutableString.Create(hostEntry.HostName)); + + // Aliases + RubyArray aliases = new RubyArray(hostEntry.Aliases.Length); + foreach (string alias in hostEntry.Aliases) { + aliases.Add(MutableString.Create(alias)); + } + result.Add(aliases); + + // Address Type + result.Add((int)hostEntry.AddressList[0].AddressFamily); + + // IP Address + foreach (IPAddress address in hostEntry.AddressList) { + result.Add(MutableString.Create(address.ToString())); + } + return result; + } + + [RubyConstructor] + public static TCPSocket/*!*/ CreateTCPSocket(CodeContext/*!*/ context, object remoteHost, object remotePort) { + MutableString hostname = Protocols.CastToString(context, remoteHost); + int port = ConvertToPortNum(context, remotePort); + + Socket socket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp); + socket.Connect(hostname.ConvertToString(), port); + + return new TCPSocket(context, socket); + } + } +} +#endif \ No newline at end of file =================================================================== add: $/Dev10/feature/vs_langs01/Merlin/Main/Languages/Ruby/Libraries.LCA_RESTRICTED/socket/UDPSocket.cs File: UDPSocket.cs =================================================================== --- [no source file] +++ Shelved Change: $/Dev10/feature/vs_langs01/Merlin/Main/Languages/Ruby/Libraries.LCA_RESTRICTED/socket/UDPSocket.cs;sockets-1 @@ -1,0 +1,92 @@ +?#if !SILVERLIGHT + +using System.Net; +using System.Net.Sockets; +using Microsoft.Scripting.Runtime; +using Ruby.Builtins; +using Ruby.Runtime; + +namespace Ruby.StandardLibrary { + [RubyClass("UDPSocket", BuildConfig = "!SILVERLIGHT")] + class UDPSocket : IPSocket { + public UDPSocket(CodeContext/*!*/ context, Socket/*!*/ socket) + : base(context, socket) { + } + [RubyConstructor] + public static UDPSocket/*!*/ CreateUDPSocket(CodeContext/*!*/ context) { + Socket socket = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp); + return new UDPSocket(context, socket); + } + [RubyConstructor] + public static UDPSocket/*!*/ CreateUDPSocket(CodeContext/*!*/ context, object family) { + AddressFamily addressFamily = ConvertToAddressFamily(context, family); + Socket socket = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp); + return new UDPSocket(context, socket); + } + + #region Public Instance Methods + [RubyMethod("bind")] + public static int Bind(CodeContext/*!*/ context, UDPSocket/*!*/ self, object hostname, object port) { + int iPort = ConvertToPortNum(context, port); + if (hostname == null) { + hostname = MutableString.Create("localhost"); + } + MutableString address = GetAddressInternal(context, hostname); + IPEndPoint ep = new IPEndPoint(IPAddress.Parse(address.ConvertToString()), iPort); + self.Socket.Bind(ep); + return 0; + } + [RubyMethod("connect")] + public static int Connect(CodeContext/*!*/ context, UDPSocket/*!*/ self, object hostname, object port) { + MutableString strHostname = ConvertToHostString(context, hostname); + int iPort = ConvertToPortNum(context, port); + self.Socket.Connect(strHostname.ConvertToString(), iPort); + return 0; + } + [RubyMethod("recvfrom_nonblock")] + public static RubyArray/*!*/ ReceiveFromNonBlocking(CodeContext/*!*/ context, IPSocket/*!*/ self, int length) { + bool blocking = self.Socket.Blocking; + try { + self.Socket.Blocking = false; + return ReceiveFrom(context, self, length, null); + } finally { + // Reset the blocking + self.Socket.Blocking = blocking; + } + } + [RubyMethod("recvfrom_nonblock")] + public static RubyArray/*!*/ ReceiveFromNonBlocking(CodeContext/*!*/ context, IPSocket/*!*/ self, int length, object/*Numeric*/ flags) { + bool blocking = self.Socket.Blocking; + try { + self.Socket.Blocking = false; + return ReceiveFrom(context, self, length, flags); + } finally { + // Reset the blocking + self.Socket.Blocking = blocking; + } + } + [RubyMethod("send")] + public static int Send(CodeContext/*!*/ context, RubyBasicSocket/*!*/ self, object message, object flags, object hostname, object port) { + Protocols.CheckSafeLevel(context, 4, "send"); + // Convert the parameters + SocketFlags sFlags = ConvertToSocketFlag(context, flags); + MutableString strMessage = Protocols.CastToString(context, message); + MutableString address = GetAddressInternal(context, hostname); + int iPort = ConvertToPortNum(context, port); + EndPoint toEndPoint = new IPEndPoint(IPAddress.Parse(address.ConvertToString()), iPort); + return self.Socket.SendTo(strMessage.ConvertToBytes(), sFlags, toEndPoint); + } + + // These overwritten methods have to be here because we kill the ones in RubyBasicSocket by creating the one above + [RubyMethod("send")] + public static new int Send(CodeContext/*!*/ context, RubyBasicSocket/*!*/ self, object message, object flags) { + return RubyBasicSocket.Send(context, self, message, flags); + } + [RubyMethod("send")] + public static new int Send(CodeContext/*!*/ context, RubyBasicSocket/*!*/ self, object message, object flags, object to) { + return RubyBasicSocket.Send(context, self, message, flags, to); + } + #endregion + } +} +#endif \ No newline at end of file =================================================================== edit: $/Dev10/feature/vs_langs01/Merlin/Main/Languages/Ruby/Ruby/Ruby.csproj;C436237 File: Ruby.csproj =================================================================== --- $/Dev10/feature/vs_langs01/Merlin/Main/Languages/Ruby/Ruby/Ruby.csproj;C436237 (server) 5/13/2008 8:53 AM +++ Shelved Change: $/Dev10/feature/vs_langs01/Merlin/Main/Languages/Ruby/Ruby/Ruby.csproj;sockets-1 @@ -74,6 +74,10 @@ False $(SilverlightSdkPath)\mscorlib.dll + + False + $(SilverlightSdkPath)\System.Net.dll + False $(SilverlightSdkPath)\System.dll =================================================================== edit: $/Dev10/feature/vs_langs01/Merlin/Main/Languages/Ruby/Ruby/Builtins/MutableString.cs;C436237 File: MutableString.cs =================================================================== --- $/Dev10/feature/vs_langs01/Merlin/Main/Languages/Ruby/Ruby/Builtins/MutableString.cs;C436237 (server) 5/13/2008 9:05 AM +++ Shelved Change: $/Dev10/feature/vs_langs01/Merlin/Main/Languages/Ruby/Ruby/Builtins/MutableString.cs;sockets-1 @@ -249,6 +249,8 @@ return ReferenceEquals(str, null) || str.Length == 0; } + public bool IsEmpty { get { return _content.Length == 0; } } + #endregion #region StartsWith, EndsWith =================================================================== edit: $/Dev10/feature/vs_langs01/Merlin/Main/Languages/Ruby/Tests/Specs/spec_runner.rb;C436237 File: spec_runner.rb =================================================================== --- $/Dev10/feature/vs_langs01/Merlin/Main/Languages/Ruby/Tests/Specs/spec_runner.rb;C436237 (server) 5/13/2008 8:53 AM +++ Shelved Change: $/Dev10/feature/vs_langs01/Merlin/Main/Languages/Ruby/Tests/Specs/spec_runner.rb;sockets-1 @@ -115,15 +115,24 @@ # language features implemented $klass_exclusions = ['thread'] +folder = "core" klass = ARGV.first + +# if you want a non-core set of tests then you have to pass in the folder as part of the klass parameter +# E.g. spec_runner library:socket:udpsocket will run the udpsocket tests in the library/socket/udpsocket folder +if klass.include? ':' + parts = klass.split(':') + klass = parts.pop + folder = parts.join('/') +end parse_reporter if klass != '-' - Dir.chdir("core/#{klass}") do + Dir.chdir("#{folder}/#{klass}") do run_specs(klass) end else - Dir.chdir("core") + Dir.chdir(folder) klasses = Dir.glob('*') klass_list = klasses - $klass_exclusions ===================================================================