public static PyDict_Items Create(PyDict dict) { var dict_items = PyTypeObject.DefaultNew <PyDict_Items>(PyDict_ItemsClass.Instance); dict_items.Dict = dict; return(dict_items); }
public static PyTuple Create(object[] values) { var pyTuple = PyTypeObject.DefaultNew <PyTuple>(PyTupleClass.Instance); pyTuple.Values = values; return(pyTuple); }
public static PyInteger Create(BigInteger value) { var pyInt = PyTypeObject.DefaultNew <PyInteger>(PyIntegerClass.Instance); pyInt.InternalValue = value; return(pyInt); }
public static PyFloat Create(Decimal value) { var pyFloat = PyTypeObject.DefaultNew <PyFloat>(PyFloatClass.Instance); pyFloat.InternalValue = value; return(pyFloat); }
private static PyBool _makeInstance(bool value) { var instance = PyTypeObject.DefaultNew <PyBool>(PyBoolClass.Instance); instance.InternalValue = value; return(instance); }
public static PyModule Create(string name) { var createdModule = PyTypeObject.DefaultNew <PyModule>(PyModuleClass.Instance); createdModule.Name = name; return(createdModule); }
public static PyList Create(List <object> existingList) { var pyList = PyTypeObject.DefaultNew <PyList>(PyListClass.Instance); pyList.list = existingList; return(pyList); }
public static PyTuple Create(List <object> values) { var pyTuple = PyTypeObject.DefaultNew <PyTuple>(PyTupleClass.Instance); pyTuple.Values = values.ToArray(); return(pyTuple); }
public static PyKeyIterator Create(PyDict dict) { var iterator = PyTypeObject.DefaultNew <PyKeyIterator>(PyKeyIteratorClass.Instance); iterator.Keys = dict.dict.Keys.GetEnumerator(); return(iterator); }
public static PyString Create(string value) { var pyString = PyTypeObject.DefaultNew <PyString>(PyStringClass.Instance); pyString.InternalValue = value; return(pyString); }
public static PyFloat Create(double value) { var pyFloat = PyTypeObject.DefaultNew <PyFloat>(PyFloatClass.Instance); pyFloat.number = new Decimal(value); return(pyFloat); }
public static PyTupleIterator Create(PyTuple tuple) { var iterator = PyTypeObject.DefaultNew <PyTupleIterator>(PyTupleIteratorClass.Instance); iterator.CurrentIdx = 0; iterator.IteratedTuple = tuple; return(iterator); }
/// <summary> /// A generic __new__ implementation for embedded class to create various kinds of PyObject; /// the specific type of PyObject to create is given by the generic argument. /// </summary> /// <typeparam name="T">The type of PyObject to create. It must have a default constructor.</typeparam> /// <param name="typeObj">An instance of the class with which to popular the object's __dict__.</param> /// <returns>An instance of the object. It still needs to be constructed with __init__, but its class /// properties have been stubbed in. /// </returns> public static T DefaultNew <T>(PyTypeObject typeObj) where T : PyObject, new() { var newObject = new T(); // Shallow copy __dict__ DefaultNewPyObject(newObject, typeObj); return(newObject); }
public static PyListIterator Create(PyList list) { var iterator = PyTypeObject.DefaultNew <PyListIterator>(PyListIteratorClass.Instance); iterator.CurrentIdx = 0; iterator.IteratedList = list; return(iterator); }
public static PyRange Create(int min, int max, int step) { var pyRange = PyTypeObject.DefaultNew <PyRange>(PyRangeClass.Instance); pyRange.Min = min; pyRange.Max = max; pyRange.Step = step; return(pyRange); }
public static PyModuleSpec Create(string name, ISpecLoader loader, string origin, string[] submodule_search_locations) { var spec = PyTypeObject.DefaultNew <PyModuleSpec>(PyModuleSpecClass.Instance); spec.Name = name; spec.Loader = loader; spec.Origin = origin; spec.SubmoduleSearchLocations = submodule_search_locations; return(spec); }
public static PyRangeIterator Create(PyRange range) { var iterator = PyTypeObject.DefaultNew <PyRangeIterator>(PyRangeIteratorClass.Instance); iterator.Min = range.Min; iterator.Max = range.Max; iterator.Step = range.Step; iterator.Current = iterator.Min; return(iterator); }
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); }
public static PyString Create() { return(PyTypeObject.DefaultNew <PyString>(PyStringClass.Instance)); }
public static PyInteger Create() { return(PyTypeObject.DefaultNew <PyInteger>(PyIntegerClass.Instance)); }
public static PyList Create() { var pyList = PyTypeObject.DefaultNew <PyList>(PyListClass.Instance); return(pyList); }
public PyObject(PyTypeObject fromType) { // TODO: Determine if there needs to be additional properties. __dict__ = fromType.__dict__; }
/// <summary> /// The default __new__ implementation for objects. This works with a /// generic PyObject. /// </summary> /// <param name="typeObj">The actual type object.</param> /// <returns>A PyObject handle that can subsequently by initialized with __init__ from the /// particular class that needs a new instance. /// </returns> public static PyObject DefaultNew(PyTypeObject typeObj) { return(DefaultNew <PyObject>(typeObj)); }
public static PyFloat Create() { return(PyTypeObject.DefaultNew <PyFloat>(PyFloatClass.Instance)); }
public static void DefaultNewPyObject(PyObject toNew, PyTypeObject classObj) { toNew.__dict__ = new Dictionary <string, object>(classObj.__dict__); toNew.__class__ = (PyClass)classObj; }