Ejemplo n.º 1
0
        public static RubyModule/*!*/ Of(RubyContext/*!*/ context, TypeGroup/*!*/ self, int genericArity) {
            TypeTracker tracker = self.GetTypeForArity(genericArity);
            if (tracker == null) {
                throw RubyExceptions.CreateArgumentError(String.Format("Type group `{0}' does not contain a type of generic arity {1}", self.Name, genericArity));
            }

            return context.GetModule(tracker.Type);
        }
Ejemplo n.º 2
0
        public static RubyModule /*!*/ Of(RubyContext /*!*/ context, TypeGroup /*!*/ self, int genericArity)
        {
            TypeTracker tracker = self.GetTypeForArity(genericArity);

            if (tracker == null)
            {
                throw RubyExceptions.CreateArgumentError("Type group `{0}' does not contain a type of generic arity {1}", self.Name, genericArity);
            }

            return(context.GetModule(tracker.Type));
        }
Ejemplo n.º 3
0
        public static object EachType(RubyContext/*!*/ context, BlockParam/*!*/ block, TypeGroup/*!*/ self) {
            if (block == null) {
                throw RubyExceptions.NoBlockGiven();
            }

            foreach (Type type in self.Types) {
                RubyModule module = context.GetModule(type);
                object result;
                if (block.Yield(module, out result)) {
                    return result;
                }
            }

            return self;
        }
Ejemplo n.º 4
0
        public static RubyModule/*!*/ Of(RubyContext/*!*/ context, TypeGroup/*!*/ self, [NotNull]params object[]/*!*/ typeArgs) {
            TypeTracker tracker = self.GetTypeForArity(typeArgs.Length);

            if (tracker == null) {
                throw RubyExceptions.CreateArgumentError(String.Format("Invalid number of type arguments for `{0}'", self.Name));
            }

            Type concreteType;
            if (typeArgs.Length > 0) {
                concreteType = tracker.Type.MakeGenericType(Protocols.ToTypes(context, typeArgs));
            } else {
                concreteType = tracker.Type;
            }

            return context.GetModule(concreteType);
        }
Ejemplo n.º 5
0
        public static object EachType(RubyContext /*!*/ context, BlockParam /*!*/ block, TypeGroup /*!*/ self)
        {
            if (block == null)
            {
                throw RubyExceptions.NoBlockGiven();
            }

            foreach (Type type in self.Types)
            {
                RubyModule module = context.GetModule(type);
                object     result;
                if (block.Yield(module, out result))
                {
                    return(result);
                }
            }

            return(self);
        }
Ejemplo n.º 6
0
        public static RubyModule /*!*/ Of(RubyContext /*!*/ context, TypeGroup /*!*/ self, [NotNullItems] params object /*!*/[] /*!*/ typeArgs)
        {
            TypeTracker tracker = self.GetTypeForArity(typeArgs.Length);

            if (tracker == null)
            {
                throw RubyExceptions.CreateArgumentError("Invalid number of type arguments for `{0}'", self.Name);
            }

            Type concreteType;

            if (typeArgs.Length > 0)
            {
                concreteType = tracker.Type.MakeGenericType(Protocols.ToTypes(context, typeArgs));
            }
            else
            {
                concreteType = tracker.Type;
            }

            return(context.GetModule(concreteType));
        }
Ejemplo n.º 7
0
 public static RubyModule /*!*/ ToModule(RubyContext /*!*/ context, Type /*!*/ self)
 {
     return(context.GetModule(self));
 }
Ejemplo n.º 8
0
 public static RubyModule ToModule(RubyContext/*!*/ context, Type/*!*/ self)
 {
     return context.GetModule(self);
 }
Ejemplo n.º 9
0
 public static RubyModule/*!*/ ToModule(RubyContext/*!*/ context, TypeTracker/*!*/ self) {
     return context.GetModule(self.Type);
 }