parent
e1d3008eaf
commit
088fee7f28
5 changed files with 75 additions and 2 deletions
@ -0,0 +1,30 @@ |
|||||||
|
// Protocol Buffers - Google's data interchange format
|
||||||
|
// Copyright 2023 Google LLC. All rights reserved.
|
||||||
|
//
|
||||||
|
// Use of this source code is governed by a BSD-style
|
||||||
|
// license that can be found in the LICENSE file or at
|
||||||
|
// https://developers.google.com/open-source/licenses/bsd
|
||||||
|
|
||||||
|
#include "upb/message/compat.h" |
||||||
|
|
||||||
|
#include <stddef.h> |
||||||
|
#include <stdint.h> |
||||||
|
|
||||||
|
#include "upb/message/internal/extension.h" |
||||||
|
#include "upb/message/message.h" |
||||||
|
#include "upb/mini_table/extension.h" |
||||||
|
|
||||||
|
// Must be last.
|
||||||
|
#include "upb/port/def.inc" |
||||||
|
|
||||||
|
const upb_Message_Extension* upb_Message_FindExtensionByNumber( |
||||||
|
const upb_Message* msg, uint32_t field_number) { |
||||||
|
size_t count = 0; |
||||||
|
const upb_Message_Extension* ext = _upb_Message_Getexts(msg, &count); |
||||||
|
|
||||||
|
while (count--) { |
||||||
|
if (upb_MiniTableExtension_Number(ext->ext) == field_number) return ext; |
||||||
|
ext++; |
||||||
|
} |
||||||
|
return NULL; |
||||||
|
} |
@ -0,0 +1,37 @@ |
|||||||
|
// Protocol Buffers - Google's data interchange format
|
||||||
|
// Copyright 2023 Google LLC. All rights reserved.
|
||||||
|
//
|
||||||
|
// Use of this source code is governed by a BSD-style
|
||||||
|
// license that can be found in the LICENSE file or at
|
||||||
|
// https://developers.google.com/open-source/licenses/bsd
|
||||||
|
|
||||||
|
#ifndef UPB_MESSAGE_COMPAT_H_ |
||||||
|
#define UPB_MESSAGE_COMPAT_H_ |
||||||
|
|
||||||
|
#include <stdint.h> |
||||||
|
|
||||||
|
#include "upb/message/message.h" |
||||||
|
|
||||||
|
// Must be last.
|
||||||
|
#include "upb/port/def.inc" |
||||||
|
|
||||||
|
// upb does not support mixing minitables from different sources but these
|
||||||
|
// functions are still used by some existing users so for now we make them
|
||||||
|
// available here. This may or may not change in the future so do not add
|
||||||
|
// them to new code.
|
||||||
|
|
||||||
|
#ifdef __cplusplus |
||||||
|
extern "C" { |
||||||
|
#endif |
||||||
|
|
||||||
|
// Returns the extension with the given field number, or NULL on failure.
|
||||||
|
const upb_Message_Extension* upb_Message_FindExtensionByNumber( |
||||||
|
const upb_Message* msg, uint32_t field_number); |
||||||
|
|
||||||
|
#ifdef __cplusplus |
||||||
|
} /* extern "C" */ |
||||||
|
#endif |
||||||
|
|
||||||
|
#include "upb/port/undef.inc" |
||||||
|
|
||||||
|
#endif /* UPB_MESSAGE_COMPAT_H_ */ |
Loading…
Reference in new issue