| 1 | /*========================== begin_copyright_notice ============================ |
| 2 | |
| 3 | Copyright (C) 2017-2021 Intel Corporation |
| 4 | |
| 5 | SPDX-License-Identifier: MIT |
| 6 | |
| 7 | ============================= end_copyright_notice ===========================*/ |
| 8 | |
| 9 | /*========================== begin_copyright_notice ============================ |
| 10 | |
| 11 | This file is distributed under the University of Illinois Open Source License. |
| 12 | See LICENSE.TXT for details. |
| 13 | |
| 14 | ============================= end_copyright_notice ===========================*/ |
| 15 | |
| 16 | #include "../headers/clang_tb.h" |
| 17 | #include "secure_mem.h" |
| 18 | |
| 19 | namespace TC { |
| 20 | |
| 21 | TRANSLATION_BLOCK_API void Register(STB_RegisterArgs *pRegisterArgs) { |
| 22 | pRegisterArgs->Version = TC::STB_VERSION; |
| 23 | uint32_t maxNumTranslationCodes = sizeof(g_cClangTranslationCodes) / sizeof(STB_TranslationCode); |
| 24 | |
| 25 | if (pRegisterArgs->pTranslationCodes != NULL) { |
| 26 | memcpy_s(pRegisterArgs->pTranslationCodes, pRegisterArgs->NumTranslationCodes * sizeof(STB_TranslationCode), |
| 27 | g_cClangTranslationCodes, sizeof(g_cClangTranslationCodes)); |
| 28 | } else { |
| 29 | pRegisterArgs->NumTranslationCodes = maxNumTranslationCodes; |
| 30 | } |
| 31 | } |
| 32 | |
| 33 | TRANSLATION_BLOCK_API CTranslationBlock *Create(STB_CreateArgs *pCreateArgs) { |
| 34 | CClangTranslationBlock *pClangTranslationBlock; |
| 35 | STB_TranslateOutputArgs pOutputArgs{}; |
| 36 | |
| 37 | CClangTranslationBlock::Create(pCreateArgs, &pOutputArgs, pClangTranslationBlock); |
| 38 | |
| 39 | return pClangTranslationBlock; |
| 40 | } |
| 41 | |
| 42 | TRANSLATION_BLOCK_API void Delete(CTranslationBlock *pTranslationBlock) { |
| 43 | CClangTranslationBlock *pClangTranslationBlock = (CClangTranslationBlock *)pTranslationBlock; |
| 44 | |
| 45 | CClangTranslationBlock::Delete(pClangTranslationBlock); |
| 46 | } |
| 47 | |
| 48 | } // namespace TC |