protected RubyClass/*!*/ DefineGlobalClass(string/*!*/ name, Type/*!*/ type, RubyClass/*!*/ super, Action<RubyModule> instanceTrait, Action<RubyModule> classTrait, RubyModule[]/*!*/ mixins, Delegate[] factories) { RubyClass result = _context.DefineLibraryClass(name, type, instanceTrait, classTrait, super, mixins, factories, _builtin); _context.ObjectClass.SetConstant(result.Name, result); return result; }
// copy ctor: private RubyStruct(RubyClass/*!*/ rubyClass, object[]/*!*/ data) : base(rubyClass) { Debug.Assert(rubyClass.StructInfo != null); Debug.Assert(!rubyClass.IsSingletonClass); _data = ArrayUtils.Copy(data); }
public static int InducedFrom(RubyClass/*!*/ self, double value) { if (value >= Int32.MinValue && value <= Int32.MaxValue) { return (Int32)value; } throw RubyExceptions.CreateRangeError("Float {0} out of range of {1}", value, self.Name); }
public static char Create(RubyClass/*!*/ self, int utf16) { try { return checked((char)utf16); } catch (OverflowException) { throw RubyExceptions.CreateRangeError("{0} is not a valid UTF-16 character code", utf16); } }
public static RubyFile/*!*/ CreateFile(RubyClass/*!*/ self, MutableString/*!*/ path, int mode) { if (path.IsEmpty) { throw new Errno.InvalidError(); } return new RubyFile(self.Context, path.ConvertToString(), (RubyFileMode)mode); }
public static Hash CreateHash(BlockParam block, RubyClass/*!*/ self, object defaultValue) { if (block != null) { throw RubyExceptions.CreateArgumentError("wrong number of arguments"); } return new Hash(self.Context.EqualityComparer, null, defaultValue); }
// called by Proc#new rule when creating a Ruby subclass of Proc: public Subclass(RubyClass/*!*/ rubyClass, Proc/*!*/ proc) : base(proc) { Assert.NotNull(rubyClass); Debug.Assert(!rubyClass.IsSingletonClass); ImmediateClass = rubyClass; }
public static MutableString/*!*/ Convert(RubyClass/*!*/ self, [DefaultProtocol]MutableString/*!*/ toEncoding, [DefaultProtocol]MutableString/*!*/ fromEncoding, [DefaultProtocol]MutableString/*!*/ str) { //return iconv(to, from, str).join; return null; }
public static char Create(RubyClass/*!*/ self, [NotNull]string/*!*/ str) { if (str.Length == 0) { throw EmptyError("string"); } return str[0]; }
public static char Create(RubyClass/*!*/ self, [NotNull]char[]/*!*/ chars) { if (chars.Length == 0) { throw EmptyError("System::Char[]"); } return chars[0]; }
// called by Class#new rule when creating a Ruby subclass of IO: public Subclass(RubyClass/*!*/ rubyClass) : base(rubyClass.Context) { Assert.NotNull(rubyClass); Debug.Assert(!rubyClass.IsSingletonClass); ImmediateClass = rubyClass; }
public static char Create(RubyClass/*!*/ self, [DefaultProtocol]MutableString/*!*/ str) { if (str.IsEmpty) { throw EmptyError("string"); } return str.GetChar(0); }
public Subclass(RubyClass/*!*/ rubyClass, MutableString begin, MutableString end, bool excludeEnd) : base(begin, end, excludeEnd) { Assert.NotNull(rubyClass); Debug.Assert(!rubyClass.IsSingletonClass); ImmediateClass = rubyClass; }
public static RhoDatabase/*!*/ Create(RubyClass/*!*/ self, [NotNull]MutableString/*!*/ dbName, [NotNull]MutableString/*!*/ dbPartition) { RhoDatabase rbDB = new RhoDatabase(); rbDB.m_db = new DBAdapter(); rbDB.m_db.rb_open(dbName.ToString(), dbPartition.ToString()); return rbDB; }
public static Hash/*!*/ CreateSubclass(RubyClass/*!*/ self, params object[]/*!*/ items) { Debug.Assert(items.Length > 0); if (items.Length % 2 != 0) { throw RubyExceptions.CreateArgumentError("odd number of arguments for Hash"); } return RubyUtils.SetHashElements(self.Context, Hash.CreateInstance(self), items); }
public static TCPSocket/*!*/ CreateTCPSocket(RubyClass/*!*/ self, [DefaultProtocol, NotNull]MutableString/*!*/ remoteHost, object remotePort) { int port = ConvertToPortNum(self.Context, remotePort); Socket socket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp); socket.Connect(remoteHost.ConvertToString(), port); return new TCPSocket(self.Context, socket); }
protected RubyClass/*!*/ DefineGlobalClass(string/*!*/ name, Type/*!*/ type, bool isSelfContained, RubyClass/*!*/ super, Action<RubyModule> instanceTrait, Action<RubyModule> classTrait, Action<RubyModule> constantsInitializer, RubyModule/*!*/[]/*!*/ mixins, params Delegate[] factories) { RubyClass result = _context.DefineLibraryClass(name, type, instanceTrait, classTrait, constantsInitializer, super, mixins, factories, isSelfContained, _builtin); _context.ObjectClass.SetConstant(result.Name, result); return result; }
protected RubyClass/*!*/ DefineGlobalClass(string/*!*/ name, Type/*!*/ type, int restrictions, RubyClass/*!*/ super, Action<RubyModule> instanceTrait, Action<RubyModule> classTrait, Action<RubyModule> constantsInitializer, RubyModule/*!*/[]/*!*/ mixins, params Delegate[] factories) { RubyClass result = _context.DefineLibraryClass(name, type, instanceTrait, classTrait, constantsInitializer, super, mixins, factories, (ModuleRestrictions)restrictions, _builtin); PublishModule(name, result); return result; }
public static GeneratorState CreateGeneratorState(RubyClass/*!*/ self, [Optional]Hash configuration) { GeneratorState state = new GeneratorState(); if (configuration != null) { Reinitialize(self.Context, state, configuration); } return state; }
/// <summary> /// Struct#new /// Creates Struct classes with the specified name and members /// </summary> private static object Create(BlockParam block, RubyClass/*!*/ self, string className, string/*!*/[]/*!*/ attributeNames) { var result = RubyStruct.DefineStruct(self, className, attributeNames); if (block != null) { return RubyUtils.EvaluateInModule(result, block, null, result); } return result; }
public static RubyIO/*!*/ CreateIO(RubyClass/*!*/ self, [DefaultProtocol]int fileDescriptor, [DefaultProtocol, NotNull, Optional]MutableString modeString) { // TODO: a new RubyIO should be created here RubyIO result = self.Context.GetDescriptor(fileDescriptor); if (modeString != null) { result.ResetIOMode(modeString.ConvertToString()); } return result; }
public static Hash/*!*/ CreateSubclass(ConversionStorage<IList>/*!*/ toAry, RubyClass/*!*/ self, [NotNull]IList/*!*/ list) { Hash result = Hash.CreateInstance(self); var toArySite = toAry.GetSite(TryConvertToArrayAction.Make(toAry.Context)); foreach (object item in list) { IList pair = toArySite.Target(toArySite, item); if (pair != null && pair.Count >= 1 && pair.Count <= 2) { RubyUtils.SetHashElement(self.Context, result, pair[0], (pair.Count == 2) ? pair[1] : null); } } return result; }
public static Exception/*!*/ CreateMissingDefaultConstructorError(RubyClass/*!*/ rubyClass, string/*!*/ initializerOwnerName) { Debug.Assert(rubyClass.IsRubyClass); Type baseType = rubyClass.GetUnderlyingSystemType().BaseType; Debug.Assert(baseType != null); return CreateTypeError("can't allocate class `{1}' that derives from type `{0}' with no default constructor;" + " define {1}#new singleton method instead of {2}#initialize", rubyClass.Context.GetTypeName(baseType, true), rubyClass.Name, initializerOwnerName ); }
public static object NewStruct(BlockParam block, RubyClass/*!*/ self, [DefaultProtocol]MutableString className, [DefaultProtocol, NotNullItems]params string/*!*/[]/*!*/ attributeNames) { if (className == null) { return Create(block, self, null, attributeNames); } string strName = className.ConvertToString(); RubyUtils.CheckConstantName(strName); return Create(block, self, strName, attributeNames); }
public static TCPSocket/*!*/ CreateTCPSocket(ConversionStorage<MutableString>/*!*/ stringCast, ConversionStorage<int>/*!*/ fixnumCast, RubyClass/*!*/ self, [DefaultProtocol]MutableString remoteHost, object remotePort, [DefaultProtocol]MutableString localHost, object localPort) { return BindLocalEndPoint( CreateTCPSocket(stringCast, fixnumCast, self, remoteHost, remotePort, 0), localHost, ConvertToPortNum(stringCast, fixnumCast, localPort) ); }
public static RubyFile/*!*/ CreateFile(RubyClass/*!*/ self, [DefaultProtocol]Union<int, MutableString> descriptorOrPath, int mode, [Optional]int permission) { if (descriptorOrPath.IsFixnum()) { // TODO: descriptor throw new NotImplementedException(); } else { // TODO: permissions return CreateFile(self, descriptorOrPath.Second, mode); } }
public static RubyClass GetSuperclass(RubyClass/*!*/ self) { if (self.IsSingletonClass) { RubyClass result = self.ImmediateClass; Debug.Assert(result.IsSingletonClass); // do not return dummy singletons, also do not create a new singleton (MRI does): return result.IsDummySingletonClass ? self : result; } else { return self.SuperClass; } }
public static MutableString Convert(RubyClass/*!*/ self, [DefaultProtocol, NotNull]MutableString/*!*/ toEncoding, [DefaultProtocol, NotNull]MutableString/*!*/ fromEncoding, [DefaultProtocol]MutableString str) { MutableString[] convertedStrings = Convert(self, toEncoding, fromEncoding, new MutableString[] { str, null }); MutableString result = MutableString.CreateEmpty(); foreach (MutableString s in convertedStrings) { result.Append(s); } return result; }
public static TCPSocket/*!*/ CreateTCPSocket(ConversionStorage<MutableString>/*!*/ stringCast, ConversionStorage<int>/*!*/ fixnumCast, RubyClass/*!*/ self, [DefaultProtocol]MutableString remoteHost, object remotePort, [Optional]int localPort) { // Not sure what the semantics should be in this case but we make sure not to blow up. // Real-world code (Server.connect_to in memcache.rb in the memcache-client gem) does do "TCPSocket.new(host, port, 0)" if (localPort != 0) { throw new NotImplementedError(); } return new TCPSocket(self.Context, CreateSocket(remoteHost, ConvertToPortNum(stringCast, fixnumCast, remotePort))); }
public static RubyIO/*!*/ CreateFile( ConversionStorage<int?>/*!*/ toInt, ConversionStorage<IDictionary<object, object>>/*!*/ toHash, ConversionStorage<MutableString>/*!*/ toStr, RubyClass/*!*/ self, object descriptor, [Optional]object optionsOrMode, [DefaultParameterValue(null), DefaultProtocol]IDictionary<object, object> options) { return Reinitialize(toInt, toHash, toStr, new RubyIO(self.Context), descriptor, optionsOrMode, options); }
public static object Open(RubyContext /*!*/ context, BlockParam /*!*/ block, RubyClass /*!*/ self, int fileDescriptor, [NotNull] MutableString /*!*/ mode) { RubyIO io = _CreateIOSharedSite11.Target(_CreateIOSharedSite11, context, self, fileDescriptor, mode); return(TryInvokeOpenBlock(context, block, io)); }
public static Hash /*!*/ CreateSubclass(ConversionStorage <IList> /*!*/ toAry, RubyClass /*!*/ self, [NotNull] IList /*!*/ list) { Hash result = Hash.CreateInstance(self); var toArySite = toAry.GetSite(TryConvertToArrayAction.Make(toAry.Context)); foreach (object item in list) { IList pair = toArySite.Target(toArySite, item); if (pair != null && pair.Count >= 1 && pair.Count <= 2) { RubyUtils.SetHashElement(self.Context, result, pair[0], (pair.Count == 2) ? pair[1] : null); } } return(result); }
public static object Open(RubyContext /*!*/ context, BlockParam /*!*/ block, RubyClass /*!*/ self, MutableString /*!*/ host, int port) { RubyIO io = _CreateIOSharedSite6.Target(_CreateIOSharedSite6, context, self, host, port); return(TryInvokeOpenBlock(context, block, io)); }
public static Hash /*!*/ CreateHash([NotNull] BlockParam /*!*/ defaultProc, RubyClass /*!*/ self) { return(new Hash(self.Context.EqualityComparer, defaultProc.Proc, null)); }
public static RubyIO /*!*/ CreateIO(RubyClass /*!*/ self) { // TODO: should create an IO object with uninitialize stream throw new NotImplementedException(); }
public static RubyArray /*!*/ ReadLines(RubyClass /*!*/ self, [DefaultProtocol, NotNull] MutableString /*!*/ path) { return(ReadLines(self, path, self.Context.InputSeparator)); }
public static Range /*!*/ CreateRange(BinaryOpStorage /*!*/ comparisonStorage, RubyClass /*!*/ self, object begin, object end, [Optional] bool excludeEnd) { return(new Range(comparisonStorage, self.Context, begin, end, excludeEnd)); }
public static void ForEach(BlockParam block, RubyClass /*!*/ self, [DefaultProtocol, NotNull] MutableString /*!*/ path, MutableString separator) { using (RubyIO io = new RubyIO(self.Context, File.OpenRead(path.ConvertToString()), "r")) { Each(block, io, separator); } }
public static IDictionary <object, object> TryConvert(ConversionStorage <IDictionary <object, object> > /*!*/ toHash, RubyClass /*!*/ self, object obj) { var site = toHash.GetSite(TryConvertToHashAction.Make(toHash.Context)); return(site.Target(site, obj)); }
public static RubyIO ForFd(RubyClass /*!*/ self, int fileDescriptor, [DefaultProtocol, NotNull] MutableString /*!*/ modeString) { return(CreateIO(self, fileDescriptor, modeString)); }
// called by Class#new rule when creating a Ruby subclass: internal Subclass(RubyClass /*!*/ rubyClass, string name) : base(rubyClass, name) { Assert.NotNull(rubyClass); _class = rubyClass; }
public static Hash /*!*/ CreateSubclass(RubyClass /*!*/ self, [NotNull] IDictionary <object, object> /*!*/ hash) { // creates a new hash and copies entries of the given hash into it (no other objects associated with the has are copied): return(IDictionaryOps.ReplaceData(Hash.CreateInstance(self), hash)); }
public static void InitializeCopy(RubyClass /*!*/ self, [NotNull] RubyClass /*!*/ other) { self.InitializeClassCopy(other); }
public static object OpenPipe(RubyContext /*!*/ context, BlockParam block, RubyClass /*!*/ self, [DefaultProtocol, NotNull] MutableString /*!*/ command, [DefaultProtocol, Optional, NotNull] MutableString modeString) { return(TryInvokeOpenBlock(context, block, OpenPipe(context, self, command, modeString))); }
// called by Class#new rule when creating a Ruby subclass: public Subclass(RubyClass /*!*/ rubyClass) : this(rubyClass, null) { }
public static void Reinitialize(BlockParam body, RubyClass /*!*/ self, [Optional] RubyClass superClass) { // Class cannot be subclassed, so this can only be called directly on an already initialized class: throw RubyExceptions.CreateTypeError("already initialized class"); }
public static Hash /*!*/ CreateSubclass(RubyClass /*!*/ self) { return(Hash.CreateInstance(self)); }
public static MutableString Mangle(RubyClass /*!*/ self, [DefaultProtocol] string /*!*/ clrName) { var ruby = RubyUtils.TryMangleName(clrName); return(ruby != null?MutableString.Create(ruby, self.Context.GetIdentifierEncoding()) : null); }
public static Hash /*!*/ CreateHash(RubyClass /*!*/ self) { return(new Hash(self.Context.EqualityComparer)); }
protected RubyClass /*!*/ DefineGlobalClass(string /*!*/ name, Type /*!*/ type, RubyClass /*!*/ super, Action <RubyModule> instanceTrait, Action <RubyModule> classTrait, RubyModule[] /*!*/ mixins, Delegate[] factories) { RubyClass result = _context.DefineLibraryClass(name, type, instanceTrait, classTrait, super, mixins, factories, _builtin); _context.ObjectClass.SetConstant(result.Name, result); return(result); }
public RubyObject(RubyClass /*!*/ cls) { Assert.NotNull(cls); Debug.Assert(!cls.IsSingletonClass); _immediateClass = cls; }
public static object Open(RubyContext /*!*/ context, BlockParam /*!*/ block, RubyClass /*!*/ self, int fileDescriptor, object mode) { RubyIO io = _CreateIOSharedSite11.Target(_CreateIOSharedSite11, context, self, fileDescriptor, Protocols.CastToString(context, mode)); return(TryInvokeOpenBlock(context, block, io)); }
protected RubyClass /*!*/ DefineClass(string /*!*/ name, Type /*!*/ type, RubyClass /*!*/ super, Action <RubyModule> instanceTrait, Action <RubyModule> classTrait, RubyModule[] /*!*/ mixins, Delegate[] factories) { return(_context.DefineLibraryClass(name, type, instanceTrait, classTrait, super, mixins, factories, _builtin)); }
public RubyObject(RubyClass /*!*/ cls) { Assert.NotNull(cls); _class = cls; }
public static string /*!*/ GetClrMessage(RubyClass /*!*/ exceptionClass, object message) { return(RubyExceptionData.GetClrMessage(exceptionClass.Context, message)); }
public Meta(Expression /*!*/ expression, BindingRestrictions /*!*/ restrictions, RubyClass /*!*/ value) : base(expression, restrictions, value) { ContractUtils.RequiresNotNull(value, "value"); }
public static float Create(RubyClass /*!*/ self, [DefaultProtocol] double value) { return((float)value); }
public static Enumerator /*!*/ Create(RubyClass /*!*/ self, object targetObject, [DefaultProtocol, Optional] string targetName, params object[] /*!*/ targetArguments) { return(Reinitialize(new Enumerator(), targetObject, targetName, targetArguments)); }
public static void ForEach(BlockParam block, RubyClass /*!*/ self, [DefaultProtocol, NotNull] MutableString /*!*/ path) { ForEach(block, self, path, self.Context.InputSeparator); }
public static object Open(RubyContext /*!*/ context, BlockParam /*!*/ block, RubyClass /*!*/ self, int fileDescriptor) { RubyIO io = _CreateIOSharedSite1.Target(_CreateIOSharedSite1, context, self, fileDescriptor); return(TryInvokeOpenBlock(context, block, io)); }