public static PySuper Create(PyObject self, PyClass superclass) { var instance = PyTypeObject.DefaultNew <PySuper>(PySuperType.Instance); // TODO: Also test for NoneType and assign NoneType if (self == null) { instance.__setattr__("__self__", null); instance.__setattr__("__self_class__", null); } else { instance.__setattr__("__self__", self); instance.__setattr__("__self_class__", self.__class__); } instance.__setattr__("__this_class__", superclass); return(instance); }
private static object __getattribute__(PyClass testClass, string name, out bool found) { found = false; if (testClass.__dict__.ContainsKey(name)) { found = true; return(testClass.__dict__[name]); } else { foreach (var parentClass in testClass.__bases__) { var parentResult = __getattribute__(parentClass, name, out found); if (found) { return(parentResult); } } } return(null); }
public void __setattr__(string name, object value) { PyClass.__setattr__(this, name, value); }
public virtual object __getattribute__(string name) { // First marked this virtual when PySuper had to create a hacked __getattribute__ return(PyClass.__getattribute__(this, name)); }