diff options
author | ZyX <kp-pav@ya.ru> | 2014-05-10 17:24:13 +0400 |
---|---|---|
committer | Thiago de Arruda <tpadilha84@gmail.com> | 2014-06-02 11:04:17 -0300 |
commit | 70929f7e1616bab2783cc5735c6061981cda8a0f (patch) | |
tree | 4a947af96fa0bac749f843a41e7b6593dd2659c0 /src/nvim/os | |
parent | 880957ad4e3fc0ff681025f5e29c5eccf797c564 (diff) | |
download | rneovim-70929f7e1616bab2783cc5735c6061981cda8a0f.tar.gz rneovim-70929f7e1616bab2783cc5735c6061981cda8a0f.tar.bz2 rneovim-70929f7e1616bab2783cc5735c6061981cda8a0f.zip |
Add automatic generation of headers
- The 'stripdecls.py' script replaces declarations in all headers by includes to
generated headers.
`ag '#\s*if(?!ndef NEOVIM_).*((?!#\s*endif).*\n)*#ifdef INCLUDE_GENERATED'`
was used for this.
- Add and integrate gendeclarations.lua into the build system to generate the
required includes.
- Add -Wno-unused-function
- Made a bunch of old-style definitions ANSI
This adds a requirement: all type and structure definitions must be present
before INCLUDE_GENERATED_DECLARATIONS-protected include.
Warning: mch_expandpath (path.h.generated.h) was moved manually. So far it is
the only exception.
Diffstat (limited to 'src/nvim/os')
-rw-r--r-- | src/nvim/os/channel.c | 13 | ||||
-rw-r--r-- | src/nvim/os/channel.h | 17 | ||||
-rw-r--r-- | src/nvim/os/event.c | 5 | ||||
-rw-r--r-- | src/nvim/os/event.h | 11 | ||||
-rw-r--r-- | src/nvim/os/fs.c | 6 | ||||
-rw-r--r-- | src/nvim/os/input.c | 7 | ||||
-rw-r--r-- | src/nvim/os/input.h | 15 | ||||
-rw-r--r-- | src/nvim/os/job.c | 11 | ||||
-rw-r--r-- | src/nvim/os/job.h | 24 | ||||
-rw-r--r-- | src/nvim/os/job_defs.h | 1 | ||||
-rw-r--r-- | src/nvim/os/rstream.c | 11 | ||||
-rw-r--r-- | src/nvim/os/rstream.h | 27 | ||||
-rw-r--r-- | src/nvim/os/server.c | 6 | ||||
-rw-r--r-- | src/nvim/os/server.h | 12 | ||||
-rw-r--r-- | src/nvim/os/shell.c | 13 | ||||
-rw-r--r-- | src/nvim/os/shell.h | 6 | ||||
-rw-r--r-- | src/nvim/os/signal.c | 6 | ||||
-rw-r--r-- | src/nvim/os/signal.h | 8 | ||||
-rw-r--r-- | src/nvim/os/time.c | 4 | ||||
-rw-r--r-- | src/nvim/os/time.h | 8 | ||||
-rw-r--r-- | src/nvim/os/uv_helpers.c | 5 | ||||
-rw-r--r-- | src/nvim/os/uv_helpers.h | 16 | ||||
-rw-r--r-- | src/nvim/os/wstream.c | 4 | ||||
-rw-r--r-- | src/nvim/os/wstream.h | 14 |
24 files changed, 72 insertions, 178 deletions
diff --git a/src/nvim/os/channel.c b/src/nvim/os/channel.c index 5886620990..9a692cf9fe 100644 --- a/src/nvim/os/channel.c +++ b/src/nvim/os/channel.c @@ -38,16 +38,9 @@ static PMap(uint64_t) *channels = NULL; static PMap(cstr_t) *event_strings = NULL; static msgpack_sbuffer msgpack_event_buffer; -static void job_out(RStream *rstream, void *data, bool eof); -static void job_err(RStream *rstream, void *data, bool eof); -static void parse_msgpack(RStream *rstream, void *data, bool eof); -static void send_event(Channel *channel, char *type, typval_T *data); -static void broadcast_event(char *type, typval_T *data); -static void unsubscribe(Channel *channel, char *event); -static void close_channel(Channel *channel); -static void close_cb(uv_handle_t *handle); -static WBuffer *serialize_event(char *type, typval_T *data); -static Channel *register_channel(void); +#ifdef INCLUDE_GENERATED_DECLARATIONS +# include "os/channel.c.generated.h" +#endif /// Initializes the module void channel_init() diff --git a/src/nvim/os/channel.h b/src/nvim/os/channel.h index 47182594b1..240461d22e 100644 --- a/src/nvim/os/channel.h +++ b/src/nvim/os/channel.h @@ -8,18 +8,7 @@ #define EVENT_MAXLEN 512 -void channel_init(void); - -void channel_teardown(void); - -void channel_from_stream(uv_stream_t *stream); - -void channel_from_job(char **argv); - -bool channel_send_event(uint64_t id, char *type, typval_T *data); - -void channel_subscribe(uint64_t id, char *event); - -void channel_unsubscribe(uint64_t id, char *event); - +#ifdef INCLUDE_GENERATED_DECLARATIONS +# include "os/channel.h.generated.h" +#endif #endif // NVIM_OS_CHANNEL_H diff --git a/src/nvim/os/event.c b/src/nvim/os/event.c index a89dcdc2ed..dd2b9ba0d1 100644 --- a/src/nvim/os/event.c +++ b/src/nvim/os/event.c @@ -20,11 +20,12 @@ #define _destroy_event(x) // do nothing KLIST_INIT(Event, Event, _destroy_event) +#ifdef INCLUDE_GENERATED_DECLARATIONS +# include "os/event.c.generated.h" +#endif static klist_t(Event) *event_queue; static uv_timer_t timer; static uv_prepare_t timer_prepare; -static void timer_cb(uv_timer_t *handle); -static void timer_prepare_cb(uv_prepare_t *); void event_init() { diff --git a/src/nvim/os/event.h b/src/nvim/os/event.h index 345ddba27e..29e304adc8 100644 --- a/src/nvim/os/event.h +++ b/src/nvim/os/event.h @@ -7,12 +7,7 @@ #include "nvim/os/event_defs.h" #include "nvim/os/job_defs.h" -void event_init(void); -void event_teardown(void); -bool event_poll(int32_t ms); -bool event_is_pending(void); -void event_push(Event event); -void event_process(void); - +#ifdef INCLUDE_GENERATED_DECLARATIONS +# include "os/event.h.generated.h" +#endif #endif // NVIM_OS_EVENT_H - diff --git a/src/nvim/os/fs.c b/src/nvim/os/fs.c index a67e13ead1..bdf20f22eb 100644 --- a/src/nvim/os/fs.c +++ b/src/nvim/os/fs.c @@ -8,8 +8,9 @@ #include "nvim/path.h" #include "nvim/strings.h" -static bool is_executable(const char_u *name); -static bool is_executable_in_path(const char_u *name); +#ifdef INCLUDE_GENERATED_DECLARATIONS +# include "os/fs.c.generated.h" +#endif // Many fs functions from libuv return that value on success. static const int kLibuvSuccess = 0; @@ -349,4 +350,3 @@ bool os_file_info_id_equal(FileInfo *file_info_1, FileInfo *file_info_2) return file_info_1->stat.st_ino == file_info_2->stat.st_ino && file_info_1->stat.st_dev == file_info_2->stat.st_dev; } - diff --git a/src/nvim/os/input.c b/src/nvim/os/input.c index 95afa95d61..3e9751a4db 100644 --- a/src/nvim/os/input.c +++ b/src/nvim/os/input.c @@ -25,12 +25,11 @@ typedef enum { static RStream *read_stream; static bool eof = false, started_reading = false; -static InbufPollResult inbuf_poll(int32_t ms); -static void stderr_switch(void); -static void read_cb(RStream *rstream, void *data, bool eof); +#ifdef INCLUDE_GENERATED_DECLARATIONS +# include "os/input.c.generated.h" +#endif // Helper function used to push bytes from the 'event' key sequence partially // between calls to os_inchar when maxlen < 3 -static int push_event_key(uint8_t *buf, int maxlen); void input_init() { diff --git a/src/nvim/os/input.h b/src/nvim/os/input.h index 57602336d5..7543950b4f 100644 --- a/src/nvim/os/input.h +++ b/src/nvim/os/input.h @@ -4,16 +4,7 @@ #include <stdint.h> #include <stdbool.h> -void input_init(void); -bool input_ready(void); -void input_start(void); -void input_stop(void); -uint32_t input_read(char *buf, uint32_t count); -int os_inchar(uint8_t *, int, int32_t, int); -bool os_char_avail(void); -void os_breakcheck(void); - -bool os_isatty(int fd); - +#ifdef INCLUDE_GENERATED_DECLARATIONS +# include "os/input.h.generated.h" +#endif #endif // NVIM_OS_INPUT_H - diff --git a/src/nvim/os/job.c b/src/nvim/os/job.c index d19e009421..f9f94158ae 100644 --- a/src/nvim/os/job.c +++ b/src/nvim/os/job.c @@ -58,16 +58,11 @@ static uint32_t job_count = 0; static uv_prepare_t job_prepare; // Some helpers shared in this module -static bool is_alive(Job *job); -static Job * find_job(int id); -static void free_job(Job *job); +#ifdef INCLUDE_GENERATED_DECLARATIONS +# include "os/job.c.generated.h" +#endif // Callbacks for libuv -static void job_prepare_cb(uv_prepare_t *handle); -static void read_cb(RStream *rstream, void *data, bool eof); -static void exit_cb(uv_process_t *proc, int64_t status, int term_signal); -static void close_cb(uv_handle_t *handle); -static void emit_exit_event(Job *job); /// Initializes job control resources void job_init() diff --git a/src/nvim/os/job.h b/src/nvim/os/job.h index 3d4c14a14a..665bdffdb5 100644 --- a/src/nvim/os/job.h +++ b/src/nvim/os/job.h @@ -13,25 +13,7 @@ #include "nvim/os/event_defs.h" #include "nvim/os/rstream_defs.h" -void job_init(void); - -void job_teardown(void); - -int job_start(char **argv, - void *data, - rstream_cb stdout_cb, - rstream_cb stderr_cb, - job_exit_cb exit_cb); - -bool job_stop(int id); - -bool job_write(int id, char *data, uint32_t len); - -void job_exit_event(Event event); - -int job_id(Job *job); - -void *job_data(Job *job); - +#ifdef INCLUDE_GENERATED_DECLARATIONS +# include "os/job.h.generated.h" +#endif #endif // NVIM_OS_JOB_H - diff --git a/src/nvim/os/job_defs.h b/src/nvim/os/job_defs.h index 8e4dc0cd88..a9caa169a8 100644 --- a/src/nvim/os/job_defs.h +++ b/src/nvim/os/job_defs.h @@ -12,4 +12,3 @@ typedef struct job Job; typedef void (*job_exit_cb)(Job *job, void *data); #endif // NVIM_OS_JOB_DEFS_H - diff --git a/src/nvim/os/rstream.c b/src/nvim/os/rstream.c index be37204de6..9b2cea52a5 100644 --- a/src/nvim/os/rstream.c +++ b/src/nvim/os/rstream.c @@ -27,12 +27,9 @@ struct rstream { bool reading, free_handle, async; }; -// Callbacks used by libuv -static void alloc_cb(uv_handle_t *, size_t, uv_buf_t *); -static void read_cb(uv_stream_t *, ssize_t, const uv_buf_t *); -static void fread_idle_cb(uv_idle_t *); -static void close_cb(uv_handle_t *handle); -static void emit_read_event(RStream *rstream, bool eof); +#ifdef INCLUDE_GENERATED_DECLARATIONS +# include "os/rstream.c.generated.h" +#endif /// Creates a new RStream instance. A RStream encapsulates all the boilerplate /// necessary for reading from a libuv stream. @@ -226,6 +223,8 @@ void rstream_read_event(Event event) rstream->cb(rstream, rstream->data, event.data.rstream.eof); } +// Callbacks used by libuv + // Called by libuv to allocate memory for reading. static void alloc_cb(uv_handle_t *handle, size_t suggested, uv_buf_t *buf) { diff --git a/src/nvim/os/rstream.h b/src/nvim/os/rstream.h index b93430ebcf..059b2a5ce8 100644 --- a/src/nvim/os/rstream.h +++ b/src/nvim/os/rstream.h @@ -8,28 +8,7 @@ #include "nvim/os/event_defs.h" #include "nvim/os/rstream_defs.h" -RStream * rstream_new(rstream_cb cb, - size_t buffer_size, - void *data, - bool async); - -void rstream_free(RStream *rstream); - -void rstream_set_stream(RStream *rstream, uv_stream_t *stream); - -void rstream_set_file(RStream *rstream, uv_file file); - -bool rstream_is_regular_file(RStream *rstream); - -void rstream_start(RStream *rstream); - -void rstream_stop(RStream *rstream); - -size_t rstream_read(RStream *rstream, char *buffer, size_t count); - -size_t rstream_available(RStream *rstream); - -void rstream_read_event(Event event); - +#ifdef INCLUDE_GENERATED_DECLARATIONS +# include "os/rstream.h.generated.h" +#endif #endif // NVIM_OS_RSTREAM_H - diff --git a/src/nvim/os/server.c b/src/nvim/os/server.c index 18a941a264..b5d8d8af64 100644 --- a/src/nvim/os/server.c +++ b/src/nvim/os/server.c @@ -42,9 +42,9 @@ typedef struct { static PMap(cstr_t) *servers = NULL; -static void connection_cb(uv_stream_t *server, int status); -static void free_client(uv_handle_t *handle); -static void free_server(uv_handle_t *handle); +#ifdef INCLUDE_GENERATED_DECLARATIONS +# include "os/server.c.generated.h" +#endif /// Initializes the module void server_init() diff --git a/src/nvim/os/server.h b/src/nvim/os/server.h index 9023dd8b3d..43592a91e4 100644 --- a/src/nvim/os/server.h +++ b/src/nvim/os/server.h @@ -1,13 +1,7 @@ #ifndef NVIM_OS_SERVER_H #define NVIM_OS_SERVER_H -void server_init(); - -void server_teardown(); - -void server_start(char *endpoint); - -void server_stop(char *endpoint); - +#ifdef INCLUDE_GENERATED_DECLARATIONS +# include "os/server.h.generated.h" +#endif #endif // NVIM_OS_SERVER_H - diff --git a/src/nvim/os/shell.c b/src/nvim/os/shell.c index 5e02c3504b..766b055450 100644 --- a/src/nvim/os/shell.c +++ b/src/nvim/os/shell.c @@ -31,20 +31,13 @@ typedef struct { garray_T ga; } ProcessData; -static int tokenize(char_u *str, char **argv); -static int word_length(char_u *command); +#ifdef INCLUDE_GENERATED_DECLARATIONS +# include "os/shell.c.generated.h" +#endif -static void write_selection(uv_write_t *req); -static int proc_cleanup_exit(ProcessData *data, - uv_process_options_t *opts, - int shellopts); // Callbacks for libuv -static void alloc_cb(uv_handle_t *handle, size_t suggested, uv_buf_t *buf); -static void read_cb(uv_stream_t *stream, ssize_t cnt, const uv_buf_t *buf); -static void write_cb(uv_write_t *req, int status); -static void exit_cb(uv_process_t *proc, int64_t status, int term_signal); /// Builds the argument vector for running the shell configured in `sh` /// ('shell' option), optionally with a command that will be passed with `shcf` diff --git a/src/nvim/os/shell.h b/src/nvim/os/shell.h index a63fed7277..3d0e32bf67 100644 --- a/src/nvim/os/shell.h +++ b/src/nvim/os/shell.h @@ -17,11 +17,11 @@ typedef enum { kShellOptHideMess = 128, ///< previously a global variable from os_unix.c } ShellOpts; -char ** shell_build_argv(char_u *cmd, char_u *extra_shell_arg); -void shell_free_argv(char **argv); -int os_call_shell(char_u *cmd, ShellOpts opts, char_u *extra_shell_arg); +#ifdef INCLUDE_GENERATED_DECLARATIONS +# include "os/shell.h.generated.h" +#endif #endif // NVIM_OS_SHELL_H diff --git a/src/nvim/os/signal.c b/src/nvim/os/signal.c index 68a455c5a2..85aa8ae5cb 100644 --- a/src/nvim/os/signal.c +++ b/src/nvim/os/signal.c @@ -21,10 +21,10 @@ static uv_signal_t spwr; #endif static bool rejecting_deadly; -static char * signal_name(int signum); -static void deadly_signal(int signum); -static void signal_cb(uv_signal_t *, int signum); +#ifdef INCLUDE_GENERATED_DECLARATIONS +# include "os/signal.c.generated.h" +#endif void signal_init() { uv_signal_init(uv_default_loop(), &sint); diff --git a/src/nvim/os/signal.h b/src/nvim/os/signal.h index 6a0ad5e9ac..7cdde3c71a 100644 --- a/src/nvim/os/signal.h +++ b/src/nvim/os/signal.h @@ -3,11 +3,9 @@ #include "nvim/os/event_defs.h" -void signal_init(void); -void signal_stop(void); -void signal_accept_deadly(void); -void signal_reject_deadly(void); -void signal_handle(Event event); +#ifdef INCLUDE_GENERATED_DECLARATIONS +# include "os/signal.h.generated.h" +#endif #endif // NVIM_OS_SIGNAL_H diff --git a/src/nvim/os/time.c b/src/nvim/os/time.c index 66f9405510..977a4f19c4 100644 --- a/src/nvim/os/time.c +++ b/src/nvim/os/time.c @@ -11,8 +11,10 @@ static uv_mutex_t delay_mutex; static uv_cond_t delay_cond; -static void microdelay(uint64_t ms); +#ifdef INCLUDE_GENERATED_DECLARATIONS +# include "os/time.c.generated.h" +#endif /// Initializes the time module void time_init() { diff --git a/src/nvim/os/time.h b/src/nvim/os/time.h index 3b185825be..cfe7eb85ff 100644 --- a/src/nvim/os/time.h +++ b/src/nvim/os/time.h @@ -4,15 +4,13 @@ #include <stdint.h> #include <stdbool.h> -void time_init(void); -void os_delay(uint64_t milliseconds, bool ignoreinput); -void os_microdelay(uint64_t microseconds, bool ignoreinput); -struct tm *os_localtime_r(const time_t *clock, struct tm *result); -struct tm *os_get_localtime(struct tm *result); +#ifdef INCLUDE_GENERATED_DECLARATIONS +# include "os/time.h.generated.h" +#endif #endif // NVIM_OS_TIME_H diff --git a/src/nvim/os/uv_helpers.c b/src/nvim/os/uv_helpers.c index fa81fcdcc6..a3c9dd5fbf 100644 --- a/src/nvim/os/uv_helpers.c +++ b/src/nvim/os/uv_helpers.c @@ -13,7 +13,10 @@ typedef struct { Job *job; } HandleData; -static HandleData *init(uv_handle_t *handle); + +#ifdef INCLUDE_GENERATED_DECLARATIONS +# include "os/uv_helpers.c.generated.h" +#endif /// Gets the RStream instance associated with a libuv handle /// diff --git a/src/nvim/os/uv_helpers.h b/src/nvim/os/uv_helpers.h index ea797ba9f0..b49656bcb8 100644 --- a/src/nvim/os/uv_helpers.h +++ b/src/nvim/os/uv_helpers.h @@ -7,17 +7,7 @@ #include "nvim/os/rstream_defs.h" #include "nvim/os/job_defs.h" -RStream *handle_get_rstream(uv_handle_t *handle); - -void handle_set_rstream(uv_handle_t *handle, RStream *rstream); - -WStream *handle_get_wstream(uv_handle_t *handle); - -void handle_set_wstream(uv_handle_t *handle, WStream *wstream); - -Job *handle_get_job(uv_handle_t *handle); - -void handle_set_job(uv_handle_t *handle, Job *job); - +#ifdef INCLUDE_GENERATED_DECLARATIONS +# include "os/uv_helpers.h.generated.h" +#endif #endif // NVIM_OS_UV_HELPERS_H - diff --git a/src/nvim/os/wstream.c b/src/nvim/os/wstream.c index b5c396b50c..899b97da7e 100644 --- a/src/nvim/os/wstream.c +++ b/src/nvim/os/wstream.c @@ -30,8 +30,10 @@ typedef struct { WBuffer *buffer; } WriteData; -static void write_cb(uv_write_t *req, int status); +#ifdef INCLUDE_GENERATED_DECLARATIONS +# include "os/wstream.c.generated.h" +#endif /// Creates a new WStream instance. A WStream encapsulates all the boilerplate /// necessary for writing to a libuv stream. /// diff --git a/src/nvim/os/wstream.h b/src/nvim/os/wstream.h index e133ef1385..d0e9bef93a 100644 --- a/src/nvim/os/wstream.h +++ b/src/nvim/os/wstream.h @@ -7,15 +7,7 @@ #include "nvim/os/wstream_defs.h" -WStream * wstream_new(size_t maxmem); - -void wstream_free(WStream *wstream); - -void wstream_set_stream(WStream *wstream, uv_stream_t *stream); - -bool wstream_write(WStream *wstream, WBuffer *buffer); - -WBuffer *wstream_new_buffer(char *data, size_t size, bool copy); - +#ifdef INCLUDE_GENERATED_DECLARATIONS +# include "os/wstream.h.generated.h" +#endif #endif // NVIM_OS_WSTREAM_H - |