Example #1
0
 public static void AttrWriter(RubyScope /*!*/ scope, RubyModule /*!*/ self, [NotNull] params object[] names)
 {
     foreach (string name in Protocols.CastToSymbols(scope.RubyContext, names))
     {
         DefineAccessor(scope, self, name, false, true);
     }
 }
Example #2
0
        internal static void SetMethodAttributes(RubyScope /*!*/ scope, RubyModule /*!*/ module, object[] /*!*/ methodNames, RubyMethodAttributes attributes)
        {
            ContractUtils.RequiresNotNull(scope, "scope");
            ContractUtils.RequiresNotNull(methodNames, "methodNames");

            if (methodNames.Length == 0)
            {
                scope.GetMethodAttributesDefinitionScope().MethodAttributes = attributes;
            }
            else
            {
                foreach (string methodName in Protocols.CastToSymbols(scope.RubyContext, methodNames))
                {
                    RubyMemberInfo method = module.ResolveMethodFallbackToObject(methodName, true);
                    if (method == null)
                    {
                        throw RubyExceptions.CreateNameError(RubyExceptions.FormatMethodMissingMessage(scope.RubyContext, module, methodName));
                    }

                    if ((attributes & RubyMethodAttributes.ModuleFunction) == RubyMethodAttributes.ModuleFunction)
                    {
                        module.AddModuleFunction(methodName, method);
                    }
                    else
                    {
                        module.SetMethodVisibility(methodName, method, (RubyMethodVisibility)(attributes & RubyMethodAttributes.VisibilityMask));
                    }
                }
            }
        }
Example #3
0
        public static object NewStruct(BlockParam block, RubyClass /*!*/ self, [DefaultProtocol, Optional] MutableString className,
                                       [NotNull] params object[] /*!*/ attributeNames)
        {
            string[] symbols = Protocols.CastToSymbols(self.Context, attributeNames);

            if (className == null)
            {
                return(Create(block, self, null, symbols));
            }

            string strName = className.ConvertToString();

            RubyUtils.CheckConstantName(strName);
            return(Create(block, self, strName, symbols));
        }
Example #4
0
 public static RubyModule /*!*/ MakeClassMethodsPublic(RubyModule /*!*/ self, [NotNull] params object[] /*!*/ methodNames)
 {
     SetClassMethodsVisibility(self, Protocols.CastToSymbols(self.Context, methodNames), RubyMethodVisibility.Public);
     return(self);
 }
Example #5
0
 public static object CreateAnonymousWithFirstAttribute(BlockParam block, RubyClass /*!*/ self,
                                                        string /*!*/ firstAttribute, object[] /*!*/ attributeNames)
 {
     return(Create(block, self, null, ArrayUtils.Insert(firstAttribute, Protocols.CastToSymbols(self.Context, attributeNames))));
 }