Data Structures | Macros | Functions | Variables
helpers.c File Reference
#include <stdbool.h>
#include <inttypes.h>
#include <msgpack.h>
#include "nvim/api/private/dispatch.h"
#include "nvim/api/private/helpers.h"
#include "nvim/msgpack_rpc/helpers.h"
#include "nvim/lib/kvec.h"
#include "nvim/vim.h"
#include "nvim/log.h"
#include "nvim/memory.h"
#include "nvim/assert.h"

Data Structures

struct  MPToAPIObjectStackItem
 
struct  APIToMPObjectStackItem
 

Macros

#define HANDLE_TYPE_CONVERSION_IMPL(t, lt)
 
#define STR_CASE(type, attr, obj, dest, conv)
 
#define ID(x)   x
 

Functions

void msgpack_rpc_helpers_init (void)
 
bool msgpack_rpc_to_object (const msgpack_object *const obj, Object *const arg) FUNC_ATTR_NONNULL_ALL
 
bool msgpack_rpc_to_array (const msgpack_object *const obj, Array *const arg) FUNC_ATTR_NONNULL_ALL
 
bool msgpack_rpc_to_dictionary (const msgpack_object *const obj, Dictionary *const arg) FUNC_ATTR_NONNULL_ALL
 
void msgpack_rpc_from_boolean (Boolean result, msgpack_packer *res) FUNC_ATTR_NONNULL_ARG(2)
 
void msgpack_rpc_from_integer (Integer result, msgpack_packer *res) FUNC_ATTR_NONNULL_ARG(2)
 
void msgpack_rpc_from_float (Float result, msgpack_packer *res) FUNC_ATTR_NONNULL_ARG(2)
 
void msgpack_rpc_from_string (const String result, msgpack_packer *res) FUNC_ATTR_NONNULL_ARG(2)
 
void msgpack_rpc_from_object (const Object result, msgpack_packer *const res) FUNC_ATTR_NONNULL_ARG(2)
 
void msgpack_rpc_from_array (Array result, msgpack_packer *res) FUNC_ATTR_NONNULL_ARG(2)
 
void msgpack_rpc_from_dictionary (Dictionary result, msgpack_packer *res) FUNC_ATTR_NONNULL_ARG(2)
 
void msgpack_rpc_serialize_request (uint32_t request_id, const String method, Array args, msgpack_packer *pac) FUNC_ATTR_NONNULL_ARG(4)
 Serializes a msgpack-rpc request or notification(id == 0) More...
 
void msgpack_rpc_serialize_response (uint32_t response_id, Error *err, Object arg, msgpack_packer *pac) FUNC_ATTR_NONNULL_ARG(2
 Serializes a msgpack-rpc response. More...
 
void msgpack_pack_int (pac, 1)
 
 msgpack_pack_uint32 (pac, response_id)
 
 if (ERROR_SET(err))
 
 msgpack_rpc_from_object (arg, pac)
 
msgpack_object * msgpack_rpc_method (msgpack_object *req)
 
msgpack_object * msgpack_rpc_args (msgpack_object *req)
 
MessageType msgpack_rpc_validate (uint32_t *response_id, msgpack_object *req, Error *err)
 

Variables

 else
 

Macro Definition Documentation

#define HANDLE_TYPE_CONVERSION_IMPL (   t,
  lt 
)
#define ID (   x)    x
#define STR_CASE (   type,
  attr,
  obj,
  dest,
  conv 
)
Value:
case type: { \
dest = conv(((String) { \
.size = obj->via.attr.size, \
.data = (obj->via.attr.ptr == NULL || obj->via.attr.size == 0 \
? xmemdupz("", 0) \
: xmemdupz(obj->via.attr.ptr, obj->via.attr.size)), \
})); \
break; \
}
Definition: defs.h:76
return NULL
Definition: eval.c:23556
void * xmemdupz(const void *data, size_t len) FUNC_ATTR_MALLOC FUNC_ATTR_NONNULL_RET FUNC_ATTR_WARN_UNUSED_RESULT FUNC_ATTR_NONNULL_ALL
Definition: memory.c:196
err type
Definition: helpers.c:1468

Function Documentation

if ( ERROR_SET(err)  )
void msgpack_pack_int ( pac  ,
 
)
msgpack_pack_uint32 ( pac  ,
response_id   
)
msgpack_object* msgpack_rpc_args ( msgpack_object *  req)
void msgpack_rpc_from_array ( Array  result,
msgpack_packer *  res 
)
void msgpack_rpc_from_boolean ( Boolean  result,
msgpack_packer *  res 
)
void msgpack_rpc_from_dictionary ( Dictionary  result,
msgpack_packer *  res 
)
void msgpack_rpc_from_float ( Float  result,
msgpack_packer *  res 
)
void msgpack_rpc_from_integer ( Integer  result,
msgpack_packer *  res 
)
void msgpack_rpc_from_object ( const Object  result,
msgpack_packer *const  res 
)

Convert type used by Nvim API to msgpack type.

Parameters
[in]resultObject to convert.
[out]resStructure that defines where conversion results are saved.
Returns
true in case of success, false otherwise.
msgpack_rpc_from_object ( arg  ,
pac   
)
void msgpack_rpc_from_string ( const String  result,
msgpack_packer *  res 
)
void msgpack_rpc_helpers_init ( void  )
msgpack_object* msgpack_rpc_method ( msgpack_object *  req)
void msgpack_rpc_serialize_request ( uint32_t  request_id,
const String  method,
Array  args,
msgpack_packer *  pac 
)

Serializes a msgpack-rpc request or notification(id == 0)

void msgpack_rpc_serialize_response ( uint32_t  response_id,
Error err,
Object  arg,
msgpack_packer *  pac 
)

Serializes a msgpack-rpc response.

bool msgpack_rpc_to_array ( const msgpack_object *const  obj,
Array *const  arg 
)
bool msgpack_rpc_to_dictionary ( const msgpack_object *const  obj,
Dictionary *const  arg 
)
bool msgpack_rpc_to_object ( const msgpack_object *const  obj,
Object *const  arg 
)

Convert type used by msgpack parser to Nvim API type.

Parameters
[in]objMsgpack value to convert.
[out]argLocation where result of conversion will be saved.
Returns
true in case of success, false otherwise.
MessageType msgpack_rpc_validate ( uint32_t *  response_id,
msgpack_object *  req,
Error err 
)

Variable Documentation

else
Initial value:
{
msgpack_pack_nil(pac)