当前位置: 首页>>代码示例>>C#>>正文


C# Builtins.RubyStruct类代码示例

本文整理汇总了C#中IronRuby.Builtins.RubyStruct的典型用法代码示例。如果您正苦于以下问题:C# RubyStruct类的具体用法?C# RubyStruct怎么用?C# RubyStruct使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


RubyStruct类属于IronRuby.Builtins命名空间,在下文中一共展示了RubyStruct类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Each

        public static object Each(BlockParam block, RubyStruct/*!*/ self)
        {
            if (block == null && self.ItemCount > 0) {
                throw RubyExceptions.NoBlockGiven();
            }

            foreach (var value in self.Values) {
                object result;
                if (block.Yield(value, out result)) {
                    return result;
                }
            }

            return self;
        }
开发者ID:TerabyteX,项目名称:main,代码行数:15,代码来源:StructOps.cs

示例2: EachPair

        public static object EachPair(BlockParam block, RubyStruct/*!*/ self)
        {
            if (block == null && self.ItemCount > 0) {
                throw RubyExceptions.NoBlockGiven();
            }

            var context = self.ImmediateClass.Context;
            foreach (KeyValuePair<string, object> entry in self.GetItems()) {
                object result;
                if (block.Yield(context.EncodeIdentifier(entry.Key), entry.Value, out result)) {
                    return result;
                }
            }

            return self;
        }
开发者ID:TerabyteX,项目名称:main,代码行数:16,代码来源:StructOps.cs

示例3: GetMembers

 public static RubyArray/*!*/ GetMembers(RubyStruct/*!*/ self) {
     Debug.Assert(self.Class.StructInfo != null);
     return self.Class.StructInfo.GetMembers();
 }
开发者ID:joshholmes,项目名称:ironruby,代码行数:4,代码来源:RubyStruct.cs

示例4: TmsSetChildUserTime

 public static void TmsSetChildUserTime(RubyStruct/*!*/ tms, double value) {
     tms[2] = value;
 }
开发者ID:atczyc,项目名称:ironruby,代码行数:3,代码来源:RubyProcess.cs

示例5: RubyClass

        // friend: RubyContext
        // tracker: non-null => show members declared on the tracker
        internal RubyClass(RubyContext/*!*/ context, string name, Type type, object singletonClassOf,
            Action<RubyModule> methodsInitializer, Action<RubyModule> constantsInitializer, Delegate/*!*/[] factories, RubyClass superClass, 
            RubyModule/*!*/[] expandedMixins, TypeTracker tracker, RubyStruct.Info structInfo,
            bool isRubyClass, bool isSingletonClass, ModuleRestrictions restrictions)
            : base(context, name, methodsInitializer, constantsInitializer, expandedMixins,
                type != typeof(object) ? null : context.Namespaces, tracker, restrictions) {

            Debug.Assert(context.Namespaces != null, "Namespaces should be initialized");
            Debug.Assert(superClass != null || structInfo == null, "BasicObject is not a struct");
            Debug.Assert(!isRubyClass || tracker == null, "Ruby class cannot have a tracker");
            Debug.Assert(singletonClassOf != null || !isSingletonClass, "Singleton classes don't have a type");
            Debug.Assert(superClass != this);

            _underlyingSystemType = type;
            _superClass = superClass;
            _isSingletonClass = isSingletonClass;
            _isRubyClass = isRubyClass;
            _singletonClassOf = singletonClassOf;
            _factories = factories ?? Utils.EmptyDelegates;

            if (superClass != null) {
                _level = superClass.Level + 1;
                _structInfo = structInfo ?? superClass._structInfo;
            } else {
                _level = 0;
            }
        }
开发者ID:kashano,项目名称:main,代码行数:29,代码来源:RubyClass.cs

示例6: ToYamlNode

        public static Node ToYamlNode(RubyStruct/*!*/ self, [NotNull]RubyRepresenter/*!*/ rep) {
            RubyContext context = self.Class.Context;
            RubyArray members = _Members.Target(_Members, context, self);
            RubyArray values = _Values.Target(_Values, context, self);

            if (members.Count != values.Count) {
                throw new ArgumentException("Struct values and members returned arrays of different lengths");
            }

            Hash map = new Hash(self.Class.Context);
            for (int i = 0; i < members.Count; i++) {
                IDictionaryOps.SetElement(context, map, members[i], values[i]);
            }
            RubyRepresenter.AddYamlProperties(context, self, map);
            return rep.Map(self, map);
        }
开发者ID:bclubb,项目名称:ironruby,代码行数:16,代码来源:BuiltinsOps.cs

示例7: ToYamlNode

 public static Node ToYamlNode(RubyStruct/*!*/ self, [NotNull]RubyRepresenter/*!*/ rep) {
     var fieldNames = self.GetNames();
     var map = new Dictionary<MutableString, object>(fieldNames.Count);
     for (int i = 0; i < fieldNames.Count; i++) {
         map[MutableString.Create(fieldNames[i])] = self.GetValue(i);
     }
     rep.AddYamlProperties(self, map);
     return rep.Map(self, map);
 }
开发者ID:jxnmaomao,项目名称:ironruby,代码行数:9,代码来源:BuiltinsOps.cs

示例8: InitializeCopy

        public static RubyStruct/*!*/ InitializeCopy(RubyStruct/*!*/ self, [NotNull]RubyStruct/*!*/ source) {
            // TODO: compare non-singleton classes?
            if (self.ImmediateClass.GetNonSingletonClass() != source.ImmediateClass.GetNonSingletonClass()) {
                throw RubyExceptions.CreateTypeError("wrong argument class");
            }

            self.SetValues(source.Values);
            return self;
        }
开发者ID:jschementi,项目名称:iron,代码行数:9,代码来源:StructOps.cs

示例9: SetValue

 public static object SetValue(RubyStruct/*!*/ self, [NotNull]MutableString/*!*/ name, object value) {
     return self[name.ConvertToString()] = value;
 }
开发者ID:jschementi,项目名称:iron,代码行数:3,代码来源:StructOps.cs

示例10: GetSize

 public static int GetSize(RubyStruct/*!*/ self) {
     return self.ItemCount;
 }
开发者ID:jschementi,项目名称:iron,代码行数:3,代码来源:StructOps.cs

示例11: GetMembers

 public static RubyArray/*!*/ GetMembers(RubyStruct/*!*/ self) {
     return RubyStruct.GetMembers(self);
 }
开发者ID:jschementi,项目名称:iron,代码行数:3,代码来源:StructOps.cs

示例12: WriteStruct

 private void WriteStruct(RubyStruct/*!*/ obj) {
     SubclassData instanceWriter = new SubclassData(this, obj, typeof(RubyStruct));
     _writer.Write((byte)'S');
     RubyClass theClass = _context.GetClassOf(obj);
     TestForAnonymous(theClass);
     WriteSymbol(theClass.Name);
     var names = obj.GetNames();
     WriteInt32(names.Count);
     foreach (string name in names) {
         int index = obj.GetIndex(name);
         WriteSymbol(name);
         WriteAnObject(obj[index]);
     }
 }
开发者ID:mscottford,项目名称:ironruby,代码行数:14,代码来源:Marshal.cs

示例13: Equals

        public static bool Equals(BinaryOpStorage/*!*/ equals, RubyStruct/*!*/ self, object obj) {
            var other = obj as RubyStruct;
            if (!self.StructReferenceEquals(other)) {
                return false;
            }
            Debug.Assert(self.ItemCount == other.ItemCount);

            if (self.Values.Length > 0) {
                var site = equals.GetCallSite("==");
                for (int i = 0; i < self.Values.Length; i++) {
                    if (RubyOps.IsFalse(site.Target(site, self.Values[i], other.Values[i]))) {
                        return false;
                    }
                }
            }

            return true;
        }
开发者ID:jcteague,项目名称:ironruby,代码行数:18,代码来源:StructOps.cs

示例14: ValuesAt

        public static RubyArray/*!*/ ValuesAt(ConversionStorage<int>/*!*/ fixnumCast, RubyStruct/*!*/ self, params object[]/*!*/ values) {
            RubyArray result = new RubyArray();
            object[] data = self.Values;

            for (int i = 0; i < values.Length; ++i) {
                Range range = values[i] as Range;
                if (range != null) {
                    int begin = Protocols.CastToFixnum(fixnumCast, range.Begin);
                    int end = Protocols.CastToFixnum(fixnumCast, range.End);

                    if (range.ExcludeEnd) {
                        end -= 1;
                    }

                    begin = NormalizeIndex(data.Length, begin);
                    end = NormalizeIndex(data.Length, end);
                    Debug.Assert(end - begin <= data.Length); // because we normalized the indicies

                    if (end - begin > 0) {
                        result.AddCapacity(end - begin);
                        for (int j = begin; j <= end; j++) {
                            result.Add(data[j]);
                        }
                    }
                } else {
                    int index = NormalizeIndex(data.Length, Protocols.CastToFixnum(fixnumCast, values[i]));
                    result.Add(data[index]);
                }
            }

            return result;
        }
开发者ID:jschementi,项目名称:iron,代码行数:32,代码来源:StructOps.cs

示例15: Reinitialize

 public static void Reinitialize(RubyStruct/*!*/ self, params object[]/*!*/ items) {
     self.SetValues(items);
 }
开发者ID:jschementi,项目名称:iron,代码行数:3,代码来源:StructOps.cs


注:本文中的IronRuby.Builtins.RubyStruct类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。