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

Data Structures

struct  MPToAPIObjectStackItem
 
struct  APIToMPObjectStackItem
 

Macros

#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

◆ ID

#define ID (   x)    x

◆ STR_CASE

#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; \
}

Function Documentation

◆ if()

if ( ERROR_SET(err)  )

◆ msgpack_pack_int()

void msgpack_pack_int ( pac  ,
 
)

◆ msgpack_pack_uint32()

msgpack_pack_uint32 ( pac  ,
response_id   
)

◆ msgpack_rpc_args()

msgpack_object* msgpack_rpc_args ( msgpack_object *  req)

◆ msgpack_rpc_from_array()

void msgpack_rpc_from_array ( Array  result,
msgpack_packer *  res 
)

◆ msgpack_rpc_from_boolean()

void msgpack_rpc_from_boolean ( Boolean  result,
msgpack_packer *  res 
)

◆ msgpack_rpc_from_dictionary()

void msgpack_rpc_from_dictionary ( Dictionary  result,
msgpack_packer *  res 
)

◆ msgpack_rpc_from_float()

void msgpack_rpc_from_float ( Float  result,
msgpack_packer *  res 
)

◆ msgpack_rpc_from_integer()

void msgpack_rpc_from_integer ( Integer  result,
msgpack_packer *  res 
)

◆ msgpack_rpc_from_object() [1/2]

msgpack_rpc_from_object ( arg  ,
pac   
)

◆ msgpack_rpc_from_object() [2/2]

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_string()

void msgpack_rpc_from_string ( const String  result,
msgpack_packer *  res 
)

◆ msgpack_rpc_helpers_init()

void msgpack_rpc_helpers_init ( void  )

◆ msgpack_rpc_method()

msgpack_object* msgpack_rpc_method ( msgpack_object *  req)

◆ msgpack_rpc_serialize_request()

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)

◆ msgpack_rpc_serialize_response()

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

Serializes a msgpack-rpc response.

◆ msgpack_rpc_to_array()

bool msgpack_rpc_to_array ( const msgpack_object *const  obj,
Array *const  arg 
)

◆ msgpack_rpc_to_dictionary()

bool msgpack_rpc_to_dictionary ( const msgpack_object *const  obj,
Dictionary *const  arg 
)

◆ msgpack_rpc_to_object()

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.

◆ msgpack_rpc_validate()

MessageType msgpack_rpc_validate ( uint32_t *  response_id,
msgpack_object *  req,
Error err 
)

Variable Documentation

◆ else

else
Initial value:
{
msgpack_pack_nil(pac)
type
err type
Definition: helpers.c:1043
String
Definition: defs.h:77
xmemdupz
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:201
NULL
return NULL
Definition: eval.c:10355