Esempio n. 1
0
 public static Hash /*!*/ Initialize(Hash /*!*/ self)
 {
     Assert.NotNull(self);
     return(self);
 }
Esempio n. 2
0
 public static Hash /*!*/ CreateSubclass(RubyClass /*!*/ self)
 {
     return(Hash.CreateInstance(self));
 }
Esempio n. 3
0
 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));
 }
Esempio n. 4
0
 public static Proc GetDefaultProc(Hash /*!*/ self)
 {
     return(self.DefaultProc);
 }
Esempio n. 5
0
        public static object Shift(CallSiteStorage <Func <CallSite, Hash, object, object> > /*!*/ storage, Hash /*!*/ self)
        {
            self.Mutate();

            if (self.Count == 0)
            {
                var site = storage.GetCallSite("default", 1);
                return(site.Target(site, self, null));
            }

            IEnumerator <KeyValuePair <object, object> > e = self.GetEnumerator();

            e.MoveNext();
            KeyValuePair <object, object> pair = e.Current;

            self.Remove(pair.Key);

            return(IDictionaryOps.MakeArray(pair));
        }
Esempio n. 6
0
 public static object SetDefaultValue(RubyContext /*!*/ context, Hash /*!*/ self, object value)
 {
     self.Mutate();
     self.DefaultProc = null;
     return(self.DefaultValue = value);
 }
Esempio n. 7
0
 public static object GetDefaultValue(CallSiteStorage <Func <CallSite, Proc, Hash, object, object> > /*!*/ storage, Hash /*!*/ self, object key)
 {
     if (self.DefaultProc != null)
     {
         var site = storage.GetCallSite("call", 2);
         return(site.Target(site, self.DefaultProc, self, key));
     }
     return(self.DefaultValue);
 }
Esempio n. 8
0
 public static object GetDefaultValue(RubyContext /*!*/ context, Hash /*!*/ self)
 {
     return(self.DefaultValue);
 }
Esempio n. 9
0
        public static object GetElement(CallSiteStorage <Func <CallSite, Hash, object, object> > /*!*/ storage, Hash /*!*/ self, object key)
        {
            object result;

            if (!self.TryGetValue(CustomStringDictionary.NullToObj(key), out result))
            {
                var site = storage.GetCallSite("default", 1);
                return(site.Target(site, self, key));
            }
            return(result);
        }
Esempio n. 10
0
 public static Hash /*!*/ InitializeCopy(RubyContext /*!*/ context, Hash /*!*/ self, [NotNull] Hash /*!*/ source)
 {
     self.Mutate();
     self.DefaultProc  = source.DefaultProc;
     self.DefaultValue = source.DefaultValue;
     IDictionaryOps.ReplaceData(self, source);
     return(self);
 }