ForEachMember() public method

public ForEachMember ( bool inherited, RubyMethodAttributes attributes, Action action ) : void
inherited bool
attributes RubyMethodAttributes
action Action
return void
コード例 #1
0
        internal static RubyArray /*!*/ GetMethods(RubyModule /*!*/ self, bool inherited, RubyMethodAttributes attributes)
        {
            var result = new RubyArray();

            self.ForEachMember(inherited, attributes, delegate(string /*!*/ name, RubyMemberInfo /*!*/ member) {
                result.Add(MutableString.Create(name));
            });
            return(result);
        }
コード例 #2
0
            public override IEnumerable <string> GetDynamicMemberNames()
            {
                var self = (IRubyObject)Value;
                RubyInstanceData instanceData = self.GetInstanceData();
                RubyModule       theClass     = (instanceData != null ? instanceData.ImmediateClass : null);

                theClass = theClass ?? self.Class;
                var names = new List <string>();

                theClass.ForEachMember(true, RubyMethodAttributes.DefaultVisibility, delegate(string /*!*/ name, RubyMemberInfo /*!*/ member) {
                    names.Add(name);
                });
                return(names);
            }
コード例 #3
0
ファイル: ModuleOps.cs プロジェクト: ife/IronLanguages
        internal static RubyArray /*!*/ GetMethods(RubyModule /*!*/ self, bool inherited, RubyMethodAttributes attributes,
                                                   IEnumerable <string> foreignMembers)
        {
            var result = new RubyArray();

            using (self.Context.ClassHierarchyLocker()) {
                self.ForEachMember(inherited, attributes, foreignMembers, (name, module, member) => {
                    if (member.IsInteropMember && (module.Restrictions & ModuleRestrictions.NoNameMapping) == 0 && RubyUtils.HasMangledName(name))
                    {
                        if (Tokenizer.IsMethodName(name) || Tokenizer.IsOperatorName(name))
                        {
                            result.Add(new ClrName(name));
                        }
                    }
                    else
                    {
                        result.Add(self.Context.StringifyIdentifier(name));
                    }
                });
            }
            return(result);
        }
コード例 #4
0
ファイル: ModuleOps.cs プロジェクト: aslakhellesoy/ironruby
 internal static RubyArray/*!*/ GetMethods(RubyModule/*!*/ self, bool inherited, RubyMethodAttributes attributes) {
     var result = new RubyArray();
     var symbolicNames = self.Context.RubyOptions.Compatibility > RubyCompatibility.Ruby18;
     self.ForEachMember(inherited, attributes, delegate(string/*!*/ name, RubyMemberInfo/*!*/ member) {
         if (symbolicNames) {
             result.Add(SymbolTable.StringToId(name));
         } else {
             result.Add(MutableString.Create(name));
         }
     });
     return result;
 }
コード例 #5
0
ファイル: ModuleOps.cs プロジェクト: mscottford/ironruby
 internal static RubyArray/*!*/ GetMethods(RubyModule/*!*/ self, bool inherited, RubyMethodAttributes attributes) {
     var result = new RubyArray();
     self.ForEachMember(inherited, attributes, delegate(string/*!*/ name, RubyMemberInfo/*!*/ member) {
         result.Add(MutableString.Create(name));
     });
     return result;
 }
コード例 #6
0
ファイル: RubyDefinition.cs プロジェクト: RaTTiE/Warlock-core
        /// <summary>
        /// メソッド定義情報を取得する。
        /// </summary>
        /// <param name="constant">モジュールまたはクラスのRubyオブジェクト。</param>
        /// <param name="attributes">メソッド取得対象を表すスイッチ。</param>
        /// <param name="objectDefinition">オブジェクト定義のインスタンス。</param>
        /// <param name="singleton">シングルトンメソッドか?</param>
        private static void GetMethodDefinitions(
            RubyModule constant,
            RubyMethodAttributes attributes,
            RubyObjectDefinition objectDefinition,
            bool singleton)
        {
            constant.ForEachMember(false, attributes | RubyMethodAttributes.VisibilityMask, (methodName, module, memberInfo) =>
            {
                if (memberInfo is RubyAttributeAccessorInfo)
                {
                    var accessorInfo = (RubyAttributeAccessorInfo)memberInfo;
                    var accessorName = methodName;

                    if (accessorInfo is RubyAttributeWriterInfo)
                    {
                        accessorName = accessorName.Substring(0, accessorName.Length - 1);
                    }

                    var accessorDefinition = (
                        from a in objectDefinition.Accessors
                        where a.Name == accessorName
                        select a
                    ).FirstOrDefault();

                    if (accessorDefinition == null)
                    {
                        accessorDefinition = new RubyAccessorDefinition()
                        {
                            Name = accessorName
                        };

                        objectDefinition.Accessors.Add(accessorDefinition);
                    }

                    if (accessorInfo is RubyAttributeWriterInfo)
                    {
                        accessorDefinition.Writable = true;
                    }
                    else if (accessorInfo is RubyAttributeReaderInfo)
                    {
                        accessorDefinition.Readable = true;
                    }
                    else
                    {
                        throw new NotImplementedException();
                    }
                }
                else if (memberInfo is RubyMethodInfo)
                {
                    var methodInfo = (RubyMethodInfo)memberInfo;

                    var methodDefinition = new RubyMethodDefinition()
                    {
                        Name = methodName,
                        Singleton = singleton
                    };

                    foreach (LocalVariable argument in methodInfo.Parameters.Mandatory)
                    {
                        methodDefinition.Arguments.Add(
                            new RubyMethodArgumentDefinition()
                            {
                                Name = argument.Name,
                                Optional = false
                            }
                        );
                    }
                    foreach (SimpleAssignmentExpression argument in methodInfo.Parameters.Optional)
                    {
                        var argumentDefinition = new RubyMethodArgumentDefinition()
                        {
                            Name = ((LocalVariable)argument.Left).Name,
                            Optional = true
                        };

                        if (argument.Right is Literal)
                        {
                            argumentDefinition.DefaultValue = ((Literal)argument.Right).Value;
                        }
                        else if (argument.Right is ClassVariable)
                        {
                            argumentDefinition.DefaultValue = ((ClassVariable)argument.Right).Name;
                            argumentDefinition.ClassVariable = true;
                        }

                        methodDefinition.Arguments.Add(argumentDefinition);
                    }

                    objectDefinition.Methods.Add(methodDefinition);
                }
                else
                {
                    throw new NotImplementedException();
                }
            });
        }
コード例 #7
0
ファイル: ModuleOps.cs プロジェクト: atczyc/ironruby
        internal static RubyArray/*!*/ GetMethods(RubyModule/*!*/ self, bool inherited, RubyMethodAttributes attributes,
            IEnumerable<string> foreignMembers) {

            var result = new RubyArray();
            var symbolicNames = self.Context.RubyOptions.Compatibility > RubyCompatibility.Ruby18;

            using (self.Context.ClassHierarchyLocker()) {
                self.ForEachMember(inherited, attributes, foreignMembers, (name, module, member) => {
                    if (member.IsInteropMember && (module.Restrictions & ModuleRestrictions.NoNameMapping) == 0 && RubyUtils.HasMangledName(name)) {
                        result.Add(new ClrName(name));
                    } else {
                        result.Add(CreateMethodName(name, symbolicNames));
                    }
                });
            }
            return result;
        }
コード例 #8
0
ファイル: ModuleOps.cs プロジェクト: jcteague/ironruby
        internal static RubyArray/*!*/ GetMethods(RubyModule/*!*/ self, bool inherited, RubyMethodAttributes attributes,
            IEnumerable<string> foreignMembers) {

            var result = new RubyArray();
            var symbolicNames = self.Context.RubyOptions.Compatibility > RubyCompatibility.Ruby18;

            using (self.Context.ClassHierarchyLocker()) {
                self.ForEachMember(inherited, attributes, foreignMembers, delegate(string/*!*/ name, RubyMemberInfo member) {
                    result.Add(CreateMethodName(name, symbolicNames));
                });
            }
            return result;
        }
コード例 #9
0
ファイル: ModuleOps.cs プロジェクト: jschementi/iron
        internal static RubyArray/*!*/ GetMethods(RubyModule/*!*/ self, bool inherited, RubyMethodAttributes attributes,
            IEnumerable<string> foreignMembers) {

            var result = new RubyArray();
            using (self.Context.ClassHierarchyLocker()) {
                self.ForEachMember(inherited, attributes, foreignMembers, (name, module, member) => {
                    if (member.IsInteropMember && (module.Restrictions & ModuleRestrictions.NoNameMapping) == 0 && RubyUtils.HasMangledName(name)) {
                        if (Tokenizer.IsMethodName(name) || Tokenizer.IsOperatorName(name)) {
                            result.Add(new ClrName(name));
                        }
                    } else {
                        result.Add(self.Context.StringifyIdentifier(name));
                    }
                });
            }
            return result;
        }