예제 #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
파일: PyModule.cs 프로젝트: bamyazi/cloaca
        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;
 }