Update() public method

Update Method
Update the dictionary from another dictionary.
public Update ( PyObject other ) : void
other PyObject
return void
Esempio n. 1
0
        private void GetArgs(object[] inargs, out PyTuple args, out PyDict kwargs)
        {
            int arg_count;

            for (arg_count = 0; arg_count < inargs.Length && !(inargs[arg_count] is Py.KeywordArguments); ++arg_count)
            {
                ;
            }
            IntPtr argtuple = Runtime.PyTuple_New(arg_count);

            for (var i = 0; i < arg_count; i++)
            {
                AddArgument(argtuple, i, inargs[i]);
            }
            args = new PyTuple(argtuple);

            kwargs = null;
            for (int i = arg_count; i < inargs.Length; i++)
            {
                if (!(inargs[i] is Py.KeywordArguments))
                {
                    throw new ArgumentException("Keyword arguments must come after normal arguments.");
                }
                if (kwargs == null)
                {
                    kwargs = (Py.KeywordArguments)inargs[i];
                }
                else
                {
                    kwargs.Update((Py.KeywordArguments)inargs[i]);
                }
            }
        }
Esempio n. 2
0
        private void GetArgs(object[] inargs, out PyTuple args, out PyDict kwargs)
        {
            int arg_count;

            for (arg_count = 0; arg_count < inargs.Length && !(inargs[arg_count] is Py.KeywordArguments); ++arg_count)
            {
                ;
            }
            IntPtr argtuple = Runtime.PyTuple_New(arg_count);

            for (int i = 0; i < arg_count; i++)
            {
                IntPtr ptr;
                if (inargs[i] is PyObject)
                {
                    ptr = ((PyObject)inargs[i]).Handle;
                    Runtime.Incref(ptr);
                }
                else
                {
                    ptr = Converter.ToPython(inargs[i], inargs[i].GetType());
                }
                if (Runtime.PyTuple_SetItem(argtuple, i, ptr) < 0)
                {
                    throw new PythonException();
                }
            }
            args   = new PyTuple(argtuple);
            kwargs = null;
            for (int i = arg_count; i < inargs.Length; i++)
            {
                if (!(inargs[i] is Py.KeywordArguments))
                {
                    throw new ArgumentException("Keyword arguments must come after normal arguments.");
                }
                if (kwargs == null)
                {
                    kwargs = (Py.KeywordArguments)inargs[i];
                }
                else
                {
                    kwargs.Update((Py.KeywordArguments)inargs[i]);
                }
            }
        }
Esempio n. 3
0
 private void GetArgs(object[] inargs, out PyTuple args, out PyDict kwargs)
 {
     int arg_count;
     for (arg_count = 0; arg_count < inargs.Length && !(inargs[arg_count] is Py.KeywordArguments); ++arg_count);
     IntPtr argtuple = Runtime.PyTuple_New(arg_count);
     for (int i = 0; i < arg_count; i++)
     {
     IntPtr ptr;
     if (inargs[i] is PyObject)
     {
         ptr = ((PyObject)inargs[i]).Handle;
         Runtime.Incref(ptr);
     }
     else
     {
         ptr = Converter.ToPython(inargs[i], inargs[i].GetType());
     }
     if (Runtime.PyTuple_SetItem(argtuple, i, ptr) < 0)
         throw new PythonException();
     }
     args = new PyTuple(argtuple);
     kwargs = null;
     for (int i = arg_count; i < inargs.Length; i++)
     {
     if (!(inargs[i] is Py.KeywordArguments))
         throw new ArgumentException("Keyword arguments must come after normal arguments.");
     if (kwargs == null)
         kwargs = (Py.KeywordArguments)inargs[i];
     else
         kwargs.Update((Py.KeywordArguments)inargs[i]);
     }
 }