Ejemplo n.º 1
0
        internal static Type/*!*/ GetOrCreateType(Type/*!*/ baseType, IList<Type/*!*/>/*!*/ interfaces, bool noOverrides) {
            Assert.NotNull(baseType);
            Assert.NotNull(interfaces);

            ITypeFeature[] features;
            if (interfaces.Count == 0) {
                features = _defaultFeatures;
            } else {
                features = new ITypeFeature[2] {
                    RubyTypeBuilder.Feature,
                    InterfacesBuilder.MakeFeature(interfaces)
                };
            }
            noOverrides |= typeof(IRubyType).IsAssignableFrom(baseType);

            TypeDescription typeInfo = new TypeDescription(baseType, features, noOverrides);
            Type type = _newTypes.GetOrCreateValue(typeInfo,
                delegate() {
                    if (TypeImplementsFeatures(baseType, features)) {
                        return baseType;
                    }
                    return CreateType(typeInfo);
                });

            Debug.Assert(typeof(IRubyObject).IsAssignableFrom(type));
            return type;
        }
Ejemplo n.º 2
0
 private static void AddBuiltinType(Type/*!*/ clsBaseType, Type/*!*/ rubyType, ITypeFeature/*!*/[]/*!*/ features, bool noOverrides) {
     _newTypes.GetOrCreateValue(new TypeDescription(clsBaseType, features, noOverrides), () => rubyType);
     _typeFeatures[rubyType] = features;
 }
Ejemplo n.º 3
0
 private static void AddSystemType(Type/*!*/ clsBaseType, Type/*!*/ rubyType, ITypeFeature/*!*/[]/*!*/ features) {
     _newTypes.GetOrCreateValue(new TypeDescription(clsBaseType, features), delegate() { return rubyType; });
     _typeFeatures[rubyType] = features;
 }