1 // Protocol Buffers - Google's data interchange format
2 // Copyright 2008 Google Inc. All rights reserved.
3 //
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
7
8 // This header is private to the ProtobolBuffers library and must NOT be
9 // included by any sources outside this library. The contents of this file are
10 // subject to change at any time without notice.
11
12 #import "GPBMessage.h"
13
14 // TODO: Remove this import. Older generated code use the OSAtomic* apis,
15 // so anyone that hasn't regenerated says building by having this. After
16 // enough time has passed, this likely can be removed as folks should have
17 // regenerated.
18 #import <libkern/OSAtomic.h>
19
20 #import "GPBBootstrap.h"
21
22 typedef struct GPBMessage_Storage {
23 uint32_t _has_storage_[0];
24 } GPBMessage_Storage;
25
26 typedef struct GPBMessage_Storage *GPBMessage_StoragePtr;
27
GPBMessage()28 @interface GPBMessage () {
29 @package
30 // NOTE: Because of the +allocWithZone code using NSAllocateObject(),
31 // this structure should ideally always be kept pointer aligned where the
32 // real storage starts is also pointer aligned. The compiler/runtime already
33 // do this, but it may not be documented.
34
35 // A pointer to the actual fields of the subclasses. The actual structure
36 // pointed to by this pointer will depend on the subclass.
37 // All of the actual structures will start the same as
38 // GPBMessage_Storage with _has_storage__ as the first field.
39 // Kept public because static functions need to access it.
40 GPBMessage_StoragePtr messageStorage_;
41 }
42
43 // Gets an extension value without autocreating the result if not found. (i.e.
44 // returns nil if the extension is not set)
45 - (id)getExistingExtension:(GPBExtensionDescriptor *)extension;
46
47 // Parses a message of this type from the input and merges it with this
48 // message.
49 //
50 // `endingTag` should be zero if expected to consume to the end of input, but if
51 // the input is supposed to be a Group, it should be the endgroup tag to look for.
52 //
53 // Warning: This does not verify that all required fields are present in
54 // the input message.
55 // NOTE: This will throw if there is an error while parsing.
56 - (void)mergeFromCodedInputStream:(GPBCodedInputStream *)input
57 extensionRegistry:(id<GPBExtensionRegistry>)extensionRegistry
58 endingTag:(uint32_t)endingTag;
59
60 - (void)addUnknownMapEntry:(int32_t)fieldNum value:(NSData *)data;
61
62 @end
63
64 CF_EXTERN_C_BEGIN
65
66 // Returns whether |message| autocreated this message. This is NO if the message
67 // was not autocreated by |message| or if it has been mutated since
68 // autocreation.
69 BOOL GPBWasMessageAutocreatedBy(GPBMessage *message, GPBMessage *parent);
70
71 // Call this when you mutate a message. It will cause the message to become
72 // visible to its autocreator.
73 void GPBBecomeVisibleToAutocreator(GPBMessage *self);
74
75 // Call this when an array/dictionary is mutated so the parent message that
76 // autocreated it can react.
77 void GPBAutocreatedArrayModified(GPBMessage *self, id array);
78 void GPBAutocreatedDictionaryModified(GPBMessage *self, id dictionary);
79
80 // Clear the autocreator, if any. Asserts if the autocreator still has an
81 // autocreated reference to this message.
82 void GPBClearMessageAutocreator(GPBMessage *self);
83
84 // The data (or null) from the unknown fields of a message;
85 NSData *GPBMessageUnknownFieldsData(GPBMessage *self);
86
87 CF_EXTERN_C_END
88