|
Karsten Hopp |
0fad6e |
To: vim_dev@googlegroups.com
|
|
Karsten Hopp |
0fad6e |
Subject: Patch 7.3.1061
|
|
Karsten Hopp |
0fad6e |
Fcc: outbox
|
|
Karsten Hopp |
0fad6e |
From: Bram Moolenaar <Bram@moolenaar.net>
|
|
Karsten Hopp |
0fad6e |
Mime-Version: 1.0
|
|
Karsten Hopp |
0fad6e |
Content-Type: text/plain; charset=UTF-8
|
|
Karsten Hopp |
0fad6e |
Content-Transfer-Encoding: 8bit
|
|
Karsten Hopp |
0fad6e |
------------
|
|
Karsten Hopp |
0fad6e |
|
|
Karsten Hopp |
0fad6e |
Patch 7.3.1061
|
|
Karsten Hopp |
0fad6e |
Problem: Python: Dictionary is not standard.
|
|
Karsten Hopp |
0fad6e |
Solution: Python patch 20: Add standard methods and fields. (ZyX)
|
|
Karsten Hopp |
0fad6e |
Files: runtime/doc/if_pyth.txt, src/eval.c, src/if_py_both.h,
|
|
Karsten Hopp |
0fad6e |
src/if_python3.c, src/if_python.c, src/proto/eval.pro,
|
|
Karsten Hopp |
0fad6e |
src/testdir/test86.in, src/testdir/test86.ok,
|
|
Karsten Hopp |
0fad6e |
src/testdir/test87.in, src/testdir/test87.ok
|
|
Karsten Hopp |
0fad6e |
|
|
Karsten Hopp |
0fad6e |
|
|
Karsten Hopp |
0fad6e |
*** ../vim-7.3.1060/runtime/doc/if_pyth.txt 2013-05-29 22:02:18.000000000 +0200
|
|
Karsten Hopp |
0fad6e |
--- runtime/doc/if_pyth.txt 2013-05-30 12:47:48.000000000 +0200
|
|
Karsten Hopp |
0fad6e |
***************
|
|
Karsten Hopp |
0fad6e |
*** 12,20 ****
|
|
Karsten Hopp |
0fad6e |
4. Range objects |python-range|
|
|
Karsten Hopp |
0fad6e |
5. Window objects |python-window|
|
|
Karsten Hopp |
0fad6e |
6. Tab page objects |python-tabpage|
|
|
Karsten Hopp |
0fad6e |
! 7. pyeval(), py3eval() Vim functions |python-pyeval|
|
|
Karsten Hopp |
0fad6e |
! 8. Dynamic loading |python-dynamic|
|
|
Karsten Hopp |
0fad6e |
! 9. Python 3 |python3|
|
|
Karsten Hopp |
0fad6e |
|
|
Karsten Hopp |
0fad6e |
{Vi does not have any of these commands}
|
|
Karsten Hopp |
0fad6e |
|
|
Karsten Hopp |
0fad6e |
--- 12,21 ----
|
|
Karsten Hopp |
0fad6e |
4. Range objects |python-range|
|
|
Karsten Hopp |
0fad6e |
5. Window objects |python-window|
|
|
Karsten Hopp |
0fad6e |
6. Tab page objects |python-tabpage|
|
|
Karsten Hopp |
0fad6e |
! 7. vim.bindeval objects |python-bindeval-objects|
|
|
Karsten Hopp |
0fad6e |
! 8. pyeval(), py3eval() Vim functions |python-pyeval|
|
|
Karsten Hopp |
0fad6e |
! 9. Dynamic loading |python-dynamic|
|
|
Karsten Hopp |
0fad6e |
! 10. Python 3 |python3|
|
|
Karsten Hopp |
0fad6e |
|
|
Karsten Hopp |
0fad6e |
{Vi does not have any of these commands}
|
|
Karsten Hopp |
0fad6e |
|
|
Karsten Hopp |
0fad6e |
***************
|
|
Karsten Hopp |
0fad6e |
*** 171,217 ****
|
|
Karsten Hopp |
0fad6e |
'eval_expr', 'kind': 'f', 'filename': './src/eval.c'}]
|
|
Karsten Hopp |
0fad6e |
|
|
Karsten Hopp |
0fad6e |
vim.bindeval(str) *python-bindeval*
|
|
Karsten Hopp |
0fad6e |
! Like |python-eval|, but
|
|
Karsten Hopp |
0fad6e |
! 1. if expression evaluates to |List| or |Dictionary| it is returned as
|
|
Karsten Hopp |
0fad6e |
! vimlist or vimdictionary python type that are connected to original
|
|
Karsten Hopp |
0fad6e |
! list or dictionary. Thus modifications to these objects imply
|
|
Karsten Hopp |
0fad6e |
! modifications of the original.
|
|
Karsten Hopp |
0fad6e |
!
|
|
Karsten Hopp |
0fad6e |
! Additionally, vim.List and vim.Dictionary type have read-write
|
|
Karsten Hopp |
0fad6e |
! `.locked` attribute that returns
|
|
Karsten Hopp |
0fad6e |
! Value Meaning ~
|
|
Karsten Hopp |
0fad6e |
! zero Variable is not locked
|
|
Karsten Hopp |
0fad6e |
! vim.VAR_LOCKED Variable is locked, but can be unlocked
|
|
Karsten Hopp |
0fad6e |
! vim.VAR_FIXED Variable is locked and can't be unlocked
|
|
Karsten Hopp |
0fad6e |
! integer constants. If variable is not fixed, you can do
|
|
Karsten Hopp |
0fad6e |
! `var.locked=True` to lock it and `var.locked=False` to unlock.
|
|
Karsten Hopp |
0fad6e |
! There is no recursive locking like |:lockvar|! does. There is also
|
|
Karsten Hopp |
0fad6e |
! no way to lock a specific key or check whether it is locked (in any
|
|
Karsten Hopp |
0fad6e |
! case these locks are ignored by anything except |:let|: |extend()|
|
|
Karsten Hopp |
0fad6e |
! does not care, neither does python interface).
|
|
Karsten Hopp |
0fad6e |
!
|
|
Karsten Hopp |
0fad6e |
! vim.Dictionary type also supports `.scope` attribute which is one
|
|
Karsten Hopp |
0fad6e |
! of
|
|
Karsten Hopp |
0fad6e |
! Value Meaning ~
|
|
Karsten Hopp |
0fad6e |
! zero Dictionary is not a scope one
|
|
Karsten Hopp |
0fad6e |
! vim.VAR_DEF_SCOPE Function-local or global scope dictionary
|
|
Karsten Hopp |
0fad6e |
! vim.VAR_SCOPE Other scope dictionary
|
|
Karsten Hopp |
0fad6e |
!
|
|
Karsten Hopp |
0fad6e |
! 2. if expression evaluates to a function reference, then it returns
|
|
Karsten Hopp |
0fad6e |
! callable vim.Function object. Use self keyword argument to assign
|
|
Karsten Hopp |
0fad6e |
! |self| object for dictionary functions.
|
|
Karsten Hopp |
0fad6e |
!
|
|
Karsten Hopp |
0fad6e |
! Note: this function has the same behavior as |lua-eval| (except that
|
|
Karsten Hopp |
0fad6e |
! lua does not support running vim functions), |python-eval| is
|
|
Karsten Hopp |
0fad6e |
! kept for backwards compatibility in order not to make scripts
|
|
Karsten Hopp |
0fad6e |
! relying on outputs of vim.eval() being a copy of original or
|
|
Karsten Hopp |
0fad6e |
! vim.eval("1") returning a string.
|
|
Karsten Hopp |
0fad6e |
!
|
|
Karsten Hopp |
0fad6e |
! You can use "List", "Dictionary" and "Function" vim module attributes
|
|
Karsten Hopp |
0fad6e |
! to test whether object has given type. These types are currently not
|
|
Karsten Hopp |
0fad6e |
! subclassable, neither they contain constructors, so you can use them
|
|
Karsten Hopp |
0fad6e |
! only for checks like `isinstance(obj, vim.List)`.
|
|
Karsten Hopp |
0fad6e |
!
|
|
Karsten Hopp |
0fad6e |
|
|
Karsten Hopp |
0fad6e |
Error object of the "vim" module
|
|
Karsten Hopp |
0fad6e |
|
|
Karsten Hopp |
0fad6e |
--- 172,180 ----
|
|
Karsten Hopp |
0fad6e |
'eval_expr', 'kind': 'f', 'filename': './src/eval.c'}]
|
|
Karsten Hopp |
0fad6e |
|
|
Karsten Hopp |
0fad6e |
vim.bindeval(str) *python-bindeval*
|
|
Karsten Hopp |
0fad6e |
! Like |python-eval|, but returns special objects described in
|
|
Karsten Hopp |
0fad6e |
! |python-bindeval-objects|. These python objects let you modify (|List|
|
|
Karsten Hopp |
0fad6e |
! or |Dictionary|) or call (|Funcref|) vim objecs.
|
|
Karsten Hopp |
0fad6e |
|
|
Karsten Hopp |
0fad6e |
Error object of the "vim" module
|
|
Karsten Hopp |
0fad6e |
|
|
Karsten Hopp |
0fad6e |
***************
|
|
Karsten Hopp |
0fad6e |
*** 497,509 ****
|
|
Karsten Hopp |
0fad6e |
TabPage object type is available using "TabPage" attribute of vim module.
|
|
Karsten Hopp |
0fad6e |
|
|
Karsten Hopp |
0fad6e |
==============================================================================
|
|
Karsten Hopp |
0fad6e |
! 7. pyeval() and py3eval() Vim functions *python-pyeval*
|
|
Karsten Hopp |
0fad6e |
|
|
Karsten Hopp |
0fad6e |
To facilitate bi-directional interface, you can use |pyeval()| and |py3eval()|
|
|
Karsten Hopp |
0fad6e |
functions to evaluate Python expressions and pass their values to VimL.
|
|
Karsten Hopp |
0fad6e |
|
|
Karsten Hopp |
0fad6e |
==============================================================================
|
|
Karsten Hopp |
0fad6e |
! 8. Dynamic loading *python-dynamic*
|
|
Karsten Hopp |
0fad6e |
|
|
Karsten Hopp |
0fad6e |
On MS-Windows the Python library can be loaded dynamically. The |:version|
|
|
Karsten Hopp |
0fad6e |
output then includes |+python/dyn|.
|
|
Karsten Hopp |
0fad6e |
--- 460,549 ----
|
|
Karsten Hopp |
0fad6e |
TabPage object type is available using "TabPage" attribute of vim module.
|
|
Karsten Hopp |
0fad6e |
|
|
Karsten Hopp |
0fad6e |
==============================================================================
|
|
Karsten Hopp |
0fad6e |
! 7. vim.bindeval objects *python-bindeval-objects*
|
|
Karsten Hopp |
0fad6e |
!
|
|
Karsten Hopp |
0fad6e |
! vim.Dictionary object *python-Dictionary*
|
|
Karsten Hopp |
0fad6e |
! Dictionary-like object providing access to vim |Dictionary| type.
|
|
Karsten Hopp |
0fad6e |
! Attributes:
|
|
Karsten Hopp |
0fad6e |
! Attribute Description ~
|
|
Karsten Hopp |
0fad6e |
! locked One of *python-.locked*
|
|
Karsten Hopp |
0fad6e |
! Value Description ~
|
|
Karsten Hopp |
0fad6e |
! zero Variable is not locked
|
|
Karsten Hopp |
0fad6e |
! vim.VAR_LOCKED Variable is locked, but can be unlocked
|
|
Karsten Hopp |
0fad6e |
! vim.VAR_FIXED Variable is locked and can't be unlocked
|
|
Karsten Hopp |
0fad6e |
! Read-write. You can unlock locked variable by assigning
|
|
Karsten Hopp |
0fad6e |
! `True` or `False` to this attribute. No recursive locking
|
|
Karsten Hopp |
0fad6e |
! is supported.
|
|
Karsten Hopp |
0fad6e |
! scope One of
|
|
Karsten Hopp |
0fad6e |
! Value Description ~
|
|
Karsten Hopp |
0fad6e |
! zero Dictionary is not a scope one
|
|
Karsten Hopp |
0fad6e |
! vim.VAR_DEF_SCOPE |g:| or |l:| dictionary
|
|
Karsten Hopp |
0fad6e |
! vim.VAR_SCOPE Other scope dictionary,
|
|
Karsten Hopp |
0fad6e |
! see |internal-variables|
|
|
Karsten Hopp |
0fad6e |
! Methods:
|
|
Karsten Hopp |
0fad6e |
! Method Description ~
|
|
Karsten Hopp |
0fad6e |
! keys() Returns a list with dictionary keys.
|
|
Karsten Hopp |
0fad6e |
! values() Returns a list with dictionary values.
|
|
Karsten Hopp |
0fad6e |
! items() Returns a list of 2-tuples with dictionary contents.
|
|
Karsten Hopp |
0fad6e |
! update(iterable)
|
|
Karsten Hopp |
0fad6e |
! update(dictionary)
|
|
Karsten Hopp |
0fad6e |
! update(**kwargs)
|
|
Karsten Hopp |
0fad6e |
! Adds keys to dictionary.
|
|
Karsten Hopp |
0fad6e |
! Examples: >
|
|
Karsten Hopp |
0fad6e |
! py d = vim.bindeval('{}')
|
|
Karsten Hopp |
0fad6e |
! d['a'] = 'b' # Item assignment
|
|
Karsten Hopp |
0fad6e |
! print d['a'] # getting item
|
|
Karsten Hopp |
0fad6e |
! d.update({'c': 'd'}) # .update(dictionary)
|
|
Karsten Hopp |
0fad6e |
! d.update(e='f') # .update(**kwargs)
|
|
Karsten Hopp |
0fad6e |
! d.update((('g', 'h'), ('i', 'j'))) # .update(iterable)
|
|
Karsten Hopp |
0fad6e |
! for key in d.keys(): # .keys()
|
|
Karsten Hopp |
0fad6e |
! for val in d.values(): # .values()
|
|
Karsten Hopp |
0fad6e |
! for key, val in d.items(): # .items()
|
|
Karsten Hopp |
0fad6e |
! print isinstance(d, vim.Dictionary) # True
|
|
Karsten Hopp |
0fad6e |
! for key in d: # Iteration over keys
|
|
Karsten Hopp |
0fad6e |
! <
|
|
Karsten Hopp |
0fad6e |
! Note: when iterating over keys you should not modify dictionary.
|
|
Karsten Hopp |
0fad6e |
!
|
|
Karsten Hopp |
0fad6e |
! vim.List object *python-List*
|
|
Karsten Hopp |
0fad6e |
! Sequence-like object providing access to vim |List| type.
|
|
Karsten Hopp |
0fad6e |
! Supports `.locked` attribute, see |python-.locked|. Also supports the
|
|
Karsten Hopp |
0fad6e |
! following methods:
|
|
Karsten Hopp |
0fad6e |
! Method Description ~
|
|
Karsten Hopp |
0fad6e |
! extend(item) Add items to the list.
|
|
Karsten Hopp |
0fad6e |
! Examples: >
|
|
Karsten Hopp |
0fad6e |
! l = vim.bindeval('[]')
|
|
Karsten Hopp |
0fad6e |
! l.extend(['abc', 'def']) # .extend() method
|
|
Karsten Hopp |
0fad6e |
! print l[1:] # slicing
|
|
Karsten Hopp |
0fad6e |
! l[:0] = ['ghi', 'jkl'] # slice assignment
|
|
Karsten Hopp |
0fad6e |
! print l[0] # getting item
|
|
Karsten Hopp |
0fad6e |
! l[0] = 'mno' # assignment
|
|
Karsten Hopp |
0fad6e |
! for i in l: # iteration
|
|
Karsten Hopp |
0fad6e |
! print isinstance(l, vim.List) # True
|
|
Karsten Hopp |
0fad6e |
!
|
|
Karsten Hopp |
0fad6e |
! vim.Function object *python-Function*
|
|
Karsten Hopp |
0fad6e |
! Function-like object, acting like vim |Funcref| object. Supports `.name`
|
|
Karsten Hopp |
0fad6e |
! attribute and is callable. Accepts special keyword argument `self`, see
|
|
Karsten Hopp |
0fad6e |
! |Dictionary-function|.
|
|
Karsten Hopp |
0fad6e |
! Examples: >
|
|
Karsten Hopp |
0fad6e |
! f = vim.bindeval('function("tr")')
|
|
Karsten Hopp |
0fad6e |
! print f('abc', 'a', 'b') # Calls tr('abc', 'a', 'b')
|
|
Karsten Hopp |
0fad6e |
! vim.command('''
|
|
Karsten Hopp |
0fad6e |
! function DictFun() dict
|
|
Karsten Hopp |
0fad6e |
! return self
|
|
Karsten Hopp |
0fad6e |
! endfunction
|
|
Karsten Hopp |
0fad6e |
! ''')
|
|
Karsten Hopp |
0fad6e |
! f = vim.bindeval('function("DictFun")')
|
|
Karsten Hopp |
0fad6e |
! print f(self={}) # Like call('DictFun', [], {})
|
|
Karsten Hopp |
0fad6e |
! print isinstance(f, vim.Function) # True
|
|
Karsten Hopp |
0fad6e |
!
|
|
Karsten Hopp |
0fad6e |
! ==============================================================================
|
|
Karsten Hopp |
0fad6e |
! 8. pyeval() and py3eval() Vim functions *python-pyeval*
|
|
Karsten Hopp |
0fad6e |
|
|
Karsten Hopp |
0fad6e |
To facilitate bi-directional interface, you can use |pyeval()| and |py3eval()|
|
|
Karsten Hopp |
0fad6e |
functions to evaluate Python expressions and pass their values to VimL.
|
|
Karsten Hopp |
0fad6e |
|
|
Karsten Hopp |
0fad6e |
==============================================================================
|
|
Karsten Hopp |
0fad6e |
! 9. Dynamic loading *python-dynamic*
|
|
Karsten Hopp |
0fad6e |
|
|
Karsten Hopp |
0fad6e |
On MS-Windows the Python library can be loaded dynamically. The |:version|
|
|
Karsten Hopp |
0fad6e |
output then includes |+python/dyn|.
|
|
Karsten Hopp |
0fad6e |
***************
|
|
Karsten Hopp |
0fad6e |
*** 520,526 ****
|
|
Karsten Hopp |
0fad6e |
sure edit "gvim.exe" and search for "python\d*.dll\c".
|
|
Karsten Hopp |
0fad6e |
|
|
Karsten Hopp |
0fad6e |
==============================================================================
|
|
Karsten Hopp |
0fad6e |
! 9. Python 3 *python3*
|
|
Karsten Hopp |
0fad6e |
|
|
Karsten Hopp |
0fad6e |
*:py3* *:python3*
|
|
Karsten Hopp |
0fad6e |
The `:py3` and `:python3` commands work similar to `:python`. A simple check
|
|
Karsten Hopp |
0fad6e |
--- 560,566 ----
|
|
Karsten Hopp |
0fad6e |
sure edit "gvim.exe" and search for "python\d*.dll\c".
|
|
Karsten Hopp |
0fad6e |
|
|
Karsten Hopp |
0fad6e |
==============================================================================
|
|
Karsten Hopp |
0fad6e |
! 10. Python 3 *python3*
|
|
Karsten Hopp |
0fad6e |
|
|
Karsten Hopp |
0fad6e |
*:py3* *:python3*
|
|
Karsten Hopp |
0fad6e |
The `:py3` and `:python3` commands work similar to `:python`. A simple check
|
|
Karsten Hopp |
0fad6e |
*** ../vim-7.3.1060/src/eval.c 2013-05-30 12:35:48.000000000 +0200
|
|
Karsten Hopp |
0fad6e |
--- src/eval.c 2013-05-30 12:52:11.000000000 +0200
|
|
Karsten Hopp |
0fad6e |
***************
|
|
Karsten Hopp |
0fad6e |
*** 10157,10162 ****
|
|
Karsten Hopp |
0fad6e |
--- 10157,10218 ----
|
|
Karsten Hopp |
0fad6e |
}
|
|
Karsten Hopp |
0fad6e |
|
|
Karsten Hopp |
0fad6e |
/*
|
|
Karsten Hopp |
0fad6e |
+ * Go over all entries in "d2" and add them to "d1".
|
|
Karsten Hopp |
0fad6e |
+ * When "action" is "error" then a duplicate key is an error.
|
|
Karsten Hopp |
0fad6e |
+ * When "action" is "force" then a duplicate key is overwritten.
|
|
Karsten Hopp |
0fad6e |
+ * Otherwise duplicate keys are ignored ("action" is "keep").
|
|
Karsten Hopp |
0fad6e |
+ */
|
|
Karsten Hopp |
0fad6e |
+ void
|
|
Karsten Hopp |
0fad6e |
+ dict_extend(d1, d2, action)
|
|
Karsten Hopp |
0fad6e |
+ dict_T *d1;
|
|
Karsten Hopp |
0fad6e |
+ dict_T *d2;
|
|
Karsten Hopp |
0fad6e |
+ char_u *action;
|
|
Karsten Hopp |
0fad6e |
+ {
|
|
Karsten Hopp |
0fad6e |
+ dictitem_T *di1;
|
|
Karsten Hopp |
0fad6e |
+ hashitem_T *hi2;
|
|
Karsten Hopp |
0fad6e |
+ int todo;
|
|
Karsten Hopp |
0fad6e |
+
|
|
Karsten Hopp |
0fad6e |
+ todo = (int)d2->dv_hashtab.ht_used;
|
|
Karsten Hopp |
0fad6e |
+ for (hi2 = d2->dv_hashtab.ht_array; todo > 0; ++hi2)
|
|
Karsten Hopp |
0fad6e |
+ {
|
|
Karsten Hopp |
0fad6e |
+ if (!HASHITEM_EMPTY(hi2))
|
|
Karsten Hopp |
0fad6e |
+ {
|
|
Karsten Hopp |
0fad6e |
+ --todo;
|
|
Karsten Hopp |
0fad6e |
+ di1 = dict_find(d1, hi2->hi_key, -1);
|
|
Karsten Hopp |
0fad6e |
+ if (d1->dv_scope != 0)
|
|
Karsten Hopp |
0fad6e |
+ {
|
|
Karsten Hopp |
0fad6e |
+ /* Disallow replacing a builtin function in l: and g:.
|
|
Karsten Hopp |
0fad6e |
+ * Check the key to be valid when adding to any
|
|
Karsten Hopp |
0fad6e |
+ * scope. */
|
|
Karsten Hopp |
0fad6e |
+ if (d1->dv_scope == VAR_DEF_SCOPE
|
|
Karsten Hopp |
0fad6e |
+ && HI2DI(hi2)->di_tv.v_type == VAR_FUNC
|
|
Karsten Hopp |
0fad6e |
+ && var_check_func_name(hi2->hi_key,
|
|
Karsten Hopp |
0fad6e |
+ di1 == NULL))
|
|
Karsten Hopp |
0fad6e |
+ break;
|
|
Karsten Hopp |
0fad6e |
+ if (!valid_varname(hi2->hi_key))
|
|
Karsten Hopp |
0fad6e |
+ break;
|
|
Karsten Hopp |
0fad6e |
+ }
|
|
Karsten Hopp |
0fad6e |
+ if (di1 == NULL)
|
|
Karsten Hopp |
0fad6e |
+ {
|
|
Karsten Hopp |
0fad6e |
+ di1 = dictitem_copy(HI2DI(hi2));
|
|
Karsten Hopp |
0fad6e |
+ if (di1 != NULL && dict_add(d1, di1) == FAIL)
|
|
Karsten Hopp |
0fad6e |
+ dictitem_free(di1);
|
|
Karsten Hopp |
0fad6e |
+ }
|
|
Karsten Hopp |
0fad6e |
+ else if (*action == 'e')
|
|
Karsten Hopp |
0fad6e |
+ {
|
|
Karsten Hopp |
0fad6e |
+ EMSG2(_("E737: Key already exists: %s"), hi2->hi_key);
|
|
Karsten Hopp |
0fad6e |
+ break;
|
|
Karsten Hopp |
0fad6e |
+ }
|
|
Karsten Hopp |
0fad6e |
+ else if (*action == 'f' && HI2DI(hi2) != di1)
|
|
Karsten Hopp |
0fad6e |
+ {
|
|
Karsten Hopp |
0fad6e |
+ clear_tv(&di1->di_tv);
|
|
Karsten Hopp |
0fad6e |
+ copy_tv(&HI2DI(hi2)->di_tv, &di1->di_tv);
|
|
Karsten Hopp |
0fad6e |
+ }
|
|
Karsten Hopp |
0fad6e |
+ }
|
|
Karsten Hopp |
0fad6e |
+ }
|
|
Karsten Hopp |
0fad6e |
+ }
|
|
Karsten Hopp |
0fad6e |
+
|
|
Karsten Hopp |
0fad6e |
+ /*
|
|
Karsten Hopp |
0fad6e |
* "extend(list, list [, idx])" function
|
|
Karsten Hopp |
0fad6e |
* "extend(dict, dict [, action])" function
|
|
Karsten Hopp |
0fad6e |
*/
|
|
Karsten Hopp |
0fad6e |
***************
|
|
Karsten Hopp |
0fad6e |
*** 10206,10217 ****
|
|
Karsten Hopp |
0fad6e |
}
|
|
Karsten Hopp |
0fad6e |
else if (argvars[0].v_type == VAR_DICT && argvars[1].v_type == VAR_DICT)
|
|
Karsten Hopp |
0fad6e |
{
|
|
Karsten Hopp |
0fad6e |
! dict_T *d1, *d2;
|
|
Karsten Hopp |
0fad6e |
! dictitem_T *di1;
|
|
Karsten Hopp |
0fad6e |
! char_u *action;
|
|
Karsten Hopp |
0fad6e |
! int i;
|
|
Karsten Hopp |
0fad6e |
! hashitem_T *hi2;
|
|
Karsten Hopp |
0fad6e |
! int todo;
|
|
Karsten Hopp |
0fad6e |
|
|
Karsten Hopp |
0fad6e |
d1 = argvars[0].vval.v_dict;
|
|
Karsten Hopp |
0fad6e |
d2 = argvars[1].vval.v_dict;
|
|
Karsten Hopp |
0fad6e |
--- 10262,10270 ----
|
|
Karsten Hopp |
0fad6e |
}
|
|
Karsten Hopp |
0fad6e |
else if (argvars[0].v_type == VAR_DICT && argvars[1].v_type == VAR_DICT)
|
|
Karsten Hopp |
0fad6e |
{
|
|
Karsten Hopp |
0fad6e |
! dict_T *d1, *d2;
|
|
Karsten Hopp |
0fad6e |
! char_u *action;
|
|
Karsten Hopp |
0fad6e |
! int i;
|
|
Karsten Hopp |
0fad6e |
|
|
Karsten Hopp |
0fad6e |
d1 = argvars[0].vval.v_dict;
|
|
Karsten Hopp |
0fad6e |
d2 = argvars[1].vval.v_dict;
|
|
Karsten Hopp |
0fad6e |
***************
|
|
Karsten Hopp |
0fad6e |
*** 10238,10283 ****
|
|
Karsten Hopp |
0fad6e |
else
|
|
Karsten Hopp |
0fad6e |
action = (char_u *)"force";
|
|
Karsten Hopp |
0fad6e |
|
|
Karsten Hopp |
0fad6e |
! /* Go over all entries in the second dict and add them to the
|
|
Karsten Hopp |
0fad6e |
! * first dict. */
|
|
Karsten Hopp |
0fad6e |
! todo = (int)d2->dv_hashtab.ht_used;
|
|
Karsten Hopp |
0fad6e |
! for (hi2 = d2->dv_hashtab.ht_array; todo > 0; ++hi2)
|
|
Karsten Hopp |
0fad6e |
! {
|
|
Karsten Hopp |
0fad6e |
! if (!HASHITEM_EMPTY(hi2))
|
|
Karsten Hopp |
0fad6e |
! {
|
|
Karsten Hopp |
0fad6e |
! --todo;
|
|
Karsten Hopp |
0fad6e |
! di1 = dict_find(d1, hi2->hi_key, -1);
|
|
Karsten Hopp |
0fad6e |
! if (d1->dv_scope != 0)
|
|
Karsten Hopp |
0fad6e |
! {
|
|
Karsten Hopp |
0fad6e |
! /* Disallow replacing a builtin function in l: and g:.
|
|
Karsten Hopp |
0fad6e |
! * Check the key to be valid when adding to any
|
|
Karsten Hopp |
0fad6e |
! * scope. */
|
|
Karsten Hopp |
0fad6e |
! if (d1->dv_scope == VAR_DEF_SCOPE
|
|
Karsten Hopp |
0fad6e |
! && HI2DI(hi2)->di_tv.v_type == VAR_FUNC
|
|
Karsten Hopp |
0fad6e |
! && var_check_func_name(hi2->hi_key,
|
|
Karsten Hopp |
0fad6e |
! di1 == NULL))
|
|
Karsten Hopp |
0fad6e |
! break;
|
|
Karsten Hopp |
0fad6e |
! if (!valid_varname(hi2->hi_key))
|
|
Karsten Hopp |
0fad6e |
! break;
|
|
Karsten Hopp |
0fad6e |
! }
|
|
Karsten Hopp |
0fad6e |
! if (di1 == NULL)
|
|
Karsten Hopp |
0fad6e |
! {
|
|
Karsten Hopp |
0fad6e |
! di1 = dictitem_copy(HI2DI(hi2));
|
|
Karsten Hopp |
0fad6e |
! if (di1 != NULL && dict_add(d1, di1) == FAIL)
|
|
Karsten Hopp |
0fad6e |
! dictitem_free(di1);
|
|
Karsten Hopp |
0fad6e |
! }
|
|
Karsten Hopp |
0fad6e |
! else if (*action == 'e')
|
|
Karsten Hopp |
0fad6e |
! {
|
|
Karsten Hopp |
0fad6e |
! EMSG2(_("E737: Key already exists: %s"), hi2->hi_key);
|
|
Karsten Hopp |
0fad6e |
! break;
|
|
Karsten Hopp |
0fad6e |
! }
|
|
Karsten Hopp |
0fad6e |
! else if (*action == 'f' && HI2DI(hi2) != di1)
|
|
Karsten Hopp |
0fad6e |
! {
|
|
Karsten Hopp |
0fad6e |
! clear_tv(&di1->di_tv);
|
|
Karsten Hopp |
0fad6e |
! copy_tv(&HI2DI(hi2)->di_tv, &di1->di_tv);
|
|
Karsten Hopp |
0fad6e |
! }
|
|
Karsten Hopp |
0fad6e |
! }
|
|
Karsten Hopp |
0fad6e |
! }
|
|
Karsten Hopp |
0fad6e |
|
|
Karsten Hopp |
0fad6e |
copy_tv(&argvars[0], rettv);
|
|
Karsten Hopp |
0fad6e |
}
|
|
Karsten Hopp |
0fad6e |
--- 10291,10297 ----
|
|
Karsten Hopp |
0fad6e |
else
|
|
Karsten Hopp |
0fad6e |
action = (char_u *)"force";
|
|
Karsten Hopp |
0fad6e |
|
|
Karsten Hopp |
0fad6e |
! dict_extend(d1, d2, action);
|
|
Karsten Hopp |
0fad6e |
|
|
Karsten Hopp |
0fad6e |
copy_tv(&argvars[0], rettv);
|
|
Karsten Hopp |
0fad6e |
}
|
|
Karsten Hopp |
0fad6e |
*** ../vim-7.3.1060/src/if_py_both.h 2013-05-30 12:43:50.000000000 +0200
|
|
Karsten Hopp |
0fad6e |
--- src/if_py_both.h 2013-05-30 12:52:42.000000000 +0200
|
|
Karsten Hopp |
0fad6e |
***************
|
|
Karsten Hopp |
0fad6e |
*** 31,37 ****
|
|
Karsten Hopp |
0fad6e |
#define INVALID_TABPAGE_VALUE ((tabpage_T *)(-1))
|
|
Karsten Hopp |
0fad6e |
|
|
Karsten Hopp |
0fad6e |
#define DICTKEY_DECL \
|
|
Karsten Hopp |
0fad6e |
! PyObject *dictkey_todecref;
|
|
Karsten Hopp |
0fad6e |
#define DICTKEY_CHECK_EMPTY(err) \
|
|
Karsten Hopp |
0fad6e |
if (*key == NUL) \
|
|
Karsten Hopp |
0fad6e |
{ \
|
|
Karsten Hopp |
0fad6e |
--- 31,37 ----
|
|
Karsten Hopp |
0fad6e |
#define INVALID_TABPAGE_VALUE ((tabpage_T *)(-1))
|
|
Karsten Hopp |
0fad6e |
|
|
Karsten Hopp |
0fad6e |
#define DICTKEY_DECL \
|
|
Karsten Hopp |
0fad6e |
! PyObject *dictkey_todecref = NULL;
|
|
Karsten Hopp |
0fad6e |
#define DICTKEY_CHECK_EMPTY(err) \
|
|
Karsten Hopp |
0fad6e |
if (*key == NUL) \
|
|
Karsten Hopp |
0fad6e |
{ \
|
|
Karsten Hopp |
0fad6e |
***************
|
|
Karsten Hopp |
0fad6e |
*** 63,68 ****
|
|
Karsten Hopp |
0fad6e |
--- 63,69 ----
|
|
Karsten Hopp |
0fad6e |
|
|
Karsten Hopp |
0fad6e |
static int ConvertFromPyObject(PyObject *, typval_T *);
|
|
Karsten Hopp |
0fad6e |
static int _ConvertFromPyObject(PyObject *, typval_T *, PyObject *);
|
|
Karsten Hopp |
0fad6e |
+ static int ConvertFromPyMapping(PyObject *, typval_T *);
|
|
Karsten Hopp |
0fad6e |
static PyObject *WindowNew(win_T *, tabpage_T *);
|
|
Karsten Hopp |
0fad6e |
static PyObject *BufferNew (buf_T *);
|
|
Karsten Hopp |
0fad6e |
static PyObject *LineToString(const char *);
|
|
Karsten Hopp |
0fad6e |
***************
|
|
Karsten Hopp |
0fad6e |
*** 877,888 ****
|
|
Karsten Hopp |
0fad6e |
pylinkedlist_T ref;
|
|
Karsten Hopp |
0fad6e |
} DictionaryObject;
|
|
Karsten Hopp |
0fad6e |
|
|
Karsten Hopp |
0fad6e |
static PyObject *
|
|
Karsten Hopp |
0fad6e |
! DictionaryNew(dict_T *dict)
|
|
Karsten Hopp |
0fad6e |
{
|
|
Karsten Hopp |
0fad6e |
DictionaryObject *self;
|
|
Karsten Hopp |
0fad6e |
|
|
Karsten Hopp |
0fad6e |
! self = PyObject_NEW(DictionaryObject, &DictionaryType);
|
|
Karsten Hopp |
0fad6e |
if (self == NULL)
|
|
Karsten Hopp |
0fad6e |
return NULL;
|
|
Karsten Hopp |
0fad6e |
self->dict = dict;
|
|
Karsten Hopp |
0fad6e |
--- 878,893 ----
|
|
Karsten Hopp |
0fad6e |
pylinkedlist_T ref;
|
|
Karsten Hopp |
0fad6e |
} DictionaryObject;
|
|
Karsten Hopp |
0fad6e |
|
|
Karsten Hopp |
0fad6e |
+ static PyObject *DictionaryUpdate(DictionaryObject *, PyObject *, PyObject *);
|
|
Karsten Hopp |
0fad6e |
+
|
|
Karsten Hopp |
0fad6e |
+ #define NEW_DICTIONARY(dict) DictionaryNew(&DictionaryType, dict)
|
|
Karsten Hopp |
0fad6e |
+
|
|
Karsten Hopp |
0fad6e |
static PyObject *
|
|
Karsten Hopp |
0fad6e |
! DictionaryNew(PyTypeObject *subtype, dict_T *dict)
|
|
Karsten Hopp |
0fad6e |
{
|
|
Karsten Hopp |
0fad6e |
DictionaryObject *self;
|
|
Karsten Hopp |
0fad6e |
|
|
Karsten Hopp |
0fad6e |
! self = (DictionaryObject *) subtype->tp_alloc(subtype, 0);
|
|
Karsten Hopp |
0fad6e |
if (self == NULL)
|
|
Karsten Hopp |
0fad6e |
return NULL;
|
|
Karsten Hopp |
0fad6e |
self->dict = dict;
|
|
Karsten Hopp |
0fad6e |
***************
|
|
Karsten Hopp |
0fad6e |
*** 893,898 ****
|
|
Karsten Hopp |
0fad6e |
--- 898,946 ----
|
|
Karsten Hopp |
0fad6e |
return (PyObject *)(self);
|
|
Karsten Hopp |
0fad6e |
}
|
|
Karsten Hopp |
0fad6e |
|
|
Karsten Hopp |
0fad6e |
+ static dict_T *
|
|
Karsten Hopp |
0fad6e |
+ py_dict_alloc()
|
|
Karsten Hopp |
0fad6e |
+ {
|
|
Karsten Hopp |
0fad6e |
+ dict_T *r;
|
|
Karsten Hopp |
0fad6e |
+
|
|
Karsten Hopp |
0fad6e |
+ if (!(r = dict_alloc()))
|
|
Karsten Hopp |
0fad6e |
+ {
|
|
Karsten Hopp |
0fad6e |
+ PyErr_NoMemory();
|
|
Karsten Hopp |
0fad6e |
+ return NULL;
|
|
Karsten Hopp |
0fad6e |
+ }
|
|
Karsten Hopp |
0fad6e |
+ ++r->dv_refcount;
|
|
Karsten Hopp |
0fad6e |
+
|
|
Karsten Hopp |
0fad6e |
+ return r;
|
|
Karsten Hopp |
0fad6e |
+ }
|
|
Karsten Hopp |
0fad6e |
+
|
|
Karsten Hopp |
0fad6e |
+ static PyObject *
|
|
Karsten Hopp |
0fad6e |
+ DictionaryConstructor(PyTypeObject *subtype, PyObject *args, PyObject *kwargs)
|
|
Karsten Hopp |
0fad6e |
+ {
|
|
Karsten Hopp |
0fad6e |
+ DictionaryObject *self;
|
|
Karsten Hopp |
0fad6e |
+ dict_T *dict;
|
|
Karsten Hopp |
0fad6e |
+
|
|
Karsten Hopp |
0fad6e |
+ if (!(dict = py_dict_alloc()))
|
|
Karsten Hopp |
0fad6e |
+ return NULL;
|
|
Karsten Hopp |
0fad6e |
+
|
|
Karsten Hopp |
0fad6e |
+ self = (DictionaryObject *) DictionaryNew(subtype, dict);
|
|
Karsten Hopp |
0fad6e |
+
|
|
Karsten Hopp |
0fad6e |
+ --dict->dv_refcount;
|
|
Karsten Hopp |
0fad6e |
+
|
|
Karsten Hopp |
0fad6e |
+ if (kwargs || PyTuple_Size(args))
|
|
Karsten Hopp |
0fad6e |
+ {
|
|
Karsten Hopp |
0fad6e |
+ PyObject *tmp;
|
|
Karsten Hopp |
0fad6e |
+ if (!(tmp = DictionaryUpdate(self, args, kwargs)))
|
|
Karsten Hopp |
0fad6e |
+ {
|
|
Karsten Hopp |
0fad6e |
+ Py_DECREF(self);
|
|
Karsten Hopp |
0fad6e |
+ return NULL;
|
|
Karsten Hopp |
0fad6e |
+ }
|
|
Karsten Hopp |
0fad6e |
+
|
|
Karsten Hopp |
0fad6e |
+ Py_DECREF(tmp);
|
|
Karsten Hopp |
0fad6e |
+ }
|
|
Karsten Hopp |
0fad6e |
+
|
|
Karsten Hopp |
0fad6e |
+ return (PyObject *)(self);
|
|
Karsten Hopp |
0fad6e |
+ }
|
|
Karsten Hopp |
0fad6e |
+
|
|
Karsten Hopp |
0fad6e |
static void
|
|
Karsten Hopp |
0fad6e |
DictionaryDestructor(DictionaryObject *self)
|
|
Karsten Hopp |
0fad6e |
{
|
|
Karsten Hopp |
0fad6e |
***************
|
|
Karsten Hopp |
0fad6e |
*** 918,924 ****
|
|
Karsten Hopp |
0fad6e |
{
|
|
Karsten Hopp |
0fad6e |
if (val == NULL)
|
|
Karsten Hopp |
0fad6e |
{
|
|
Karsten Hopp |
0fad6e |
! PyErr_SetString(PyExc_AttributeError, _("Cannot delete DictionaryObject attributes"));
|
|
Karsten Hopp |
0fad6e |
return -1;
|
|
Karsten Hopp |
0fad6e |
}
|
|
Karsten Hopp |
0fad6e |
|
|
Karsten Hopp |
0fad6e |
--- 966,973 ----
|
|
Karsten Hopp |
0fad6e |
{
|
|
Karsten Hopp |
0fad6e |
if (val == NULL)
|
|
Karsten Hopp |
0fad6e |
{
|
|
Karsten Hopp |
0fad6e |
! PyErr_SetString(PyExc_AttributeError,
|
|
Karsten Hopp |
0fad6e |
! _("cannot delete vim.Dictionary attributes"));
|
|
Karsten Hopp |
0fad6e |
return -1;
|
|
Karsten Hopp |
0fad6e |
}
|
|
Karsten Hopp |
0fad6e |
|
|
Karsten Hopp |
0fad6e |
***************
|
|
Karsten Hopp |
0fad6e |
*** 926,932 ****
|
|
Karsten Hopp |
0fad6e |
{
|
|
Karsten Hopp |
0fad6e |
if (self->dict->dv_lock == VAR_FIXED)
|
|
Karsten Hopp |
0fad6e |
{
|
|
Karsten Hopp |
0fad6e |
! PyErr_SetString(PyExc_TypeError, _("Cannot modify fixed dictionary"));
|
|
Karsten Hopp |
0fad6e |
return -1;
|
|
Karsten Hopp |
0fad6e |
}
|
|
Karsten Hopp |
0fad6e |
else
|
|
Karsten Hopp |
0fad6e |
--- 975,981 ----
|
|
Karsten Hopp |
0fad6e |
{
|
|
Karsten Hopp |
0fad6e |
if (self->dict->dv_lock == VAR_FIXED)
|
|
Karsten Hopp |
0fad6e |
{
|
|
Karsten Hopp |
0fad6e |
! PyErr_SetString(PyExc_TypeError, _("cannot modify fixed dictionary"));
|
|
Karsten Hopp |
0fad6e |
return -1;
|
|
Karsten Hopp |
0fad6e |
}
|
|
Karsten Hopp |
0fad6e |
else
|
|
Karsten Hopp |
0fad6e |
***************
|
|
Karsten Hopp |
0fad6e |
*** 943,949 ****
|
|
Karsten Hopp |
0fad6e |
}
|
|
Karsten Hopp |
0fad6e |
else
|
|
Karsten Hopp |
0fad6e |
{
|
|
Karsten Hopp |
0fad6e |
! PyErr_SetString(PyExc_AttributeError, _("Cannot set this attribute"));
|
|
Karsten Hopp |
0fad6e |
return -1;
|
|
Karsten Hopp |
0fad6e |
}
|
|
Karsten Hopp |
0fad6e |
}
|
|
Karsten Hopp |
0fad6e |
--- 992,998 ----
|
|
Karsten Hopp |
0fad6e |
}
|
|
Karsten Hopp |
0fad6e |
else
|
|
Karsten Hopp |
0fad6e |
{
|
|
Karsten Hopp |
0fad6e |
! PyErr_SetString(PyExc_AttributeError, _("cannot set this attribute"));
|
|
Karsten Hopp |
0fad6e |
return -1;
|
|
Karsten Hopp |
0fad6e |
}
|
|
Karsten Hopp |
0fad6e |
}
|
|
Karsten Hopp |
0fad6e |
***************
|
|
Karsten Hopp |
0fad6e |
*** 954,979 ****
|
|
Karsten Hopp |
0fad6e |
return ((PyInt) (self->dict->dv_hashtab.ht_used));
|
|
Karsten Hopp |
0fad6e |
}
|
|
Karsten Hopp |
0fad6e |
|
|
Karsten Hopp |
0fad6e |
static PyObject *
|
|
Karsten Hopp |
0fad6e |
! DictionaryItem(DictionaryObject *self, PyObject *keyObject)
|
|
Karsten Hopp |
0fad6e |
{
|
|
Karsten Hopp |
0fad6e |
char_u *key;
|
|
Karsten Hopp |
0fad6e |
dictitem_T *di;
|
|
Karsten Hopp |
0fad6e |
DICTKEY_DECL
|
|
Karsten Hopp |
0fad6e |
|
|
Karsten Hopp |
0fad6e |
DICTKEY_GET(NULL, 0)
|
|
Karsten Hopp |
0fad6e |
|
|
Karsten Hopp |
0fad6e |
! di = dict_find(self->dict, key, -1);
|
|
Karsten Hopp |
0fad6e |
|
|
Karsten Hopp |
0fad6e |
DICTKEY_UNREF
|
|
Karsten Hopp |
0fad6e |
|
|
Karsten Hopp |
0fad6e |
! if (di == NULL)
|
|
Karsten Hopp |
0fad6e |
{
|
|
Karsten Hopp |
0fad6e |
! PyErr_SetObject(PyExc_KeyError, keyObject);
|
|
Karsten Hopp |
0fad6e |
return NULL;
|
|
Karsten Hopp |
0fad6e |
}
|
|
Karsten Hopp |
0fad6e |
|
|
Karsten Hopp |
0fad6e |
! return ConvertToPyObject(&di->di_tv);
|
|
Karsten Hopp |
0fad6e |
}
|
|
Karsten Hopp |
0fad6e |
|
|
Karsten Hopp |
0fad6e |
static PyInt
|
|
Karsten Hopp |
0fad6e |
--- 1003,1172 ----
|
|
Karsten Hopp |
0fad6e |
return ((PyInt) (self->dict->dv_hashtab.ht_used));
|
|
Karsten Hopp |
0fad6e |
}
|
|
Karsten Hopp |
0fad6e |
|
|
Karsten Hopp |
0fad6e |
+ #define DICT_FLAG_HAS_DEFAULT 0x01
|
|
Karsten Hopp |
0fad6e |
+ #define DICT_FLAG_POP 0x02
|
|
Karsten Hopp |
0fad6e |
+ #define DICT_FLAG_NONE_DEFAULT 0x04
|
|
Karsten Hopp |
0fad6e |
+ #define DICT_FLAG_RETURN_BOOL 0x08 /* Incompatible with DICT_FLAG_POP */
|
|
Karsten Hopp |
0fad6e |
+ #define DICT_FLAG_RETURN_PAIR 0x10
|
|
Karsten Hopp |
0fad6e |
+
|
|
Karsten Hopp |
0fad6e |
static PyObject *
|
|
Karsten Hopp |
0fad6e |
! _DictionaryItem(DictionaryObject *self, PyObject *args, int flags)
|
|
Karsten Hopp |
0fad6e |
{
|
|
Karsten Hopp |
0fad6e |
+ PyObject *keyObject;
|
|
Karsten Hopp |
0fad6e |
+ PyObject *defObject = ((flags & DICT_FLAG_NONE_DEFAULT)? Py_None : NULL);
|
|
Karsten Hopp |
0fad6e |
+ PyObject *r;
|
|
Karsten Hopp |
0fad6e |
char_u *key;
|
|
Karsten Hopp |
0fad6e |
dictitem_T *di;
|
|
Karsten Hopp |
0fad6e |
+ dict_T *dict = self->dict;
|
|
Karsten Hopp |
0fad6e |
+ hashitem_T *hi;
|
|
Karsten Hopp |
0fad6e |
+
|
|
Karsten Hopp |
0fad6e |
DICTKEY_DECL
|
|
Karsten Hopp |
0fad6e |
|
|
Karsten Hopp |
0fad6e |
+ if (flags & DICT_FLAG_HAS_DEFAULT)
|
|
Karsten Hopp |
0fad6e |
+ {
|
|
Karsten Hopp |
0fad6e |
+ if (!PyArg_ParseTuple(args, "O|O", &keyObject, &defObject))
|
|
Karsten Hopp |
0fad6e |
+ return NULL;
|
|
Karsten Hopp |
0fad6e |
+ }
|
|
Karsten Hopp |
0fad6e |
+ else
|
|
Karsten Hopp |
0fad6e |
+ keyObject = args;
|
|
Karsten Hopp |
0fad6e |
+
|
|
Karsten Hopp |
0fad6e |
+ if (flags & DICT_FLAG_RETURN_BOOL)
|
|
Karsten Hopp |
0fad6e |
+ defObject = Py_False;
|
|
Karsten Hopp |
0fad6e |
+
|
|
Karsten Hopp |
0fad6e |
DICTKEY_GET(NULL, 0)
|
|
Karsten Hopp |
0fad6e |
|
|
Karsten Hopp |
0fad6e |
! hi = hash_find(&dict->dv_hashtab, key);
|
|
Karsten Hopp |
0fad6e |
|
|
Karsten Hopp |
0fad6e |
DICTKEY_UNREF
|
|
Karsten Hopp |
0fad6e |
|
|
Karsten Hopp |
0fad6e |
! if (HASHITEM_EMPTY(hi))
|
|
Karsten Hopp |
0fad6e |
{
|
|
Karsten Hopp |
0fad6e |
! if (defObject)
|
|
Karsten Hopp |
0fad6e |
! {
|
|
Karsten Hopp |
0fad6e |
! Py_INCREF(defObject);
|
|
Karsten Hopp |
0fad6e |
! return defObject;
|
|
Karsten Hopp |
0fad6e |
! }
|
|
Karsten Hopp |
0fad6e |
! else
|
|
Karsten Hopp |
0fad6e |
! {
|
|
Karsten Hopp |
0fad6e |
! PyErr_SetObject(PyExc_KeyError, keyObject);
|
|
Karsten Hopp |
0fad6e |
! return NULL;
|
|
Karsten Hopp |
0fad6e |
! }
|
|
Karsten Hopp |
0fad6e |
! }
|
|
Karsten Hopp |
0fad6e |
! else if (flags & DICT_FLAG_RETURN_BOOL)
|
|
Karsten Hopp |
0fad6e |
! {
|
|
Karsten Hopp |
0fad6e |
! Py_INCREF(Py_True);
|
|
Karsten Hopp |
0fad6e |
! return Py_True;
|
|
Karsten Hopp |
0fad6e |
! }
|
|
Karsten Hopp |
0fad6e |
!
|
|
Karsten Hopp |
0fad6e |
! di = dict_lookup(hi);
|
|
Karsten Hopp |
0fad6e |
!
|
|
Karsten Hopp |
0fad6e |
! if (!(r = ConvertToPyObject(&di->di_tv)))
|
|
Karsten Hopp |
0fad6e |
return NULL;
|
|
Karsten Hopp |
0fad6e |
+
|
|
Karsten Hopp |
0fad6e |
+ if (flags & DICT_FLAG_POP)
|
|
Karsten Hopp |
0fad6e |
+ {
|
|
Karsten Hopp |
0fad6e |
+ if (dict->dv_lock)
|
|
Karsten Hopp |
0fad6e |
+ {
|
|
Karsten Hopp |
0fad6e |
+ PyErr_SetVim(_("dict is locked"));
|
|
Karsten Hopp |
0fad6e |
+ Py_DECREF(r);
|
|
Karsten Hopp |
0fad6e |
+ return NULL;
|
|
Karsten Hopp |
0fad6e |
+ }
|
|
Karsten Hopp |
0fad6e |
+
|
|
Karsten Hopp |
0fad6e |
+ hash_remove(&dict->dv_hashtab, hi);
|
|
Karsten Hopp |
0fad6e |
+ dictitem_free(di);
|
|
Karsten Hopp |
0fad6e |
}
|
|
Karsten Hopp |
0fad6e |
|
|
Karsten Hopp |
0fad6e |
! if (flags & DICT_FLAG_RETURN_PAIR)
|
|
Karsten Hopp |
0fad6e |
! {
|
|
Karsten Hopp |
0fad6e |
! PyObject *tmp = r;
|
|
Karsten Hopp |
0fad6e |
!
|
|
Karsten Hopp |
0fad6e |
! if (!(r = Py_BuildValue("(" Py_bytes_fmt "O)", hi->hi_key, tmp)))
|
|
Karsten Hopp |
0fad6e |
! {
|
|
Karsten Hopp |
0fad6e |
! Py_DECREF(tmp);
|
|
Karsten Hopp |
0fad6e |
! return NULL;
|
|
Karsten Hopp |
0fad6e |
! }
|
|
Karsten Hopp |
0fad6e |
! }
|
|
Karsten Hopp |
0fad6e |
!
|
|
Karsten Hopp |
0fad6e |
! return r;
|
|
Karsten Hopp |
0fad6e |
! }
|
|
Karsten Hopp |
0fad6e |
!
|
|
Karsten Hopp |
0fad6e |
! static PyObject *
|
|
Karsten Hopp |
0fad6e |
! DictionaryItem(DictionaryObject *self, PyObject *keyObject)
|
|
Karsten Hopp |
0fad6e |
! {
|
|
Karsten Hopp |
0fad6e |
! return _DictionaryItem(self, keyObject, 0);
|
|
Karsten Hopp |
0fad6e |
! }
|
|
Karsten Hopp |
0fad6e |
!
|
|
Karsten Hopp |
0fad6e |
! static int
|
|
Karsten Hopp |
0fad6e |
! DictionaryContains(DictionaryObject *self, PyObject *keyObject)
|
|
Karsten Hopp |
0fad6e |
! {
|
|
Karsten Hopp |
0fad6e |
! PyObject *rObj = _DictionaryItem(self, keyObject, DICT_FLAG_RETURN_BOOL);
|
|
Karsten Hopp |
0fad6e |
! int r;
|
|
Karsten Hopp |
0fad6e |
!
|
|
Karsten Hopp |
0fad6e |
! r = (rObj == Py_True);
|
|
Karsten Hopp |
0fad6e |
!
|
|
Karsten Hopp |
0fad6e |
! Py_DECREF(Py_True);
|
|
Karsten Hopp |
0fad6e |
!
|
|
Karsten Hopp |
0fad6e |
! return r;
|
|
Karsten Hopp |
0fad6e |
! }
|
|
Karsten Hopp |
0fad6e |
!
|
|
Karsten Hopp |
0fad6e |
! typedef struct
|
|
Karsten Hopp |
0fad6e |
! {
|
|
Karsten Hopp |
0fad6e |
! hashitem_T *ht_array;
|
|
Karsten Hopp |
0fad6e |
! long_u ht_used;
|
|
Karsten Hopp |
0fad6e |
! hashtab_T *ht;
|
|
Karsten Hopp |
0fad6e |
! hashitem_T *hi;
|
|
Karsten Hopp |
0fad6e |
! int todo;
|
|
Karsten Hopp |
0fad6e |
! } dictiterinfo_T;
|
|
Karsten Hopp |
0fad6e |
!
|
|
Karsten Hopp |
0fad6e |
! static PyObject *
|
|
Karsten Hopp |
0fad6e |
! DictionaryIterNext(dictiterinfo_T **dii)
|
|
Karsten Hopp |
0fad6e |
! {
|
|
Karsten Hopp |
0fad6e |
! PyObject *r;
|
|
Karsten Hopp |
0fad6e |
!
|
|
Karsten Hopp |
0fad6e |
! if (!(*dii)->todo)
|
|
Karsten Hopp |
0fad6e |
! return NULL;
|
|
Karsten Hopp |
0fad6e |
!
|
|
Karsten Hopp |
0fad6e |
! if ((*dii)->ht->ht_array != (*dii)->ht_array ||
|
|
Karsten Hopp |
0fad6e |
! (*dii)->ht->ht_used != (*dii)->ht_used)
|
|
Karsten Hopp |
0fad6e |
! {
|
|
Karsten Hopp |
0fad6e |
! PyErr_SetString(PyExc_RuntimeError,
|
|
Karsten Hopp |
0fad6e |
! _("hashtab changed during iteration"));
|
|
Karsten Hopp |
0fad6e |
! return NULL;
|
|
Karsten Hopp |
0fad6e |
! }
|
|
Karsten Hopp |
0fad6e |
!
|
|
Karsten Hopp |
0fad6e |
! while (((*dii)->todo) && HASHITEM_EMPTY((*dii)->hi))
|
|
Karsten Hopp |
0fad6e |
! ++((*dii)->hi);
|
|
Karsten Hopp |
0fad6e |
!
|
|
Karsten Hopp |
0fad6e |
! --((*dii)->todo);
|
|
Karsten Hopp |
0fad6e |
!
|
|
Karsten Hopp |
0fad6e |
! if (!(r = PyBytes_FromString((char *) (*dii)->hi->hi_key)))
|
|
Karsten Hopp |
0fad6e |
! return NULL;
|
|
Karsten Hopp |
0fad6e |
!
|
|
Karsten Hopp |
0fad6e |
! return r;
|
|
Karsten Hopp |
0fad6e |
! }
|
|
Karsten Hopp |
0fad6e |
!
|
|
Karsten Hopp |
0fad6e |
! static PyObject *
|
|
Karsten Hopp |
0fad6e |
! DictionaryIter(DictionaryObject *self)
|
|
Karsten Hopp |
0fad6e |
! {
|
|
Karsten Hopp |
0fad6e |
! dictiterinfo_T *dii;
|
|
Karsten Hopp |
0fad6e |
! hashtab_T *ht;
|
|
Karsten Hopp |
0fad6e |
!
|
|
Karsten Hopp |
0fad6e |
! if (!(dii = PyMem_New(dictiterinfo_T, 1)))
|
|
Karsten Hopp |
0fad6e |
! {
|
|
Karsten Hopp |
0fad6e |
! PyErr_NoMemory();
|
|
Karsten Hopp |
0fad6e |
! return NULL;
|
|
Karsten Hopp |
0fad6e |
! }
|
|
Karsten Hopp |
0fad6e |
!
|
|
Karsten Hopp |
0fad6e |
! ht = &self->dict->dv_hashtab;
|
|
Karsten Hopp |
0fad6e |
! dii->ht_array = ht->ht_array;
|
|
Karsten Hopp |
0fad6e |
! dii->ht_used = ht->ht_used;
|
|
Karsten Hopp |
0fad6e |
! dii->ht = ht;
|
|
Karsten Hopp |
0fad6e |
! dii->hi = dii->ht_array;
|
|
Karsten Hopp |
0fad6e |
! dii->todo = dii->ht_used;
|
|
Karsten Hopp |
0fad6e |
!
|
|
Karsten Hopp |
0fad6e |
! return IterNew(dii,
|
|
Karsten Hopp |
0fad6e |
! (destructorfun) PyMem_Free, (nextfun) DictionaryIterNext,
|
|
Karsten Hopp |
0fad6e |
! NULL, NULL);
|
|
Karsten Hopp |
0fad6e |
}
|
|
Karsten Hopp |
0fad6e |
|
|
Karsten Hopp |
0fad6e |
static PyInt
|
|
Karsten Hopp |
0fad6e |
***************
|
|
Karsten Hopp |
0fad6e |
*** 1016,1033 ****
|
|
Karsten Hopp |
0fad6e |
|
|
Karsten Hopp |
0fad6e |
if (di == NULL)
|
|
Karsten Hopp |
0fad6e |
{
|
|
Karsten Hopp |
0fad6e |
! di = dictitem_alloc(key);
|
|
Karsten Hopp |
0fad6e |
! if (di == NULL)
|
|
Karsten Hopp |
0fad6e |
{
|
|
Karsten Hopp |
0fad6e |
PyErr_NoMemory();
|
|
Karsten Hopp |
0fad6e |
return -1;
|
|
Karsten Hopp |
0fad6e |
}
|
|
Karsten Hopp |
0fad6e |
di->di_tv.v_lock = 0;
|
|
Karsten Hopp |
0fad6e |
|
|
Karsten Hopp |
0fad6e |
if (dict_add(dict, di) == FAIL)
|
|
Karsten Hopp |
0fad6e |
{
|
|
Karsten Hopp |
0fad6e |
DICTKEY_UNREF
|
|
Karsten Hopp |
0fad6e |
vim_free(di);
|
|
Karsten Hopp |
0fad6e |
PyErr_SetVim(_("failed to add key to dictionary"));
|
|
Karsten Hopp |
0fad6e |
return -1;
|
|
Karsten Hopp |
0fad6e |
}
|
|
Karsten Hopp |
0fad6e |
--- 1209,1227 ----
|
|
Karsten Hopp |
0fad6e |
|
|
Karsten Hopp |
0fad6e |
if (di == NULL)
|
|
Karsten Hopp |
0fad6e |
{
|
|
Karsten Hopp |
0fad6e |
! if (!(di = dictitem_alloc(key)))
|
|
Karsten Hopp |
0fad6e |
{
|
|
Karsten Hopp |
0fad6e |
PyErr_NoMemory();
|
|
Karsten Hopp |
0fad6e |
return -1;
|
|
Karsten Hopp |
0fad6e |
}
|
|
Karsten Hopp |
0fad6e |
di->di_tv.v_lock = 0;
|
|
Karsten Hopp |
0fad6e |
+ di->di_tv.v_type = VAR_UNKNOWN;
|
|
Karsten Hopp |
0fad6e |
|
|
Karsten Hopp |
0fad6e |
if (dict_add(dict, di) == FAIL)
|
|
Karsten Hopp |
0fad6e |
{
|
|
Karsten Hopp |
0fad6e |
DICTKEY_UNREF
|
|
Karsten Hopp |
0fad6e |
vim_free(di);
|
|
Karsten Hopp |
0fad6e |
+ dictitem_free(di);
|
|
Karsten Hopp |
0fad6e |
PyErr_SetVim(_("failed to add key to dictionary"));
|
|
Karsten Hopp |
0fad6e |
return -1;
|
|
Karsten Hopp |
0fad6e |
}
|
|
Karsten Hopp |
0fad6e |
***************
|
|
Karsten Hopp |
0fad6e |
*** 1042,1062 ****
|
|
Karsten Hopp |
0fad6e |
return 0;
|
|
Karsten Hopp |
0fad6e |
}
|
|
Karsten Hopp |
0fad6e |
|
|
Karsten Hopp |
0fad6e |
static PyObject *
|
|
Karsten Hopp |
0fad6e |
! DictionaryListKeys(DictionaryObject *self)
|
|
Karsten Hopp |
0fad6e |
{
|
|
Karsten Hopp |
0fad6e |
dict_T *dict = self->dict;
|
|
Karsten Hopp |
0fad6e |
long_u todo = dict->dv_hashtab.ht_used;
|
|
Karsten Hopp |
0fad6e |
Py_ssize_t i = 0;
|
|
Karsten Hopp |
0fad6e |
PyObject *r;
|
|
Karsten Hopp |
0fad6e |
hashitem_T *hi;
|
|
Karsten Hopp |
0fad6e |
|
|
Karsten Hopp |
0fad6e |
r = PyList_New(todo);
|
|
Karsten Hopp |
0fad6e |
for (hi = dict->dv_hashtab.ht_array; todo > 0; ++hi)
|
|
Karsten Hopp |
0fad6e |
{
|
|
Karsten Hopp |
0fad6e |
if (!HASHITEM_EMPTY(hi))
|
|
Karsten Hopp |
0fad6e |
{
|
|
Karsten Hopp |
0fad6e |
! PyList_SetItem(r, i, PyBytes_FromString((char *)(hi->hi_key)));
|
|
Karsten Hopp |
0fad6e |
--todo;
|
|
Karsten Hopp |
0fad6e |
++i;
|
|
Karsten Hopp |
0fad6e |
}
|
|
Karsten Hopp |
0fad6e |
--- 1236,1269 ----
|
|
Karsten Hopp |
0fad6e |
return 0;
|
|
Karsten Hopp |
0fad6e |
}
|
|
Karsten Hopp |
0fad6e |
|
|
Karsten Hopp |
0fad6e |
+ typedef PyObject *(*hi_to_py)(hashitem_T *);
|
|
Karsten Hopp |
0fad6e |
+
|
|
Karsten Hopp |
0fad6e |
static PyObject *
|
|
Karsten Hopp |
0fad6e |
! DictionaryListObjects(DictionaryObject *self, hi_to_py hiconvert)
|
|
Karsten Hopp |
0fad6e |
{
|
|
Karsten Hopp |
0fad6e |
dict_T *dict = self->dict;
|
|
Karsten Hopp |
0fad6e |
long_u todo = dict->dv_hashtab.ht_used;
|
|
Karsten Hopp |
0fad6e |
Py_ssize_t i = 0;
|
|
Karsten Hopp |
0fad6e |
PyObject *r;
|
|
Karsten Hopp |
0fad6e |
hashitem_T *hi;
|
|
Karsten Hopp |
0fad6e |
+ PyObject *newObj;
|
|
Karsten Hopp |
0fad6e |
|
|
Karsten Hopp |
0fad6e |
r = PyList_New(todo);
|
|
Karsten Hopp |
0fad6e |
for (hi = dict->dv_hashtab.ht_array; todo > 0; ++hi)
|
|
Karsten Hopp |
0fad6e |
{
|
|
Karsten Hopp |
0fad6e |
if (!HASHITEM_EMPTY(hi))
|
|
Karsten Hopp |
0fad6e |
{
|
|
Karsten Hopp |
0fad6e |
! if (!(newObj = hiconvert(hi)))
|
|
Karsten Hopp |
0fad6e |
! {
|
|
Karsten Hopp |
0fad6e |
! Py_DECREF(r);
|
|
Karsten Hopp |
0fad6e |
! return NULL;
|
|
Karsten Hopp |
0fad6e |
! }
|
|
Karsten Hopp |
0fad6e |
! if (PyList_SetItem(r, i, newObj))
|
|
Karsten Hopp |
0fad6e |
! {
|
|
Karsten Hopp |
0fad6e |
! Py_DECREF(r);
|
|
Karsten Hopp |
0fad6e |
! Py_DECREF(newObj);
|
|
Karsten Hopp |
0fad6e |
! return NULL;
|
|
Karsten Hopp |
0fad6e |
! }
|
|
Karsten Hopp |
0fad6e |
--todo;
|
|
Karsten Hopp |
0fad6e |
++i;
|
|
Karsten Hopp |
0fad6e |
}
|
|
Karsten Hopp |
0fad6e |
***************
|
|
Karsten Hopp |
0fad6e |
*** 1064,1069 ****
|
|
Karsten Hopp |
0fad6e |
--- 1271,1505 ----
|
|
Karsten Hopp |
0fad6e |
return r;
|
|
Karsten Hopp |
0fad6e |
}
|
|
Karsten Hopp |
0fad6e |
|
|
Karsten Hopp |
0fad6e |
+ static PyObject *
|
|
Karsten Hopp |
0fad6e |
+ dict_key(hashitem_T *hi)
|
|
Karsten Hopp |
0fad6e |
+ {
|
|
Karsten Hopp |
0fad6e |
+ return PyBytes_FromString((char *)(hi->hi_key));
|
|
Karsten Hopp |
0fad6e |
+ }
|
|
Karsten Hopp |
0fad6e |
+
|
|
Karsten Hopp |
0fad6e |
+ static PyObject *
|
|
Karsten Hopp |
0fad6e |
+ DictionaryListKeys(DictionaryObject *self)
|
|
Karsten Hopp |
0fad6e |
+ {
|
|
Karsten Hopp |
0fad6e |
+ return DictionaryListObjects(self, dict_key);
|
|
Karsten Hopp |
0fad6e |
+ }
|
|
Karsten Hopp |
0fad6e |
+
|
|
Karsten Hopp |
0fad6e |
+ static PyObject *
|
|
Karsten Hopp |
0fad6e |
+ dict_val(hashitem_T *hi)
|
|
Karsten Hopp |
0fad6e |
+ {
|
|
Karsten Hopp |
0fad6e |
+ dictitem_T *di;
|
|
Karsten Hopp |
0fad6e |
+
|
|
Karsten Hopp |
0fad6e |
+ di = dict_lookup(hi);
|
|
Karsten Hopp |
0fad6e |
+ return ConvertToPyObject(&di->di_tv);
|
|
Karsten Hopp |
0fad6e |
+ }
|
|
Karsten Hopp |
0fad6e |
+
|
|
Karsten Hopp |
0fad6e |
+ static PyObject *
|
|
Karsten Hopp |
0fad6e |
+ DictionaryListValues(DictionaryObject *self)
|
|
Karsten Hopp |
0fad6e |
+ {
|
|
Karsten Hopp |
0fad6e |
+ return DictionaryListObjects(self, dict_val);
|
|
Karsten Hopp |
0fad6e |
+ }
|
|
Karsten Hopp |
0fad6e |
+
|
|
Karsten Hopp |
0fad6e |
+ static PyObject *
|
|
Karsten Hopp |
0fad6e |
+ dict_item(hashitem_T *hi)
|
|
Karsten Hopp |
0fad6e |
+ {
|
|
Karsten Hopp |
0fad6e |
+ PyObject *keyObject;
|
|
Karsten Hopp |
0fad6e |
+ PyObject *valObject;
|
|
Karsten Hopp |
0fad6e |
+ PyObject *r;
|
|
Karsten Hopp |
0fad6e |
+
|
|
Karsten Hopp |
0fad6e |
+ if (!(keyObject = dict_key(hi)))
|
|
Karsten Hopp |
0fad6e |
+ return NULL;
|
|
Karsten Hopp |
0fad6e |
+
|
|
Karsten Hopp |
0fad6e |
+ if (!(valObject = dict_val(hi)))
|
|
Karsten Hopp |
0fad6e |
+ {
|
|
Karsten Hopp |
0fad6e |
+ Py_DECREF(keyObject);
|
|
Karsten Hopp |
0fad6e |
+ return NULL;
|
|
Karsten Hopp |
0fad6e |
+ }
|
|
Karsten Hopp |
0fad6e |
+
|
|
Karsten Hopp |
0fad6e |
+ r = Py_BuildValue("(OO)", keyObject, valObject);
|
|
Karsten Hopp |
0fad6e |
+
|
|
Karsten Hopp |
0fad6e |
+ Py_DECREF(keyObject);
|
|
Karsten Hopp |
0fad6e |
+ Py_DECREF(valObject);
|
|
Karsten Hopp |
0fad6e |
+
|
|
Karsten Hopp |
0fad6e |
+ return r;
|
|
Karsten Hopp |
0fad6e |
+ }
|
|
Karsten Hopp |
0fad6e |
+
|
|
Karsten Hopp |
0fad6e |
+ static PyObject *
|
|
Karsten Hopp |
0fad6e |
+ DictionaryListItems(DictionaryObject *self)
|
|
Karsten Hopp |
0fad6e |
+ {
|
|
Karsten Hopp |
0fad6e |
+ return DictionaryListObjects(self, dict_item);
|
|
Karsten Hopp |
0fad6e |
+ }
|
|
Karsten Hopp |
0fad6e |
+
|
|
Karsten Hopp |
0fad6e |
+ static PyObject *
|
|
Karsten Hopp |
0fad6e |
+ DictionaryUpdate(DictionaryObject *self, PyObject *args, PyObject *kwargs)
|
|
Karsten Hopp |
0fad6e |
+ {
|
|
Karsten Hopp |
0fad6e |
+ dict_T *dict = self->dict;
|
|
Karsten Hopp |
0fad6e |
+
|
|
Karsten Hopp |
0fad6e |
+ if (dict->dv_lock)
|
|
Karsten Hopp |
0fad6e |
+ {
|
|
Karsten Hopp |
0fad6e |
+ PyErr_SetVim(_("dict is locked"));
|
|
Karsten Hopp |
0fad6e |
+ return NULL;
|
|
Karsten Hopp |
0fad6e |
+ }
|
|
Karsten Hopp |
0fad6e |
+
|
|
Karsten Hopp |
0fad6e |
+ if (kwargs)
|
|
Karsten Hopp |
0fad6e |
+ {
|
|
Karsten Hopp |
0fad6e |
+ typval_T tv;
|
|
Karsten Hopp |
0fad6e |
+
|
|
Karsten Hopp |
0fad6e |
+ if (ConvertFromPyMapping(kwargs, &tv) == -1)
|
|
Karsten Hopp |
0fad6e |
+ return NULL;
|
|
Karsten Hopp |
0fad6e |
+
|
|
Karsten Hopp |
0fad6e |
+ VimTryStart();
|
|
Karsten Hopp |
0fad6e |
+ dict_extend(self->dict, tv.vval.v_dict, (char_u *) "force");
|
|
Karsten Hopp |
0fad6e |
+ clear_tv(&tv;;
|
|
Karsten Hopp |
0fad6e |
+ if (VimTryEnd())
|
|
Karsten Hopp |
0fad6e |
+ return NULL;
|
|
Karsten Hopp |
0fad6e |
+ }
|
|
Karsten Hopp |
0fad6e |
+ else
|
|
Karsten Hopp |
0fad6e |
+ {
|
|
Karsten Hopp |
0fad6e |
+ PyObject *object;
|
|
Karsten Hopp |
0fad6e |
+
|
|
Karsten Hopp |
0fad6e |
+ if (!PyArg_Parse(args, "(O)", &object))
|
|
Karsten Hopp |
0fad6e |
+ return NULL;
|
|
Karsten Hopp |
0fad6e |
+
|
|
Karsten Hopp |
0fad6e |
+ if (PyObject_HasAttrString(object, "keys"))
|
|
Karsten Hopp |
0fad6e |
+ return DictionaryUpdate(self, NULL, object);
|
|
Karsten Hopp |
0fad6e |
+ else
|
|
Karsten Hopp |
0fad6e |
+ {
|
|
Karsten Hopp |
0fad6e |
+ PyObject *iterator;
|
|
Karsten Hopp |
0fad6e |
+ PyObject *item;
|
|
Karsten Hopp |
0fad6e |
+
|
|
Karsten Hopp |
0fad6e |
+ if (!(iterator = PyObject_GetIter(object)))
|
|
Karsten Hopp |
0fad6e |
+ return NULL;
|
|
Karsten Hopp |
0fad6e |
+
|
|
Karsten Hopp |
0fad6e |
+ while ((item = PyIter_Next(iterator)))
|
|
Karsten Hopp |
0fad6e |
+ {
|
|
Karsten Hopp |
0fad6e |
+ PyObject *fast;
|
|
Karsten Hopp |
0fad6e |
+ PyObject *keyObject;
|
|
Karsten Hopp |
0fad6e |
+ PyObject *valObject;
|
|
Karsten Hopp |
0fad6e |
+ PyObject *todecref;
|
|
Karsten Hopp |
0fad6e |
+ char_u *key;
|
|
Karsten Hopp |
0fad6e |
+ dictitem_T *di;
|
|
Karsten Hopp |
0fad6e |
+
|
|
Karsten Hopp |
0fad6e |
+ if (!(fast = PySequence_Fast(item, "")))
|
|
Karsten Hopp |
0fad6e |
+ {
|
|
Karsten Hopp |
0fad6e |
+ Py_DECREF(iterator);
|
|
Karsten Hopp |
0fad6e |
+ Py_DECREF(item);
|
|
Karsten Hopp |
0fad6e |
+ return NULL;
|
|
Karsten Hopp |
0fad6e |
+ }
|
|
Karsten Hopp |
0fad6e |
+
|
|
Karsten Hopp |
0fad6e |
+ Py_DECREF(item);
|
|
Karsten Hopp |
0fad6e |
+
|
|
Karsten Hopp |
0fad6e |
+ if (PySequence_Fast_GET_SIZE(fast) != 2)
|
|
Karsten Hopp |
0fad6e |
+ {
|
|
Karsten Hopp |
0fad6e |
+ Py_DECREF(iterator);
|
|
Karsten Hopp |
0fad6e |
+ Py_DECREF(fast);
|
|
Karsten Hopp |
0fad6e |
+ PyErr_SetString(PyExc_ValueError,
|
|
Karsten Hopp |
0fad6e |
+ _("expected sequence element of size 2"));
|
|
Karsten Hopp |
0fad6e |
+ return NULL;
|
|
Karsten Hopp |
0fad6e |
+ }
|
|
Karsten Hopp |
0fad6e |
+
|
|
Karsten Hopp |
0fad6e |
+ keyObject = PySequence_Fast_GET_ITEM(fast, 0);
|
|
Karsten Hopp |
0fad6e |
+
|
|
Karsten Hopp |
0fad6e |
+ if (!(key = StringToChars(keyObject, &todecref)))
|
|
Karsten Hopp |
0fad6e |
+ {
|
|
Karsten Hopp |
0fad6e |
+ Py_DECREF(iterator);
|
|
Karsten Hopp |
0fad6e |
+ Py_DECREF(fast);
|
|
Karsten Hopp |
0fad6e |
+ return NULL;
|
|
Karsten Hopp |
0fad6e |
+ }
|
|
Karsten Hopp |
0fad6e |
+
|
|
Karsten Hopp |
0fad6e |
+ di = dictitem_alloc(key);
|
|
Karsten Hopp |
0fad6e |
+
|
|
Karsten Hopp |
0fad6e |
+ Py_XDECREF(todecref);
|
|
Karsten Hopp |
0fad6e |
+
|
|
Karsten Hopp |
0fad6e |
+ if (di == NULL)
|
|
Karsten Hopp |
0fad6e |
+ {
|
|
Karsten Hopp |
0fad6e |
+ Py_DECREF(fast);
|
|
Karsten Hopp |
0fad6e |
+ Py_DECREF(iterator);
|
|
Karsten Hopp |
0fad6e |
+ PyErr_NoMemory();
|
|
Karsten Hopp |
0fad6e |
+ return NULL;
|
|
Karsten Hopp |
0fad6e |
+ }
|
|
Karsten Hopp |
0fad6e |
+ di->di_tv.v_lock = 0;
|
|
Karsten Hopp |
0fad6e |
+ di->di_tv.v_type = VAR_UNKNOWN;
|
|
Karsten Hopp |
0fad6e |
+
|
|
Karsten Hopp |
0fad6e |
+ valObject = PySequence_Fast_GET_ITEM(fast, 1);
|
|
Karsten Hopp |
0fad6e |
+
|
|
Karsten Hopp |
0fad6e |
+ if (ConvertFromPyObject(valObject, &di->di_tv) == -1)
|
|
Karsten Hopp |
0fad6e |
+ {
|
|
Karsten Hopp |
0fad6e |
+ Py_DECREF(iterator);
|
|
Karsten Hopp |
0fad6e |
+ Py_DECREF(fast);
|
|
Karsten Hopp |
0fad6e |
+ dictitem_free(di);
|
|
Karsten Hopp |
0fad6e |
+ return NULL;
|
|
Karsten Hopp |
0fad6e |
+ }
|
|
Karsten Hopp |
0fad6e |
+
|
|
Karsten Hopp |
0fad6e |
+ Py_DECREF(fast);
|
|
Karsten Hopp |
0fad6e |
+
|
|
Karsten Hopp |
0fad6e |
+ if (dict_add(dict, di) == FAIL)
|
|
Karsten Hopp |
0fad6e |
+ {
|
|
Karsten Hopp |
0fad6e |
+ Py_DECREF(iterator);
|
|
Karsten Hopp |
0fad6e |
+ dictitem_free(di);
|
|
Karsten Hopp |
0fad6e |
+ PyErr_SetVim(_("failed to add key to dictionary"));
|
|
Karsten Hopp |
0fad6e |
+ return NULL;
|
|
Karsten Hopp |
0fad6e |
+ }
|
|
Karsten Hopp |
0fad6e |
+ }
|
|
Karsten Hopp |
0fad6e |
+
|
|
Karsten Hopp |
0fad6e |
+ Py_DECREF(iterator);
|
|
Karsten Hopp |
0fad6e |
+
|
|
Karsten Hopp |
0fad6e |
+ /* Iterator may have finished due to an exception */
|
|
Karsten Hopp |
0fad6e |
+ if (PyErr_Occurred())
|
|
Karsten Hopp |
0fad6e |
+ return NULL;
|
|
Karsten Hopp |
0fad6e |
+ }
|
|
Karsten Hopp |
0fad6e |
+ }
|
|
Karsten Hopp |
0fad6e |
+ Py_INCREF(Py_None);
|
|
Karsten Hopp |
0fad6e |
+ return Py_None;
|
|
Karsten Hopp |
0fad6e |
+ }
|
|
Karsten Hopp |
0fad6e |
+
|
|
Karsten Hopp |
0fad6e |
+ static PyObject *
|
|
Karsten Hopp |
0fad6e |
+ DictionaryGet(DictionaryObject *self, PyObject *args)
|
|
Karsten Hopp |
0fad6e |
+ {
|
|
Karsten Hopp |
0fad6e |
+ return _DictionaryItem(self, args,
|
|
Karsten Hopp |
0fad6e |
+ DICT_FLAG_HAS_DEFAULT|DICT_FLAG_NONE_DEFAULT);
|
|
Karsten Hopp |
0fad6e |
+ }
|
|
Karsten Hopp |
0fad6e |
+
|
|
Karsten Hopp |
0fad6e |
+ static PyObject *
|
|
Karsten Hopp |
0fad6e |
+ DictionaryPop(DictionaryObject *self, PyObject *args)
|
|
Karsten Hopp |
0fad6e |
+ {
|
|
Karsten Hopp |
0fad6e |
+ return _DictionaryItem(self, args, DICT_FLAG_HAS_DEFAULT|DICT_FLAG_POP);
|
|
Karsten Hopp |
0fad6e |
+ }
|
|
Karsten Hopp |
0fad6e |
+
|
|
Karsten Hopp |
0fad6e |
+ static PyObject *
|
|
Karsten Hopp |
0fad6e |
+ DictionaryPopItem(DictionaryObject *self, PyObject *args)
|
|
Karsten Hopp |
0fad6e |
+ {
|
|
Karsten Hopp |
0fad6e |
+ PyObject *keyObject;
|
|
Karsten Hopp |
0fad6e |
+
|
|
Karsten Hopp |
0fad6e |
+ if (!PyArg_ParseTuple(args, "O", &keyObject))
|
|
Karsten Hopp |
0fad6e |
+ return NULL;
|
|
Karsten Hopp |
0fad6e |
+
|
|
Karsten Hopp |
0fad6e |
+ return _DictionaryItem(self, keyObject,
|
|
Karsten Hopp |
0fad6e |
+ DICT_FLAG_POP|DICT_FLAG_RETURN_PAIR);
|
|
Karsten Hopp |
0fad6e |
+ }
|
|
Karsten Hopp |
0fad6e |
+
|
|
Karsten Hopp |
0fad6e |
+ static PyObject *
|
|
Karsten Hopp |
0fad6e |
+ DictionaryHasKey(DictionaryObject *self, PyObject *args)
|
|
Karsten Hopp |
0fad6e |
+ {
|
|
Karsten Hopp |
0fad6e |
+ PyObject *keyObject;
|
|
Karsten Hopp |
0fad6e |
+
|
|
Karsten Hopp |
0fad6e |
+ if (!PyArg_ParseTuple(args, "O", &keyObject))
|
|
Karsten Hopp |
0fad6e |
+ return NULL;
|
|
Karsten Hopp |
0fad6e |
+
|
|
Karsten Hopp |
0fad6e |
+ return _DictionaryItem(self, keyObject, DICT_FLAG_RETURN_BOOL);
|
|
Karsten Hopp |
0fad6e |
+ }
|
|
Karsten Hopp |
0fad6e |
+
|
|
Karsten Hopp |
0fad6e |
+ static PySequenceMethods DictionaryAsSeq = {
|
|
Karsten Hopp |
0fad6e |
+ 0, /* sq_length */
|
|
Karsten Hopp |
0fad6e |
+ 0, /* sq_concat */
|
|
Karsten Hopp |
0fad6e |
+ 0, /* sq_repeat */
|
|
Karsten Hopp |
0fad6e |
+ 0, /* sq_item */
|
|
Karsten Hopp |
0fad6e |
+ 0, /* sq_slice */
|
|
Karsten Hopp |
0fad6e |
+ 0, /* sq_ass_item */
|
|
Karsten Hopp |
0fad6e |
+ 0, /* sq_ass_slice */
|
|
Karsten Hopp |
0fad6e |
+ (objobjproc) DictionaryContains, /* sq_contains */
|
|
Karsten Hopp |
0fad6e |
+ 0, /* sq_inplace_concat */
|
|
Karsten Hopp |
0fad6e |
+ 0, /* sq_inplace_repeat */
|
|
Karsten Hopp |
0fad6e |
+ };
|
|
Karsten Hopp |
0fad6e |
+
|
|
Karsten Hopp |
0fad6e |
static PyMappingMethods DictionaryAsMapping = {
|
|
Karsten Hopp |
0fad6e |
(lenfunc) DictionaryLength,
|
|
Karsten Hopp |
0fad6e |
(binaryfunc) DictionaryItem,
|
|
Karsten Hopp |
0fad6e |
***************
|
|
Karsten Hopp |
0fad6e |
*** 1072,1077 ****
|
|
Karsten Hopp |
0fad6e |
--- 1508,1520 ----
|
|
Karsten Hopp |
0fad6e |
|
|
Karsten Hopp |
0fad6e |
static struct PyMethodDef DictionaryMethods[] = {
|
|
Karsten Hopp |
0fad6e |
{"keys", (PyCFunction)DictionaryListKeys, METH_NOARGS, ""},
|
|
Karsten Hopp |
0fad6e |
+ {"values", (PyCFunction)DictionaryListValues, METH_NOARGS, ""},
|
|
Karsten Hopp |
0fad6e |
+ {"items", (PyCFunction)DictionaryListItems, METH_NOARGS, ""},
|
|
Karsten Hopp |
0fad6e |
+ {"update", (PyCFunction)DictionaryUpdate, METH_VARARGS|METH_KEYWORDS, ""},
|
|
Karsten Hopp |
0fad6e |
+ {"get", (PyCFunction)DictionaryGet, METH_VARARGS, ""},
|
|
Karsten Hopp |
0fad6e |
+ {"pop", (PyCFunction)DictionaryPop, METH_VARARGS, ""},
|
|
Karsten Hopp |
0fad6e |
+ {"popitem", (PyCFunction)DictionaryPopItem, METH_VARARGS, ""},
|
|
Karsten Hopp |
0fad6e |
+ {"has_key", (PyCFunction)DictionaryHasKey, METH_VARARGS, ""},
|
|
Karsten Hopp |
0fad6e |
{"__dir__", (PyCFunction)DictionaryDir, METH_NOARGS, ""},
|
|
Karsten Hopp |
0fad6e |
{ NULL, NULL, 0, NULL}
|
|
Karsten Hopp |
0fad6e |
};
|
|
Karsten Hopp |
0fad6e |
***************
|
|
Karsten Hopp |
0fad6e |
*** 1541,1554 ****
|
|
Karsten Hopp |
0fad6e |
selfdictObject = PyDict_GetItemString(kwargs, "self");
|
|
Karsten Hopp |
0fad6e |
if (selfdictObject != NULL)
|
|
Karsten Hopp |
0fad6e |
{
|
|
Karsten Hopp |
0fad6e |
! if (!PyMapping_Check(selfdictObject))
|
|
Karsten Hopp |
0fad6e |
! {
|
|
Karsten Hopp |
0fad6e |
! PyErr_SetString(PyExc_TypeError,
|
|
Karsten Hopp |
0fad6e |
! _("'self' argument must be a dictionary"));
|
|
Karsten Hopp |
0fad6e |
! clear_tv(&args);
|
|
Karsten Hopp |
0fad6e |
! return NULL;
|
|
Karsten Hopp |
0fad6e |
! }
|
|
Karsten Hopp |
0fad6e |
! if (ConvertFromPyObject(selfdictObject, &selfdicttv) == -1)
|
|
Karsten Hopp |
0fad6e |
{
|
|
Karsten Hopp |
0fad6e |
clear_tv(&args);
|
|
Karsten Hopp |
0fad6e |
return NULL;
|
|
Karsten Hopp |
0fad6e |
--- 1984,1990 ----
|
|
Karsten Hopp |
0fad6e |
selfdictObject = PyDict_GetItemString(kwargs, "self");
|
|
Karsten Hopp |
0fad6e |
if (selfdictObject != NULL)
|
|
Karsten Hopp |
0fad6e |
{
|
|
Karsten Hopp |
0fad6e |
! if (ConvertFromPyMapping(selfdictObject, &selfdicttv) == -1)
|
|
Karsten Hopp |
0fad6e |
{
|
|
Karsten Hopp |
0fad6e |
clear_tv(&args);
|
|
Karsten Hopp |
0fad6e |
return NULL;
|
|
Karsten Hopp |
0fad6e |
***************
|
|
Karsten Hopp |
0fad6e |
*** 1994,2000 ****
|
|
Karsten Hopp |
0fad6e |
else if (strcmp(name, "number") == 0)
|
|
Karsten Hopp |
0fad6e |
return PyLong_FromLong((long) get_tab_number(self->tab));
|
|
Karsten Hopp |
0fad6e |
else if (strcmp(name, "vars") == 0)
|
|
Karsten Hopp |
0fad6e |
! return DictionaryNew(self->tab->tp_vars);
|
|
Karsten Hopp |
0fad6e |
else if (strcmp(name, "window") == 0)
|
|
Karsten Hopp |
0fad6e |
{
|
|
Karsten Hopp |
0fad6e |
/* For current tab window.c does not bother to set or update tp_curwin
|
|
Karsten Hopp |
0fad6e |
--- 2430,2436 ----
|
|
Karsten Hopp |
0fad6e |
else if (strcmp(name, "number") == 0)
|
|
Karsten Hopp |
0fad6e |
return PyLong_FromLong((long) get_tab_number(self->tab));
|
|
Karsten Hopp |
0fad6e |
else if (strcmp(name, "vars") == 0)
|
|
Karsten Hopp |
0fad6e |
! return NEW_DICTIONARY(self->tab->tp_vars);
|
|
Karsten Hopp |
0fad6e |
else if (strcmp(name, "window") == 0)
|
|
Karsten Hopp |
0fad6e |
{
|
|
Karsten Hopp |
0fad6e |
/* For current tab window.c does not bother to set or update tp_curwin
|
|
Karsten Hopp |
0fad6e |
***************
|
|
Karsten Hopp |
0fad6e |
*** 2225,2231 ****
|
|
Karsten Hopp |
0fad6e |
return PyLong_FromLong((long)(W_WINCOL(self->win)));
|
|
Karsten Hopp |
0fad6e |
#endif
|
|
Karsten Hopp |
0fad6e |
else if (strcmp(name, "vars") == 0)
|
|
Karsten Hopp |
0fad6e |
! return DictionaryNew(self->win->w_vars);
|
|
Karsten Hopp |
0fad6e |
else if (strcmp(name, "options") == 0)
|
|
Karsten Hopp |
0fad6e |
return OptionsNew(SREQ_WIN, self->win, (checkfun) CheckWindow,
|
|
Karsten Hopp |
0fad6e |
(PyObject *) self);
|
|
Karsten Hopp |
0fad6e |
--- 2661,2667 ----
|
|
Karsten Hopp |
0fad6e |
return PyLong_FromLong((long)(W_WINCOL(self->win)));
|
|
Karsten Hopp |
0fad6e |
#endif
|
|
Karsten Hopp |
0fad6e |
else if (strcmp(name, "vars") == 0)
|
|
Karsten Hopp |
0fad6e |
! return NEW_DICTIONARY(self->win->w_vars);
|
|
Karsten Hopp |
0fad6e |
else if (strcmp(name, "options") == 0)
|
|
Karsten Hopp |
0fad6e |
return OptionsNew(SREQ_WIN, self->win, (checkfun) CheckWindow,
|
|
Karsten Hopp |
0fad6e |
(PyObject *) self);
|
|
Karsten Hopp |
0fad6e |
***************
|
|
Karsten Hopp |
0fad6e |
*** 3402,3408 ****
|
|
Karsten Hopp |
0fad6e |
else if (strcmp(name, "number") == 0)
|
|
Karsten Hopp |
0fad6e |
return Py_BuildValue(Py_ssize_t_fmt, self->buf->b_fnum);
|
|
Karsten Hopp |
0fad6e |
else if (strcmp(name, "vars") == 0)
|
|
Karsten Hopp |
0fad6e |
! return DictionaryNew(self->buf->b_vars);
|
|
Karsten Hopp |
0fad6e |
else if (strcmp(name, "options") == 0)
|
|
Karsten Hopp |
0fad6e |
return OptionsNew(SREQ_BUF, self->buf, (checkfun) CheckBuffer,
|
|
Karsten Hopp |
0fad6e |
(PyObject *) self);
|
|
Karsten Hopp |
0fad6e |
--- 3838,3844 ----
|
|
Karsten Hopp |
0fad6e |
else if (strcmp(name, "number") == 0)
|
|
Karsten Hopp |
0fad6e |
return Py_BuildValue(Py_ssize_t_fmt, self->buf->b_fnum);
|
|
Karsten Hopp |
0fad6e |
else if (strcmp(name, "vars") == 0)
|
|
Karsten Hopp |
0fad6e |
! return NEW_DICTIONARY(self->buf->b_vars);
|
|
Karsten Hopp |
0fad6e |
else if (strcmp(name, "options") == 0)
|
|
Karsten Hopp |
0fad6e |
return OptionsNew(SREQ_BUF, self->buf, (checkfun) CheckBuffer,
|
|
Karsten Hopp |
0fad6e |
(PyObject *) self);
|
|
Karsten Hopp |
0fad6e |
***************
|
|
Karsten Hopp |
0fad6e |
*** 4307,4312 ****
|
|
Karsten Hopp |
0fad6e |
--- 4743,4778 ----
|
|
Karsten Hopp |
0fad6e |
}
|
|
Karsten Hopp |
0fad6e |
|
|
Karsten Hopp |
0fad6e |
static int
|
|
Karsten Hopp |
0fad6e |
+ ConvertFromPyMapping(PyObject *obj, typval_T *tv)
|
|
Karsten Hopp |
0fad6e |
+ {
|
|
Karsten Hopp |
0fad6e |
+ PyObject *lookup_dict;
|
|
Karsten Hopp |
0fad6e |
+ int r;
|
|
Karsten Hopp |
0fad6e |
+
|
|
Karsten Hopp |
0fad6e |
+ if (!(lookup_dict = PyDict_New()))
|
|
Karsten Hopp |
0fad6e |
+ return -1;
|
|
Karsten Hopp |
0fad6e |
+
|
|
Karsten Hopp |
0fad6e |
+ if (PyType_IsSubtype(obj->ob_type, &DictionaryType))
|
|
Karsten Hopp |
0fad6e |
+ {
|
|
Karsten Hopp |
0fad6e |
+ tv->v_type = VAR_DICT;
|
|
Karsten Hopp |
0fad6e |
+ tv->vval.v_dict = (((DictionaryObject *)(obj))->dict);
|
|
Karsten Hopp |
0fad6e |
+ ++tv->vval.v_dict->dv_refcount;
|
|
Karsten Hopp |
0fad6e |
+ r = 0;
|
|
Karsten Hopp |
0fad6e |
+ }
|
|
Karsten Hopp |
0fad6e |
+ else if (PyDict_Check(obj))
|
|
Karsten Hopp |
0fad6e |
+ r = convert_dl(obj, tv, pydict_to_tv, lookup_dict);
|
|
Karsten Hopp |
0fad6e |
+ else if (PyMapping_Check(obj))
|
|
Karsten Hopp |
0fad6e |
+ r = convert_dl(obj, tv, pymap_to_tv, lookup_dict);
|
|
Karsten Hopp |
0fad6e |
+ else
|
|
Karsten Hopp |
0fad6e |
+ {
|
|
Karsten Hopp |
0fad6e |
+ PyErr_SetString(PyExc_TypeError,
|
|
Karsten Hopp |
0fad6e |
+ _("unable to convert object to vim dictionary"));
|
|
Karsten Hopp |
0fad6e |
+ r = -1;
|
|
Karsten Hopp |
0fad6e |
+ }
|
|
Karsten Hopp |
0fad6e |
+ Py_DECREF(lookup_dict);
|
|
Karsten Hopp |
0fad6e |
+ return r;
|
|
Karsten Hopp |
0fad6e |
+ }
|
|
Karsten Hopp |
0fad6e |
+
|
|
Karsten Hopp |
0fad6e |
+ static int
|
|
Karsten Hopp |
0fad6e |
ConvertFromPyObject(PyObject *obj, typval_T *tv)
|
|
Karsten Hopp |
0fad6e |
{
|
|
Karsten Hopp |
0fad6e |
PyObject *lookup_dict;
|
|
Karsten Hopp |
0fad6e |
***************
|
|
Karsten Hopp |
0fad6e |
*** 4322,4328 ****
|
|
Karsten Hopp |
0fad6e |
static int
|
|
Karsten Hopp |
0fad6e |
_ConvertFromPyObject(PyObject *obj, typval_T *tv, PyObject *lookup_dict)
|
|
Karsten Hopp |
0fad6e |
{
|
|
Karsten Hopp |
0fad6e |
! if (obj->ob_type == &DictionaryType)
|
|
Karsten Hopp |
0fad6e |
{
|
|
Karsten Hopp |
0fad6e |
tv->v_type = VAR_DICT;
|
|
Karsten Hopp |
0fad6e |
tv->vval.v_dict = (((DictionaryObject *)(obj))->dict);
|
|
Karsten Hopp |
0fad6e |
--- 4788,4794 ----
|
|
Karsten Hopp |
0fad6e |
static int
|
|
Karsten Hopp |
0fad6e |
_ConvertFromPyObject(PyObject *obj, typval_T *tv, PyObject *lookup_dict)
|
|
Karsten Hopp |
0fad6e |
{
|
|
Karsten Hopp |
0fad6e |
! if (PyType_IsSubtype(obj->ob_type, &DictionaryType))
|
|
Karsten Hopp |
0fad6e |
{
|
|
Karsten Hopp |
0fad6e |
tv->v_type = VAR_DICT;
|
|
Karsten Hopp |
0fad6e |
tv->vval.v_dict = (((DictionaryObject *)(obj))->dict);
|
|
Karsten Hopp |
0fad6e |
***************
|
|
Karsten Hopp |
0fad6e |
*** 4437,4443 ****
|
|
Karsten Hopp |
0fad6e |
case VAR_LIST:
|
|
Karsten Hopp |
0fad6e |
return ListNew(tv->vval.v_list);
|
|
Karsten Hopp |
0fad6e |
case VAR_DICT:
|
|
Karsten Hopp |
0fad6e |
! return DictionaryNew(tv->vval.v_dict);
|
|
Karsten Hopp |
0fad6e |
case VAR_FUNC:
|
|
Karsten Hopp |
0fad6e |
return FunctionNew(tv->vval.v_string == NULL
|
|
Karsten Hopp |
0fad6e |
? (char_u *)"" : tv->vval.v_string);
|
|
Karsten Hopp |
0fad6e |
--- 4903,4909 ----
|
|
Karsten Hopp |
0fad6e |
case VAR_LIST:
|
|
Karsten Hopp |
0fad6e |
return ListNew(tv->vval.v_list);
|
|
Karsten Hopp |
0fad6e |
case VAR_DICT:
|
|
Karsten Hopp |
0fad6e |
! return NEW_DICTIONARY(tv->vval.v_dict);
|
|
Karsten Hopp |
0fad6e |
case VAR_FUNC:
|
|
Karsten Hopp |
0fad6e |
return FunctionNew(tv->vval.v_string == NULL
|
|
Karsten Hopp |
0fad6e |
? (char_u *)"" : tv->vval.v_string);
|
|
Karsten Hopp |
0fad6e |
***************
|
|
Karsten Hopp |
0fad6e |
*** 4608,4617 ****
|
|
Karsten Hopp |
0fad6e |
DictionaryType.tp_name = "vim.dictionary";
|
|
Karsten Hopp |
0fad6e |
DictionaryType.tp_basicsize = sizeof(DictionaryObject);
|
|
Karsten Hopp |
0fad6e |
DictionaryType.tp_dealloc = (destructor)DictionaryDestructor;
|
|
Karsten Hopp |
0fad6e |
DictionaryType.tp_as_mapping = &DictionaryAsMapping;
|
|
Karsten Hopp |
0fad6e |
! DictionaryType.tp_flags = Py_TPFLAGS_DEFAULT;
|
|
Karsten Hopp |
0fad6e |
DictionaryType.tp_doc = "dictionary pushing modifications to vim structure";
|
|
Karsten Hopp |
0fad6e |
DictionaryType.tp_methods = DictionaryMethods;
|
|
Karsten Hopp |
0fad6e |
#if PY_MAJOR_VERSION >= 3
|
|
Karsten Hopp |
0fad6e |
DictionaryType.tp_getattro = (getattrofunc)DictionaryGetattro;
|
|
Karsten Hopp |
0fad6e |
DictionaryType.tp_setattro = (setattrofunc)DictionarySetattro;
|
|
Karsten Hopp |
0fad6e |
--- 5074,5087 ----
|
|
Karsten Hopp |
0fad6e |
DictionaryType.tp_name = "vim.dictionary";
|
|
Karsten Hopp |
0fad6e |
DictionaryType.tp_basicsize = sizeof(DictionaryObject);
|
|
Karsten Hopp |
0fad6e |
DictionaryType.tp_dealloc = (destructor)DictionaryDestructor;
|
|
Karsten Hopp |
0fad6e |
+ DictionaryType.tp_as_sequence = &DictionaryAsSeq;
|
|
Karsten Hopp |
0fad6e |
DictionaryType.tp_as_mapping = &DictionaryAsMapping;
|
|
Karsten Hopp |
0fad6e |
! DictionaryType.tp_flags = Py_TPFLAGS_DEFAULT|Py_TPFLAGS_BASETYPE;
|
|
Karsten Hopp |
0fad6e |
DictionaryType.tp_doc = "dictionary pushing modifications to vim structure";
|
|
Karsten Hopp |
0fad6e |
DictionaryType.tp_methods = DictionaryMethods;
|
|
Karsten Hopp |
0fad6e |
+ DictionaryType.tp_iter = (getiterfunc)DictionaryIter;
|
|
Karsten Hopp |
0fad6e |
+ DictionaryType.tp_new = (newfunc)DictionaryConstructor;
|
|
Karsten Hopp |
0fad6e |
+ DictionaryType.tp_alloc = (allocfunc)PyType_GenericAlloc;
|
|
Karsten Hopp |
0fad6e |
#if PY_MAJOR_VERSION >= 3
|
|
Karsten Hopp |
0fad6e |
DictionaryType.tp_getattro = (getattrofunc)DictionaryGetattro;
|
|
Karsten Hopp |
0fad6e |
DictionaryType.tp_setattro = (setattrofunc)DictionarySetattro;
|
|
Karsten Hopp |
0fad6e |
***************
|
|
Karsten Hopp |
0fad6e |
*** 4786,4793 ****
|
|
Karsten Hopp |
0fad6e |
return -1;
|
|
Karsten Hopp |
0fad6e |
ADD_OBJECT(m, "error", VimError);
|
|
Karsten Hopp |
0fad6e |
|
|
Karsten Hopp |
0fad6e |
! ADD_CHECKED_OBJECT(m, "vars", DictionaryNew(&globvardict));
|
|
Karsten Hopp |
0fad6e |
! ADD_CHECKED_OBJECT(m, "vvars", DictionaryNew(&vimvardict));
|
|
Karsten Hopp |
0fad6e |
ADD_CHECKED_OBJECT(m, "options",
|
|
Karsten Hopp |
0fad6e |
OptionsNew(SREQ_GLOBAL, NULL, dummy_check, NULL));
|
|
Karsten Hopp |
0fad6e |
return 0;
|
|
Karsten Hopp |
0fad6e |
--- 5256,5263 ----
|
|
Karsten Hopp |
0fad6e |
return -1;
|
|
Karsten Hopp |
0fad6e |
ADD_OBJECT(m, "error", VimError);
|
|
Karsten Hopp |
0fad6e |
|
|
Karsten Hopp |
0fad6e |
! ADD_CHECKED_OBJECT(m, "vars", NEW_DICTIONARY(&globvardict));
|
|
Karsten Hopp |
0fad6e |
! ADD_CHECKED_OBJECT(m, "vvars", NEW_DICTIONARY(&vimvardict));
|
|
Karsten Hopp |
0fad6e |
ADD_CHECKED_OBJECT(m, "options",
|
|
Karsten Hopp |
0fad6e |
OptionsNew(SREQ_GLOBAL, NULL, dummy_check, NULL));
|
|
Karsten Hopp |
0fad6e |
return 0;
|
|
Karsten Hopp |
0fad6e |
*** ../vim-7.3.1060/src/if_python3.c 2013-05-30 12:40:36.000000000 +0200
|
|
Karsten Hopp |
0fad6e |
--- src/if_python3.c 2013-05-30 12:47:48.000000000 +0200
|
|
Karsten Hopp |
0fad6e |
***************
|
|
Karsten Hopp |
0fad6e |
*** 96,101 ****
|
|
Karsten Hopp |
0fad6e |
--- 96,102 ----
|
|
Karsten Hopp |
0fad6e |
#define PyInt_FromLong(i) PyLong_FromLong(i)
|
|
Karsten Hopp |
0fad6e |
#define PyInt_AsLong(obj) PyLong_AsLong(obj)
|
|
Karsten Hopp |
0fad6e |
#define Py_ssize_t_fmt "n"
|
|
Karsten Hopp |
0fad6e |
+ #define Py_bytes_fmt "y"
|
|
Karsten Hopp |
0fad6e |
|
|
Karsten Hopp |
0fad6e |
#if defined(DYNAMIC_PYTHON3) || defined(PROTO)
|
|
Karsten Hopp |
0fad6e |
|
|
Karsten Hopp |
0fad6e |
***************
|
|
Karsten Hopp |
0fad6e |
*** 149,154 ****
|
|
Karsten Hopp |
0fad6e |
--- 150,156 ----
|
|
Karsten Hopp |
0fad6e |
# define PySequence_Check py3_PySequence_Check
|
|
Karsten Hopp |
0fad6e |
# define PySequence_Size py3_PySequence_Size
|
|
Karsten Hopp |
0fad6e |
# define PySequence_GetItem py3_PySequence_GetItem
|
|
Karsten Hopp |
0fad6e |
+ # define PySequence_Fast py3_PySequence_Fast
|
|
Karsten Hopp |
0fad6e |
# define PyTuple_Size py3_PyTuple_Size
|
|
Karsten Hopp |
0fad6e |
# define PyTuple_GetItem py3_PyTuple_GetItem
|
|
Karsten Hopp |
0fad6e |
# define PySlice_GetIndicesEx py3_PySlice_GetIndicesEx
|
|
Karsten Hopp |
0fad6e |
***************
|
|
Karsten Hopp |
0fad6e |
*** 168,173 ****
|
|
Karsten Hopp |
0fad6e |
--- 170,176 ----
|
|
Karsten Hopp |
0fad6e |
#undef PyRun_String
|
|
Karsten Hopp |
0fad6e |
# define PyRun_String py3_PyRun_String
|
|
Karsten Hopp |
0fad6e |
# define PyObject_GetAttrString py3_PyObject_GetAttrString
|
|
Karsten Hopp |
0fad6e |
+ # define PyObject_HasAttrString py3_PyObject_HasAttrString
|
|
Karsten Hopp |
0fad6e |
# define PyObject_SetAttrString py3_PyObject_SetAttrString
|
|
Karsten Hopp |
0fad6e |
# define PyObject_CallFunctionObjArgs py3_PyObject_CallFunctionObjArgs
|
|
Karsten Hopp |
0fad6e |
# define PyEval_GetLocals py3_PyEval_GetLocals
|
|
Karsten Hopp |
0fad6e |
***************
|
|
Karsten Hopp |
0fad6e |
*** 269,274 ****
|
|
Karsten Hopp |
0fad6e |
--- 272,278 ----
|
|
Karsten Hopp |
0fad6e |
static int (*py3_PySequence_Check)(PyObject *);
|
|
Karsten Hopp |
0fad6e |
static Py_ssize_t (*py3_PySequence_Size)(PyObject *);
|
|
Karsten Hopp |
0fad6e |
static PyObject* (*py3_PySequence_GetItem)(PyObject *, Py_ssize_t);
|
|
Karsten Hopp |
0fad6e |
+ static PyObject* (*py3_PySequence_Fast)(PyObject *, const char *);
|
|
Karsten Hopp |
0fad6e |
static Py_ssize_t (*py3_PyTuple_Size)(PyObject *);
|
|
Karsten Hopp |
0fad6e |
static PyObject* (*py3_PyTuple_GetItem)(PyObject *, Py_ssize_t);
|
|
Karsten Hopp |
0fad6e |
static int (*py3_PyMapping_Check)(PyObject *);
|
|
Karsten Hopp |
0fad6e |
***************
|
|
Karsten Hopp |
0fad6e |
*** 282,287 ****
|
|
Karsten Hopp |
0fad6e |
--- 286,292 ----
|
|
Karsten Hopp |
0fad6e |
static int (*py3_PyRun_SimpleString)(char *);
|
|
Karsten Hopp |
0fad6e |
static PyObject* (*py3_PyRun_String)(char *, int, PyObject *, PyObject *);
|
|
Karsten Hopp |
0fad6e |
static PyObject* (*py3_PyObject_GetAttrString)(PyObject *, const char *);
|
|
Karsten Hopp |
0fad6e |
+ static int (*py3_PyObject_HasAttrString)(PyObject *, const char *);
|
|
Karsten Hopp |
0fad6e |
static PyObject* (*py3_PyObject_SetAttrString)(PyObject *, const char *, PyObject *);
|
|
Karsten Hopp |
0fad6e |
static PyObject* (*py3_PyObject_CallFunctionObjArgs)(PyObject *, ...);
|
|
Karsten Hopp |
0fad6e |
static PyObject* (*py3_PyEval_GetGlobals)();
|
|
Karsten Hopp |
0fad6e |
***************
|
|
Karsten Hopp |
0fad6e |
*** 425,430 ****
|
|
Karsten Hopp |
0fad6e |
--- 430,436 ----
|
|
Karsten Hopp |
0fad6e |
{"PySequence_Check", (PYTHON_PROC*)&py3_PySequence_Check},
|
|
Karsten Hopp |
0fad6e |
{"PySequence_Size", (PYTHON_PROC*)&py3_PySequence_Size},
|
|
Karsten Hopp |
0fad6e |
{"PySequence_GetItem", (PYTHON_PROC*)&py3_PySequence_GetItem},
|
|
Karsten Hopp |
0fad6e |
+ {"PySequence_Fast", (PYTHON_PROC*)&py3_PySequence_Fast},
|
|
Karsten Hopp |
0fad6e |
{"PyTuple_Size", (PYTHON_PROC*)&py3_PyTuple_Size},
|
|
Karsten Hopp |
0fad6e |
{"PyTuple_GetItem", (PYTHON_PROC*)&py3_PyTuple_GetItem},
|
|
Karsten Hopp |
0fad6e |
{"PySlice_GetIndicesEx", (PYTHON_PROC*)&py3_PySlice_GetIndicesEx},
|
|
Karsten Hopp |
0fad6e |
***************
|
|
Karsten Hopp |
0fad6e |
*** 435,440 ****
|
|
Karsten Hopp |
0fad6e |
--- 441,447 ----
|
|
Karsten Hopp |
0fad6e |
{"PyRun_SimpleString", (PYTHON_PROC*)&py3_PyRun_SimpleString},
|
|
Karsten Hopp |
0fad6e |
{"PyRun_String", (PYTHON_PROC*)&py3_PyRun_String},
|
|
Karsten Hopp |
0fad6e |
{"PyObject_GetAttrString", (PYTHON_PROC*)&py3_PyObject_GetAttrString},
|
|
Karsten Hopp |
0fad6e |
+ {"PyObject_HasAttrString", (PYTHON_PROC*)&py3_PyObject_HasAttrString},
|
|
Karsten Hopp |
0fad6e |
{"PyObject_SetAttrString", (PYTHON_PROC*)&py3_PyObject_SetAttrString},
|
|
Karsten Hopp |
0fad6e |
{"PyObject_CallFunctionObjArgs", (PYTHON_PROC*)&py3_PyObject_CallFunctionObjArgs},
|
|
Karsten Hopp |
0fad6e |
{"PyEval_GetGlobals", (PYTHON_PROC*)&py3_PyEval_GetGlobals},
|
|
Karsten Hopp |
0fad6e |
*** ../vim-7.3.1060/src/if_python.c 2013-05-30 12:40:36.000000000 +0200
|
|
Karsten Hopp |
0fad6e |
--- src/if_python.c 2013-05-30 12:48:47.000000000 +0200
|
|
Karsten Hopp |
0fad6e |
***************
|
|
Karsten Hopp |
0fad6e |
*** 103,108 ****
|
|
Karsten Hopp |
0fad6e |
--- 103,109 ----
|
|
Karsten Hopp |
0fad6e |
# define PyIntIntObjArgProc intintobjargproc
|
|
Karsten Hopp |
0fad6e |
# define Py_ssize_t_fmt "i"
|
|
Karsten Hopp |
0fad6e |
#endif
|
|
Karsten Hopp |
0fad6e |
+ #define Py_bytes_fmt "s"
|
|
Karsten Hopp |
0fad6e |
|
|
Karsten Hopp |
0fad6e |
/* Parser flags */
|
|
Karsten Hopp |
0fad6e |
#define single_input 256
|
|
Karsten Hopp |
0fad6e |
***************
|
|
Karsten Hopp |
0fad6e |
*** 187,192 ****
|
|
Karsten Hopp |
0fad6e |
--- 188,194 ----
|
|
Karsten Hopp |
0fad6e |
# define PySequence_Check dll_PySequence_Check
|
|
Karsten Hopp |
0fad6e |
# define PySequence_Size dll_PySequence_Size
|
|
Karsten Hopp |
0fad6e |
# define PySequence_GetItem dll_PySequence_GetItem
|
|
Karsten Hopp |
0fad6e |
+ # define PySequence_Fast dll_PySequence_Fast
|
|
Karsten Hopp |
0fad6e |
# define PyTuple_Size dll_PyTuple_Size
|
|
Karsten Hopp |
0fad6e |
# define PyTuple_GetItem dll_PyTuple_GetItem
|
|
Karsten Hopp |
0fad6e |
# define PyTuple_Type (*dll_PyTuple_Type)
|
|
Karsten Hopp |
0fad6e |
***************
|
|
Karsten Hopp |
0fad6e |
*** 207,212 ****
|
|
Karsten Hopp |
0fad6e |
--- 209,215 ----
|
|
Karsten Hopp |
0fad6e |
# define PyRun_SimpleString dll_PyRun_SimpleString
|
|
Karsten Hopp |
0fad6e |
# define PyRun_String dll_PyRun_String
|
|
Karsten Hopp |
0fad6e |
# define PyObject_GetAttrString dll_PyObject_GetAttrString
|
|
Karsten Hopp |
0fad6e |
+ # define PyObject_HasAttrString dll_PyObject_HasAttrString
|
|
Karsten Hopp |
0fad6e |
# define PyObject_SetAttrString dll_PyObject_SetAttrString
|
|
Karsten Hopp |
0fad6e |
# define PyObject_CallFunctionObjArgs dll_PyObject_CallFunctionObjArgs
|
|
Karsten Hopp |
0fad6e |
# define PyString_AsString dll_PyString_AsString
|
|
Karsten Hopp |
0fad6e |
***************
|
|
Karsten Hopp |
0fad6e |
*** 227,232 ****
|
|
Karsten Hopp |
0fad6e |
--- 230,236 ----
|
|
Karsten Hopp |
0fad6e |
# define PySys_SetArgv dll_PySys_SetArgv
|
|
Karsten Hopp |
0fad6e |
# define PyType_Type (*dll_PyType_Type)
|
|
Karsten Hopp |
0fad6e |
# define PyType_Ready (*dll_PyType_Ready)
|
|
Karsten Hopp |
0fad6e |
+ # define PyType_GenericAlloc dll_PyType_GenericAlloc
|
|
Karsten Hopp |
0fad6e |
# define Py_BuildValue dll_Py_BuildValue
|
|
Karsten Hopp |
0fad6e |
# define Py_FindMethod dll_Py_FindMethod
|
|
Karsten Hopp |
0fad6e |
# define Py_InitModule4 dll_Py_InitModule4
|
|
Karsten Hopp |
0fad6e |
***************
|
|
Karsten Hopp |
0fad6e |
*** 318,323 ****
|
|
Karsten Hopp |
0fad6e |
--- 322,328 ----
|
|
Karsten Hopp |
0fad6e |
static int (*dll_PySequence_Check)(PyObject *);
|
|
Karsten Hopp |
0fad6e |
static PyInt(*dll_PySequence_Size)(PyObject *);
|
|
Karsten Hopp |
0fad6e |
static PyObject*(*dll_PySequence_GetItem)(PyObject *, PyInt);
|
|
Karsten Hopp |
0fad6e |
+ static PyObject*(*dll_PySequence_Fast)(PyObject *, const char *);
|
|
Karsten Hopp |
0fad6e |
static PyInt(*dll_PyTuple_Size)(PyObject *);
|
|
Karsten Hopp |
0fad6e |
static PyObject*(*dll_PyTuple_GetItem)(PyObject *, PyInt);
|
|
Karsten Hopp |
0fad6e |
static PyTypeObject* dll_PyTuple_Type;
|
|
Karsten Hopp |
0fad6e |
***************
|
|
Karsten Hopp |
0fad6e |
*** 336,341 ****
|
|
Karsten Hopp |
0fad6e |
--- 341,347 ----
|
|
Karsten Hopp |
0fad6e |
static int(*dll_PyRun_SimpleString)(char *);
|
|
Karsten Hopp |
0fad6e |
static PyObject *(*dll_PyRun_String)(char *, int, PyObject *, PyObject *);
|
|
Karsten Hopp |
0fad6e |
static PyObject* (*dll_PyObject_GetAttrString)(PyObject *, const char *);
|
|
Karsten Hopp |
0fad6e |
+ static int (*dll_PyObject_HasAttrString)(PyObject *, const char *);
|
|
Karsten Hopp |
0fad6e |
static PyObject* (*dll_PyObject_SetAttrString)(PyObject *, const char *, PyObject *);
|
|
Karsten Hopp |
0fad6e |
static PyObject* (*dll_PyObject_CallFunctionObjArgs)(PyObject *, ...);
|
|
Karsten Hopp |
0fad6e |
static char*(*dll_PyString_AsString)(PyObject *);
|
|
Karsten Hopp |
0fad6e |
***************
|
|
Karsten Hopp |
0fad6e |
*** 354,359 ****
|
|
Karsten Hopp |
0fad6e |
--- 360,366 ----
|
|
Karsten Hopp |
0fad6e |
static int(*dll_PySys_SetArgv)(int, char **);
|
|
Karsten Hopp |
0fad6e |
static PyTypeObject* dll_PyType_Type;
|
|
Karsten Hopp |
0fad6e |
static int (*dll_PyType_Ready)(PyTypeObject *type);
|
|
Karsten Hopp |
0fad6e |
+ static PyObject* (*dll_PyType_GenericAlloc)(PyTypeObject *type, PyInt nitems);
|
|
Karsten Hopp |
0fad6e |
static PyObject*(*dll_Py_BuildValue)(char *, ...);
|
|
Karsten Hopp |
0fad6e |
static PyObject*(*dll_Py_FindMethod)(struct PyMethodDef[], PyObject *, char *);
|
|
Karsten Hopp |
0fad6e |
static PyObject*(*dll_Py_InitModule4)(char *, struct PyMethodDef *, char *, PyObject *, int);
|
|
Karsten Hopp |
0fad6e |
***************
|
|
Karsten Hopp |
0fad6e |
*** 475,483 ****
|
|
Karsten Hopp |
0fad6e |
{"PyList_SetItem", (PYTHON_PROC*)&dll_PyList_SetItem},
|
|
Karsten Hopp |
0fad6e |
{"PyList_Size", (PYTHON_PROC*)&dll_PyList_Size},
|
|
Karsten Hopp |
0fad6e |
{"PyList_Type", (PYTHON_PROC*)&dll_PyList_Type},
|
|
Karsten Hopp |
0fad6e |
- {"PySequence_GetItem", (PYTHON_PROC*)&dll_PySequence_GetItem},
|
|
Karsten Hopp |
0fad6e |
{"PySequence_Size", (PYTHON_PROC*)&dll_PySequence_Size},
|
|
Karsten Hopp |
0fad6e |
{"PySequence_Check", (PYTHON_PROC*)&dll_PySequence_Check},
|
|
Karsten Hopp |
0fad6e |
{"PyTuple_GetItem", (PYTHON_PROC*)&dll_PyTuple_GetItem},
|
|
Karsten Hopp |
0fad6e |
{"PyTuple_Size", (PYTHON_PROC*)&dll_PyTuple_Size},
|
|
Karsten Hopp |
0fad6e |
{"PyTuple_Type", (PYTHON_PROC*)&dll_PyTuple_Type},
|
|
Karsten Hopp |
0fad6e |
--- 482,491 ----
|
|
Karsten Hopp |
0fad6e |
{"PyList_SetItem", (PYTHON_PROC*)&dll_PyList_SetItem},
|
|
Karsten Hopp |
0fad6e |
{"PyList_Size", (PYTHON_PROC*)&dll_PyList_Size},
|
|
Karsten Hopp |
0fad6e |
{"PyList_Type", (PYTHON_PROC*)&dll_PyList_Type},
|
|
Karsten Hopp |
0fad6e |
{"PySequence_Size", (PYTHON_PROC*)&dll_PySequence_Size},
|
|
Karsten Hopp |
0fad6e |
{"PySequence_Check", (PYTHON_PROC*)&dll_PySequence_Check},
|
|
Karsten Hopp |
0fad6e |
+ {"PySequence_GetItem", (PYTHON_PROC*)&dll_PySequence_GetItem},
|
|
Karsten Hopp |
0fad6e |
+ {"PySequence_Fast", (PYTHON_PROC*)&dll_PySequence_Fast},
|
|
Karsten Hopp |
0fad6e |
{"PyTuple_GetItem", (PYTHON_PROC*)&dll_PyTuple_GetItem},
|
|
Karsten Hopp |
0fad6e |
{"PyTuple_Size", (PYTHON_PROC*)&dll_PyTuple_Size},
|
|
Karsten Hopp |
0fad6e |
{"PyTuple_Type", (PYTHON_PROC*)&dll_PyTuple_Type},
|
|
Karsten Hopp |
0fad6e |
***************
|
|
Karsten Hopp |
0fad6e |
*** 496,501 ****
|
|
Karsten Hopp |
0fad6e |
--- 504,510 ----
|
|
Karsten Hopp |
0fad6e |
{"PyRun_SimpleString", (PYTHON_PROC*)&dll_PyRun_SimpleString},
|
|
Karsten Hopp |
0fad6e |
{"PyRun_String", (PYTHON_PROC*)&dll_PyRun_String},
|
|
Karsten Hopp |
0fad6e |
{"PyObject_GetAttrString", (PYTHON_PROC*)&dll_PyObject_GetAttrString},
|
|
Karsten Hopp |
0fad6e |
+ {"PyObject_HasAttrString", (PYTHON_PROC*)&dll_PyObject_HasAttrString},
|
|
Karsten Hopp |
0fad6e |
{"PyObject_SetAttrString", (PYTHON_PROC*)&dll_PyObject_SetAttrString},
|
|
Karsten Hopp |
0fad6e |
{"PyObject_CallFunctionObjArgs", (PYTHON_PROC*)&dll_PyObject_CallFunctionObjArgs},
|
|
Karsten Hopp |
0fad6e |
{"PyString_AsString", (PYTHON_PROC*)&dll_PyString_AsString},
|
|
Karsten Hopp |
0fad6e |
***************
|
|
Karsten Hopp |
0fad6e |
*** 514,519 ****
|
|
Karsten Hopp |
0fad6e |
--- 523,529 ----
|
|
Karsten Hopp |
0fad6e |
{"PySys_SetArgv", (PYTHON_PROC*)&dll_PySys_SetArgv},
|
|
Karsten Hopp |
0fad6e |
{"PyType_Type", (PYTHON_PROC*)&dll_PyType_Type},
|
|
Karsten Hopp |
0fad6e |
{"PyType_Ready", (PYTHON_PROC*)&dll_PyType_Ready},
|
|
Karsten Hopp |
0fad6e |
+ {"PyType_GenericAlloc", (PYTHON_PROC*)&dll_PyType_GenericAlloc},
|
|
Karsten Hopp |
0fad6e |
{"Py_FindMethod", (PYTHON_PROC*)&dll_Py_FindMethod},
|
|
Karsten Hopp |
0fad6e |
{"Py_SetPythonHome", (PYTHON_PROC*)&dll_Py_SetPythonHome},
|
|
Karsten Hopp |
0fad6e |
{"Py_Initialize", (PYTHON_PROC*)&dll_Py_Initialize},
|
|
Karsten Hopp |
0fad6e |
***************
|
|
Karsten Hopp |
0fad6e |
*** 1116,1125 ****
|
|
Karsten Hopp |
0fad6e |
(PyIntObjArgProc) BufferAssItem, /* sq_ass_item, x[i]=v */
|
|
Karsten Hopp |
0fad6e |
(PyIntIntObjArgProc) BufferAssSlice, /* sq_ass_slice, x[i:j]=v */
|
|
Karsten Hopp |
0fad6e |
(objobjproc) 0,
|
|
Karsten Hopp |
0fad6e |
- #if PY_MAJOR_VERSION >= 2
|
|
Karsten Hopp |
0fad6e |
(binaryfunc) 0,
|
|
Karsten Hopp |
0fad6e |
0,
|
|
Karsten Hopp |
0fad6e |
- #endif
|
|
Karsten Hopp |
0fad6e |
};
|
|
Karsten Hopp |
0fad6e |
|
|
Karsten Hopp |
0fad6e |
/* Buffer object - Implementation
|
|
Karsten Hopp |
0fad6e |
--- 1126,1133 ----
|
|
Karsten Hopp |
0fad6e |
*** ../vim-7.3.1060/src/proto/eval.pro 2013-05-30 12:35:48.000000000 +0200
|
|
Karsten Hopp |
0fad6e |
--- src/proto/eval.pro 2013-05-30 12:47:48.000000000 +0200
|
|
Karsten Hopp |
0fad6e |
***************
|
|
Karsten Hopp |
0fad6e |
*** 75,80 ****
|
|
Karsten Hopp |
0fad6e |
--- 75,81 ----
|
|
Karsten Hopp |
0fad6e |
dictitem_T *dict_find __ARGS((dict_T *d, char_u *key, int len));
|
|
Karsten Hopp |
0fad6e |
char_u *get_dict_string __ARGS((dict_T *d, char_u *key, int save));
|
|
Karsten Hopp |
0fad6e |
long get_dict_number __ARGS((dict_T *d, char_u *key));
|
|
Karsten Hopp |
0fad6e |
+ void dict_extend __ARGS((dict_T *d1, dict_T *d2, char_u *action));
|
|
Karsten Hopp |
0fad6e |
char_u *get_function_name __ARGS((expand_T *xp, int idx));
|
|
Karsten Hopp |
0fad6e |
char_u *get_expr_name __ARGS((expand_T *xp, int idx));
|
|
Karsten Hopp |
0fad6e |
char_u *get_expanded_name __ARGS((char_u *name, int check));
|
|
Karsten Hopp |
0fad6e |
*** ../vim-7.3.1060/src/testdir/test86.in 2013-05-30 12:26:52.000000000 +0200
|
|
Karsten Hopp |
0fad6e |
--- src/testdir/test86.in 2013-05-30 12:47:48.000000000 +0200
|
|
Karsten Hopp |
0fad6e |
***************
|
|
Karsten Hopp |
0fad6e |
*** 31,46 ****
|
|
Karsten Hopp |
0fad6e |
:"
|
|
Karsten Hopp |
0fad6e |
:" Extending Dictionary directly with different types
|
|
Karsten Hopp |
0fad6e |
:let d = {}
|
|
Karsten Hopp |
0fad6e |
! :py d=vim.bindeval('d')
|
|
Karsten Hopp |
0fad6e |
! :py d['1']='asd'
|
|
Karsten Hopp |
0fad6e |
! :py d['b']=[1, 2, f]
|
|
Karsten Hopp |
0fad6e |
! :py d['-1']={'a': 1}
|
|
Karsten Hopp |
0fad6e |
! :let dkeys = []
|
|
Karsten Hopp |
0fad6e |
! :py dk=vim.bindeval('dkeys')
|
|
Karsten Hopp |
0fad6e |
! :py dkeys=d.keys()
|
|
Karsten Hopp |
0fad6e |
! :py dkeys.sort()
|
|
Karsten Hopp |
0fad6e |
! :py dk.extend(dkeys)
|
|
Karsten Hopp |
0fad6e |
! :$put =string(dkeys)
|
|
Karsten Hopp |
0fad6e |
:for [key, val] in sort(items(d))
|
|
Karsten Hopp |
0fad6e |
: $put =string(key) . ' : ' . string(val)
|
|
Karsten Hopp |
0fad6e |
: unlet key val
|
|
Karsten Hopp |
0fad6e |
--- 31,52 ----
|
|
Karsten Hopp |
0fad6e |
:"
|
|
Karsten Hopp |
0fad6e |
:" Extending Dictionary directly with different types
|
|
Karsten Hopp |
0fad6e |
:let d = {}
|
|
Karsten Hopp |
0fad6e |
! py << EOF
|
|
Karsten Hopp |
0fad6e |
! d=vim.bindeval('d')
|
|
Karsten Hopp |
0fad6e |
! d['1']='asd'
|
|
Karsten Hopp |
0fad6e |
! d.update(b=[1, 2, f])
|
|
Karsten Hopp |
0fad6e |
! d.update((('-1', {'a': 1}),))
|
|
Karsten Hopp |
0fad6e |
! d.update({'0': -1})
|
|
Karsten Hopp |
0fad6e |
! dk = d.keys()
|
|
Karsten Hopp |
0fad6e |
! dv = d.values()
|
|
Karsten Hopp |
0fad6e |
! di = d.items()
|
|
Karsten Hopp |
0fad6e |
! dk.sort(key=repr)
|
|
Karsten Hopp |
0fad6e |
! dv.sort(key=repr)
|
|
Karsten Hopp |
0fad6e |
! di.sort(key=repr)
|
|
Karsten Hopp |
0fad6e |
! EOF
|
|
Karsten Hopp |
0fad6e |
! :$put =pyeval('repr(dk)')
|
|
Karsten Hopp |
0fad6e |
! :$put =substitute(pyeval('repr(dv)'),'0x\x\+','','g')
|
|
Karsten Hopp |
0fad6e |
! :$put =substitute(pyeval('repr(di)'),'0x\x\+','','g')
|
|
Karsten Hopp |
0fad6e |
:for [key, val] in sort(items(d))
|
|
Karsten Hopp |
0fad6e |
: $put =string(key) . ' : ' . string(val)
|
|
Karsten Hopp |
0fad6e |
: unlet key val
|
|
Karsten Hopp |
0fad6e |
***************
|
|
Karsten Hopp |
0fad6e |
*** 60,66 ****
|
|
Karsten Hopp |
0fad6e |
--- 66,85 ----
|
|
Karsten Hopp |
0fad6e |
:$put =string(l)
|
|
Karsten Hopp |
0fad6e |
:"
|
|
Karsten Hopp |
0fad6e |
:py del d['-1']
|
|
Karsten Hopp |
0fad6e |
+ :$put =string(pyeval('d.get(''b'', 1)'))
|
|
Karsten Hopp |
0fad6e |
+ :$put =string(pyeval('d.pop(''b'')'))
|
|
Karsten Hopp |
0fad6e |
+ :$put =string(pyeval('d.get(''b'', 1)'))
|
|
Karsten Hopp |
0fad6e |
+ :$put =string(pyeval('d.pop(''1'', 2)'))
|
|
Karsten Hopp |
0fad6e |
+ :$put =string(pyeval('d.pop(''1'', 2)'))
|
|
Karsten Hopp |
0fad6e |
+ :$put =pyeval('repr(d.has_key(''0''))')
|
|
Karsten Hopp |
0fad6e |
+ :$put =pyeval('repr(d.has_key(''1''))')
|
|
Karsten Hopp |
0fad6e |
+ :$put =pyeval('repr(''0'' in d)')
|
|
Karsten Hopp |
0fad6e |
+ :$put =pyeval('repr(''1'' in d)')
|
|
Karsten Hopp |
0fad6e |
+ :$put =pyeval('repr(list(iter(d)))')
|
|
Karsten Hopp |
0fad6e |
:$put =string(d)
|
|
Karsten Hopp |
0fad6e |
+ :$put =pyeval('repr(d.popitem(''0''))')
|
|
Karsten Hopp |
0fad6e |
+ :$put =pyeval('repr(d.get(''0''))')
|
|
Karsten Hopp |
0fad6e |
+ :$put =pyeval('repr(list(iter(d)))')
|
|
Karsten Hopp |
0fad6e |
:"
|
|
Karsten Hopp |
0fad6e |
:" removing items out of range: silently skip items that don't exist
|
|
Karsten Hopp |
0fad6e |
:let l = [0, 1, 2, 3]
|
|
Karsten Hopp |
0fad6e |
***************
|
|
Karsten Hopp |
0fad6e |
*** 198,203 ****
|
|
Karsten Hopp |
0fad6e |
--- 217,225 ----
|
|
Karsten Hopp |
0fad6e |
em('d[""]=1')
|
|
Karsten Hopp |
0fad6e |
em('d["a\\0b"]=1')
|
|
Karsten Hopp |
0fad6e |
em('d[u"a\\0b"]=1')
|
|
Karsten Hopp |
0fad6e |
+
|
|
Karsten Hopp |
0fad6e |
+ em('d.pop("abc")')
|
|
Karsten Hopp |
0fad6e |
+ em('d.popitem("abc")')
|
|
Karsten Hopp |
0fad6e |
EOF
|
|
Karsten Hopp |
0fad6e |
:$put =messages
|
|
Karsten Hopp |
0fad6e |
:unlet messages
|
|
Karsten Hopp |
0fad6e |
***************
|
|
Karsten Hopp |
0fad6e |
*** 709,714 ****
|
|
Karsten Hopp |
0fad6e |
--- 731,740 ----
|
|
Karsten Hopp |
0fad6e |
del o
|
|
Karsten Hopp |
0fad6e |
EOF
|
|
Karsten Hopp |
0fad6e |
:"
|
|
Karsten Hopp |
0fad6e |
+ :" Test vim.*.__new__
|
|
Karsten Hopp |
0fad6e |
+ :$put =string(pyeval('vim.Dictionary({})'))
|
|
Karsten Hopp |
0fad6e |
+ :$put =string(pyeval('vim.Dictionary(a=1)'))
|
|
Karsten Hopp |
0fad6e |
+ :$put =string(pyeval('vim.Dictionary(((''a'', 1),))'))
|
|
Karsten Hopp |
0fad6e |
:"
|
|
Karsten Hopp |
0fad6e |
:" Test stdout/stderr
|
|
Karsten Hopp |
0fad6e |
:redir => messages
|
|
Karsten Hopp |
0fad6e |
***************
|
|
Karsten Hopp |
0fad6e |
*** 718,723 ****
|
|
Karsten Hopp |
0fad6e |
--- 744,759 ----
|
|
Karsten Hopp |
0fad6e |
:py sys.stderr.writelines(iter('abc'))
|
|
Karsten Hopp |
0fad6e |
:redir END
|
|
Karsten Hopp |
0fad6e |
:$put =string(substitute(messages, '\d\+', '', 'g'))
|
|
Karsten Hopp |
0fad6e |
+ :" Test subclassing
|
|
Karsten Hopp |
0fad6e |
+ py << EOF
|
|
Karsten Hopp |
0fad6e |
+ class DupDict(vim.Dictionary):
|
|
Karsten Hopp |
0fad6e |
+ def __setitem__(self, key, value):
|
|
Karsten Hopp |
0fad6e |
+ super(DupDict, self).__setitem__(key, value)
|
|
Karsten Hopp |
0fad6e |
+ super(DupDict, self).__setitem__('dup_' + key, value)
|
|
Karsten Hopp |
0fad6e |
+ dd = DupDict()
|
|
Karsten Hopp |
0fad6e |
+ dd['a'] = 'b'
|
|
Karsten Hopp |
0fad6e |
+ EOF
|
|
Karsten Hopp |
0fad6e |
+ :$put =string(sort(keys(pyeval('dd'))))
|
|
Karsten Hopp |
0fad6e |
:"
|
|
Karsten Hopp |
0fad6e |
:" Test exceptions
|
|
Karsten Hopp |
0fad6e |
:fun Exe(e)
|
|
Karsten Hopp |
0fad6e |
*** ../vim-7.3.1060/src/testdir/test86.ok 2013-05-30 12:26:52.000000000 +0200
|
|
Karsten Hopp |
0fad6e |
--- src/testdir/test86.ok 2013-05-30 12:47:48.000000000 +0200
|
|
Karsten Hopp |
0fad6e |
***************
|
|
Karsten Hopp |
0fad6e |
*** 4,16 ****
|
|
Karsten Hopp |
0fad6e |
Vim(put):E684:
|
|
Karsten Hopp |
0fad6e |
[0, 'as''d', [1, 2, function('strlen'), {'a': 1}]]
|
|
Karsten Hopp |
0fad6e |
[0, function('strlen'), [1, 2, function('strlen'), {'a': 1}]]
|
|
Karsten Hopp |
0fad6e |
! ['-1', '1', 'b']
|
|
Karsten Hopp |
0fad6e |
'-1' : {'a': 1}
|
|
Karsten Hopp |
0fad6e |
'1' : 'asd'
|
|
Karsten Hopp |
0fad6e |
'b' : [1, 2, function('strlen')]
|
|
Karsten Hopp |
0fad6e |
[0, function('strlen')]
|
|
Karsten Hopp |
0fad6e |
[3]
|
|
Karsten Hopp |
0fad6e |
! {'1': 'asd', 'b': [1, 2, function('strlen')]}
|
|
Karsten Hopp |
0fad6e |
[0, 1, 2, 3]
|
|
Karsten Hopp |
0fad6e |
[0, 1, 2, 3]
|
|
Karsten Hopp |
0fad6e |
[0, 1, 3]
|
|
Karsten Hopp |
0fad6e |
--- 4,32 ----
|
|
Karsten Hopp |
0fad6e |
Vim(put):E684:
|
|
Karsten Hopp |
0fad6e |
[0, 'as''d', [1, 2, function('strlen'), {'a': 1}]]
|
|
Karsten Hopp |
0fad6e |
[0, function('strlen'), [1, 2, function('strlen'), {'a': 1}]]
|
|
Karsten Hopp |
0fad6e |
! ['-1', '0', '1', 'b']
|
|
Karsten Hopp |
0fad6e |
! ['asd', -1L, <vim.dictionary object at >, <vim.list object at >]
|
|
Karsten Hopp |
0fad6e |
! [('-1', <vim.dictionary object at >), ('0', -1L), ('1', 'asd'), ('b', <vim.list object at >)]
|
|
Karsten Hopp |
0fad6e |
'-1' : {'a': 1}
|
|
Karsten Hopp |
0fad6e |
+ '0' : -1
|
|
Karsten Hopp |
0fad6e |
'1' : 'asd'
|
|
Karsten Hopp |
0fad6e |
'b' : [1, 2, function('strlen')]
|
|
Karsten Hopp |
0fad6e |
[0, function('strlen')]
|
|
Karsten Hopp |
0fad6e |
[3]
|
|
Karsten Hopp |
0fad6e |
! [1, 2, function('strlen')]
|
|
Karsten Hopp |
0fad6e |
! [1, 2, function('strlen')]
|
|
Karsten Hopp |
0fad6e |
! 1
|
|
Karsten Hopp |
0fad6e |
! 'asd'
|
|
Karsten Hopp |
0fad6e |
! 2
|
|
Karsten Hopp |
0fad6e |
! True
|
|
Karsten Hopp |
0fad6e |
! False
|
|
Karsten Hopp |
0fad6e |
! True
|
|
Karsten Hopp |
0fad6e |
! False
|
|
Karsten Hopp |
0fad6e |
! ['0']
|
|
Karsten Hopp |
0fad6e |
! {'0': -1}
|
|
Karsten Hopp |
0fad6e |
! ('', -1L)
|
|
Karsten Hopp |
0fad6e |
! None
|
|
Karsten Hopp |
0fad6e |
! []
|
|
Karsten Hopp |
0fad6e |
[0, 1, 2, 3]
|
|
Karsten Hopp |
0fad6e |
[0, 1, 2, 3]
|
|
Karsten Hopp |
0fad6e |
[0, 1, 3]
|
|
Karsten Hopp |
0fad6e |
***************
|
|
Karsten Hopp |
0fad6e |
*** 44,49 ****
|
|
Karsten Hopp |
0fad6e |
--- 60,67 ----
|
|
Karsten Hopp |
0fad6e |
ValueError
|
|
Karsten Hopp |
0fad6e |
TypeError
|
|
Karsten Hopp |
0fad6e |
TypeError
|
|
Karsten Hopp |
0fad6e |
+ KeyError
|
|
Karsten Hopp |
0fad6e |
+ KeyError
|
|
Karsten Hopp |
0fad6e |
d : locked:0;scope:0
|
|
Karsten Hopp |
0fad6e |
dl : locked:1;scope:0
|
|
Karsten Hopp |
0fad6e |
v: : locked:2;scope:1
|
|
Karsten Hopp |
0fad6e |
***************
|
|
Karsten Hopp |
0fad6e |
*** 387,396 ****
|
|
Karsten Hopp |
0fad6e |
window:__dir__,__members__,buffer,col,cursor,height,number,options,row,tabpage,valid,vars
|
|
Karsten Hopp |
0fad6e |
tabpage:__dir__,__members__,number,valid,vars,window,windows
|
|
Karsten Hopp |
0fad6e |
range:__dir__,__members__,append,end,start
|
|
Karsten Hopp |
0fad6e |
! dictionary:__dir__,__members__,keys,locked,scope
|
|
Karsten Hopp |
0fad6e |
list:__dir__,__members__,extend,locked
|
|
Karsten Hopp |
0fad6e |
function:__call__,__dir__,__members__,softspace
|
|
Karsten Hopp |
0fad6e |
output:__dir__,__members__,flush,softspace,write,writelines
|
|
Karsten Hopp |
0fad6e |
'
|
|
Karsten Hopp |
0fad6e |
abcdef
|
|
Karsten Hopp |
0fad6e |
line :
|
|
Karsten Hopp |
0fad6e |
--- 405,417 ----
|
|
Karsten Hopp |
0fad6e |
window:__dir__,__members__,buffer,col,cursor,height,number,options,row,tabpage,valid,vars
|
|
Karsten Hopp |
0fad6e |
tabpage:__dir__,__members__,number,valid,vars,window,windows
|
|
Karsten Hopp |
0fad6e |
range:__dir__,__members__,append,end,start
|
|
Karsten Hopp |
0fad6e |
! dictionary:__dir__,__members__,get,has_key,items,keys,locked,pop,popitem,scope,update,values
|
|
Karsten Hopp |
0fad6e |
list:__dir__,__members__,extend,locked
|
|
Karsten Hopp |
0fad6e |
function:__call__,__dir__,__members__,softspace
|
|
Karsten Hopp |
0fad6e |
output:__dir__,__members__,flush,softspace,write,writelines
|
|
Karsten Hopp |
0fad6e |
+ {}
|
|
Karsten Hopp |
0fad6e |
+ {'a': 1}
|
|
Karsten Hopp |
0fad6e |
+ {'a': 1}
|
|
Karsten Hopp |
0fad6e |
'
|
|
Karsten Hopp |
0fad6e |
abcdef
|
|
Karsten Hopp |
0fad6e |
line :
|
|
Karsten Hopp |
0fad6e |
***************
|
|
Karsten Hopp |
0fad6e |
*** 398,403 ****
|
|
Karsten Hopp |
0fad6e |
--- 419,425 ----
|
|
Karsten Hopp |
0fad6e |
abc
|
|
Karsten Hopp |
0fad6e |
line :
|
|
Karsten Hopp |
0fad6e |
abc'
|
|
Karsten Hopp |
0fad6e |
+ ['a', 'dup_a']
|
|
Karsten Hopp |
0fad6e |
(<class 'vim.error'>, error('abc',))
|
|
Karsten Hopp |
0fad6e |
(<class 'vim.error'>, error('def',))
|
|
Karsten Hopp |
0fad6e |
(<class 'vim.error'>, error('ghi',))
|
|
Karsten Hopp |
0fad6e |
*** ../vim-7.3.1060/src/testdir/test87.in 2013-05-30 12:26:52.000000000 +0200
|
|
Karsten Hopp |
0fad6e |
--- src/testdir/test87.in 2013-05-30 12:47:48.000000000 +0200
|
|
Karsten Hopp |
0fad6e |
***************
|
|
Karsten Hopp |
0fad6e |
*** 26,41 ****
|
|
Karsten Hopp |
0fad6e |
:"
|
|
Karsten Hopp |
0fad6e |
:" Extending Dictionary directly with different types
|
|
Karsten Hopp |
0fad6e |
:let d = {}
|
|
Karsten Hopp |
0fad6e |
! :py3 d=vim.bindeval('d')
|
|
Karsten Hopp |
0fad6e |
! :py3 d['1']='asd'
|
|
Karsten Hopp |
0fad6e |
! :py3 d['b']=[1, 2, f]
|
|
Karsten Hopp |
0fad6e |
! :py3 d['-1']={'a': 1}
|
|
Karsten Hopp |
0fad6e |
! :let dkeys = []
|
|
Karsten Hopp |
0fad6e |
! :py3 dk=vim.bindeval('dkeys')
|
|
Karsten Hopp |
0fad6e |
! :py3 dkeys=d.keys()
|
|
Karsten Hopp |
0fad6e |
! :py3 dkeys.sort()
|
|
Karsten Hopp |
0fad6e |
! :py3 dk+=dkeys
|
|
Karsten Hopp |
0fad6e |
! :$put =string(dkeys)
|
|
Karsten Hopp |
0fad6e |
:for [key, val] in sort(items(d))
|
|
Karsten Hopp |
0fad6e |
: $put =string(key) . ' : ' . string(val)
|
|
Karsten Hopp |
0fad6e |
: unlet key val
|
|
Karsten Hopp |
0fad6e |
--- 26,47 ----
|
|
Karsten Hopp |
0fad6e |
:"
|
|
Karsten Hopp |
0fad6e |
:" Extending Dictionary directly with different types
|
|
Karsten Hopp |
0fad6e |
:let d = {}
|
|
Karsten Hopp |
0fad6e |
! py3 << EOF
|
|
Karsten Hopp |
0fad6e |
! d=vim.bindeval('d')
|
|
Karsten Hopp |
0fad6e |
! d['1']='asd'
|
|
Karsten Hopp |
0fad6e |
! d.update(b=[1, 2, f])
|
|
Karsten Hopp |
0fad6e |
! d.update((('-1', {'a': 1}),))
|
|
Karsten Hopp |
0fad6e |
! d.update({'0': -1})
|
|
Karsten Hopp |
0fad6e |
! dk = d.keys()
|
|
Karsten Hopp |
0fad6e |
! dv = d.values()
|
|
Karsten Hopp |
0fad6e |
! di = d.items()
|
|
Karsten Hopp |
0fad6e |
! dk.sort(key=repr)
|
|
Karsten Hopp |
0fad6e |
! dv.sort(key=repr)
|
|
Karsten Hopp |
0fad6e |
! di.sort(key=repr)
|
|
Karsten Hopp |
0fad6e |
! EOF
|
|
Karsten Hopp |
0fad6e |
! :$put =py3eval('repr(dk)')
|
|
Karsten Hopp |
0fad6e |
! :$put =substitute(py3eval('repr(dv)'),'0x\x\+','','g')
|
|
Karsten Hopp |
0fad6e |
! :$put =substitute(py3eval('repr(di)'),'0x\x\+','','g')
|
|
Karsten Hopp |
0fad6e |
:for [key, val] in sort(items(d))
|
|
Karsten Hopp |
0fad6e |
: $put =string(key) . ' : ' . string(val)
|
|
Karsten Hopp |
0fad6e |
: unlet key val
|
|
Karsten Hopp |
0fad6e |
***************
|
|
Karsten Hopp |
0fad6e |
*** 55,61 ****
|
|
Karsten Hopp |
0fad6e |
--- 61,80 ----
|
|
Karsten Hopp |
0fad6e |
:$put =string(l)
|
|
Karsten Hopp |
0fad6e |
:"
|
|
Karsten Hopp |
0fad6e |
:py3 del d['-1']
|
|
Karsten Hopp |
0fad6e |
+ :$put =string(py3eval('d.get(''b'', 1)'))
|
|
Karsten Hopp |
0fad6e |
+ :$put =string(py3eval('d.pop(''b'')'))
|
|
Karsten Hopp |
0fad6e |
+ :$put =string(py3eval('d.get(''b'', 1)'))
|
|
Karsten Hopp |
0fad6e |
+ :$put =string(py3eval('d.pop(''1'', 2)'))
|
|
Karsten Hopp |
0fad6e |
+ :$put =string(py3eval('d.pop(''1'', 2)'))
|
|
Karsten Hopp |
0fad6e |
+ :$put =py3eval('repr(d.has_key(''0''))')
|
|
Karsten Hopp |
0fad6e |
+ :$put =py3eval('repr(d.has_key(''1''))')
|
|
Karsten Hopp |
0fad6e |
+ :$put =py3eval('repr(''0'' in d)')
|
|
Karsten Hopp |
0fad6e |
+ :$put =py3eval('repr(''1'' in d)')
|
|
Karsten Hopp |
0fad6e |
+ :$put =py3eval('repr(list(iter(d)))')
|
|
Karsten Hopp |
0fad6e |
:$put =string(d)
|
|
Karsten Hopp |
0fad6e |
+ :$put =py3eval('repr(d.popitem(''0''))')
|
|
Karsten Hopp |
0fad6e |
+ :$put =py3eval('repr(d.get(''0''))')
|
|
Karsten Hopp |
0fad6e |
+ :$put =py3eval('repr(list(iter(d)))')
|
|
Karsten Hopp |
0fad6e |
:"
|
|
Karsten Hopp |
0fad6e |
:" removing items out of range: silently skip items that don't exist
|
|
Karsten Hopp |
0fad6e |
:let l = [0, 1, 2, 3]
|
|
Karsten Hopp |
0fad6e |
***************
|
|
Karsten Hopp |
0fad6e |
*** 181,215 ****
|
|
Karsten Hopp |
0fad6e |
:py3 <
|
|
Karsten Hopp |
0fad6e |
d=vim.bindeval('{}')
|
|
Karsten Hopp |
0fad6e |
m=vim.bindeval('messages')
|
|
Karsten Hopp |
0fad6e |
! try:
|
|
Karsten Hopp |
0fad6e |
! d['abc']
|
|
Karsten Hopp |
0fad6e |
! except Exception as e:
|
|
Karsten Hopp |
0fad6e |
! m.extend([e.__class__.__name__])
|
|
Karsten Hopp |
0fad6e |
!
|
|
Karsten Hopp |
0fad6e |
! try:
|
|
Karsten Hopp |
0fad6e |
! d['abc']="\0"
|
|
Karsten Hopp |
0fad6e |
! except Exception as e:
|
|
Karsten Hopp |
0fad6e |
! m.extend([e.__class__.__name__])
|
|
Karsten Hopp |
0fad6e |
!
|
|
Karsten Hopp |
0fad6e |
! try:
|
|
Karsten Hopp |
0fad6e |
! d['abc']=vim
|
|
Karsten Hopp |
0fad6e |
! except Exception as e:
|
|
Karsten Hopp |
0fad6e |
! m.extend([e.__class__.__name__])
|
|
Karsten Hopp |
0fad6e |
!
|
|
Karsten Hopp |
0fad6e |
! try:
|
|
Karsten Hopp |
0fad6e |
! d['']=1
|
|
Karsten Hopp |
0fad6e |
! except Exception as e:
|
|
Karsten Hopp |
0fad6e |
! m.extend([e.__class__.__name__])
|
|
Karsten Hopp |
0fad6e |
|
|
Karsten Hopp |
0fad6e |
! try:
|
|
Karsten Hopp |
0fad6e |
! d['a\0b']=1
|
|
Karsten Hopp |
0fad6e |
! except Exception as e:
|
|
Karsten Hopp |
0fad6e |
! m.extend([e.__class__.__name__])
|
|
Karsten Hopp |
0fad6e |
|
|
Karsten Hopp |
0fad6e |
! try:
|
|
Karsten Hopp |
0fad6e |
! d[b'a\0b']=1
|
|
Karsten Hopp |
0fad6e |
! except Exception as e:
|
|
Karsten Hopp |
0fad6e |
! m.extend([e.__class__.__name__])
|
|
Karsten Hopp |
0fad6e |
EOF
|
|
Karsten Hopp |
0fad6e |
:$put =messages
|
|
Karsten Hopp |
0fad6e |
:unlet messages
|
|
Karsten Hopp |
0fad6e |
--- 200,220 ----
|
|
Karsten Hopp |
0fad6e |
:py3 <
|
|
Karsten Hopp |
0fad6e |
d=vim.bindeval('{}')
|
|
Karsten Hopp |
0fad6e |
m=vim.bindeval('messages')
|
|
Karsten Hopp |
0fad6e |
! def em(expr, g=globals(), l=locals()):
|
|
Karsten Hopp |
0fad6e |
! try:
|
|
Karsten Hopp |
0fad6e |
! exec(expr, g, l)
|
|
Karsten Hopp |
0fad6e |
! except Exception as e:
|
|
Karsten Hopp |
0fad6e |
! m.extend([e.__class__.__name__])
|
|
Karsten Hopp |
0fad6e |
|
|
Karsten Hopp |
0fad6e |
! em('d["abc"]')
|
|
Karsten Hopp |
0fad6e |
! em('d["abc"]="\\0"')
|
|
Karsten Hopp |
0fad6e |
! em('d["abc"]=vim')
|
|
Karsten Hopp |
0fad6e |
! em('d[""]=1')
|
|
Karsten Hopp |
0fad6e |
! em('d["a\\0b"]=1')
|
|
Karsten Hopp |
0fad6e |
! em('d[b"a\\0b"]=1')
|
|
Karsten Hopp |
0fad6e |
|
|
Karsten Hopp |
0fad6e |
! em('d.pop("abc")')
|
|
Karsten Hopp |
0fad6e |
! em('d.popitem("abc")')
|
|
Karsten Hopp |
0fad6e |
EOF
|
|
Karsten Hopp |
0fad6e |
:$put =messages
|
|
Karsten Hopp |
0fad6e |
:unlet messages
|
|
Karsten Hopp |
0fad6e |
***************
|
|
Karsten Hopp |
0fad6e |
*** 687,692 ****
|
|
Karsten Hopp |
0fad6e |
--- 692,701 ----
|
|
Karsten Hopp |
0fad6e |
del o
|
|
Karsten Hopp |
0fad6e |
EOF
|
|
Karsten Hopp |
0fad6e |
:"
|
|
Karsten Hopp |
0fad6e |
+ :" Test vim.Dictionary.__new__
|
|
Karsten Hopp |
0fad6e |
+ :$put =string(py3eval('vim.Dictionary({})'))
|
|
Karsten Hopp |
0fad6e |
+ :$put =string(py3eval('vim.Dictionary(a=1)'))
|
|
Karsten Hopp |
0fad6e |
+ :$put =string(py3eval('vim.Dictionary(((''a'', 1),))'))
|
|
Karsten Hopp |
0fad6e |
:"
|
|
Karsten Hopp |
0fad6e |
:" Test stdout/stderr
|
|
Karsten Hopp |
0fad6e |
:redir => messages
|
|
Karsten Hopp |
0fad6e |
***************
|
|
Karsten Hopp |
0fad6e |
*** 696,701 ****
|
|
Karsten Hopp |
0fad6e |
--- 705,720 ----
|
|
Karsten Hopp |
0fad6e |
:py sys.stderr.writelines(iter('abc'))
|
|
Karsten Hopp |
0fad6e |
:redir END
|
|
Karsten Hopp |
0fad6e |
:$put =string(substitute(messages, '\d\+', '', 'g'))
|
|
Karsten Hopp |
0fad6e |
+ :" Test subclassing
|
|
Karsten Hopp |
0fad6e |
+ py3 << EOF
|
|
Karsten Hopp |
0fad6e |
+ class DupDict(vim.Dictionary):
|
|
Karsten Hopp |
0fad6e |
+ def __setitem__(self, key, value):
|
|
Karsten Hopp |
0fad6e |
+ super(DupDict, self).__setitem__(key, value)
|
|
Karsten Hopp |
0fad6e |
+ super(DupDict, self).__setitem__('dup_' + key, value)
|
|
Karsten Hopp |
0fad6e |
+ dd = DupDict()
|
|
Karsten Hopp |
0fad6e |
+ dd['a'] = 'b'
|
|
Karsten Hopp |
0fad6e |
+ EOF
|
|
Karsten Hopp |
0fad6e |
+ :$put =string(sort(keys(py3eval('dd'))))
|
|
Karsten Hopp |
0fad6e |
:"
|
|
Karsten Hopp |
0fad6e |
:" Test exceptions
|
|
Karsten Hopp |
0fad6e |
:fun Exe(e)
|
|
Karsten Hopp |
0fad6e |
*** ../vim-7.3.1060/src/testdir/test87.ok 2013-05-30 12:26:52.000000000 +0200
|
|
Karsten Hopp |
0fad6e |
--- src/testdir/test87.ok 2013-05-30 12:47:48.000000000 +0200
|
|
Karsten Hopp |
0fad6e |
***************
|
|
Karsten Hopp |
0fad6e |
*** 4,16 ****
|
|
Karsten Hopp |
0fad6e |
Vim(put):E684:
|
|
Karsten Hopp |
0fad6e |
[0, 'as''d', [1, 2, function('strlen'), {'a': 1}]]
|
|
Karsten Hopp |
0fad6e |
[0, function('strlen'), [1, 2, function('strlen'), {'a': 1}]]
|
|
Karsten Hopp |
0fad6e |
! ['-1', '1', 'b']
|
|
Karsten Hopp |
0fad6e |
'-1' : {'a': 1}
|
|
Karsten Hopp |
0fad6e |
'1' : 'asd'
|
|
Karsten Hopp |
0fad6e |
'b' : [1, 2, function('strlen')]
|
|
Karsten Hopp |
0fad6e |
[0, function('strlen')]
|
|
Karsten Hopp |
0fad6e |
[3]
|
|
Karsten Hopp |
0fad6e |
! {'1': 'asd', 'b': [1, 2, function('strlen')]}
|
|
Karsten Hopp |
0fad6e |
[0, 1, 2, 3]
|
|
Karsten Hopp |
0fad6e |
[0, 1, 2, 3]
|
|
Karsten Hopp |
0fad6e |
[0, 1, 3]
|
|
Karsten Hopp |
0fad6e |
--- 4,32 ----
|
|
Karsten Hopp |
0fad6e |
Vim(put):E684:
|
|
Karsten Hopp |
0fad6e |
[0, 'as''d', [1, 2, function('strlen'), {'a': 1}]]
|
|
Karsten Hopp |
0fad6e |
[0, function('strlen'), [1, 2, function('strlen'), {'a': 1}]]
|
|
Karsten Hopp |
0fad6e |
! [b'-1', b'0', b'1', b'b']
|
|
Karsten Hopp |
0fad6e |
! [-1, <vim.dictionary object at >, <vim.list object at >, b'asd']
|
|
Karsten Hopp |
0fad6e |
! [(b'-1', <vim.dictionary object at >), (b'0', -1), (b'1', b'asd'), (b'b', <vim.list object at >)]
|
|
Karsten Hopp |
0fad6e |
'-1' : {'a': 1}
|
|
Karsten Hopp |
0fad6e |
+ '0' : -1
|
|
Karsten Hopp |
0fad6e |
'1' : 'asd'
|
|
Karsten Hopp |
0fad6e |
'b' : [1, 2, function('strlen')]
|
|
Karsten Hopp |
0fad6e |
[0, function('strlen')]
|
|
Karsten Hopp |
0fad6e |
[3]
|
|
Karsten Hopp |
0fad6e |
! [1, 2, function('strlen')]
|
|
Karsten Hopp |
0fad6e |
! [1, 2, function('strlen')]
|
|
Karsten Hopp |
0fad6e |
! 1
|
|
Karsten Hopp |
0fad6e |
! 'asd'
|
|
Karsten Hopp |
0fad6e |
! 2
|
|
Karsten Hopp |
0fad6e |
! True
|
|
Karsten Hopp |
0fad6e |
! False
|
|
Karsten Hopp |
0fad6e |
! True
|
|
Karsten Hopp |
0fad6e |
! False
|
|
Karsten Hopp |
0fad6e |
! [b'0']
|
|
Karsten Hopp |
0fad6e |
! {'0': -1}
|
|
Karsten Hopp |
0fad6e |
! (b'', -1)
|
|
Karsten Hopp |
0fad6e |
! None
|
|
Karsten Hopp |
0fad6e |
! []
|
|
Karsten Hopp |
0fad6e |
[0, 1, 2, 3]
|
|
Karsten Hopp |
0fad6e |
[0, 1, 2, 3]
|
|
Karsten Hopp |
0fad6e |
[0, 1, 3]
|
|
Karsten Hopp |
0fad6e |
***************
|
|
Karsten Hopp |
0fad6e |
*** 44,49 ****
|
|
Karsten Hopp |
0fad6e |
--- 60,67 ----
|
|
Karsten Hopp |
0fad6e |
ValueError
|
|
Karsten Hopp |
0fad6e |
TypeError
|
|
Karsten Hopp |
0fad6e |
TypeError
|
|
Karsten Hopp |
0fad6e |
+ KeyError
|
|
Karsten Hopp |
0fad6e |
+ KeyError
|
|
Karsten Hopp |
0fad6e |
d : locked:0;scope:0
|
|
Karsten Hopp |
0fad6e |
dl : locked:1;scope:0
|
|
Karsten Hopp |
0fad6e |
v: : locked:2;scope:1
|
|
Karsten Hopp |
0fad6e |
***************
|
|
Karsten Hopp |
0fad6e |
*** 376,385 ****
|
|
Karsten Hopp |
0fad6e |
window:__dir__,buffer,col,cursor,height,number,options,row,tabpage,valid,vars
|
|
Karsten Hopp |
0fad6e |
tabpage:__dir__,number,valid,vars,window,windows
|
|
Karsten Hopp |
0fad6e |
range:__dir__,append,end,start
|
|
Karsten Hopp |
0fad6e |
! dictionary:__dir__,keys,locked,scope
|
|
Karsten Hopp |
0fad6e |
list:__dir__,extend,locked
|
|
Karsten Hopp |
0fad6e |
function:__call__,__dir__,softspace
|
|
Karsten Hopp |
0fad6e |
output:__dir__,flush,softspace,write,writelines
|
|
Karsten Hopp |
0fad6e |
'
|
|
Karsten Hopp |
0fad6e |
abcdef
|
|
Karsten Hopp |
0fad6e |
line :
|
|
Karsten Hopp |
0fad6e |
--- 394,406 ----
|
|
Karsten Hopp |
0fad6e |
window:__dir__,buffer,col,cursor,height,number,options,row,tabpage,valid,vars
|
|
Karsten Hopp |
0fad6e |
tabpage:__dir__,number,valid,vars,window,windows
|
|
Karsten Hopp |
0fad6e |
range:__dir__,append,end,start
|
|
Karsten Hopp |
0fad6e |
! dictionary:__dir__,get,has_key,items,keys,locked,pop,popitem,scope,update,values
|
|
Karsten Hopp |
0fad6e |
list:__dir__,extend,locked
|
|
Karsten Hopp |
0fad6e |
function:__call__,__dir__,softspace
|
|
Karsten Hopp |
0fad6e |
output:__dir__,flush,softspace,write,writelines
|
|
Karsten Hopp |
0fad6e |
+ {}
|
|
Karsten Hopp |
0fad6e |
+ {'a': 1}
|
|
Karsten Hopp |
0fad6e |
+ {'a': 1}
|
|
Karsten Hopp |
0fad6e |
'
|
|
Karsten Hopp |
0fad6e |
abcdef
|
|
Karsten Hopp |
0fad6e |
line :
|
|
Karsten Hopp |
0fad6e |
***************
|
|
Karsten Hopp |
0fad6e |
*** 387,392 ****
|
|
Karsten Hopp |
0fad6e |
--- 408,414 ----
|
|
Karsten Hopp |
0fad6e |
abc
|
|
Karsten Hopp |
0fad6e |
line :
|
|
Karsten Hopp |
0fad6e |
abc'
|
|
Karsten Hopp |
0fad6e |
+ ['a', 'dup_a']
|
|
Karsten Hopp |
0fad6e |
(<class 'vim.error'>, error('abc',))
|
|
Karsten Hopp |
0fad6e |
(<class 'vim.error'>, error('def',))
|
|
Karsten Hopp |
0fad6e |
(<class 'vim.error'>, error('ghi',))
|
|
Karsten Hopp |
0fad6e |
*** ../vim-7.3.1060/src/version.c 2013-05-30 12:43:50.000000000 +0200
|
|
Karsten Hopp |
0fad6e |
--- src/version.c 2013-05-30 12:59:48.000000000 +0200
|
|
Karsten Hopp |
0fad6e |
***************
|
|
Karsten Hopp |
0fad6e |
*** 730,731 ****
|
|
Karsten Hopp |
0fad6e |
--- 730,733 ----
|
|
Karsten Hopp |
0fad6e |
{ /* Add new patch number below this line */
|
|
Karsten Hopp |
0fad6e |
+ /**/
|
|
Karsten Hopp |
0fad6e |
+ 1061,
|
|
Karsten Hopp |
0fad6e |
/**/
|
|
Karsten Hopp |
0fad6e |
|
|
Karsten Hopp |
0fad6e |
--
|
|
Karsten Hopp |
0fad6e |
How To Keep A Healthy Level Of Insanity:
|
|
Karsten Hopp |
0fad6e |
4. Put your garbage can on your desk and label it "in".
|
|
Karsten Hopp |
0fad6e |
|
|
Karsten Hopp |
0fad6e |
/// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\
|
|
Karsten Hopp |
0fad6e |
/// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
|
|
Karsten Hopp |
0fad6e |
\\\ an exciting new programming language -- http://www.Zimbu.org ///
|
|
Karsten Hopp |
0fad6e |
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///
|