blob: 1814b5245268a2d6c4f5e9173819555dbb8b3205 [file] [log] [blame]
Adam Cozzette501ecec2023-09-26 14:36:20 -07001// Protocol Buffers - Google's data interchange format
2// Copyright 2023 Google LLC. All rights reserved.
3// https://developers.google.com/protocol-buffers/
4//
5// Redistribution and use in source and binary forms, with or without
6// modification, are permitted provided that the following conditions are
7// met:
8//
9// * Redistributions of source code must retain the above copyright
10// notice, this list of conditions and the following disclaimer.
11// * Redistributions in binary form must reproduce the above
12// copyright notice, this list of conditions and the following disclaimer
13// in the documentation and/or other materials provided with the
14// distribution.
15// * Neither the name of Google LLC nor the names of its
16// contributors may be used to endorse or promote products derived from
17// this software without specific prior written permission.
18//
19// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
21// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
22// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
23// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
24// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
25// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
26// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
27// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
28// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
29// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30
Adam Cozzette12c7bb02023-09-28 12:54:11 -070031#ifndef UPB_GENERATOR_UPBDEV_H_
32#define UPB_GENERATOR_UPBDEV_H_
Adam Cozzette501ecec2023-09-26 14:36:20 -070033
34#include "upb/base/status.h"
35#include "upb/base/string_view.h"
36#include "upb/mem/arena.h"
37
38// Must be last.
39#include "upb/port/def.inc"
40
41#ifdef __cplusplus
42extern "C" {
43#endif
44
45// Consume |buf|, deserialize it to a Code_Generator_Request proto, construct a
Adam Cozzette12c7bb02023-09-28 12:54:11 -070046// upb_Code_Generator_Request, and return it as a JSON-encoded string.
Adam Cozzette501ecec2023-09-26 14:36:20 -070047UPB_API upb_StringView upbdev_ProcessInput(const char* buf, size_t size,
48 upb_Arena* arena,
49 upb_Status* status);
50
51// Decode |buf| from JSON, serialize to wire format, and return it.
52UPB_API upb_StringView upbdev_ProcessOutput(const char* buf, size_t size,
53 upb_Arena* arena,
54 upb_Status* status);
55
56// Decode |buf| from JSON, serialize to wire format, and write it to stdout.
57UPB_API void upbdev_ProcessStdout(const char* buf, size_t size,
58 upb_Arena* arena, upb_Status* status);
59
60// The following wrappers allow the protoc plugins to call the above functions
61// without pulling in the entire pb_runtime library.
62UPB_API upb_Arena* upbdev_Arena_New(void);
63UPB_API void upbdev_Status_Clear(upb_Status* status);
64
65#ifdef __cplusplus
66} /* extern "C" */
67#endif
68
69#include "upb/port/undef.inc"
70
Adam Cozzette12c7bb02023-09-28 12:54:11 -070071#endif // UPB_GENERATOR_UPBDEV_H_