-
Notifications
You must be signed in to change notification settings - Fork 16
/
file.js
123 lines (108 loc) · 2.28 KB
/
file.js
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
114
115
116
117
118
119
120
121
122
123
/*
* Copyright (c) 2022 ACOAUTO Team.
* All rights reserved.
*
* Detailed license information can be found in the LICENSE file.
*
* File: file.js C & H file template.
*
* Author: Han.hui <hanhui@acoinfo.com>
*
*/
/* Configure */
const CONF = global.CONF;
/*
* C File Header
*/
exports.C_HEADER =
`/*
* Copyright (c) 2022 ACOAUTO Team.
* All rights reserved.
*
* Detailed license information can be found in the LICENSE file.
*
* File: ${CONF.name}_jstruct.c ${CONF.name} JSON <-> C struct.
*
* Date: ${new Date().toString()}
*
* This file is automatically generated by the jstruct tool, please do not modify.
*
* Author: Han.hui <hanhui@acoinfo.com>
*
*/
#include <string.h>
#include ${CONF.platform === 'autosar' ? '"vsoa.h"' : '<stdlib.h>'}
#include "yyjson.h"
#include "${CONF.name}_jstruct.h"
`;
/*
* C File Footer
*/
exports.C_FOOTER =
`/*
* end
*/
`;
/*
* H File Header
*/
exports.H_HEADER =
`/*
* Copyright (c) 2022 ACOAUTO Team.
* All rights reserved.
*
* Detailed license information can be found in the LICENSE file.
*
* File: ${CONF.name}_jstruct.h ${CONF.name} JSON <-> C struct.
*
* Date: ${new Date().toString()}
*
* This file is automatically generated by the jstruct tool, please do not modify.
*
* Author: Han.hui <hanhui@acoinfo.com>
*
*/
#ifndef ${CONF.name.toUpperCase()}_JSTRUCT_H
#define ${CONF.name.toUpperCase()}_JSTRUCT_H
#include <stddef.h>
#include <stdint.h>
#include <stdbool.h>
`;
/*
* H C++ Extern Start
*/
exports.H_CPP_START = `
#ifdef __cplusplus
extern "C" {
#endif
`;
/*
* H C++ Extern End
*/
exports.H_CPP_END = `
#ifdef __cplusplus
}
#endif
`;
/*
* H File Body
*/
exports.H_BODY = `
/* Deserialize the JSON string into a structure '${CONF.struct.name}' */
bool ${CONF.name}_json_parse(struct ${CONF.struct.name} *, const char *, size_t);
/* Free ${CONF.name}_json_parse() buffer, Warning: string type member can no longer be used */
void ${CONF.name}_json_parse_free(struct ${CONF.struct.name} *);
/* Serialize the structure '${CONF.struct.name}' into a JSON string */
char *${CONF.name}_json_stringify(const struct ${CONF.struct.name} *);
/* Free ${CONF.name}_json_stringify() return value */
void ${CONF.name}_json_stringify_free(char *);
`;
/*
* H File Footer
*/
exports.H_FOOTER = `
#endif /* ${CONF.name.toUpperCase()}_JSTRUCT_H */
/*
* end
*/
`;