示例#1
0
        public static PyDict_Items Create(PyDict dict)
        {
            var dict_items = PyTypeObject.DefaultNew <PyDict_Items>(PyDict_ItemsClass.Instance);

            dict_items.Dict = dict;
            return(dict_items);
        }
示例#2
0
        public static PyTuple Create(object[] values)
        {
            var pyTuple = PyTypeObject.DefaultNew <PyTuple>(PyTupleClass.Instance);

            pyTuple.Values = values;
            return(pyTuple);
        }
示例#3
0
        public static PyInteger Create(BigInteger value)
        {
            var pyInt = PyTypeObject.DefaultNew <PyInteger>(PyIntegerClass.Instance);

            pyInt.InternalValue = value;
            return(pyInt);
        }
示例#4
0
        public static PyFloat Create(Decimal value)
        {
            var pyFloat = PyTypeObject.DefaultNew <PyFloat>(PyFloatClass.Instance);

            pyFloat.InternalValue = value;
            return(pyFloat);
        }
示例#5
0
        private static PyBool _makeInstance(bool value)
        {
            var instance = PyTypeObject.DefaultNew <PyBool>(PyBoolClass.Instance);

            instance.InternalValue = value;
            return(instance);
        }
示例#6
0
        public static PyModule Create(string name)
        {
            var createdModule = PyTypeObject.DefaultNew <PyModule>(PyModuleClass.Instance);

            createdModule.Name = name;
            return(createdModule);
        }
示例#7
0
        public static PyList Create(List <object> existingList)
        {
            var pyList = PyTypeObject.DefaultNew <PyList>(PyListClass.Instance);

            pyList.list = existingList;
            return(pyList);
        }
示例#8
0
        public static PyTuple Create(List <object> values)
        {
            var pyTuple = PyTypeObject.DefaultNew <PyTuple>(PyTupleClass.Instance);

            pyTuple.Values = values.ToArray();
            return(pyTuple);
        }
示例#9
0
        public static PyKeyIterator Create(PyDict dict)
        {
            var iterator = PyTypeObject.DefaultNew <PyKeyIterator>(PyKeyIteratorClass.Instance);

            iterator.Keys = dict.dict.Keys.GetEnumerator();
            return(iterator);
        }
示例#10
0
        public static PyString Create(string value)
        {
            var pyString = PyTypeObject.DefaultNew <PyString>(PyStringClass.Instance);

            pyString.InternalValue = value;
            return(pyString);
        }
示例#11
0
文件: PyFloat.cs 项目: bamyazi/cloaca
        public static PyFloat Create(double value)
        {
            var pyFloat = PyTypeObject.DefaultNew <PyFloat>(PyFloatClass.Instance);

            pyFloat.number = new Decimal(value);
            return(pyFloat);
        }
示例#12
0
        public static PyTupleIterator Create(PyTuple tuple)
        {
            var iterator = PyTypeObject.DefaultNew <PyTupleIterator>(PyTupleIteratorClass.Instance);

            iterator.CurrentIdx    = 0;
            iterator.IteratedTuple = tuple;
            return(iterator);
        }
示例#13
0
        /// <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);
        }
示例#14
0
        public static PyListIterator Create(PyList list)
        {
            var iterator = PyTypeObject.DefaultNew <PyListIterator>(PyListIteratorClass.Instance);

            iterator.CurrentIdx   = 0;
            iterator.IteratedList = list;

            return(iterator);
        }
示例#15
0
        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);
        }
示例#16
0
        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);
        }
示例#17
0
        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);
        }
示例#18
0
        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);
        }
示例#19
0
 public static PyString Create()
 {
     return(PyTypeObject.DefaultNew <PyString>(PyStringClass.Instance));
 }
示例#20
0
 public static PyInteger Create()
 {
     return(PyTypeObject.DefaultNew <PyInteger>(PyIntegerClass.Instance));
 }
示例#21
0
        public static PyList Create()
        {
            var pyList = PyTypeObject.DefaultNew <PyList>(PyListClass.Instance);

            return(pyList);
        }
示例#22
0
 public PyObject(PyTypeObject fromType)
 {
     // TODO: Determine if there needs to be additional properties.
     __dict__ = fromType.__dict__;
 }
示例#23
0
 /// <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));
 }
示例#24
0
文件: PyFloat.cs 项目: bamyazi/cloaca
 public static PyFloat Create()
 {
     return(PyTypeObject.DefaultNew <PyFloat>(PyFloatClass.Instance));
 }
示例#25
0
 public static void DefaultNewPyObject(PyObject toNew, PyTypeObject classObj)
 {
     toNew.__dict__  = new Dictionary <string, object>(classObj.__dict__);
     toNew.__class__ = (PyClass)classObj;
 }