This repository has been archived by the owner on Oct 24, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathflecs_json.h
114 lines (91 loc) · 2.62 KB
/
flecs_json.h
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
// Comment out this line when using as DLL
#define flecs_json_STATIC
#ifndef FLECS_JSON_H
#define FLECS_JSON_H
/* This generated file contains includes for project dependencies */
/*
)
(.)
.|.
| |
_.--| |--._
.-'; ;`-'& ; `&.
\ & ; & &_/
|"""---...---"""|
\ | | | | | | | /
`---.|.|.|.---'
* This file is generated by bake.lang.c for your convenience. Headers of
* dependencies will automatically show up in this file. Include bake_config.h
* in your main project file. Do not edit! */
#ifndef FLECS_JSON_BAKE_CONFIG_H
#define FLECS_JSON_BAKE_CONFIG_H
/* Headers of public dependencies */
#include <flecs.h>
#include <flecs_meta.h>
/* Convenience macro for exporting symbols */
#ifndef flecs_json_STATIC
#if flecs_json_EXPORTS && (defined(_MSC_VER) || defined(__MINGW32__))
#define FLECS_JSON_API __declspec(dllexport)
#elif flecs_json_EXPORTS
#define FLECS_JSON_API __attribute__((__visibility__("default")))
#elif defined _MSC_VER
#define FLECS_JSON_API __declspec(dllimport)
#else
#define FLECS_JSON_API
#endif
#else
#define FLECS_JSON_API
#endif
#endif
#ifdef __cplusplus
extern "C" {
#endif
FLECS_JSON_API
char* ecs_ptr_to_json(
ecs_world_t *world,
ecs_entity_t type,
void *ptr);
FLECS_JSON_API
char* ecs_entity_to_json(
ecs_world_t *world,
ecs_entity_t e,
ecs_type_t select);
FLECS_JSON_API
char* ecs_iter_to_json(
ecs_world_t *world,
ecs_iter_t *it,
ecs_iter_next_action_t iter_next,
ecs_type_t select);
FLECS_JSON_API
char* ecs_type_to_json(
ecs_world_t *world,
ecs_type_t type);
#ifdef __cplusplus
}
#endif
#ifdef __cplusplus
#ifndef FLECS_NO_CPP
namespace flecs {
template <typename T>
flecs::string to_json(flecs::world& world, flecs::entity_t type, T& data) {
char *str = ecs_ptr_to_json(world, type, &data);
return flecs::string(str);
}
template <typename T>
flecs::string to_json(flecs::world& world, flecs::entity type, T& data) {
return to_json(world, type.id(), data);
}
template <typename T>
flecs::string to_json(flecs::world& world, T& data) {
entity_t type = _::cpp_type<T>::id(world);
return flecs::to_json(world, type, data);
}
template <>
inline flecs::string to_json<flecs::entity>(flecs::world& world, flecs::entity& entity) {
char *str = ecs_entity_to_json(world, entity, nullptr);
return flecs::string(str);
}
}
#endif
#endif
#endif