Commit Graph

81 Commits

Author SHA1 Message Date
Nicolas Hillegeer
6f30b25f45 eval: reimplement f_system() on top of os_system()
This evades the tempfile problem (unless of course one manually adds
redirects to the shell commandline, which some plugins seem to do, e.g.:
vim-easytags).
2014-07-27 14:00:44 -03:00
Nicolas Hillegeer
6cbda2cbf6 viml: re-add sha256() function
Was removed in #699 but actually doesn't have anything to do with security.
2014-07-21 19:29:29 +02:00
Nicolas Hillegeer
fb15cbbaea startuptime: always enable startuptime
Removes the STARTUPTIME define.
2014-07-20 16:59:57 -04:00
Thiago de Arruda
486c8e37c1 provider: Add support for python commands/functions
This uses the provider/scripting infrastructure to reintroduce python support
through the msgpack-rpc API.

A new 'initpython' option was added, and it must be set to a command that will
bootstrap the python provider the first time it's needed.
2014-07-17 11:37:41 -03:00
Thiago de Arruda
8a091e7f5c provider: Add support functions for calling external interpreters
This uses the provider module infrastructure to implement common code for
vimscript commands/functions that need to communicate with external
interpreters, eg: pydo, rubydo, pyfile, rubyfile, etc.
2014-07-17 11:37:41 -03:00
Thiago de Arruda
887d32e546 provider: New module used to expose extension points for core services
Introducing the concept of providers: co-processes that talk with the editor
through the remote API and provide implementation for one or more core
services.

The `provider_register` function and it's API wrapper can be used by channels
that want to self-register as a service provider.

Some old builtin vim features will be re-implemented as providers. The
`provider_has_feature` function is used to check if a provider
implementing a certain feature is available(It will be called by the `has`
vimscript function to check for features in a vim-compatible way)

This implements the provider module without exposing any extension points, which
will be done in future commits.
2014-07-17 11:37:08 -03:00
Thiago de Arruda
bce4c365bc job: No longer free the job data. It's now done by the exit callback 2014-07-17 11:30:01 -03:00
Thiago de Arruda
0e20afe37e wstream: Pass WBuffer refcount as a constructor parameter
This is required to handle broadcasting when the first write fails.

Ref: 11916b6b59 (commitcomment-6792287)
2014-07-17 11:30:01 -03:00
Nicolas Hillegeer
db7cd61f62 profiling: implement on top of os_hrtime()
Should be better than gettimeofday() since libuv uses higher resolution
clocks on most UNIX platforms. Libuv also tries to use monotonic clocks,
kernel bugs notwithstanding, which is another win over gettimeofday().

Necessary for Windows, which doesn't have gettimeofday(). In vanilla vim,
Windows uses QueryPerformanceCounter, which is the correct primitive for
this sort of things, but that was removed when slimming up the codebase.
Libuv uses QueryPerformanceCounter to implement uv_hrtime() on Windows so
the behaviour of vim profiling on Windows should now be the same.

The behaviour on Linux should be different (better) though, libuv uses more
accurate primitives than gettimeofday().

Other misc. changes:
- Added function attributes where relevant (const, pure, ...)
- Convert functions to receive scalars: Now that proftime_T is always a
  (uint64_t) scalar (and not a struct), it's clearer to convert the
  functions to receive it as such instead of a pointer to a scalar.
- Extract profiling funcs to profile.c: make everything clearer and reduces
  the size of the "catch-all" ex_cmds2.c
- Add profile.{c,h} to clint and -Wconv:
  - Don't use sprintf, use snprintf
  - Don't use long, use int16_t/int32_t/...
2014-07-16 17:12:34 +02:00
Pavel Platto
286ce271e7 Extract tempfile module from fileio
Though this module is relatively small it has very clear boundaries.
The last argument for extracting `tempfile` was the errors which I got
when I was writing unittests for it: `cimport './src/nvim/fileio.h'`
does not work for some reason.
2014-07-14 21:14:40 +02:00
Pavel Platto
29e0cd1571 Refactor vim_tempname
- temp_count is uint32_t now instead of long because it supposed to be
  at most 999999999 (comment on line 5227) temporary files. The most
  probably it was a long for compatibility with systems where int is
  16-bit.
- Use "nvim" as prefix for temp folder name instead of "v"
- Remove unused parameter from vim_tempname
2014-07-14 21:14:40 +02:00
Pavel Platto
47084ea765 Use strict function prototypes #945
`-Wstrict-prototypes` warn if a function is declared or defined without
specifying the argument types.

This warning disallow function prototypes with empty parameter list.
In C, a function declared with an empty parameter list accepts an
arbitrary number of arguments when being called. This is for historic
reasons; originally, C functions didn't have prototypes, as C evolved
from B, a typeless language. When prototypes were added, the original
typeless declarations were left in the language for backwards
compatibility.
Instead we should provide `void` in argument list to state
that function doesn't have arguments.

Also this warning disallow declaring type of the parameters after the
parentheses because Neovim header generator produce no declarations for
old-stlyle prototypes: it expects to find `{` after prototype.
2014-07-14 20:28:40 +02:00
Justin M. Keyes
180c84ed37 os_open: impl mch_open with libuv. ref #133
- use return value instead of open_req.result
- libuv uv_fs_open() returns `-errno` instead of always -1
- libuv always sets open_req.result to the return value, _except_ for OOM
  where it only sets the return value. So always use the return value.
- replace calls to mch_open macro.
- update call sites expecting -1 error
2014-07-14 09:04:54 -04:00
Brandon Coleman
a32df5e734 move defines from vim.h
buffer.h:
   buflist_getfile() flags
   buflist_new() flags
   buf_freeall() flags
   do_buffer() flags

charset.h:
   chartab[] flags

edit.h:
   in_cinkeys() flags
   change_indent() flags
   beginline() flags
   insertchar() flags
   nv_mousescroll() flags

eval.c
   AUTOLOAD_CHAR

eval.h:
   enum for vimvars[]

ex_cmds.h:
   do_ecmd
   read_viminfo flags

ex_cmds2.h:
   check_changed() flags
   do_source() flags

ex_cmds_defs.h:
   BAD_* flags

ex_docmd.h:
   VALID_PATH VALID_HEAD
   EXMODE_*
   do_cmdline() flags
added include

ex_getln.c
   *_ESC_CHARS definitions

ex_getln.h:
   history table flags - used by add_to_history()

fileio.h:
   readfile() flags
   event_T definition

getchar.h:
   ins_typebuf() flags
   KEYLEN_*

globals.h:
   NO_SCREEN
   NO_BUFFERS
   SEA_* defines
   current_SID flags
   hlf_T enum
   HL_FLAGS
   do_profiling() flags
   schar_T
   sattr_T

indent.h:
   set_indent() flags

macros.h:
   BINARY_FILE_IO flags

mbyte.h:
   MB_BYTE2LEN*
   ENC_*

memfile.h:
   mf_sync() flags

misc1.h:
   open_line() flags

message.h:
   do_dialog() flags
   vim_dialogyesno() flags
   DLG_BUTTON_*

normal.h:
   find_ident_under_cursor() flags

ops.h:
   do_put() flags
   operator ID's

option.h:
   buf_copy_options() flags
   OPT_* flags

os_unix.h:
   mch_nodetype() flags

quickfix.h:
   skip_vimgrep_pat() flags

regexp.h:
   vim_regcomp() flags
   values for reg_do_extmatch

search.h:
   do_search() flags
   search_regcomp() flags
   findmatchlimit() flags

syntax.h:
   HL_* flags
      HL_FOLD is used in buffer_defs.h but nvim
      compiles just fine with the defines in
      syntax.h

tag.h:
   do_tag() flags
   find_tags() flags

term.h:
   TBUFSZ flags
   MOUSE flags

ui.h:
   jump_to_mouse() flags

window.h:
   file_name_in_line() flags
   win_split() flags
   MIN_LINES
   MIN_COLUMNS

Remove VimClipboard which should have been removed with PR #921.
2014-07-12 14:26:55 +02:00
Will Stamper
1cdd4ff7f6 vim-patch:7.4.306 #842
Problem:    getchar(0) does not return Esc.
Solution:   Do not wait for an Esc sequence to be complete.  (Yasuhiro
            Matsumoto)

https://code.google.com/p/vim/source/detail?r=05e1d8afcc5e375bf708ccc9810e2fd1a5a8a3cf
2014-07-11 16:42:45 -04:00
Nicolas Hillegeer
94f488d1ca c99: remove vim_round #909
C89 did not have round(), vim emulated it with vim_round. But since we're
using C99 this is not a problem anymore.
2014-07-11 13:10:59 -04:00
Brandon Coleman
0fff487690 move errno.h include out of vim.h 2014-07-09 00:18:20 +02:00
Brandon Coleman
b94d07b046 move stdarg.h include out of vim.h 2014-07-09 00:18:19 +02:00
Brandon Coleman
bf219e1442 move <inttypes.h> include out of vim.h 2014-07-09 00:18:19 +02:00
Brandon Coleman
b18ca14ef8 move locale.h include out of vim.h 2014-07-09 00:18:19 +02:00
Brandon Coleman
82b71a3056 move ascii.h include out of vim.h 2014-07-09 00:18:18 +02:00
Brandon Coleman
a4f441e547 remove stdbool.h include from vim.h and globals.h 2014-07-09 00:18:17 +02:00
Klemen Košir
a568e8b644 Replaced most TRUE/FALSE macros in arabic, mbyte and spell. #645 2014-07-08 17:34:08 +00:00
Klemen Košir
ef34a0ab13 Replace int with bool in some files. #654 2014-07-08 17:25:48 +00:00
Felipe Oliveira Carvalho
5ed74cfb7c Introduce ga_append_via_ptr() and GA_APPEND_VIA_PTR()
Similar to GA_APPEND(). Replaces this pattern:

    ga_grow(&ga, 1);
    item_type *p = ((item_type *)ga.ga_data) + ga.ga_len;
    p->field1 = v1;
    p->field2 = v2;
    ga.ga_len++;
2014-06-30 03:57:50 -04:00
Felipe Oliveira Carvalho
45e7814e6a Introduce GA_APPEND()
This macro is used to append an element to a growable array. It replaces this
common idiom:

   ga_grow(&ga, 1);
   ((item_type *)ga.ga_data)[ga.ga_len] = item;
   ++ga.ga_len;
2014-06-30 03:57:50 -04:00
Nicolas Hillegeer
8c51804d52 libcall: remove libcall ifdefs
Remove all the legacy code that related to mch_libcall in some way.
os_libcall is implemented on top of libuv now.
2014-06-28 14:44:17 -04:00
Nicolas Hillegeer
99163c9f13 os: implement VimL libcall with {mch,os}_libcall
The old mch_libcall was removed from neovim. This is a partial
reimplementation on top of libuv. It doesn't catch exceptions (windows) nor
signals (unix) though, so it's quite a bit more prone to crashing if the
loadable library throws an exception or crashes. Still, it should be fine
for well-behaved libraries. Requested by @Shougo.
2014-06-28 14:42:59 -04:00
Thiago de Arruda
bc0380038e channel/msgpack_rpc: Refactor to better split functions across modules
Move validation/conversion functions and to msgpack_rpc_helpers to separate
those from the functions that are used from the channel module
2014-06-24 13:02:24 -03:00
Thiago de Arruda
ea7a389ec7 channel: Implement the 'channel_send_call' function
This function is used to send RPC calls to clients. In contrast to
`channel_send_event`, this function will block until the client sends a
response(But it will continue processing requests from that client).

The RPC call stack has a maximum depth of 20.
2014-06-24 13:02:24 -03:00
Thiago de Arruda
0dea2682dc job: Add a maxmem parameter to job_start
The value is forwarded to it's own WStream instance
2014-06-24 13:02:24 -03:00
Thiago de Arruda
0fd46ae8f0 job: Fix vimscript wrapper by returning when an invalid id is passed 2014-06-24 13:02:23 -03:00
oni-link
937c78fe2e vim-patch:7.4.298 #815
Problem:    Can't have a funcref start with "t:".
Solution:   Add "t" to the list of accepted names. (Yukihiro Nakadaira)

https://code.google.com/p/vim/source/detail?r=156f891d520e93eab5d3ce02784660fb13a3b0d3
2014-06-20 02:28:51 -04:00
Will Stamper
3141c02c02 coverity/68215: removed failed variable + dead code from f_readfile #860 2014-06-18 23:57:05 -04:00
Nikolay Orlyuk
ec72b7adc7 spatch to drop check after alloc/lalloc/xmalloc #690 2014-06-18 19:21:01 -04:00
Thiago de Arruda
20fda27cda api: Change type of event data to Object from typval_T 2014-06-18 11:36:07 -03:00
Thiago de Arruda
abc423983d job: Refactor job_write to receive WBuffer instances.
This was done to give more control over memory management to job_write callers.
2014-06-18 11:36:07 -03:00
Thiago de Arruda
287967a2c0 job: Add defer flag and setter method
This is has the same effect as the RStream 'defer' flag, but also works for the
job's exit event.
2014-06-18 11:36:07 -03:00
Thiago de Arruda
71d9899f3c job: Refactor to use pointers instead of ids
'job_start' returns the id as an out paramter, and the 'job_find' function is
now used by eval.c to translate job ids into pointers.
2014-06-18 11:36:07 -03:00
Felipe Oliveira Carvalho
e85598e5a9 Remove unnecessary comments and unnecessary return 2014-06-16 01:40:29 -03:00
Felipe Oliveira Carvalho
238fa72884 No OOM for list_alloc() 2014-06-16 01:40:28 -03:00
Felipe Oliveira Carvalho
3cb3c20b74 Fix some "out of memory" comments and few cosmetics 2014-06-16 01:40:28 -03:00
Felipe Oliveira Carvalho
85100bb01d No OOM in concat_str() (few remaining cases)
Also fixed the duplicated declaration (path.c and strings.c)
2014-06-16 01:40:27 -03:00
Felipe Oliveira Carvalho
3a9a76c996 No OOM in vim_strsave_escape_csi() 2014-06-16 01:36:32 -03:00
Felipe Oliveira Carvalho
a26a1697c7 No OOM in home_replace_save() 2014-06-16 01:36:32 -03:00
Felipe Oliveira Carvalho
8234f2839f No OOM in vim_strsave_escaped[_ext]() 2014-06-16 01:36:31 -03:00
Felipe Oliveira Carvalho
9e7d06da41 No OOM in autoload_name() 2014-06-16 01:31:36 -03:00
Felipe Oliveira Carvalho
129db629dd No OOM in list_insert_tv() and list_extend() 2014-06-16 01:31:35 -03:00
Felipe Oliveira Carvalho
dd57e64794 No OOM in listitem_alloc() 2014-06-16 01:31:35 -03:00
Felipe Oliveira Carvalho
2d092cc229 No OOM in dictitem_copy 2014-06-16 01:31:35 -03:00