Adam Cozzette | 501ecec | 2023-09-26 14:36:20 -0700 | [diff] [blame] | 1 | // Protocol Buffers - Google's data interchange format |
| 2 | // Copyright 2023 Google LLC. All rights reserved. |
Adam Cozzette | 501ecec | 2023-09-26 14:36:20 -0700 | [diff] [blame] | 3 | // |
Hong Shin | b837d17 | 2023-11-07 13:24:59 -0800 | [diff] [blame] | 4 | // Use of this source code is governed by a BSD-style |
| 5 | // license that can be found in the LICENSE file or at |
| 6 | // https://developers.google.com/open-source/licenses/bsd |
Adam Cozzette | 501ecec | 2023-09-26 14:36:20 -0700 | [diff] [blame] | 7 | |
Adam Cozzette | 12c7bb0 | 2023-09-28 12:54:11 -0700 | [diff] [blame] | 8 | #ifndef UPB_GENERATOR_UPBDEV_H_ |
| 9 | #define UPB_GENERATOR_UPBDEV_H_ |
Adam Cozzette | 501ecec | 2023-09-26 14:36:20 -0700 | [diff] [blame] | 10 | |
| 11 | #include "upb/base/status.h" |
| 12 | #include "upb/base/string_view.h" |
| 13 | #include "upb/mem/arena.h" |
| 14 | |
| 15 | // Must be last. |
| 16 | #include "upb/port/def.inc" |
| 17 | |
| 18 | #ifdef __cplusplus |
| 19 | extern "C" { |
| 20 | #endif |
| 21 | |
| 22 | // Consume |buf|, deserialize it to a Code_Generator_Request proto, construct a |
Adam Cozzette | 12c7bb0 | 2023-09-28 12:54:11 -0700 | [diff] [blame] | 23 | // upb_Code_Generator_Request, and return it as a JSON-encoded string. |
Adam Cozzette | 501ecec | 2023-09-26 14:36:20 -0700 | [diff] [blame] | 24 | UPB_API upb_StringView upbdev_ProcessInput(const char* buf, size_t size, |
| 25 | upb_Arena* arena, |
| 26 | upb_Status* status); |
| 27 | |
Adam Cozzette | 501ecec | 2023-09-26 14:36:20 -0700 | [diff] [blame] | 28 | // Decode |buf| from JSON, serialize to wire format, and write it to stdout. |
| 29 | UPB_API void upbdev_ProcessStdout(const char* buf, size_t size, |
| 30 | upb_Arena* arena, upb_Status* status); |
| 31 | |
| 32 | // The following wrappers allow the protoc plugins to call the above functions |
| 33 | // without pulling in the entire pb_runtime library. |
| 34 | UPB_API upb_Arena* upbdev_Arena_New(void); |
| 35 | UPB_API void upbdev_Status_Clear(upb_Status* status); |
| 36 | |
| 37 | #ifdef __cplusplus |
| 38 | } /* extern "C" */ |
| 39 | #endif |
| 40 | |
| 41 | #include "upb/port/undef.inc" |
| 42 | |
Adam Cozzette | 12c7bb0 | 2023-09-28 12:54:11 -0700 | [diff] [blame] | 43 | #endif // UPB_GENERATOR_UPBDEV_H_ |