From 880957ad4e3fc0ff681025f5e29c5eccf797c564 Mon Sep 17 00:00:00 2001 From: ZyX Date: Sat, 10 May 2014 00:53:36 +0400 Subject: Move documentation from function declarations to definitions Uses a perl script to move it (scripts/movedocs.pl) --- src/nvim/os/wstream.c | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) (limited to 'src/nvim/os/wstream.c') diff --git a/src/nvim/os/wstream.c b/src/nvim/os/wstream.c index 57afdd0e8f..b5c396b50c 100644 --- a/src/nvim/os/wstream.c +++ b/src/nvim/os/wstream.c @@ -32,6 +32,11 @@ typedef struct { static void write_cb(uv_write_t *req, int status); +/// Creates a new WStream instance. A WStream encapsulates all the boilerplate +/// necessary for writing to a libuv stream. +/// +/// @param maxmem Maximum amount memory used by this `WStream` instance. +/// @return The newly-allocated `WStream` instance WStream * wstream_new(size_t maxmem) { WStream *rv = xmalloc(sizeof(WStream)); @@ -44,6 +49,9 @@ WStream * wstream_new(size_t maxmem) return rv; } +/// Frees all memory allocated for a WStream instance +/// +/// @param wstream The `WStream` instance void wstream_free(WStream *wstream) { if (!wstream->pending_reqs) { @@ -53,12 +61,23 @@ void wstream_free(WStream *wstream) } } +/// Sets the underlying `uv_stream_t` instance +/// +/// @param wstream The `WStream` instance +/// @param stream The new `uv_stream_t` instance void wstream_set_stream(WStream *wstream, uv_stream_t *stream) { handle_set_wstream((uv_handle_t *)stream, wstream); wstream->stream = stream; } +/// Queues data for writing to the backing file descriptor of a `WStream` +/// instance. This will fail if the write would cause the WStream use more +/// memory than specified by `maxmem`. +/// +/// @param wstream The `WStream` instance +/// @param buffer The buffer which contains data to be written +/// @return false if the write failed bool wstream_write(WStream *wstream, WBuffer *buffer) { WriteData *data; @@ -87,6 +106,15 @@ bool wstream_write(WStream *wstream, WBuffer *buffer) return true; } +/// Creates a WBuffer object for holding output data. Instances of this +/// object can be reused across WStream instances, and the memory is freed +/// automatically when no longer needed(it tracks the number of references +/// internally) +/// +/// @param data Data stored by the WBuffer +/// @param size The size of the data array +/// @param copy If true, the data will be copied into the WBuffer +/// @return The allocated WBuffer instance WBuffer *wstream_new_buffer(char *data, size_t size, bool copy) { WBuffer *rv = xmalloc(sizeof(WBuffer)); -- cgit From 70929f7e1616bab2783cc5735c6061981cda8a0f Mon Sep 17 00:00:00 2001 From: ZyX Date: Sat, 10 May 2014 17:24:13 +0400 Subject: 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. --- src/nvim/os/wstream.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'src/nvim/os/wstream.c') 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. /// -- cgit From dca28e55c7f798238e693d6db56da201c8d6dc29 Mon Sep 17 00:00:00 2001 From: ZyX Date: Sun, 1 Jun 2014 02:11:35 +0400 Subject: Fix some styles --- src/nvim/os/wstream.c | 1 + 1 file changed, 1 insertion(+) (limited to 'src/nvim/os/wstream.c') diff --git a/src/nvim/os/wstream.c b/src/nvim/os/wstream.c index 899b97da7e..c2ed05b78f 100644 --- a/src/nvim/os/wstream.c +++ b/src/nvim/os/wstream.c @@ -34,6 +34,7 @@ typedef struct { #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. /// -- cgit