2 #include "ypc/core_t/analyzer/helper/ecall_impl_helper.h"
3 #include "ypc/stbox/tsgx/util.h"
4 #include "ypc/version.h"
6 #define COMMON_PARSER_IMPL(pw) \
7 uint32_t begin_parse_data_item() { \
8 stbox::bytes hash(get_enclave_hash_size()); \
9 get_enclave_hash(hash.data(), hash.size()); \
11 pw.set_enclave_hash(hash.data(), hash.size()); \
13 return pw.begin_parse_data_item(); \
15 uint32_t end_parse_data_item() { return pw.end_parse_data_item(); } \
17 uint32_t get_enclave_hash_size() { return SGX_HASH_SIZE; } \
18 uint32_t get_enclave_hash(uint8_t *hash, uint32_t hash_size) { \
19 auto enclave_hash = stbox::get_enclave_hash(); \
20 memcpy(hash, enclave_hash.data(), hash_size); \
24 uint32_t get_analyze_result_size() { return pw.get_analyze_result_size(); } \
25 uint32_t get_analyze_result(uint8_t *res, uint32_t res_size) { \
26 return pw.get_analyze_result(res, res_size); \
28 uint32_t init_data_source(const uint8_t *data_source_info, uint32_t len) { \
29 return call_init_data_source_helper<decltype(pw)>::call( \
30 pw, data_source_info, len); \
32 uint32_t init_model(const uint8_t *model, uint32_t len) { \
33 return call_init_model_helper<decltype(pw)>::call(pw, model, len); \
35 uint32_t get_parser_type() { return pw.get_parser_type(); }
37 #define YPC_PARSER_IMPL(...) \
38 JOIN(YPC_PARSER_IMPL_, PP_NARG(__VA_ARGS__))(__VA_ARGS__)
40 #define YPC_PARSER_IMPL_1(pw) \
41 COMMON_PARSER_IMPL(pw) \
42 uint32_t parse_data_item(const uint8_t *input_param, uint32_t len) { \
43 return pw.parse_data_item(input_param, len); \