aboutsummaryrefslogtreecommitdiff
path: root/include/param.h
blob: d0b5bf0940bb19e8b675946da1627be1a3e60f81 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#pragma once

#include <stdint.h>
#include "sockbuf.h"

typedef struct httpd_req httpd_req_t;

typedef uint32_t color_int_t;
typedef uint8_t fraction_t;
typedef uint16_t ratio_t;

#define DECL_PARAMETER_INSTANCE(ty) \
  void handle_option__##ty(const char* attr, sockbuf_t* sockbuf, ty* ptr); \
  size_t serialize_to_json__##ty(                                     \
      char** out, size_t len, const char* attr, const char* display_name, \
      ty value);                                                       \
  void http_handle__##ty(httpd_req_t* req, ty* val);                   \
  void print__##ty(sockbuf_t* sockbuf, const char* attr, ty v);

#define cmd_handle(ty) handle_option__##ty
#define http_handle(ty) http_handle__##ty
#define serialize_to_json(ty) serialize_to_json__##ty
#define print(ty) print__##ty

DECL_PARAMETER_INSTANCE(uint8_t);
DECL_PARAMETER_INSTANCE(bool);
DECL_PARAMETER_INSTANCE(uint32_t);
DECL_PARAMETER_INSTANCE(color_int_t);
DECL_PARAMETER_INSTANCE(fraction_t);
DECL_PARAMETER_INSTANCE(ratio_t);
DECL_PARAMETER_INSTANCE(int);
DECL_PARAMETER_INSTANCE(int32_t);