Beispiel #1
0
 public static Hash /*!*/ Initialize(Hash /*!*/ self)
 {
     Assert.NotNull(self);
     return(self);
 }
Beispiel #2
0
 public static Hash /*!*/ CreateSubclass(RubyClass /*!*/ self)
 {
     return(Hash.CreateInstance(self));
 }
Beispiel #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));
 }
Beispiel #4
0
 public static Proc GetDefaultProc(Hash /*!*/ self)
 {
     return(self.DefaultProc);
 }
Beispiel #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));
        }
Beispiel #6
0
 public static object SetDefaultValue(RubyContext /*!*/ context, Hash /*!*/ self, object value)
 {
     self.Mutate();
     self.DefaultProc = null;
     return(self.DefaultValue = value);
 }
Beispiel #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);
 }
Beispiel #8
0
 public static object GetDefaultValue(RubyContext /*!*/ context, Hash /*!*/ self)
 {
     return(self.DefaultValue);
 }
Beispiel #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);
        }
Beispiel #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);
 }